You can create your If-Then-Else expressions using the asset-related functions and actions in combination with other basic expression functions.
Average - avg()
The following example determines the average value of temperature readings taken from an asset during the day (AM, Noon, PM) and compares that average to 80. If the average is higher than 80, then the HighTemp alarm is created. This example shows how to specify an array of data item values to average using the fully qualified format for each data item value, separated by a comma, with no space between the data items.
If avg(DataItem.AMTemp.value,DataItem.NoonTemp.value,DataItem.PMTemp.value) > 80
Then CreateAlarm(HighTemp, 100, "HighTemp = " +str(DataItem.HighTemp.value))
Minimum - min()
The following example looks for the lowest pressure reading taken from an asset during the day (AM, Noon, PM) and compares that lowest reading to 60. This example shows how to specify an array of data item values to check using the fully qualified format for each data item value, with the data items separated by a comma, with no space:
If min(DataItem.AMpressure.value,DataItem.NoonPressure.value,DataItem.PMpressure.value) > 60
Maximum - max()
The following example looks for the highest pump speed among three different assets (pumps) and compares it to 50;. The data item (Speed) from the first pump is obtained directly because the pump is the asset that is in the context of the message that is causing the expression rule to run. To obtain the Speeds of the second and third pumps, you need to use the function that can retrieve data from an asset other than the one in the current context, GetCurrentDataForDevice:
If max(DataItem.Speed.value, GetCurrentDataForDevice("Pump236A", "Pump2","Speed"), GetCurrentDataForDevice("Pump236A", "Pump3", "Speed")) >= 50
Convert number to a String - Str()
In the following example, if the value of data item "Temp" is greater than 82, and the value of data item "AC" is equal to 1, then the HighTemp alarm is created with a description that shows the value of Temp in string format.
If DataItem.Temp.value >82 && DataItem.AC.value==1
Then CreateAlarm(HighTemp, 250, "AC Is on, temp = " + str(DataItem.temp.value))
Note: If you want an audit message (Audit() function) to include ANALOG or DIGITAL data items or the LOCATION variable, then you must convert them to the String data type using str().