Compare commits
2 Commits
8e45062957
...
9a1e9dc996
Author | SHA1 | Date | |
---|---|---|---|
9a1e9dc996 | |||
b2bc67ecc3 |
@ -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::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")
|
?: 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::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")
|
?: throw NameNotFoundException("State with name $stateName not found")
|
||||||
return state.asBooleanProperty()
|
return state.asBooleanProperty()
|
||||||
}
|
}
|
||||||
|
@ -112,15 +112,17 @@ 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).onChange {
|
connection.valueStateProperty(state).apply {
|
||||||
runLater {
|
isSelected = value?.boolean ?: false
|
||||||
isSelected = it?.boolean ?: false
|
onChange {
|
||||||
|
runLater {
|
||||||
|
isSelected = it?.boolean ?: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,10 @@ 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"))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user