The GetCurrentDataForDevice() function retrieves the most recent value for the specified data item for the specified asset, which is NOT the asset that triggers the expression rule (also referred to as the "current asset"). This function retrieves the value as an Object, which can be Boolean, Double, or String, depending on the data item.
Object GetCurrentDataForDevice(String model,
String serialnumber, String dataitem)
where:
model -- The name of model for the asset from which you want to retrieve the most recent value.
serialnumber -- The serial number of the asset.
dataitem -- The name of the data item whose most recent value you want to retrieve.
If historical functions are enabled for your Platform, you can use this function in combination with the GetDataN function to compare the value of a data item for the current asset with the most recent value for the same data item from another asset.
The following example compares three temperature readings taken for the asset that generated the rule with the current temperature for the asset, "device1".
If: max(DataItem.AMtemp.value,DataItemNoonTemp.value,DataItem.PMtemp.value) > GetCurrentDataForDevice("model1","device1","AMtemp")
The following example compares the current temperature value of the asset that generated the rule with the most recent value for the same data item (temperature) of another asset.
If: temperature > GetCurrentDataForDevice("model1","device1","temperature")
Using the historical data function, GetDataN, inside the max function, the following example compares the last ten temperature values of the asset that generated the rule with the current temperature for the asset, device1:
If: max(GetDataN("temperature", 10)) > GetCurrentDataForDevice("model1", "device1", "temperature"))