Set storing by default

This commit is contained in:
Alexander Nozik 2023-11-08 11:46:13 +03:00
parent c20ac1ffb8
commit b2bc67ecc3
Signed by: altavir
GPG Key ID: B10A55DCC7B9AEBB
3 changed files with 12 additions and 6 deletions

View File

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

View File

@ -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
}
}
}
}

View File

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