From b2bc67ecc36b4fcf811cd4dfbc1b8680506b0d32 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 8 Nov 2023 11:46:13 +0300 Subject: [PATCH] Set storing by default --- .../main/kotlin/inr/numass/control/DeviceDisplayFX.kt | 4 ++-- .../src/main/kotlin/inr/numass/control/FXExtensions.kt | 10 ++++++---- .../inr/numass/control/readvac/VacCollectorDevice.kt | 4 ++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/numass-control/src/main/kotlin/inr/numass/control/DeviceDisplayFX.kt b/numass-control/src/main/kotlin/inr/numass/control/DeviceDisplayFX.kt index 9d5f6b9..4c10691 100644 --- a/numass-control/src/main/kotlin/inr/numass/control/DeviceDisplayFX.kt +++ b/numass-control/src/main/kotlin/inr/numass/control/DeviceDisplayFX.kt @@ -78,13 +78,13 @@ abstract class DeviceDisplayFX : Component(), Connection { protected abstract fun buildView(device: D): UIComponent?; fun valueStateProperty(stateName: String): ObjectProperty { - val state: ValueState = device.states.filterIsInstance(ValueState::class.java).find { it.name == stateName } + val state: ValueState = device.states.filterIsInstance().find { it.name == stateName } ?: throw NameNotFoundException("State with name $stateName not found") return state.asProperty() } fun booleanStateProperty(stateName: String): BooleanProperty { - val state: ValueState = device.states.filterIsInstance(ValueState::class.java).find { it.name == stateName } + val state: ValueState = device.states.filterIsInstance().find { it.name == stateName } ?: throw NameNotFoundException("State with name $stateName not found") return state.asBooleanProperty() } diff --git a/numass-control/src/main/kotlin/inr/numass/control/FXExtensions.kt b/numass-control/src/main/kotlin/inr/numass/control/FXExtensions.kt index 836c11f..c39312a 100644 --- a/numass-control/src/main/kotlin/inr/numass/control/FXExtensions.kt +++ b/numass-control/src/main/kotlin/inr/numass/control/FXExtensions.kt @@ -112,15 +112,17 @@ fun EventTarget.deviceStateIndicator(connection: DeviceDisplayFX<*>, state: Stri fun Node.deviceStateToggle(connection: DeviceDisplayFX<*>, state: String, title: String = state) { if (connection.device.stateNames.contains(state)) { togglebutton(title) { - isSelected = false selectedProperty().addListener { _, oldValue, newValue -> if (oldValue != newValue) { connection.device.states[state] = newValue } } - connection.valueStateProperty(state).onChange { - runLater { - isSelected = it?.boolean ?: false + connection.valueStateProperty(state).apply { + isSelected = value?.boolean ?: false + onChange { + runLater { + isSelected = it?.boolean ?: false + } } } } 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 41d287a..d2cbce2 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 @@ -47,6 +47,10 @@ class VacCollectorDevice(context: Context, meta: Meta, val sensors: Collection