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