Search in sources :

Example 1 with NoStatisticsGenerator

use of com.infiniteautomation.mango.statistics.NoStatisticsGenerator in project ma-modules-public by infiniteautomation.

the class MultiDataPointDefaultRollupStatisticsQuantizerStream method process.

/**
 * Process the data into lists per data point, simplify if necessary
 */
private Map<DataPointVO, List<DataPointValueTime>> process(Integer limit) {
    Map<DataPointVO, List<DataPointValueTime>> processed = new LinkedHashMap<>();
    for (DataPointVO vo : voMap.values()) {
        List<DataPointStatisticsGenerator> generators = valueMap.get(vo.getId());
        List<DataPointValueTime> values = new ArrayList<>();
        if (generators.get(0).getGenerator() instanceof NoStatisticsGenerator) {
            // Iterate and combine into an array
            for (DataPointStatisticsGenerator gen : generators) {
                NoStatisticsGenerator noGen = (NoStatisticsGenerator) gen.getGenerator();
                for (IValueTime value : noGen.getValues()) {
                    values.add(new DataPointVOPointValueTimeBookend(vo, (IdPointValueTime) value));
                }
            }
        } else {
            for (DataPointStatisticsGenerator generator : generators) {
                values.add(new DataPointRollupPeriodValue(generator, RollupEnum.convertTo(vo.getRollup())));
            }
        }
        if (values.size() > 0) {
            // As the other endpoints, limit before simplification
            if (limit != null)
                values = values.subList(0, limit);
            if (vo.isSimplifyDataSets()) {
                if (vo.getSimplifyType() == DataPointVO.SimplifyTypes.TARGET)
                    values = SimplifyUtility.simplify(null, vo.getSimplifyTarget(), true, true, values);
                else
                    values = SimplifyUtility.simplify(vo.getSimplifyTolerance(), null, true, true, values);
            }
            processed.put(vo, values);
        }
    }
    return processed;
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) NoStatisticsGenerator(com.infiniteautomation.mango.statistics.NoStatisticsGenerator) ArrayList(java.util.ArrayList) IValueTime(com.serotonin.m2m2.view.stats.IValueTime) IdPointValueTime(com.serotonin.m2m2.rt.dataImage.IdPointValueTime) DataPointVOPointValueTimeBookend(com.infiniteautomation.mango.rest.latest.model.pointValue.DataPointVOPointValueTimeBookend) LinkedHashMap(java.util.LinkedHashMap) DataPointValueTime(com.infiniteautomation.mango.rest.latest.model.pointValue.DataPointValueTime) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

DataPointVOPointValueTimeBookend (com.infiniteautomation.mango.rest.latest.model.pointValue.DataPointVOPointValueTimeBookend)1 DataPointValueTime (com.infiniteautomation.mango.rest.latest.model.pointValue.DataPointValueTime)1 NoStatisticsGenerator (com.infiniteautomation.mango.statistics.NoStatisticsGenerator)1 IdPointValueTime (com.serotonin.m2m2.rt.dataImage.IdPointValueTime)1 IValueTime (com.serotonin.m2m2.view.stats.IValueTime)1 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1