New features in the script

The scripting language has been extended: the use of hexadecimal constants and labels, INIT and JUMP statements, function @STAYINZONE. In the conditional statement, you can use the bitwise conjunction and disjunction. A description of the new features is published in the script manual.

Here is an example of a script that uses new features. The script does the following: If an object entered a certain zone and stayed there for more than a specified time, then one command is sent, if the object exits this zone, another command is sent

 LET INZONE = @INZONE 1234
LET INZONE_TIME = @STAYINZONE 1234
INIT S_INZONE = INZONE
IF INZONE == 0 THEN JUMP OUTOFZONE
LET S_INZONE = 1
INIT S_INZONE_TIME = 1
LET ZONESTAY = INZONE_TIME * S_INZONE_TIME
IF ZONESTAY<60 THEN RETURN
COMMAND "command_body_1"
LET S_INZONE_TIME = 0
RETURN
OUTOFZONE:
IF S_INZONE != INZONE THEN COMMAND "command_body_2" ELSE RETURN
LET S_INZONE = 0
LET S_INZONE_TIME = 1

Comments

LET INZONE = @INZONE 1234
LET INZONE_TIME = @STAYINZONE 1234
If the object is in the zone with identifier 1234, the variable INZONE is equal to 1, otherwise - 0. Variable INZONE_TIME store the time of the object stay in the specified zone, 0 - if the object is outside the zone or just entered this zone.
INIT S_INZONE = INZONE
Initializing the variable S_INZONE.
IF INZONE == 0 THEN JUMP OUTOFZONE
If the object is outside the zone, go to the label OUTOFZONE.
LET S_INZONE = 1
INIT S_INZONE_TIME = 1
Saving that the object in the zone and initializing the variable S_INZONE_TIME.
LET ZONESTAY = INZONE_TIME * S_INZONE_TIME
Calculating the time of staying the object in the zone. Variable S_INZONE_TIME allows preventing multiple sending of the command.
IF ZONESTAY<60 THEN RETURN
If the object is in the zone less than the specified time (60 sec), we exit the script.
COMMAND "command_body_1"
Sending to the object the command 1.
LET S_INZONE_TIME = 0
Setting the variable S_INZONE_TIME to 0.
RETURN
Exit the script.
OUTOFZONE:
IF S_INZONE != INZONE THEN COMMAND "command_body_2" ELSE RETURN
If the object has just left the zone, we send command 2, otherwise, we exit the script.
LET S_INZONE = 0
LET S_INZONE_TIME = 1
Saving that the object out of the zone and setting the variable S_INZONE_TIME to 1.