Programming - First steps
P.
34 of 349
Button or menu or shortcut
Look for:
Syntax highlighting (page 128)
Code completion (page Fehler:
Referenz nicht gefunden)
if- statement
The statement block
Manual group address
The data type must be specified for
manual group addresses and
values!
Now just copy the text by using the clipboard into the field "user program".
Figure 3: Compile and send to the Enertex® EibPC
This program must now be entered into the Enertex
®
EibStudio and subsequently transferred to the
Enertex
®
EibPC. To do this, press the selected button (Figure 3), or click into the menu “P
ROGRAM
“ on
the appropriate button or use the shortcut "CTRL-SHIFT-B".
You can see the syntax highlighting in Figure 4: The Enertex
®
EibStudio assists you in correctly
entering programs during their creation. You can find further information on syntax highlighting and
code completion of keywords on page Fehler: Referenz nicht gefunden and the following .
Figure 4: Syntax highlighting in the Enertex
®
EibStudio
Let us look at the code more closely. Our task consists of a conditional statement ("When the switch
is pressed ..."). For this purpose, the important “if” statement exists in the programming language.
if
(
'1/0/0'b01
==
ON
)
then write
(
'1/1/1'b01
,
ON
);
write
(
'1/1/2'u08
,
80%
)
endif
The syntax of an if statement is as follows:
i
f
(
Query condition
)
then
Statement
endif
If the query condition is met, the statement is executed once in the then branch. Thus, the if
statement only reacts to changes. More about that this in this introduction.
It can also be executed multiple statements as a block. In this case, the instructions are separated
by semicolons.
After the last statement there is not a semicolon
.
A query condition is considered to be fulfilled, if it takes the value 1. If it takes the value 0, then the
then-branch is not executed.
What does
'1/0/0'b01
==
EIN
?
'1/0/0b1'
is the syntax for a group address 1/0/0 with a binary datatyp. We have not imported the
group address and its name from the ETS, but used it directly. In this manual, we refer to this as
"manual" group entered addresses. The "generation law" for this is simply the group address
surrounded by two '-marks (for more information, see on page 153). Thus, the "Generation Law" for
the syntax of manually assigned addresses is defined by:
Manual address:
'
group address
'
data type
Group addresses have different information depending on the number of bits in the corresponding
KNX™ telegram and the interpretation of this information. We are talking about data types. If we use
the manual group address and value, we must know and specify the data type.
In our example, we used two data types (more on page 153):
●
The binary (value 0 and 1), characterized by the suffix 'b01' and
●
the percentage (values 0.0 to 100.0), characterized by the addition of '%'.
HandbuchEibPC_USA-30.odt, 2017-05-11
Enertex
®
Bayern GmbH - Erlachstraße 13 - 91301 Forchheim - [email protected]