Search in sources :

Example 1 with DataValue

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

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;
    }
}
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 DataValue

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);
}
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 DataValue

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);
}
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 DataValue

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);
        }
    }
}
Also used : AlphanumericValue(com.serotonin.m2m2.rt.dataImage.types.AlphanumericValue) ShouldNeverHappenException(com.serotonin.ShouldNeverHappenException) PointValueTime(com.serotonin.m2m2.rt.dataImage.PointValueTime) NumericValue(com.serotonin.m2m2.rt.dataImage.types.NumericValue)

Aggregations

DataValue (com.serotonin.m2m2.rt.dataImage.types.DataValue)30 PointValueTime (com.serotonin.m2m2.rt.dataImage.PointValueTime)13 NumericValue (com.serotonin.m2m2.rt.dataImage.types.NumericValue)10 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)10 AlphanumericValue (com.serotonin.m2m2.rt.dataImage.types.AlphanumericValue)8 MultistateValue (com.serotonin.m2m2.rt.dataImage.types.MultistateValue)8 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)6 AnnotatedPointValueTime (com.serotonin.m2m2.rt.dataImage.AnnotatedPointValueTime)6 BinaryValue (com.serotonin.m2m2.rt.dataImage.types.BinaryValue)6 BucketCalculator (com.serotonin.m2m2.view.quantize2.BucketCalculator)6 ShouldNeverHappenException (com.serotonin.ShouldNeverHappenException)5 HashMap (java.util.HashMap)5 PointValueDao (com.serotonin.m2m2.db.dao.PointValueDao)4 DataPointRT (com.serotonin.m2m2.rt.dataImage.DataPointRT)4 ImageValue (com.serotonin.m2m2.rt.dataImage.types.ImageValue)4 AbstractDataQuantizer (com.serotonin.m2m2.view.quantize2.AbstractDataQuantizer)4 ExportDataValue (com.serotonin.m2m2.vo.export.ExportDataValue)4 ImageSaveException (com.serotonin.m2m2.ImageSaveException)3 IDataPointValueSource (com.serotonin.m2m2.rt.dataImage.IDataPointValueSource)2 IdPointValueTime (com.serotonin.m2m2.rt.dataImage.IdPointValueTime)2