Search in sources :

Example 1 with AbstractDataQuantizer

use of com.serotonin.m2m2.view.quantize2.AbstractDataQuantizer in project ma-modules-public by infiniteautomation.

the class XidPointValueMapRollupCalculator method generateStream.

/* (non-Javadoc)
	 * @see com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.PointValueTimeStream#streamData(java.io.Writer)
	 */
@Override
protected void generateStream(DateTime from, DateTime to, JsonGenerator jgen) throws IOException {
    Iterator<Integer> it = this.voMap.keySet().iterator();
    while (it.hasNext()) {
        DataPointVO vo = this.voMap.get(it.next());
        jgen.writeArrayFieldStart(vo.getXid());
        DataValue startValue = this.getStartValue(vo.getId());
        BucketCalculator bc = this.getBucketCalculator(from, to);
        final AbstractDataQuantizer quantizer = createQuantizer(vo, startValue, bc, jgen);
        this.calculate(quantizer, vo.getId(), from, to);
        jgen.writeEndArray();
    }
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) DataValue(com.serotonin.m2m2.rt.dataImage.types.DataValue) BucketCalculator(com.serotonin.m2m2.view.quantize2.BucketCalculator) AbstractDataQuantizer(com.serotonin.m2m2.view.quantize2.AbstractDataQuantizer)

Example 2 with AbstractDataQuantizer

use of com.serotonin.m2m2.view.quantize2.AbstractDataQuantizer in project ma-modules-public by infiniteautomation.

the class XidPointValueMapRollupCalculator method generateStream.

/* (non-Javadoc)
	 * @see com.serotonin.m2m2.web.mvc.rest.v1.model.QueryArrayStream#streamData(com.serotonin.m2m2.web.mvc.rest.v1.csv.CSVPojoWriter)
	 */
@Override
protected void generateStream(DateTime from, DateTime to, CSVPojoWriter<Map<String, List<PointValueTime>>> writer) {
    Iterator<Integer> it = this.voMap.keySet().iterator();
    boolean writeHeaders = true;
    while (it.hasNext()) {
        DataPointVO vo = this.voMap.get(it.next());
        DataValue startValue = this.getStartValue(vo.getId());
        BucketCalculator bc = this.getBucketCalculator(from, to);
        final AbstractDataQuantizer quantizer = createQuantizer(vo, startValue, bc, writer, true, writeHeaders);
        this.calculate(quantizer, vo.getId(), from, to);
        // Only write the headers on the first iteration
        writeHeaders = false;
    }
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) DataValue(com.serotonin.m2m2.rt.dataImage.types.DataValue) BucketCalculator(com.serotonin.m2m2.view.quantize2.BucketCalculator) AbstractDataQuantizer(com.serotonin.m2m2.view.quantize2.AbstractDataQuantizer)

Example 3 with AbstractDataQuantizer

use of com.serotonin.m2m2.view.quantize2.AbstractDataQuantizer in project ma-modules-public by infiniteautomation.

the class PointValueRollupCalculator method generateStream.

@Override
protected void generateStream(DateTime from, DateTime to, CSVPojoWriter<PointValueTimeModel> writer) {
    DataValue startValue = this.getStartValue(vo.getId());
    BucketCalculator bc = this.getBucketCalculator(from, to);
    final AbstractDataQuantizer quantizer = createQuantizer(vo, startValue, bc, writer, false, true);
    this.calculate(quantizer, vo.getId(), from, to);
}
Also used : DataValue(com.serotonin.m2m2.rt.dataImage.types.DataValue) BucketCalculator(com.serotonin.m2m2.view.quantize2.BucketCalculator) AbstractDataQuantizer(com.serotonin.m2m2.view.quantize2.AbstractDataQuantizer)

Example 4 with AbstractDataQuantizer

use of com.serotonin.m2m2.view.quantize2.AbstractDataQuantizer in project ma-modules-public by infiniteautomation.

the class PointValueRollupCalculator 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) {
    DataValue startValue = this.getStartValue(vo.getId());
    BucketCalculator bc = this.getBucketCalculator(from, to);
    final AbstractDataQuantizer quantizer = createQuantizer(vo, startValue, bc, jgen);
    this.calculate(quantizer, vo.getId(), from, to);
}
Also used : DataValue(com.serotonin.m2m2.rt.dataImage.types.DataValue) BucketCalculator(com.serotonin.m2m2.view.quantize2.BucketCalculator) AbstractDataQuantizer(com.serotonin.m2m2.view.quantize2.AbstractDataQuantizer)

Example 5 with AbstractDataQuantizer

use of com.serotonin.m2m2.view.quantize2.AbstractDataQuantizer in project ma-modules-public by infiniteautomation.

the class AbstractPointValueRollupCalculator method createQuantizer.

/**
 * Create the proper quantizer for csv generation
 * @param vo
 * @param startValue
 * @param bc
 * @param writer
 * @return
 */
protected AbstractDataQuantizer createQuantizer(DataPointVO vo, DataValue startValue, BucketCalculator bc, CSVPojoWriter<T> writer, boolean writeXidColumn, boolean writeHeaders) {
    if (vo.getPointLocator().getDataTypeId() == DataTypes.NUMERIC) {
        return new AnalogStatisticsQuantizer(bc, startValue, new NumericPointValueStatisticsQuantizerCsvCallback(writer.getWriter(), vo, this.useRendered, this.unitConversion, this.rollup, writeXidColumn, writeHeaders, this.limit, this.dateTimeFormat, this.timezone));
    } else {
        if (!rollup.nonNumericSupport()) {
            LOG.warn("Invalid non-numeric rollup type: " + rollup);
            // Default to first
            rollup = RollupEnum.FIRST;
        }
        return new ValueChangeCounterQuantizer(bc, startValue, new NonNumericPointValueStatisticsQuantizerCsvCallback(writer.getWriter(), vo, useRendered, unitConversion, this.rollup, writeXidColumn, writeHeaders, this.limit, this.dateTimeFormat, this.timezone));
    }
}
Also used : NonNumericPointValueStatisticsQuantizerCsvCallback(com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.statistics.NonNumericPointValueStatisticsQuantizerCsvCallback) NumericPointValueStatisticsQuantizerCsvCallback(com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.statistics.NumericPointValueStatisticsQuantizerCsvCallback) NonNumericPointValueStatisticsQuantizerCsvCallback(com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.statistics.NonNumericPointValueStatisticsQuantizerCsvCallback) ValueChangeCounterQuantizer(com.serotonin.m2m2.view.quantize2.ValueChangeCounterQuantizer) AnalogStatisticsQuantizer(com.serotonin.m2m2.view.quantize2.AnalogStatisticsQuantizer)

Aggregations

DataValue (com.serotonin.m2m2.rt.dataImage.types.DataValue)4 AbstractDataQuantizer (com.serotonin.m2m2.view.quantize2.AbstractDataQuantizer)4 BucketCalculator (com.serotonin.m2m2.view.quantize2.BucketCalculator)4 AnalogStatisticsQuantizer (com.serotonin.m2m2.view.quantize2.AnalogStatisticsQuantizer)2 ValueChangeCounterQuantizer (com.serotonin.m2m2.view.quantize2.ValueChangeCounterQuantizer)2 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)2 NonNumericPointValueStatisticsQuantizerCsvCallback (com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.statistics.NonNumericPointValueStatisticsQuantizerCsvCallback)1 NonNumericPointValueStatisticsQuantizerJsonCallback (com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.statistics.NonNumericPointValueStatisticsQuantizerJsonCallback)1 NumericPointValueStatisticsQuantizerCsvCallback (com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.statistics.NumericPointValueStatisticsQuantizerCsvCallback)1 NumericPointValueStatisticsQuantizerJsonCallback (com.serotonin.m2m2.web.mvc.rest.v1.model.pointValue.statistics.NumericPointValueStatisticsQuantizerJsonCallback)1