Development of HS/FS logic modules
Content
1.
Disclaimer
2.
Introduction
3.
Create your own logic module
4.
Structure of the definition file
5.
Variable
6.
Calculation of a building block
7.
Start behaviour of the logic
8.
Notes on language syntax
9.
Troubleshooting
10.
Examples
11.
Publication

## 1.Disclaimer

Even though the documents have been prepared and checked with great care, errors cannot be completely ruled out. For this reason, the person placing the product on the market does not assume any legal responsibility or any guarantee with regard to the content.
We reserve the right to make technical changes!

## 2.Introduction

Since firmware 2.1, the HS/FS has the possibility to extend the logic functionality of the HS/FS by its own logic modules.

### 2.1.Number ranges

In order to avoid overlapping IDs of logic modules from different developers, we offer a central administration of number ranges.
To reserve a number range, please send us a corresponding request by email to logik [at] dacom-ha.de.

### 2.2.Further sources

Other important sources are the logic modules of other users. For a better understanding the study of other HSL files should serve very well.

### 2.3.Support

There is no support for self-created logic modules. You can send us suggestions at any time by e-mail: logik [at] dacom-ha.de

## 3.Create your own logic module

Each logic module can contain exactly one component. The modules are stored as individual files with the file extension HSL in the HS/FS Expert subdirectory \logic. How the definition file of a logic module has to look like is explained in this chapter.

### 3.1.Assigning a file name

The file name of a logic module consists of the module ID and a short description and has the file extension ".hsl". ID and short description are separated by an underscore.
Attention: Block ID
The block ID must be a five-digit number from the number range 10.000-19.999.
Note: Development ID
The numbers 10.000 to 10.999 are not used "publicly", i.e. every developer can use this number range during the development time (or for building blocks which he does not want to publish) as he likes, because these numbers are never used by other published blocks.
To avoid duplicate device IDs, there is the possibility to reserve a certain number range. This prevents several users from using the same numbers.
Note: IDs for published blocks
A number range, which you receive from us, is always in the range from 11.000 to 19.999.
This ensures that published block IDs do not overlap with private ones (number ranges from 10,000 to 10,999).
Example for a file name: 11001_Sinus.hsl.
Attention: Unique block ID
The block ID must be unique. This means that the block ID must not be used twice in the \logic directory. As soon as a block is used, the block ID must not be changed. So the block ID can only be changed arbitrarily before it is used in the project!

### 3.2.Include logic modules in project

If a logic module was copied into the HS/FS Expert subdirectory \logic, the HS/FS Expert must be restarted. Only after a restart does it recognise new modules. From the restart the new modules are available in the graphical logic editor.

#### 3.2.1.System paths

The full path to the \logic directory is usually

Expert Version | Path to the '\logic' directory
--- | ---
From Expert v2.4 | - Public Documents]\HS+FS Expert\logic or - [Public Documents]\HS-FS Expert\logic
From Expert v2.5 | - Public Documents]\HS+FS Expert [version]\logic or - [Public Documents]\HS-FS Expert [version]\logic
From Expert v2.10 | Public documents]\[Company]\HS+FS Expert [version]\logic

The [Public Documents] can be found here by default:

Windows version | Path
--- | ---
Windows XP | C:\Documents and Settings\All Users\Documents
Windows Vista / 7 / 8 / 10 | C:\Users\Public\Documents

The [Program Files] directory is usually located here:

Windows version | Path (32-bit Windows) | Path (64-bit Windows)
--- | --- | ---
Windows XP | C:\Programmes | C:\Programmes x(86)
Windows Vista / 7 / 8 / 10 | C:\Program files | C:\Program files x(86)

## 4.Structure of the definition file

A separate definition file is required for each logic module.
A definition file is structured line by line and each line consists of a record type and several property fields separated by the character "|".

Record type | Description | See chapter
--- | --- | ---
5000 | Information for the HS/FS expert | see here
4999 | Definition of foreign languages for the HS/FS expert | see here
5001 | Definition of the logic module | see here
5002 | Definition of an input | see here
5003 | Definition of an internal memory variable | see here
5004 | Definition of an output | see here
5012 | Definition of a formula | see here

Note: Comments
Comments are introduced with a "#" within the definition file.

### 4.1.Record type 5000 - Definition for HS/FS Expert

The following settings do not yet affect the functionality of the logic module. The line with record type 5000 only defines information required by the HS/FS expert.
This line may only occur once in the logic module and must be defined first within the file. All fields of type text are specified in inverted commas.

Field | Type | Description
--- | --- | ---
5000 | Number | Record type
Designation | Text | Name of the block in the HS/FS Expert. The structure in the HS/FS-Expert allows a categorisation of the blocks. Up to HS/FS Expert Version 2.3: A maximum of one category may be used! (Example: category a\category b\module would be invalid) From HS/FS-Expert version 2.4: Any category depth may be used! (Example: Cat1\Cat2\Cat3\Cat4\Block would be valid) Example without category: AND gate (2 inputs) Example with one category: Further modules\telegram generator
Remanent | Number | If this module is defined as remanent: 1 = yes 0 = no Attention: Remanent marking If the block is not marked as remanent here, variables marked as remanent are nevertheless volatile! (cf. record type 5003).
Number of inputs | Number | Number of defined inputs. (at least 1 input must be defined!)
Designation Input n | Text | All designations of the inputs. If a block contains 4 inputs, four designations are required. The individual input designations are in turn separated from each other by a "|" character.
Number of outputs | Number | Number of defined outputs. (at least 1 output must be defined!)
Designation Output n | Text | All designations of the outputs. If a block contains 4 outputs, four designations are required. The individual output designations are again separated from each other by a "|" character.
Version No. (from expert version 2.7) | Text | The text specified here is displayed in the GLE as a version number
No. of an input or 0 (from expert version 4.7) | Number | Use only for HSL 2.0 modules! HSL 2.0: Input used to specify the destination port for port forwarding. Otherwise: 0
No. of an input or 0 (from expert version 4.7) | Number | Use only for HSL 2.0 modules! HSL 2.0: Input used to specify the base path for port forwarding. Otherwise: 0

Example using an AND gate:
#5000|name+path in GLE|Remanent(1/0)|number of inputs|(names of inputs)|number of outputs|(names of outputs)
5000|"AND gate\2 inputs"|0|2|"E1"|"E2"|4|"A1"|"A2 neg"|"A3 (sbc)"|"A4 neg (sbc)"|"v1.23"|0|0
Example based on the on/off delay:
#5000|name+path in GLE|Remanent(1/0)|number of inputs|(names of inputs)|number of outputs|(names of outputs)
5000|"Delay\On/Off delay"|0|3|"E1 ON (sec.)"|"E2 OFF
(sec.)"|"E3 Signal"|2|"A1"|"A1 neg"|"v2.7.110721"|0|0

#### 4.1.1.Record type 4999 - Definition of several languages

Note: Optional specification
This record type is optional and is only required when using several languages in the HS/FS Expert.
Only the foreign languages need to be defined! For the language used in record type 5000 (usually German ("de")), no 4999 line needs to be created!
If the HS/FS expert uses a language that is not defined in the logic module by means of record type 4999, the texts from record type 5000 are displayed.
The logic block can only be displayed in languages that can be set in the expert. Therefore language definition lines of other languages cannot be used by the block!
For each foreign language exactly one 4999 line must be created!
Attention: Position of the definition line!
If this record type is used, the definition line must always be created after the definition line of record type 5000!

Field | Type | Description
--- | --- | ---
4999 | Number | Record type
Language abbreviation | Text | 2-digit language abbreviation of the respective language. In general: For each language the TLD (Top-Level-Domain) abbreviation of the country where the language is located is used. Exception: English, as in many places in the HS/FS Expert the abbreviation "en" has historically been used for English.
Designation | Text | Name of the block in the above mentioned language in the HS/FS Expert. The structure in the HS/FS Expert allows a categorisation of the building blocks. (see record type 5000)
Designation Input n | Text | All designations of the inputs. If a block contains 4 inputs, four designations are required. The individual input designations are in turn separated from each other by a "|" character.
Designation Output n | Text | All designations of the outputs. If a module contains 4 outputs, four designations are required. The individual output designations are again separated from each other by a "|" character.

Example using an AND-gate (language "English" = "en"):
#4999|language abbreviation|designation+path in GLE|(names of inputs)|(names of outputs)
`4999|"en"|"AND gate\2 inputs"|"i1"|"i2"|"o1"|"o2 neg"|"o3 (sbc)"|"o4 neg (sbc)"`
Example using the on/off delay (language "English" = "en"):
#4999|language abbreviation|description+path in GLE|(names of inputs)|(names of outputs)
`4999|"en"|"Delay\Switch on/off delay"|"i1 ON (sec.)"|"i2 OFF (sec.)"|"i3 Signal"|"o1"|"o1 neg"`
Example using an AND gate (language "French" = "fr"):
#4999|language abbreviation|description+path in GLE|(names of inputs)|(names of outputs)
`4999|"fr"|"Porte\ET, 2 entrées"|"e1"|"e2"|"s1"|"s2 neg"|"s3 (sbc)"|"s4 neg (sbc)"`
Example using the on/off delay (language "Italian" = "it"):
#4999|language abbreviation|description+path in GLE|(names of inputs)|(names of outputs)
`4999|"it"|"Ritardo\Ritardo di accensione/spegnimento"|"i1 ON (sec.)"|"i2 OFF (sec.)"|"i3 segnale"|"u1"|"u1 neg"
`

### 4.2.Record type 5001 - Definition of the block

Defines the properties of the module.
The following properties are necessary to define a module:

Field | Type | Description
--- | --- | ---
5001 | Number | Record type
Number of inputs | Number | At least one entrance must be available. See also record type 5002.
Number of outputs | Number | At least one output must be available. See also record type 5004.
Number of time memories | Number | Number of time memories used by the block. Time memories are used to restart the calculation of a block after a certain time. The execution time of a time memory can be overwritten during a calculation Here the value 0 is possible. The use of time memories is optional.
Number of memory variables | Number | Number of internal (local) memory variables used by the block A memory variable can be remanent. See also record type 5003. Here the value 0 is possible. The use of memory variables is optional.
Calculation at initialisation | Boolean (number) | Indicates whether the block is calculated during initialisation. See also Calculation of a block. Permitted values: 1 = yes 0 = no
Coded formula block (optional) | Boolean (number) | Indicates whether the block contains coded lines of type 5012. Permitted values: 1 = yes 0 = no not specified = no Note This parameter is used in connection with the program "Logikbaustein_AES256.exe"(docu). Note This parameter is required by the HS/FS expert so that the coded part of coded blocks is transferred to the HS/FS!

Example without specification of the KFB using an AND-gate:
#5001|Number of inputs|Number of outputs|Number of time memory|Number of memory variable|Calculation at Init.(y/n)|KFB(y/n)
5001|2|4|0|0|1|0
Example with specification of the KFB using the switch-on/switch-off delay:
#5001|Number of inputs|Number of outputs|Number of time memory|Number of memory variable|Calculation at Init.(y/n)|KFB(y/n)
5001|3|2|2|2|0|0|0

### 4.3.Record type 5002 - Definition of an input

Record type 5002 defines the characteristics of an input. For each input defined in record type 5000, one line of record type 5002 must be defined.

Field | Type | Description
--- | --- | ---
5002 | Number | Record type
Entrance | Number | The index of the input. (Starting with 1, continuous)
Init. value | Number / Text | Value assigned to the input during initialisation. If the input is of type "Text", the init. value must be set in inverted commas. Attention The type of the init. value must match the entry in the field "Data format"!
Data format | Number | Defines the format of the input. Permitted values: 0 = Numeric (default) 1 = text Numeric means integer or float value. Inputs which are defined as text inputs can only be assigned in the HS/FS Expert with K. objects or outputs which are also of the type text (e.g. 14-byte). Attention The type of the init. value must match the specification in the field "Data format"! The specification of the data format is only relevant for the HS/FS expert. The HS/FS recognises the data format by the init. value. The two specifications must therefore match!

Example using an AND gate:
#5002|Input|Init.value|Data format
5002|1|1|0
5002|2|1|0
Example based on the text length calculation:
#5002|Input|Init.value|data format
5002|1|""|1

### 4.4.Record type 5003 - Definition of a memory variable

The use of memory variables is optional. Memory variables are used for intermediate storage of values. Memory variables can also be remanent, i.e. they retain their value even after a restart.

Field | Type | Description
--- | --- | ---
5003 | Number | Record type
Memory | Number | The index of the variable. (Starting with 1, continuous)
Init. value | Number / Text | Value with which the variable is initialised. If the text is empty, "" must be entered.
Remanent (y/n) | Boolean (number) | Indicates whether the value of the variable is stored remanently. If remanent storage is used, the value of the variable is retained even after restarting. Permitted values: 1 = yes 0 = no If remanent memory variables are used, this must also be defined in record type 5000! Attention: Remanent marking If the block is not marked as remanent in record type 5000, the variable is not remanent even if 1 is set in this field! Note: Change the number of remanent memory variables If the number of remanent memories in the definition of a logic block is changed and the project with the changed block is transferred to the HS, all remanent data of the projected logic block instances of this block are discarded!

Note
Memory variables are local. Global variables can be implemented as follows:

- Connect outputs to inputs in the graphical logic editor.
- Connect internal or external knockout objects to inputs and outputs.

Example using an AND gate:
An AND gate does not require storage variables.
Example using the on/off delay:
#5003|Memory|Init.value|Remanent
5003|1|0|0
5003|2|1|0

### 4.5.Record type 5004 - Definition of an output

Record type 5004 defines the behaviour of a specific output. For each output defined in record type 5000, a line of record type 5004 must be defined.

Field | Type | Description
--- | --- | ---
5004 | Number | Record type
Output | Number | The index of the output. (Starting with 1, continuous)
Init. value | Number/Text | Value with which the output is initialised. If the output is of type "Text", the init. value must be set in inverted commas. Attention The type of the init. value must match the entry in the field "Data format"!
Rounding to binary | Boolean | Converts a value into the binary form (0 or 1). For each value <> 0, the output is set to 1. Permitted values: 1 = yes 0 = no
Output type | Number | Send / Send by Change Permitted values: 1 = output on calculation (send). The value is sent to the output with every calculation. 2 = output only in case of change (send by change). The value is only sent to the output if the value at the output would change as a result.
Data format | Number | Defines the format of the output. Permitted values: 0 = Numeric (standard) 1 = text Numeric means integer or float value Outputs which are defined as text outputs can only be assigned in the HS/FS Expert with K. objects or inputs which are also of the type text (e.g. 14 bytes). Attention The type of the Init. value must correspond to the specification in the field "Data format"! The specification of the data format is only relevant for the HS/FS expert. The HS/FS recognises the data format by the init. value. The two specifications must therefore match!

Example using an AND gate:
#5004|Output|Init. value|Binary|Type|Data format
5004|1|0|1|1|0
5004|2|0|1|1|0
5004|3|0|1|2|0
5004|4|0|1|2|0
Example using the "Integer to Text" conversion:
#5004|Output|Init. value|Binary|Type|Data format
5004|1|""|0|1|1

### 4.6.Record type 5012 - Definition of a formula line

The actual functionality of a module is defined within the formula line.
The formula rows are executed in the order of definition. Changing the order of the rows can therefore lead to different results. A formula row is executed once per calculation of the module. For more information, see Calculating a building block.
A formula row consists of the following fields:

Field | Type | Description
--- | --- | ---
5012 | Number | Record type
End after execution | Boolean | Stops calculation of the block after the formula has been processed if the result of the condition is not zero. See Calculating a block for more information. Permitted values: 1 = yes 0 = no
Condition | Formula | If the result of the condition is not zero, the calculation of the "formula" is performed. If the result of the condition should always be true/true, the field is filled by two inverted commas. Example `""`
Formula | Formula | Will be executed if "Condition" results in non-zero. The result of the calculation can be forwarded to the pins.
Time formula | Formula | Is executed if "condition" results unequal zero and at least one time memory has been defined in the block. This specification is optional. If it is not required, inverted commas must be used. Example `""` The result of this calculation serves as the execution time for the time memory assigned in the "Pin Time Memory". The execution time of a time memory can be changed during a calculation. More about this under calculation of a block.
Pin - Output | Number / Index | The result of the calculation in the field "Formula" is written into this output. The specification is optional. If this value is zero, no forwarding to an output takes place.
Pin - Time memory | Number / Index | In this time memory the result of the calculation is written in the field "time formula". The result of the time formula triggers the recalculation of the block by the time memory assigned here. If the result is zero, the time memory is stopped. If the result is not zero, a value in seconds is expected. The result of "Formula" is written to the ON [Index] variable in a calculation triggered by the time memory. The OC[Index] variable has the value 1 during the calculation triggered. More about "Variable" in this chapter. The specification is optional. If this value is zero, no forwarding to a time memory takes place.
Pin - memory variable | Number / Index | The result of the calculation in the field "Formula" is written into this memory variable. The specification is optional. If this value is zero, no forwarding to a memory variable takes place.
Pin - Negated output | Number / Index | In this output the negated result of the calculation is written in the field "Formula". Attention The "negated result of the calculation" is not always identical with the "negated value of the pin - output"! The specification is optional. If this value is zero, there is no forwarding to an output.

In the chapter examples 6 blocks are described exemplarily, of which e.g. the telegram generator uses time memory.

## 5.Variable

The variables listed in the following table are available within the formulas/conditions:
Note
These variables can only be read, but not written!

Field | Type | Description
--- | --- | ---
EI | Number | Possible values: 1 = The calculation takes place within the initialisation. 0 = The calculation takes place outside the initialisation. Attention This only refers to the initialisation of the block itself! If during the initialisation phase of the HS/FS the block is calculated several times by other blocks and their initialisation(s) in the logic, EI is equal to '1' only for the first, i.e. for the own initialisation!
EA | Array | The value of the input before the calculation.
EN | Array | The current value of the input.
EC | Array of Boolean | Possible values: 1 = A telegram has arrived at the input. The input telegram has triggered the calculation. 0 = The input is not active.
AA | Array | The value of the output before the calculation.
AN | Array | The current value of the output.
AC | Array of Boolean | Possible values: 1 = The value of the output has changed. 0 = The value of the output has not changed.
ON | Array | Contains the value written to the time memory once the time memory has expired.
OC | Array of Boolean | Possible values: 1 = As soon as the time memory has expired. 0 = As long as the time memory is running.
SA | Array | The value of a memory variable before calculation.
SN | Array | The current value of a memory variable.
SC | Array of Boolean | Possible values: 1 = The value of the variable has changed. 0 = The value of the variable has not changed.

Notes:

- The size of the respective arrays depends on how many inputs, outputs, time memories or memory variables are defined in the logic block(record type 5001).
- All arrays start with index 1.
  To access an index, you have to put the index in square brackets after the variable. So the syntax EN[2] returns the second value within the array EN. This corresponds to the current value of the second input.
- If an invalid index is used, the HS/FS triggers exception handling. This "exception" leads to a faulty calculation of the block. All occurred "exceptions" can be viewed on the debug page in the section "Exceptions".

See also some documented examples.

## 6.Calculation of a building block

### 6.1.When is the charge made?

The calculation of a block is always started when

- ...the system starts and the property "Calculation on initialisation"(record type 5001) is set.
- ...an input signal arrives at an occupied input.
- ...a time memory has expired.
  A time memory can be defined in a line of record type 5001 and can be triggered in a time formula(record type 5012). If a time memory has not yet expired, the execution time can be changed.

Note
If a telegram arrives at the input and a value is sent at one of the outputs, all attached blocks, if any, are also calculated.

### 6.2.How is the calculation done?

Each defined formula line(record type 5012) is calculated in the given order (i.e. the ".hsl" file is processed from top to bottom)
Example:
`5012|0|"EC[1] and EN[1] and EN[4]"|"SN[1]+1"|""|0|0|1|0
5012|0|"EC[2] and EN[2] and EN[4] and (SN[1]&gt;0)"|"SN[1]-1"|""|0|0|1|0
5012|0|"EC[3] and EN[3]"|"0"|""|0|0|1|0
5012|0|"SC[1] or EI"|"SN[1]"|""|1|0|0|0
`

### 6.3.Cancel calculation

To cancel a calculation, the property "End after execution" must be set.
The calculation will be aborted if the condition results in True/True. Before the calculation is finished the current line is calculated to the end. All further formula lines are ignored.

## 7.Start behaviour of the logic

See file `"logikstart.html"`, which is part of the online documentation of the HS/FS Expert.

## 8.Notes on language syntax

The logic uses the syntax of the script language '''Python'' within the conditions, formulas and time formulas. Notes and documentation on Python can be found on the Internet at https://www.python.org/.

### 8.1.Permitted expressions and functions

Only expressions and functions with return value are allowed, i.e., loops, if-else constructs, etc. are '''not''' supported!

### 8.2.Operators

The variables can be manipulated and compared using the following operators:

Operator | Description
--- | ---
+ | Addition
- | Subtraction
* | Multiplication
/ | Division
& | binary AND
| | binary OR
== | Equal (as comparator)
< | Little one
<= | Smaller equal
> | Larger
>= | Greater or equal
!= | Unequal (identical "<>")
<> | Unequal (identical "!=")

Examples:
`EN[1]+SN[1]`
Explanation: Adds input 1 and memory variable 1
`((EN[1]+SN[1])&gt;EN[2])`
Explanation: Checks whether the sum of input 1 and the memory variable 1 is greater than the value at input 2. Results in TRUE / TRUE if successful.
More operators can be found in the Python documentation at

- https://docs.python.org/2/reference/lexical_analysis.html#operators
- https://docs.python.org/2.7/library/stdtypes.html

Note: Calculating with floating point values
To work with floating point values, each variable must be enclosed with the function float().
For example, when dividing two input values
`float(EN[1])/float(EN[2])` . A simple calculation gives only the result as an integer, i.e.: 2/3 gives 0 and 4/3 gives 1. However, the calculation `float(2)/float(3)` gives the correct floating point value.

### 8.3.Boolean operators

The following Boolean operators are supported:
and: logical "AND". Combines several values with a logical "AND":

- 1 and 1 gives 1
- 1 and 0 gives 0
- 0 and 1 gives 0
- 0 and 0 gives 0

or: "OR". Combines several values with a logical "OR":

- 1 or 1 gives 1
- 1 or 0 gives 1
- 0 or 1 gives 1
- 0 or 0 gives 0

### 8.4.Notes on the use of external libraries

Within a formula it is possible to include (external) Python libraries. Currently the access is limited to the following libraries:

Library | Description
--- | ---
math | The module maths provides mathematical functions. Detailed description: math.
whrandom | (up to incl. expert 2.8) The module whrandom is used to generate random numbers. Further info: whrandom.
random | (from Expert v2.10, replaces the whrandom library used in earlier Expert versions) The module random is used for the generation of random numbers. Detailed description: random.
time | The time module is used for time handling. Note To determine the current time/date, the localtime() function should be used. This is especially important when changing between summer and winter time. Exact description: time.
string | The module string provides functions for text handling Detailed description: string.

External functions are called according to the following scheme:
`__import__`('LIBRARY').NAME_OF_FUNCTION(EVENTUAL_PARAMETERS)
Note: Before and after "import" there are 2 underscores each.
Examples of use:

- `__import__('whrandom').randint(1,100)
  oder
  __import__('random').randint(1,100)
  `
  Explanation: This expression calls the function randint() from the library "whrandom" or "random". As an answer, the call returns a random integer in the range 1-100 (both numbers included), which can be placed on an output, for example.
- `__import__('time').time()`
  Explanation: This call returns the current time as an integer. The call has no parameters.
- `__import__('time').localtime()[1]`
  Explanation: The function localtime() returns an array. In this array the current month is at position 1.

## 9.Troubleshooting

### 9.1.Using the home server debug list

The HS/FS keeps an internal list for logging the errors that occurred when interpreting the logic modules. To call up this list, the debug page must be called up in the browser:
`https://HS_IP/hslist?lst=debug&user=USER&pw=PWD`
Under "Exceptions" you will find the error messages issued by the interpreter.
Depending on the configuration, you can also access the debug page via `"http:\\..."` instead of `"https:\\..."`.

### 9.2.Detection of structural errors

The HS/FS expert detects errors in the structure of building blocks when checking the project. If there are errors in the structure of a block, the HS/FS Expert signals this with an error message.

### 9.3.External aids

#### 9.3.1.Test

A very useful tool is the "Python IDLE Shell", which is a standard part of the Python environment in Windows.
It allows you to test statements line by line. The easiest way to do this is to define the required arrays (SN[],EN[],....) and apply the formula lines to them. Logic or syntax errors are already noticeable here before the project is loaded onto the HS/FS. This allows a quick development of logic modules without having to reload the project onto the HS/FS every time the logic module is changed.
For more information about the Python IDLE Shell and the installation packages, visit www.python.de.

#### 9.3.2.Help file

There is a sample template for creating an HTML help file for logic blocks. This can be found under the name "`log55555.html`", together with a style sheet, in the subfolder "`/HSL SDK/Help Template/`" of the ZIP file which also contains this documentation (interface information.zip).

#### 9.3.3.Container File

To simplify the publication and/or distribution, there is the possibility to pack the module together with help files into a container which can be imported in the HS/FS Expert.
For more details, see "`hslz_structure.html`" in the "`/HSL SDK/HSLZ/`" subfolder of the ZIP file which also contains this documentation (interface information.zip).

## 10.Examples

In this chapter some already existing blocks are explained and defined in the correct HSL file definition. These are the following blocks:

- Binary Trigger
- AND gate
  Only use inputs and outputs.
- Telegram Generator
  Uses inputs, outputs and time memory.
- Counter module
- On/off delay
  Uses inputs, outputs and memory variables.
- Text trigger
  Equivalent to the binary trigger, works with values of type text.

### 10.1.Binary trip unit as logic module

5000|"Binary release"|0|1|"E1"|2|"A1 (value = 1)"|"A2 (value <> 1)
The module is displayed in the HS/FS Expert at the top level. The block is marked as not remanent and has one input and two outputs.
`5001|1|2|0|0|0`
The binary trigger has one input and two outputs. It has no memory variables and no time memories. Furthermore the block is only calculated for incoming telegrams.
The block is not calculated during initialisation.
`5002|1|0|0`
Input 1 is defined here. The init. value of the input is 0.
`5004|1|0|1|1|0`
Output 1 has the init. value 0, is rounded binary and sent with every calculation.
`5004|2|0|1|1|0`
Output 2 has the same properties as output 1.
`5012|0|""|"EN[1]<>0"|""|1|0|0|2`
With each incoming telegram the result of the expression input 1<>0 is sent to output 1. If the condition applies, the result of the comparison is 1 (TRUE).
Thus a one is sent to output 1 and a zero is sent to output 2.

### 10.2.AND gate as logic module

5000|"AND gate\2-fold"|0|2|"E1"|"E2"|4|"A1"|"A2 neg"|"A3 (SBC)"|"A4 neg (SBC)
The block is displayed in the HS/FS Expert in the AND gates category with the designation 2-fold.
The module is marked as non-remanent and has two inputs and four outputs.
`5001|2|4|0|0|1`
The AND gate has two inputs and four outputs. It has no memory variables and no time memories. The block is calculated during initialisation.
`5002|1|1|0
5002|2|1|0
` The two inputs have the init value one.
`5004|1|0|1|1|0
5004|2|0|1|1|0
` Outputs 1 and 2 each have the init value zero. The result is always rounded binary and sent with each calculation.
`5004|3|0|1|2|0
5004|4|0|1|2|0
` Outputs 3 and 4 each have the init value zero. Here too, the result is rounded in binary. The values are only transmitted in case of a value change.
`5012|0|""|"EN[1] and EN[2]"|""|1|0|0|2`
Input 1 and input 2 are linked with the AND operator. The result is sent to output 1. The negation is sent to output 2.
`5012|0|"(EI==0)"|"EN[1] and EN[2]"|""|3|0|0|4`
The formula is identical to the one in the previous 5012 line. However, the formula from this line has an additional condition. The calculation is therefore only executed if the variable EI has the value 0. Only if this comparison is 1 (TRUE), the AND comparison is executed and the result is sent to the outputs.

### 10.3.Telegram generator as logic module

5000|"Weitere Bausteine\Telegrammgenerator"|0|2|"E1"|"E2"|2|"A1"|"A2"
The block is displayed in the category Further blocks under the designation Telegram generator. It has two inputs and two outputs. Furthermore it is marked as not remanent.
`5001|2|2|1|0|1`
The block has two inputs, two outputs, a time memory and no memory variable. It is calculated during initialisation.
`5002|1|0|0
5002|2|0|0
` Both inputs are initialised with the value zero.
`5004|1|0|1|1|0
5004|2|0|1|1|0
` Both outputs are initialised with the value zero, rounded binary and sent with each calculation.
`5012|1|"(EI or OC[1] or EC[1] or EC[2]) and EN[2] and (EN[1]&gt;0)"|"1"|"EN[1]"|1|1|0|2`
The first condition block is fulfilled if the calculation of the block takes place during initialisation (EI==1), if a time memory has expired (OC[1]), or if one of the inputs has changed (EC[1], EC[2]).
If the first block is TRUE, input 2 equals one (True/True), and input 1 is greater than zero, the entire condition is fulfilled.
If this is the case, a one is sent to output 1 and time memory 1 and the negation is sent to output 2.
In the Formula/Time field, the value of input 1 is used as the new timer. After this time has expired, the block is calculated again.
Note
If a telegram arrives at input 1 or 2 before this time has elapsed, the current time memory is aborted and restarted, since it is written to with a new value and a new time.

### 10.4.Counter module as logic module

5000|"Further modules\counter module"|1|4|"E1 (+counter)"|"E2 (-counter)"|"E3
Reset"|"E4 On/Off"|1|"A1 Clocks (sbc)"
The module is displayed in the category Further modules under the name counter module. It has four inputs and one output and is marked as remanent.
`5001|4|1|0|1|1`
The block has four inputs, one output and a memory variable.
The block is calculated during initialisation.
`5002|1|0|0
5002|2|0|0
5002|3|0|0
5002|4|0|0
` All four inputs are initialised with the value 0.
`5004|1|0|0|2|0`
The only output is initialised with the value 0 and is only sent in case of a change.
`5003|1|0|1`
The only memory variable is remanent.
`5012|0|"EC[1] and EN[1] and EN[4]"|"SN[1]+1"|""|0|0|1|0`
If input 1 has changed, the value of input 1 is not zero and the value of input 4 is also not zero, the value of memory variable 1 is increased by one.
`5012|0|"EC[2] and EN[2] and EN[4] and (SN[1]&gt;0)"|"SN[1]-1"|""|0|0|1|0`
If input 2 has changed, the value of input 2 is not zero and the value of input 4 is also not zero, the value of memory variable 1 is reduced by one.
`5012|0|"EC[3] and EN[3]"|"0"|""|0|0|1|0`
If input 3 has changed and the value of input 3 is not zero, memory variable 1 is set to zero.
`5012|0|"SC[1] or EI"|"SN[1]"|""|1|0|0|0`
When the first memory variable is initialized or its value changes, the value of memory variable 1 is sent to output 1.

### 10.5.On/Off delay

5000|"Delay\On/Off delay"|0|3|"E1"|"E2"|"E3"|2|"A1"|"A2"
The block is displayed in the Delay category under the designation On/Off delay. It has three inputs and two outputs and is marked as non-remanent.
`5001|3|2|2|2|0`
The block has three inputs, two outputs, uses two time memories and two memory variables.
`5002|1|0|0
5002|2|0|0
5002|3|0|0
` All inputs have the init. value 0
`5003|1|0|0`
The memory variable 1 is initialised with the value zero.
`5003|2|1|0`
The memory variable 2 is initialised with the value One.
`5004|1|0|1|1|0
5004|2|0|1|1|0
` All outputs are sent in binary form when calculated.
`5012|0|"OC[1]"|"ON[1]"|""|1|0|0|2`
Is calculated when the time memory 1 has expired. Sends the value of the time memory to output 1 and the negated value to output 2.
`5012|1|"OC[1]"|"0"|""|0|0|1|0`
If time memory 1 has expired, the value zero is written to memory variable 1 and the calculation is then terminated, no further lines are executed.
`5012|0|"OC[2]"|"ON[2]"|""|1|0|0|2`
Is calculated when time memory 2 has expired. Sends the time memory value to output 1 and the negated value to output 2.
`5012|1|"OC[2]"|"1"|""|0|0|2|0`
When the time memory 2 has expired, a zero value is written into memory variable 2 and the calculation is then stopped, no further lines are executed.
`5012|0|"EC[3] and (EN[3]<>0)"|"1"|"0"|0|2|2|0`
If a value not equal to 0 is received at input 3, a one is written to memory variable 2 and to time memory 2, and timer 2 is stopped. This stops the switch-off delay.
`5012|1|"EC[3] and (EN[3]<>0) and (EN[1]==0)"|"1"|""|1|0|0|2`
If a value unequal to 0 is received at input 3 and input 1 is assigned a zero, a one is sent to output 1 and a zero to output 2.
The calculation is then terminated.
`5012|1|"EC[3] and (EN[3]<>0) and (SN[1]==0)"|"1"|"EN[1]"|0|1|1|0`
If a value unequal to 0 is received at input 3 and memory variable 1 is zero, a one is written to memory variable 1 and time memory 1. Time memory 1 is started with the value of input 1.
Attention
The time memory 1 has the value one, but triggers a recalculation after n seconds (depending on the value of input 1).
`5012|0|"EC[3] and (EN[3]==0)"|"0"|"0"|0|1|1|0`
If a value equal to 0 arrives at input 3, a zero is written to memory variable 1 and to time memory 1, timer 1 is stopped. Thus the switch-on delay is stopped.
`5012|1|"EC[3] and (EN[3]==0) and (EN[2]==0)"|"0"|""|1|0|0|2`
If a value equal to 0 arrives at input 3 and input 2 is assigned a zero, a zero is sent to output 1 and a one to output 2.
The calculation is then terminated.
`5012|1|"EC[3] and (EN[3]==0) and (SN[2]==1)"|"0"|"EN[2]"|0|2|2|0`
If a value equal to 0 arrives at input 3 and memory variable 2 is equal to one, a zero is written to memory variable 2 and time memory 2. Time memory 2 is started with the value of input 2.
Attention
Time memory 2 has the value zero, but triggers a recalculation after n seconds (depending on the value of input 2).

### 10.6.Text trigger

5000|"Text functions\text trigger"|0|1|"E1"|2|"A1 (text length > 0)"|"A2 (text length = 0)"
The block is displayed in the Text functions category under the designation Text trigger. The block is marked as non-remanent and has one input and two outputs.
`5001|1|2|0|0|0`
The block has one input and two outputs. It has no memory variables and no time memories. Furthermore, the block is only calculated for incoming telegrams. The block is not calculated during initialisation.
`5002|1|""|1`
Here, input 1 is defined as text input. The input receives a blank text as the init. value.
`5004|1|0|1|1|0`
Output 1 has the init. value zero. The output is rounded binary and is sent with every calculation.
`5004|2|0|1|1|0`
Output 2 has the same properties as output 1.
`5012|0|""|"len(str(EN[1]))>0"|""|1|0|0|2`
With each incoming telegram the result of the expression 'text length of input 1' > 0 is sent to output 1. If the condition applies, the result of the comparison is one (TRUE).
Thus a one is sent to output 1 and a zero is sent to output 2.

## 11.Publication

- 18.09.2018 version 4.8 - changes
  - Record type 5003 - texts are now allowed.
  - Help file - Added reference to HTML Help template.
  - Container file - Added reference to HSLZ file.
  - Addedreference to HTTP access when calling the debug page
  - Added reference to the change in number range assignment and DSGVO
  - System paths updated
- 25.04.2017 Version 4.7 - Changes
  - Record type 5000 - New optional fields
  - Front and back page removed
  - Details of HS/FS endpoints are now in the form "https://..."
- 23.02.2016 Version 4.5 - Restructuring
  - Documentation format changed from PDF to HTML
  - All chapters revised and if necessary updated
- 14.01.2014 Version 4.2 - Changes
  - Record type 5004 - output type: explanation of "sbc" specified
  - Record type 5012 - negated output: note added
  - Variable - Declaration on EI clarified
  - Starting behaviour of the logic - Chapter Deleted. Content is available in the online help
- 22.01.2013 Version 4.0 - Changes
  - Version number of the documentation adapted to the version number of the expert
  - System paths - added format for expert from v4.0
- 12.10.2012 Version 2.2 - Changes
  - Cover page - HomeServer 4 & FacilityServer 4 added
  - Assign a file name - Correct the URL to the number range page
  - Integrate logic modules into project - Revised
  - Operators - Completed
  - External libraries - Revised / supplemented
- 20.08.2012 Version 2.1 - Changes
  - Number ranges - replaced by new contents
  - Other sources - Revised
- 16.12.2011 Version 2.0 - Changes
  - Record type 49999 - Specification of the description of the language abbreviation
- 17.11.2011 Version 1.9 - Changes
  - Structure of the definition file - new table line with record type 4999
  - Record type 49999 - chapter added
- 21.07.2011 Version 1.8 - Changes
  - Record type 5000 - New function: display of version no.
- 25.02.2011 Version 1.7 - Changes
  - Chapter 3.1 - Internet address correction
  - Chapter 3.2 - Supplement/update the logic folder path information
  - Chapter 4.6 - Correcting the chapter number given on the last line
  - Chapter 5 - Correction of the chapter no. indicated on the last line
  - New chapter 7 - "Starting behaviour of the logic
  - Chapters renumbered from 7 to 10 - Are now chapters 8 to 11
  - Title line - changed
- 01.10.2010 Version 1.5 - Changes
  - Chapter 4.2 - Note 2 added in the "Coded formula block" field.
- 29.09.2010 Version 1.4 - modifications
  - Chapter 4.2 - New field "Coded formula block Examples adapted.
- 22.09.2009 Version 1.3 - Changes
  - Chapter 4.1 - Any category depth may be used from expert version 2.4 on.
- 18.06.2008 Version 1.2 - corrections
  - Chapter 2.1 - Internet address(es) corrected
  - Chapter 2.4 - Text corrections
  - Chapter 2.5 - (has been deleted)
  - Chapter 3.1 - Internet address corrected
- 02.02.2007 Version 1.1 - additions and bug fixes
  - Chapter 4.6 - Error correction
  - Chapter 8 - Chapter "Troubleshooting" inserted
- 19.01.2007 Version 1.0 - additions and bug fixes
  - Chapter 4.1 - Supplements
  - Chapter 4.4 - Supplements
  - Chapter 4.6 - wording clarified
  - Chapter 5 - Notes corrected
  - Chapter 6.2 - Additions and example
  - Chapter 7 - Supplements
  - Chapter 8.2 - Additions and clarifications
  - Chapter 8.3 - Supplements
  - Chapter 8.4 - Completion of record type 5000
  - Chapter 8.6 - Correction
- 08.12.2006 Version 0.8 - additions and bug fixes
  - Chapter 4.3 - Supplements
  - Chapter 4.6 - Supplements
  - Chapter 5 - URL of the debug page added
  - Chapter 7.2 - Chapter renamed and clarified, additions
  - Chapter 7.3 - Restrictions on the use of Boolean operators
  - Chapter 7.4 - Links corrected
- 28.08.2006 Version 0.7 - bug fix
  - Chapter 5 - Text amendment for the variable EC
  - Chapter 6.1 - Addition
- 27.06.2006 Version 0.6 - additions
  - Chapter 7.x - Chapter 7.3 was moved to 7.4. 7.3 was added.
- 26.06.2006 Version 0.5 - additions and bug fixes
  - Chapter 4.2 - Text completion
  - Chapter 4.3 - Correction of the examples
  - Chapter 4.4 - Note
  - Chapter 4.6 - Addition
  - Chapter 7.2 - Chapter was added
- 25.04.2005 Version 0.4 - bug fix
- 05.03.2005 Version 0.3 - First release