DataTriggerInfo

The DataTriggerInfo object is intended for obtaining the state of the data trigger (its data source).

Fields

Name

Description

state

Contains an object of ValueState type and represents the last obtained value from the data source (tag).

states

Contains an array of objects of ValueState type and represents the sequence of values obtained from the data source (tag). This property is relevant only if the tag returns a sequence of values, for example, in the case of the IEC 60870-5-104 driver, where ASDU may contain buffered values for the same IOA.

Examples

The following example demonstrates access to data triggers. In this example, the expression has two data triggers with the names hypotenuse and cathetus and the corresponding data sources. Changing any of these triggers initiates the execution of the expression's code and updates its value.

// For brevity, we will save the length of the cathetus in an intermediate variable
var b = context.data['cathetus'].state.value;

// For brevity, we will save the length of the hypotenuse in an intermediate variable
var c = context.data['hypotenuse'].state.value;

return Math.sqrt(c*c - b*b);

The example below shows an expression that returns True if the data trigger value has not changed within 5 minutes, otherwise it returns False. In this example, the expression has a data trigger named slow and a periodic trigger (with the period of 1000 ms) that initiates the code execution.

// Interval
const INTERVAL = 5 * 60 * 1000;

var now = Date.now();
j
// Saving the time of the last update
var last = context.data['slow'].state.time;
 
// Difference in milliseconds
var millis = now - last;

if (millis > INTERVAL)
  return true;
else return false;

Last updated