Expression Rules

Expression rules are the heart of the Platform's processing capability. These rules have an If-Then-Else structure that's easy to create and understand. We think they're like a formula in a spreadsheet. For example, say your asset has a dataitem reading for temperature:

If: temperature > 80
Then: CreateAlarm("High Temp", 100)

This rule compares the temperature to 80 every time a reading is received. When this happens, the rule creates an alarm with name "High Temp" and severity 100.

Dataitems represent readings from an asset. They are typically sensors or monitoring parameters in an application. But also think of dataitems as variables. The rule can be changed to

If: temperature > threshold

so each asset has its own threshold that can be adjusted independently.

Look at the complete list of Expression Rule

  • triggers - the events that trigger a rule to run
  • variables - the information you can access in an expression
  • functions - the functions that can be used within an expression
  • actions - these are called in the Then or Else part of an expression to make something happen

A rule can calculate a new value. For example, if you wanted to know the max temperature

If: temperature > maxTemperature
Then: SetDataItem("maxTemperature" temperature)

To convert a temperature in celsius to fahrenheit

If: temperature
Then: SetDataItem("tempF", temperature*9/5 + 32)

The If simply names the variable, so any change to that variable triggers the rule to run. There may be lots of other dataitems reported for an asset, and changes to the other dataitems should not recalculate the temperature.

Read about how Rule Timers can trigger rules to run on a scheduled basis.

When rules should run only when an asset is in a particular mode or state, or when there is a complex sequence to model, read about how State Machines come to the rescue.

This tutorial shows how to create and test an Expression Rule.