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.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

View File

@ -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<PKT8Result>(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<PKT8Result> {
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")
}
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<PKT8Result>(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)

View File

@ -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<PKT8Device>(), MeasurementListener {
override fun buildView(device: PKT8Device): View = CryoView()
override fun buildView(device: PKT8Device) = CryoView()
internal val table = FXCollections.observableHashMap<String, PKT8Result>()
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 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 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<PKT8Device>(), 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)
}