GetDataNForDevice() Function

Like the GetDataN() function for the current asset, the GetDataNForDevice() function retrieves the last N values posted to the Platform for the specified data item as an array. The difference is that this function retrieves values posted by ANOTHER asset, specified in the model and serialNumber arguments of this function. Use this function when you want to compare data from the current asset with data from another asset.

The Platform cannot return more than 100 values. The array can contain Boolean values, numbers, or Strings, depending on the data item. This function must be used within a statistical function; either min, max, or avg.

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

Historical 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.

If no data exists for a specified data item or time frame, the function returns an empty array.

 

Format:

Array GetDataNForDevice(String model, String serialnumber, String dataitem, Number number)


where:

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

serialnumber -- The serial number of the asset.

dataitem -- The name of the data item whose N values you want to retrieve.

number -- The number of values to retrieve for the data item. This function cannot return more than 100 values.

 

Use this function in combination with the GetDataN function to compare the values for a data item from the current asset with the values for the same data item from another asset.

Example:

The following example retrieves the last ten values for the data item "temperature" for the asset that generated the expression rule and picks the highest value from them. It also retrieves the last ten values for the same data item from a different asset (model1, device1) and determines the highest value. The example then compares the two values to see if the value for the asset that generated the rule is higher than that for the other asset:

If: max(GetDataN("temperature", 10)) > max(GetDataNForDevice("model1","device1","temperature", 10))

 

See Also