Programming - First steps
P.
69 of 349
event(readudp): Invalid at every
telegram
Command1: I arrived a telegram, ,
IP and Port are OK.
Command2: ditto
[EibPC]
// Variables
Command=0u32;Number1=0u32;Number2=0u32;FloatingPoint=0f32
IP=0u32;Port=0u16
// Is the telegram on the correct port?
CheckSender=(IP==192.168.22.22) and (Port==5220u16)
// The both telegram types
Command1=event(readudp(Port,IP,Command, Number1, FloatingPoint, Number2 )) and CheckSender
Command2=event(readudp(Port,IP,Command, FloatingPoint, Number1)) and CheckSender
// Sum back
if Command==1000u32 and Command1 then
\\
sendudp(Port,IP, 1100u16,Zahl2, FloatingPoint, Number2 ) \\
endif
// Difference back
if Command==1001u32 and Command1 then
\\
sendudp(Port,IP, 1100u16,Zahl1, convert(Number1, FloatingPoint)-
\\
convert(Number2, FloatingPoint), Number2 ) \\
endif
// Square root
if Command==2001u32 and Command2 and FloatingPoint>0f32 then \\
sendudp(Port,IP, 2001u16,sqrt(FloatingPoint), 0u32 ) \\
endif
// Square root does not run, because argument is smaller than zero
if Command==2001u32 and Command2 and FloatingPoint<0f32 then \\
sendudp(Port,IP, 2001u16, FloatingPoint, 1u32 ) \\
endif
With any incoming UDP telegram at port 5220, the function
event
(
readudp
(...)) is temporarily
changing from 0b01 to 1b01.
Then, the telegram types
Command1
and
Command2
react (linked with
CheckSender
) at each
telegram that 192.168.22.22 sends from its port 5220 (the destination port in Enertex
®
EibPC is
4806).
By linking with the variable
Command
, the desired telegram analysis is then performed. Accordingly,
Command1
and
Command2
are absolutely identical of behavior, especially
Command1
is also ON, if
Command2
goes to ON.
Therefore,
Command1
and
Command2
could be alternatively combined into one telegram realized
by the variable
Telegram
as described below.
HandbuchEibPC_USA-30.odt, 2017-05-11
Enertex
®
Bayern GmbH - Erlachstraße 13 - 91301 Forchheim - mail@enertex.de