Go to documentation repository
The list of operators used to describe actions:
DoReact(object type, number, action[,Parameters]) – —execute an action.
Example of use:
Code Block |
---|
OnEvent("GRAY","1","ON") { DoReact("GRELE","1","ON"); //close relay 1 when closing sensor 1 } |
DoCommand(command line) – —run the command line.
Examples of use:
Code Block |
---|
OnEvent("GRAY","1","ON") { DoCommand("notepad.exe"); //when sensor 1 is closed, run "Notepad" } |
Wait(number of seconds) – —wait for N seconds;
Sleep(number of milliseconds) - —wait for N milliseconds.
Await operators are to must be in a single thread. Single thread is to must be inside square brackets.
Example. When Sensor 1 is closed, Relay 1 is closed for 5 five seconds.
Code Block |
---|
OnEvent("GRAY","1","ON") { [ DoReact("GRELE","1","ON"); Wait(5); DoReact("GRELE","1","OFF"); ] } |
Checking Function to check the object state function:
CheckState(object type, number, state) – —the result is 1, if the state of an object is is factually accurate, otherwise 0.
Expressions can be used as parameters. Constant values are quoted.
Example. Check the state of camera 2 when closing sensor 1 and if the state is “Alarmed“, then close relay 1
Code Block |
---|
OnEvent("GRAY","1","ON") { if(CheckState("CAM","2","ALARMED")) { DoReact("GRELE","1","ON"); } } |
Conditional operator:
Code Block |
---|
If (expression) { ... // if the result is not equal to 0 } else { ... // if the result is equal to 0 } |
else {} part can be absent.
Example of use:
Code Block |
---|
OnEvent("MACRO","1","RUN"){ x=5; if(x>10) {y=2;} // if "x" is greater than 10, then y=2 else {y=3;} //otherwise y=3 } |
For operator:
Code Block |
---|
For(expression 1; expression 2; expression 3){ ... } |
Expression1 is executed at the beginning of the loop; loop body is executed if expression2 is true; expression3 is executed after each execution of the loop body.
Example. When sensor1 is closed, relay1 is closed and opened every second and it will happen 10 times.
Code Block |
---|
OnEvent ("GRAY","1","ON") { [ for(i=0;i<10;i=str(i+1)) { DoReact("GRELE","1","ON"); Wait(1); DoReact("GRELE","1","OFF"); Wait(1); } ] } |
DoReactGlobal(object type, number, state) – —function that creates reactions of system objects. Meanwhile, the created reaction is sent to all cores connected over the network.
Example. When running macro 1, camera 1 is armed.
Code Block |
---|
OnEvent("MACRO","1","RUN")
{
DoReactGlobal("CAM","1","ARM");
} |
NotifyEventGlobal (object type, number, state) – —function that creates system events. Meanwhile, the created events are sent to all cores connected over the network.
Example. When running macro 1, create event “Recording” for camera 1. The command is sent to all cores as an event in order to be logged.
Code Block |
---|
OnEvent("MACRO","1","RUN") { NotifyEventGlobal("CAM","1","REC"); } |
Info | ||
---|---|---|
| ||
If there is no need to send event to all system cores, then use the NotifyEvent function. |