Fixed problem with laminate inherent descriptors.

This commit is contained in:
Alexander Nozik 2017-11-15 22:44:30 +03:00
parent f0fc22c9ec
commit 3965b04297
3 changed files with 16 additions and 17 deletions

View File

@ -62,7 +62,7 @@ class BoardController() : Controller(), AutoCloseable {
deviceManager.buildDevice(it) 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 { }.also {
runLater { runLater {
context = it context = it

View File

@ -22,6 +22,7 @@ import hep.dataforge.control.collectors.RegularPointCollector
import hep.dataforge.control.connections.Roles import hep.dataforge.control.connections.Roles
import hep.dataforge.control.devices.Device import hep.dataforge.control.devices.Device
import hep.dataforge.control.devices.PortSensor import hep.dataforge.control.devices.PortSensor
import hep.dataforge.control.devices.Sensor
import hep.dataforge.control.devices.StateDef import hep.dataforge.control.devices.StateDef
import hep.dataforge.control.measurements.AbstractMeasurement import hep.dataforge.control.measurements.AbstractMeasurement
import hep.dataforge.control.measurements.Measurement import hep.dataforge.control.measurements.Measurement
@ -237,25 +238,19 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor<PKT8Result>(context,
private fun setSPS(sps: Int) { private fun setSPS(sps: Int) {
logger.info("Setting sampling rate to " + spsToStr(sps)) logger.info("Setting sampling rate to " + spsToStr(sps))
var response: String val response: String = try {
try { sendAndWait("v" + sps, TIMEOUT).trim { it <= ' ' }
response = sendAndWait("v" + sps, TIMEOUT).trim { it <= ' ' }
} catch (ex: Exception) { } catch (ex: Exception) {
response = ex.message ?: "" ex.message ?: ""
} }
if (response.contains("=")) { if (response.contains("=")) {
updateState(SPS, Integer.parseInt(response.substring(4))) updateState(SPS, Integer.parseInt(response.substring(4)))
// getLogger().info("successfully sampling rate to {}", spsToStr(this.sps));
} else { } else {
logger.error("Setting sps failed with message: " + response) logger.error("Setting sps failed with message: " + response)
} }
} }
// public void connectPointListener(PointListenerConnection listener) {
// this.connect(listener, Roles.POINT_LISTENER_ROLE);
// }
@Throws(MeasurementException::class) @Throws(MeasurementException::class)
override fun createMeasurement(): Measurement<PKT8Result> { override fun createMeasurement(): Measurement<PKT8Result> {
return if (this.measurement != null) { return if (this.measurement != null) {
@ -315,14 +310,14 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor<PKT8Result>(context,
logger.warn("Trying to stop measurement which is already stopped") logger.warn("Trying to stop measurement which is already stopped")
} }
return try { try {
logger.info("Stopping measurement") logger.info("Stopping measurement")
val response = sendAndWait("p", TIMEOUT).trim { it <= ' ' } val response = sendAndWait("p", TIMEOUT).trim { it <= ' ' }
// Должно быть именно с большой буквы!!! // Должно быть именно с большой буквы!!!
"Stopped" == response || "stopped" == response return "Stopped" == response || "stopped" == response
} catch (ex: Exception) { } catch (ex: Exception) {
error(ex) error(ex)
false return false
} finally { } finally {
collector?.clear() collector?.clear()
logger.debug("Removing port lock") logger.debug("Removing port lock")
@ -337,6 +332,7 @@ class PKT8Device(context: Context, meta: Meta) : PortSensor<PKT8Result>(context,
if (isStarted) { if (isStarted) {
if (trimmed == "Stopped" || trimmed == "stopped") { if (trimmed == "Stopped" || trimmed == "stopped") {
afterPause() afterPause()
updateState(Sensor.MEASURING_STATE, false)
// getLogger().info("Measurement stopped"); // getLogger().info("Measurement stopped");
} else { } else {
val designation = trimmed.substring(0, 1) val designation = trimmed.substring(0, 1)

View File

@ -3,7 +3,9 @@ package inr.numass.control.cryotemp
import hep.dataforge.control.devices.Sensor 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 hep.dataforge.description.DescriptorUtils
import hep.dataforge.fx.bindWindow import hep.dataforge.fx.bindWindow
import hep.dataforge.fx.dfIconView
import hep.dataforge.fx.fragments.LogFragment import hep.dataforge.fx.fragments.LogFragment
import hep.dataforge.fx.plots.PlotContainer import hep.dataforge.fx.plots.PlotContainer
import hep.dataforge.meta.Meta import hep.dataforge.meta.Meta
@ -33,7 +35,7 @@ import java.time.Instant
*/ */
class PKT8Display : DeviceDisplay<PKT8Device>(), MeasurementListener { class PKT8Display : DeviceDisplay<PKT8Device>(), MeasurementListener {
override fun buildView(device: PKT8Device): View = CryoView() override fun buildView(device: PKT8Device) = CryoView()
internal val table = FXCollections.observableHashMap<String, PKT8Result>() internal val table = FXCollections.observableHashMap<String, PKT8Result>()
val lastUpdateProperty = SimpleObjectProperty<String>("NEVER") val lastUpdateProperty = SimpleObjectProperty<String>("NEVER")
@ -58,7 +60,7 @@ class PKT8Display : DeviceDisplay<PKT8Device>(), MeasurementListener {
} }
} }
inner class CryoView : View() { inner class CryoView : Fragment("PKT values", dfIconView) {
private var plotButton: ToggleButton by singleAssign() private var plotButton: ToggleButton by singleAssign()
private var logButton: ToggleButton by singleAssign() private var logButton: ToggleButton by singleAssign()
@ -135,11 +137,12 @@ class PKT8Display : DeviceDisplay<PKT8Device>(), 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 plotFrameMeta: Meta = device.meta.getMetaOrEmpty("plotConfig")
private val plotFrame: PlotFrame by lazy { private val plotFrame: PlotFrame by lazy {
JFreeChartFrame(plotFrameMeta).apply { JFreeChartFrame(plotFrameMeta).apply {
plots.descriptor = DescriptorUtils.buildDescriptor(TimePlot::class.java)
PlotUtils.setXAxis(this, "timestamp", null, "time") PlotUtils.setXAxis(this, "timestamp", null, "time")
} }
} }
@ -170,7 +173,7 @@ class PKT8Display : DeviceDisplay<PKT8Device>(), MeasurementListener {
init { init {
if (device.meta().hasMeta("plotConfig")) { if (device.meta().hasMeta("plotConfig")) {
with(plotFrame.plots) { with(plotFrame.plots) {
configure(device.meta().getMeta("plotConfig")) //configure(device.meta().getMeta("plotConfig"))
TimePlot.setMaxItems(this, 1000) TimePlot.setMaxItems(this, 1000)
TimePlot.setPrefItems(this, 400) TimePlot.setPrefItems(this, 400)
} }