Compare commits

..

No commits in common. "9a1e9dc996c039892f6a49dbfcf1e8851f31c027" and "8e45062957461a4eed28c1e9a5661a027f678c91" have entirely different histories.

3 changed files with 6 additions and 12 deletions

View File

@ -78,13 +78,13 @@ abstract class DeviceDisplayFX<D : Device> : Component(), Connection {
protected abstract fun buildView(device: D): UIComponent?; protected abstract fun buildView(device: D): UIComponent?;
fun valueStateProperty(stateName: String): ObjectProperty<Value> { fun valueStateProperty(stateName: String): ObjectProperty<Value> {
val state: ValueState = device.states.filterIsInstance<ValueState>().find { it.name == stateName } val state: ValueState = device.states.filterIsInstance(ValueState::class.java).find { it.name == stateName }
?: throw NameNotFoundException("State with name $stateName not found") ?: throw NameNotFoundException("State with name $stateName not found")
return state.asProperty() return state.asProperty()
} }
fun booleanStateProperty(stateName: String): BooleanProperty { fun booleanStateProperty(stateName: String): BooleanProperty {
val state: ValueState = device.states.filterIsInstance<ValueState>().find { it.name == stateName } val state: ValueState = device.states.filterIsInstance(ValueState::class.java).find { it.name == stateName }
?: throw NameNotFoundException("State with name $stateName not found") ?: throw NameNotFoundException("State with name $stateName not found")
return state.asBooleanProperty() return state.asBooleanProperty()
} }

View File

@ -112,20 +112,18 @@ fun EventTarget.deviceStateIndicator(connection: DeviceDisplayFX<*>, state: Stri
fun Node.deviceStateToggle(connection: DeviceDisplayFX<*>, state: String, title: String = state) { fun Node.deviceStateToggle(connection: DeviceDisplayFX<*>, state: String, title: String = state) {
if (connection.device.stateNames.contains(state)) { if (connection.device.stateNames.contains(state)) {
togglebutton(title) { togglebutton(title) {
isSelected = false
selectedProperty().addListener { _, oldValue, newValue -> selectedProperty().addListener { _, oldValue, newValue ->
if (oldValue != newValue) { if (oldValue != newValue) {
connection.device.states[state] = newValue connection.device.states[state] = newValue
} }
} }
connection.valueStateProperty(state).apply { connection.valueStateProperty(state).onChange {
isSelected = value?.boolean ?: false
onChange {
runLater { runLater {
isSelected = it?.boolean ?: false isSelected = it?.boolean ?: false
} }
} }
} }
}
deviceStateIndicator(connection, state, false) deviceStateIndicator(connection, state, false)
} else { } else {
throw RuntimeException("Device does not support state $state"); throw RuntimeException("Device does not support state $state");

View File

@ -47,10 +47,6 @@ class VacCollectorDevice(context: Context, meta: Meta, val sensors: Collection<S
private val helper = StorageHelper(this, this::buildLoader) private val helper = StorageHelper(this, this::buildLoader)
init {
states["storing"] = true
}
private val collector = object : DeviceListener { private val collector = object : DeviceListener {
val averagingDuration: Duration = Duration.parse(meta.getString("averagingDuration", "PT30S")) val averagingDuration: Duration = Duration.parse(meta.getString("averagingDuration", "PT30S"))