Search in sources :

Example 46 with PointValueTime

use of com.serotonin.m2m2.rt.dataImage.PointValueTime in project ma-core-public by infiniteautomation.

the class MockPointValueDao method getPointValuesBetween.

/* (non-Javadoc)
     * @see com.serotonin.m2m2.db.dao.PointValueDao#getPointValuesBetween(int, long, long, int)
     */
@Override
public List<PointValueTime> getPointValuesBetween(int pointId, long from, long to, int limit) {
    List<PointValueTime> pvts = new ArrayList<>();
    List<PointValueTime> existing = data.get(pointId);
    if (existing != null) {
        for (PointValueTime pvt : existing) {
            if (pvt.getTime() >= from && pvt.getTime() < to)
                pvts.add(pvt);
            if (pvts.size() >= limit)
                break;
        }
    }
    return pvts;
}
Also used : IdPointValueTime(com.serotonin.m2m2.rt.dataImage.IdPointValueTime) AnnotatedPointValueTime(com.serotonin.m2m2.rt.dataImage.AnnotatedPointValueTime) PointValueTime(com.serotonin.m2m2.rt.dataImage.PointValueTime) ArrayList(java.util.ArrayList)

Example 47 with PointValueTime

use of com.serotonin.m2m2.rt.dataImage.PointValueTime in project ma-core-public by infiniteautomation.

the class ImagePointWrapper method ago.

public byte[] ago(int periodType, int periods) {
    long from = DateUtils.minus(getContext().getRuntime(), periodType, periods);
    PointValueTime pvt = point.getPointValueBefore(from);
    if (pvt == null)
        return null;
    return ((ImageValue) pvt.getValue()).getData();
}
Also used : PointValueTime(com.serotonin.m2m2.rt.dataImage.PointValueTime) ImageValue(com.serotonin.m2m2.rt.dataImage.types.ImageValue)

Example 48 with PointValueTime

use of com.serotonin.m2m2.rt.dataImage.PointValueTime in project ma-core-public by infiniteautomation.

the class AlphanumericPointWrapper method ago.

public String ago(int periodType, int count) {
    long from = DateUtils.minus(getContext().getRuntime(), periodType, count);
    PointValueTime pvt = point.getPointValueBefore(from);
    if (pvt == null)
        return null;
    return pvt.getValue().getStringValue();
}
Also used : PointValueTime(com.serotonin.m2m2.rt.dataImage.PointValueTime)

Example 49 with PointValueTime

use of com.serotonin.m2m2.rt.dataImage.PointValueTime in project ma-core-public by infiniteautomation.

the class AlphanumericPointWrapper method getStats.

public ValueChangeCounterWrapper getStats(long from, long to) {
    PointValueTime start = point.getPointValueBefore(from);
    List<PointValueTime> values = point.getPointValuesBetween(from, to);
    ValueChangeCounter stats = new ValueChangeCounter(from, to, start, values);
    ValueChangeCounterWrapper wrapper = new ValueChangeCounterWrapper(stats);
    return wrapper;
}
Also used : ValueChangeCounter(com.infiniteautomation.mango.statistics.ValueChangeCounter) PointValueTime(com.serotonin.m2m2.rt.dataImage.PointValueTime)

Example 50 with PointValueTime

use of com.serotonin.m2m2.rt.dataImage.PointValueTime in project ma-core-public by infiniteautomation.

the class BinaryPointWrapper method ago.

public boolean ago(int periodType, int count) {
    long from = DateUtils.minus(getContext().getRuntime(), periodType, count);
    PointValueTime pvt = point.getPointValueBefore(from);
    if (pvt == null)
        return false;
    return pvt.getBooleanValue();
}
Also used : PointValueTime(com.serotonin.m2m2.rt.dataImage.PointValueTime)

Aggregations

PointValueTime (com.serotonin.m2m2.rt.dataImage.PointValueTime)104 ArrayList (java.util.ArrayList)33 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)31 AnnotatedPointValueTime (com.serotonin.m2m2.rt.dataImage.AnnotatedPointValueTime)29 DataPointRT (com.serotonin.m2m2.rt.dataImage.DataPointRT)24 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)23 IdPointValueTime (com.serotonin.m2m2.rt.dataImage.IdPointValueTime)23 IOException (java.io.IOException)18 DataValue (com.serotonin.m2m2.rt.dataImage.types.DataValue)17 HashMap (java.util.HashMap)17 ShouldNeverHappenException (com.serotonin.ShouldNeverHappenException)15 ImageValue (com.serotonin.m2m2.rt.dataImage.types.ImageValue)12 PointValueFacade (com.serotonin.m2m2.rt.dataImage.PointValueFacade)11 ScriptException (javax.script.ScriptException)10 PointValueDao (com.serotonin.m2m2.db.dao.PointValueDao)9 IDataPointValueSource (com.serotonin.m2m2.rt.dataImage.IDataPointValueSource)9 LogStopWatch (com.serotonin.log.LogStopWatch)8 AlphanumericValue (com.serotonin.m2m2.rt.dataImage.types.AlphanumericValue)8 NumericValue (com.serotonin.m2m2.rt.dataImage.types.NumericValue)8 ResultTypeException (com.serotonin.m2m2.rt.script.ResultTypeException)8