Updates on control
This commit is contained in:
parent
d032c48ef4
commit
7e676681b7
@ -96,14 +96,14 @@ class PKT8Display : DeviceDisplayFX<PKT8Device>(), PKT8ValueListener {
|
||||
|
||||
plotButton = togglebutton("Plot") {
|
||||
isSelected = false
|
||||
plotView.bindWindow(selectedProperty())
|
||||
plotView.bindWindow(this, selectedProperty())
|
||||
}
|
||||
|
||||
logButton = togglebutton("Log") {
|
||||
isSelected = false
|
||||
LogFragment().apply {
|
||||
addLogHandler(device.logger)
|
||||
bindWindow(selectedProperty())
|
||||
bindWindow(this@togglebutton, selectedProperty())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import hep.dataforge.description.ValueDef
|
||||
import hep.dataforge.exceptions.ControlException
|
||||
import hep.dataforge.exceptions.MeasurementException
|
||||
import hep.dataforge.exceptions.PortException
|
||||
import hep.dataforge.kodex.useMeta
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.states.StateDef
|
||||
import hep.dataforge.states.StateDefs
|
||||
@ -108,13 +109,19 @@ class MspDevice(context: Context, meta: Meta) : PortSensor(context, meta) {
|
||||
}
|
||||
}
|
||||
|
||||
override fun init() {
|
||||
super.init()
|
||||
meta.useMeta("peakJump"){
|
||||
updateState(MEASUREMENT_META_STATE, it)
|
||||
}
|
||||
}
|
||||
|
||||
@Throws(ControlException::class)
|
||||
override fun shutdown() {
|
||||
super.stopMeasurement()
|
||||
if (connected.booleanValue) {
|
||||
if (controlled.booleanValue) {
|
||||
setFilamentOn(false)
|
||||
}
|
||||
controlled.set(false)
|
||||
super.shutdown()
|
||||
}
|
||||
|
||||
@ -129,10 +136,10 @@ class MspDevice(context: Context, meta: Meta) : PortSensor(context, meta) {
|
||||
* @throws hep.dataforge.exceptions.ControlException
|
||||
*/
|
||||
private fun control(on: Boolean): Boolean {
|
||||
logger.info("Starting initialization sequence")
|
||||
if (on != this.controlled.booleanValue) {
|
||||
val sensorName: String
|
||||
if (on) {
|
||||
logger.info("Starting initialization sequence")
|
||||
//ensure device is connected
|
||||
connected.setAndWait(true)
|
||||
var response = commandAndWait("Sensors")
|
||||
@ -163,6 +170,7 @@ class MspDevice(context: Context, meta: Meta) : PortSensor(context, meta) {
|
||||
updateState(PortSensor.CONNECTED_STATE, true)
|
||||
return true
|
||||
} else {
|
||||
logger.info("Releasing device")
|
||||
return !commandAndWait("Release").isOK
|
||||
}
|
||||
} else {
|
||||
@ -248,59 +256,11 @@ class MspDevice(context: Context, meta: Meta) : PortSensor(context, meta) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The MKS response as two-dimensional array of strings
|
||||
*/
|
||||
class MspResponse(response: String) {
|
||||
|
||||
private val data = ArrayList<List<String>>()
|
||||
|
||||
val commandName: String
|
||||
get() = this[0, 0]
|
||||
|
||||
val isOK: Boolean
|
||||
get() = "OK" == this[0, 1]
|
||||
|
||||
init {
|
||||
val rx = "[^\"\\s]+|\"(\\\\.|[^\\\\\"])*\""
|
||||
val scanner = Scanner(response.trim { it <= ' ' })
|
||||
|
||||
while (scanner.hasNextLine()) {
|
||||
val line = ArrayList<String>()
|
||||
var next: String? = scanner.findWithinHorizon(rx, 0)
|
||||
while (next != null) {
|
||||
line.add(next)
|
||||
next = scanner.findInLine(rx)
|
||||
}
|
||||
data.add(line)
|
||||
}
|
||||
}
|
||||
|
||||
fun errorCode(): Int {
|
||||
return if (isOK) {
|
||||
-1
|
||||
} else {
|
||||
Integer.parseInt(get(1, 1))
|
||||
}
|
||||
}
|
||||
|
||||
val errorDescription: String
|
||||
get() {
|
||||
return if (isOK) {
|
||||
throw RuntimeException("Not a error")
|
||||
} else {
|
||||
get(2, 1)
|
||||
}
|
||||
}
|
||||
|
||||
operator fun get(lineNo: Int, columnNo: Int): String = data[lineNo][columnNo]
|
||||
}
|
||||
|
||||
override fun stopMeasurement() {
|
||||
super.stopMeasurement()
|
||||
runOnDeviceThread {
|
||||
stopPeakJump()
|
||||
}
|
||||
super.stopMeasurement()
|
||||
}
|
||||
|
||||
override fun startMeasurement(oldMeta: Meta?, newMeta: Meta) {
|
||||
@ -322,7 +282,7 @@ class MspDevice(context: Context, meta: Meta) : PortSensor(context, meta) {
|
||||
val filterMode = meta.getString("filterMode", "PeakAverage")
|
||||
val accuracy = meta.getInt("accuracy", 5)
|
||||
//PENDING вставить остальные параметры?
|
||||
sendAndWait("MeasurementRemoveAll")
|
||||
sendAndWait("MeasurementRemoveAll", Duration.ofMillis(200))
|
||||
|
||||
// val peakMap: MutableMap<Int, String> = LinkedHashMap()
|
||||
|
||||
@ -393,6 +353,55 @@ class MspDevice(context: Context, meta: Meta) : PortSensor(context, meta) {
|
||||
notifyMeasurementState(MeasurementState.STOPPED)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The MKS response as two-dimensional array of strings
|
||||
*/
|
||||
class MspResponse(response: String) {
|
||||
|
||||
private val data = ArrayList<List<String>>()
|
||||
|
||||
val commandName: String
|
||||
get() = this[0, 0]
|
||||
|
||||
val isOK: Boolean
|
||||
get() = "OK" == this[0, 1]
|
||||
|
||||
init {
|
||||
val rx = "[^\"\\s]+|\"(\\\\.|[^\\\\\"])*\""
|
||||
val scanner = Scanner(response.trim { it <= ' ' })
|
||||
|
||||
while (scanner.hasNextLine()) {
|
||||
val line = ArrayList<String>()
|
||||
var next: String? = scanner.findWithinHorizon(rx, 0)
|
||||
while (next != null) {
|
||||
line.add(next)
|
||||
next = scanner.findInLine(rx)
|
||||
}
|
||||
data.add(line)
|
||||
}
|
||||
}
|
||||
|
||||
fun errorCode(): Int {
|
||||
return if (isOK) {
|
||||
-1
|
||||
} else {
|
||||
Integer.parseInt(get(1, 1))
|
||||
}
|
||||
}
|
||||
|
||||
val errorDescription: String
|
||||
get() {
|
||||
return if (isOK) {
|
||||
throw RuntimeException("Not a error")
|
||||
} else {
|
||||
get(2, 1)
|
||||
}
|
||||
}
|
||||
|
||||
operator fun get(lineNo: Int, columnNo: Int): String = data[lineNo][columnNo]
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val MSP_DEVICE_TYPE = "numass.msp"
|
||||
const val CONTROLLED_STATE = "controlled"
|
||||
|
@ -64,41 +64,6 @@ class SpectrumView(
|
||||
private val data: ObservableMap<String, NumassSet> = FXCollections.observableHashMap();
|
||||
val isEmpty = booleanBinding(data) { data.isEmpty() }
|
||||
|
||||
/*
|
||||
<BorderPane fx:id="spectrumPlotPane" prefHeight="200.0" prefWidth="200.0"
|
||||
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<top>
|
||||
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||
<VBox>
|
||||
<Label text="Lo channel"/>
|
||||
<TextField fx:id="lowChannelField" prefWidth="60.0"/>
|
||||
</VBox>
|
||||
<RangeSlider fx:id="channelSlider" accessibleRole="SLIDER"
|
||||
highValue="1900.0" lowValue="300.0" majorTickUnit="500.0"
|
||||
max="4000.0" minorTickCount="5" prefHeight="38.0"
|
||||
prefWidth="276.0" showTickLabels="true" showTickMarks="true">
|
||||
<padding>
|
||||
<Insets left="10.0" right="10.0"/>
|
||||
</padding>
|
||||
</RangeSlider>
|
||||
<VBox>
|
||||
<Label text="Up channel"/>
|
||||
<TextField fx:id="upChannelField" prefWidth="60.0"/>
|
||||
</VBox>
|
||||
<Separator orientation="VERTICAL"/>
|
||||
<VBox>
|
||||
<Label text="Dead time (us)"/>
|
||||
<TextField fx:id="dTimeField" prefHeight="25.0" prefWidth="0.0"
|
||||
text="7.2"/>
|
||||
</VBox>
|
||||
<Separator orientation="VERTICAL"/>
|
||||
<Pane minWidth="0.0" HBox.hgrow="ALWAYS"/>
|
||||
<Button fx:id="spectrumExportButton" mnemonicParsing="false" text="Export"/>
|
||||
</ToolBar>
|
||||
</top>
|
||||
</BorderPane>
|
||||
*/
|
||||
override val root = borderpane {
|
||||
top {
|
||||
toolbar {
|
||||
|
@ -122,7 +122,7 @@ class StorageView(private val context: Context = Global) : View(title = "Numass
|
||||
isSelected = false
|
||||
LogFragment().apply {
|
||||
addLogHandler(context.logger)
|
||||
bindWindow(selectedProperty())
|
||||
bindWindow(this@togglebutton, selectedProperty())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user