From bfeeed00d56b9727b9b550f6e3502c414a3d2dc4 Mon Sep 17 00:00:00 2001 From: darksnake Date: Mon, 5 Jun 2023 17:12:01 +0300 Subject: [PATCH] process images cleanup --- .../kotlin/space/kscience/controls/ports/ChannelPort.kt | 2 ++ .../space/kscience/controls/modbus/DeviceProcessImage.kt | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/controls-core/src/jvmMain/kotlin/space/kscience/controls/ports/ChannelPort.kt b/controls-core/src/jvmMain/kotlin/space/kscience/controls/ports/ChannelPort.kt index 04d1eb9..d7983f2 100644 --- a/controls-core/src/jvmMain/kotlin/space/kscience/controls/ports/ChannelPort.kt +++ b/controls-core/src/jvmMain/kotlin/space/kscience/controls/ports/ChannelPort.kt @@ -3,6 +3,7 @@ package space.kscience.controls.ports import kotlinx.coroutines.* import space.kscience.dataforge.context.Context import space.kscience.dataforge.context.error +import space.kscience.dataforge.context.info import space.kscience.dataforge.context.logger import space.kscience.dataforge.meta.* import java.net.InetSocketAddress @@ -118,6 +119,7 @@ public object UdpPort : PortFactory { localPort?.let { bind(InetSocketAddress(localHost, localPort)) } //connect to remote port to send messages connect(InetSocketAddress(remoteHost, remotePort)) + context.logger.info { "Connected to UDP $remotePort on $remoteHost" } } } diff --git a/controls-modbus/src/main/kotlin/space/kscience/controls/modbus/DeviceProcessImage.kt b/controls-modbus/src/main/kotlin/space/kscience/controls/modbus/DeviceProcessImage.kt index 581d228..47acb4a 100644 --- a/controls-modbus/src/main/kotlin/space/kscience/controls/modbus/DeviceProcessImage.kt +++ b/controls-modbus/src/main/kotlin/space/kscience/controls/modbus/DeviceProcessImage.kt @@ -45,7 +45,7 @@ public class DeviceToModbusMapping private constructor( } } -public fun DeviceToModbusMapping(block: DeviceToModbusMapping.Builder.()->Unit): DeviceToModbusMapping = +public inline fun DeviceToModbusMapping(block: DeviceToModbusMapping.Builder.()->Unit): DeviceToModbusMapping = DeviceToModbusMapping.Builder().apply(block).build() @Suppress("UNCHECKED_CAST") @@ -142,4 +142,7 @@ public fun D.toProcessImage(mapping: DeviceToModbusMapping): Pro } } return image -} \ No newline at end of file +} + +public inline fun D.toProcessImage(block: DeviceToModbusMapping.Builder.()->Unit): ProcessImage = + toProcessImage(DeviceToModbusMapping(block)) \ No newline at end of file