Go to documentation repository
There are three standard procedures that can be performed when the corresponding event occurs:
OnInit()—used for initialization of variables (setting initial values) that will be used in scripts. It is executed before starting all modules of the system. We recommend calling the procedure once for all scripts.
Example of use:
OnInit(){ flag=1; num=8; //variables will be initialized at startup }
OnTime(DOW (1-7), day-month-year, hours, minutes, seconds)—running at specific time.
OnTime(W,D,X,Y,H,C,S) { //W - DOW (0 - Monday, 6 - Sunday); //D - date in the day-month-year format, 16 August 2001 is "16-08-01" //X,Y - reserved //H - hour //C - minutes //S - seconds // COMPARING WITH PARAMETERS, THE ACTION IS SPECIFIED FURTHER }
Examples of use:
OnTime(W,"16-08-01",X,Y,"11","11","30") { //the code will be executed on 16 August, 2001 at 11:11:30 }
OnTime(W,D,X,Y,"11","11","30") { //the code will be executed every day at 11:11:30 }
OnTime(W,"16-08-01",X,Y,H,C,S) { //the code will be executed on 16 August, 2001 //every second }
OnTime(W,"16-08-01",X,Y,"11","11",S) { //the code will be executed on 16 August, 2001 //every second from 11:11 to 11:12 }
OnTime("0",D,X,Y,"21","0","0") { //the code will be executed every Monday // at 21:00:00 }
OnEvent(source type, number,event)—running if there is a specific event from the system object. This is the main procedure when writing scripts.
Examples of use:
OnEvent("GRAY","1","ON") { //will be executed when closing sensor 1 }
OnEvent("CAM","12","MD_START") { //will be executed when motion detection tool of camera 12 triggers }
Each procedure that has parameters can be seen in a code many times with various parameters. When an event occurs, the system will execute those of them that have the same parameters as one that has occurred.
The procedure parameter can be defined or not. If it is defined, then its value is in quotes, otherwise the parameter is written in Latin letters and the procedure will be executed for all events for which it can be defined.
Examples of use:
OnEvent("GRAY","1","ON") // will be executed when closing sensor 1 { i=1; i=i+1; //as variables are string, then the sum will be 11 j=1; j=str(j+1); // str is a number-to-string conversion function. Inside the str //function all string variables (if any) are converted to integers and //then all integers are added together, therefore, the sum will be 2. }
OnEvent("GRAY",N,"ON") //will be executed when any sensor is closed { if(strequal(N,"3") { // will be executed if this is sensor 3 } }