Search in sources :

Example 1 with ValueChangeCounterChildQuantizer

use of com.serotonin.m2m2.web.mvc.rest.v1.statistics.ValueChangeCounterChildQuantizer in project ma-modules-public by infiniteautomation.

the class IdPointValueRollupCalculator method generateStream.

/* (non-Javadoc)
	 * @see com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.AbstractPointValueRollupCalculator#generateStream(org.joda.time.DateTime, org.joda.time.DateTime, com.serotonin.m2m2.web.mvc.rest.v1.csv.CSVPojoWriter)
	 */
@Override
protected void generateStream(DateTime from, DateTime to, CSVPojoWriter<PointValueTimeModel> writer) {
    BucketCalculator bc = this.getBucketCalculator(from, to);
    IdPointValueStatisticsQuantizerCsvCallback callback = new IdPointValueStatisticsQuantizerCsvCallback(writer.getWriter(), this.voMap, this.useRendered, this.unitConversion, this.rollup, this.dateTimeFormat, timezone);
    Iterator<Integer> it = this.voMap.keySet().iterator();
    ParentDataQuantizer quantizer = new ParentDataQuantizer(bc, callback);
    while (it.hasNext()) {
        DataPointVO vo = this.voMap.get(it.next());
        DataValue startValue = this.getStartValue(vo.getId());
        if (vo.getPointLocator().getDataTypeId() == DataTypes.NUMERIC) {
            quantizer.startQuantizer(vo.getId(), startValue, new AnalogStatisticsChildQuantizer(vo.getId(), quantizer));
        } else {
            quantizer.startQuantizer(vo.getId(), startValue, new ValueChangeCounterChildQuantizer(vo.getId(), quantizer));
        }
    }
    this.calculate(quantizer, from, to);
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) DataValue(com.serotonin.m2m2.rt.dataImage.types.DataValue) IdPointValueStatisticsQuantizerCsvCallback(com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.statistics.IdPointValueStatisticsQuantizerCsvCallback) AnalogStatisticsChildQuantizer(com.serotonin.m2m2.web.mvc.rest.v1.statistics.AnalogStatisticsChildQuantizer) BucketCalculator(com.serotonin.m2m2.view.quantize2.BucketCalculator) ParentDataQuantizer(com.serotonin.m2m2.web.mvc.rest.v1.statistics.ParentDataQuantizer) ValueChangeCounterChildQuantizer(com.serotonin.m2m2.web.mvc.rest.v1.statistics.ValueChangeCounterChildQuantizer)

Example 2 with ValueChangeCounterChildQuantizer

use of com.serotonin.m2m2.web.mvc.rest.v1.statistics.ValueChangeCounterChildQuantizer in project ma-modules-public by infiniteautomation.

the class IdPointValueRollupCalculator method generateStream.

/* (non-Javadoc)
	 * @see com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.AbstractPointValueRollupCalculator#generateStream(org.joda.time.DateTime, org.joda.time.DateTime, com.fasterxml.jackson.core.JsonGenerator)
	 */
@Override
protected void generateStream(DateTime from, DateTime to, JsonGenerator jgen) {
    BucketCalculator bc = this.getBucketCalculator(from, to);
    IdPointValueStatisticsQuantizerJsonCallback callback = new IdPointValueStatisticsQuantizerJsonCallback(jgen, this.voMap, this.useRendered, this.unitConversion, this.rollup, this.limit, this.dateTimeFormat, timezone);
    Iterator<Integer> it = this.voMap.keySet().iterator();
    ParentDataQuantizer quantizer = new ParentDataQuantizer(bc, callback);
    while (it.hasNext()) {
        DataPointVO vo = this.voMap.get(it.next());
        DataValue startValue = this.getStartValue(vo.getId());
        if (vo.getPointLocator().getDataTypeId() == DataTypes.NUMERIC) {
            quantizer.startQuantizer(vo.getId(), startValue, new AnalogStatisticsChildQuantizer(vo.getId(), quantizer));
        } else {
            quantizer.startQuantizer(vo.getId(), startValue, new ValueChangeCounterChildQuantizer(vo.getId(), quantizer));
        }
    }
    this.calculate(quantizer, from, to);
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) IdPointValueStatisticsQuantizerJsonCallback(com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.statistics.IdPointValueStatisticsQuantizerJsonCallback) DataValue(com.serotonin.m2m2.rt.dataImage.types.DataValue) AnalogStatisticsChildQuantizer(com.serotonin.m2m2.web.mvc.rest.v1.statistics.AnalogStatisticsChildQuantizer) BucketCalculator(com.serotonin.m2m2.view.quantize2.BucketCalculator) ParentDataQuantizer(com.serotonin.m2m2.web.mvc.rest.v1.statistics.ParentDataQuantizer) ValueChangeCounterChildQuantizer(com.serotonin.m2m2.web.mvc.rest.v1.statistics.ValueChangeCounterChildQuantizer)

Aggregations

DataValue (com.serotonin.m2m2.rt.dataImage.types.DataValue)2 BucketCalculator (com.serotonin.m2m2.view.quantize2.BucketCalculator)2 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)2 AnalogStatisticsChildQuantizer (com.serotonin.m2m2.web.mvc.rest.v1.statistics.AnalogStatisticsChildQuantizer)2 ParentDataQuantizer (com.serotonin.m2m2.web.mvc.rest.v1.statistics.ParentDataQuantizer)2 ValueChangeCounterChildQuantizer (com.serotonin.m2m2.web.mvc.rest.v1.statistics.ValueChangeCounterChildQuantizer)2 IdPointValueStatisticsQuantizerCsvCallback (com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.statistics.IdPointValueStatisticsQuantizerCsvCallback)1 IdPointValueStatisticsQuantizerJsonCallback (com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.statistics.IdPointValueStatisticsQuantizerJsonCallback)1