When an Expression Rule of type Data calls a Groovy script, the script is provided with the implicit object dataItems. This example shows how the dataItems object can be used.to get the dataitem information (value, name, type and update time)
import com.axeda.drm.sdk.data.*
import com.axeda.drm.sdk.device.DataItem
try {
def deviceName = context.device.name
// implicit object dataItems passes a list of dataItem objects
def dataItemsList = dataItems
for(dio in dataItemsList) {
logger.info("Checking " + dio.name + " Value: " + dio.value)
if(dio.name == "updateTime") {
logger.info("Found: " + dio.name + " Value: " + dio.value + " Type: " + dio.perceptType + " Last Updated: " + new Date(dio.timeInMillis))
// perceptType = analog, digital or string
}
}
}
catch (Exception e) {
logger.error e.message
}