HSL2.0 - Initialisation phase
Content
1.
Introduction
2.
Example
2.1.
Case 1: Building block B1 is an HSL 1.0 building block
2.2.
Case 2: Block B1 is an HSL2.0 block

## 1.Introduction

Information on the behaviour of HSL2.0 blocks during initialisation and the correct procedure.
During initialisation the blocks are processed. The exact procedure is described in the HTML online help of the HS/FS Expert under "Start behaviour of the logic" (logikstart.html).
With an HSL 2.0 module, the following points/events must be observed, which take place in this order:

- The instantiation of the HSL 2.0 class takes place in the context of the logic.
- The method on_init() is executed in the context of the module. The calculation does not block the logic thread. HSL2.0 devices are always calculated on restart.
- For all input telegrams which arrive after the initialisation of a block, the method on_input_value() is executed in the context of the block. The calculation does not block the logic thread.

It follows that there are situations where HSL2.0 and HSL1.0 blocks behave differently.

## 2.Example

The diagram shows a simplified representation of two building blocks that are connected to each other and to several KOs:

- E1, E2: K-objects which are connected to the inputs of building block B1
- E3: K-object connected to one of the inputs of block B2
- A1: K-object connected to the output of block B2
- B1: An "AND gate" as HSL1.0 (block ID 9002) or HSL2.0 block (code example see here)
- B2: An "OR gate" as HSL1.0 module (module ID 9005)

### 2.1.Case 1: Building block B1 is an HSL1.0 building block

In this case the blocks B1 and B2 form a "calculation chain", which is processed from right to left during initialisation. (see already at the beginning mentioned docu "start behaviour of logic")
The values of KO connected to the inputs of block B1 are taken into account and the input of B2 receives the value during initialisation which is present at its output by calculation of block B1.
Conclusion: Module B2 fires exactly once after the end of the entire logic initialisation, namely the value which has been created by calculating the entire "chain".

### 2.2.Case 2: Block B1 is a HSL2.0 block

Block B1 is instantiated during the initialisation of the logic. At this point it is not possible to describe an output, so the "calculation chain" is interrupted.
In this case, the input of B2 receives the init value of the output of B1 during its initialisation and after completion of the logic initialisation the building block fires. All this takes place in the logic context.
Module B1 is calculated in parallel in the module context, the method on_init() is triggered and it fires. This value is placed in the queue of the logic context.
Conclusion: Block B2 fires once after the end of the logic initialisation, namely the value that was created using the init value from the output of block B1. When the logic queue is processed, block B2 fires a second time, this time using the value that resulted from the calculation of block B1.
Note
If an input is assigned an Init value which can never be received at this input during runtime (the Init value is outside the value range of the KO connected to the input), the value applied to the input can be compared with the Init value during initialisation (in the method on_init()) by means of self.get_input_value() and thus it can be determined whether the input has already been described by the KO before the calculation of the block.