diff --git a/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Device.kt b/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Device.kt index 3cd46dae..a31572ba 100644 --- a/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Device.kt +++ b/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Device.kt @@ -123,7 +123,7 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor(context, meta) { logger.info("Setting dynamic range to " + it.intValue()) val response = sendAndWait("g" + it.intValue()).trim { it <= ' ' } if (response.contains("=")) { - updateLogicalState(PGA, Integer.parseInt(response.substring(4))) + updateState(PGA, Integer.parseInt(response.substring(4))) } else { logger.error("Setting pga failed with message: $response") } @@ -166,7 +166,7 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor(context, meta) { } if (response.contains("=")) { - updateLogicalState(ABUF, Integer.parseInt(response.substring(14))) + updateState(ABUF, Integer.parseInt(response.substring(14))) // getLogger().info("successfully set buffer size to {}", this.abuf); } else { logger.error("Setting averaging buffer failed with message: $response") @@ -230,13 +230,13 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor(context, meta) { } private fun notifyChannelResult(designation: String, rawValue: Double) { - updateLogicalState("raw.$designation", rawValue) + updateState("raw.$designation", rawValue) val channel = channels[designation] val temperature = channel?.let { val temp = it.getTemperature(rawValue) - updateLogicalState("temp.$designation", temp) + updateState("temp.$designation", temp) collector.put(it.name, temp) temp } @@ -305,7 +305,7 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor(context, meta) { } if (response.contains("=")) { - updateLogicalState(SPS, Integer.parseInt(response.substring(4))) + updateState(SPS, Integer.parseInt(response.substring(4))) } else { logger.error("Setting sps failed with message: $response") } diff --git a/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/LambdaMagnet.kt b/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/LambdaMagnet.kt index 16dd9631..13a3e341 100644 --- a/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/LambdaMagnet.kt +++ b/numass-control/magnet/src/main/kotlin/inr/numass/control/magnet/LambdaMagnet.kt @@ -163,7 +163,7 @@ open class LambdaMagnet(context: Context, meta: Meta, private val controller: La // val out: Boolean = "ON" == talk("OUT?") // // val measuredCurrent = s2d(getParameter("MC")) -// updateLogicalState("current", measuredCurrent) +// updateState("current", measuredCurrent) // val setCurrent = s2d(getParameter("PC")) // val measuredVoltage = s2d(getParameter("MV")) // val setVoltage = s2d(getParameter("PV")) @@ -216,11 +216,11 @@ open class LambdaMagnet(context: Context, meta: Meta, private val controller: La private fun update(key: String, value: String) { when (key) { - "OUT" -> updateLogicalState("output", value == "ON") - "MC" -> updateLogicalState("current", s2d(value)) - "PC" -> updateLogicalState("targetCurrent", s2d(value)) - "MV" -> updateLogicalState("voltage", s2d(value)) - "PV" -> updateLogicalState("targetVoltage", s2d(value)) + "OUT" -> updateState("output", value == "ON") + "MC" -> updateState("current", s2d(value)) + "PC" -> updateState("targetCurrent", s2d(value)) + "MV" -> updateState("voltage", s2d(value)) + "PV" -> updateState("targetVoltage", s2d(value)) } } @@ -287,7 +287,7 @@ open class LambdaMagnet(context: Context, meta: Meta, private val controller: La updateTask = scheduler.scheduleWithFixedDelay(call, 0, delay.toLong(), TimeUnit.MILLISECONDS) listener?.updateTaskStateChanged(getName(), true) - updateLogicalState("updating", Value.of(true)) + updateState("updating", Value.of(true)) } @Throws(PortException::class) @@ -339,7 +339,7 @@ open class LambdaMagnet(context: Context, meta: Meta, private val controller: La listener?.monitorTaskStateChanged(getName(), false) monitorTask = null } - updateLogicalState("output", Value.of(false)) + updateState("output", Value.of(false)) } override fun getName(): String { diff --git a/numass-control/msp/src/main/kotlin/inr/numass/control/msp/MspDevice.kt b/numass-control/msp/src/main/kotlin/inr/numass/control/msp/MspDevice.kt index 744047b3..6698ded8 100644 --- a/numass-control/msp/src/main/kotlin/inr/numass/control/msp/MspDevice.kt +++ b/numass-control/msp/src/main/kotlin/inr/numass/control/msp/MspDevice.kt @@ -91,8 +91,8 @@ class MspDevice(context: Context, meta: Meta) : PortSensor(context, meta) { it.weakOnPhrase({ it.startsWith("FilamentStatus") }, this) { val response = MspResponse(it) val status = response[0, 2] - updateLogicalState("filamentOn", status == "ON") - updateLogicalState("filamentStatus", status) + updateState("filamentOn", status == "ON") + updateState("filamentStatus", status) } logger.info("Connected to MKS mass-spectrometer on {}", it.port) } @@ -153,7 +153,7 @@ class MspDevice(context: Context, meta: Meta) : PortSensor(context, meta) { response = commandAndWait("Select", sensorName) if (response.isOK) { - updateLogicalState("selected", true) + updateState("selected", true) } else { notifyError(response.errorDescription, null) return false @@ -162,13 +162,13 @@ class MspDevice(context: Context, meta: Meta) : PortSensor(context, meta) { response = commandAndWait("Control", "inr.numass.msp", "1.1") if (response.isOK) { - updateLogicalState("controlled", true) + updateState("controlled", true) } else { notifyError(response.errorDescription, null) return false } // connected = true; - updateLogicalState(PortSensor.CONNECTED_STATE, true) + updateState(PortSensor.CONNECTED_STATE, true) return true } else { return !commandAndWait("Release").isOK @@ -224,7 +224,7 @@ class MspDevice(context: Context, meta: Meta) : PortSensor(context, meta) { private fun selectFilament(filament: Int) { val response = commandAndWait("FilamentSelect", filament) if (response.isOK) { - updateLogicalState("filament", response[1, 1]) + updateState("filament", response[1, 1]) } else { logger.error("Failed to set filament with error: {}", response.errorDescription) } @@ -366,7 +366,7 @@ class MspDevice(context: Context, meta: Meta) : PortSensor(context, meta) { forEachConnection(Roles.VIEW_ROLE, NamedValueListener::class.java) { listener -> listener.pushValue(massName, value) } } "ZeroReading" -> { - updateLogicalState("peakJump.zero", java.lang.Double.parseDouble(response[0, 2]) / 100.0) + updateState("peakJump.zero", java.lang.Double.parseDouble(response[0, 2]) / 100.0) } "StartingScan" -> { val numScans = Integer.parseInt(response[0, 3]) diff --git a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/CM32Device.kt b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/CM32Device.kt index 595e924d..f743523d 100644 --- a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/CM32Device.kt +++ b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/CM32Device.kt @@ -42,16 +42,16 @@ class CM32Device(context: Context, meta: Meta) : PortSensor(context, meta) { val answer = sendAndWait("MES R PM 1\r\n") return if (answer.isEmpty()) { - updateLogicalState(PortSensor.CONNECTED_STATE, false) + updateState(PortSensor.CONNECTED_STATE, false) produceError("No signal") } else if (!answer.contains("PM1:mbar")) { - updateLogicalState(PortSensor.CONNECTED_STATE, false) + updateState(PortSensor.CONNECTED_STATE, false) produceError("Wrong answer: $answer") } else if (answer.substring(14, 17) == "OFF") { - updateLogicalState(PortSensor.CONNECTED_STATE, true) + updateState(PortSensor.CONNECTED_STATE, true) produceError("Off") } else { - updateLogicalState(PortSensor.CONNECTED_STATE, true) + updateState(PortSensor.CONNECTED_STATE, true) produceResult(answer.substring(14, 17) + answer.substring(19, 23)) } } diff --git a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSBaratronDevice.kt b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSBaratronDevice.kt index 78d7133f..66425096 100644 --- a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSBaratronDevice.kt +++ b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSBaratronDevice.kt @@ -47,10 +47,10 @@ class MKSBaratronDevice(context: Context, meta: Meta) : PortSensor(context, meta val answer = sendAndWait("AV$channel\r") if (answer.isEmpty()) { // invalidateState("connection"); - updateLogicalState(PortSensor.CONNECTED_STATE, false) + updateState(PortSensor.CONNECTED_STATE, false) return produceError("No connection") } else { - updateLogicalState(PortSensor.CONNECTED_STATE, true) + updateState(PortSensor.CONNECTED_STATE, true) } val res = java.lang.Double.parseDouble(answer) return if (res <= 0) { diff --git a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSVacDevice.kt b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSVacDevice.kt index 9e3bd086..6e4b2750 100644 --- a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSVacDevice.kt +++ b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MKSVacDevice.kt @@ -93,14 +93,14 @@ class MKSVacDevice(context: Context, meta: Meta) : PortSensor(context, meta) { // } val ans = talk("FP!ON") if (ans == "ON") { - updateLogicalState("power", true) + updateState("power", true) } else { this.notifyError("Failed to set power state") } } else { val ans = talk("FP!OFF") if (ans == "OFF") { - updateLogicalState("power", false) + updateState("power", false) } else { this.notifyError("Failed to set power state") } @@ -121,12 +121,12 @@ class MKSVacDevice(context: Context, meta: Meta) : PortSensor(context, meta) { val channel = meta.getInt("channel", 5) val answer = talk("PR$channel?") if (answer == null || answer.isEmpty()) { - updateLogicalState(PortSensor.CONNECTED_STATE, false) + updateState(PortSensor.CONNECTED_STATE, false) return produceError("No connection") } val res = parseDouble(answer) return if (res <= 0) { - updateLogicalState("power", false) + updateState("power", false) produceError("No power") } else { this.updateMessage("OK") diff --git a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MeradatVacDevice.kt b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MeradatVacDevice.kt index 2a7f7a75..3ae9dd90 100644 --- a/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MeradatVacDevice.kt +++ b/numass-control/vac/src/main/kotlin/inr/numass/control/readvac/MeradatVacDevice.kt @@ -55,7 +55,7 @@ class MeradatVacDevice(context: Context, meta: Meta) : PortSensor(context, meta) val answer = sendAndWait(query) { phrase -> phrase.startsWith(requestBase) } if (answer.isEmpty()) { - updateLogicalState(PortSensor.CONNECTED_STATE, false) + updateState(PortSensor.CONNECTED_STATE, false) return produceError("No signal") } else { val match = response.matcher(answer) @@ -68,10 +68,10 @@ class MeradatVacDevice(context: Context, meta: Meta) : PortSensor(context, meta) } var res = BigDecimal.valueOf(base * Math.pow(10.0, exp.toDouble())) res = res.setScale(4, RoundingMode.CEILING) - updateLogicalState(PortSensor.CONNECTED_STATE, true) + updateState(PortSensor.CONNECTED_STATE, true) produceResult(res) } else { - updateLogicalState(PortSensor.CONNECTED_STATE, false) + updateState(PortSensor.CONNECTED_STATE, false) produceError("Wrong answer: $answer") } }