vac to kotlin
This commit is contained in:
parent
04b3dc9fc2
commit
5e21fa5a0f
@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
package inr.numass.control.readvac
|
|
||||||
|
|
||||||
import javafx.fxml.FXML
|
|
||||||
import javafx.fxml.FXMLLoader
|
|
||||||
import javafx.scene.Node
|
|
||||||
import org.controlsfx.control.ToggleSwitch
|
|
||||||
import java.io.IOException
|
|
||||||
import java.net.URL
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author [Alexander Nozik](mailto:altavir@gmail.com)
|
|
||||||
*/
|
|
||||||
class PoweredVacuumeterViewConnection : VacuumeterViewConnection() {
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private val powerSwitch: ToggleSwitch? = null
|
|
||||||
|
|
||||||
|
|
||||||
val component: Node
|
|
||||||
get() {
|
|
||||||
if (getNode() == null) {
|
|
||||||
try {
|
|
||||||
val loader = FXMLLoader(javaClass.getResource("/fxml/PoweredVacBox.fxml"))
|
|
||||||
loader.setController(this)
|
|
||||||
this.setNode(loader.load<T>())
|
|
||||||
} catch (ex: IOException) {
|
|
||||||
throw RuntimeException(ex)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return getNode()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun initialize(location: URL, resources: ResourceBundle) {
|
|
||||||
super.initialize(location, resources)
|
|
||||||
getUnitLabel().setText(device.meta().getString("units", "mbar"))
|
|
||||||
getDeviceNameLabel().setText(device.name)
|
|
||||||
bindBooleanToState("power", powerSwitch!!.selectedProperty())
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,12 +11,15 @@ import hep.dataforge.control.devices.Sensor
|
|||||||
import hep.dataforge.control.measurements.Measurement
|
import hep.dataforge.control.measurements.Measurement
|
||||||
import hep.dataforge.control.measurements.MeasurementListener
|
import hep.dataforge.control.measurements.MeasurementListener
|
||||||
import inr.numass.control.DeviceViewConnection
|
import inr.numass.control.DeviceViewConnection
|
||||||
|
import inr.numass.control.switch
|
||||||
import javafx.application.Platform
|
import javafx.application.Platform
|
||||||
import javafx.beans.property.SimpleStringProperty
|
import javafx.beans.property.SimpleStringProperty
|
||||||
import javafx.scene.control.Label
|
import javafx.geometry.Insets
|
||||||
import javafx.scene.layout.BorderPane
|
import javafx.geometry.Orientation
|
||||||
|
import javafx.geometry.Pos
|
||||||
|
import javafx.scene.layout.Priority
|
||||||
import javafx.scene.paint.Color
|
import javafx.scene.paint.Color
|
||||||
import org.controlsfx.control.ToggleSwitch
|
import javafx.scene.text.FontWeight
|
||||||
import tornadofx.*
|
import tornadofx.*
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
@ -29,10 +32,10 @@ import java.time.format.DateTimeFormatter
|
|||||||
*/
|
*/
|
||||||
open class VacuumeterViewConnection : DeviceViewConnection<Sensor<Double>>(), MeasurementListener {
|
open class VacuumeterViewConnection : DeviceViewConnection<Sensor<Double>>(), MeasurementListener {
|
||||||
|
|
||||||
val statusProperty = SimpleStringProperty()
|
val statusProperty = SimpleStringProperty("")
|
||||||
var status: String by statusProperty
|
var status: String by statusProperty
|
||||||
|
|
||||||
val valueProperty = SimpleStringProperty()
|
val valueProperty = SimpleStringProperty("---")
|
||||||
var value: String by valueProperty
|
var value: String by valueProperty
|
||||||
|
|
||||||
|
|
||||||
@ -71,26 +74,85 @@ open class VacuumeterViewConnection : DeviceViewConnection<Sensor<Double>>(), Me
|
|||||||
|
|
||||||
inner class VacView : View("Numass vacuumeter ${device.meta().getString("title", device.name)}") {
|
inner class VacView : View("Numass vacuumeter ${device.meta().getString("title", device.name)}") {
|
||||||
|
|
||||||
override val root: BorderPane by fxml()
|
override val root = borderpane {
|
||||||
|
style {
|
||||||
|
|
||||||
val deviceNameLabel: Label by fxid()
|
}
|
||||||
val unitLabel: Label by fxid()
|
top {
|
||||||
val valueLabel: Label by fxid()
|
borderpane {
|
||||||
val status: Label by fxid()
|
center {
|
||||||
val disableButton: ToggleSwitch by fxid()
|
label(device.name){
|
||||||
|
style {
|
||||||
init {
|
fontSize = 18.pt
|
||||||
status.textProperty().bind(statusProperty)
|
fontWeight = FontWeight.BOLD
|
||||||
valueLabel.textProperty().bind(valueProperty)
|
}
|
||||||
unitLabel.text = device.meta().getString("units", "mbar")
|
}
|
||||||
deviceNameLabel.text = device.name
|
style {
|
||||||
bindBooleanToState(CONNECTED_STATE, disableButton.selectedProperty());
|
backgroundColor = multi(Color.LAVENDER)
|
||||||
disableButton.selectedProperty().addListener { _, _, newValue ->
|
}
|
||||||
if (!newValue) {
|
}
|
||||||
valueLabel.text = "---"
|
right {
|
||||||
|
switch {
|
||||||
|
bindBooleanToState(CONNECTED_STATE, selectedProperty());
|
||||||
|
selectedProperty().addListener { _, _, newValue ->
|
||||||
|
if (!newValue) {
|
||||||
|
value = "---"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
center {
|
||||||
|
vbox {
|
||||||
|
separator(Orientation.HORIZONTAL)
|
||||||
|
borderpane {
|
||||||
|
left {
|
||||||
|
label {
|
||||||
|
padding = Insets(5.0, 5.0, 5.0, 5.0)
|
||||||
|
prefHeight = 60.0
|
||||||
|
alignment = Pos.CENTER_RIGHT
|
||||||
|
textProperty().bind(valueProperty)
|
||||||
|
device.meta().optValue("color").ifPresent { colorValue -> textFill = Color.valueOf(colorValue.stringValue()) }
|
||||||
|
style {
|
||||||
|
fontSize = 24.pt
|
||||||
|
fontWeight = FontWeight.BOLD
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
right {
|
||||||
|
label {
|
||||||
|
padding = Insets(5.0, 5.0, 5.0, 5.0)
|
||||||
|
prefHeight = 60.0
|
||||||
|
prefWidth = 75.0
|
||||||
|
alignment = Pos.CENTER_LEFT
|
||||||
|
text = device.meta().getString("units", "mbar")
|
||||||
|
style {
|
||||||
|
fontSize = 24.pt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (device.hasState("power")) {
|
||||||
|
separator(Orientation.HORIZONTAL)
|
||||||
|
pane {
|
||||||
|
minHeight = 30.0
|
||||||
|
vgrow = Priority.ALWAYS
|
||||||
|
switch("Power") {
|
||||||
|
alignment = Pos.CENTER
|
||||||
|
bindBooleanToState("power", selectedProperty())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
separator(Orientation.HORIZONTAL)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bottom {
|
||||||
|
label {
|
||||||
|
padding = Insets(5.0, 5.0, 5.0, 5.0)
|
||||||
|
textProperty().bind(statusProperty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
device.meta().optValue("color").ifPresent { colorValue -> valueLabel.textFill = Color.valueOf(colorValue.stringValue()) }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,53 +9,47 @@
|
|||||||
<stylesheets>
|
<stylesheets>
|
||||||
<URL value="@vacstyles.css"/>
|
<URL value="@vacstyles.css"/>
|
||||||
</stylesheets>
|
</stylesheets>
|
||||||
<children>
|
<VBox layoutX="50.0" layoutY="6.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||||
<VBox layoutX="50.0" layoutY="6.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<AnchorPane styleClass="namePane">
|
||||||
<children>
|
<Label id="name" fx:id="deviceNameLabel" alignment="CENTER" prefHeight="40.0" text="device Name"
|
||||||
<AnchorPane styleClass="namePane">
|
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="50.0"
|
||||||
<Label id="name" fx:id="deviceNameLabel" alignment="CENTER" prefHeight="40.0" text="device Name"
|
AnchorPane.topAnchor="0.0"/>
|
||||||
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="50.0"
|
<ToggleSwitch fx:id="disableButton" alignment="CENTER" layoutX="130.0" layoutY="10.0"
|
||||||
AnchorPane.topAnchor="0.0"/>
|
prefWidth="40.0" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="10.0"
|
||||||
<ToggleSwitch fx:id="disableButton" alignment="CENTER" layoutX="130.0" layoutY="10.0"
|
AnchorPane.topAnchor="10.0"/>
|
||||||
prefWidth="40.0" AnchorPane.bottomAnchor="10.0" AnchorPane.rightAnchor="10.0"
|
</AnchorPane>
|
||||||
AnchorPane.topAnchor="10.0"/>
|
<Separator/>
|
||||||
</AnchorPane>
|
<BorderPane>
|
||||||
<Separator/>
|
<left>
|
||||||
<BorderPane>
|
<Label id="pressure" fx:id="valueLabel" alignment="CENTER_RIGHT" minWidth="110.0"
|
||||||
<left>
|
prefHeight="60.0" text="---" BorderPane.alignment="CENTER">
|
||||||
<Label id="pressure" fx:id="valueLabel" alignment="CENTER_RIGHT" minWidth="110.0"
|
|
||||||
prefHeight="60.0" text="---" BorderPane.alignment="CENTER">
|
|
||||||
<padding>
|
|
||||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
|
||||||
</padding>
|
|
||||||
</Label>
|
|
||||||
</left>
|
|
||||||
<right>
|
|
||||||
<Label id="units" fx:id="unitLabel" prefHeight="60.0" prefWidth="75.0" text="mbar"
|
|
||||||
BorderPane.alignment="CENTER">
|
|
||||||
<padding>
|
|
||||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
|
||||||
</padding>
|
|
||||||
</Label>
|
|
||||||
</right>
|
|
||||||
</BorderPane>
|
|
||||||
<Separator/>
|
|
||||||
<Pane minHeight="30.0" prefHeight="30.0" VBox.vgrow="ALWAYS">
|
|
||||||
<ToggleSwitch fx:id="powerSwitch" layoutX="58.0" layoutY="5.0" text="Power"/>
|
|
||||||
</Pane>
|
|
||||||
<Separator/>
|
|
||||||
<AnchorPane styleClass="statusPane">
|
|
||||||
<children>
|
|
||||||
<Label fx:id="status" maxWidth="200.0" text="Initializing" wrapText="true"
|
|
||||||
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
|
|
||||||
AnchorPane.topAnchor="0.0"/>
|
|
||||||
</children>
|
|
||||||
<padding>
|
<padding>
|
||||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||||
</padding>
|
</padding>
|
||||||
</AnchorPane>
|
</Label>
|
||||||
</children>
|
</left>
|
||||||
</VBox>
|
<right>
|
||||||
</children>
|
<Label id="units" fx:id="unitLabel" prefHeight="60.0" prefWidth="75.0" text="mbar"
|
||||||
|
BorderPane.alignment="CENTER">
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||||
|
</padding>
|
||||||
|
</Label>
|
||||||
|
</right>
|
||||||
|
</BorderPane>
|
||||||
|
<Separator/>
|
||||||
|
<Pane minHeight="30.0" prefHeight="30.0" VBox.vgrow="ALWAYS">
|
||||||
|
<ToggleSwitch fx:id="powerSwitch" layoutX="58.0" layoutY="5.0" text="Power"/>
|
||||||
|
</Pane>
|
||||||
|
<Separator/>
|
||||||
|
<AnchorPane styleClass="statusPane">
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||||
|
</padding>
|
||||||
|
<Label fx:id="status" maxWidth="200.0" text="Initializing" wrapText="true"
|
||||||
|
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
|
||||||
|
AnchorPane.topAnchor="0.0"/>
|
||||||
|
</AnchorPane>
|
||||||
|
</VBox>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
Loading…
Reference in New Issue
Block a user