Dev #8
@ -1,5 +1,6 @@
|
|||||||
package ru.mipt.npm.controls.controllers
|
package ru.mipt.npm.controls.controllers
|
||||||
|
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import ru.mipt.npm.controls.api.Device
|
import ru.mipt.npm.controls.api.Device
|
||||||
import ru.mipt.npm.controls.api.DeviceHub
|
import ru.mipt.npm.controls.api.DeviceHub
|
||||||
import space.kscience.dataforge.context.*
|
import space.kscience.dataforge.context.*
|
||||||
@ -38,6 +39,9 @@ public class DeviceManager : AbstractPlugin(), DeviceHub {
|
|||||||
public fun <D : Device> DeviceManager.install(name: String, factory: Factory<D>, meta: Meta = Meta.EMPTY): D {
|
public fun <D : Device> DeviceManager.install(name: String, factory: Factory<D>, meta: Meta = Meta.EMPTY): D {
|
||||||
val device = factory(meta, context)
|
val device = factory(meta, context)
|
||||||
registerDevice(NameToken(name), device)
|
registerDevice(NameToken(name), device)
|
||||||
|
device.launch {
|
||||||
|
device.open()
|
||||||
|
}
|
||||||
return device
|
return device
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,9 @@ class DemoDevice(context: Context, meta: Meta) : DeviceBySpec<DemoDevice>(DemoDe
|
|||||||
|
|
||||||
|
|
||||||
companion object : DeviceSpec<DemoDevice>(), Factory<DemoDevice> {
|
companion object : DeviceSpec<DemoDevice>(), Factory<DemoDevice> {
|
||||||
|
|
||||||
|
override fun invoke(meta: Meta, context: Context): DemoDevice = DemoDevice(context, meta)
|
||||||
|
|
||||||
// register virtual properties based on actual object state
|
// register virtual properties based on actual object state
|
||||||
val timeScale by property(MetaConverter.double, DemoDevice::timeScaleState) {
|
val timeScale by property(MetaConverter.double, DemoDevice::timeScaleState) {
|
||||||
metaDescriptor {
|
metaDescriptor {
|
||||||
@ -77,6 +80,5 @@ class DemoDevice(context: Context, meta: Meta) : DeviceBySpec<DemoDevice>(DemoDe
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun invoke(meta: Meta, context: Context): DemoDevice = DemoDevice(context, meta)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user