Search in sources :

Example 1 with TimeInterval

use of org.diirt.util.TimeInterval in project yamcs-studio by yamcs.

the class Replay method createValues.

@Override
List<VDouble> createValues(TimeInterval interval) {
    offset = Duration.between(interval.getStart(), ((VDouble) values.getValues().get(0)).getTimestamp()).abs();
    TimeInterval originalInterval = interval.minus(offset);
    List<VDouble> newValues = new ArrayList<VDouble>();
    for (ReplayValue value : values.getValues()) {
        if (originalInterval.contains(value.getTimestamp())) {
            ReplayValue copy = value.copy();
            if (values.isAdjustTime()) {
                copy.adjustTime(offset);
            }
            newValues.add((VDouble) copy);
        }
    }
    return newValues;
}
Also used : VDouble(org.diirt.vtype.VDouble) TimeInterval(org.diirt.util.TimeInterval) ArrayList(java.util.ArrayList)

Example 2 with TimeInterval

use of org.diirt.util.TimeInterval in project yamcs-studio by yamcs.

the class SynchronizedVDoubleAggregator method readValue.

@Override
public VMultiDouble readValue() {
    Instant reference = electReferenceTimeStamp(collectors);
    if (reference == null)
        return null;
    TimeInterval allowedInterval = TimeInterval.around(tolerance, reference);
    List<VDouble> values = new ArrayList<VDouble>(collectors.size());
    StringBuilder buffer = new StringBuilder();
    for (ReadFunction<List<VDouble>> collector : collectors) {
        List<VDouble> data = collector.readValue();
        if (log.isLoggable(Level.FINE)) {
            buffer.append(data.size()).append(", ");
        }
        VDouble value = closestElement(data, allowedInterval, reference);
        values.add(value);
    }
    if (log.isLoggable(Level.FINE)) {
        log.fine(buffer.toString());
    }
    return ValueFactory.newVMultiDouble(values, ValueFactory.alarmNone(), ValueFactory.newTime(reference), ValueFactory.displayNone());
}
Also used : VDouble(org.diirt.vtype.VDouble) TimeInterval(org.diirt.util.TimeInterval) Instant(java.time.Instant) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ArrayList (java.util.ArrayList)2 TimeInterval (org.diirt.util.TimeInterval)2 VDouble (org.diirt.vtype.VDouble)2 Instant (java.time.Instant)1 List (java.util.List)1