Programming - First steps
P.
45 of 349
From the Beginning to the end and
from the beginning again
Validation
Setting variables in the if statement
Setting variables in the if statement
and with assignment of group
addresses
Exactly one assignment is needed
in the main level:
Definition of the variable
Like already mentioned, the Enertex® EibPC evaluates the user program continuously. Clearly
spoken, when the Enertex® EibPC has reached the last instruction at the end of the application
program, it starts again with the first instruction. The code is only processed, if something has
changed. The states of the incoming telegrams are saved and only when the telegrams or the
variables has been changed, the processing is evaluated. We named this process validation
scheme.
The important topic in this example is to understand, that the statement "Set Dimmer to 80%" is only
evaluated during the first run through the user program, because the value 80% will not change. On
the other hand
"Motiondetector"
depends on the group address “MotionDetector-1/2/0“ and on the
telegrams with this group address at the KNX
TM
bus.
A smalll excursus:
In the following user program the variable
DimmVar
is set to 80% at the first run of the program
code. When the motion detector sends an ON (1b01) to the group address 1/2/0, the if-statement is
fulfilled and
DimmVar
is set to 30%. But at the next run of the program code
DimmVar
is not set to
80%, because the value 80% has
not
been changed. So, you can overwrite a variable or it content,
respectively, with the help of the if-statement.
DimmVar=80%
Detector="Motiondetector-1/2/0"
if Detector then DimmVar=30% endif
In the following user program the variable is set to the value of the group address 5/8/1 at the first run. When the
motion detector sends ON (1b01) to the group address 1/2/0, then
DimmVar
is set to 30%. When the Enertex®
EibPC receives the next telegram (and the value in the telegram is different from the current value),
DimmVar
is set
to the new value containing in the telegram.
DimmVar="Dimmer-5/8/1"
Detector="Motiondetector-1/2/0"
if Detector then DimmVar=30% endif
You can tread the assignment in the if statement as a assignment in the 2
nd
level. The main level is the definition of
the variable (e.g.
DimmVar
=80%) without leading if-statement. In the 1
st
(main) level each variable can only be set
one times, otherwise the compiler throws an error. This means, each variable must not be located on the left hand
side of a equal sign more than one times. Therefore, the next program do not run correctly:
//Attention invalid Code
DimmVar="Dimmer-5/8/1"
DimmVar=30%
We call the assignment in the main level definition of the variable. Before you can use a variable in your user
program, the variable
must be defined in the main level
. Therefore, in the next user program the variable
LogicB
is
defined with the value OFF in the main level.
By means of setting the variables in the if statement, you have the possibility to implement arbitrary links. Similarly,
this is also possible at the definition of the variable:
// Variant A
LogicA="Motiondetector-1/2/0" and "Dimmer-5/8/1">50%
// Variant B (equal to A).
LogicB=OFF
if "Motiondetector-1/2/0" and "Dimmer-5/8/1">50% then LogicB=ON else LogicB=OFF endif
Both variables
LogicA
and
LogicB
are identical - several ways lead to Rome...
HandbuchEibPC_USA-30.odt, 2017-05-11
Enertex
®
Bayern GmbH - Erlachstraße 13 - 91301 Forchheim - [email protected]