Dev #8

Merged
altavir merged 78 commits from dev into master 2023-03-04 16:47:55 +03:00
2 changed files with 7 additions and 1 deletions
Showing only changes of commit 7b56436983 - Show all commits

View File

@ -1,5 +1,6 @@
package ru.mipt.npm.controls.controllers
import kotlinx.coroutines.launch
import ru.mipt.npm.controls.api.Device
import ru.mipt.npm.controls.api.DeviceHub
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 {
val device = factory(meta, context)
registerDevice(NameToken(name), device)
device.launch {
device.open()
}
return device
}

View File

@ -34,6 +34,9 @@ class DemoDevice(context: Context, meta: Meta) : DeviceBySpec<DemoDevice>(DemoDe
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
val timeScale by property(MetaConverter.double, DemoDevice::timeScaleState) {
metaDescriptor {
@ -77,6 +80,5 @@ class DemoDevice(context: Context, meta: Meta) : DeviceBySpec<DemoDevice>(DemoDe
null
}
override fun invoke(meta: Meta, context: Context): DemoDevice = DemoDevice(context, meta)
}
}