cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Axeda Expression Rules

No ratings

Expression rules are the heart of the Axeda Platforms 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 that 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.

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.

Creating and Testing an Expression Rule

We're going to create a simple Expression Rule and show it running in a few steps. Above, you saw a rule that created an alarm when temperature > 80. Now, we will make one that converts a temperature in F to one in C.

An Expression Rule consists of a few things:

  • Name
  • Description - an optional field to describe the rule
  • Trigger - what makes this rule run? The trigger tells the rule if it applies to Alarms, Data, Files, or many others.
  • If - the logic expression for the condition to evaluate
  • Then - the logic to run if the condition is true
  • Else - the logic to run if the condition is false

To begin, log into an Axeda Platform instance.

Navigate to the Manage tab

Select ​New​, then ​Expression Rule

Enter this Expression Rule information

Name: TempConvert
Type: Data
Description:
Enabled
: Leave checked

If: TempC
Then: SetDataItem("TempF", TempC*9/5 + 32)


If you click on functions or scroll down for actions in the Expression Tree, you will see a description in Details.

Click the Apply to Asset​ button to select models and specific assets to apply this rule to.

Now that you have an Expression Rule, lets try it.

Testing the Expression Rule (NEEDS UPDATING)

You can test the expression rule by simulating the TempC data using Axeda Simulator, as instructed below. Or, you can use the Expression Rules Debugger to simulate the reading and display the results. For information about using the Expression Rules Debugger, see the Expression Rules Debugger documentation in the on-line Help system.Simulate a TempC reading

Launch the Axeda Simulator

The Axeda Simulator will launch in a new browser window

  • Enter your registered email address, Developer Connection password, and click Login.

     

Select asset1 from the Asset dropdown.

Under the Data tab, enter the dataitem name TempC, and a value like 28:

Then Click Send.

To see the exciting result, go back to the Platform window and navigate to the Service tab:

and you should see that 28C = 82.4F.

You created an Expression Rule that triggers when a value of TempC is received, and creates a new dataitem TempF with a calculated value. This rule applies to your model, but if you had many models of assets, it could apply to as many as you want.

You could change the rule to do the conversion only If: TempC > 9 and simulate inputs to see that this is the new behavior.

Further Reading

  • Read about how Rule Timers can trigger rules to run on a scheduled basis. (TODO)
Version history
Last update:
‎Jun 03, 2016 06:58 PM
Updated by:
Labels (2)