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

cdutz 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 44680103c4 feat: Extended the browse item with array-information.
44680103c4 is described below

commit 44680103c4970ff00dc9c377a0ea517caa68c5f8
Author: Christofer Dutz <cd...@apache.org>
AuthorDate: Fri Jul 12 17:30:07 2024 +0200

    feat: Extended the browse item with array-information.
---
 .../testing/protocols/eip/DriverTestsuite.xml      |  2 +-
 .../plc4x/java/api/messages/PlcBrowseItem.java     |  8 ++++
 .../plc4x/java/ads/protocol/AdsProtocolLogic.java  | 21 ++++++++---
 .../readwrite/connection/CtrlXConnection.java      |  2 +-
 .../spi/messages/DefaultListPlcBrowseItem.java     | 18 ++++++++-
 .../java/spi/messages/DefaultPlcBrowseItem.java    | 12 ++++++
 .../messages/DefaultPlcBrowseItemArrayInfo.java    | 44 ++++++++++++++++++++++
 7 files changed, 98 insertions(+), 9 deletions(-)

diff --git a/plc4go/assets/testing/protocols/eip/DriverTestsuite.xml 
b/plc4go/assets/testing/protocols/eip/DriverTestsuite.xml
index 4a41ee8f6f..b18faac99d 100644
--- a/plc4go/assets/testing/protocols/eip/DriverTestsuite.xml
+++ b/plc4go/assets/testing/protocols/eip/DriverTestsuite.xml
@@ -28,7 +28,7 @@
   <driver-name>eip</driver-name>
   <driver-parameters>
     <parameter>
-      <name>bigEndian</name>
+      <name>big-endian</name>
       <value>false</value>
     </parameter>
   </driver-parameters>
diff --git 
a/plc4j/api/src/main/java/org/apache/plc4x/java/api/messages/PlcBrowseItem.java 
b/plc4j/api/src/main/java/org/apache/plc4x/java/api/messages/PlcBrowseItem.java
index 292ad8da01..3ac7d09c93 100644
--- 
a/plc4j/api/src/main/java/org/apache/plc4x/java/api/messages/PlcBrowseItem.java
+++ 
b/plc4j/api/src/main/java/org/apache/plc4x/java/api/messages/PlcBrowseItem.java
@@ -21,6 +21,7 @@ package org.apache.plc4x.java.api.messages;
 import org.apache.plc4x.java.api.model.PlcTag;
 import org.apache.plc4x.java.api.value.PlcValue;
 
+import java.util.List;
 import java.util.Map;
 
 public interface PlcBrowseItem {
@@ -50,6 +51,13 @@ public interface PlcBrowseItem {
      */
     boolean isSubscribable();
 
+    boolean isArray();
+
+    /**
+     * @return list of elements providing information about the array 
dimensions of this item.
+     */
+    List<PlcBrowseItemArrayInfo> getArrayInformation();
+
     /**
      * @return returns any children this item might have
      */
diff --git 
a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java
 
b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java
index dc952e7c72..7e70c78a2f 100644
--- 
a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java
+++ 
b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java
@@ -505,13 +505,16 @@ public class AdsProtocolLogic extends 
Plc4xProtocolBase<AmsTCPPacket> implements
                 options.put("size-in-bytes", new PlcUDINT(symbol.getSize()));
 
                 if (plc4xPlcValueType == 
org.apache.plc4x.java.api.types.PlcValueType.List) {
-                    List<ArrayInfo> arrayInfo = new ArrayList<>();
+                    List<ArrayInfo> arrayInfo = new 
ArrayList<>(dataType.getArrayInfo().size());
+                    List<PlcBrowseItemArrayInfo> itemArrayInfo = new 
ArrayList<>(dataType.getArrayInfo().size());
                     for (AdsDataTypeArrayInfo adsDataTypeArrayInfo : 
dataType.getArrayInfo()) {
                         arrayInfo.add(new DefaultArrayInfo(
                             (int) adsDataTypeArrayInfo.getLowerBound(), (int) 
adsDataTypeArrayInfo.getUpperBound()));
+                        itemArrayInfo.add(new DefaultPlcBrowseItemArrayInfo(
+                            adsDataTypeArrayInfo.getLowerBound(), 
adsDataTypeArrayInfo.getUpperBound()));
                     }
                     DefaultListPlcBrowseItem item = new 
DefaultListPlcBrowseItem(new SymbolicAdsTag(symbol.getName(), 
plc4xPlcValueType, arrayInfo), itemName,
-                        true, !symbol.getFlagReadOnly(), true, childMap, 
options);
+                        true, !symbol.getFlagReadOnly(), true, childMap, 
options, itemArrayInfo);
 
                     // Check if this item should be added to the result
                     if (interceptor.intercept(item)) {
@@ -571,17 +574,23 @@ public class AdsProtocolLogic extends 
Plc4xProtocolBase<AmsTCPPacket> implements
             options.put("size-in-bytes", new 
PlcUDINT(childDataType.getSize()));
 
             if (plc4xPlcValueType == 
org.apache.plc4x.java.api.types.PlcValueType.List) {
-                List<ArrayInfo> arrayInfo = new ArrayList<>();
+                List<ArrayInfo> arrayInfo = new 
ArrayList<>(childDataType.getArrayInfo().size());
+                List<PlcBrowseItemArrayInfo> itemArrayInfo = new 
ArrayList<>(childDataType.getArrayInfo().size());
                 for (AdsDataTypeArrayInfo adsDataTypeArrayInfo : 
childDataType.getArrayInfo()) {
                     arrayInfo.add(new DefaultArrayInfo(
                         (int) adsDataTypeArrayInfo.getLowerBound(), (int) 
adsDataTypeArrayInfo.getUpperBound()));
+                    itemArrayInfo.add(new DefaultPlcBrowseItemArrayInfo(
+                        adsDataTypeArrayInfo.getLowerBound(), 
adsDataTypeArrayInfo.getUpperBound()));
                 }
                 // Add the type itself.
-                values.add(new DefaultListPlcBrowseItem(new 
SymbolicAdsTag(basePath + "." + child.getPropertyName(), plc4xPlcValueType, 
arrayInfo), itemName,
-                    true, parentWritable, true, childMap, options));
+                values.add(new DefaultListPlcBrowseItem(new SymbolicAdsTag(
+                    basePath + "." + child.getPropertyName(), 
plc4xPlcValueType, arrayInfo), itemName,
+                    true, parentWritable, true, childMap, options, 
itemArrayInfo));
             } else {
                 // Add the type itself.
-                values.add(new DefaultPlcBrowseItem(new 
SymbolicAdsTag(basePath + "." + child.getPropertyName(), plc4xPlcValueType, 
Collections.emptyList()), itemName,
+                values.add(new DefaultPlcBrowseItem(new SymbolicAdsTag(
+                    basePath + "." + child.getPropertyName(), 
plc4xPlcValueType,
+                    Collections.emptyList()), itemName,
                     true, parentWritable, true, childMap, options));
             }
         }
diff --git 
a/plc4j/drivers/ctrlx/src/main/java/org/apache/plc4x/java/ctrlx/readwrite/connection/CtrlXConnection.java
 
b/plc4j/drivers/ctrlx/src/main/java/org/apache/plc4x/java/ctrlx/readwrite/connection/CtrlXConnection.java
index 44324ab09b..867e5dd345 100644
--- 
a/plc4j/drivers/ctrlx/src/main/java/org/apache/plc4x/java/ctrlx/readwrite/connection/CtrlXConnection.java
+++ 
b/plc4j/drivers/ctrlx/src/main/java/org/apache/plc4x/java/ctrlx/readwrite/connection/CtrlXConnection.java
@@ -261,7 +261,7 @@ public class CtrlXConnection implements PlcConnection, 
PlcPinger, PlcBrowser {
                                 new DefaultListPlcBrowseItem(
                                     new CtrlXTag(curNode, PlcValueType.BOOL, 
Collections.emptyList()),
                                     curNode, true, true, true,
-                                    Collections.emptyMap(), 
Collections.emptyMap())));
+                                    Collections.emptyMap(), 
Collections.emptyMap(), Collections.emptyList())));
                         }
                     }
                     // If this node has children, then it's branch, and we 
need to add its children to the queue.
diff --git 
a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultListPlcBrowseItem.java
 
b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultListPlcBrowseItem.java
index 8d8c3a3bd9..aafb664975 100644
--- 
a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultListPlcBrowseItem.java
+++ 
b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultListPlcBrowseItem.java
@@ -19,6 +19,7 @@
 package org.apache.plc4x.java.spi.messages;
 
 import org.apache.plc4x.java.api.messages.PlcBrowseItem;
+import org.apache.plc4x.java.api.messages.PlcBrowseItemArrayInfo;
 import org.apache.plc4x.java.api.model.PlcTag;
 import org.apache.plc4x.java.api.value.PlcValue;
 import org.apache.plc4x.java.spi.codegen.WithOption;
@@ -26,18 +27,33 @@ import 
org.apache.plc4x.java.spi.generation.SerializationException;
 import org.apache.plc4x.java.spi.generation.WriteBuffer;
 
 import java.nio.charset.StandardCharsets;
+import java.util.List;
 import java.util.Map;
 
 public class DefaultListPlcBrowseItem extends DefaultPlcBrowseItem {
 
+    private final List<PlcBrowseItemArrayInfo> arrayInformation;
+
     public DefaultListPlcBrowseItem(PlcTag tag,
                                     String name,
                                     boolean readable,
                                     boolean writable,
                                     boolean subscribable,
                                     Map<String, PlcBrowseItem> children,
-                                    Map<String, PlcValue> options) {
+                                    Map<String, PlcValue> options,
+                                    List<PlcBrowseItemArrayInfo> 
arrayInformation) {
         super(tag, name, readable, writable, subscribable, children, options);
+        this.arrayInformation = arrayInformation;
+    }
+
+    @Override
+    public boolean isArray() {
+        return (arrayInformation != null) && !arrayInformation.isEmpty();
+    }
+
+    @Override
+    public List<PlcBrowseItemArrayInfo> getArrayInformation() {
+        return arrayInformation;
     }
 
     @Override
diff --git 
a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcBrowseItem.java
 
b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcBrowseItem.java
index 3c98140f8a..460b27de81 100644
--- 
a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcBrowseItem.java
+++ 
b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcBrowseItem.java
@@ -19,6 +19,7 @@
 package org.apache.plc4x.java.spi.messages;
 
 import org.apache.plc4x.java.api.messages.PlcBrowseItem;
+import org.apache.plc4x.java.api.messages.PlcBrowseItemArrayInfo;
 import org.apache.plc4x.java.api.model.PlcTag;
 import org.apache.plc4x.java.api.value.PlcValue;
 import org.apache.plc4x.java.spi.codegen.WithOption;
@@ -27,6 +28,8 @@ import org.apache.plc4x.java.spi.generation.WriteBuffer;
 import org.apache.plc4x.java.spi.utils.Serializable;
 
 import java.nio.charset.StandardCharsets;
+import java.util.Collections;
+import java.util.List;
 import java.util.Map;
 
 public class DefaultPlcBrowseItem implements PlcBrowseItem, Serializable {
@@ -81,6 +84,15 @@ public class DefaultPlcBrowseItem implements PlcBrowseItem, 
Serializable {
         return subscribable;
     }
 
+    @Override
+    public boolean isArray() {
+        return false;
+    }
+
+    public List<PlcBrowseItemArrayInfo> getArrayInformation() {
+        return Collections.emptyList();
+    }
+
     @Override
     public Map<String, PlcBrowseItem> getChildren() {
         return children;
diff --git 
a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcBrowseItemArrayInfo.java
 
b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcBrowseItemArrayInfo.java
new file mode 100644
index 0000000000..5be3aae609
--- /dev/null
+++ 
b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcBrowseItemArrayInfo.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.plc4x.java.spi.messages;
+
+import org.apache.plc4x.java.api.messages.PlcBrowseItemArrayInfo;
+
+public class DefaultPlcBrowseItemArrayInfo implements PlcBrowseItemArrayInfo {
+
+    private final long lowerBound;
+    private final long upperBound;
+
+    public DefaultPlcBrowseItemArrayInfo(long lowerBound, long upperBound) {
+        this.lowerBound = lowerBound;
+        this.upperBound = upperBound;
+    }
+
+    @Override
+    public long getLowerBound() {
+        return lowerBound;
+    }
+
+    @Override
+    public long getUpperBound() {
+        return upperBound;
+    }
+
+}

Reply via email to