ValueState
The ValueState object contains information about the state of the value (value, UTC time of obtaining the value, status).
Constructor
Fields
Name | Description |
value | Contains a value of arbitrary type |
status | Contains the status of the value (number), e.g. Good, BadNoCommunication, BadLicenseExpired, etc. |
time | Contains the UTC time of obtaining the value (Date) |
Examples
The following example demonstrates an expression that returns True if the data trigger state has changed from BadNoCommunication, otherwise returning False. In this example, the expression has a data trigger named some_value.
In the previous examples, the expression always returned only a value, but you can return the state of the expression as a result by defining a value, UTC time, and status:
Please note that creating an instance of ValueState will immediately put the script module into demo mode if it is not licensed
The following example shows an expression that returns a state sequence as a result.
The returned sequence cannot be seen in Go Online mode. In these cases, you can observe only the last element of the sequence (number 5), but if you specify this expression as the data source of the time series and set the discrete sampling mode for the series, you will see the following picture:
The feature described in the previous example allows you to create all sorts of filters or, for example, "unwrap" numerical arrays (INT[]) into a sequence of numbers (INT, INT, INT...).
Note that the code return [1, 2, 3, 4, 5] is not the same as the code described in the example above, in this case a value of INT[] (array of integer) type is returned when the result of the sample is a sequence of values where each value is represented by an INT type
Last updated