You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2022/09/05 13:49:44 UTC

[plc4x] branch develop updated: fix(plc-simulator/cbus): when exstat is switch restart monitors

This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new d42ab0d49 fix(plc-simulator/cbus): when exstat is switch restart monitors
d42ab0d49 is described below

commit d42ab0d497f4fc903ff9f3170835897fce200147
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Mon Sep 5 15:49:38 2022 +0200

    fix(plc-simulator/cbus): when exstat is switch restart monitors
---
 .../src/main/resources/templates/go/plc4x_common.go.ftlh     |  2 +-
 .../simulator/server/cbus/protocol/CBusServerAdapter.java    | 12 ++++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/code-generation/language-go/src/main/resources/templates/go/plc4x_common.go.ftlh b/code-generation/language-go/src/main/resources/templates/go/plc4x_common.go.ftlh
index f844cffc2..bd3a49188 100644
--- a/code-generation/language-go/src/main/resources/templates/go/plc4x_common.go.ftlh
+++ b/code-generation/language-go/src/main/resources/templates/go/plc4x_common.go.ftlh
@@ -50,6 +50,6 @@ import "github.com/rs/zerolog/log"
 // Code generated by code-generation. DO NOT EDIT.
 
 // Plc4xModelLog is the Logger used by the Parse/Serialize methods
-var Plc4xModelLog = log.Logger
+var Plc4xModelLog = &log.Logger
 
 </#outputformat>
diff --git a/plc4j/utils/plc-simulator/src/main/java/org/apache/plc4x/simulator/server/cbus/protocol/CBusServerAdapter.java b/plc4j/utils/plc-simulator/src/main/java/org/apache/plc4x/simulator/server/cbus/protocol/CBusServerAdapter.java
index 8e35f3e7f..41aee45b2 100644
--- a/plc4j/utils/plc-simulator/src/main/java/org/apache/plc4x/simulator/server/cbus/protocol/CBusServerAdapter.java
+++ b/plc4j/utils/plc-simulator/src/main/java/org/apache/plc4x/simulator/server/cbus/protocol/CBusServerAdapter.java
@@ -191,7 +191,15 @@ public class CBusServerAdapter extends ChannelInboundHandlerAdapter {
                     return;
                 case INTERFACE_OPTIONS_3:
                     InterfaceOptions3 interfaceOptions3Value = ((ParameterValueInterfaceOptions3) calDataWrite.getParameterValue()).getValue();
+                    boolean oldExstat = exstat;
                     exstat = interfaceOptions3Value.getExstat();
+                    if (oldExstat != exstat) {
+                        LOGGER.info("Restarting monitors");
+                        stopMMIMonitor();
+                        startMMIMonitor(ctx);
+                        stopSALMonitor();
+                        startSALMonitor(ctx);
+                    }
                     pun = interfaceOptions3Value.getPun();
                     // TODO: add support for localsal
                     // localsal = interfaceOptions3Value.getLocalSal();
@@ -703,7 +711,7 @@ public class CBusServerAdapter extends ChannelInboundHandlerAdapter {
                 outputLock.lock();
                 CALReply calReply;
                 if (exstat) {
-                    // TODO: map actuall values from simulator
+                    // TODO: map actual values from simulator
                     List<StatusByte> statusBytes = new LinkedList<>();
                     for (int i = 0; i < 22; i++) {
                         statusBytes.add(new StatusByte(GAVState.ON, GAVState.ERROR, GAVState.OFF, GAVState.DOES_NOT_EXIST));
@@ -712,7 +720,7 @@ public class CBusServerAdapter extends ChannelInboundHandlerAdapter {
                     calReply = new CALReplyLong((byte) 0x86, calData, 0x00, new UnitAddress((byte) 0x04), null, new SerialInterfaceAddress((byte) 0x02), (byte) 0x00, null, cBusOptions, requestContext);
                 } else {
                     List<StatusByte> statusBytes = new LinkedList<>();
-                    // TODO: map actuall values from simulator
+                    // TODO: map actual values from simulator
                     for (int i = 0; i < 23; i++) {
                         statusBytes.add(new StatusByte(GAVState.ON, GAVState.ERROR, GAVState.OFF, GAVState.DOES_NOT_EXIST));
                     }