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();
}
}
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;
}
}
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);
}
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);
}
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));
}
}
Aggregations