Updating control

This commit is contained in:
Alexander Nozik 2018-04-05 22:35:56 +03:00
parent 98ef7688d5
commit 68fa5c715b
11 changed files with 35 additions and 20 deletions

View File

@ -58,5 +58,6 @@ class LambdaHub(context: Context, meta: Meta) : DeviceHub, AbstractDevice(contex
override fun optDevice(name: Name): Optional<Device> =
magnets.stream().filter { it.name == name.toUnescaped() }.map { it as Device }.findFirst()
override fun getDeviceNames(): Stream<Name> = magnets.stream().map { Name.ofSingle(it.name) }
override val deviceNames: Stream<Name>
get() = magnets.stream().map { Name.ofSingle(it.name) }
}

View File

@ -12,9 +12,7 @@ import javafx.stage.Stage
class MagnetApp: NumassControlApplication<LambdaHub>() {
override val deviceFactory: DeviceFactory = object :DeviceFactory{
override fun getType(): String {
return "numass.lambda"
}
override val type: String = "numass.lambda"
override fun build(context: Context, meta: Meta): Device {
return LambdaHub(context, meta)

View File

@ -124,7 +124,8 @@ class MspDevice(context: Context, meta: Meta) : PortSensor(context, meta) {
// else -> super.computeState(stateName)
// }
override fun getType(): String = MSP_DEVICE_TYPE
override val type: String
get() = MSP_DEVICE_TYPE
/**
* Startup MSP: get available sensors, select sensor and control.

View File

@ -136,9 +136,15 @@ abstract class DeviceDisplayFX<D : Device> : Component(), Connection, DeviceList
alignment = Pos.CENTER_LEFT
vgrow = Priority.ALWAYS;
deviceStateIndicator(this@DeviceDisplayFX, Device.INITIALIZED_STATE)
deviceStateIndicator(this@DeviceDisplayFX, PortSensor.CONNECTED_STATE)
deviceStateIndicator(this@DeviceDisplayFX, Sensor.MEASURING_STATE)
deviceStateIndicator(this@DeviceDisplayFX, "storing")
if(device is PortSensor) {
deviceStateIndicator(this@DeviceDisplayFX, PortSensor.CONNECTED_STATE)
}
if(device is Sensor) {
deviceStateIndicator(this@DeviceDisplayFX, Sensor.MEASURING_STATE)
}
if(device.stateNames.contains("storing")) {
deviceStateIndicator(this@DeviceDisplayFX, "storing")
}
pane {
hgrow = Priority.ALWAYS
}

View File

@ -52,8 +52,9 @@ class CM32Device(context: Context, meta: Meta) : PortSensor(context, meta) {
}
}
override fun getType(): String {
return meta.getString("type", "numass.vac.cm32")
}
override val type: String
get() {
return meta.getString("type", "numass.vac.cm32")
}
}

View File

@ -27,9 +27,10 @@ class MKSBaratronDevice(context: Context, meta: Meta) : PortSensor(context, meta
var channel by valueState("channel").intDelegate
override fun getType(): String {
return meta.getString("type", "numass.vac.baratron")
}
override val type: String
get() {
return meta.getString("type", "numass.vac.baratron")
}
override fun connect(meta: Meta): GenericPortController {
val port: Port = PortFactory.build(meta)

View File

@ -97,7 +97,8 @@ class MKSVacDevice(context: Context, meta: Meta) : PortSensor(context, meta) {
}
}
override fun getType(): String = meta.getString("type", "numass.vac.mks")
override val type: String
get() = meta.getString("type", "numass.vac.mks")
override fun startMeasurement(oldMeta: Meta?, newMeta: Meta) {
measurement {

View File

@ -35,9 +35,10 @@ class MeradatVacDevice(context: Context, meta: Meta) : PortSensor(context, meta)
return GenericPortController(context, port) { it.endsWith("\r\n") }
}
override fun getType(): String {
return meta.getString("type", "numass.vac.vit")
}
override val type: String
get() {
return meta.getString("type", "numass.vac.vit")
}
override fun startMeasurement(oldMeta: Meta?, newMeta: Meta) {
measurement{

View File

@ -75,7 +75,8 @@ class VacCollectorDevice(context: Context, meta: Meta, val sensors: Collection<S
}
}
override fun getType(): String = "numass.vac.collector"
override val type: String
get() = "numass.vac.collector"
@Throws(ControlException::class)

View File

@ -29,6 +29,10 @@ protobuf {
generatedFilesBaseDir = "$projectDir/gen"
}
compileKotlin {
dependsOn(':numass-core:generateProto')
}
sourceSets {
main.kotlin.srcDirs += 'gen/main/java'
}

View File

@ -95,7 +95,7 @@ val deviceInterceptor = InterceptorFactory { context, meta ->
val device = deviceManager.optDevice(name).get();
devices.add(jsonObject {
add("name", name.toUnescaped())
add("type", device.getType())
add("type", device.type)
add("getMeta", device.meta.asJson())
})
}