Перейти до вмісту

Appendix C: Task Files

Цей контент ще не доступний вашою мовою.

After running, EM-486 starts execution of the program for logic of action, if it was placed earlier in the built-in memory. If there is no program in the built-in memory, EM-486 searches for and checks the task files placed in the folder “TASKS” on the memory card, provided the card is formatted in the FAT or FAT32 format. The correctly discovered files are read in the built-in memory and form the logic program of actions. Such a reading runs once after startup or after installing a new memory card, only if the built-in memory does not contain the programs.

To clean the internal memory, you should:

  1. Enter EM-486 parameter setting via WEB interface (see Manual, para 5.3.3)
  2. Go to the tab “Files”
  3. Press the button “Clear built-in tasks memory”
  4. If the result of the reading the program is not displayed immediately in the tab “Files”, refresh the page a few seconds later

The tab “Files” indicates the result of reading the folder “TASKS”, including the number of discovered and read files. If during reading and verifying the program errors were detected, then it indicates the type of error, file and line number of the file error. If the program consisted of several files in the folder “TASKS”, then the internal memory will read all files except those in which errors are detected. Therefore, during error correction you should compare the number of discovered and read files and if some were read, to clear again the internal memory to re-read the program.

Files can have arbitrary names and extensions and placed in subfolders of the folder “TASKS”. Files placed directly in the folder TASKS, allow you to use MODBUS ID default in the text, equal to MODBUS ID of the device EM-486. Files placed in subfolders in the folder “TASKS” with names from “1” to “247”, allow to use the text MODBUS ID default name of the subfolder. Therefore, if the program logic is divided into tasks so that each is associated with its connected device, it is recommended that files relating only to EM-486, to be placed in the folder “TASKS” and files related to primarily the other device, to be put in a subfolder with the name of the MODBUS ID of this device. This allows you to change the list of managed devices by copying and renaming the subfolders, and create universal and portable files of the tasks.

File of tasks describes repeated after a specified time interval the set of actions for gathering, processing and comparing the data and special actions after fulfillment of the preset conditions according to the processing results.

The task file is divided into sections which in turn are divided into lines.

The section is part of the file that starts with ”!” and the name of the section written in a row.

Correct example:

!META
* UPDATE 60
!PARAMS
...

Incorrect example:

META
UPDATE 60
PARAMS
...

If the section allows you to refer the lines in it, then all the lines of the section are numbered, otherwise instead of a number of the line will be put the sign *. The format of the line is different in each section. The number and order of sections does not matter (sections can be interrupted and then be continued after one or more sections), if two rules are fulfilled:

1. If a section with numbered lines is found for the first time, the numbering starts with 0, otherwise, numbering continues from the previous section of the same name.

Correct example:

...
!VARS
0 VAL 0
!CONDS
0 VAREQVAL V0 0
!ACTS
0 RELAYON 1 2
1 RELAYOFF 1 2
!REACTS
* C0 ACT A0
!CONDS
1 NOT C0
!REACTS
* C1 ACT A1
...

Incorrect example:

...
!VARS
0 VAL 0
!CONDS
0 VAREQVAL V0 0
!ACTS
0 RELAYON 1 2
1 RELAYOFF 1 2
!REACTS
* C0 ACT A0
!CONDS
0 NOT C0
!REACTS
* C1 ACT A1
...

2. Link to next line should be below the line that is referenced.

Correct example:

...
!CONDS
0 VAREQVAL V0 0
1 NOT C0
...

Incorrect example:

...
!CONDS
0 NOT C1
1 VAREQVAL V0 0
...

The file should end with an empty line or a comment. The file should not have extra spaces, including at the end of lines. The file can contain comment lines that begin with #, and are ignored when reading the file.

Correct example:

...
# this is comment
!VARS
# number of seconds in a minute
0 VAL 60
1 VAL 1
...

Incorrect example:

...
# this is comment
!VARS
0 VAL 60 # number of seconds in a minute
1 VAL 1
...
SectionDescription
METAGeneral information and the file run settings
DEVICESMODBUS devices capabilities
PARAMSParameters, registers and bits of MODBUS devices, and type conversion
VARSVariables, transformation of parameters and calculations
PHONESPhone numbers to which SMS are sent
STRSTexts of messages to send to SMS
CONDSComparison of variables, the conditions for performing actions
ACTSActions that can be performed
REACTSReactions that determine under what conditions you will run the actions

It contains the general information about the file and settings for its execution, and is responsible for the particularities of the program cycle fulfillment (the so-called “updates”), including the frequency of updates. Lines in it do not have numbering, instead of index is *. Each line has the following format:

* <modifier type> <argument>

The types of the arguments are the following:

  • <int> - 32-bit signed integer
  • <uchar> - 8-bit unsigned integer
  • <ushort> - 16-bit unsigned integer
ModifierDescription
PROTOCOLVERSION <int>Version of the file: It prevents the processing of files with outdated firmware EM-486. The version described in this document is 9
UPDATE <int>Frequency of the program cycle fulfillment (update rate) in seconds: Every cycle has the reading of parameters, calculation of variables values, defining operation conditions and implementation of response to these conditions. The frequency determines only the approximate time of the cycle restart. If during the task execution the time of the new update (this or another task) will be skipped, this new update will be postponed until the end of the running cycle. If one or more updates are missed for the deferred update, these additional updates will not be performed. The minimum value is 1 second. For higher speeds, the UPDATE DIVISOR modifier should be used. By default, if a modifier is not specified, it equals to 60
UPDATEDIVISOR <int>Update divisor. It allows you to speed up the update rate. If the divisor is 0, update cycles are performed with an accuracy of not more than 1 second. For other values, the accuracy is not more than 0.002 seconds, and the resulting frequency, equal to the value of the UPDATE / UPDATE DIVISOR fraction, cannot be greater than 60 or less than 0.002 seconds. Practical limiting speed, as a rule, is less. The speed is significantly reduced when using SMS and parameters in the task file, which are accessed through RS-485 and GSM interfaces. By default, if no modifier is specified, it is 0
PARAMACTUAL <ushort>Frequency of reading the parameters in seconds: It allows optimizing the number of readings of parameters. At the moment of the updating the parameter it is checked how many seconds ago it was read last time, and if this time is not more than the value PARAMACTUAL, then upgrade option will not be read and the last read value of the Parameter will be accepted as current one. Thus, if the total program consists of several files, reading the same parameters, the number of readings of these parameters and the excessive load on the communication channels can be reduced. For the value 0 – with each update the parameter values will be read again. By default, if a modifier is not specified, it equals to 0
PARAMRETRIES <uchar>Number of times to repeat reading in case of error: The value 0 for the programming cycle there will not be more than one attempt to read the parameter. For 1 – it will be made up to two attempts to read, etc. Calculations and reaction to conditions can be performed even without a successful reading of all parameters, if they have sufficient known data. By default, if a modifier is not specified, it equals to 0
PARAMTIMEOUT <int>Time of waiting for response to MODBUS query in milliseconds: It is used if in the settings of EM-486 the total timeout MODBUS is more than frequency of update of this file, or if the exception code generation is disabled if no MODBUS response. By default, if a modifier is not specified, it equals to 1000
PARAMLOADRATIO <uchar>Maximum load of RS-485 channel, in percent: After each query a delay is added, depending on the waiting time of the last response that allows other clients to send queries and receive responses. A value of 100 generates the minimum possible delays (it is not recommended). A value of 50 means a delay equal to the time of waiting for a response. A value of 25 means a delay of 3 times exceeding the response time. By default, if a modifier is not specified, it equals to 25

Example:

!META
* PROTOCOLVERSION 9
* UPDATE 5
* PARAMRETRIES 2

It contains the capabilities of MODBUS devices, the settings of not specified here devices will be treated the same as for the device with maximum features and functions. The lines in this section do not have numbering, instead of an index is *. Each line has the following format:

* <MODBUS ID of device> <record type> <argument 1> [argument 2]

MODBUS device ID: a number from 1 to 247. “0” – is the broadcast, it can be used to configure recording simultaneously to all devices that support the broadcasting (the argument 1 in this case is defined, but not used). * instead of the MODBUS ID means a device by default for this folder (EM-486, if the file is placed directly in the program folder, or device with the MODBUS ID of the name of the subfolder, if the file is placed in the subfolder named “1” to “247”).

Lines with different types or arguments, but with the same MODBUS ID are not permitted. These lines being in different files in the folder of programs are also considered to be incorrect.

Arguments type: <uchar> – 8-bit unsigned integer.

Record TypeDescription
WRHANY <uchar> <uchar>Device can write both as a function of 6 and function of 16 in the storage registers. The first argument specifies how many registers can be read in one query; the second one determines how many you can record in a single query
WRHMULTIPLE <uchar> <uchar>Device can write only using function 16 in the storage registers. The first argument specifies how many registers can be read in one query; the second one determines how many you can record in a single query
WRHSINGLE <uchar>Device can write only using function 6 in the single storage register. The argument specifies how many registers can be read in one query
WRHDENIED <uchar>Device can’t write to the storage registers. The argument specifies how many registers can be read in one query

Example:

!DEVICES
* * WRHANY 50 50
* 3 WRHSINGLE 4

It contains parameters, their addressing, and conversion between types (how they are used by the device). When reading the settings are always converted from the specified type to the default type for the program EM-486 (INT32 – 32-bit signed integer). When recording the inverse transform is performed. The lines in this section are in ascending order, starting from zero. Each line has the following format:

<index> <MODBUS ID of device> <data type> <register table> <address>
  • Index: the sequential number of the line
  • MODBUS ID of device: a number from 1 to 247. “0” – is the broadcast, it can be used for writing only. * instead of the MODBUS ID means a device by default for this folder (EM-486, if the file is placed directly in the program folder, or device with the MODBUS ID of the name of the subfolder, if the file is placed in the subfolder named “1” to “247”)
  • Tables of registers:
    • H - storage registers (most frequently used registers)
    • I - input registers
    • D - digital inputs
    • C – flags
  • Address: a number from 0 to 65535
TypeDescription
0 UINT1616-bit unsigned integer. It occupies one register
1 INT1616-bit signed integer
2 INT16BLE16-bit signed integer with reverse order of byte transfer
3 INT3232-bit signed integer. It occupies 2 registers
4 INT32BLE32-bit signed integer with reverse order of bytes
5 INT32WLE32-bit signed integer with reverse order of words
6 BIT1-bit value for the digital inputs and flags
7 INT32BE32-bit signed integer. For compatibility, the analog to INT32
8 F32EP0R32-bit rounded to an integer with floating point
9 F32BLEEP0R32-bit big-endian floating point
10 F32WLEEP0R32-bit reverse word order and floating point
11 F32EP1R32-bit floating point multiplied by 10, rounded
12 F32BLEEP1R32-bit big endian floating point × 10
13 F32WLEEP1R32-bit reversed word order floating point × 10
14 F32EP2R32-bit floating point multiplied by 100, rounded
15 F32BLEEP2R32-bit big-endian floating point × 100
16 F32WLEEP2R32-bit reversed word order floating point × 100
17 F32EP3R32-bit floating point multiplied by 1000, rounded
18 F32BLEEP3R32-bit big endian floating point × 1000
19 F32WLEEP3R32-bit with reverse order of words and floating-point × 1000

Example:

!PARAMS
0 3 UINT16 H 240

It contains variables, processing the parameters and other calculations (e.g. the sum of the parameters). The lines in this section are in ascending order, starting from zero. Each line has the following format:

<index> <source type> <argument 1> [argument 2]
  • Index: the sequential number of the line

The types of the arguments:

  • <bit number> - is the bit number of the parameter from 0 and above. For 16-bit parameters it is no more than 15. For 32-bit parameters it is not more than 31
  • <int> - 32-bit signed integer
  • <param ref> - parameter reference of format Pn, where n is index of the parameter
  • <var ref> - variable reference of format Vn, where n is index of the variable
  • <cond ref> - reference to the condition of the Cn format, where n is the condition index
Source TypeDescription
COPY <var ref>Copy the variable
VAL <int>Set to the specified value
PARAMVAL <param ref>Copy the value of the parameter
PARAMBIT <param ref> <bit number>Copy one bit of the parameter value
PARAMERC <param ref>Copy the last error code of MODBUS parameter
PARAMERN <param ref>Copy the error counter of reading the parameter (it is reset to 0 after successful reading, and is incremented by 1 after each update, for which read attempts of the parameter was terminated)
VARADDVAR <var ref> <var ref>Sum of two variables
VARADDVAL <var ref> <int>Sum of the variable and the specified value
VARMULVAR <var ref> <var ref>Product of two variables
VARMULVAL <var ref> <int>Product of the variable and the specified value
VARSUBVAR <var ref> <var ref>Difference of two variables
VARSUBVAL <var ref> <int>Difference between the variable and the specified value
VARDIVVAR <var ref> <var ref>Quotient of two variables (the remainder is discarded)
VARDIVVAL <var ref> <int>Quotient of the variable and the specified value (without remainder)
VARMODVAR <var ref> <var ref>Remainder of the division of two variables
VARMODVAL <var ref> <int>Remainder of the division of the variable by the specified value
VARSMIN <var ref> <var ref>Minimum of all variables in the specified range
VARSMINIDX <var ref> <var ref>Number of the minimum variable in the specified range
VARSMAX <var ref> <var ref>Maximum of all variables in the specified range
VARSMAXIDX <var ref> <var ref>Number of the maximum variable in the specified range
VARSSUM <var ref> <var ref>Sum of the all variables in the specified range
VARSSELBYC <var ref> <cond ref>Select one variable from the range by condition. The value of that variable from the range (from the specified to the current one), the order of which in the range corresponds to the first condition that is fulfilled (starting from the specified one). To use such a variable, it is necessary to describe not only a list of variables above it, but also a list of conditions. Since the conditions usually refer to variables, such a list of conditions is placed “in a break” in the variable list, after which the variable is placed in the continued “VARS” section. It is recommended that the last condition in the list be described in such a way that it is always fulfilled to limit the list

Example:

!VARS
0 PARAMBIT P0 0

It contains the text used as message for actions. The lines in this section are in ascending order, starting from zero. Each line has the following format:

<index> <text>
  • Index: the sequential number of the line

Special sequences in the line text:

  • *U* - MODBUS ID by default (reference to the number in the folder name where the file is located)
  • *M0* - telephone number of the main subscriber (link to the line in the device settings)
  • *<var ref>* - the value of the variable (reference to the variable, for example *V2*)
  • ** - means a single character *

Example:

!STRS
0 *U* - alarm 21: TS2 short circuit

It contains texts that are used for addressing SMS. The lines in this section are in ascending order, starting from zero. Each line has the following format:

<index> <text(phone number)>
  • Index: the sequential number of the line

Special sequences in the line text:

  • *U* - MODBUS ID by default (reference to the number in the folder name where the file is located)
  • *M0* - telephone number of the main subscriber (link to the line in the device settings)
  • *<var ref>* - the value of the variable (reference to the variable, for example *V2*)
  • ** - means a single character *

Example:

!PHONES
# Ivanoff - comment
0 067*v0*

It contains conditions for comparison of variables and triggering actions. The lines in this section are in ascending order, starting from zero. Each line has the following format:

<index> <condition type> <argument 1> [argument 2]
  • Index: the sequential number of the line

The types of the arguments:

  • <int> - 32-bit signed integer
  • <cond ref> - reference to the condition of the format Cn, where n is the index of conditions
  • <var ref> - reference to the variable of format Vn, where n is the index of the variable
Condition TypeDescription
IF <cond ref>Copy of the condition
CONDIS <int>Set to the specified value. The condition is met if the value is not 0. It can be used for debugging or for unconditional actions for each update cycle
NOT <cond ref>Logical NOT. The condition is satisfied, when the referred condition did not happen and vice versa
AND <cond ref> <cond ref>Logical AND. Condition is satisfied, when both referred conditions happened
OR <cond ref> <cond ref>Logical OR. The condition is satisfied, when any referred conditions occurred
VAREQVAR <var ref> <var ref>Comparison of two variables. The condition is fulfilled, if they are equal
VAREQVAL <var ref> <int>Comparison of a variable with a specified value. The condition is fulfilled when a variable by reference is equal to the specified value
VARNEVAR <var ref> <var ref>Comparison of two variables. The condition is fulfilled, if they are not equal
VARNEVAL <var ref> <int>Comparison of a variable with a specified value. The condition is fulfilled when a variable by reference is not equal to the specified value
VARGRVAR <var ref> <var ref>Comparison of two variables. The condition is fulfilled when the first variable by reference is more than the second variable
VARGRVAL <var ref> <int>Comparison of a variable with a specified value. The condition is fulfilled when a variable by reference is more than the specified value
VARLEVAR <var ref> <var ref>Comparison of two variables. The condition is fulfilled when the first variable by reference is no more than the second variable
VARLEVAL <var ref> <int>Comparison of a variable with a specified value. The condition is fulfilled when a variable by reference is no more than the specified value
VARLSVAR <var ref> <var ref>Comparison of two variables. The condition is fulfilled when the first variable by reference is less than the second variable
VARLSVAL <var ref> <int>Comparison of a variable with a specified value. The condition is fulfilled when a variable by reference is less than the specified value
VARGEVAR <var ref> <var ref>Comparison of two variables. The condition is fulfilled when the first variable by reference is no less than the second variable
VARGEVAL <var ref> <int>Comparison of a variable with a specified value. The condition is fulfilled when a variable by reference is no less than the specified value

Example:

!CONDS
0 VAREQVAL V0 1
1 NOT C0

It contains actions that can be performed (action is performed only by references from the section of the reactions REACTS, during the performance of the conditions indicated there). The lines in this section are in ascending order, starting from zero. Each line has the following format:

<index> <action type> <argument 1> [argument 2]
  • Index: the sequential number of the line

The types of the arguments:

  • <int> - 32-bit signed integer
  • <alarm reason> - is the number of causes of the accident – when any of the accidents is enabled, red LED of accident is on, so to turn off the indicator, each of them needs to be turned off
  • <relay reason> - is the number of reason to enable the relay; the relay may be on for reasons with different numbers, and remains in the active state until all causes for this relay will not be switched off
  • <relay number> - is the number of relay, it can be 1, 2 or 3
  • <param ref> - reference to the parameter of format Pn, where n is the index of the parameter
  • <phone ref> - reference to the phone of format Hn, where n is the index of the phone
  • <str ref> - reference to the line of format Sn, where n is the index of the line
  • <var ref> - reference to variable of format Vn, where n is the index of the variable
Action TypeDescription
ALARMON <alarm reason>Turn on alarm LED. Red LED alarm will be on to the action of ALARMOFF with the same number of <alarm reason>
ALARMOFF <alarm reason>Turn off alarm LED
RELAYON <relay reason> <relay number>Turn on the relay. Hold the relay on up to the action of RELAYOFF with the same number of <relay reason>
RELAYOFF <relay reason> <relay number>Turn off the relay
PARAMWRVAR <param ref> <var ref>Record the parameter with the value of the variable
PARAMWRVAL <param ref> <int>Record the parameter with the set value
SENDSMS <phone ref> <str ref>Send SMS
PARAMLOG <param ref>Write the parameter value to the log (see Appendix E - Memory Card)
PARAMCOMMENT <param ref> <str ref>Write parameter value to log with comment. Comments are written only in tabular log format
PARAMLOGCHGVAR <param ref> <var ref>Write the parameter value to the log if it has changed by more than the specified variable
PARAMLOGCHGVAL <param ref> <int>Write the parameter value to the log, if it has changed by more than the specified value

Example:

!ACTS
0 RELAYON 5 1

It contains the responses, a list of actions that must be performed under specified conditions. Lines do not have numbering, instead of an index is *. Each line has the following format:

* <cond ref> <response type> <act ref>

The types of the arguments:

  • <cond ref> - reference to the condition of the format Cn, where n is the index of the condition
  • <act ref> - reference to the action of format An, where n is the index of the action
Response TypeDescription
<cond ref> ACT <act ref>Perform once. If the condition occurred, but did not occur in the previous update, the action will be performed once
<cond ref> REPEAT <act ref>Perform each time. Regardless of the previous state, the action will be executed. The action will be executed even, if the state conditions are not defined in this update due to reading errors, but this condition has already happened earlier

Example:

!REACTS
* C0 ACT A0
* C1 REPEAT A1

For complete example programs demonstrating task file usage, see Task File Examples.