From 3965b042975e57e5ac5a3494bf1485de123fbefb Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 15 Nov 2017 22:44:30 +0300 Subject: [PATCH] Fixed problem with laminate inherent descriptors. --- .../inr/numass/control/BoardController.kt | 2 +- .../inr/numass/control/cryotemp/PKT8Device.kt | 20 ++++++++----------- .../numass/control/cryotemp/PKT8Display.kt | 11 ++++++---- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/numass-control/control-room/src/main/kotlin/inr/numass/control/BoardController.kt b/numass-control/control-room/src/main/kotlin/inr/numass/control/BoardController.kt index 9e859900..835dfb75 100644 --- a/numass-control/control-room/src/main/kotlin/inr/numass/control/BoardController.kt +++ b/numass-control/control-room/src/main/kotlin/inr/numass/control/BoardController.kt @@ -62,7 +62,7 @@ class BoardController() : Controller(), AutoCloseable { deviceManager.buildDevice(it) } } - deviceManager.devices.forEach { it.connect(connection, Roles.STORAGE_ROLE, Roles.MEASUREMENT_LISTENER_ROLE) } + deviceManager.devices.forEach { it.connect(connection, Roles.STORAGE_ROLE) } }.also { runLater { context = it 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 33f5b838..a6c6e70b 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 @@ -22,6 +22,7 @@ import hep.dataforge.control.collectors.RegularPointCollector import hep.dataforge.control.connections.Roles import hep.dataforge.control.devices.Device import hep.dataforge.control.devices.PortSensor +import hep.dataforge.control.devices.Sensor import hep.dataforge.control.devices.StateDef import hep.dataforge.control.measurements.AbstractMeasurement import hep.dataforge.control.measurements.Measurement @@ -237,25 +238,19 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor(context, private fun setSPS(sps: Int) { logger.info("Setting sampling rate to " + spsToStr(sps)) - var response: String - try { - response = sendAndWait("v" + sps, TIMEOUT).trim { it <= ' ' } + val response: String = try { + sendAndWait("v" + sps, TIMEOUT).trim { it <= ' ' } } catch (ex: Exception) { - response = ex.message ?: "" + ex.message ?: "" } if (response.contains("=")) { updateState(SPS, Integer.parseInt(response.substring(4))) - // getLogger().info("successfully sampling rate to {}", spsToStr(this.sps)); } else { logger.error("Setting sps failed with message: " + response) } } - // public void connectPointListener(PointListenerConnection listener) { - // this.connect(listener, Roles.POINT_LISTENER_ROLE); - // } - @Throws(MeasurementException::class) override fun createMeasurement(): Measurement { return if (this.measurement != null) { @@ -315,14 +310,14 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor(context, logger.warn("Trying to stop measurement which is already stopped") } - return try { + try { logger.info("Stopping measurement") val response = sendAndWait("p", TIMEOUT).trim { it <= ' ' } // Должно быть именно с большой буквы!!! - "Stopped" == response || "stopped" == response + return "Stopped" == response || "stopped" == response } catch (ex: Exception) { error(ex) - false + return false } finally { collector?.clear() logger.debug("Removing port lock") @@ -337,6 +332,7 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor(context, if (isStarted) { if (trimmed == "Stopped" || trimmed == "stopped") { afterPause() + updateState(Sensor.MEASURING_STATE, false) // getLogger().info("Measurement stopped"); } else { val designation = trimmed.substring(0, 1) diff --git a/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Display.kt b/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Display.kt index 82ae792b..ef072cf1 100644 --- a/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Display.kt +++ b/numass-control/cryotemp/src/main/kotlin/inr/numass/control/cryotemp/PKT8Display.kt @@ -3,7 +3,9 @@ package inr.numass.control.cryotemp import hep.dataforge.control.devices.Sensor import hep.dataforge.control.measurements.Measurement import hep.dataforge.control.measurements.MeasurementListener +import hep.dataforge.description.DescriptorUtils import hep.dataforge.fx.bindWindow +import hep.dataforge.fx.dfIconView import hep.dataforge.fx.fragments.LogFragment import hep.dataforge.fx.plots.PlotContainer import hep.dataforge.meta.Meta @@ -33,7 +35,7 @@ import java.time.Instant */ class PKT8Display : DeviceDisplay(), MeasurementListener { - override fun buildView(device: PKT8Device): View = CryoView() + override fun buildView(device: PKT8Device) = CryoView() internal val table = FXCollections.observableHashMap() val lastUpdateProperty = SimpleObjectProperty("NEVER") @@ -58,7 +60,7 @@ class PKT8Display : DeviceDisplay(), MeasurementListener { } } - inner class CryoView : View() { + inner class CryoView : Fragment("PKT values", dfIconView) { private var plotButton: ToggleButton by singleAssign() private var logButton: ToggleButton by singleAssign() @@ -135,11 +137,12 @@ class PKT8Display : DeviceDisplay(), MeasurementListener { } } - inner class CryoPlotView : View("PKT8 temperature plot") { + inner class CryoPlotView : Fragment("PKT8 temperature plot", dfIconView) { private val plotFrameMeta: Meta = device.meta.getMetaOrEmpty("plotConfig") private val plotFrame: PlotFrame by lazy { JFreeChartFrame(plotFrameMeta).apply { + plots.descriptor = DescriptorUtils.buildDescriptor(TimePlot::class.java) PlotUtils.setXAxis(this, "timestamp", null, "time") } } @@ -170,7 +173,7 @@ class PKT8Display : DeviceDisplay(), MeasurementListener { init { if (device.meta().hasMeta("plotConfig")) { with(plotFrame.plots) { - configure(device.meta().getMeta("plotConfig")) + //configure(device.meta().getMeta("plotConfig")) TimePlot.setMaxItems(this, 1000) TimePlot.setPrefItems(this, 400) }