GetDataForDevice() Function

The GetDataForDevice() function is similar to the GetData function, with the difference being that this function retrieves data values (as an array) for an asset other than the asset that generated the expression rule (referred to as the "current context" for the expression rule). Use this function to retrieve data from another asset in an expression rule. For example, you want to compare the value of a data item that generated the expression rule with the value of the same data item from another asset of the same model.

Important! This function is available only if the Axeda® Platform is configured to enable historical functions.

This function can return up to 100 data item values in an array. Since the values are returned in an array, you must nest this function within one of the
statistical functions, min(), max(), or avg().

The historical data functions retrieve data from the Platform, which can slow response time for rules processing.
To ensure optimal response time, Axeda strongly recommends that you limit the amount of data these functions retrieve, the frequency that the expression rules that use them run, and the number of assets associated with expression rules that use them. For example, do not request historical data more than once per second.

 

Format:

Array GetDataForDevice(String model, String serialnumber, String dataitem, Number timespan, Number max)


Where:

model - The name of the model for the asset for which you want to retrieve data.

serialnumber - The serial number of the asset for which you want to retrieve data.

dataitem - The name of data item you want to retrieve.

timespan - The timespan during which you want to retrieve mobile locations. You can specify this value in minutes, hours, days, weeks, or months. To learn how to define the timespan, refer to Timespan values. Unless defined otherwise, the default unit for the value of the timespan is minutes.

max - Optional; the maximum number of data item values to be returned. The function does not return more than 100 data items.

The array of values for the specified device of the specified model for the specified data item over the specified time period may contain Boolean values, numbers, or Strings, depending on the data item.

When nested in one of the statistical functions, the format of this function should be:

min(GetDataForDevice(String modelnumber, String serialnumber, String dataitemname, int timespan, int max))

The min function would return the smallest data item posted to the Axeda Platform during the timespan. The max function causes the Platform to return the largest data item posted during the timespan. The avg function calculates and returns the average of the data item values.

Examples:

From the asset, Model2, Serial Number SN356, the following expression retrieves up to 20 values for temperature that were logged within the last 10 minutes and determines if the highest temperature is over 100.

If: max(GetDataForDevice("Model2", "SN356", "temperature", 10, 20)) > 100 Then do something

From the asset, Model MN458, Serial Number SN1984, the following expression retrieves up to five values for temperature that were logged within the last 3 days and determines if the lowest temperature is below 0.

If min(GetDataForDevice("MN458", "SN1984", "temperature", 3d, 5)) < 0 Then do something

From the asset, Model M_XYZ, Serial Number SN1992, the following expression retrieves all values for temperature that were logged for the past week (up to 100 values can be returned), and determines if their average was less than 0.

If avg(GetDataForDevice("M_XYZ", "SN1992", "temperature", 1w)) < 0 Then do something