use of org.diirt.vtype.AlarmSeverity 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.AlarmSeverity in project yamcs-studio by yamcs.
the class ProgressBarEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
IWidgetPropertyChangeHandler originHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((ProgressBarFigure) figure).setOrigin((Double) newValue);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_ORIGIN, originHandler);
IWidgetPropertyChangeHandler originIgnoredHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((ProgressBarFigure) figure).setOriginIgnored((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_ORIGIN_IGNORED, originIgnoredHandler);
// fillColor
IWidgetPropertyChangeHandler fillColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setFillColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_FILL_COLOR, fillColorHandler);
// fillBackgroundColor
IWidgetPropertyChangeHandler fillBackColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setFillBackgroundColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_FILLBACKGROUND_COLOR, fillBackColorHandler);
// effect 3D
IWidgetPropertyChangeHandler effect3DHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setEffect3D((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_EFFECT3D, effect3DHandler);
// effect 3D
IWidgetPropertyChangeHandler showLabelHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setShowLabel((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_SHOW_LABEL, showLabelHandler);
IWidgetPropertyChangeHandler indicatorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setIndicatorMode((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_INDICATOR_MODE, indicatorHandler);
// horizontal
IWidgetPropertyChangeHandler horizontalHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setHorizontal((Boolean) newValue);
ProgressBarModel model = (ProgressBarModel) getModel();
if (// from vertical to horizontal
(Boolean) newValue)
model.setLocation(model.getLocation().x - model.getSize().height / 2 + model.getSize().width / 2, model.getLocation().y + model.getSize().height / 2 - model.getSize().width / 2);
else
// from horizontal to vertical
model.setLocation(model.getLocation().x + model.getSize().width / 2 - model.getSize().height / 2, model.getLocation().y - model.getSize().width / 2 + model.getSize().height / 2);
model.setSize(model.getSize().height, model.getSize().width);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_HORIZONTAL, horizontalHandler);
// enabled. WidgetBaseEditPart will force the widget as disabled in edit model,
// which is not the case for the scaled slider
IWidgetPropertyChangeHandler enableHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ProgressBarFigure slider = (ProgressBarFigure) refreshableFigure;
slider.setEnabled((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_ENABLED, enableHandler);
// Change fill color when "FillColor Alarm Sensitive" property changes.
IWidgetPropertyChangeHandler fillColorAlarmSensitiveHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
ProgressBarFigure figure = (ProgressBarFigure) refreshableFigure;
boolean sensitive = (Boolean) newValue;
figure.setFillColor(delegate.calculateAlarmColor(sensitive, getWidgetModel().getFillColor()));
return true;
}
};
setPropertyChangeHandler(ProgressBarModel.PROP_FILLCOLOR_ALARM_SENSITIVE, fillColorAlarmSensitiveHandler);
// Change fill color when alarm severity changes.
delegate.addAlarmSeverityListener(new AlarmSeverityListener() {
@Override
public boolean severityChanged(AlarmSeverity severity, IFigure figure) {
if (!getWidgetModel().isFillColorAlarmSensitive())
return false;
ProgressBarFigure progress = (ProgressBarFigure) figure;
progress.setFillColor(delegate.calculateAlarmColor(getWidgetModel().isFillColorAlarmSensitive(), getWidgetModel().getFillColor()));
return true;
}
});
}
use of org.diirt.vtype.AlarmSeverity in project yamcs-studio by yamcs.
the class TankEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
// fillColor
IWidgetPropertyChangeHandler fillColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
TankFigure tank = (TankFigure) refreshableFigure;
tank.setFillColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(TankModel.PROP_FILL_COLOR, fillColorHandler);
// fillBackgroundColor
IWidgetPropertyChangeHandler fillBackColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
TankFigure tank = (TankFigure) refreshableFigure;
tank.setFillBackgroundColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(TankModel.PROP_FILLBACKGROUND_COLOR, fillBackColorHandler);
// effect 3D
IWidgetPropertyChangeHandler effect3DHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
TankFigure tank = (TankFigure) refreshableFigure;
tank.setEffect3D((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(TankModel.PROP_EFFECT3D, effect3DHandler);
// Change fill color when "FillColor Alarm Sensitive" property changes.
IWidgetPropertyChangeHandler fillColorAlarmSensitiveHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
TankFigure figure = (TankFigure) refreshableFigure;
boolean sensitive = (Boolean) newValue;
figure.setFillColor(delegate.calculateAlarmColor(sensitive, getWidgetModel().getFillColor()));
return true;
}
};
setPropertyChangeHandler(TankModel.PROP_FILLCOLOR_ALARM_SENSITIVE, fillColorAlarmSensitiveHandler);
// Change fill color when alarm severity changes.
delegate.addAlarmSeverityListener(new AlarmSeverityListener() {
@Override
public boolean severityChanged(AlarmSeverity severity, IFigure figure) {
if (!getWidgetModel().isFillColorAlarmSensitive())
return false;
TankFigure tank = (TankFigure) figure;
tank.setFillColor(delegate.calculateAlarmColor(getWidgetModel().isFillColorAlarmSensitive(), getWidgetModel().getFillColor()));
return true;
}
});
}
use of org.diirt.vtype.AlarmSeverity in project yamcs-studio by yamcs.
the class ThermometerEditPart method registerPropertyChangeHandlers.
/**
* {@inheritDoc}
*/
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
// fillColor
IWidgetPropertyChangeHandler fillColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThermometerFigure thermometer = (ThermometerFigure) refreshableFigure;
thermometer.setFillColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(ThermometerModel.PROP_FILL_COLOR, fillColorHandler);
// fillBackgroundColor
IWidgetPropertyChangeHandler fillBackColorHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThermometerFigure thermometer = (ThermometerFigure) refreshableFigure;
thermometer.setFillBackgroundColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(ThermometerModel.PROP_FILLBACKGROUND_COLOR, fillBackColorHandler);
// show bulb
IWidgetPropertyChangeHandler showBulbHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThermometerFigure thermometer = (ThermometerFigure) refreshableFigure;
thermometer.setShowBulb((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ThermometerModel.PROP_SHOW_BULB, showBulbHandler);
// unit
IWidgetPropertyChangeHandler fahrenheitHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThermometerFigure thermometer = (ThermometerFigure) refreshableFigure;
thermometer.setTemperatureUnit(TemperatureUnit.values()[(Integer) newValue]);
return false;
}
};
setPropertyChangeHandler(ThermometerModel.PROP_UNIT, fahrenheitHandler);
// effect 3D
IWidgetPropertyChangeHandler effect3DHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(final Object oldValue, final Object newValue, final IFigure refreshableFigure) {
ThermometerFigure thermo = (ThermometerFigure) refreshableFigure;
thermo.setEffect3D((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(ThermometerModel.PROP_EFFECT3D, effect3DHandler);
// Change fill color when "FillColor Alarm Sensitive" property changes.
IWidgetPropertyChangeHandler fillColorAlarmSensitiveHandler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure refreshableFigure) {
ThermometerFigure figure = (ThermometerFigure) refreshableFigure;
boolean sensitive = (Boolean) newValue;
figure.setFillColor(delegate.calculateAlarmColor(sensitive, getWidgetModel().getFillColor()));
return true;
}
};
setPropertyChangeHandler(ThermometerModel.PROP_FILLCOLOR_ALARM_SENSITIVE, fillColorAlarmSensitiveHandler);
// Change fill color when alarm severity changes.
delegate.addAlarmSeverityListener(new AlarmSeverityListener() {
@Override
public boolean severityChanged(AlarmSeverity severity, IFigure figure) {
if (!getWidgetModel().isFillColorAlarmSensitive())
return false;
ThermometerFigure thermo = (ThermometerFigure) figure;
thermo.setFillColor(delegate.calculateAlarmColor(getWidgetModel().isFillColorAlarmSensitive(), getWidgetModel().getFillColor()));
return true;
}
});
}
use of org.diirt.vtype.AlarmSeverity in project org.csstudio.display.builder by kasemir.
the class MatlabFileExportJob method performExport.
/**
* {@inheritDoc}
*/
@Override
protected void performExport(final IProgressMonitor monitor, final PrintStream out) throws Exception {
// This exporter does its own file handling
if (out != null)
throw new IllegalStateException();
final MatFileIncrementalWriter writer = new MatFileIncrementalWriter(filename);
int i = 0;
for (ModelItem item : model.getItems()) {
// Get data
monitor.subTask(NLS.bind("Fetching data for {0}", item.getName()));
final ValueIterator iter = createValueIterator(item);
final List<Instant> times = new ArrayList<Instant>();
final List<Double> values = new ArrayList<Double>();
final List<AlarmSeverity> severities = new ArrayList<AlarmSeverity>();
while (iter.hasNext() && !monitor.isCanceled()) {
final VType value = iter.next();
times.add(VTypeHelper.getTimestamp(value));
values.add(VTypeHelper.toDouble(value));
severities.add(VTypeHelper.getSeverity(value));
if (values.size() % PROGRESS_UPDATE_LINES == 0)
monitor.subTask(NLS.bind("{0}: Obtained {1} samples", item.getName(), values.size()));
}
// Add to Matlab file
final MLStructure struct = createMLStruct(i++, item.getName(), times, values, severities);
writer.write(struct);
}
writer.close();
}
Aggregations