diff --git a/README.md b/README.md index 0177832..f8746e0 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Among other things, you can: ### `dataforge-control-core` module packages - `api` - defines API for device management. The main class here is -[`Device`](controls-core/src/commonMain/kotlin/hep/dataforge/control/api/Device.kt). +[`Device`](controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/api/Device.kt). Generally, a Device has Properties that can be read and written. Also, some Actions can optionally be applied on a device (may or may not affect properties). diff --git a/build.gradle.kts b/build.gradle.kts index 6711893..de93677 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { kotlin("js") apply false } -val dataforgeVersion: String by extra("0.4.0-dev-2") +val dataforgeVersion: String by extra("0.4.0-dev-8") val ktorVersion: String by extra(ru.mipt.npm.gradle.KScienceVersions.ktorVersion) val rsocketVersion by extra("0.12.0") diff --git a/controls-core/src/commonMain/kotlin/hep/dataforge/control/api/Device.kt b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/api/Device.kt similarity index 100% rename from controls-core/src/commonMain/kotlin/hep/dataforge/control/api/Device.kt rename to controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/api/Device.kt diff --git a/controls-core/src/commonMain/kotlin/hep/dataforge/control/api/DeviceHub.kt b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/api/DeviceHub.kt similarity index 100% rename from controls-core/src/commonMain/kotlin/hep/dataforge/control/api/DeviceHub.kt rename to controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/api/DeviceHub.kt diff --git a/controls-core/src/commonMain/kotlin/hep/dataforge/control/api/Socket.kt b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/api/Socket.kt similarity index 100% rename from controls-core/src/commonMain/kotlin/hep/dataforge/control/api/Socket.kt rename to controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/api/Socket.kt diff --git a/controls-core/src/commonMain/kotlin/hep/dataforge/control/api/descriptors.kt b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/api/descriptors.kt similarity index 100% rename from controls-core/src/commonMain/kotlin/hep/dataforge/control/api/descriptors.kt rename to controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/api/descriptors.kt diff --git a/controls-core/src/commonMain/kotlin/hep/dataforge/control/base/DeviceAction.kt b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/base/DeviceAction.kt similarity index 100% rename from controls-core/src/commonMain/kotlin/hep/dataforge/control/base/DeviceAction.kt rename to controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/base/DeviceAction.kt diff --git a/controls-core/src/commonMain/kotlin/hep/dataforge/control/base/DeviceBase.kt b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/base/DeviceBase.kt similarity index 98% rename from controls-core/src/commonMain/kotlin/hep/dataforge/control/base/DeviceBase.kt rename to controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/base/DeviceBase.kt index 23a29e1..047521c 100644 --- a/controls-core/src/commonMain/kotlin/hep/dataforge/control/base/DeviceBase.kt +++ b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/base/DeviceBase.kt @@ -24,6 +24,10 @@ public data class LogEntry(val content: String, val priority: Int = 0) @Suppress("EXPERIMENTAL_API_USAGE") public abstract class DeviceBase(override val context: Context) : Device { + override val scope: CoroutineScope by lazy { + CoroutineScope(context.coroutineContext + Job(context.coroutineContext[Job])) + } + private val _properties = HashMap() public val properties: Map get() = _properties private val _actions = HashMap() diff --git a/controls-core/src/commonMain/kotlin/hep/dataforge/control/base/DeviceProperty.kt b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/base/DeviceProperty.kt similarity index 100% rename from controls-core/src/commonMain/kotlin/hep/dataforge/control/base/DeviceProperty.kt rename to controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/base/DeviceProperty.kt diff --git a/controls-core/src/commonMain/kotlin/hep/dataforge/control/base/TypedDeviceProperty.kt b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/base/TypedDeviceProperty.kt similarity index 100% rename from controls-core/src/commonMain/kotlin/hep/dataforge/control/base/TypedDeviceProperty.kt rename to controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/base/TypedDeviceProperty.kt diff --git a/controls-core/src/commonMain/kotlin/hep/dataforge/control/base/actionDelegates.kt b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/base/actionDelegates.kt similarity index 100% rename from controls-core/src/commonMain/kotlin/hep/dataforge/control/base/actionDelegates.kt rename to controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/base/actionDelegates.kt diff --git a/controls-core/src/commonMain/kotlin/hep/dataforge/control/base/devicePropertyDelegates.kt b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/base/devicePropertyDelegates.kt similarity index 100% rename from controls-core/src/commonMain/kotlin/hep/dataforge/control/base/devicePropertyDelegates.kt rename to controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/base/devicePropertyDelegates.kt diff --git a/controls-core/src/commonMain/kotlin/hep/dataforge/control/base/misc.kt b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/base/misc.kt similarity index 100% rename from controls-core/src/commonMain/kotlin/hep/dataforge/control/base/misc.kt rename to controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/base/misc.kt diff --git a/controls-core/src/commonMain/kotlin/hep/dataforge/control/controllers/DeviceController.kt b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/controllers/DeviceController.kt similarity index 100% rename from controls-core/src/commonMain/kotlin/hep/dataforge/control/controllers/DeviceController.kt rename to controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/controllers/DeviceController.kt diff --git a/controls-core/src/commonMain/kotlin/hep/dataforge/control/controllers/DeviceManager.kt b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/controllers/DeviceManager.kt similarity index 100% rename from controls-core/src/commonMain/kotlin/hep/dataforge/control/controllers/DeviceManager.kt rename to controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/controllers/DeviceManager.kt diff --git a/controls-core/src/commonMain/kotlin/hep/dataforge/control/controllers/HubController.kt b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/controllers/HubController.kt similarity index 100% rename from controls-core/src/commonMain/kotlin/hep/dataforge/control/controllers/HubController.kt rename to controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/controllers/HubController.kt diff --git a/controls-core/src/commonMain/kotlin/hep/dataforge/control/messages/DeviceMessage.kt b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/messages/DeviceMessage.kt similarity index 100% rename from controls-core/src/commonMain/kotlin/hep/dataforge/control/messages/DeviceMessage.kt rename to controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/messages/DeviceMessage.kt diff --git a/controls-core/src/commonMain/kotlin/hep/dataforge/control/ports/Port.kt b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/ports/Port.kt similarity index 100% rename from controls-core/src/commonMain/kotlin/hep/dataforge/control/ports/Port.kt rename to controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/ports/Port.kt diff --git a/controls-core/src/commonMain/kotlin/hep/dataforge/control/ports/PortProxy.kt b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/ports/PortProxy.kt similarity index 100% rename from controls-core/src/commonMain/kotlin/hep/dataforge/control/ports/PortProxy.kt rename to controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/ports/PortProxy.kt diff --git a/controls-core/src/commonMain/kotlin/hep/dataforge/control/ports/SynchronousPortHandler.kt b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/ports/SynchronousPortHandler.kt similarity index 100% rename from controls-core/src/commonMain/kotlin/hep/dataforge/control/ports/SynchronousPortHandler.kt rename to controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/ports/SynchronousPortHandler.kt diff --git a/controls-core/src/commonMain/kotlin/hep/dataforge/control/ports/phrases.kt b/controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/ports/phrases.kt similarity index 100% rename from controls-core/src/commonMain/kotlin/hep/dataforge/control/ports/phrases.kt rename to controls-core/src/commonMain/kotlin/ru/mipt/npm/controls/ports/phrases.kt diff --git a/controls-core/src/jvmMain/kotlin/hep/dataforge/control/controllers/delegates.kt b/controls-core/src/jvmMain/kotlin/ru/mipt/npm/controls/controllers/delegates.kt similarity index 100% rename from controls-core/src/jvmMain/kotlin/hep/dataforge/control/controllers/delegates.kt rename to controls-core/src/jvmMain/kotlin/ru/mipt/npm/controls/controllers/delegates.kt diff --git a/controls-core/src/jvmMain/kotlin/hep/dataforge/control/ports/TcpPort.kt b/controls-core/src/jvmMain/kotlin/ru/mipt/npm/controls/ports/TcpPort.kt similarity index 100% rename from controls-core/src/jvmMain/kotlin/hep/dataforge/control/ports/TcpPort.kt rename to controls-core/src/jvmMain/kotlin/ru/mipt/npm/controls/ports/TcpPort.kt diff --git a/controls-core/src/jvmTest/kotlin/hep/dataforge/control/ports/PortIOTest.kt b/controls-core/src/jvmTest/kotlin/ru/mipt/npm/controls/ports/PortIOTest.kt similarity index 100% rename from controls-core/src/jvmTest/kotlin/hep/dataforge/control/ports/PortIOTest.kt rename to controls-core/src/jvmTest/kotlin/ru/mipt/npm/controls/ports/PortIOTest.kt diff --git a/controls-magix-client/src/commonMain/kotlin/hep/dataforge/control/client/TangoPayload.kt b/controls-magix-client/src/commonMain/kotlin/hep/dataforge/control/client/TangoPayload.kt deleted file mode 100644 index d545105..0000000 --- a/controls-magix-client/src/commonMain/kotlin/hep/dataforge/control/client/TangoPayload.kt +++ /dev/null @@ -1,24 +0,0 @@ -package space.kscience.dataforge.control.client - -public sealed class TangoPayload( - val host: String, - val device: String, - val name: String, - val timestamp: Long? = null, - val quality: String = "VALID", - val event: String? = null, -// val input: Any? = null, -// val output: Any? = null, -// val errors: Iterable?, -) - -public class TangoAttributePayload( - host: String, - device: String, - name: String, - val value: Any? = null, - timestamp: Long? = null, - quality: String = "VALID", - event: String? = null, - errors: Iterable?, -) : TangoPayload(host, device, name, timestamp, quality, event) \ No newline at end of file diff --git a/controls-magix-client/src/commonMain/kotlin/ru/mipt/npm/controls/client/TangoPayload.kt b/controls-magix-client/src/commonMain/kotlin/ru/mipt/npm/controls/client/TangoPayload.kt new file mode 100644 index 0000000..8bce776 --- /dev/null +++ b/controls-magix-client/src/commonMain/kotlin/ru/mipt/npm/controls/client/TangoPayload.kt @@ -0,0 +1,24 @@ +package space.kscience.dataforge.control.client + +//public sealed class TangoPayload( +// val host: String, +// val device: String, +// val name: String, +// val timestamp: Long? = null, +// val quality: String = "VALID", +// val event: String? = null, +//// val input: Any? = null, +//// val output: Any? = null, +//// val errors: Iterable?, +//) +// +//public class TangoAttributePayload( +// host: String, +// device: String, +// name: String, +// val value: Any? = null, +// timestamp: Long? = null, +// quality: String = "VALID", +// event: String? = null, +// errors: Iterable?, +//) : TangoPayload(host, device, name, timestamp, quality, event) \ No newline at end of file diff --git a/controls-magix-client/src/commonMain/kotlin/hep/dataforge/control/client/magixClient.kt b/controls-magix-client/src/commonMain/kotlin/ru/mipt/npm/controls/client/magixClient.kt similarity index 100% rename from controls-magix-client/src/commonMain/kotlin/hep/dataforge/control/client/magixClient.kt rename to controls-magix-client/src/commonMain/kotlin/ru/mipt/npm/controls/client/magixClient.kt diff --git a/controls-magix-server/build.gradle.kts b/controls-magix-server/build.gradle.kts new file mode 100644 index 0000000..c9963fc --- /dev/null +++ b/controls-magix-server/build.gradle.kts @@ -0,0 +1,21 @@ +plugins { + id("ru.mipt.npm.gradle.mpp") + `maven-publish` +} + +kscience{ + useSerialization { + json() + } +} + +kotlin { + sourceSets { + commonMain { + dependencies { + implementation(project(":magix:magix-server")) + implementation(project(":controls-core")) + } + } + } +} \ No newline at end of file diff --git a/controls-serial/src/main/kotlin/hep/dataforge/control/serial/SerialPort.kt b/controls-serial/src/main/kotlin/ru/mipt/npm/controls/serial/SerialPort.kt similarity index 100% rename from controls-serial/src/main/kotlin/hep/dataforge/control/serial/SerialPort.kt rename to controls-serial/src/main/kotlin/ru/mipt/npm/controls/serial/SerialPort.kt diff --git a/controls-server/src/main/kotlin/hep/dataforge/control/server/conversions.kt b/controls-server/src/main/kotlin/ru/mipt/npm/controls/server/conversions.kt similarity index 100% rename from controls-server/src/main/kotlin/hep/dataforge/control/server/conversions.kt rename to controls-server/src/main/kotlin/ru/mipt/npm/controls/server/conversions.kt diff --git a/controls-server/src/main/kotlin/hep/dataforge/control/server/deviceWebServer.kt b/controls-server/src/main/kotlin/ru/mipt/npm/controls/server/deviceWebServer.kt similarity index 100% rename from controls-server/src/main/kotlin/hep/dataforge/control/server/deviceWebServer.kt rename to controls-server/src/main/kotlin/ru/mipt/npm/controls/server/deviceWebServer.kt diff --git a/controls-tcp/src/jvmMain/kotlin/hep/dataforge/control/ports/KtorTcpPort.kt b/controls-tcp/src/jvmMain/kotlin/ru/mipt/npm/controls/ports/KtorTcpPort.kt similarity index 100% rename from controls-tcp/src/jvmMain/kotlin/hep/dataforge/control/ports/KtorTcpPort.kt rename to controls-tcp/src/jvmMain/kotlin/ru/mipt/npm/controls/ports/KtorTcpPort.kt diff --git a/demo/src/main/kotlin/hep/dataforge/control/demo/DemoControllerView.kt b/demo/src/main/kotlin/ru/mipt/npm/controls/demo/DemoControllerView.kt similarity index 98% rename from demo/src/main/kotlin/hep/dataforge/control/demo/DemoControllerView.kt rename to demo/src/main/kotlin/ru/mipt/npm/controls/demo/DemoControllerView.kt index e515d1a..1670610 100644 --- a/demo/src/main/kotlin/hep/dataforge/control/demo/DemoControllerView.kt +++ b/demo/src/main/kotlin/ru/mipt/npm/controls/demo/DemoControllerView.kt @@ -18,7 +18,7 @@ class DemoController : Controller(), ContextAware { var device: DemoDevice? = null var server: ApplicationEngine? = null - override val context = Global.context("demoDevice") + override val context = Global.buildContext("demoDevice") fun init() { context.launch { diff --git a/demo/src/main/kotlin/hep/dataforge/control/demo/DemoDevice.kt b/demo/src/main/kotlin/ru/mipt/npm/controls/demo/DemoDevice.kt similarity index 100% rename from demo/src/main/kotlin/hep/dataforge/control/demo/DemoDevice.kt rename to demo/src/main/kotlin/ru/mipt/npm/controls/demo/DemoDevice.kt diff --git a/demo/src/main/kotlin/hep/dataforge/control/demo/demoDeviceServer.kt b/demo/src/main/kotlin/ru/mipt/npm/controls/demo/demoDeviceServer.kt similarity index 100% rename from demo/src/main/kotlin/hep/dataforge/control/demo/demoDeviceServer.kt rename to demo/src/main/kotlin/ru/mipt/npm/controls/demo/demoDeviceServer.kt diff --git a/demo/src/main/kotlin/hep/dataforge/control/demo/generateMessageSchema.kt b/demo/src/main/kotlin/ru/mipt/npm/controls/demo/generateMessageSchema.kt similarity index 100% rename from demo/src/main/kotlin/hep/dataforge/control/demo/generateMessageSchema.kt rename to demo/src/main/kotlin/ru/mipt/npm/controls/demo/generateMessageSchema.kt diff --git a/docs/uml/device-properties.puml b/docs/uml/device-properties.puml new file mode 100644 index 0000000..2b3c5ae --- /dev/null +++ b/docs/uml/device-properties.puml @@ -0,0 +1,25 @@ +@startuml +participant Physical +participant Logical +participant Remote + +group Asynchronous update + Physical -> Logical: Notify changed + Logical -> Remote: Send event +end + +group Timed update + Logical -> Logical: Timed check + Logical -> Physical: Request value + Physical -> Logical: Respond + Logical --> Remote: Send event if changed +end + +group Request update + Remote -> Logical: Request value + Logical --> Physical: Request if needed + Physical --> Logical: Respond + Logical -> Remote: Force send event +end + +@enduml \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index da9702f..f371643 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/magix/magix-server/build.gradle.kts b/magix/magix-server/build.gradle.kts index 69e7947..e9ffdb3 100644 --- a/magix/magix-server/build.gradle.kts +++ b/magix/magix-server/build.gradle.kts @@ -12,7 +12,7 @@ kscience { val dataforgeVersion: String by rootProject.extra val rsocketVersion: String by rootProject.extra -val ktorVersion: String = "1.5.3" +val ktorVersion: String = ru.mipt.npm.gradle.KScienceVersions.ktorVersion dependencies{ api(project(":magix:magix-api")) diff --git a/motors/src/main/kotlin/ru/mipt/npm/devices/pimotionmaster/PiMotionMasterApp.kt b/motors/src/main/kotlin/ru/mipt/npm/devices/pimotionmaster/PiMotionMasterApp.kt index 463ad6a..8cce497 100644 --- a/motors/src/main/kotlin/ru/mipt/npm/devices/pimotionmaster/PiMotionMasterApp.kt +++ b/motors/src/main/kotlin/ru/mipt/npm/devices/pimotionmaster/PiMotionMasterApp.kt @@ -12,6 +12,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.launch import space.kscience.dataforge.context.Global +import space.kscience.dataforge.context.fetch import space.kscience.dataforge.control.controllers.DeviceManager import space.kscience.dataforge.control.controllers.installing import tornadofx.* @@ -20,10 +21,12 @@ class PiMotionMasterApp : App(PiMotionMasterView::class) class PiMotionMasterController : Controller() { //initialize context - val context = Global.context("piMotionMaster") + val context = Global.buildContext("piMotionMaster"){ + plugin(DeviceManager) + } //initialize deviceManager plugin - val deviceManager: DeviceManager = context.plugins.load(DeviceManager) + val deviceManager: DeviceManager = context.fetch(DeviceManager) // install device val motionMaster: PiMotionMasterDevice by deviceManager.installing(PiMotionMasterDevice) diff --git a/settings.gradle.kts b/settings.gradle.kts index f4d01b9..14e7573 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,6 +1,6 @@ pluginManagement { - val kotlinVersion = "1.4.32" - val toolsVersion = "0.9.3" + val kotlinVersion = "1.5.0-M2" + val toolsVersion = "0.9.5-dev" repositories { mavenLocal() @@ -35,6 +35,7 @@ include( ":magix:magix-service", ":magix:magix-java-client", ":controls-magix-client", + ":controls-magix-server", ":motors" )