Programming - First steps
P.
57 of 349
Date control
Display birthdays
We use the macro “Online“
Insert macros
Summer by date definition
Suppose you want to realize a birthday calendar by a KNX
TM
display element, which expects a
KNX
TM
character string to the group address 1/2/3:
If there is a birthday, this shall be displayed on the display element.
In all other cases, the uptime of the Enertex
®
EibPC shall be shown.
To solve this problem, the macro
Online()
from the library Enertex.lib is used. We need to integrate
the library into our program. Click on P
ROGRAM
/ M
ACRO
-
LIBRARIES
and there on the menu item A
DD
.
Select the Library “Enertex.lib“ and click on Add.
In the second step select the macro
Online()
in P
ROGRAM
/ M
ACRO
. A parameter dialog is opened,
which you simply confirm by clicking OK.
The macro
Online()
defines the variable “DisplayOnline“, a KNX
TM
character string (data type c14),
which writes the time of last start of the user program into a string. The format is ddd.hh: mm (ddd:
day from 0 to 999, hh hours, mm minutes).
Here is the program:
[Macros]
//Macros
Online()
[MacroLibs]
//Macro-Libraries
Enertex.lib
[EibPC]
Birthday=OFF
DisplayBirth=$ $c14
// Here, adding arbitrary Birthdays
if month(10,01) then DisplayBirth=$ Alex $c14;Birthday=ON endif
if month(15,01) then DisplayBirth=$ Martin $c14;Birthday=ON endif
if month(21,02) then DisplayBirth=$ Jürgen $c14;Birthday=ON endif
// Reset short of switching
if htime(23,59,59) then Birthday=OFF endif
// Here, is the output of the time
if change(DisplayOnline) and !Birthday then write("HallText-0/2/1"c14,DisplayOnline) endif
if systemstart() then write("HallText-0/2/1"c14,DisplayOnline) endif
// Birthday display will blink
DisplayBlink=0
if Birthday and cycle(0,3) then write("HallText-0/2/1"c14,DisplayBirth);DisplayBlink=1 endif
if after(DisplayBlink==1,1700u64) then write("HallText-0/2/1"c14,$Birthday$c14);DisplayBlink=2 endif
if after(DisplayBlink==2,700u64) then write("HallText-0/2/1"c14,$ !!+++!! $c14);DisplayBlink=0 endif
We have used the function
month
:
month
(
Day
,
Month
)
The function returns a logical ONE (1
b01
), if the date of any year is reached. In the other case it is
OFF (0
b01
). The switching point is exactly 00:00:00.
Every day, at 23:59:59 (statement with
htime
) the variable
Birthday
is switched OFF again.
You can also define periods with
month
function: The following variable Summer is ON during the
period from 1 May to 30 September, otherwise OFF.
Summer=month(01,05) and !month(30,09)
Therefore, you are able to realize the summer as a query condition:
if Summer then ....
HandbuchEibPC_USA-30.odt, 2017-05-11
Enertex
®
Bayern GmbH - Erlachstraße 13 - 91301 Forchheim - [email protected]