def aggregate(self, data, sensordescription):
        """
        this method is called when stream data has been annotated.
        :param data:
        :param sensordescription:
        :return: The aggregated data
        """
        if not data.fields:
            return None
        result = []
        try:
            aggregation_objs = self.aggregation_objs[sensordescription.uuid]
            for key, agg in aggregation_objs.items():
                agg_result = agg.control(data[key])
                if agg_result:
                    g, start, end, size = agg_result

                    r = JSONObject()
                    r.graph = g
                    r.field = sensordescription.field[key]
                    r.sensorID = sensordescription.sensorID
                    r.propertyName = sensordescription.field[key].propertyName
                    r.category = sensordescription.sensorType
                    r.aggregationMethod = sensordescription.field[key].aggregationMethod
                    r.aggregationConfiguration = sensordescription.field[key].aggregationConfiguration
                    r.start = start
                    r.end = end
                    r.size = size
                    result.append(r)
                return result
        except Exception as e:
            Log.e("aggregation failed due to Exception", e)
            return None
 def aggregate(self, data, sensordescription):
     result = []
     try:
         dftobjs = self.dftobjects[sensordescription.uuid]
         for f in dftobjs:
             g = dftobjs[f].control(data[f])
             if g:
                 r = JSONObject()
                 r.graph = g
                 r.sensorID = sensordescription.sensorID
                 r.propertyType = sensordescription.field[f].propertyName
                 r.category = sensordescription.sensorType
                 result.append(r)
         return result
     except KeyError:
         Log.e("Dft aggregation failed")
         return None
 def aggregate(self, data, sensordescription):
     if not data.fields:
         # Log.e("There was no data available so it could not be aggregated")
         return None
     result = []
     try:
         saxobjs = self.aggregation_objs[sensordescription.uuid]
         for f in saxobjs:
             g = saxobjs[f].control(data[f])
             if g:
                 r = JSONObject()
                 r.graph = g
                 r.sensorID = sensordescription.sensorID
                 r.propertyType = sensordescription.field[f].propertyName
                 r.category = sensordescription.sensorType
                 result.append(r)
         del data
         if result is not None and len(result) is not 0:
             Log.d2('SaxAggregator: Aggregation successful %s' % str(result))
         return result
     except Exception as e:
         Log.e("aggregation failed due to Exception", e)
         return None