Formulas are used for calculating values and statuses of input channels and calculating values of commands. Formulas processing is performed by the Server application.
Formulas are contained by the Input channels and Output channels tables of the configuration database. To enable the formula, tick the appropriate checkbox in the Formula used column. The Formulas table stores additional functions and data structures which can be used in formulas for input and output channels.
The general rules of using formulas:
The rules of using formulas for input channels:
The rules of using formulas for output channels:
The variables accessible in formulas:
Variable | Value Type | Description |
---|---|---|
CnlVal, Cnl | double | The input channel value transmitted to Server before calculation |
CnlStat | int | The input channel status transmitted to Server before calculation |
CmdVal, Cmd | double | The command value transmitted to Server before calculation |
CmdData | byte[] | The command data transmitted to Server before calculation |
CnlNum | int | The channel number for which the formula is calculated |
E | double | The natural logarithmic base, specified by the constant, e |
PI | double | The ratio of the circumference of a circle to its diameter, specified by the constant, π |
The functions accessible in formulas:
Fucntion | Value Type | Description |
---|---|---|
N(n) | int | Returns the specified channel number for updating numbers on cloning |
Val() | double | Gets the current value of the formula channel |
Val(n) | double | Gets the current value of the channel n |
SetVal(n, val) | double | Sets the current value of the channel n |
Stat() | int | Gets the current status of the formula channel |
Stat(n) | int | Gets the current status of the channel n |
SetStat(n, stat) | int | Sets the current status of the channel n |
SetData(n, val, stat) | double | Sets the current value and status of the channel n |
Abs(x) | double | Calculates the absolute value of a number |
Sin(x) | double | Calculates the sine of the specified angle |
Cos(x) | double | Calculates the cosine of the specified angle |
Tan(x) | double | Calculates the tangent of the specified angle |
Exp(x) | double | Calculates e raised to the specified power |
Ln(x), Log(x) | double | Calculates the natural (base e) logarithm of a specified number |
Sqr(x) | double | Calculates the square of a specified number |
Sqrt(x) | double | Calculates the square root of a specified number |