Macrosfunctional blocks
P.
313 of 349
Macros
functional blocks
Basics
Available libraries
Programming a macro
Basics
Definition
A macro starts with :begin
... ends with :end
With the aid of macros, also designated (ready-to-use) functional blocks, programming the Enertex
®
EibPC is
•
substantially simplified for the beginner and
•
schematized for the experienced user. The user can separate out complete code
fragments of program parts he repeatedly uses into a library of his own and hence re-use
the programming in different projects at any time.
•
You can use the macro-wizard, which guides you if you parametrize a macro. This means
dialogs with explanation on every arguments are given by EibStudio. If you change any
argument later on, again the wizards can be opened and help you re-parametrizing the
macro.
•
You can use a macro guided by the macro-assistant or as a “normal function” in your
application program. In this case the assistant is not available.
On page 24 you will find the step-by-step explanation of the application of already existing libraries.
A macro is (a part of) a user program which is separated out into a library. As an independent part of
another user program, these macros can be integrated into other projects. Within the macro, you can
define various inputs (arguments) containing project-specific data.
Most conveniently, the programming of macros can be explained by means of an example. You have
programmed the double occupancy of a KNX
TM
button: Pressing the button sends an ON telegram to
the address 0/0/1. If the button is pressed twice within 800ms, the Enertex
®
EibPC shall send an ON
telegram to the address 3/4/6, if it is pressed only once, it shall send an ON telegram to the address
3/4/5: The following user program arises:
[
EIBPC]
DoubleClick=0
if event('0/0/1'b01) and ('0/0/1'b01==EIN) then DoubleClick=Doub1 endif
if after(DoubleClick==1, 800u64) then write('3/4/5'b01, EIN) endif
if after(DoubleClick==1, 800u64) and DoubleClick==2 then write('3/4/6'b01, EIN) endif
if after(DoubleClick==1, 1000u64) then DoubleClick=0 endif
To transfer this functionality to additional buttons and group addresses, you can change the text by
way of copy & paste in the text editor of the Enertex
®
EibStudio.
However, this method possibly may become error-prone.
With a macro your are capable of creating templates in such situations which make programming
easy. To this end, you create a new text file (ending „.lib“) and write now:
:begin DoubleClick(Name,ButtonGA,ButtonValueClick1GA,Click1Value,Click2GA,Click2Value)
Name^DoubleClick=0
if event(ButtonGA) and (ButtonGA==ButtonValue) then Name^DoubleClick=Name^Doub1 endif
if after(Name^DoubleClick==1, 800u64) then write(Klick1GA,Klick1Wert) endif
if after(Name^DoubleClick==1, 800u64) and Name^DoubleClick==2 then write(Klick2GA,Klick2Wert) endif
if after(Name^DoubleClick==1, 1000u64) then Name^DoubleClick=0 endif
:end
A macro starts with the keyword
:begin
and ends with
:end
. The definition itself is the name of the
macro, followed by comma-separated arguments which are confined by parentheses, and is
positioned directly after
:begin
.
The arguments of the macro are used as pure text replacements in the macro code. The syntax is
exactly the same as that of the “normal” user program. The code generated from the macros as it
were from text templates is bound internally by the compiler to the section [
EibPC
]. You can look at
your macro code generated by the compiler also in the file „tmpMacroOut.txt“ in the working directory
of the Enertex
®
EibStudio.set
HandbuchEibPC_USA-30.odt, 2017-05-11
Enertex
®
Bayern GmbH - Erlachstraße 13 - 91301 Forchheim - [email protected]