cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Axeda Groovy Script: Handling dataItems

No ratings

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

}

Version history
Last update:
‎May 26, 2016 05:29 PM
Updated by:
Labels (2)