use of org.diirt.vtype.Display in project yamcs-studio by yamcs.
the class PVComposite method createPVProperties.
private void createPVProperties(PVInfo pvInfo) {
IPV pv = pvInfo.getPV();
StringBuilder stateInfo = new StringBuilder();
if (!pv.isStarted()) {
stateInfo.append("Not started");
} else if (pv.isConnected()) {
stateInfo.append("Connected");
if (pv.isPaused()) {
stateInfo.append(" Paused");
} else {
stateInfo.append(" Running");
}
} else {
stateInfo.append("Connecting");
}
createKeyValueTextPair("Name", pv.getName());
createKeyValueTextPair("State", stateInfo.toString());
createSeparator();
if (pv.getValue() != null) {
createKeyValueTextPair("Last Received Value", pv.getValue().toString());
Display displayInfo = VTypeHelper.getDisplayInfo(pv.getValue());
if (displayInfo != null) {
createKeyValueTextPair("Units", displayInfo.getUnits());
createKeyValueTextPair("Precision", "" + displayInfo.getFormat().getMaximumFractionDigits());
createKeyValueTextPair("Display Low", "" + displayInfo.getLowerDisplayLimit());
createKeyValueTextPair("Display High", "" + displayInfo.getUpperDisplayLimit());
createKeyValueTextPair("Alarm Low", "" + displayInfo.getLowerAlarmLimit());
createKeyValueTextPair("Warning Low", "" + displayInfo.getLowerWarningLimit());
createKeyValueTextPair("Warning High", "" + displayInfo.getUpperWarningLimit());
createKeyValueTextPair("Alarm High", "" + displayInfo.getUpperAlarmLimit());
}
}
}
use of org.diirt.vtype.Display in project yamcs-studio by yamcs.
the class VNumbersToVNumberArrayConverter method readValue.
@Override
public VNumberArray readValue() {
final List<VNumber> values = new ArrayList<VNumber>();
Display meta = displayNone();
for (ReadFunction<? extends VNumber> function : arguments) {
VNumber number = function.readValue();
values.add(number);
if (meta == null && number != null)
meta = number;
}
ListDouble data = new ListDouble() {
@Override
public double getDouble(int index) {
VNumber number = values.get(index);
if (number == null || number.getValue() == null)
return Double.NaN;
else
return number.getValue().doubleValue();
}
@Override
public int size() {
return values.size();
}
};
return ValueFactory.newVDoubleArray(data, alarmNone(), timeNow(), displayNone());
}
use of org.diirt.vtype.Display in project yamcs-studio by yamcs.
the class ArrayOfNumberFormulaFunction method calculate.
@Override
public Object calculate(final List<Object> args) {
ListDouble data = new ListDouble() {
@Override
public double getDouble(int index) {
VNumber number = (VNumber) args.get(index);
if (number == null || number.getValue() == null)
return Double.NaN;
else
return number.getValue().doubleValue();
}
@Override
public int size() {
return args.size();
}
};
VNumber firstNonNull = null;
for (Object object : args) {
if (object != null) {
firstNonNull = (VNumber) object;
}
}
Display display = displayNone();
if (firstNonNull != null) {
if (ValueUtil.displayHasValidDisplayLimits(firstNonNull)) {
display = firstNonNull;
} else {
Statistics stats = StatisticsUtil.statisticsOf(data);
display = newDisplay(stats.getRange().getMinimum(), stats.getRange().getMinimum(), stats.getRange().getMinimum(), "", NumberFormats.toStringFormat(), stats.getRange().getMaximum(), stats.getRange().getMaximum(), stats.getRange().getMaximum(), stats.getRange().getMinimum(), stats.getRange().getMaximum());
}
}
return ValueFactory.newVNumberArray(data, highestSeverityOf(args, false), latestValidTimeOrNowOf(args), display);
}
use of org.diirt.vtype.Display in project yamcs-studio by yamcs.
the class ScrollbarEditPart method registerLoadLimitsListener.
/**
*/
private void registerLoadLimitsListener() {
if (getExecutionMode() == ExecutionMode.RUN_MODE) {
final ScrollBarModel model = getWidgetModel();
if (model.isLimitsFromPV()) {
IPV pv = getPV(AbstractPVWidgetModel.PROP_PVNAME);
if (pv != null) {
if (pvLoadLimitsListener == null)
pvLoadLimitsListener = new IPVListener.Stub() {
@Override
public void valueChanged(IPV pv) {
VType value = pv.getValue();
Display displayInfo = VTypeHelper.getDisplayInfo(value);
if (value != null && displayInfo != null) {
Display new_meta = displayInfo;
if (meta == null || !meta.equals(new_meta)) {
meta = new_meta;
model.setPropertyValue(ScrollBarModel.PROP_MAX, meta.getUpperDisplayLimit());
model.setPropertyValue(ScrollBarModel.PROP_MIN, meta.getLowerDisplayLimit());
}
}
}
};
pv.addListener(pvLoadLimitsListener);
}
}
}
}
use of org.diirt.vtype.Display in project org.csstudio.display.builder by kasemir.
the class ScrollBarRepresentation method limitsChanged.
private void limitsChanged(final WidgetProperty<?> property, final Object old_value, final Object new_value) {
double min_val = model_widget.propMinimum().getValue();
double max_val = model_widget.propMaximum().getValue();
if (model_widget.propLimitsFromPV().getValue()) {
// Try to get display range from PV
final Display display_info = ValueUtil.displayOf(model_widget.runtimePropValue().getValue());
if (display_info != null) {
min_val = display_info.getLowerDisplayLimit();
max_val = display_info.getUpperDisplayLimit();
}
}
// If invalid limits, fall back to 0..100 range
if (min_val >= max_val) {
min_val = 0.0;
max_val = 100.0;
}
min = min_val;
max = max_val;
dirty_size.mark();
toolkit.scheduleUpdate(this);
}
Aggregations