Search in sources :

Example 1 with VDouble

use of org.diirt.vtype.VDouble 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 VDouble

use of org.diirt.vtype.VDouble in project yamcs-studio by yamcs.

the class StatisticsDoubleAggregator method calculate.

@Override
protected VStatistics calculate(List<VDouble> data) {
    Stats stats = new Stats();
    AlarmSeverity statSeverity = null;
    for (VDouble vDouble : data) {
        switch(vDouble.getAlarmSeverity()) {
            case NONE:
                // severity should be NONE
                if (statSeverity != MINOR || statSeverity != MAJOR)
                    statSeverity = NONE;
                stats.includeValue(vDouble.getValue());
                break;
            case MINOR:
                // set it to MINOR
                if (statSeverity != MAJOR)
                    statSeverity = MINOR;
                stats.includeValue(vDouble.getValue());
                break;
            case MAJOR:
                statSeverity = MAJOR;
                stats.includeValue(vDouble.getValue());
                break;
            case UNDEFINED:
                if (statSeverity == null)
                    statSeverity = UNDEFINED;
                break;
            case INVALID:
                if (statSeverity == null || statSeverity == UNDEFINED)
                    statSeverity = INVALID;
                break;
            default:
        }
    }
    return newVStatistics(stats.totalSum / stats.nElements, sqrt(stats.totalSquareSum / stats.nElements - (stats.totalSum * stats.totalSum) / (stats.nElements * stats.nElements)), stats.min, stats.max, stats.nElements, newAlarm(statSeverity, "NONE"), newTime(data.get(data.size() / 2).getTimestamp()), data.get(0));
}
Also used : AlarmSeverity(org.diirt.vtype.AlarmSeverity) VDouble(org.diirt.vtype.VDouble)

Example 3 with VDouble

use of org.diirt.vtype.VDouble 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)

Example 4 with VDouble

use of org.diirt.vtype.VDouble in project yamcs-studio by yamcs.

the class AverageAggregator method calculate.

@Override
protected VDouble calculate(List<VDouble> data) {
    // TODO: this code should be consolidated with the StatisticsDoubleAggregator
    double totalSum = 0;
    AlarmSeverity statSeverity = null;
    for (VDouble vDouble : data) {
        switch(vDouble.getAlarmSeverity()) {
            case NONE:
                // severity should be NONE
                if (statSeverity != MINOR || statSeverity != MAJOR)
                    statSeverity = NONE;
                totalSum += vDouble.getValue();
                break;
            case MINOR:
                // set it to MINOR
                if (statSeverity != MAJOR)
                    statSeverity = MINOR;
                totalSum += vDouble.getValue();
                break;
            case MAJOR:
                statSeverity = MAJOR;
                totalSum += vDouble.getValue();
                break;
            case UNDEFINED:
                if (statSeverity == null)
                    statSeverity = UNDEFINED;
                break;
            case INVALID:
                if (statSeverity == null || statSeverity == UNDEFINED)
                    statSeverity = INVALID;
                break;
            default:
        }
    }
    return newVDouble(totalSum / data.size(), newAlarm(statSeverity, "NONE"), newTime(data.get(data.size() / 2).getTimestamp()), data.get(0));
}
Also used : AlarmSeverity(org.diirt.vtype.AlarmSeverity) VDouble(org.diirt.vtype.VDouble)

Aggregations

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