INNER CODE UNIT · Kotlin

writeHandler

vogler75/automation-gateway · source/lib-plc4x/src/main/kotlin/Plc4xDriver.kt:352

    override fun writeHandler(message: Message<JsonObject>) {
        val node = message.body().getValue("NodeId")
        when {
            plc?.metadata?.isWriteSupported == false -> {
                message.reply(JsonObject().put("Ok", false).put("Error", "Write not supported!"))
            }
            node != null && node is String -> {
                val value = message.body().getString("Value", "")
                writeValueAsync(node, value).onComplete {
                    message.reply(JsonObject().put("Ok", it.succeeded() && it.result()))
                }
            }
            node != null && node is JsonArray -> {
                logger.warning("Write of array not yet implemented!")
            }
            else -> {
                val err = String.format("Invalid format in write request!")
                message.reply(JsonObject().put("Ok", false))

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…