From 3ef471d49ee348d17924ef6d0d901582df6f7ed3 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 26 Feb 2023 20:23:30 +0300 Subject: [PATCH] Move ZMQ to a separate module --- .../kscience/controls/opcua/server/DeviceNameSpace.kt | 3 +++ .../space/kscience/controls/demo/DemoControllerView.kt | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/controls-opcua/src/main/kotlin/space/kscience/controls/opcua/server/DeviceNameSpace.kt b/controls-opcua/src/main/kotlin/space/kscience/controls/opcua/server/DeviceNameSpace.kt index 84537ef..6b8e44c 100644 --- a/controls-opcua/src/main/kotlin/space/kscience/controls/opcua/server/DeviceNameSpace.kt +++ b/controls-opcua/src/main/kotlin/space/kscience/controls/opcua/server/DeviceNameSpace.kt @@ -208,5 +208,8 @@ public class DeviceNameSpace( } } +/** + * Serve devices from [deviceManager] as OPC-UA + */ public fun OpcUaServer.serveDevices(deviceManager: DeviceManager): DeviceNameSpace = DeviceNameSpace(this, deviceManager).apply { startup() } \ No newline at end of file diff --git a/demo/all-things/src/main/kotlin/space/kscience/controls/demo/DemoControllerView.kt b/demo/all-things/src/main/kotlin/space/kscience/controls/demo/DemoControllerView.kt index 4fe6798..802fc4d 100644 --- a/demo/all-things/src/main/kotlin/space/kscience/controls/demo/DemoControllerView.kt +++ b/demo/all-things/src/main/kotlin/space/kscience/controls/demo/DemoControllerView.kt @@ -51,13 +51,18 @@ class DemoController : Controller(), ContextAware { context.launch { device = deviceManager.install("demo", DemoDevice) //starting magix event loop - magixServer = startMagixServer(RSocketMagixFlowPlugin(), ZmqMagixFlowPlugin()) + magixServer = startMagixServer( + RSocketMagixFlowPlugin(), //TCP rsocket support + ZmqMagixFlowPlugin() //ZMQ support + ) //Launch device client and connect it to the server val deviceEndpoint = MagixEndpoint.rSocketWithTcp("localhost") deviceManager.connectToMagix(deviceEndpoint) + //connect visualization to a magix endpoint val visualEndpoint = MagixEndpoint.rSocketWithWebSockets("localhost") visualizer = visualEndpoint.startDemoDeviceServer() + //serve devices as OPC-UA namespace opcUaServer.startup() opcUaServer.serveDevices(deviceManager) }