V2/Concepts/Expression

From Senfi Docs
Jump to: navigation, search

Expression

User can make use of Senfi's flexible autonomous intelligence engine to be alerted of abnormality in the system they are monitoring.

As introduced, an Expression is a tool that you can use to monitor your assets and be notified of abnormal situations or events. You can configure an expression to trigger an event to send email or notify your operators in the Digital Twin. Examples of use cases include: a fire is detected in a building, a lift has broken down, or when a machine is overdue for maintenance. Expression editor is the tool you can use to configure these conditions.

An Expression in Senfi comprises of:

  • Inputs - Assets, Metric & Tag values
  • Conditions - Data transformation and/or logic
  • Result - False to True / True to False
  • Event - Trigger Event when Result changes. e.g. fire detected
  • Expression execution type - Configures when a Expression is evaluated

Inputs are evaluated by Conditions to generate a single Result. When value of Result changes (from False to True or True to False), an Event can be triggered. Actions defined in the Event such as email and Digital Twin alerts, are executed when the Event is triggered. Expression execution type allows you to configure how the Expression is executed. e.g: how often the Expression is evaluated, whether it's immediate or on poll.

Inputs --> Conditions --> Result

Result Changed --> Event --> Actions

Example

Using our Smart Weighing Scale measurement from earlier, we can form one simple Expression as follows:

  • Input: iot_weighingscale_v1.battery_level
  • Condition: < 20
  • Event: Battery level low
  • Event action: Send email notification to remind changing of battery
  • Expression execution type: Immediate (means evaluate this rule whenever there is any incoming measurement)

Inputs, Conditions and Result

Before adding an Expression, you should already have an Event or situation that you wish to be notified about. The Event or situation should be one that can be detected by monitoring data received by Senfi.

Concepts Automation Expression.png


Select Assets as Inputs, from which the Measurements, Metrics, Location and Attribute can be used to detect an Event or situation. Then, construct the set of Conditions from data transformation or logic functions. The set of Conditions will evaluate from false to true or true to false when Event or situation occurs. The result of said Conditions is the Result of the Expression. Whenever Result changes (from true to false and vice versa), Events may be triggered.

Expression Execution Options

By setting Type to Immediate or Polling, you can choose to execute an Expression when new values are received for any Input Measurements, or periodically, regardless of whether any Input Measurements have changed.

If Expression is set to run periodically (Polling), you must specify how often the Expression is executed by setting Intervals in seconds.

Expression Editor

Expressions are defined using the Expression Editor. The Expression Editor is a graph-based Drag & Drop editor.

Expression Editor

Arrows coming in from the left of a node indicate its input and those going out from its right indicate its output.

Input & Output of a Node

Each Node falls into one of the following categories:

  • Asset Identifier
  • Input
  • Data Transformation
  • Logic
  • Result
  • Event

Data originates from Metric nodes, is transformed by Data Transformation and/or Logic nodes, and eventually consumed by Result & Event nodes.

Input nodes
Metric - outputs the value/s of a metric. can be set to output the last known value, or a range of historical values
Logic Nodes
Compare - comparison operators. e.g. <, >=, ==, !=
Logic - perform "AND" or "OR" between 2 or more boolean values
Data Transformation nodes
Filter - used to filter a range of values and output a subset number of values. Can only be used after a Metric node in "Range of Value" mode and before an Aggregate
Aggregate - used to aggregates a range of values into a single value. E.g. sum, average, median. Can only be used after a Metric node in "Range of Value" mode
Function - value-wise transformation. Transform each value, e.g ABS, Floor, Round etc. Can be used after a Metric node and before a Compare node. Outputs the same number of values as its input.
Result node
Result - Result node. Specifies the Result of an Expression. Result can be False to True or True to False.
Event nodes
Event - Event node. Input must always be from the "Result" node. Can have 0 or more "Event" nodes. Instructs Senfi to do something when Result changes. Event Input Data is passed on to the related Event.

See Node Type for more information about each Node Type.

Example

Example 1

Example 1: A simple Expression detecting when a Lift has tripped (safetyTrip == 1).

Example 2

Example 2: Detects when a Lift tripped (safetyTrip == 1), AND passengers are trapped in the Lift (load > 0)

Working with historical values

When historical values is required to detect an event, the "Range", "Filter" and "Aggregate" nodes are needed.

By default, a "Metric" node will output the Last Known value of the metric. To obtain historical values of a metric, select "Range value of" for "Metric" node type.

The configuration options of the "Range value" type allows you to change the range of historical values to output. E.g: You can configure it to output metric values from 1 hour ago till now, or the last 10 received metric values.

After obtaining the list of historical values, you can:

  • Filter the list using the "Filter" node.
  • Transform each value in the list using the "Function" node.

The "Filter" and "Function" nodes can be nested.

Finally, the list of historical values must be aggregated using the "Aggregate" node before its output can be used by a "Logic" or "Operator" node.

Example using historical values

Historical Example 1

The example above detects when a Lift is stopped at Level 2 for over a minute.

Configuring Nodes

Each node contains attributes & options which you can modify. To modify the attributes of a node, move your mouse over the node and click on the "Gear" button that appears near the top right corner of the node (Beside the "X" button). A window will popup to allow you to configure the node.

Aggregate node

This section explains what each of the options for "Aggregate" node does.

sum
the sum of all input values
count
the number of input values
average
the average of input values
median
the median value of input values
max
the largest value
min
the smallest value
mode
the value that appears most often
range
the difference between the largest and smallest value (max - min)
stddev
standard deviation
percentile
percentile. This option accepts an additional "Percentile Value" parameter.
every
outputs true if every value fulfills the condition. This option accepts an additional "Condition" parameter.
any
outputs true if at least 1 value fulfills the condition. This option accepts an additional "Condition" parameter.

Function node

This section explains what each of the options in "Function" node does.

abs
absolute value
round
round to nearest integer
ceil
round up
floor
round down
map
This option accepts an additional "function" parameter. Using the custom "function" parameter, transforms each input value

What's Next