Logic schemes
Article contents:
Logic schemes are used to program automatic actions in the system depending on the events occurring.
Logic control is possible only with the permission of "logic" or "all" in the profile of the user performing the request.
Description of logic schemes
When you send a request for a change or creation of a logical circuit, a circuit description is sent. The format of this description is as follows:
|
Where:
Condition (parentheses):
SENSORID - unique identifier of the sensor, the condition for changing the state of which is described;
OLDSTATE-NEWSTATE - the status codes of the element, condition is met by switching to this state (the values of both parameters must be the same);
OPERATOR - the code of the operator using which the result of the compound condition is calculated;
Action (braces):
SENSORID1 - unique identifier of the sensor, the state of which must be changed when the conditions of the logic circuit are fulfilled;
TIMEOUT - timeout for the action;
REPEAT - repetition of execution of the condition (optional parameter) or video duration for cameras (in seconds);
NEWSTATE2 - the status code to which the element is to be translated;
OPERATOR2 - the character '+', is used to create a compound action.
State codes:
'normal': 1;
'low alarm': 2;
'high warning' and 'warning': 3;
'high alarm' and 'alarm': 4;
'on': 5;
'off': 6;
'not connected': 7;
'pulse': 8;
'low warning': 9;
'idle': 10.
Operator Codes:
'and': the '+' character;
'or': the '|' character.
Logic circuit management
For management of logic schemes, the following types of requests are used (passed in the querytype field):
addlogic - add / change logic. Extra options are:
k - user session ID;
id - identifier of the logical circuit (this is not the identifier of the element), in case the identifier absent, a new logical circuit is created, otherwise the existing one is modified;
logic - the description of logic (the format of the description is described above);
name - the name of the logical circuit.
If the new logic circuit is successfully created, the response contains the identifier of the created element (field id) and the identifier of the logical circuit (field num), and looks like:
|
When creating a new logical circuit (id is not specified), all the listed parameters are mandatory. When changing, only modifiable parameters can be specified. Empty parameters are not allowed.
getelement - reading of the element is associated with the logic circuit. Required parameters:
k - user session ID;
id - Element ID.
The answer contains information about the element:
|
It contains the following fields:
num - identifier of the logical circuit used to access getlogic;
desc - a description of the logic circuit, compiled according to the rules above;
timeout - total time of locking the logic in seconds, 0 - if the circuit is not locked;
disabled - the remaining, at the moment, time of blocking the logic in seconds.
getlogic - get information about the logical circuit. Extra options are:
k - user session ID;
id - identifier of the requested logic circuit (this is not the identifier of the element), in the absence of which, user receives a list of all logical schemes available for reading to this user.
Example of a response to a query of a logic circuit with the identifier '3':
|
dellogic - delete information about the logical circuit. Extra options are:
k - user session ID;
id - identifier of the logical circuit.
disablelogic - disable the execution of the logical circuit. Extra options are:
k - user session ID;
id - identifier of the logical circuit;
timeout - time for which the logic circuit is rohibited tooperate.
onlogics - enable the execution of all logical schemes. Extra options are:
k - user session ID.
offlogics - disable execution of all logical schemes. Extra options are:
k - user session ID;
timeout - timeout in seconds.
Element "System" in logic schemes
The "System" element corresponds to the state of the entire system. It can be used in logic schemes. The identifier of this element is fixed and equal to "100". When using this element in conditions for logic schemes, state codes can be as follows:
'normal': 1;
'warning': 3;
'alarm': 4;
'on': 5.
Code 'on' means turning on the system (system start).
When using the "System" element to perform the forced reboot task, the status code is:
'off': 6.