This is an automated email from the ASF dual-hosted git repository. cdutz pushed a commit to branch fix/opc-ua-fine-tuning in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit 735def28a1925888b2fe9181e37a8f3965361956 Author: Christofer Dutz <[email protected]> AuthorDate: Fri Feb 13 14:12:33 2026 +0100 chore: Added a comprehensive test against my S7-1500 devices and started fine-tuning the code to work with more and more of the test-cases. --- .../apache/plc4x/java/opcua/readwrite/Variant.java | 16 +- .../plc4x/java/opcua/readwrite/VariantBoolean.java | 4 +- .../plc4x/java/opcua/readwrite/VariantByte.java | 4 +- .../java/opcua/readwrite/VariantByteString.java | 4 +- .../java/opcua/readwrite/VariantDataValue.java | 4 +- .../java/opcua/readwrite/VariantDateTime.java | 4 +- .../opcua/readwrite/VariantDiagnosticInfo.java | 4 +- .../plc4x/java/opcua/readwrite/VariantDouble.java | 4 +- .../opcua/readwrite/VariantExpandedNodeId.java | 4 +- .../opcua/readwrite/VariantExtensionObject.java | 4 +- .../plc4x/java/opcua/readwrite/VariantFloat.java | 4 +- .../plc4x/java/opcua/readwrite/VariantGuid.java | 4 +- .../plc4x/java/opcua/readwrite/VariantInt16.java | 4 +- .../plc4x/java/opcua/readwrite/VariantInt32.java | 4 +- .../plc4x/java/opcua/readwrite/VariantInt64.java | 4 +- .../java/opcua/readwrite/VariantLocalizedText.java | 4 +- .../plc4x/java/opcua/readwrite/VariantNodeId.java | 4 +- .../plc4x/java/opcua/readwrite/VariantNull.java | 4 +- .../java/opcua/readwrite/VariantQualifiedName.java | 4 +- .../plc4x/java/opcua/readwrite/VariantSByte.java | 4 +- .../java/opcua/readwrite/VariantStatusCode.java | 4 +- .../plc4x/java/opcua/readwrite/VariantString.java | 4 +- .../plc4x/java/opcua/readwrite/VariantUInt16.java | 4 +- .../plc4x/java/opcua/readwrite/VariantUInt32.java | 4 +- .../plc4x/java/opcua/readwrite/VariantUInt64.java | 4 +- .../plc4x/java/opcua/readwrite/VariantVariant.java | 4 +- .../java/opcua/readwrite/VariantXmlElement.java | 4 +- .../plc4x/java/opcua/context/Conversation.java | 8 +- .../java/opcua/protocol/OpcuaProtocolLogic.java | 173 +++++++++++++++------ .../java/opcua/ManualS71500NewFWDriverTest.java | 139 +++++++++++++++++ .../generated/protocols/opcua/opc-manual.mspec | 2 +- protocols/opcua/src/main/xslt/opc-manual.xsl | 2 +- 32 files changed, 334 insertions(+), 110 deletions(-) diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/Variant.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/Variant.java index 14397b3060..58e4669943 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/Variant.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/Variant.java @@ -44,13 +44,13 @@ public abstract class Variant implements Message { protected final boolean arrayLengthSpecified; protected final boolean arrayDimensionsSpecified; protected final Integer noOfArrayDimensions; - protected final List<Boolean> arrayDimensions; + protected final List<Integer> arrayDimensions; public Variant( boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { super(); this.arrayLengthSpecified = arrayLengthSpecified; this.arrayDimensionsSpecified = arrayDimensionsSpecified; @@ -70,7 +70,7 @@ public abstract class Variant implements Message { return noOfArrayDimensions; } - public List<Boolean> getArrayDimensions() { + public List<Integer> getArrayDimensions() { return arrayDimensions; } @@ -99,7 +99,7 @@ public abstract class Variant implements Message { writeOptionalField("noOfArrayDimensions", noOfArrayDimensions, writeSignedInt(writeBuffer, 32)); // Array Field (arrayDimensions) - writeSimpleTypeArrayField("arrayDimensions", arrayDimensions, writeBoolean(writeBuffer)); + writeSimpleTypeArrayField("arrayDimensions", arrayDimensions, writeSignedInt(writeBuffer, 32)); writeBuffer.popContext("Variant"); } @@ -133,7 +133,7 @@ public abstract class Variant implements Message { // Array field if (arrayDimensions != null) { - lengthInBits += 1 * arrayDimensions.size(); + lengthInBits += 32 * arrayDimensions.size(); } return lengthInBits; @@ -222,10 +222,10 @@ public abstract class Variant implements Message { readOptionalField( "noOfArrayDimensions", readSignedInt(readBuffer, 32), arrayDimensionsSpecified); - List<Boolean> arrayDimensions = + List<Integer> arrayDimensions = readCountArrayField( "arrayDimensions", - readBoolean(readBuffer), + readSignedInt(readBuffer, 32), (((noOfArrayDimensions) == (null)) ? 0 : noOfArrayDimensions)); readBuffer.closeContext("Variant"); @@ -241,7 +241,7 @@ public abstract class Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions); + List<Integer> arrayDimensions); } @Override diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantBoolean.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantBoolean.java index 452894bc4d..a89d643968 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantBoolean.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantBoolean.java @@ -50,7 +50,7 @@ public class VariantBoolean extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, byte[] value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -136,7 +136,7 @@ public class VariantBoolean extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantBoolean variantBoolean = new VariantBoolean( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantByte.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantByte.java index d4bb68dfe9..0d488d2aa3 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantByte.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantByte.java @@ -50,7 +50,7 @@ public class VariantByte extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<Short> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -138,7 +138,7 @@ public class VariantByte extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantByte variantByte = new VariantByte( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantByteString.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantByteString.java index 7c5478e068..f9b2af6a1b 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantByteString.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantByteString.java @@ -50,7 +50,7 @@ public class VariantByteString extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<ByteStringArray> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -142,7 +142,7 @@ public class VariantByteString extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantByteString variantByteString = new VariantByteString( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantDataValue.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantDataValue.java index 424128db2a..7ee036082a 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantDataValue.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantDataValue.java @@ -50,7 +50,7 @@ public class VariantDataValue extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<DataValue> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -142,7 +142,7 @@ public class VariantDataValue extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantDataValue variantDataValue = new VariantDataValue( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantDateTime.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantDateTime.java index 68feac1370..603b8da10f 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantDateTime.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantDateTime.java @@ -50,7 +50,7 @@ public class VariantDateTime extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<Long> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -136,7 +136,7 @@ public class VariantDateTime extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantDateTime variantDateTime = new VariantDateTime( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantDiagnosticInfo.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantDiagnosticInfo.java index 3d4cc55c09..eeebd81b3b 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantDiagnosticInfo.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantDiagnosticInfo.java @@ -50,7 +50,7 @@ public class VariantDiagnosticInfo extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<DiagnosticInfo> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -142,7 +142,7 @@ public class VariantDiagnosticInfo extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantDiagnosticInfo variantDiagnosticInfo = new VariantDiagnosticInfo( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantDouble.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantDouble.java index 6c7f9f33a2..1acb34c938 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantDouble.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantDouble.java @@ -50,7 +50,7 @@ public class VariantDouble extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<Double> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -136,7 +136,7 @@ public class VariantDouble extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantDouble variantDouble = new VariantDouble( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantExpandedNodeId.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantExpandedNodeId.java index 5b4db90d26..0ac9caaa76 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantExpandedNodeId.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantExpandedNodeId.java @@ -50,7 +50,7 @@ public class VariantExpandedNodeId extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<ExpandedNodeId> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -142,7 +142,7 @@ public class VariantExpandedNodeId extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantExpandedNodeId variantExpandedNodeId = new VariantExpandedNodeId( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantExtensionObject.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantExtensionObject.java index b30622ff80..b914e79d5b 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantExtensionObject.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantExtensionObject.java @@ -50,7 +50,7 @@ public class VariantExtensionObject extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<ExtensionObject> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -143,7 +143,7 @@ public class VariantExtensionObject extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantExtensionObject variantExtensionObject = new VariantExtensionObject( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantFloat.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantFloat.java index 186aaed2a0..4f8b1b7694 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantFloat.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantFloat.java @@ -50,7 +50,7 @@ public class VariantFloat extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<Float> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -136,7 +136,7 @@ public class VariantFloat extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantFloat variantFloat = new VariantFloat( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantGuid.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantGuid.java index fc85b24505..7011f02a82 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantGuid.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantGuid.java @@ -50,7 +50,7 @@ public class VariantGuid extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<GuidValue> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -142,7 +142,7 @@ public class VariantGuid extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantGuid variantGuid = new VariantGuid( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantInt16.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantInt16.java index ce6f2cd30c..8950ea2277 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantInt16.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantInt16.java @@ -50,7 +50,7 @@ public class VariantInt16 extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<Short> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -138,7 +138,7 @@ public class VariantInt16 extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantInt16 variantInt16 = new VariantInt16( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantInt32.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantInt32.java index 8cc8a9051f..ace173c9fc 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantInt32.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantInt32.java @@ -50,7 +50,7 @@ public class VariantInt32 extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<Integer> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -136,7 +136,7 @@ public class VariantInt32 extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantInt32 variantInt32 = new VariantInt32( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantInt64.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantInt64.java index f5bf1d9025..b11d03c2f7 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantInt64.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantInt64.java @@ -50,7 +50,7 @@ public class VariantInt64 extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<Long> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -136,7 +136,7 @@ public class VariantInt64 extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantInt64 variantInt64 = new VariantInt64( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantLocalizedText.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantLocalizedText.java index e7ac52373f..7a3706b867 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantLocalizedText.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantLocalizedText.java @@ -50,7 +50,7 @@ public class VariantLocalizedText extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<LocalizedText> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -142,7 +142,7 @@ public class VariantLocalizedText extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantLocalizedText variantLocalizedText = new VariantLocalizedText( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantNodeId.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantNodeId.java index 215174c888..e91da66e74 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantNodeId.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantNodeId.java @@ -50,7 +50,7 @@ public class VariantNodeId extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<NodeId> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -142,7 +142,7 @@ public class VariantNodeId extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantNodeId variantNodeId = new VariantNodeId( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantNull.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantNull.java index cfc5715b59..d6d77484a8 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantNull.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantNull.java @@ -46,7 +46,7 @@ public class VariantNull extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); } @@ -92,7 +92,7 @@ public class VariantNull extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantNull variantNull = new VariantNull( arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantQualifiedName.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantQualifiedName.java index 550e91622e..9ff7e799b7 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantQualifiedName.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantQualifiedName.java @@ -50,7 +50,7 @@ public class VariantQualifiedName extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<QualifiedName> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -142,7 +142,7 @@ public class VariantQualifiedName extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantQualifiedName variantQualifiedName = new VariantQualifiedName( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantSByte.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantSByte.java index 9a5cdb3fa6..921899ecd3 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantSByte.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantSByte.java @@ -50,7 +50,7 @@ public class VariantSByte extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, byte[] value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -136,7 +136,7 @@ public class VariantSByte extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantSByte variantSByte = new VariantSByte( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantStatusCode.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantStatusCode.java index 55ae3cca88..538849d02e 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantStatusCode.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantStatusCode.java @@ -50,7 +50,7 @@ public class VariantStatusCode extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<StatusCode> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -142,7 +142,7 @@ public class VariantStatusCode extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantStatusCode variantStatusCode = new VariantStatusCode( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantString.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantString.java index 31cc206039..5a52922e82 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantString.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantString.java @@ -50,7 +50,7 @@ public class VariantString extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<PascalString> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -142,7 +142,7 @@ public class VariantString extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantString variantString = new VariantString( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantUInt16.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantUInt16.java index 04bbc933d7..93428581f4 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantUInt16.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantUInt16.java @@ -50,7 +50,7 @@ public class VariantUInt16 extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<Integer> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -138,7 +138,7 @@ public class VariantUInt16 extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantUInt16 variantUInt16 = new VariantUInt16( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantUInt32.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantUInt32.java index c42a0c7acc..4fd3a59060 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantUInt32.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantUInt32.java @@ -50,7 +50,7 @@ public class VariantUInt32 extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<Long> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -138,7 +138,7 @@ public class VariantUInt32 extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantUInt32 variantUInt32 = new VariantUInt32( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantUInt64.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantUInt64.java index 054473830c..29e5b7c1d1 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantUInt64.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantUInt64.java @@ -51,7 +51,7 @@ public class VariantUInt64 extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<BigInteger> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -139,7 +139,7 @@ public class VariantUInt64 extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantUInt64 variantUInt64 = new VariantUInt64( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantVariant.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantVariant.java index dd10e407d9..f5f552ca24 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantVariant.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantVariant.java @@ -50,7 +50,7 @@ public class VariantVariant extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<Variant> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -142,7 +142,7 @@ public class VariantVariant extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantVariant variantVariant = new VariantVariant( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantXmlElement.java b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantXmlElement.java index 4da3834ac9..7b93a5d04c 100644 --- a/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantXmlElement.java +++ b/plc4j/drivers/opcua/src/main/generated/org/apache/plc4x/java/opcua/readwrite/VariantXmlElement.java @@ -50,7 +50,7 @@ public class VariantXmlElement extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions, + List<Integer> arrayDimensions, Integer arrayLength, List<PascalString> value) { super(arrayLengthSpecified, arrayDimensionsSpecified, noOfArrayDimensions, arrayDimensions); @@ -142,7 +142,7 @@ public class VariantXmlElement extends Variant implements Message { boolean arrayLengthSpecified, boolean arrayDimensionsSpecified, Integer noOfArrayDimensions, - List<Boolean> arrayDimensions) { + List<Integer> arrayDimensions) { VariantXmlElement variantXmlElement = new VariantXmlElement( arrayLengthSpecified, diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/Conversation.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/Conversation.java index c2ef7978ea..a9c9c2b176 100644 --- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/Conversation.java +++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/Conversation.java @@ -337,7 +337,13 @@ public class Conversation { if (extensionObjectBody instanceof ServiceFault) { ServiceFault fault = (ServiceFault) extensionObjectBody; - future.completeExceptionally(toProtocolException(fault)); + // If we write the same data a tag already had, Siemens devices return an error. + if (fault.getResponseHeader().getServiceResult().getStatusCode() == OpcuaStatusCode.BadNothingToDo.getValue()) { + // TODO: Here we need to fake a WriteResponse. + future.complete(extensionObjectBody); + } else { + future.completeExceptionally(toProtocolException(fault)); + } } else { future.complete(extensionObjectBody); } diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java index 41d8c94cd7..887c5497ca 100644 --- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java +++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java @@ -50,7 +50,6 @@ import org.apache.plc4x.java.spi.Plc4xProtocolBase; import org.apache.plc4x.java.spi.configuration.HasConfiguration; import org.apache.plc4x.java.spi.connection.PlcTagHandler; import org.apache.plc4x.java.spi.context.DriverContext; -import org.apache.plc4x.java.spi.generation.Message; import org.apache.plc4x.java.spi.messages.*; import org.apache.plc4x.java.spi.messages.utils.DefaultPlcResponseItem; import org.apache.plc4x.java.spi.messages.utils.PlcResponseItem; @@ -59,9 +58,7 @@ import org.apache.plc4x.java.spi.model.DefaultPlcConsumerRegistration; import org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionTag; import org.apache.plc4x.java.spi.transaction.RequestTransactionManager; import org.apache.plc4x.java.spi.transaction.RequestTransactionManager.RequestTransaction; -import org.apache.plc4x.java.spi.values.LegacyPlcValueHandler; -import org.apache.plc4x.java.spi.values.PlcList; -import org.apache.plc4x.java.spi.values.PlcSTRING; +import org.apache.plc4x.java.spi.values.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -314,65 +311,147 @@ public class OpcuaProtocolLogic extends Plc4xProtocolBase<OpcuaAPU> implements H PlcValue value = null; if (variant instanceof VariantBoolean) { byte[] array = ((VariantBoolean) variant).getValue(); - int length = array.length; - Boolean[] tmpValue = new Boolean[length]; - for (int i = 0; i < length; i++) { - tmpValue[i] = array[i] != 0; + if (array.length == 1) { + value = new PlcBOOL(array[0] != 0); + } else { + List<PlcValue> values = new ArrayList<>(array.length); + for (byte b : array) { + values.add(new PlcBOOL(b != 0)); + } + value = new PlcList(values); } - value = LegacyPlcValueHandler.of(tmpValue); } else if (variant instanceof VariantSByte) { byte[] array = ((VariantSByte) variant).getValue(); - value = LegacyPlcValueHandler.of(tag, array); + if (array.length == 1) { + value = new PlcSINT(array[0]); + } else { + List<PlcValue> values = new ArrayList<>(array.length); + for (byte b : array) { + values.add(new PlcSINT(b)); + } + value = new PlcList(values); + } } else if (variant instanceof VariantByte) { List<Short> array = ((VariantByte) variant).getValue(); - Short[] tmpValue = array.toArray(new Short[0]); - value = LegacyPlcValueHandler.of(tmpValue); + if (array.size() == 1) { + value = new PlcUSINT(array.getFirst()); + } else { + List<PlcValue> values = new ArrayList<>(array.size()); + for (Short s : array) { + values.add(new PlcUSINT(s)); + } + value = new PlcList(values); + } } else if (variant instanceof VariantInt16) { List<Short> array = ((VariantInt16) variant).getValue(); - Short[] tmpValue = array.toArray(new Short[0]); - value = LegacyPlcValueHandler.of(tmpValue); + if (array.size() == 1) { + value = new PlcINT(array.getFirst()); + } else { + List<PlcValue> values = new ArrayList<>(array.size()); + for (Short s : array) { + values.add(new PlcINT(s)); + } + value = new PlcList(values); + } } else if (variant instanceof VariantUInt16) { List<Integer> array = ((VariantUInt16) variant).getValue(); - Integer[] tmpValue = array.toArray(new Integer[0]); - value = LegacyPlcValueHandler.of(tmpValue); + if (array.size() == 1) { + value = new PlcUINT(array.getFirst()); + } else { + List<PlcValue> values = new ArrayList<>(array.size()); + for (Integer i : array) { + values.add(new PlcUINT(i)); + } + value = new PlcList(values); + } } else if (variant instanceof VariantInt32) { List<Integer> array = ((VariantInt32) variant).getValue(); - Integer[] tmpValue = array.toArray(new Integer[0]); - value = LegacyPlcValueHandler.of(tmpValue); + if (array.size() == 1) { + value = new PlcDINT(array.getFirst()); + } else { + List<PlcValue> values = new ArrayList<>(array.size()); + for (Integer i : array) { + values.add(new PlcDINT(i)); + } + value = new PlcList(values); + } } else if (variant instanceof VariantUInt32) { List<Long> array = ((VariantUInt32) variant).getValue(); - Long[] tmpValue = array.toArray(new Long[0]); - value = LegacyPlcValueHandler.of(tmpValue); + if (array.size() == 1) { + value = new PlcUDINT(array.getFirst()); + } else { + List<PlcValue> values = new ArrayList<>(array.size()); + for (Long l : array) { + values.add(new PlcUDINT(l)); + } + value = new PlcList(values); + } } else if (variant instanceof VariantInt64) { List<Long> array = ((VariantInt64) variant).getValue(); - Long[] tmpValue = array.toArray(new Long[0]); - value = LegacyPlcValueHandler.of(tmpValue); + if (array.size() == 1) { + value = new PlcLINT(array.getFirst()); + } else { + List<PlcValue> values = new ArrayList<>(array.size()); + for (Long l : array) { + values.add(new PlcLINT(l)); + } + value = new PlcList(values); + } } else if (variant instanceof VariantUInt64) { - value = LegacyPlcValueHandler.of(((VariantUInt64) variant).getValue()); + List<BigInteger> array = ((VariantUInt64) variant).getValue(); + if (array.size() == 1) { + value = new PlcULINT(array.getFirst()); + } else { + List<PlcValue> values = new ArrayList<>(array.size()); + for (BigInteger bi : array) { + values.add(new PlcULINT(bi)); + } + value = new PlcList(values); + } } else if (variant instanceof VariantFloat) { List<Float> array = ((VariantFloat) variant).getValue(); - Float[] tmpValue = array.toArray(new Float[0]); - value = LegacyPlcValueHandler.of(tmpValue); + if (array.size() == 1) { + value = new PlcREAL(array.getFirst()); + } else { + List<PlcValue> values = new ArrayList<>(array.size()); + for (Float f : array) { + values.add(new PlcREAL(f)); + } + value = new PlcList(values); + } } else if (variant instanceof VariantDouble) { List<Double> array = ((VariantDouble) variant).getValue(); - Double[] tmpValue = array.toArray(new Double[0]); - value = LegacyPlcValueHandler.of(tmpValue); + if (array.size() == 1) { + value = new PlcLREAL(array.getFirst()); + } else { + List<PlcValue> values = new ArrayList<>(array.size()); + for (Double d : array) { + values.add(new PlcLREAL(d)); + } + value = new PlcList(values); + } } else if (variant instanceof VariantString) { - int length = ((VariantString) variant).getValue().size(); List<PascalString> stringArray = ((VariantString) variant).getValue(); - String[] tmpValue = new String[length]; - for (int i = 0; i < length; i++) { - tmpValue[i] = stringArray.get(i).getStringValue(); + if (stringArray.size() == 1) { + value = new PlcSTRING(stringArray.getFirst().getStringValue()); + } else { + List<PlcValue> values = new ArrayList<>(stringArray.size()); + for (PascalString ps : stringArray) { + values.add(new PlcSTRING(ps.getStringValue())); + } + value = new PlcList(values); } - value = LegacyPlcValueHandler.of(tmpValue); } else if (variant instanceof VariantDateTime) { List<Long> array = ((VariantDateTime) variant).getValue(); - int length = array.size(); - LocalDateTime[] tmpValue = new LocalDateTime[length]; - for (int i = 0; i < length; i++) { - tmpValue[i] = LocalDateTime.ofInstant(Instant.ofEpochMilli(getDateTime(array.get(i))), ZoneOffset.UTC); + if (array.size() == 1) { + value = LegacyPlcValueHandler.of(LocalDateTime.ofInstant(Instant.ofEpochMilli(getDateTime(array.getFirst())), ZoneOffset.UTC)); + } else { + List<PlcValue> values = new ArrayList<>(array.size()); + for (Long l : array) { + values.add(LegacyPlcValueHandler.of(LocalDateTime.ofInstant(Instant.ofEpochMilli(getDateTime(l)), ZoneOffset.UTC))); + } + value = new PlcList(values); } - value = LegacyPlcValueHandler.of(tmpValue); } else if (variant instanceof VariantGuid) { List<GuidValue> array = ((VariantGuid) variant).getValue(); int length = array.size(); @@ -495,21 +574,21 @@ public class OpcuaProtocolLogic extends Plc4xProtocolBase<OpcuaAPU> implements H List<PlcValue> plcValueList = valueObject.getList(); PlcValueType dataType = tag.getPlcValueType(); if (dataType.equals(PlcValueType.NULL)) { - if (plcValueList.get(0).getObject() instanceof Boolean) { + if (plcValueList.getFirst().getObject() instanceof Boolean) { dataType = PlcValueType.BOOL; - } else if (plcValueList.get(0).getObject() instanceof Byte) { + } else if (plcValueList.getFirst().getObject() instanceof Byte) { dataType = PlcValueType.SINT; - } else if (plcValueList.get(0).getObject() instanceof Short) { + } else if (plcValueList.getFirst().getObject() instanceof Short) { dataType = PlcValueType.INT; - } else if (plcValueList.get(0).getObject() instanceof Integer) { + } else if (plcValueList.getFirst().getObject() instanceof Integer) { dataType = PlcValueType.DINT; - } else if (plcValueList.get(0).getObject() instanceof Long) { + } else if (plcValueList.getFirst().getObject() instanceof Long) { dataType = PlcValueType.LINT; - } else if (plcValueList.get(0).getObject() instanceof Float) { + } else if (plcValueList.getFirst().getObject() instanceof Float) { dataType = PlcValueType.REAL; - } else if (plcValueList.get(0).getObject() instanceof Double) { + } else if (plcValueList.getFirst().getObject() instanceof Double) { dataType = PlcValueType.LREAL; - } else if (plcValueList.get(0).getObject() instanceof String) { + } else if (plcValueList.getFirst().getObject() instanceof String) { dataType = PlcValueType.STRING; } } @@ -802,7 +881,7 @@ public class OpcuaProtocolLogic extends Plc4xProtocolBase<OpcuaAPU> implements H @Override public CompletableFuture<PlcSubscriptionResponse> subscribe(PlcSubscriptionRequest subscriptionRequest) { List<String> tagNames = new ArrayList<>(subscriptionRequest.getTagNames()); - long cycleTime = (subscriptionRequest.getTag(tagNames.get(0))).getDuration().orElse(Duration.ofMillis(1000)).toMillis(); + long cycleTime = (subscriptionRequest.getTag(tagNames.getFirst())).getDuration().orElse(Duration.ofMillis(1000)).toMillis(); CompletableFuture<PlcSubscriptionResponse> future = new CompletableFuture<>(); RequestTransaction transaction = tm.startRequest(); @@ -823,7 +902,7 @@ public class OpcuaProtocolLogic extends Plc4xProtocolBase<OpcuaAPU> implements H subscriptions.put(handle.getSubscriptionId(), handle); return handle; }) - .thenCompose(handle -> handle.onSubscribeCreateMonitoredItemsRequest()) + .thenCompose(OpcuaSubscriptionHandle::onSubscribeCreateMonitoredItemsRequest) .thenApply(handle -> { Map<String, PlcResponseItem<PlcSubscriptionHandle>> values = new HashMap<>(); for (String tagName : subscriptionRequest.getTagNames()) { diff --git a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/ManualS71500NewFWDriverTest.java b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/ManualS71500NewFWDriverTest.java new file mode 100644 index 0000000000..768a3e255f --- /dev/null +++ b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/ManualS71500NewFWDriverTest.java @@ -0,0 +1,139 @@ +/* + * 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 + * + * https://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.opcua; + +import org.apache.plc4x.java.spi.values.*; +import org.apache.plc4x.test.manual.ManualTest; + +import java.math.BigDecimal; +import java.time.Duration; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.List; + +public class ManualS71500NewFWDriverTest extends ManualTest { + + public ManualS71500NewFWDriverTest(String connectionString) { + super(connectionString, true, false, true, true, 100); + } + + public static void main(String[] args) throws Exception { + boolean testArrays = true; + ManualS71500NewFWDriverTest test = new ManualS71500NewFWDriverTest("opcua://192.168.23.28:4840"); +// test.addTestCase(/*"g_b1",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_b1\"", new PlcBOOL(true)); +// test.addTestCase(/*"g_b8",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_b8\"", new PlcBYTE(0xAB)); +// test.addTestCase(/*"g_s8",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_s8\"", new PlcSINT(-12)); +// test.addTestCase(/*"g_u8",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_u8\"", new PlcUSINT(250)); +// test.addTestCase(/*"g_b16",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_b16\"", new PlcWORD(0xBEEF)); +// test.addTestCase(/*"g_s16",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_s16\"", new PlcINT(-1234)); +// test.addTestCase(/*"g_u16",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_u16\"", new PlcUINT(54321)); +// test.addTestCase(/*"g_b32",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_b32\"", new PlcDWORD(0xDEADBEEFL)); +// test.addTestCase(/*"g_s32",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_s32\"", new PlcDINT(-12345678)); +// test.addTestCase(/*"g_u32",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_u32\"", new PlcUDINT(305419896)); +// test.addTestCase(/*"g_b64",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_b64\"", new PlcLWORD(0x0123_4567_89AB_CDEFL)); +// test.addTestCase(/*"g_s64",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_s64\"", new PlcLINT(-9223372036854770000L)); +// test.addTestCase(/*"g_u64",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_u64\"", new PlcULINT(new BigDecimal("18446744073709551000"))); +// test.addTestCase(/*"g_r32",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_r32\"", new PlcREAL(3.14159)); +// test.addTestCase(/*"g_r64",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_r64\"", new PlcLREAL(2.71828182845905)); +// test.addTestCase(/*"g_tim",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_tim\"", new PlcTIME(2500)); // TODO: Is returned as Int32 +// test.addTestCase(/*"g_dat",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_dat\"", new PlcDATE(LocalDate.of(2025, 11, 12))); // TODO: Is returned as UInt16 +// test.addTestCase(/*"g_timoday",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_timoday\"", new PlcTIME_OF_DAY(LocalTime.of(14, 33, 21, 250000000))); // TODO: Is returned as UInt32 +// test.addTestCase(/*"g_dattim",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_dattim\"", new PlcDATE_AND_LTIME(LocalDateTime.of(2025, 11, 12, 14, 33, 21, 500_000_000))); // TODO: Getting a class cast error, because OpcuaMessageResponse cannot be cast to OpcuaAPU +// test.addTestCase(/*"g_str",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_str\"", new PlcSTRING("Hello PLC4X")); +// test.addTestCase(/*"g_wstr",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_wstr\"", new PlcWSTRING("Grüße von PLC4X")); + if(testArrays) { +// test.addTestCase(/*"g_arrBool",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_arrBool\"", new PlcList(List.of( +// new PlcBOOL(true), new PlcBOOL(false), new PlcBOOL(true), new PlcBOOL(true), +// new PlcBOOL(false), new PlcBOOL(false), new PlcBOOL(true), new PlcBOOL(false)) +// )); +// test.addTestCase(/*"g_arrByte",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_arrByte\"", new PlcList(List.of( +// new PlcBYTE(0xDE), new PlcBYTE(0xAD), new PlcBYTE(0xBE), new PlcBYTE(0xEF), +// new PlcBYTE(0x12), new PlcBYTE(0x34), new PlcBYTE(0x56), new PlcBYTE(0x78)) +// )); +// test.addTestCase(/*"g_arrInt",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_arrInt\"", new PlcList(List.of( +// new PlcINT(-3), new PlcINT(-1), new PlcINT(0), new PlcINT(1), new PlcINT(3)) +// )); +// test.addTestCase(/*"g_arrUInt",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_arrUInt\"", new PlcList(List.of( +// new PlcUINT(1), new PlcUINT(10), new PlcUINT(100), new PlcUINT(1000), new PlcUINT(10000)) +// )); +// test.addTestCase(/*"g_arrDInt",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_arrDInt\"", new PlcList(List.of( +// new PlcDINT(-1000), new PlcDINT(0), new PlcDINT(1000), new PlcDINT(2000000)) +// )); +// test.addTestCase(/*"g_arrUDInt",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_arrUDInt\"", new PlcList(List.of( +// new PlcUDINT(0), new PlcUDINT(1), new PlcUDINT(0xFFFF), new PlcUDINT(0x12345678)) +// )); +// test.addTestCase(/*"g_arrLReal",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_arrLReal\"", new PlcList(List.of( +// new PlcLREAL(1.5), new PlcLREAL(-2.0), new PlcLREAL(0.125)) +// )); +// test.addTestCase(/*"g_arrTime",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_arrTime\"", new PlcList(List.of( +// new PlcTIME(Duration.ofMillis(10)), new PlcTIME(Duration.ofSeconds(1)), new PlcTIME(Duration.ofSeconds(10))) +// )); +// test.addTestCase(/*"g_arrString",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_arrString\"", new PlcList(List.of( +// new PlcSTRING("alpha"), new PlcSTRING("beta"), new PlcSTRING("gamma")) +// )); +// test.addTestCase(/*"g_arrWString",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_arrWString\"", new PlcList(List.of( +// new PlcWSTRING("Äpfel"), new PlcWSTRING("Öl")) +// )); +// test.addTestCase(/*"g_matI16_2x3",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_matI16_2x3\"", new PlcList(List.of( // TODO: Getting a class cast error, because OpcuaMessageResponse cannot be cast to OpcuaAPU +// new PlcList(List.of( +// new PlcINT(10), new PlcINT(11), new PlcINT(12) +// )), +// new PlcList(List.of( +// new PlcINT(-10), new PlcINT(-11), new PlcINT(-12) +// ))) +// )); + test.addTestCase(/*"g_matR32_3x2",*/ "ns=3;s=\"OPC_UA_DB\".\"OPC Data\".\"g_matR32_3x2\"", new PlcList(List.of( + new PlcList(List.of( + new PlcREAL(1.0), new PlcREAL(1.5) + )), + new PlcList(List.of( + new PlcREAL(2.0), new PlcREAL(2.5) + )), + new PlcList(List.of( + new PlcREAL(3.0), new PlcREAL(3.5) + ))) + )); +// test.addTestCase(/*"g_cubeU16_2x2x2",*/ "%DB42:466.0:INT[1;1..2][1;1..2][1;1..2]", new PlcList(List.of( +// new PlcList(List.of( +// new PlcList(List.of( +// new PlcINT(1), new PlcINT(2) +// )), +// new PlcList(List.of( +// new PlcINT(3), new PlcINT(4) +// )) +// )), +// new PlcList(List.of( +// new PlcList(List.of( +// new PlcINT(5), new PlcINT(6) +// )), +// new PlcList(List.of( +// new PlcINT(7), new PlcINT(8) +// )) +// ))) +// )); + } + + long start = System.currentTimeMillis(); + test.run(); + long end = System.currentTimeMillis(); + System.out.printf("Finished in %d ms", end - start); + } + +} diff --git a/protocols/opcua/src/main/generated/protocols/opcua/opc-manual.mspec b/protocols/opcua/src/main/generated/protocols/opcua/opc-manual.mspec index 380da9f2b8..b2cb1610b7 100644 --- a/protocols/opcua/src/main/generated/protocols/opcua/opc-manual.mspec +++ b/protocols/opcua/src/main/generated/protocols/opcua/opc-manual.mspec @@ -2736,7 +2736,7 @@ ] ] [optional int 32 noOfArrayDimensions 'arrayDimensionsSpecified'] - [array bit arrayDimensions count 'noOfArrayDimensions == null ? 0 : noOfArrayDimensions'] + [array int 32 arrayDimensions count 'noOfArrayDimensions == null ? 0 : noOfArrayDimensions'] ] // node type, with two leading reserved bytes diff --git a/protocols/opcua/src/main/xslt/opc-manual.xsl b/protocols/opcua/src/main/xslt/opc-manual.xsl index c0fd1267b8..f5ea6879df 100644 --- a/protocols/opcua/src/main/xslt/opc-manual.xsl +++ b/protocols/opcua/src/main/xslt/opc-manual.xsl @@ -355,7 +355,7 @@ ] ] [optional int 32 noOfArrayDimensions 'arrayDimensionsSpecified'] - [array bit arrayDimensions count 'noOfArrayDimensions == null ? 0 : noOfArrayDimensions'] + [array int 32 arrayDimensions count 'noOfArrayDimensions == null ? 0 : noOfArrayDimensions'] ] // node type, with two leading reserved bytes
