diff --git a/numass-control/src/main/kotlin/inr/numass/control/DeviceDisplay.kt b/numass-control/src/main/kotlin/inr/numass/control/DeviceDisplay.kt index e1bf192e..40cb95a6 100644 --- a/numass-control/src/main/kotlin/inr/numass/control/DeviceDisplay.kt +++ b/numass-control/src/main/kotlin/inr/numass/control/DeviceDisplay.kt @@ -143,11 +143,11 @@ abstract class DeviceDisplay : Component(), Connection, DeviceListen } } - override fun notifyDeviceStateChanged(device: Device, name: String, state: Value) { + override fun notifyStateChanged(device: Device, name: String, state: Value) { bindings[name]?.invalidate() } - override fun notifyDeviceStateChanged(device: Device, name: String, state: Meta) { + override fun notifyMetaStateChanged(device: Device, name: String, state: Meta) { metaBindings[name]?.invalidate() } diff --git a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/ConsoleVac.kt b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/ConsoleVac.kt index 41748c9e..a16182ac 100644 --- a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/ConsoleVac.kt +++ b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/ConsoleVac.kt @@ -12,6 +12,11 @@ import java.time.Instant * Created by darksnake on 06-Dec-16. */ object ConsoleVac { + private fun Sensor.read():Double{ + this.measure() + + } + @Throws(Exception::class) @JvmStatic fun main(args: Array) { @@ -33,7 +38,7 @@ object ConsoleVac { var className: String = cli.getOptionValue("c") ?: throw RuntimeException("Vacuumeter class not defined") if (!className.contains(".")) { - className = "inr.numass.readvac.devices." + className + className = "inr.numass.readvac.devices.$className" } val name = cli.getOptionValue("n", "sensor") diff --git a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacCollectorDevice.kt b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacCollectorDevice.kt index 6db8483d..09ad02e1 100644 --- a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacCollectorDevice.kt +++ b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/VacCollectorDevice.kt @@ -34,6 +34,7 @@ import inr.numass.control.StorageHelper import kotlinx.coroutines.experimental.launch import kotlinx.coroutines.experimental.time.delay import java.time.Duration +import java.time.Instant import java.util.* import java.util.stream.Stream @@ -53,11 +54,11 @@ class VacCollectorDevice(context: Context, meta: Meta, val sensors: Collection() { return VacView(); } - override fun evaluateDeviceException(device: Device, message: String, exception: Throwable) { - if (!message.isEmpty()) { - Platform.runLater { - status = "ERROR: $message" - } - } - } - - override fun onMeasurementFailed(measurement: Measurement<*>, exception: Throwable) { - Platform.runLater { - value = "Err" - } - } - fun message(message: String) { Platform.runLater { status = message } } - fun onResult(res: Any, time: Instant) { + private fun onResult(res: Any, time: Instant) { val result = Number::class.java.cast(res).toDouble() val resString = FORMAT.format(result) Platform.runLater { @@ -78,21 +66,32 @@ open class VacDisplay : DeviceDisplay() { } } - override fun notifyDeviceStateChanged(device: Device, name: String, state: Meta) { - super.notifyDeviceStateChanged(device, name, state) + override fun notifyMetaStateChanged(device: Device, name: String, state: Meta) { + super.notifyMetaStateChanged(device, name, state) when (name) { Sensor.MEASUREMENT_RESULT_STATE -> { - val res by state.value(Sensor.RESULT_VALUE) - val time by state.timeValue(Sensor.RESULT_TIMESTAMP) - onResult(res, time) + if(state.getBoolean(Sensor.RESULT_SUCCESS)) { + val res by state.value(Sensor.RESULT_VALUE) + val time by state.timeValue(Sensor.RESULT_TIMESTAMP) + onResult(res, time) + } else{ + Platform.runLater { + value = "Err" + } + } } Sensor.MEASUREMENT_ERROR_STATE -> { - + val message by state.stringValue("message") + message(message) } } } + override fun notifyStateChanged(device: Device, name: String, state: Value) { + super.notifyStateChanged(device, name, state) + } + fun getTitle(): String { return device.meta.getString("title", device.name); }