Creating Expression Rules

We're going to create a simple Expression Rule and show it running in a few steps. In Get Started, you saw a rule that created an alarm when value1 > 100. 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 create our rule, Launch the Platform (Register to enable access to an account on the Axeda Platform)

After clicking on the Platform Access Link above, a new tab or window will appear.

  • Navigate to the Configuration tab

    

  • Select New->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.

Now save the rule and associate it with your model. The rule currently has no association, so it will never run. Rules are associated to one or more models, so you can apply it to many things.

You associate by clicking on the pencil icon

Now you see the Rule Association dialog. Click on the magnifying glass, then drag your model to the right pane. Click Save.

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

Testing the Expression Rule

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.

To explore further, see the overview of Expression Rules.

Keywords: