use of com.serotonin.m2m2.rt.dataImage.types.DataValue 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.rt.dataImage.types.DataValue 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.rt.dataImage.types.DataValue 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.rt.dataImage.types.DataValue 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.rt.dataImage.types.DataValue in project ma-modules-public by infiniteautomation.
the class PointValueTimeWriter method writeNonNull.
/**
* Write a Data Value that if null contains an annotation saying there is no data at this point in time
* - useful for Rollups with gaps in the data
* @param value
* @param time
* @throws ConversionException
* @throws IOException
*/
public void writeNonNull(DataValue value, Long time, DataPointVO vo) throws ConversionException, IOException {
if (time == null)
throw new ShouldNeverHappenException("Time cannot be null");
if (value == null) {
if (useRendered) {
this.writePointValueTime(new AlphanumericValue(""), time, this.noDataMessage, vo);
} else {
this.writePointValueTime(0.0D, time, this.noDataMessage, vo);
}
} else {
if (useRendered) {
// Convert to Alphanumeric Value
String textValue = Functions.getRenderedText(vo, new PointValueTime(value, time));
this.writePointValueTime(new AlphanumericValue(textValue), time, null, vo);
} else if (unitConversion) {
// Convert Value, must be numeric
if (value instanceof NumericValue)
this.writePointValueTime(vo.getUnit().getConverterTo(vo.getRenderedUnit()).convert(value.getDoubleValue()), time, null, vo);
else
this.writePointValueTime(value, time, null, vo);
} else {
this.writePointValueTime(value, time, null, vo);
}
}
}
Aggregations