private String timeStampOf(Object value) { if (value == null) return ""; return ValueUtil.timeOf(value).getTimestamp().toString(); }
@Override public Object calculate(List<Object> args) { VType value = (VType) args.get(0); Alarm alarm = ValueUtil.alarmOf(value); if (alarm == null) { alarm = ValueFactory.alarmNone(); } Time time = ValueUtil.timeOf(value); if (time == null) { time = ValueFactory.timeNow(); } return ValueFactory.newVString(ValueUtil.getDefaultValueFormat().format(value), alarm, time); }
@Override public Object calculate(final List<Object> args) { Alarm alarm = ValueUtil.highestSeverityOf(args, true); Time time = ValueUtil.timeOf(alarm); if (time == null) { time = ValueFactory.timeNow(); } return ValueFactory.newVEnum(alarm.getAlarmSeverity().ordinal(), AlarmSeverity.labels(), alarm, time); }
@Override public void pvChanged(PVReaderEvent<VType> event) { VType value = event.getPvReader().getValue(); // We can extract the different aspect of the read object, // so that we can work on them separately // This returns the interface implemented (VDouble, VInt, ...) Class<?> type = ValueUtil.typeOf(value); // Extracts the alarm if present Alarm alarm = ValueUtil.alarmOf(value); // Extracts the time if present Time time = ValueUtil.timeOf(value); // Extracts a numeric value if present Double number = ValueUtil.numericValueOf(value); // Extract display information if present Display display = ValueUtil.displayOf(value); // setAlarm(alarm); // setTime(time); } })
@Override public void pvChanged(PVReaderEvent<Object> event) { setLastError(pv.lastException()); Object value = pv.getValue(); setTextValue(format.format(value)); setType(ValueUtil.typeOf(value)); setAlarm(ValueUtil.alarmOf(value)); setTime(ValueUtil.timeOf(value)); setIndicator(ValueUtil.normalizedNumericValueOf(value)); setMetadata(ValueUtil.displayOf(value)); setConnected(pv.isConnected()); } })
@Override public VString readValue() { VType value = argument.readValue(); if (forward != null) { forward.writeValue(value); } if (value == null) { return null; } String string = format.format(value); Alarm alarm = ValueUtil.alarmOf(value); if (alarm == null) { alarm = ValueFactory.alarmNone(); } Time time = ValueUtil.timeOf(value); if (time == null) { time = ValueFactory.timeNow(); } return ValueFactory.newVString(string, alarm, time); }