You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by jf...@apache.org on 2022/10/24 10:52:26 UTC

[plc4x] branch rel/0.6 updated: Feature: Add connection option to connect with CPs (#558)

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

jfeinauer pushed a commit to branch rel/0.6
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/rel/0.6 by this push:
     new 898e22272 Feature: Add connection option to connect with CPs (#558)
898e22272 is described below

commit 898e222724ba72e4f157d1b5a09c865a51e3770f
Author: Julian <j....@pragmaticminds.de>
AuthorDate: Mon Oct 24 12:52:18 2022 +0200

    Feature: Add connection option to connect with CPs (#558)
---
 .../org/apache/plc4x/java/s7/connection/S7PlcConnection.java  | 11 ++++++++++-
 plc4j/examples/pom.xml                                        |  2 +-
 plc4j/pom.xml                                                 |  2 +-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/connection/S7PlcConnection.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/connection/S7PlcConnection.java
index 34ddfa01a..831c99730 100644
--- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/connection/S7PlcConnection.java
+++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/connection/S7PlcConnection.java
@@ -55,6 +55,7 @@ import org.slf4j.LoggerFactory;
 
 import java.net.InetAddress;
 import java.util.Collections;
+import java.util.Objects;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
@@ -95,6 +96,7 @@ public class S7PlcConnection extends NettyPlcConnection implements PlcReader, Pl
     private final short paramMaxAmqCaller;
     private final short paramMaxAmqCallee;
     private final S7ControllerType paramControllerType;
+    private DeviceGroup deviceGroup = DeviceGroup.OS;
 
     public S7PlcConnection(InetAddress address, int rack, int slot, String params) {
         this(new TcpSocketChannelFactory(address, ISO_ON_TCP_PORT), rack, slot, params);
@@ -134,6 +136,13 @@ public class S7PlcConnection extends NettyPlcConnection implements PlcReader, Pl
                         case "controller-type":
                             curParamControllerType = S7ControllerType.valueOf(paramValue);
                             break;
+                        case "device-group":
+                            if (Objects.equals(paramValue, "others")) {
+                                this.deviceGroup = DeviceGroup.OTHERS;
+                            } else {
+                                throw new RuntimeException("Only OTHERS as Device Group is allowed!");
+                            }
+                            break;
                         default:
                             logger.debug("Unknown parameter {} with value {}", paramName, paramValue);
                     }
@@ -170,7 +179,7 @@ public class S7PlcConnection extends NettyPlcConnection implements PlcReader, Pl
 
     @Override
     protected ChannelHandler getChannelHandler(CompletableFuture<Void> sessionSetupCompleteFuture) {
-        short calledTsapId = S7TsapIdEncoder.encodeS7TsapId(DeviceGroup.OS, rack, slot);
+        short calledTsapId = S7TsapIdEncoder.encodeS7TsapId(this.deviceGroup, rack, slot);
         short callingTsapId = S7TsapIdEncoder.encodeS7TsapId(DeviceGroup.PG_OR_PC, rack, slot);
 
         return new ChannelInitializer() {
diff --git a/plc4j/examples/pom.xml b/plc4j/examples/pom.xml
index 09b551c87..1f856d130 100644
--- a/plc4j/examples/pom.xml
+++ b/plc4j/examples/pom.xml
@@ -49,7 +49,7 @@
     <module>hello-storage-elasticsearch</module>
     <module>hello-webapp</module>
     <module>hello-world-plc4x</module>
-    <module>hello-integration-iotdb</module>
+<!--    <module>hello-integration-iotdb</module>-->
   </modules>
 
   <build>
diff --git a/plc4j/pom.xml b/plc4j/pom.xml
index bcda6f0cb..c4159c745 100644
--- a/plc4j/pom.xml
+++ b/plc4j/pom.xml
@@ -41,7 +41,7 @@
 
     <module>examples</module>
     <module>integrations</module>
-    <module>karaf-features</module>
+<!--    <module>karaf-features</module>-->
   </modules>
 
   <build>