From bff83ffcd573441de3b19821741a5c13898314dd Mon Sep 17 00:00:00 2001 From: Kevin Herron Date: Fri, 16 Sep 2022 14:30:53 -0700 Subject: [PATCH] Implement Matrix as a container for multidimensional array values --- .../opcua/sdk/client/AddressSpaceTest.java | 4 +- .../sdk/client/DynamicMatrixTestTypeTest.java | 47 + .../sdk/client/StaticMatrixTestTypeTest.java | 52 + .../milo/opcua/sdk/core/DataTypeTreeTest.java | 4 +- .../sdk/test/AbstractClientServerTest.java | 2 + .../milo/opcua/sdk/test/MatrixTestType.java | 122 +++ .../milo/opcua/sdk/test/TestNamespace.java | 177 +++- .../DataTypeCodecSessionInitializer.java | 19 + .../sdk/core/types/DynamicStructCodec.java | 57 +- .../core/encoding/json/OpcUaJsonDecoder.java | 123 ++- .../core/encoding/json/OpcUaJsonEncoder.java | 350 ++++++- .../encoding/json/OpcUaJsonDecoderTest.java | 83 +- .../encoding/json/OpcUaJsonEncoderTest.java | 90 +- .../core/encoding/xml/OpcUaXmlDecoder.java | 22 + .../core/encoding/xml/OpcUaXmlEncoder.java | 21 + .../opcua/stack/core/BuiltinDataType.java | 14 + .../opcua/stack/core/encoding/UaDecoder.java | 10 + .../opcua/stack/core/encoding/UaEncoder.java | 9 + .../encoding/binary/OpcUaBinaryDecoder.java | 115 ++- .../encoding/binary/OpcUaBinaryEncoder.java | 129 ++- .../stack/core/types/builtin/Matrix.java | 957 ++++++++++++++++++ .../core/types/builtin/OptionSetUI16.java | 26 + .../core/types/builtin/OptionSetUI32.java | 26 + .../core/types/builtin/OptionSetUI64.java | 26 + .../core/types/builtin/OptionSetUI8.java | 26 + .../core/types/builtin/OptionSetUInteger.java | 2 +- .../stack/core/types/builtin/Variant.java | 10 + .../types/structured/AccessLevelExType.java | 20 +- .../types/structured/AccessLevelType.java | 20 +- .../structured/AccessRestrictionType.java | 20 +- .../types/structured/AddNodesResponse.java | 3 +- .../types/structured/AddReferencesItem.java | 3 +- .../structured/AddReferencesRequest.java | 3 +- .../types/structured/AliasNameDataType.java | 3 +- .../types/structured/AttributeOperand.java | 3 +- .../types/structured/AttributeWriteMask.java | 20 +- .../types/structured/BrowseDescription.java | 3 +- .../types/structured/BrowseNextRequest.java | 3 +- .../types/structured/BrowseNextResponse.java | 3 +- .../types/structured/BrowsePathResult.java | 3 +- .../types/structured/BrowsePathTarget.java | 3 +- .../types/structured/CallMethodRequest.java | 3 +- .../types/structured/CallMethodResult.java | 3 +- .../structured/ChannelSecurityToken.java | 3 +- .../types/structured/CloseSessionRequest.java | 3 +- .../structured/CloseSessionResponse.java | 3 +- .../types/structured/ComplexNumberType.java | 3 +- .../ConfigurationVersionDataType.java | 3 +- .../structured/ContentFilterElement.java | 3 +- .../types/structured/ContentFilterResult.java | 3 +- .../CreateMonitoredItemsResponse.java | 3 +- .../structured/CreateSessionRequest.java | 3 +- .../types/structured/CurrencyUnitType.java | 3 +- .../types/structured/DataChangeFilter.java | 3 +- .../structured/DataSetFieldContentMask.java | 20 +- .../types/structured/DataSetFieldFlags.java | 20 +- .../types/structured/DataSetMetaDataType.java | 3 +- .../types/structured/DataTypeAttributes.java | 3 +- .../types/structured/DeleteAtTimeDetails.java | 3 +- .../types/structured/DeleteEventDetails.java | 3 +- .../DeleteMonitoredItemsResponse.java | 3 +- .../types/structured/DeleteNodesRequest.java | 3 +- .../types/structured/DeleteNodesResponse.java | 3 +- .../structured/DeleteReferencesItem.java | 3 +- .../types/structured/EndpointDescription.java | 3 +- .../types/structured/EphemeralKeyType.java | 3 +- .../types/structured/EventFilterResult.java | 3 +- .../types/structured/EventNotifierType.java | 20 +- .../types/structured/FieldTargetDataType.java | 3 +- .../FindServersOnNetworkResponse.java | 3 +- .../types/structured/FindServersRequest.java | 3 +- .../types/structured/FindServersResponse.java | 3 +- .../types/structured/GenericAttributes.java | 3 +- .../types/structured/GetEndpointsRequest.java | 3 +- .../structured/GetEndpointsResponse.java | 3 +- .../types/structured/HistoryModifiedData.java | 3 +- .../types/structured/HistoryReadDetails.java | 3 +- .../types/structured/HistoryReadRequest.java | 3 +- .../types/structured/HistoryReadResponse.java | 3 +- .../types/structured/HistoryReadResult.java | 3 +- .../types/structured/HistoryReadValueId.java | 3 +- .../structured/HistoryUpdateDetails.java | 3 +- .../structured/HistoryUpdateRequest.java | 3 +- .../types/structured/HistoryUpdateResult.java | 3 +- .../types/structured/IssuedIdentityToken.java | 3 +- .../JsonDataSetMessageContentMask.java | 20 +- .../JsonDataSetReaderMessageDataType.java | 3 +- .../JsonDataSetWriterMessageDataType.java | 3 +- .../JsonNetworkMessageContentMask.java | 20 +- .../JsonWriterGroupMessageDataType.java | 3 +- .../types/structured/MethodAttributes.java | 3 +- .../ModelChangeStructureDataType.java | 3 +- .../types/structured/ModificationInfo.java | 3 +- .../ModifyMonitoredItemsResponse.java | 3 +- .../types/structured/MonitoringFilter.java | 3 +- .../structured/MonitoringParameters.java | 3 +- .../structured/NetworkGroupDataType.java | 3 +- .../types/structured/NodeTypeDescription.java | 3 +- .../types/structured/NotificationData.java | 3 +- .../types/structured/NotificationMessage.java | 3 +- .../types/structured/ObjectAttributes.java | 3 +- .../structured/ObjectTypeAttributes.java | 3 +- .../types/structured/PasswordOptionsMask.java | 20 +- .../core/types/structured/PermissionType.java | 20 +- .../PubSubConfiguration2DataType.java | 3 +- .../PubSubConfigurationRefDataType.java | 3 +- .../PubSubConfigurationRefMask.java | 20 +- .../PubSubConfigurationValueDataType.java | 3 +- .../structured/QueryDataDescription.java | 3 +- .../types/structured/QueryFirstRequest.java | 3 +- .../types/structured/QueryFirstResponse.java | 3 +- .../types/structured/QueryNextRequest.java | 3 +- .../types/structured/QueryNextResponse.java | 3 +- .../types/structured/ReadAtTimeDetails.java | 3 +- .../types/structured/ReadEventDetails.java | 3 +- .../structured/ReadProcessedDetails.java | 3 +- .../types/structured/ReaderGroupDataType.java | 3 +- .../structured/ReferenceDescription.java | 3 +- .../types/structured/ReferenceTypeNode.java | 3 +- .../structured/RegisterNodesRequest.java | 3 +- .../types/structured/RegisteredServer.java | 3 +- .../types/structured/RelativePathElement.java | 3 +- .../types/structured/RepublishRequest.java | 3 +- .../types/structured/RepublishResponse.java | 3 +- .../types/structured/RolePermissionType.java | 3 +- .../SemanticChangeStructureDataType.java | 3 +- .../ServerDiagnosticsSummaryDataType.java | 3 +- .../structured/ServerStatusDataType.java | 3 +- .../SessionlessInvokeRequestType.java | 3 +- .../SessionlessInvokeResponseType.java | 3 +- .../structured/SetTriggeringRequest.java | 3 +- .../types/structured/StructureDefinition.java | 3 +- .../structured/StructureDescription.java | 3 +- .../SubscribedDataSetMirrorDataType.java | 3 +- .../SubscriptionDiagnosticsDataType.java | 3 +- .../types/structured/ThreeDOrientation.java | 3 +- .../types/structured/TimeZoneDataType.java | 3 +- .../TransferSubscriptionsRequest.java | 3 +- .../TransferSubscriptionsResponse.java | 3 +- .../types/structured/TrustListDataType.java | 3 +- .../structured/UABinaryFileDataType.java | 3 +- .../UadpDataSetMessageContentMask.java | 20 +- .../UadpDataSetReaderMessageDataType.java | 3 +- .../UadpDataSetWriterMessageDataType.java | 3 +- .../UadpNetworkMessageContentMask.java | 20 +- .../UadpWriterGroupMessageDataType.java | 3 +- .../types/structured/UpdateDataDetails.java | 3 +- .../types/structured/UpdateEventDetails.java | 3 +- .../structured/UserConfigurationMask.java | 20 +- .../types/structured/VariableAttributes.java | 3 +- .../types/structured/VariableTypeNode.java | 3 +- .../types/structured/WriterGroupDataType.java | 3 +- .../types/structured/X509IdentityToken.java | 3 +- .../binary/VariantSerializationTest.java | 15 +- .../stack/core/types/builtin/MatrixTest.java | 71 ++ 155 files changed, 2851 insertions(+), 391 deletions(-) create mode 100644 opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/DynamicMatrixTestTypeTest.java create mode 100644 opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/StaticMatrixTestTypeTest.java create mode 100644 opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/test/MatrixTestType.java create mode 100644 opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/Matrix.java create mode 100644 opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUI16.java create mode 100644 opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUI32.java create mode 100644 opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUI64.java create mode 100644 opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUI8.java create mode 100644 opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/MatrixTest.java diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/AddressSpaceTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/AddressSpaceTest.java index 010ab4f55..056eccf11 100644 --- a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/AddressSpaceTest.java +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/AddressSpaceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 the Eclipse Milo Authors + * Copyright (c) 2022 the Eclipse Milo Authors * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -84,7 +84,7 @@ public void browseWithBrowseDirection() throws UaException { List nodes = addressSpace.browseNodes(objectsFolderNode, browseOptions); - assertEquals(8, nodes.size()); + assertEquals(9, nodes.size()); assertTrue(nodes.stream().anyMatch(n -> n.getNodeId().equals(NodeIds.RootFolder))); assertTrue(nodes.stream().anyMatch(n -> n.getNodeId().equals(NodeIds.Server))); assertTrue(nodes.stream().anyMatch(n -> n.getNodeId().equals(NodeIds.Aliases))); diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/DynamicMatrixTestTypeTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/DynamicMatrixTestTypeTest.java new file mode 100644 index 000000000..459f30db1 --- /dev/null +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/DynamicMatrixTestTypeTest.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +package org.eclipse.milo.opcua.sdk.client; + +import org.eclipse.milo.opcua.sdk.client.nodes.UaVariableNode; +import org.eclipse.milo.opcua.sdk.core.types.DynamicStruct; +import org.eclipse.milo.opcua.sdk.test.AbstractClientServerTest; +import org.eclipse.milo.opcua.sdk.test.MatrixTestType; +import org.eclipse.milo.opcua.stack.core.UaException; +import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue; +import org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject; +import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +public class DynamicMatrixTestTypeTest extends AbstractClientServerTest { + + @Test + public void read() throws UaException { + AddressSpace addressSpace = client.getAddressSpace(); + + UaVariableNode testNode = (UaVariableNode) addressSpace.getNode( + new NodeId(2, "MatrixTestTypeValue") + ); + + DataValue value = testNode.readValue(); + assertNotNull(value); + + ExtensionObject xo = (ExtensionObject) value.getValue().getValue(); + assert xo != null; + + DynamicStruct decoded = (DynamicStruct) xo.decode(client.getDynamicEncodingContext()); + assertEquals(MatrixTestType.TYPE_ID, decoded.getTypeId().absolute(client.getNamespaceTable()).orElseThrow()); + System.out.println(decoded); + } + +} diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/StaticMatrixTestTypeTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/StaticMatrixTestTypeTest.java new file mode 100644 index 000000000..aa0ab5ef6 --- /dev/null +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/client/StaticMatrixTestTypeTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +package org.eclipse.milo.opcua.sdk.client; + +import org.eclipse.milo.opcua.sdk.client.nodes.UaVariableNode; +import org.eclipse.milo.opcua.sdk.test.AbstractClientServerTest; +import org.eclipse.milo.opcua.sdk.test.MatrixTestType; +import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue; +import org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject; +import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +public class StaticMatrixTestTypeTest extends AbstractClientServerTest { + + @Test + public void read() throws Exception { + // Register Codecs for each supported encoding with DataTypeManager + client.getStaticDataTypeManager().registerType( + MatrixTestType.TYPE_ID.toNodeIdOrThrow(client.getNamespaceTable()), + new MatrixTestType.Codec(), + MatrixTestType.BINARY_ENCODING_ID.toNodeIdOrThrow(client.getNamespaceTable()), + null, + MatrixTestType.JSON_ENCODING_ID.toNodeIdOrThrow(client.getNamespaceTable()) + ); + + AddressSpace addressSpace = client.getAddressSpace(); + + UaVariableNode testNode = (UaVariableNode) addressSpace.getNode( + new NodeId(2, "MatrixTestTypeValue") + ); + + DataValue value = testNode.readValue(); + assertNotNull(value); + + ExtensionObject xo = (ExtensionObject) value.getValue().getValue(); + assert xo != null; + + MatrixTestType decoded = (MatrixTestType) xo.decode(client.getStaticEncodingContext()); + System.out.println(decoded); + } + +} diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/core/DataTypeTreeTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/core/DataTypeTreeTest.java index d8fc3a365..db2e765c9 100644 --- a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/core/DataTypeTreeTest.java +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/core/DataTypeTreeTest.java @@ -168,7 +168,9 @@ public void testGetEncodingIds() { assertNotNull(treeNode); treeNode.traverse(dataType -> { - if (!Objects.equals(dataType.getBrowseName().getName(), "Structure")) { + String name = dataType.getBrowseName().getName(); + + if (!Objects.equals(name, "Structure") && !Objects.equals(name, "MatrixTestType")) { assertNotNull(dataType.getBinaryEncodingId()); assertNotNull(dataType.getXmlEncodingId()); assertNotNull(dataType.getJsonEncodingId()); diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/test/AbstractClientServerTest.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/test/AbstractClientServerTest.java index 57aab186e..fcf0c17a9 100644 --- a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/test/AbstractClientServerTest.java +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/test/AbstractClientServerTest.java @@ -12,6 +12,7 @@ import java.util.concurrent.ExecutionException; +import org.eclipse.milo.opcua.sdk.client.DataTypeCodecSessionInitializer; import org.eclipse.milo.opcua.sdk.client.OpcUaClient; import org.eclipse.milo.opcua.sdk.client.dtd.BinaryDataTypeDictionarySessionInitializer; import org.eclipse.milo.opcua.sdk.core.dtd.generic.StructCodec; @@ -39,6 +40,7 @@ public void startClientAndServer() throws Exception { server.startup().get(); client = TestClient.create(server); + client.addSessionInitializer(new DataTypeCodecSessionInitializer()); client.addSessionInitializer(new BinaryDataTypeDictionarySessionInitializer(StructCodec::new)); client.connect().get(); diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/test/MatrixTestType.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/test/MatrixTestType.java new file mode 100644 index 000000000..b370bb164 --- /dev/null +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/test/MatrixTestType.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +package org.eclipse.milo.opcua.sdk.test; + +import java.util.Arrays; + +import org.eclipse.milo.opcua.stack.core.BuiltinDataType; +import org.eclipse.milo.opcua.stack.core.UaSerializationException; +import org.eclipse.milo.opcua.stack.core.encoding.EncodingContext; +import org.eclipse.milo.opcua.stack.core.encoding.GenericDataTypeCodec; +import org.eclipse.milo.opcua.stack.core.encoding.UaDecoder; +import org.eclipse.milo.opcua.stack.core.encoding.UaEncoder; +import org.eclipse.milo.opcua.stack.core.types.UaStructuredType; +import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId; +import org.eclipse.milo.opcua.stack.core.types.builtin.Matrix; +import org.eclipse.milo.opcua.stack.core.types.enumerated.ApplicationType; +import org.eclipse.milo.opcua.stack.core.types.structured.XVType; + +public class MatrixTestType implements UaStructuredType { + + public static final ExpandedNodeId TYPE_ID = ExpandedNodeId.parse("nsu=urn:eclipse:milo:test;s=MatrixTestType.TypeId"); + public static final ExpandedNodeId BINARY_ENCODING_ID = ExpandedNodeId.parse("nsu=urn:eclipse:milo:test;s=MatrixTestType.BinaryEncoding"); + public static final ExpandedNodeId JSON_ENCODING_ID = ExpandedNodeId.parse("nsu=urn:eclipse:milo:test;s=MatrixTestType.JsonEncoding"); + + private final Integer[][] builtinMatrix; + private final ApplicationType[][] enumMatrix; + private final XVType[][] structMatrix; + + public MatrixTestType(Integer[][] builtinMatrix, ApplicationType[][] enumMatrix, XVType[][] structMatrix) { + this.builtinMatrix = builtinMatrix; + this.enumMatrix = enumMatrix; + this.structMatrix = structMatrix; + } + + public Integer[][] getBuiltinMatrix() { + return builtinMatrix; + } + + public ApplicationType[][] getEnumMatrix() { + return enumMatrix; + } + + public XVType[][] getStructMatrix() { + return structMatrix; + } + + @Override + public ExpandedNodeId getTypeId() { + return TYPE_ID; + } + + @Override + public ExpandedNodeId getBinaryEncodingId() { + return BINARY_ENCODING_ID; + } + + @Override + public ExpandedNodeId getJsonEncodingId() { + return JSON_ENCODING_ID; + } + + @Override + public String toString() { + return "MatrixTestType{" + + "builtinMatrix=" + Arrays.deepToString(builtinMatrix) + + ", enumMatrix=" + Arrays.deepToString(enumMatrix) + + ", structMatrix=" + Arrays.deepToString(structMatrix) + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + MatrixTestType that = (MatrixTestType) o; + return Arrays.deepEquals(builtinMatrix, that.builtinMatrix) && + Arrays.deepEquals(enumMatrix, that.enumMatrix) && + Arrays.deepEquals(structMatrix, that.structMatrix); + } + + @Override + public int hashCode() { + int result = Arrays.hashCode(builtinMatrix); + result = 31 * result + Arrays.hashCode(enumMatrix); + result = 31 * result + Arrays.hashCode(structMatrix); + return result; + } + + public static class Codec extends GenericDataTypeCodec { + + @Override + public Class getType() { + return MatrixTestType.class; + } + + @Override + public MatrixTestType decodeType(EncodingContext context, UaDecoder decoder) throws UaSerializationException { + Integer[][] builtinMatrix = (Integer[][]) decoder.decodeMatrix("BuiltinMatrix", BuiltinDataType.Int32).nestedArrayValue(); + ApplicationType[][] enumMatrix = (ApplicationType[][]) decoder.decodeEnumMatrix("EnumMatrix").transform(e -> ApplicationType.from((Integer) e)).nestedArrayValue(); + XVType[][] structMatrix = (XVType[][]) decoder.decodeStructMatrix("StructMatrix", XVType.TYPE_ID).nestedArrayValue(); + + return new MatrixTestType(builtinMatrix, enumMatrix, structMatrix); + } + + @Override + public void encodeType(EncodingContext context, UaEncoder encoder, MatrixTestType value) throws UaSerializationException { + encoder.encodeMatrix("BuiltinMatrix", new Matrix(value.builtinMatrix)); + encoder.encodeEnumMatrix("EnumMatrix", new Matrix(value.enumMatrix)); + encoder.encodeStructMatrix("StructMatrix", new Matrix(value.structMatrix), XVType.TYPE_ID); + } + + } + +} diff --git a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/test/TestNamespace.java b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/test/TestNamespace.java index bdbc67490..37f51ec50 100644 --- a/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/test/TestNamespace.java +++ b/opc-ua-sdk/integration-tests/src/test/java/org/eclipse/milo/opcua/sdk/test/TestNamespace.java @@ -26,8 +26,10 @@ import org.eclipse.milo.opcua.sdk.server.api.methods.AbstractMethodInvocationHandler; import org.eclipse.milo.opcua.sdk.server.api.methods.InvalidArgumentException; import org.eclipse.milo.opcua.sdk.server.model.objects.BaseEventTypeNode; +import org.eclipse.milo.opcua.sdk.server.model.objects.DataTypeEncodingTypeNode; import org.eclipse.milo.opcua.sdk.server.model.objects.ServerTypeNode; import org.eclipse.milo.opcua.sdk.server.model.variables.AnalogItemTypeNode; +import org.eclipse.milo.opcua.sdk.server.nodes.UaDataTypeNode; import org.eclipse.milo.opcua.sdk.server.nodes.UaMethodNode; import org.eclipse.milo.opcua.sdk.server.nodes.UaNode; import org.eclipse.milo.opcua.sdk.server.nodes.UaNodeContext; @@ -36,6 +38,7 @@ import org.eclipse.milo.opcua.stack.core.NodeIds; import org.eclipse.milo.opcua.stack.core.StatusCodes; import org.eclipse.milo.opcua.stack.core.UaException; +import org.eclipse.milo.opcua.stack.core.types.DataTypeEncoding; import org.eclipse.milo.opcua.stack.core.types.builtin.ByteString; import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue; import org.eclipse.milo.opcua.stack.core.types.builtin.DateTime; @@ -44,11 +47,17 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode; import org.eclipse.milo.opcua.stack.core.types.builtin.Variant; +import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; +import org.eclipse.milo.opcua.stack.core.types.enumerated.ApplicationType; +import org.eclipse.milo.opcua.stack.core.types.enumerated.StructureType; import org.eclipse.milo.opcua.stack.core.types.structured.AccessRestrictionType; import org.eclipse.milo.opcua.stack.core.types.structured.Argument; import org.eclipse.milo.opcua.stack.core.types.structured.PermissionType; import org.eclipse.milo.opcua.stack.core.types.structured.Range; import org.eclipse.milo.opcua.stack.core.types.structured.RolePermissionType; +import org.eclipse.milo.opcua.stack.core.types.structured.StructureDefinition; +import org.eclipse.milo.opcua.stack.core.types.structured.StructureField; +import org.eclipse.milo.opcua.stack.core.types.structured.XVType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -95,10 +104,10 @@ public void shutdown() { .setDisplayName(LocalizedText.english("TestInt32")) .setDataType(NodeIds.Int32) .setTypeDefinition(NodeIds.BaseDataVariableType) - .setRolePermissions(new RolePermissionType[] { + .setRolePermissions(new RolePermissionType[]{ new RolePermissionType(newNodeId("roleId"), new PermissionType(uint(0))) }) - .setUserRolePermissions(new RolePermissionType[] { + .setUserRolePermissions(new RolePermissionType[]{ new RolePermissionType(newNodeId("roleId"), new PermissionType(uint(0))) }) .setAccessRestrictions(new AccessRestrictionType(ushort(0))) @@ -278,6 +287,57 @@ protected Variant[] invoke(InvocationContext invocationContext, Variant[] inputV return methodNode; }); }); + + getLifecycleManager().addStartupTask(() -> { + try { + registerMatrixTestType(); + + UaVariableNode node = new UaVariableNode.UaVariableNodeBuilder(getNodeContext()) + .setNodeId(newNodeId("MatrixTestTypeValue")) + .setAccessLevel(AccessLevel.READ_WRITE) + .setUserAccessLevel(AccessLevel.READ_WRITE) + .setBrowseName(newQualifiedName("MatrixTestTypeValue")) + .setDisplayName(LocalizedText.english("MatrixTestTypeValue")) + .setDataType(MatrixTestType.TYPE_ID.toNodeIdOrThrow(server.getNamespaceTable())) + .setTypeDefinition(NodeIds.BaseDataVariableType) + .setRolePermissions(new RolePermissionType[]{ + new RolePermissionType(newNodeId("roleId"), new PermissionType(uint(0))) + }) + .setUserRolePermissions(new RolePermissionType[]{ + new RolePermissionType(newNodeId("roleId"), new PermissionType(uint(0))) + }) + .setAccessRestrictions(new AccessRestrictionType(ushort(0))) + .build(); + + MatrixTestType value = new MatrixTestType( + new Integer[][]{ + new Integer[]{0, 1}, + new Integer[]{2, 3} + }, + new ApplicationType[][]{ + new ApplicationType[]{ApplicationType.Server, ApplicationType.Client}, + new ApplicationType[]{ApplicationType.ClientAndServer, ApplicationType.DiscoveryServer} + }, + new XVType[][]{ + new XVType[]{new XVType(0.0d, 1.0f), new XVType(2.0d, 3.0f)}, + new XVType[]{new XVType(4.0d, 5.0f), new XVType(6.0d, 7.0f)} + } + ); + + node.setValue(new DataValue(new Variant(value))); + + node.addReference(new Reference( + node.getNodeId(), + NodeIds.HasComponent, + NodeIds.ObjectsFolder.expanded(), + Reference.Direction.INVERSE + )); + + getNodeManager().addNode(node); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); } private void startBogusEventNotifier() { @@ -336,6 +396,119 @@ private void startBogusEventNotifier() { } } + private void registerMatrixTestType() throws Exception { + // Get the NodeId for the DataType and encoding Nodes. + NodeId dataTypeId = MatrixTestType.TYPE_ID.toNodeIdOrThrow(getServer().getNamespaceTable()); + NodeId binaryEncodingId = MatrixTestType.BINARY_ENCODING_ID.toNodeIdOrThrow(getServer().getNamespaceTable()); + NodeId jsonEncodingId = MatrixTestType.JSON_ENCODING_ID.toNodeIdOrThrow(getServer().getNamespaceTable()); + + // Add a custom DataTypeNode with a SubtypeOf reference to Structure + UaDataTypeNode dataTypeNode = new UaDataTypeNode( + getNodeContext(), + dataTypeId, + newQualifiedName("MatrixTestType"), + LocalizedText.english("MatrixTestType"), + LocalizedText.NULL_VALUE, + uint(0), + uint(0), + false + ); + + dataTypeNode.addReference(new Reference( + dataTypeId, + NodeIds.HasSubtype, + NodeIds.Structure.expanded(), + Reference.Direction.INVERSE + )); + + getNodeManager().addNode(dataTypeNode); + + // Add encoding nodes + addEncodingNode(dataTypeId, binaryEncodingId, DataTypeEncoding.BINARY_ENCODING_NAME); + addEncodingNode(dataTypeId, jsonEncodingId, DataTypeEncoding.JSON_ENCODING_NAME); + + // Define the structure + StructureField[] fields = new StructureField[]{ + new StructureField( + "BuiltinMatrix", + LocalizedText.NULL_VALUE, + NodeIds.Int32, + 2, + new UInteger[]{uint(2), uint(2)}, + getServer().getConfig().getLimits().getMaxStringLength(), + false + ), + new StructureField( + "EnumMatrix", + LocalizedText.NULL_VALUE, + NodeIds.ApplicationType, + 2, + new UInteger[]{uint(2), uint(2)}, + getServer().getConfig().getLimits().getMaxStringLength(), + false + ), + new StructureField( + "StructMatrix", + LocalizedText.NULL_VALUE, + NodeIds.XVType, + 2, + new UInteger[]{uint(2), uint(2)}, + uint(0), + false + ) + }; + + StructureDefinition definition = new StructureDefinition( + binaryEncodingId, + NodeIds.Structure, + StructureType.Structure, + fields + ); + + // Populate the OPC UA 1.04+ DataTypeDefinition attribute + dataTypeNode.setDataTypeDefinition(definition); + + // Register Codecs for each supported encoding with DataTypeManager + getNodeContext().getServer().getDataTypeManager().registerType( + dataTypeId, + new MatrixTestType.Codec(), + binaryEncodingId, + null, + jsonEncodingId + ); + } + + private void addEncodingNode(NodeId dataTypeId, NodeId encodingId, QualifiedName encodingName) { + DataTypeEncodingTypeNode dataTypeEncodingNode = new DataTypeEncodingTypeNode( + getNodeContext(), + encodingId, + encodingName, + LocalizedText.english(encodingName.getName()), + LocalizedText.NULL_VALUE, + uint(0), + uint(0), + null, + null, + null + ); + + dataTypeEncodingNode.addReference(new Reference( + dataTypeEncodingNode.getNodeId(), + NodeIds.HasTypeDefinition, + NodeIds.DataTypeEncodingType.expanded(), + Reference.Direction.FORWARD + )); + + dataTypeEncodingNode.addReference(new Reference( + dataTypeEncodingNode.getNodeId(), + NodeIds.HasEncoding, + dataTypeId.expanded(), + Reference.Direction.INVERSE + )); + + getNodeManager().addNode(dataTypeEncodingNode); + } + @Override public void onDataItemsCreated(List dataItems) { diff --git a/opc-ua-sdk/sdk-client/src/main/java/org/eclipse/milo/opcua/sdk/client/DataTypeCodecSessionInitializer.java b/opc-ua-sdk/sdk-client/src/main/java/org/eclipse/milo/opcua/sdk/client/DataTypeCodecSessionInitializer.java index 493c02db5..79d13d710 100644 --- a/opc-ua-sdk/sdk-client/src/main/java/org/eclipse/milo/opcua/sdk/client/DataTypeCodecSessionInitializer.java +++ b/opc-ua-sdk/sdk-client/src/main/java/org/eclipse/milo/opcua/sdk/client/DataTypeCodecSessionInitializer.java @@ -1,3 +1,13 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + package org.eclipse.milo.opcua.sdk.client; import java.util.concurrent.CompletableFuture; @@ -12,10 +22,14 @@ import org.eclipse.milo.opcua.stack.core.types.structured.StructureDefinition; import org.eclipse.milo.opcua.stack.core.util.Tree; import org.eclipse.milo.opcua.stack.core.util.Unit; +import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class DataTypeCodecSessionInitializer implements SessionFsm.SessionInitializer { + private static final Logger LOGGER = + LoggerFactory.getLogger(DataTypeCodecSessionInitializer.class); + @Override public CompletableFuture initialize(UaStackClient stackClient, OpcUaSession session) { String treeKey = DataTypeTreeSessionInitializer.SESSION_ATTRIBUTE_KEY; @@ -45,6 +59,11 @@ private static void registerCodecs(UaStackClient stackClient, DataTypeTree dataT DataTypeDefinition definition = dataType.getDataTypeDefinition(); if (definition instanceof StructureDefinition) { + LOGGER.debug( + "Registering type: name={}, dataTypeId={}", + dataType.getBrowseName(), dataType.getNodeId() + ); + stackClient.getDynamicDataTypeManager().registerType( dataType.getNodeId(), new DynamicStructCodec(dataTypeTree, dataType), diff --git a/opc-ua-sdk/sdk-core/src/main/java/org/eclipse/milo/opcua/sdk/core/types/DynamicStructCodec.java b/opc-ua-sdk/sdk-core/src/main/java/org/eclipse/milo/opcua/sdk/core/types/DynamicStructCodec.java index b99a1e0ae..adfacf278 100644 --- a/opc-ua-sdk/sdk-core/src/main/java/org/eclipse/milo/opcua/sdk/core/types/DynamicStructCodec.java +++ b/opc-ua-sdk/sdk-core/src/main/java/org/eclipse/milo/opcua/sdk/core/types/DynamicStructCodec.java @@ -32,6 +32,7 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject; import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; +import org.eclipse.milo.opcua.stack.core.types.builtin.Matrix; import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode; @@ -282,8 +283,39 @@ private Object decodeFieldValue(UaDecoder decoder, StructureField field) { return value; } else if (valueRank > 1) { - // TODO special matrix encoding for multi-dimensional array structure fields - throw new RuntimeException("not implemented"); + Object value; + + Object hint = fieldHints.get(field); + if (hint instanceof BuiltinDataType) { + BuiltinDataType builtinDataType = (BuiltinDataType) hint; + + value = decoder.decodeMatrix(fieldName, builtinDataType); + } else { + TypeHint typeHint = (TypeHint) hint; + + switch (typeHint) { + case ENUM: { + Matrix matrix = decoder.decodeEnumMatrix(fieldName); + + if (matrix.isNotNull()) { + Function factory = enumFactories.get(dataTypeId); + assert factory != null; + + value = matrix.transform(o -> factory.apply((Integer) o)); + } else { + value = matrix; + } + break; + } + case STRUCT: + value = decoder.decodeStructMatrix(fieldName, dataTypeId); + break; + default: + throw new RuntimeException("codecType: " + typeHint); + } + } + + return value; } else { throw new UaSerializationException( StatusCodes.Bad_DecodingError, "illegal ValueRank: " + valueRank); @@ -333,8 +365,25 @@ private void encodeFieldValue(UaEncoder encoder, StructureField field, Object va } } } else if (valueRank > 1) { - // TODO special matrix encoding for multi-dimensional array structure fields - throw new RuntimeException("not implemented"); + Matrix matrix = (Matrix) value; + + Object hint = fieldHints.get(field); + if (hint instanceof BuiltinDataType) { + encoder.encodeMatrix(fieldName, matrix); + } else { + TypeHint typeHint = (TypeHint) hint; + + switch (typeHint) { + case ENUM: + encoder.encodeEnumMatrix(fieldName, matrix); + break; + case STRUCT: + encoder.encodeStructMatrix(fieldName, matrix, dataTypeId); + break; + default: + throw new RuntimeException("codecType: " + typeHint); + } + } } else { throw new UaSerializationException( StatusCodes.Bad_EncodingError, "illegal ValueRank: " + valueRank); diff --git a/opc-ua-stack/encoding-json/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/json/OpcUaJsonDecoder.java b/opc-ua-stack/encoding-json/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/json/OpcUaJsonDecoder.java index a82bedf7b..d1460dec4 100644 --- a/opc-ua-stack/encoding-json/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/json/OpcUaJsonDecoder.java +++ b/opc-ua-stack/encoding-json/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/json/OpcUaJsonDecoder.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Base64; +import java.util.List; import java.util.UUID; import java.util.function.Function; @@ -26,6 +27,7 @@ import com.google.gson.JsonParser; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; +import org.eclipse.milo.opcua.stack.core.BuiltinDataType; import org.eclipse.milo.opcua.stack.core.StatusCodes; import org.eclipse.milo.opcua.stack.core.UaSerializationException; import org.eclipse.milo.opcua.stack.core.encoding.DataTypeCodec; @@ -39,6 +41,7 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject; import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; +import org.eclipse.milo.opcua.stack.core.types.builtin.Matrix; import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode; @@ -1089,9 +1092,21 @@ public Variant decodeVariant(String field) throws UaSerializationException { try { jsonReader = new JsonReader(new StringReader(bodyElement.toString())); - Object value = readFlattenedMultiDimensionalVariantValue(typeId, dimensions); + var elements = new ArrayList<>(); + jsonReader.beginArray(); + while (jsonReader.peek() != JsonToken.END_ARRAY) { + elements.add(readBuiltinTypeValue(null, typeId)); + } + jsonReader.endArray(); + + Object flatArray = Array.newInstance(TypeUtil.getPrimitiveBackingClass(typeId), elements.size()); + for (int i = 0; i < elements.size(); i++) { + Array.set(flatArray, i, elements.get(i)); + } - return new Variant(value); + var matrix = new Matrix(flatArray, dimensions, BuiltinDataType.fromTypeId(typeId)); + + return new Variant(matrix); } finally { jsonReader = reader; } @@ -1563,6 +1578,110 @@ public T[] decodeArray( } } + @Override + public Matrix decodeMatrix(String field, BuiltinDataType builtinDataType) throws UaSerializationException { + try { + if (field != null) { + String nextName = nextName(); + if (!field.equals(nextName)) { + this.peekedNextName = nextName; + return Matrix.ofNull(); + } + } + + Object nestedArray = decodeNestedMultiDimensionalArrayBuiltinValue(builtinDataType.getTypeId()); + + return new Matrix(nestedArray); + } catch (IOException e) { + throw new UaSerializationException(StatusCodes.Bad_DecodingError, e); + } + } + + @Override + public Matrix decodeEnumMatrix(String field) throws UaSerializationException { + return decodeMatrix(field, BuiltinDataType.Int32); + } + + @Override + public Matrix decodeStructMatrix(String field, NodeId dataTypeId) throws UaSerializationException { + DataTypeCodec codec = context.getDataTypeManager() + .getCodec(OpcUaDefaultJsonEncoding.ENCODING_NAME, dataTypeId); + + if (codec != null) { + try { + if (field != null) { + String nextName = nextName(); + if (!field.equals(nextName)) { + throw new UaSerializationException( + StatusCodes.Bad_DecodingError, + String.format("readStruct: %s != %s", field, nextName) + ); + } + } + + Object nestedArray = decodeNestedMultiDimensionalArrayStructValue(codec); + + return new Matrix(nestedArray); + } catch (IOException e) { + throw new UaSerializationException(StatusCodes.Bad_DecodingError, e); + } + } else { + throw new UaSerializationException( + StatusCodes.Bad_DecodingError, + "decodeStructMatrix: no codec registered: " + dataTypeId + ); + } + } + + @Override + public Matrix decodeStructMatrix(String field, ExpandedNodeId dataTypeId) throws UaSerializationException { + NodeId localDataTypeId = dataTypeId.toNodeId(context.getNamespaceTable()) + .orElseThrow(() -> new UaSerializationException( + StatusCodes.Bad_DecodingError, + "decodeStructMatrix: namespace not registered: " + dataTypeId + )); + + return decodeStructMatrix(field, localDataTypeId); + } + + private Object decodeNestedMultiDimensionalArrayBuiltinValue(int typeId) throws IOException { + if (jsonReader.peek() == JsonToken.BEGIN_ARRAY) { + jsonReader.beginArray(); + List elements = new ArrayList<>(); + while (jsonReader.peek() != JsonToken.END_ARRAY) { + elements.add(decodeNestedMultiDimensionalArrayBuiltinValue(typeId)); + } + jsonReader.endArray(); + + Object array = Array.newInstance(elements.get(0).getClass(), elements.size()); + for (int i = 0; i < elements.size(); i++) { + Array.set(array, i, elements.get(i)); + } + return array; + } else { + return readBuiltinTypeValue(null, typeId); + } + } + + private Object decodeNestedMultiDimensionalArrayStructValue(DataTypeCodec codec) throws IOException { + if (jsonReader.peek() == JsonToken.BEGIN_ARRAY) { + jsonReader.beginArray(); + List elements = new ArrayList<>(); + while (jsonReader.peek() != JsonToken.END_ARRAY) { + elements.add(decodeNestedMultiDimensionalArrayStructValue(codec)); + } + jsonReader.endArray(); + + Object array = Array.newInstance(elements.get(0).getClass(), elements.size()); + for (int i = 0; i < elements.size(); i++) { + Array.set(array, i, elements.get(i)); + } + return array; + } else { + return decodeStruct(null, codec); + } + } + /** * This ugly hack is so `readArray` can "push back" the next name it reads if it doesn't match * the expected field name, because that probably means it was omitted due to being null. diff --git a/opc-ua-stack/encoding-json/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/json/OpcUaJsonEncoder.java b/opc-ua-stack/encoding-json/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/json/OpcUaJsonEncoder.java index 897c87ced..ea305f94a 100644 --- a/opc-ua-stack/encoding-json/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/json/OpcUaJsonEncoder.java +++ b/opc-ua-stack/encoding-json/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/json/OpcUaJsonEncoder.java @@ -16,6 +16,7 @@ import java.io.Writer; import java.lang.reflect.Array; import java.time.format.DateTimeFormatter; +import java.util.Arrays; import java.util.Base64; import java.util.Stack; import java.util.UUID; @@ -37,6 +38,7 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject; import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; +import org.eclipse.milo.opcua.stack.core.types.builtin.Matrix; import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUInteger; import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; @@ -734,83 +736,135 @@ public void encodeVariant(String field, Variant value) throws UaSerializationExc jsonWriter.name(field); } - writeVariantValue(value.getValue()); + assert value.getValue() != null; + encodeVariantValue(value.getValue()); } catch (IOException e) { throw new UaSerializationException(StatusCodes.Bad_EncodingError, e); } } - private void writeVariantValue(Object value) throws IOException { - Class valueClass = getClass(value); + enum TypeHint {BUILTIN, ENUM, STRUCT, OPTION_SET} - int typeId; - if (UaStructuredType.class.isAssignableFrom(valueClass)) { - typeId = BuiltinDataType.ExtensionObject.getTypeId(); - - value = ExtensionObject.encode(encodingContext, (UaStructuredType) value); - } else if (UaEnumeratedType.class.isAssignableFrom(valueClass)) { - typeId = BuiltinDataType.Int32.getTypeId(); + private void encodeVariantValue(@NotNull Object value) throws IOException { + Class valueClass; + if (value instanceof Matrix) { + Matrix m = (Matrix) value; + if (m.getElements() == null) return; + valueClass = getClass(m.getElements()); + } else { + valueClass = getClass(value); + } - value = ((UaEnumeratedType) value).getValue(); + TypeHint typeHint = TypeHint.BUILTIN; + if (UaEnumeratedType.class.isAssignableFrom(valueClass)) { + typeHint = TypeHint.ENUM; + } else if (UaStructuredType.class.isAssignableFrom(valueClass)) { + typeHint = TypeHint.STRUCT; } else if (OptionSetUInteger.class.isAssignableFrom(valueClass)) { - Object optionSetValue = ((OptionSetUInteger) value).getValue(); - typeId = TypeUtil.getBuiltinTypeId(optionSetValue.getClass()); + typeHint = TypeHint.OPTION_SET; + } - value = optionSetValue; + int typeId; + if (typeHint == TypeHint.ENUM) { + typeId = BuiltinDataType.Int32.getTypeId(); + } else if (typeHint == TypeHint.STRUCT) { + typeId = BuiltinDataType.ExtensionObject.getTypeId(); + } else if (typeHint == TypeHint.OPTION_SET) { + // TODO this would fail on empty array + // would be better to have size-specific OptionSetUI subclasses, e.g. OptionSetUI8, OptionSetUI16, etc... + Object os = Array.get(value, 0); + Object osv = ((OptionSetUInteger) os).getValue(); + typeId = TypeUtil.getBuiltinTypeId(osv.getClass()); } else { typeId = TypeUtil.getBuiltinTypeId(valueClass); } - if (typeId == -1) { - throw new UaSerializationException( - StatusCodes.Bad_EncodingError, - "not a built-in type: " + value.getClass() - ); - } + if (value.getClass().isArray()) { + if (reversible) { + jsonWriter.beginObject(); + jsonWriter.name("Type").value(typeId); + jsonWriter.name("Body"); + } - if (reversible) { - jsonWriter.beginObject(); - jsonWriter.name("Type").value(typeId); - } + int length = Array.getLength(value); + jsonWriter.beginArray(); + for (int i = 0; i < length; i++) { + Object o = Array.get(value, i); - if (!value.getClass().isArray()) { - String field = reversible ? "Body" : null; - writeBuiltinTypeValue(field, typeId, value); - } else { - int[] dimensions = ArrayUtil.getDimensions(value); + encodeVariantBodyValue(o, typeHint, typeId); + } + jsonWriter.endArray(); if (reversible) { + jsonWriter.endObject(); + } + } else if (value instanceof Matrix) { + if (reversible) { + jsonWriter.beginObject(); + jsonWriter.name("Type").value(typeId); jsonWriter.name("Body"); } - if (dimensions.length == 1) { - int length = Array.getLength(value); - + Matrix m = (Matrix) value; + if (reversible) { + Object flatArray = m.getElements(); + int length = Array.getLength(flatArray); jsonWriter.beginArray(); for (int i = 0; i < length; i++) { - Object o = Array.get(value, i); + Object o = Array.get(flatArray, i); - writeBuiltinTypeValue(null, typeId, o); + encodeVariantBodyValue(o, typeHint, typeId); } jsonWriter.endArray(); - } else { - if (reversible) { - writeFlattenedMultiDimensionalVariantValue(typeId, value, dimensions, 0); - jsonWriter.name("Dimensions"); - jsonWriter.beginArray(); - for (int dimension : dimensions) { - jsonWriter.value(dimension); - } - jsonWriter.endArray(); - } else { - writeNestedMultiDimensionalVariantValue(typeId, value, dimensions, 0); + jsonWriter.name("Dimensions"); + jsonWriter.beginArray(); + for (int dimension : m.getDimensions()) { + jsonWriter.value(dimension); } + jsonWriter.endArray(); + jsonWriter.endObject(); + } else { + Object nestedArray = ArrayUtil.unflatten(m.getElements(), m.getDimensions()); + writeNestedMultiDimensionalVariantValue(typeId, nestedArray, m.getDimensions(), 0); + } + } else { + if (reversible) { + jsonWriter.beginObject(); + jsonWriter.name("Type").value(typeId); + jsonWriter.name("Body"); + } + + encodeVariantBodyValue(value, typeHint, typeId); + + if (reversible) { + jsonWriter.endObject(); } } + } - if (reversible) { - jsonWriter.endObject(); + private void encodeVariantBodyValue(Object value, TypeHint typeHint, int typeId) { + switch (typeHint) { + case BUILTIN: { + encodeBuiltinTypeValue(null, typeId, value); + break; + } + case ENUM: { + Object enumValue = ((UaEnumeratedType) value).getValue(); + encodeBuiltinTypeValue(null, typeId, enumValue); + break; + } + case STRUCT: { + UaStructuredType struct = (UaStructuredType) value; + ExtensionObject xo = ExtensionObject.encode(encodingContext, struct); + encodeBuiltinTypeValue(null, typeId, xo); + break; + } + case OPTION_SET: { + Object optionSetValue = ((OptionSetUInteger) value).getValue(); + encodeBuiltinTypeValue(null, typeId, optionSetValue); + break; + } } } @@ -834,7 +888,7 @@ private void writeFlattenedMultiDimensionalVariantValue( } else if (dimensionIndex == dimensions.length - 1) { for (int i = 0; i < dimensions[dimensionIndex]; i++) { Object e = Array.get(value, i); - writeBuiltinTypeValue(null, typeId, e); + encodeBuiltinTypeValue(null, typeId, e); } } else { for (int i = 0; i < dimensions[dimensionIndex]; i++) { @@ -858,7 +912,7 @@ private void writeNestedMultiDimensionalVariantValue( jsonWriter.beginArray(); for (int i = 0; i < dimensions[dimensionIndex]; i++) { Object e = Array.get(value, i); - writeBuiltinTypeValue(null, typeId, e); + encodeBuiltinTypeValue(null, typeId, e); } jsonWriter.endArray(); } else { @@ -871,7 +925,7 @@ private void writeNestedMultiDimensionalVariantValue( } } - private void writeBuiltinTypeValue(String field, int typeId, Object value) throws UaSerializationException { + private void encodeBuiltinTypeValue(String field, int typeId, Object value) throws UaSerializationException { contextPush(OpcUaJsonEncoder.EncodingContext.BUILTIN); switch (typeId) { case 1: @@ -1215,18 +1269,24 @@ public void encodeStructArray(String field, Object[] value, NodeId dataTypeId) t } @Override - public void encodeStructArray(String field, Object[] value, ExpandedNodeId dataTypeId) throws UaSerializationException { + public void encodeStructArray( + String field, + Object[] value, + ExpandedNodeId dataTypeId + ) throws UaSerializationException { + NodeId localDataTypeId = dataTypeId.toNodeId(encodingContext.getNamespaceTable()) .orElseThrow(() -> new UaSerializationException( StatusCodes.Bad_EncodingError, - "no codec registered: " + dataTypeId + "encodeStructArray: namespace not registered: " + dataTypeId )); encodeStructArray(field, value, localDataTypeId); } @Override - public void encodeArray(String field, T[] values, BiConsumer encoder) throws UaSerializationException { + public void encodeArray(String field, T[] values, BiConsumer encoder) throws + UaSerializationException { if (values == null) { return; } @@ -1253,4 +1313,188 @@ public void encodeArray(String field, T[] values, BiConsumer enco } } + @Override + public void encodeMatrix(String field, Matrix value) throws UaSerializationException { + try { + EncodingContext context = contextPeek(); + if (!reversible || context == OpcUaJsonEncoder.EncodingContext.BUILTIN || (value != null && value.isNotNull())) { + if (field != null) { + jsonWriter.name(field); + } + + Object flatArray = value.getElements(); + if (flatArray == null) { + try { + jsonWriter.nullValue(); + } catch (IOException e) { + throw new UaSerializationException(StatusCodes.Bad_EncodingError, e); + } + } else { + int[] dimensions = value.getDimensions(); + BuiltinDataType builtinDataType = value.getBuiltinDataType().orElseThrow(); + try { + encodeFlatArrayAsNested(flatArray, dimensions, builtinDataType, 0); + } catch (IOException e) { + throw new UaSerializationException(StatusCodes.Bad_EncodingError, e); + } + } + } + } catch (IOException e) { + throw new UaSerializationException(StatusCodes.Bad_EncodingError, e); + } + } + + @Override + public void encodeEnumMatrix(String field, Matrix value) throws UaSerializationException { + try { + EncodingContext context = contextPeek(); + if (!reversible || context == OpcUaJsonEncoder.EncodingContext.BUILTIN || (value != null && value.isNotNull())) { + if (field != null) { + jsonWriter.name(field); + } + + Object flatArray = value.getElements(); + if (flatArray == null) { + try { + jsonWriter.nullValue(); + } catch (IOException e) { + throw new UaSerializationException(StatusCodes.Bad_EncodingError, e); + } + } else { + int[] dimensions = value.getDimensions(); + + try { + encodeFlatEnumArrayAsNested((UaEnumeratedType[]) flatArray, dimensions, 0); + } catch (IOException e) { + throw new UaSerializationException(StatusCodes.Bad_EncodingError, e); + } + } + } + } catch (IOException e) { + throw new UaSerializationException(StatusCodes.Bad_EncodingError, e); + } + } + + @Override + public void encodeStructMatrix(String field, Matrix value, NodeId dataTypeId) throws UaSerializationException { + try { + EncodingContext context = contextPeek(); + if (!reversible || context == OpcUaJsonEncoder.EncodingContext.BUILTIN || (value != null && value.isNotNull())) { + if (field != null) { + jsonWriter.name(field); + } + + Object flatArray = value.getElements(); + if (flatArray == null) { + try { + jsonWriter.nullValue(); + } catch (IOException e) { + throw new UaSerializationException(StatusCodes.Bad_EncodingError, e); + } + } else { + int[] dimensions = value.getDimensions(); + + try { + encodeFlatStructArrayAsNested(flatArray, dataTypeId, dimensions, 0); + } catch (IOException e) { + throw new UaSerializationException(StatusCodes.Bad_EncodingError, e); + } + } + } + } catch (IOException e) { + throw new UaSerializationException(StatusCodes.Bad_EncodingError, e); + } + } + + @Override + public void encodeStructMatrix(String field, Matrix value, ExpandedNodeId dataTypeId) throws UaSerializationException { + NodeId localDataTypeId = dataTypeId.toNodeId(encodingContext.getNamespaceTable()) + .orElseThrow(() -> new UaSerializationException( + StatusCodes.Bad_EncodingError, + "encodeStructArray: namespace not registered: " + dataTypeId + )); + + encodeStructMatrix(field, value, localDataTypeId); + } + + private void encodeFlatArrayAsNested( + Object value, + int[] dimensions, + BuiltinDataType builtinDataType, + int offset + ) throws IOException { + + if (dimensions.length == 1) { + jsonWriter.beginArray(); + for (int i = 0; i < dimensions[0]; i++) { + Object e = Array.get(value, offset + i); + encodeBuiltinTypeValue(null, builtinDataType.getTypeId(), e); + } + jsonWriter.endArray(); + } else { + jsonWriter.beginArray(); + int[] tail = Arrays.copyOfRange(dimensions, 1, dimensions.length); + for (int i = 0; i < dimensions[0]; i++) { + encodeFlatArrayAsNested(value, tail, builtinDataType, offset + i * length(tail)); + } + jsonWriter.endArray(); + } + } + + private void encodeFlatEnumArrayAsNested( + UaEnumeratedType[] value, + int[] dimensions, + int offset + ) throws IOException { + + if (dimensions.length == 1) { + jsonWriter.beginArray(); + for (int i = 0; i < dimensions[0]; i++) { + Object e = Array.get(value, offset + i); + encodeEnum(null, (UaEnumeratedType) e); + } + jsonWriter.endArray(); + } else { + jsonWriter.beginArray(); + int[] tail = Arrays.copyOfRange(dimensions, 1, dimensions.length); + for (int i = 0; i < dimensions[0]; i++) { + encodeFlatEnumArrayAsNested(value, tail, offset + i * length(tail)); + } + jsonWriter.endArray(); + } + } + + private void encodeFlatStructArrayAsNested( + Object value, + NodeId dataTypeId, + int[] dimensions, + int offset + ) throws IOException { + + if (dimensions.length == 1) { + jsonWriter.beginArray(); + for (int i = 0; i < dimensions[0]; i++) { + Object e = Array.get(value, offset + i); + encodeStruct(null, e, dataTypeId); + } + jsonWriter.endArray(); + } else { + jsonWriter.beginArray(); + int[] tail = Arrays.copyOfRange(dimensions, 1, dimensions.length); + for (int i = 0; i < dimensions[0]; i++) { + encodeFlatStructArrayAsNested(value, dataTypeId, tail, offset + i * length(tail)); + } + jsonWriter.endArray(); + } + } + + private static int length(int[] tail) { + int product = 1; + for (int aTail : tail) { + product *= aTail; + } + return product; + } + + } diff --git a/opc-ua-stack/encoding-json/src/test/java/org/eclipse/milo/opcua/stack/core/encoding/json/OpcUaJsonDecoderTest.java b/opc-ua-stack/encoding-json/src/test/java/org/eclipse/milo/opcua/stack/core/encoding/json/OpcUaJsonDecoderTest.java index cd54d4cc9..ab3a7316b 100644 --- a/opc-ua-stack/encoding-json/src/test/java/org/eclipse/milo/opcua/stack/core/encoding/json/OpcUaJsonDecoderTest.java +++ b/opc-ua-stack/encoding-json/src/test/java/org/eclipse/milo/opcua/stack/core/encoding/json/OpcUaJsonDecoderTest.java @@ -18,6 +18,7 @@ import java.util.Random; import java.util.UUID; +import org.eclipse.milo.opcua.stack.core.BuiltinDataType; import org.eclipse.milo.opcua.stack.core.NodeIds; import org.eclipse.milo.opcua.stack.core.StatusCodes; import org.eclipse.milo.opcua.stack.core.encoding.EncodingContext; @@ -28,6 +29,7 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject; import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; +import org.eclipse.milo.opcua.stack.core.types.builtin.Matrix; import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode; @@ -43,6 +45,7 @@ import org.eclipse.milo.opcua.stack.core.types.structured.ReadRequest; import org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId; import org.eclipse.milo.opcua.stack.core.types.structured.RequestHeader; +import org.eclipse.milo.opcua.stack.core.types.structured.XVType; import org.junit.jupiter.api.Test; import static org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.Unsigned.uint; @@ -344,7 +347,7 @@ void readByteString() throws IOException { decoder.reset(new StringReader(String.format("\"%s\"", Base64.getEncoder().encodeToString(emptyBytes)))); assertEquals(ByteString.of(emptyBytes), decoder.decodeByteString(null)); - byte[] randomBytes = randomBytes(16); + byte[] randomBytes = randomBytes16(); decoder.reset(new StringReader(String.format("\"%s\"", Base64.getEncoder().encodeToString(randomBytes)))); assertEquals(ByteString.of(randomBytes), decoder.decodeByteString(null)); @@ -408,7 +411,7 @@ void readNodeId() throws IOException { assertEquals(nodeId, decoder.decodeNodeId(null)); // IdType == ByteString, Namespace = 0 - ByteString bs = ByteString.of(randomBytes(16)); + ByteString bs = ByteString.of(randomBytes16()); nodeId = new NodeId(0, bs); decoder.reset(new StringReader("{\"IdType\":3,\"Id\":\"" + Base64.getEncoder().encodeToString(bs.bytesOrEmpty()) + "\"}")); assertEquals(nodeId, decoder.decodeNodeId(null)); @@ -639,10 +642,10 @@ void readVariant() throws IOException { assertEquals(new Variant(value1d), decoder.decodeVariant(null)); decoder.reset(new StringReader("{\"Type\":6,\"Body\":[0,2,3,1,3,4],\"Dimensions\":[2,3]}")); - assertEquals(new Variant(value2d), decoder.decodeVariant(null)); + assertEquals(new Variant(Matrix.ofInt32(value2d)), decoder.decodeVariant(null)); decoder.reset(new StringReader("{\"Type\":6,\"Body\":[0,1,2,3,4,5,6,7],\"Dimensions\":[2,2,2]}")); - assertEquals(new Variant(value3d), decoder.decodeVariant(null)); + assertEquals(new Variant(Matrix.ofInt32(value3d)), decoder.decodeVariant(null)); decoder.reset(new StringReader("{\"foo\":{\"Type\":1,\"Body\":true}}")); decoder.jsonReader.beginObject(); @@ -746,9 +749,77 @@ void readStruct() throws IOException { assertEquals(struct, decoder.decodeStruct(null, Argument.TYPE_ID)); } - private static byte[] randomBytes(int length) { + @Test + void decodeMatrix() throws IOException { + var decoder = new OpcUaJsonDecoder(context, new StringReader("")); + + var matrix2d = new Matrix(new Integer[][]{ + new Integer[]{0, 1}, + new Integer[]{2, 3} + }); + + var matrix3d = new Matrix(new Integer[][][]{ + new Integer[][]{ + {0, 1}, {2, 3} + }, + new Integer[][]{ + {4, 5}, {6, 7} + } + }); + + decoder.reset(new StringReader("[[0,1],[2,3]]")); + assertEquals(matrix2d, decoder.decodeMatrix(null, BuiltinDataType.Int32)); + + decoder.reset(new StringReader("[[[0,1],[2,3]],[[4,5],[6,7]]]")); + assertEquals(matrix3d, decoder.decodeMatrix(null, BuiltinDataType.Int32)); + + decoder.reset(new StringReader("{\"foo\":[[0,1],[2,3]]}")); + decoder.jsonReader.beginObject(); + assertEquals(matrix2d, decoder.decodeMatrix("foo", BuiltinDataType.Int32)); + decoder.jsonReader.endObject(); + + decoder.reset(new StringReader("{\"foo\":[[[0,1],[2,3]],[[4,5],[6,7]]]}")); + decoder.jsonReader.beginObject(); + assertEquals(matrix3d, decoder.decodeMatrix("foo", BuiltinDataType.Int32)); + decoder.jsonReader.endObject(); + } + + @Test + void decodeEnumMatrix() throws Exception { + var decoder = new OpcUaJsonDecoder(context, new StringReader("")); + + decoder.reset(new StringReader("[[0,1],[2,3]]")); + assertEquals(Matrix.ofInt32(new Integer[][]{{0, 1}, {2, 3}}), decoder.decodeEnumMatrix(null)); + + decoder.reset(new StringReader("{\"foo\":[[0,1],[2,3]]}")); + decoder.jsonReader.beginObject(); + assertEquals(Matrix.ofInt32(new Integer[][]{{0, 1}, {2, 3}}), decoder.decodeEnumMatrix("foo")); + decoder.jsonReader.endObject(); + } + + @Test + void decodeStructMatrix() throws Exception { + var decoder = new OpcUaJsonDecoder(context, new StringReader("")); + + XVType[][] xvTypes = new XVType[][]{ + new XVType[]{new XVType(0.0d, 1.0f), new XVType(2.0d, 3.0f)}, + new XVType[]{new XVType(4.0d, 5.0f), new XVType(6.0d, 7.0f)} + }; + + var matrix = new Matrix(xvTypes); + + decoder.reset(new StringReader("[[{\"X\":0.0,\"Value\":1.0},{\"X\":2.0,\"Value\":3.0}],[{\"X\":4.0,\"Value\":5.0},{\"X\":6.0,\"Value\":7.0}]]")); + assertEquals(matrix, decoder.decodeStructMatrix(null, XVType.TYPE_ID)); + + decoder.reset(new StringReader("{\"foo\":[[{\"X\":0.0,\"Value\":1.0},{\"X\":2.0,\"Value\":3.0}],[{\"X\":4.0,\"Value\":5.0},{\"X\":6.0,\"Value\":7.0}]]}")); + decoder.jsonReader.beginObject(); + assertEquals(matrix, decoder.decodeStructMatrix("foo", XVType.TYPE_ID)); + decoder.jsonReader.endObject(); + } + + private static byte[] randomBytes16() { var random = new Random(); - var bs = new byte[length]; + var bs = new byte[16]; random.nextBytes(bs); return bs; } diff --git a/opc-ua-stack/encoding-json/src/test/java/org/eclipse/milo/opcua/stack/core/encoding/json/OpcUaJsonEncoderTest.java b/opc-ua-stack/encoding-json/src/test/java/org/eclipse/milo/opcua/stack/core/encoding/json/OpcUaJsonEncoderTest.java index e239233fd..d214d04fc 100644 --- a/opc-ua-stack/encoding-json/src/test/java/org/eclipse/milo/opcua/stack/core/encoding/json/OpcUaJsonEncoderTest.java +++ b/opc-ua-stack/encoding-json/src/test/java/org/eclipse/milo/opcua/stack/core/encoding/json/OpcUaJsonEncoderTest.java @@ -27,6 +27,7 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject; import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; +import org.eclipse.milo.opcua.stack.core.types.builtin.Matrix; import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode; @@ -42,6 +43,7 @@ import org.eclipse.milo.opcua.stack.core.types.structured.ReadRequest; import org.eclipse.milo.opcua.stack.core.types.structured.ReadValueId; import org.eclipse.milo.opcua.stack.core.types.structured.RequestHeader; +import org.eclipse.milo.opcua.stack.core.types.structured.XVType; import org.eclipse.milo.opcua.stack.core.util.Namespaces; import org.junit.jupiter.api.Test; @@ -870,6 +872,10 @@ public void writeVariant() { encoder.reset(writer = new StringWriter()); encoder.encodeVariant(null, new Variant(new Variant[]{new Variant("foo"), new Variant("bar")})); assertEquals("{\"Type\":24,\"Body\":[{\"Type\":12,\"Body\":\"foo\"},{\"Type\":12,\"Body\":\"bar\"}]}", writer.toString()); + + encoder.reset(writer = new StringWriter()); + encoder.encodeVariant(null, new Variant(Matrix.ofInt32(new int[][]{{0, 1}, {2, 3}}))); + assertEquals("{\"Type\":6,\"Body\":[0,1,2,3],\"Dimensions\":[2,2]}", writer.toString()); //endregion //region non-reversible @@ -910,11 +916,11 @@ public void writeVariant() { assertEquals("{\"Type\":6,\"Body\":[0,1,2,3]}", writer.toString()); encoder.reset(writer = new StringWriter()); - encoder.encodeVariant(null, new Variant(value2d)); + encoder.encodeVariant(null, new Variant(Matrix.ofInt32(value2d))); assertEquals("{\"Type\":6,\"Body\":[0,2,3,1,3,4],\"Dimensions\":[2,3]}", writer.toString()); encoder.reset(writer = new StringWriter()); - encoder.encodeVariant(null, new Variant(value3d)); + encoder.encodeVariant(null, new Variant(Matrix.ofInt32(value3d))); assertEquals("{\"Type\":6,\"Body\":[0,1,2,3,4,5,6,7],\"Dimensions\":[2,2,2]}", writer.toString()); //endregion @@ -926,11 +932,11 @@ public void writeVariant() { assertEquals("[0,1,2,3]", writer.toString()); encoder.reset(writer = new StringWriter()); - encoder.encodeVariant(null, new Variant(value2d)); + encoder.encodeVariant(null, new Variant(Matrix.ofInt32(value2d))); assertEquals("[[0,2,3],[1,3,4]]", writer.toString()); encoder.reset(writer = new StringWriter()); - encoder.encodeVariant(null, new Variant(value3d)); + encoder.encodeVariant(null, new Variant(Matrix.ofInt32(value3d))); assertEquals("[[[0,1],[2,3]],[[4,5],[6,7]]]", writer.toString()); //endregion } @@ -978,7 +984,6 @@ public void writeDiagnosticInfo() throws IOException { public void writeMessage() { var writer = new StringWriter(); var encoder = new OpcUaJsonEncoder(context, writer); - encoder.encodingContext = new TestEncodingContext(); var message = new ReadRequest( new RequestHeader( @@ -1061,7 +1066,6 @@ public void writeStruct() { public void writeBooleanArray() throws IOException { var writer = new StringWriter(); var encoder = new OpcUaJsonEncoder(context, writer); - encoder.encodingContext = new TestEncodingContext(); encoder.reset(writer = new StringWriter()); encoder.encodeBooleanArray(null, null); @@ -1092,6 +1096,80 @@ public void writeBooleanArray() throws IOException { assertEquals("{}", writer.toString()); } + @Test + void encodeMatrix() throws IOException { + var writer = new StringWriter(); + var encoder = new OpcUaJsonEncoder(context, writer); + + var matrix2d = new Matrix(new Integer[][]{ + new Integer[]{0, 1}, + new Integer[]{2, 3} + }); + + var matrix3d = new Matrix(new Integer[][][]{ + new Integer[][]{ + {0, 1}, {2, 3} + }, + new Integer[][]{ + {4, 5}, {6, 7} + } + }); + + encoder.reset(writer = new StringWriter()); + encoder.encodeMatrix(null, matrix2d); + assertEquals("[[0,1],[2,3]]", writer.toString()); + + encoder.reset(writer = new StringWriter()); + encoder.encodeMatrix(null, matrix3d); + assertEquals("[[[0,1],[2,3]],[[4,5],[6,7]]]", writer.toString()); + + encoder.reset(writer = new StringWriter()); + encoder.jsonWriter.beginObject(); + encoder.encodeMatrix("foo", matrix2d); + encoder.jsonWriter.endObject(); + assertEquals("{\"foo\":[[0,1],[2,3]]}", writer.toString()); + + encoder.reset(writer = new StringWriter()); + encoder.jsonWriter.beginObject(); + encoder.encodeMatrix("foo", matrix3d); + encoder.jsonWriter.endObject(); + assertEquals("{\"foo\":[[[0,1],[2,3]],[[4,5],[6,7]]]}", writer.toString()); + } + + @Test + void encodeEnumMatrix() { + var writer = new StringWriter(); + var encoder = new OpcUaJsonEncoder(context, writer); + + var applicationTypes = new ApplicationType[][]{ + new ApplicationType[]{ApplicationType.Server, ApplicationType.Client}, + new ApplicationType[]{ApplicationType.ClientAndServer, ApplicationType.DiscoveryServer} + }; + + var matrix = new Matrix(applicationTypes); + + encoder.reset(writer = new StringWriter()); + encoder.encodeEnumMatrix(null, matrix); + assertEquals("[[0,1],[2,3]]", writer.toString()); + } + + @Test + void encodeStructMatrix() { + var writer = new StringWriter(); + var encoder = new OpcUaJsonEncoder(context, writer); + + XVType[][] xvTypes = new XVType[][]{ + new XVType[]{new XVType(0.0d, 1.0f), new XVType(2.0d, 3.0f)}, + new XVType[]{new XVType(4.0d, 5.0f), new XVType(6.0d, 7.0f)} + }; + + var matrix = new Matrix(xvTypes); + + encoder.reset(writer = new StringWriter()); + encoder.encodeStructMatrix(null, matrix, XVType.TYPE_ID); + assertEquals("[[{\"Value\":1.0},{\"X\":2.0,\"Value\":3.0}],[{\"X\":4.0,\"Value\":5.0},{\"X\":6.0,\"Value\":7.0}]]", writer.toString()); + } + private static byte[] randomBytes(int length) { var random = new Random(); var bs = new byte[length]; diff --git a/opc-ua-stack/encoding-xml/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/xml/OpcUaXmlDecoder.java b/opc-ua-stack/encoding-xml/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/xml/OpcUaXmlDecoder.java index c3510fc31..be3c3e0af 100644 --- a/opc-ua-stack/encoding-xml/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/xml/OpcUaXmlDecoder.java +++ b/opc-ua-stack/encoding-xml/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/xml/OpcUaXmlDecoder.java @@ -33,6 +33,7 @@ import com.google.common.io.CharStreams; import jakarta.xml.bind.DatatypeConverter; +import org.eclipse.milo.opcua.stack.core.BuiltinDataType; import org.eclipse.milo.opcua.stack.core.StatusCodes; import org.eclipse.milo.opcua.stack.core.UaRuntimeException; import org.eclipse.milo.opcua.stack.core.UaSerializationException; @@ -48,6 +49,7 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject; import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; +import org.eclipse.milo.opcua.stack.core.types.builtin.Matrix; import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode; @@ -1254,6 +1256,26 @@ public Object[] decodeStructArray(String field, ExpandedNodeId dataTypeId) throw } } + @Override + public Matrix decodeMatrix(String field, BuiltinDataType builtinDataType) throws UaSerializationException { + return null; + } + + @Override + public Matrix decodeEnumMatrix(String field) { + return null; + } + + @Override + public Matrix decodeStructMatrix(String field, NodeId dataTypeId) { + return null; + } + + @Override + public Matrix decodeStructMatrix(String field, ExpandedNodeId dataTypeId) { + return null; + } + private void checkArrayLength(int length) throws UaSerializationException { if (length > context.getEncodingLimits().getMaxMessageSize()) { throw new UaSerializationException( diff --git a/opc-ua-stack/encoding-xml/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/xml/OpcUaXmlEncoder.java b/opc-ua-stack/encoding-xml/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/xml/OpcUaXmlEncoder.java index 7c2255151..4ce652b6c 100644 --- a/opc-ua-stack/encoding-xml/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/xml/OpcUaXmlEncoder.java +++ b/opc-ua-stack/encoding-xml/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/xml/OpcUaXmlEncoder.java @@ -30,6 +30,7 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject; import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; +import org.eclipse.milo.opcua.stack.core.types.builtin.Matrix; import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode; @@ -395,4 +396,24 @@ public void encodeArray( } + @Override + public void encodeMatrix(String field, Matrix value) throws UaSerializationException { + + } + + @Override + public void encodeEnumMatrix(String field, Matrix value) throws UaSerializationException { + + } + + @Override + public void encodeStructMatrix(String field, Matrix value, NodeId dataTypeId) throws UaSerializationException { + + } + + @Override + public void encodeStructMatrix(String field, Matrix value, ExpandedNodeId dataTypeId) throws UaSerializationException { + + } + } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/BuiltinDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/BuiltinDataType.java index 62640a323..a66242874 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/BuiltinDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/BuiltinDataType.java @@ -131,6 +131,16 @@ public static Class getBackingClass(ExpandedNodeId typeId) { return null; } + public static @Nullable BuiltinDataType fromTypeId(int typeId) { + // TODO turn this into a lookup + for (BuiltinDataType builtinDataType : values()) { + if (builtinDataType.typeId == typeId) { + return builtinDataType; + } + } + return null; + } + @Nullable public static BuiltinDataType fromBackingClass(Class backingClass) { NodeId nodeId = BackingClassesByNodeId.inverse().get(maybeBoxPrimitive(backingClass)); @@ -166,6 +176,10 @@ public static boolean isBuiltin(ExpandedNodeId typeId) { return BuiltinDataType.fromNodeId(typeId) != null; } + public static boolean isBuiltin(Class clazz) { + return BackingClassesById.inverse().containsKey(maybeBoxPrimitive(clazz)); + } + private static Class maybeBoxPrimitive(Class clazz) { if (clazz.isPrimitive()) { if (clazz == boolean.class) { diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/UaDecoder.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/UaDecoder.java index 37e4567ab..a6c80af9b 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/UaDecoder.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/UaDecoder.java @@ -13,6 +13,7 @@ import java.util.UUID; import java.util.function.Function; +import org.eclipse.milo.opcua.stack.core.BuiltinDataType; import org.eclipse.milo.opcua.stack.core.UaSerializationException; import org.eclipse.milo.opcua.stack.core.types.UaMessageType; import org.eclipse.milo.opcua.stack.core.types.builtin.ByteString; @@ -22,6 +23,7 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject; import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; +import org.eclipse.milo.opcua.stack.core.types.builtin.Matrix; import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode; @@ -152,4 +154,12 @@ public interface UaDecoder { T[] decodeArray(String field, Function decoder, Class clazz) throws UaSerializationException; + Matrix decodeMatrix(String field, BuiltinDataType builtinDataType) throws UaSerializationException; + + Matrix decodeEnumMatrix(String field) throws UaSerializationException; + + Matrix decodeStructMatrix(String field, NodeId dataTypeId) throws UaSerializationException; + + Matrix decodeStructMatrix(String field, ExpandedNodeId dataTypeId) throws UaSerializationException; + } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/UaEncoder.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/UaEncoder.java index 3854aded8..eade095f0 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/UaEncoder.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/UaEncoder.java @@ -23,6 +23,7 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject; import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; +import org.eclipse.milo.opcua.stack.core.types.builtin.Matrix; import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode; @@ -153,4 +154,12 @@ public interface UaEncoder { void encodeArray(String field, T[] values, BiConsumer encoder) throws UaSerializationException; + void encodeMatrix(String field, Matrix value) throws UaSerializationException; + + void encodeEnumMatrix(String field, Matrix value) throws UaSerializationException; + + void encodeStructMatrix(String field, Matrix value, NodeId dataTypeId) throws UaSerializationException; + + void encodeStructMatrix(String field, Matrix value, ExpandedNodeId dataTypeId) throws UaSerializationException; + } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/binary/OpcUaBinaryDecoder.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/binary/OpcUaBinaryDecoder.java index 6e9b100f3..f1d63526e 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/binary/OpcUaBinaryDecoder.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/binary/OpcUaBinaryDecoder.java @@ -20,6 +20,7 @@ import io.netty.buffer.ByteBuf; import io.netty.util.ByteProcessor; +import org.eclipse.milo.opcua.stack.core.BuiltinDataType; import org.eclipse.milo.opcua.stack.core.StatusCodes; import org.eclipse.milo.opcua.stack.core.UaSerializationException; import org.eclipse.milo.opcua.stack.core.encoding.DataTypeCodec; @@ -33,6 +34,7 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject; import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; +import org.eclipse.milo.opcua.stack.core.types.builtin.Matrix; import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode; @@ -42,7 +44,6 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.ULong; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UShort; -import org.eclipse.milo.opcua.stack.core.util.ArrayUtil; import org.eclipse.milo.opcua.stack.core.util.TypeUtil; import org.jetbrains.annotations.Nullable; @@ -398,6 +399,7 @@ public Variant decodeVariant() throws UaSerializationException { } else { checkArrayLength(length); + // TODO speed this up by switching on BuiltinDataType instead of using reflection Object flatArray = Array.newInstance(backingClass, length); for (int i = 0; i < length; i++) { @@ -407,9 +409,15 @@ public Variant decodeVariant() throws UaSerializationException { } int[] dimensions = dimensionsEncoded ? decodeDimensions() : new int[]{length}; - Object array = dimensions.length > 1 ? ArrayUtil.unflatten(flatArray, dimensions) : flatArray; - return new Variant(array); + Object value; + if (dimensions.length > 1) { + value = new Matrix(flatArray, dimensions, BuiltinDataType.fromTypeId(typeId)); + } else { + value = flatArray; + } + + return new Variant(value); } } else { Object value = decodeBuiltinType(typeId); @@ -1225,4 +1233,105 @@ public T[] decodeArray( } } + @Override + public Matrix decodeMatrix(String field, BuiltinDataType builtinDataType) throws UaSerializationException { + int[] dimensions = decodeMatrixDimensions(); + if (dimensions == null) return null; + + int length = 1; + for (int d : dimensions) { + checkArrayLength(d); + if (d > 0) { + length *= d; + } else { + length = 0; + } + } + checkArrayLength(length); + + // TODO speed this up by switching on BuiltinDataType instead of using reflection + Class backingClass = builtinDataType.getBackingClass(); + Object flatArray = Array.newInstance(backingClass, length); + + for (int i = 0; i < length; i++) { + Object element = decodeBuiltinType(builtinDataType.getTypeId()); + + Array.set(flatArray, i, element); + } + + return new Matrix(flatArray, dimensions, builtinDataType); + } + + + @Override + public Matrix decodeEnumMatrix(String field) throws UaSerializationException { + return decodeMatrix(field, BuiltinDataType.Int32); + } + + @Override + public Matrix decodeStructMatrix(String field, NodeId dataTypeId) throws UaSerializationException { + int[] dimensions = decodeMatrixDimensions(); + if (dimensions == null) return null; + + int length = 1; + for (int d : dimensions) { + checkArrayLength(d); + if (d > 0) { + length *= d; + } else { + length = 0; + } + } + checkArrayLength(length); + + DataTypeCodec codec = context.getDataTypeManager() + .getCodec(OpcUaDefaultBinaryEncoding.ENCODING_NAME, dataTypeId); + + if (codec == null) { + throw new UaSerializationException( + StatusCodes.Bad_DecodingError, + "no codec registered: " + dataTypeId + ); + } + + Class clazz = codec.getType(); + Object flatArray = Array.newInstance(clazz, length); + + for (int i = 0; i < length; i++) { + Object value = codec.decode(context, this); + + Array.set(flatArray, i, value); + } + + return new Matrix(flatArray, dimensions, BuiltinDataType.ExtensionObject); + } + + @Override + public Matrix decodeStructMatrix(String field, ExpandedNodeId dataTypeId) throws UaSerializationException { + NodeId localDataTypeId = dataTypeId.toNodeId(context.getNamespaceTable()) + .orElseThrow(() -> new UaSerializationException( + StatusCodes.Bad_DecodingError, + "decodeStructMatrix: namespace not registered: " + dataTypeId + )); + + return decodeStructMatrix(field, localDataTypeId); + } + + private int @Nullable [] decodeMatrixDimensions() { + int length = decodeInt32(null); + + if (length == -1) { + return null; + } else { + checkArrayLength(length); + + int[] dimensions = new int[length]; + for (int i = 0; i < length; i++) { + dimensions[i] = decodeInt32(null); + } + + return dimensions; + } + } + } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/binary/OpcUaBinaryEncoder.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/binary/OpcUaBinaryEncoder.java index f32bf9e4c..55b4bc443 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/binary/OpcUaBinaryEncoder.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/encoding/binary/OpcUaBinaryEncoder.java @@ -13,6 +13,7 @@ import java.lang.reflect.Array; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import java.util.Arrays; import java.util.UUID; import java.util.function.BiConsumer; import java.util.function.Consumer; @@ -33,6 +34,7 @@ import org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject; import org.eclipse.milo.opcua.stack.core.types.builtin.LocalizedText; +import org.eclipse.milo.opcua.stack.core.types.builtin.Matrix; import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUInteger; import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; @@ -605,6 +607,13 @@ public void encodeVariant(Variant variant) throws UaSerializationException { } else if (OptionSetUInteger.class.isAssignableFrom(valueClass)) { valueClass = ((OptionSetUInteger) value).getValue().getClass(); optionSet = true; + } else if (Matrix.class.isAssignableFrom(valueClass)) { + Matrix m = (Matrix) value; + if (m.isNull()) { + buffer.writeByte(0); + return; + } + valueClass = ((Matrix) value).getBuiltinDataType().orElseThrow().getBackingClass(); } int typeId = TypeUtil.getBuiltinTypeId(valueClass); @@ -614,10 +623,8 @@ public void encodeVariant(Variant variant) throws UaSerializationException { .warn("Not a built-in type: {}", valueClass); } - if (value.getClass().isArray()) { - int[] dimensions = ArrayUtil.getDimensions(value); - - if (dimensions.length == 1) { + if (value.getClass().isArray() || value instanceof Matrix) { + if (value.getClass().isArray()) { buffer.writeByte(typeId | 0x80); int length = Array.getLength(value); @@ -629,14 +636,16 @@ public void encodeVariant(Variant variant) throws UaSerializationException { encodeValue(o, typeId, structure, enumeration, optionSet); } } else { + int[] dimensions = ((Matrix) value).getDimensions(); + buffer.writeByte(typeId | 0xC0); - Object flattened = ArrayUtil.flatten(value); - int length = Array.getLength(flattened); + Object elements = ((Matrix) value).getElements(); + int length = Array.getLength(elements); buffer.writeIntLE(length); for (int i = 0; i < length; i++) { - Object o = Array.get(flattened, i); + Object o = Array.get(elements, i); encodeValue(o, typeId, structure, enumeration, optionSet); } @@ -1147,4 +1156,110 @@ public void encodeArray( } } + @Override + public void encodeMatrix(String field, Matrix value) throws UaSerializationException { + Object elements = value.getElements(); + + if (elements == null) { + buffer.writeIntLE(-1); + return; + } + + int[] dimensions = value.getDimensions(); + assert dimensions.length > 1; + + boolean noZeroDimensions = true; + buffer.writeIntLE(dimensions.length); + for (int d : dimensions) { + if (d <= 0) noZeroDimensions = false; + buffer.writeIntLE(d); + } + + if (noZeroDimensions) { + int length = Array.getLength(elements); + assert length == Arrays.stream(dimensions).reduce(1, (left, right) -> left * right); + + int typeId = value.getBuiltinDataType().orElseThrow().getTypeId(); // won't throw, we checked for null + + for (int i = 0; i < length; i++) { + Object o = Array.get(elements, i); + + encodeValue(o, typeId, false, false, false); + } + } + } + + @Override + public void encodeEnumMatrix(String field, Matrix value) throws UaSerializationException { + Object elements = value.getElements(); + + if (elements == null) { + buffer.writeIntLE(-1); + return; + } + + int[] dimensions = value.getDimensions(); + assert dimensions.length > 1; + + boolean noZeroDimensions = true; + buffer.writeIntLE(dimensions.length); + for (int d : dimensions) { + if (d <= 0) noZeroDimensions = false; + buffer.writeIntLE(d); + } + + if (noZeroDimensions) { + int length = Array.getLength(elements); + assert length == Arrays.stream(dimensions).reduce(1, (left, right) -> left * right); + + for (int i = 0; i < length; i++) { + Object o = Array.get(elements, i); + + encodeEnum(null, (UaEnumeratedType) o); + } + } + } + + @Override + public void encodeStructMatrix(String field, Matrix value, NodeId dataTypeId) throws UaSerializationException { + Object elements = value.getElements(); + + if (elements == null) { + buffer.writeIntLE(-1); + return; + } + + int[] dimensions = value.getDimensions(); + assert dimensions.length > 1; + + boolean noZeroDimensions = true; + buffer.writeIntLE(dimensions.length); + for (int d : dimensions) { + if (d <= 0) noZeroDimensions = false; + buffer.writeIntLE(d); + } + + if (noZeroDimensions) { + int length = Array.getLength(elements); + assert length == Arrays.stream(dimensions).reduce(1, (left, right) -> left * right); + + for (int i = 0; i < length; i++) { + Object o = Array.get(elements, i); + + encodeStruct(null, o, dataTypeId); + } + } + } + + @Override + public void encodeStructMatrix(String field, Matrix value, ExpandedNodeId dataTypeId) throws UaSerializationException { + NodeId localDataTypeId = dataTypeId.toNodeId(context.getNamespaceTable()) + .orElseThrow(() -> new UaSerializationException( + StatusCodes.Bad_EncodingError, + "encodeStructArray: namespace not registered: " + dataTypeId + )); + + encodeStructMatrix(field, value, localDataTypeId); + } + } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/Matrix.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/Matrix.java new file mode 100644 index 000000000..57ead3e9d --- /dev/null +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/Matrix.java @@ -0,0 +1,957 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +package org.eclipse.milo.opcua.stack.core.types.builtin; + +import java.lang.reflect.Array; +import java.util.Arrays; +import java.util.Objects; +import java.util.Optional; +import java.util.StringJoiner; +import java.util.UUID; +import java.util.function.Function; + +import org.eclipse.milo.opcua.stack.core.BuiltinDataType; +import org.eclipse.milo.opcua.stack.core.types.UaEnumeratedType; +import org.eclipse.milo.opcua.stack.core.types.UaStructuredType; +import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UByte; +import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; +import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.ULong; +import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UShort; +import org.eclipse.milo.opcua.stack.core.util.ArrayUtil; +import org.jetbrains.annotations.Nullable; + +/** + * Matrix is a container for multidimensional array values. + *

+ * Allowed value types: + *

    + *
  • any builtin type
  • + *
  • UaStructuredType
  • + *
  • UaEnumeratedType
  • + *
  • OptionSetUInteger subclasses
  • + *
+ */ +public class Matrix { + + private final Object flatArray; + private final int[] dimensions; + private final BuiltinDataType builtinDataType; + + public Matrix(@Nullable Object nestedArray) { + if (nestedArray == null) { + this.flatArray = null; + this.dimensions = new int[0]; + this.builtinDataType = null; + } else { + this.flatArray = ArrayUtil.flatten(nestedArray); + this.dimensions = ArrayUtil.getDimensions(nestedArray); + this.builtinDataType = deriveBuiltinType(flatArray); + } + + assert flatArray == null || (dimensions.length > 1 && builtinDataType != null); + } + + public Matrix(Object flatArray, int[] dimensions) { + this.flatArray = flatArray; + this.dimensions = dimensions; + this.builtinDataType = deriveBuiltinType(flatArray); + + assert dimensions.length > 1 && builtinDataType != null; + } + + public Matrix(Object flatArray, int[] dimensions, BuiltinDataType builtinDataType) { + this.flatArray = flatArray; + this.dimensions = dimensions; + this.builtinDataType = builtinDataType; + + assert flatArray != null && dimensions.length > 1 && builtinDataType != null; + } + + private static BuiltinDataType deriveBuiltinType(Object flatArray) { + Class type = ArrayUtil.getType(flatArray); + + if (UaEnumeratedType.class.isAssignableFrom(type)) { + return BuiltinDataType.Int32; + } else if (UaStructuredType.class.isAssignableFrom(type)) { + return BuiltinDataType.ExtensionObject; + } else if (OptionSetUInteger.class.isAssignableFrom(type)) { + if (OptionSetUI8.class.isAssignableFrom(type)) { + return BuiltinDataType.Byte; + } else if (OptionSetUI16.class.isAssignableFrom(type)) { + return BuiltinDataType.UInt16; + } else if (OptionSetUI32.class.isAssignableFrom(type)) { + return BuiltinDataType.UInt32; + } else if (OptionSetUI64.class.isAssignableFrom(type)) { + return BuiltinDataType.UInt64; + } else { + throw new RuntimeException("unknown OptionSetUInteger subclass: " + type); + } + } else { + return BuiltinDataType.fromBackingClass(type); + } + } + + /** + * Get the elements of this Matrix in a flattened array. + * + * @return the elements of this Matrix in a flattened array. + */ + public @Nullable Object getElements() { + return flatArray; + } + + /** + * Get the dimensions of this Matrix. + *

+ * The returned array is zero length if this Matrix contains a null value. + * + * @return the dimensions of this Matrix. + */ + public int[] getDimensions() { + return dimensions; + } + + /** + * Get the value rank (number of dimensions) of this Matrix. + *

+ * The returned value is -1 if this Matrix contains a null value. + * + * @return the value rank of this Matrix. + */ + public int getValueRank() { + return flatArray != null ? dimensions.length : -1; + } + + /** + * Get the {@link BuiltinDataType} of the elements of this Matrix. + *

+ * Empty only if this Matrix contains a {@code null} value. + * + * @return the {@link BuiltinDataType} of the elements of this Matrix. + */ + public Optional getBuiltinDataType() { + return Optional.ofNullable(builtinDataType); + } + + /** + * @return {@code true} if this Matrix contains a null value. + */ + public boolean isNull() { + return flatArray == null; + } + + /** + * @return {@code true} if this Matrix contains a non-null value. + */ + public boolean isNotNull() { + return !isNull(); + } + + /** + * Create a new Matrix by applying the transform function {@code f} to each of the elements in + * this Matrix. + * + * @param f the transform function applied to each element. + * @return a new Matrix containing transformed elements. + */ + public Matrix transform(Function f) { + if (flatArray == null) { + return new Matrix(null); + } else { + Object transformedArray = null; + + int length = Array.getLength(flatArray); + for (int i = 0; i < length; i++) { + Object e = Array.get(flatArray, i); + Object t = f.apply(e); + if (transformedArray == null) { + transformedArray = Array.newInstance(t.getClass(), length); + } + Array.set(transformedArray, i, t); + } + + return new Matrix(transformedArray, dimensions); + } + } + + /** + * Get a copy of nested (un-flattened) multidimensional array value contained by this Matrix. + * + * @return a copy of nested (un-flattened) multidimensional array value contained by this Matrix. + */ + public Object nestedArrayValue() { + return ArrayUtil.unflatten(flatArray, dimensions); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Matrix matrix = (Matrix) o; + return Objects.deepEquals(flatArray, matrix.flatArray) && + Arrays.equals(dimensions, matrix.dimensions) && + builtinDataType == matrix.builtinDataType; + } + + @Override + public int hashCode() { + int result = Objects.hash(flatArray, builtinDataType); + result = 31 * result + Arrays.hashCode(dimensions); + return result; + } + + @Override + public String toString() { + StringJoiner joiner = new StringJoiner(", ", Matrix.class.getSimpleName() + "{", "}") + .add("builtinDataType=" + builtinDataType) + .add("dimensions=" + Arrays.toString(dimensions)); + + Class clazz = ArrayUtil.getType(flatArray); + + if (clazz.isPrimitive()) { + if (clazz == boolean.class) { + joiner.add("flatArray=" + Arrays.toString((boolean[]) flatArray)); + } else if (clazz == byte.class) { + joiner.add("flatArray=" + Arrays.toString((byte[]) flatArray)); + } else if (clazz == short.class) { + joiner.add("flatArray=" + Arrays.toString((short[]) flatArray)); + } else if (clazz == int.class) { + joiner.add("flatArray=" + Arrays.toString((int[]) flatArray)); + } else if (clazz == long.class) { + joiner.add("flatArray=" + Arrays.toString((long[]) flatArray)); + } else if (clazz == float.class) { + joiner.add("flatArray=" + Arrays.toString((float[]) flatArray)); + } else if (clazz == double.class) { + joiner.add("flatArray=" + Arrays.toString((double[]) flatArray)); + } else { + joiner.add("flatArray=" + flatArray); + } + } else { + joiner.add("flatArray=" + Arrays.toString((Object[]) flatArray)); + } + + return joiner.toString(); + } + + //region Static factory methods + + /** + * Create a Matrix containing a null value. + * + * @return a Matrix containing a null value. + */ + public static Matrix ofNull() { + return new Matrix(null); + } + + /** + * Create a Matrix containing a multidimensional Boolean value. + * + * @param value the multidimensional Boolean value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofBoolean(Boolean[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Boolean value. + * + * @param value the multidimensional Boolean value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofBoolean(boolean[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Boolean value. + * + * @param value the multidimensional Boolean value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofBoolean(Boolean[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Boolean value. + * + * @param value the multidimensional Boolean value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofBoolean(boolean[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional SByte value. + * + * @param value the multidimensional SByte value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofSByte(Byte[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional SByte value. + * + * @param value the multidimensional SByte value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofSByte(byte[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional SByte value. + * + * @param value the multidimensional SByte value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofSByte(Byte[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional SByte value. + * + * @param value the multidimensional SByte value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofSByte(byte[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Byte value. + * + * @param value the multidimensional Byte value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofByte(UByte[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Byte value. + * + * @param value the multidimensional Byte value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofByte(UByte[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Int16 value. + * + * @param value the multidimensional Int16 value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofInt16(Short[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Int16 value. + * + * @param value the multidimensional Int16 value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofInt16(short[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Int16 value. + * + * @param value the multidimensional Int16 value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofInt16(Short[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Int16 value. + * + * @param value the multidimensional Int16 value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofInt16(short[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional UInt16 value. + * + * @param value the multidimensional UInt16 value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofUInt16(UShort[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional UInt16 value. + * + * @param value the multidimensional UInt16 value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofUInt16(UShort[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Int32 value. + * + * @param value the multidimensional Int32 value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofInt32(Integer[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Int32 value. + * + * @param value the multidimensional Int32 value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofInt32(int[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Int32 value. + * + * @param value the multidimensional Int32 value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofInt32(Integer[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Int32 value. + * + * @param value the multidimensional Int32 value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofInt32(int[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional UInt32 value. + * + * @param value the multidimensional UInt32 value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofUInt32(UInteger[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional UInt32 value. + * + * @param value the multidimensional UInt32 value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofUInt32(UInteger[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Int64 value. + * + * @param value the multidimensional Int64 value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofInt64(Long[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Int64 value. + * + * @param value the multidimensional Int64 value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofInt64(long[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Int64 value. + * + * @param value the multidimensional Int64 value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofInt64(Long[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Int64 value. + * + * @param value the multidimensional Int64 value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofInt64(long[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional UInt64 value. + * + * @param value the multidimensional UInt64 value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofUInt64(ULong[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional UInt64 value. + * + * @param value the multidimensional UInt64 value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofUInt64(ULong[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Float value. + * + * @param value the multidimensional Float value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofFloat(Float[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Float value. + * + * @param value the multidimensional Float value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofFloat(float[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Float value. + * + * @param value the multidimensional Float value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofFloat(Float[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Float value. + * + * @param value the multidimensional Float value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofFloat(float[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Double value. + * + * @param value the multidimensional Double value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofDouble(Double[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Double value. + * + * @param value the multidimensional Double value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofDouble(double[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Double value. + * + * @param value the multidimensional Double value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofDouble(Double[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Double value. + * + * @param value the multidimensional Double value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofDouble(double[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional String value. + * + * @param value the multidimensional String value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofString(String[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional String value. + * + * @param value the multidimensional String value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofString(String[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional DateTime value. + * + * @param value the multidimensional DateTime value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofDateTime(DateTime[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional DateTime value. + * + * @param value the multidimensional DateTime value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofDateTime(DateTime[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Guid value. + * + * @param value the multidimensional Guid value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofGuid(UUID[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Guid value. + * + * @param value the multidimensional Guid value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofGuid(UUID[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional ByteString value. + * + * @param value the multidimensional ByteString value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofByteString(ByteString[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional ByteString value. + * + * @param value the multidimensional ByteString value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofByteString(ByteString[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional XmlElement value. + * + * @param value the multidimensional XmlElement value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofXmlElement(XmlElement[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional XmlElement value. + * + * @param value the multidimensional XmlElement value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofXmlElement(XmlElement[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional NodeId value. + * + * @param value the multidimensional NodeId value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofNodeId(NodeId[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional NodeId value. + * + * @param value the multidimensional NodeId value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofNodeId(NodeId[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional ExpandedNodeId value. + * + * @param value the multidimensional ExpandedNodeId value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofExpandedNodeId(ExpandedNodeId[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional ExpandedNodeId value. + * + * @param value the multidimensional ExpandedNodeId value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofExpandedNodeId(ExpandedNodeId[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional StatusCode value. + * + * @param value the multidimensional StatusCode value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofStatusCode(StatusCode[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional StatusCode value. + * + * @param value the multidimensional StatusCode value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofStatusCode(StatusCode[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional QualifiedName value. + * + * @param value the multidimensional QualifiedName value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofQualifiedName(QualifiedName[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional QualifiedName value. + * + * @param value the multidimensional QualifiedName value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofQualifiedName(QualifiedName[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional LocalizedText value. + * + * @param value the multidimensional LocalizedText value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofLocalizedText(LocalizedText[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional LocalizedText value. + * + * @param value the multidimensional LocalizedText value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofLocalizedText(LocalizedText[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional ExtensionObject value. + * + * @param value the multidimensional ExtensionObject value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofExtensionObject(ExtensionObject[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional ExtensionObject value. + * + * @param value the multidimensional ExtensionObject value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofExtensionObject(ExtensionObject[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional DataValue value. + * + * @param value the multidimensional DataValue value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofDataValue(DataValue[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional DataValue value. + * + * @param value the multidimensional DataValue value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofDataValue(DataValue[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Variant value. + * + * @param value the multidimensional Variant value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofVariant(Variant[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional Variant value. + * + * @param value the multidimensional Variant value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofVariant(Variant[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional DiagnosticInfo value. + * + * @param value the multidimensional DiagnosticInfo value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofDiagnosticInfo(DiagnosticInfo[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional DiagnosticInfo value. + * + * @param value the multidimensional DiagnosticInfo value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofDiagnosticInfo(DiagnosticInfo[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional UaEnumeratedType value. + * + * @param value the multidimensional UaEnumeratedType value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofEnum(UaEnumeratedType[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional UaEnumeratedType value. + * + * @param value the multidimensional UaEnumeratedType value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofEnum(UaEnumeratedType[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional UaStructuredType value. + * + * @param value the multidimensional UaStructuredType value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofStruct(UaStructuredType[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional UaStructuredType value. + * + * @param value the multidimensional UaStructuredType value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofStruct(UaStructuredType[][][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional OptionSetUInteger value. + * + * @param value the multidimensional OptionSetUInteger value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofOptionSetUI(OptionSetUInteger[][] value) { + return new Matrix(value); + } + + /** + * Create a Matrix containing a multidimensional OptionSetUInteger value. + * + * @param value the multidimensional OptionSetUInteger value. + * @return a new Matrix containing {@code value}. + */ + public static Matrix ofOptionSetUI(OptionSetUInteger[][][] value) { + return new Matrix(value); + } + + //endregion + +} diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUI16.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUI16.java new file mode 100644 index 000000000..015bf5f22 --- /dev/null +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUI16.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +package org.eclipse.milo.opcua.stack.core.types.builtin; + +import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UShort; + +public abstract class OptionSetUI16 & OptionSetUInteger.BitIndex> extends OptionSetUInteger { + + public OptionSetUI16(UShort value) { + super(value); + } + + @Override + public UShort getValue() { + return (UShort) value; + } + +} diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUI32.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUI32.java new file mode 100644 index 000000000..499de3117 --- /dev/null +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUI32.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +package org.eclipse.milo.opcua.stack.core.types.builtin; + +import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; + +public abstract class OptionSetUI32 & OptionSetUInteger.BitIndex> extends OptionSetUInteger { + + public OptionSetUI32(UInteger value) { + super(value); + } + + @Override + public UInteger getValue() { + return (UInteger) value; + } + +} diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUI64.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUI64.java new file mode 100644 index 000000000..1ccc02d9b --- /dev/null +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUI64.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +package org.eclipse.milo.opcua.stack.core.types.builtin; + +import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.ULong; + +public abstract class OptionSetUI64 & OptionSetUInteger.BitIndex> extends OptionSetUInteger { + + public OptionSetUI64(ULong value) { + super(value); + } + + @Override + public ULong getValue() { + return (ULong) value; + } + +} diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUI8.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUI8.java new file mode 100644 index 000000000..227b41219 --- /dev/null +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUI8.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +package org.eclipse.milo.opcua.stack.core.types.builtin; + +import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UByte; + +public abstract class OptionSetUI8 & OptionSetUInteger.BitIndex> extends OptionSetUInteger { + + public OptionSetUI8(UByte value) { + super(value); + } + + @Override + public UByte getValue() { + return (UByte) value; + } + +} diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUInteger.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUInteger.java index edf04aaf3..bed776e0f 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUInteger.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/OptionSetUInteger.java @@ -20,7 +20,7 @@ public abstract class OptionSetUInteger & OptionSetUInteger.Bi protected final UNumber value; - public OptionSetUInteger(UNumber value) { + OptionSetUInteger(UNumber value) { this.value = value; } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/Variant.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/Variant.java index d3baa5548..fec0289ca 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/Variant.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/builtin/Variant.java @@ -782,6 +782,16 @@ public static Variant ofVariantArray(Variant[] value) { return new Variant(value); } + /** + * Create a Variant containing a Matrix value. + * + * @param value the Matrix value. + * @return a new Variant containing {@code value}. + */ + public static Variant ofMatrix(Matrix value) { + return new Variant(value); + } + //endregion } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AccessLevelExType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AccessLevelExType.java index 4d6db1681..ed1264777 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AccessLevelExType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AccessLevelExType.java @@ -1,3 +1,13 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + package org.eclipse.milo.opcua.stack.core.types.structured; import java.util.Arrays; @@ -6,7 +16,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; -import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUInteger; +import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUI32; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; /** @@ -16,7 +26,7 @@ callSuper = true ) @ToString -public class AccessLevelExType extends OptionSetUInteger { +public class AccessLevelExType extends OptionSetUI32 { public AccessLevelExType(UInteger value) { super(value); } @@ -79,13 +89,13 @@ public UInteger getValue() { } @Override - public Set toSet() { + public Set toSet() { return Arrays.stream(Field.values()) .filter(this::get) .collect(Collectors.toSet()); } - public static AccessLevelExType of(AccessLevelExType.Field... fields) { + public static AccessLevelExType of(Field... fields) { long bits = 0L; for (Field f : fields) { @@ -95,7 +105,7 @@ public static AccessLevelExType of(AccessLevelExType.Field... fields) { return new AccessLevelExType(UInteger.valueOf(bits)); } - public enum Field implements OptionSetUInteger.BitIndex { + public enum Field implements BitIndex { CurrentRead(0), CurrentWrite(1), diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AccessLevelType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AccessLevelType.java index 607e3aeac..120b99746 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AccessLevelType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AccessLevelType.java @@ -1,3 +1,13 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + package org.eclipse.milo.opcua.stack.core.types.structured; import java.util.Arrays; @@ -6,7 +16,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; -import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUInteger; +import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUI8; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UByte; /** @@ -16,7 +26,7 @@ callSuper = true ) @ToString -public class AccessLevelType extends OptionSetUInteger { +public class AccessLevelType extends OptionSetUI8 { public AccessLevelType(UByte value) { super(value); } @@ -55,13 +65,13 @@ public UByte getValue() { } @Override - public Set toSet() { + public Set toSet() { return Arrays.stream(Field.values()) .filter(this::get) .collect(Collectors.toSet()); } - public static AccessLevelType of(AccessLevelType.Field... fields) { + public static AccessLevelType of(Field... fields) { long bits = 0L; for (Field f : fields) { @@ -71,7 +81,7 @@ public static AccessLevelType of(AccessLevelType.Field... fields) { return new AccessLevelType(UByte.valueOf(bits)); } - public enum Field implements OptionSetUInteger.BitIndex { + public enum Field implements BitIndex { CurrentRead(0), CurrentWrite(1), diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AccessRestrictionType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AccessRestrictionType.java index 6c693c009..e39b4a20b 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AccessRestrictionType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AccessRestrictionType.java @@ -1,3 +1,13 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + package org.eclipse.milo.opcua.stack.core.types.structured; import java.util.Arrays; @@ -6,7 +16,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; -import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUInteger; +import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUI16; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UShort; /** @@ -16,7 +26,7 @@ callSuper = true ) @ToString -public class AccessRestrictionType extends OptionSetUInteger { +public class AccessRestrictionType extends OptionSetUI16 { public AccessRestrictionType(UShort value) { super(value); } @@ -43,13 +53,13 @@ public UShort getValue() { } @Override - public Set toSet() { + public Set toSet() { return Arrays.stream(Field.values()) .filter(this::get) .collect(Collectors.toSet()); } - public static AccessRestrictionType of(AccessRestrictionType.Field... fields) { + public static AccessRestrictionType of(Field... fields) { long bits = 0L; for (Field f : fields) { @@ -59,7 +69,7 @@ public static AccessRestrictionType of(AccessRestrictionType.Field... fields) { return new AccessRestrictionType(UShort.valueOf(bits)); } - public enum Field implements OptionSetUInteger.BitIndex { + public enum Field implements BitIndex { SigningRequired(0), EncryptionRequired(1), diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AddNodesResponse.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AddNodesResponse.java index 345523229..b1e5c4786 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AddNodesResponse.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AddNodesResponse.java @@ -116,8 +116,7 @@ public AddNodesResponse decodeType(EncodingContext context, UaDecoder decoder) { } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - AddNodesResponse value) { + public void encodeType(EncodingContext context, UaEncoder encoder, AddNodesResponse value) { encoder.encodeStruct("ResponseHeader", value.getResponseHeader(), ResponseHeader.TYPE_ID); encoder.encodeStructArray("Results", value.getResults(), AddNodesResult.TYPE_ID); encoder.encodeDiagnosticInfoArray("DiagnosticInfos", value.getDiagnosticInfos()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AddReferencesItem.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AddReferencesItem.java index 25cac93ff..e6802978f 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AddReferencesItem.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AddReferencesItem.java @@ -143,8 +143,7 @@ public AddReferencesItem decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - AddReferencesItem value) { + public void encodeType(EncodingContext context, UaEncoder encoder, AddReferencesItem value) { encoder.encodeNodeId("SourceNodeId", value.getSourceNodeId()); encoder.encodeNodeId("ReferenceTypeId", value.getReferenceTypeId()); encoder.encodeBoolean("IsForward", value.getIsForward()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AddReferencesRequest.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AddReferencesRequest.java index f714423d8..f286a9a66 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AddReferencesRequest.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AddReferencesRequest.java @@ -105,8 +105,7 @@ public AddReferencesRequest decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - AddReferencesRequest value) { + public void encodeType(EncodingContext context, UaEncoder encoder, AddReferencesRequest value) { encoder.encodeStruct("RequestHeader", value.getRequestHeader(), RequestHeader.TYPE_ID); encoder.encodeStructArray("ReferencesToAdd", value.getReferencesToAdd(), AddReferencesItem.TYPE_ID); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AliasNameDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AliasNameDataType.java index c94e00afd..0c94db416 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AliasNameDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AliasNameDataType.java @@ -106,8 +106,7 @@ public AliasNameDataType decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - AliasNameDataType value) { + public void encodeType(EncodingContext context, UaEncoder encoder, AliasNameDataType value) { encoder.encodeQualifiedName("AliasName", value.getAliasName()); encoder.encodeExpandedNodeIdArray("ReferencedNodes", value.getReferencedNodes()); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AttributeOperand.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AttributeOperand.java index 0ed66909b..80ec907b5 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AttributeOperand.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AttributeOperand.java @@ -133,8 +133,7 @@ public AttributeOperand decodeType(EncodingContext context, UaDecoder decoder) { } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - AttributeOperand value) { + public void encodeType(EncodingContext context, UaEncoder encoder, AttributeOperand value) { encoder.encodeNodeId("NodeId", value.getNodeId()); encoder.encodeString("Alias", value.getAlias()); encoder.encodeStruct("BrowsePath", value.getBrowsePath(), RelativePath.TYPE_ID); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AttributeWriteMask.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AttributeWriteMask.java index b4011c7a5..5ed0d3964 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AttributeWriteMask.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/AttributeWriteMask.java @@ -1,3 +1,13 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + package org.eclipse.milo.opcua.stack.core.types.structured; import java.util.Arrays; @@ -6,7 +16,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; -import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUInteger; +import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUI32; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; /** @@ -16,7 +26,7 @@ callSuper = true ) @ToString -public class AttributeWriteMask extends OptionSetUInteger { +public class AttributeWriteMask extends OptionSetUI32 { public AttributeWriteMask(UInteger value) { super(value); } @@ -131,13 +141,13 @@ public UInteger getValue() { } @Override - public Set toSet() { + public Set toSet() { return Arrays.stream(Field.values()) .filter(this::get) .collect(Collectors.toSet()); } - public static AttributeWriteMask of(AttributeWriteMask.Field... fields) { + public static AttributeWriteMask of(Field... fields) { long bits = 0L; for (Field f : fields) { @@ -147,7 +157,7 @@ public static AttributeWriteMask of(AttributeWriteMask.Field... fields) { return new AttributeWriteMask(UInteger.valueOf(bits)); } - public enum Field implements OptionSetUInteger.BitIndex { + public enum Field implements BitIndex { AccessLevel(0), ArrayDimensions(1), diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowseDescription.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowseDescription.java index b3785cd26..2d821956b 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowseDescription.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowseDescription.java @@ -143,8 +143,7 @@ public BrowseDescription decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - BrowseDescription value) { + public void encodeType(EncodingContext context, UaEncoder encoder, BrowseDescription value) { encoder.encodeNodeId("NodeId", value.getNodeId()); encoder.encodeEnum("BrowseDirection", value.getBrowseDirection()); encoder.encodeNodeId("ReferenceTypeId", value.getReferenceTypeId()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowseNextRequest.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowseNextRequest.java index 6f35d379b..323a99aa2 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowseNextRequest.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowseNextRequest.java @@ -116,8 +116,7 @@ public BrowseNextRequest decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - BrowseNextRequest value) { + public void encodeType(EncodingContext context, UaEncoder encoder, BrowseNextRequest value) { encoder.encodeStruct("RequestHeader", value.getRequestHeader(), RequestHeader.TYPE_ID); encoder.encodeBoolean("ReleaseContinuationPoints", value.getReleaseContinuationPoints()); encoder.encodeByteStringArray("ContinuationPoints", value.getContinuationPoints()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowseNextResponse.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowseNextResponse.java index ddcb87083..f8feef68c 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowseNextResponse.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowseNextResponse.java @@ -116,8 +116,7 @@ public BrowseNextResponse decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - BrowseNextResponse value) { + public void encodeType(EncodingContext context, UaEncoder encoder, BrowseNextResponse value) { encoder.encodeStruct("ResponseHeader", value.getResponseHeader(), ResponseHeader.TYPE_ID); encoder.encodeStructArray("Results", value.getResults(), BrowseResult.TYPE_ID); encoder.encodeDiagnosticInfoArray("DiagnosticInfos", value.getDiagnosticInfos()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowsePathResult.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowsePathResult.java index 4b4743b54..f2b4a22e0 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowsePathResult.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowsePathResult.java @@ -106,8 +106,7 @@ public BrowsePathResult decodeType(EncodingContext context, UaDecoder decoder) { } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - BrowsePathResult value) { + public void encodeType(EncodingContext context, UaEncoder encoder, BrowsePathResult value) { encoder.encodeStatusCode("StatusCode", value.getStatusCode()); encoder.encodeStructArray("Targets", value.getTargets(), BrowsePathTarget.TYPE_ID); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowsePathTarget.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowsePathTarget.java index ae2157280..f7a6418c9 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowsePathTarget.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/BrowsePathTarget.java @@ -105,8 +105,7 @@ public BrowsePathTarget decodeType(EncodingContext context, UaDecoder decoder) { } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - BrowsePathTarget value) { + public void encodeType(EncodingContext context, UaEncoder encoder, BrowsePathTarget value) { encoder.encodeExpandedNodeId("TargetId", value.getTargetId()); encoder.encodeUInt32("RemainingPathIndex", value.getRemainingPathIndex()); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CallMethodRequest.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CallMethodRequest.java index 0f2e04fce..a73904b17 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CallMethodRequest.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CallMethodRequest.java @@ -115,8 +115,7 @@ public CallMethodRequest decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - CallMethodRequest value) { + public void encodeType(EncodingContext context, UaEncoder encoder, CallMethodRequest value) { encoder.encodeNodeId("ObjectId", value.getObjectId()); encoder.encodeNodeId("MethodId", value.getMethodId()); encoder.encodeVariantArray("InputArguments", value.getInputArguments()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CallMethodResult.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CallMethodResult.java index c76d12093..46f02410f 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CallMethodResult.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CallMethodResult.java @@ -127,8 +127,7 @@ public CallMethodResult decodeType(EncodingContext context, UaDecoder decoder) { } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - CallMethodResult value) { + public void encodeType(EncodingContext context, UaEncoder encoder, CallMethodResult value) { encoder.encodeStatusCode("StatusCode", value.getStatusCode()); encoder.encodeStatusCodeArray("InputArgumentResults", value.getInputArgumentResults()); encoder.encodeDiagnosticInfoArray("InputArgumentDiagnosticInfos", value.getInputArgumentDiagnosticInfos()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ChannelSecurityToken.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ChannelSecurityToken.java index e7b5d7c4a..d004cc3c4 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ChannelSecurityToken.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ChannelSecurityToken.java @@ -125,8 +125,7 @@ public ChannelSecurityToken decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - ChannelSecurityToken value) { + public void encodeType(EncodingContext context, UaEncoder encoder, ChannelSecurityToken value) { encoder.encodeUInt32("ChannelId", value.getChannelId()); encoder.encodeUInt32("TokenId", value.getTokenId()); encoder.encodeDateTime("CreatedAt", value.getCreatedAt()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CloseSessionRequest.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CloseSessionRequest.java index c0f187d06..838c2d4dd 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CloseSessionRequest.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CloseSessionRequest.java @@ -105,8 +105,7 @@ public CloseSessionRequest decodeType(EncodingContext context, UaDecoder decoder } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - CloseSessionRequest value) { + public void encodeType(EncodingContext context, UaEncoder encoder, CloseSessionRequest value) { encoder.encodeStruct("RequestHeader", value.getRequestHeader(), RequestHeader.TYPE_ID); encoder.encodeBoolean("DeleteSubscriptions", value.getDeleteSubscriptions()); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CloseSessionResponse.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CloseSessionResponse.java index 4c7ca27bb..ac3679138 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CloseSessionResponse.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CloseSessionResponse.java @@ -96,8 +96,7 @@ public CloseSessionResponse decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - CloseSessionResponse value) { + public void encodeType(EncodingContext context, UaEncoder encoder, CloseSessionResponse value) { encoder.encodeStruct("ResponseHeader", value.getResponseHeader(), ResponseHeader.TYPE_ID); } } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ComplexNumberType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ComplexNumberType.java index 8d799df1a..e9e8d4e24 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ComplexNumberType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ComplexNumberType.java @@ -105,8 +105,7 @@ public ComplexNumberType decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - ComplexNumberType value) { + public void encodeType(EncodingContext context, UaEncoder encoder, ComplexNumberType value) { encoder.encodeFloat("Real", value.getReal()); encoder.encodeFloat("Imaginary", value.getImaginary()); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ConfigurationVersionDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ConfigurationVersionDataType.java index ffba0688c..ec2cafcba 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ConfigurationVersionDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ConfigurationVersionDataType.java @@ -98,8 +98,7 @@ public Class getType() { } @Override - public ConfigurationVersionDataType decodeType(EncodingContext context, - UaDecoder decoder) { + public ConfigurationVersionDataType decodeType(EncodingContext context, UaDecoder decoder) { UInteger majorVersion = decoder.decodeUInt32("MajorVersion"); UInteger minorVersion = decoder.decodeUInt32("MinorVersion"); return new ConfigurationVersionDataType(majorVersion, minorVersion); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ContentFilterElement.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ContentFilterElement.java index 6e187b20d..9c8f26f14 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ContentFilterElement.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ContentFilterElement.java @@ -107,8 +107,7 @@ public ContentFilterElement decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - ContentFilterElement value) { + public void encodeType(EncodingContext context, UaEncoder encoder, ContentFilterElement value) { encoder.encodeEnum("FilterOperator", value.getFilterOperator()); encoder.encodeExtensionObjectArray("FilterOperands", value.getFilterOperands()); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ContentFilterResult.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ContentFilterResult.java index 0b9d43e5d..52e3aa02c 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ContentFilterResult.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ContentFilterResult.java @@ -107,8 +107,7 @@ public ContentFilterResult decodeType(EncodingContext context, UaDecoder decoder } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - ContentFilterResult value) { + public void encodeType(EncodingContext context, UaEncoder encoder, ContentFilterResult value) { encoder.encodeStructArray("ElementResults", value.getElementResults(), ContentFilterElementResult.TYPE_ID); encoder.encodeDiagnosticInfoArray("ElementDiagnosticInfos", value.getElementDiagnosticInfos()); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CreateMonitoredItemsResponse.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CreateMonitoredItemsResponse.java index c69872ac6..89e68cb77 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CreateMonitoredItemsResponse.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CreateMonitoredItemsResponse.java @@ -108,8 +108,7 @@ public Class getType() { } @Override - public CreateMonitoredItemsResponse decodeType(EncodingContext context, - UaDecoder decoder) { + public CreateMonitoredItemsResponse decodeType(EncodingContext context, UaDecoder decoder) { ResponseHeader responseHeader = (ResponseHeader) decoder.decodeStruct("ResponseHeader", ResponseHeader.TYPE_ID); MonitoredItemCreateResult[] results = (MonitoredItemCreateResult[]) decoder.decodeStructArray("Results", MonitoredItemCreateResult.TYPE_ID); DiagnosticInfo[] diagnosticInfos = decoder.decodeDiagnosticInfoArray("DiagnosticInfos"); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CreateSessionRequest.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CreateSessionRequest.java index 771cd48f3..f041f2eed 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CreateSessionRequest.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CreateSessionRequest.java @@ -172,8 +172,7 @@ public CreateSessionRequest decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - CreateSessionRequest value) { + public void encodeType(EncodingContext context, UaEncoder encoder, CreateSessionRequest value) { encoder.encodeStruct("RequestHeader", value.getRequestHeader(), RequestHeader.TYPE_ID); encoder.encodeStruct("ClientDescription", value.getClientDescription(), ApplicationDescription.TYPE_ID); encoder.encodeString("ServerUri", value.getServerUri()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CurrencyUnitType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CurrencyUnitType.java index f794590e0..7f17e0781 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CurrencyUnitType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/CurrencyUnitType.java @@ -124,8 +124,7 @@ public CurrencyUnitType decodeType(EncodingContext context, UaDecoder decoder) { } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - CurrencyUnitType value) { + public void encodeType(EncodingContext context, UaEncoder encoder, CurrencyUnitType value) { encoder.encodeInt16("NumericCode", value.getNumericCode()); encoder.encodeSByte("Exponent", value.getExponent()); encoder.encodeString("AlphabeticCode", value.getAlphabeticCode()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataChangeFilter.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataChangeFilter.java index b3296e958..49546af98 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataChangeFilter.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataChangeFilter.java @@ -115,8 +115,7 @@ public DataChangeFilter decodeType(EncodingContext context, UaDecoder decoder) { } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - DataChangeFilter value) { + public void encodeType(EncodingContext context, UaEncoder encoder, DataChangeFilter value) { encoder.encodeEnum("Trigger", value.getTrigger()); encoder.encodeUInt32("DeadbandType", value.getDeadbandType()); encoder.encodeDouble("DeadbandValue", value.getDeadbandValue()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataSetFieldContentMask.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataSetFieldContentMask.java index 752b0b7ce..4fc846a6e 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataSetFieldContentMask.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataSetFieldContentMask.java @@ -1,3 +1,13 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + package org.eclipse.milo.opcua.stack.core.types.structured; import java.util.Arrays; @@ -6,7 +16,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; -import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUInteger; +import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUI32; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; /** @@ -16,7 +26,7 @@ callSuper = true ) @ToString -public class DataSetFieldContentMask extends OptionSetUInteger { +public class DataSetFieldContentMask extends OptionSetUI32 { public DataSetFieldContentMask(UInteger value) { super(value); } @@ -51,13 +61,13 @@ public UInteger getValue() { } @Override - public Set toSet() { + public Set toSet() { return Arrays.stream(Field.values()) .filter(this::get) .collect(Collectors.toSet()); } - public static DataSetFieldContentMask of(DataSetFieldContentMask.Field... fields) { + public static DataSetFieldContentMask of(Field... fields) { long bits = 0L; for (Field f : fields) { @@ -67,7 +77,7 @@ public static DataSetFieldContentMask of(DataSetFieldContentMask.Field... fields return new DataSetFieldContentMask(UInteger.valueOf(bits)); } - public enum Field implements OptionSetUInteger.BitIndex { + public enum Field implements BitIndex { StatusCode(0), SourceTimestamp(1), diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataSetFieldFlags.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataSetFieldFlags.java index 3ce763daf..cc2c447a2 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataSetFieldFlags.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataSetFieldFlags.java @@ -1,3 +1,13 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + package org.eclipse.milo.opcua.stack.core.types.structured; import java.util.Arrays; @@ -6,7 +16,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; -import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUInteger; +import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUI16; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UShort; /** @@ -16,7 +26,7 @@ callSuper = true ) @ToString -public class DataSetFieldFlags extends OptionSetUInteger { +public class DataSetFieldFlags extends OptionSetUI16 { public DataSetFieldFlags(UShort value) { super(value); } @@ -31,13 +41,13 @@ public UShort getValue() { } @Override - public Set toSet() { + public Set toSet() { return Arrays.stream(Field.values()) .filter(this::get) .collect(Collectors.toSet()); } - public static DataSetFieldFlags of(DataSetFieldFlags.Field... fields) { + public static DataSetFieldFlags of(Field... fields) { long bits = 0L; for (Field f : fields) { @@ -47,7 +57,7 @@ public static DataSetFieldFlags of(DataSetFieldFlags.Field... fields) { return new DataSetFieldFlags(UShort.valueOf(bits)); } - public enum Field implements OptionSetUInteger.BitIndex { + public enum Field implements BitIndex { PromotedField(0); private final int bitIndex; diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataSetMetaDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataSetMetaDataType.java index c9d3cfa74..b230534b0 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataSetMetaDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataSetMetaDataType.java @@ -146,8 +146,7 @@ public DataSetMetaDataType decodeType(EncodingContext context, UaDecoder decoder } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - DataSetMetaDataType value) { + public void encodeType(EncodingContext context, UaEncoder encoder, DataSetMetaDataType value) { encoder.encodeStringArray("Namespaces", value.getNamespaces()); encoder.encodeStructArray("StructureDataTypes", value.getStructureDataTypes(), StructureDescription.TYPE_ID); encoder.encodeStructArray("EnumDataTypes", value.getEnumDataTypes(), EnumDescription.TYPE_ID); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataTypeAttributes.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataTypeAttributes.java index a7172d8f8..90b799253 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataTypeAttributes.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DataTypeAttributes.java @@ -108,8 +108,7 @@ public DataTypeAttributes decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - DataTypeAttributes value) { + public void encodeType(EncodingContext context, UaEncoder encoder, DataTypeAttributes value) { encoder.encodeUInt32("SpecifiedAttributes", value.getSpecifiedAttributes()); encoder.encodeLocalizedText("DisplayName", value.getDisplayName()); encoder.encodeLocalizedText("Description", value.getDescription()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteAtTimeDetails.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteAtTimeDetails.java index ea0d1ac0a..9ae3171c0 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteAtTimeDetails.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteAtTimeDetails.java @@ -100,8 +100,7 @@ public DeleteAtTimeDetails decodeType(EncodingContext context, UaDecoder decoder } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - DeleteAtTimeDetails value) { + public void encodeType(EncodingContext context, UaEncoder encoder, DeleteAtTimeDetails value) { encoder.encodeNodeId("NodeId", value.getNodeId()); encoder.encodeDateTimeArray("ReqTimes", value.getReqTimes()); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteEventDetails.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteEventDetails.java index 0af4670ad..83d65aebc 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteEventDetails.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteEventDetails.java @@ -100,8 +100,7 @@ public DeleteEventDetails decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - DeleteEventDetails value) { + public void encodeType(EncodingContext context, UaEncoder encoder, DeleteEventDetails value) { encoder.encodeNodeId("NodeId", value.getNodeId()); encoder.encodeByteStringArray("EventIds", value.getEventIds()); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteMonitoredItemsResponse.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteMonitoredItemsResponse.java index cb5648d9e..1bf566168 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteMonitoredItemsResponse.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteMonitoredItemsResponse.java @@ -109,8 +109,7 @@ public Class getType() { } @Override - public DeleteMonitoredItemsResponse decodeType(EncodingContext context, - UaDecoder decoder) { + public DeleteMonitoredItemsResponse decodeType(EncodingContext context, UaDecoder decoder) { ResponseHeader responseHeader = (ResponseHeader) decoder.decodeStruct("ResponseHeader", ResponseHeader.TYPE_ID); StatusCode[] results = decoder.decodeStatusCodeArray("Results"); DiagnosticInfo[] diagnosticInfos = decoder.decodeDiagnosticInfoArray("DiagnosticInfos"); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteNodesRequest.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteNodesRequest.java index cdda5839a..82d3832c8 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteNodesRequest.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteNodesRequest.java @@ -105,8 +105,7 @@ public DeleteNodesRequest decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - DeleteNodesRequest value) { + public void encodeType(EncodingContext context, UaEncoder encoder, DeleteNodesRequest value) { encoder.encodeStruct("RequestHeader", value.getRequestHeader(), RequestHeader.TYPE_ID); encoder.encodeStructArray("NodesToDelete", value.getNodesToDelete(), DeleteNodesItem.TYPE_ID); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteNodesResponse.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteNodesResponse.java index 96285ed23..c95f4ef50 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteNodesResponse.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteNodesResponse.java @@ -117,8 +117,7 @@ public DeleteNodesResponse decodeType(EncodingContext context, UaDecoder decoder } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - DeleteNodesResponse value) { + public void encodeType(EncodingContext context, UaEncoder encoder, DeleteNodesResponse value) { encoder.encodeStruct("ResponseHeader", value.getResponseHeader(), ResponseHeader.TYPE_ID); encoder.encodeStatusCodeArray("Results", value.getResults()); encoder.encodeDiagnosticInfoArray("DiagnosticInfos", value.getDiagnosticInfos()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteReferencesItem.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteReferencesItem.java index a3fe7a5ae..42ef6484f 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteReferencesItem.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/DeleteReferencesItem.java @@ -133,8 +133,7 @@ public DeleteReferencesItem decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - DeleteReferencesItem value) { + public void encodeType(EncodingContext context, UaEncoder encoder, DeleteReferencesItem value) { encoder.encodeNodeId("SourceNodeId", value.getSourceNodeId()); encoder.encodeNodeId("ReferenceTypeId", value.getReferenceTypeId()); encoder.encodeBoolean("IsForward", value.getIsForward()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/EndpointDescription.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/EndpointDescription.java index 6ca8f3606..d3da7679c 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/EndpointDescription.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/EndpointDescription.java @@ -164,8 +164,7 @@ public EndpointDescription decodeType(EncodingContext context, UaDecoder decoder } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - EndpointDescription value) { + public void encodeType(EncodingContext context, UaEncoder encoder, EndpointDescription value) { encoder.encodeString("EndpointUrl", value.getEndpointUrl()); encoder.encodeStruct("Server", value.getServer(), ApplicationDescription.TYPE_ID); encoder.encodeByteString("ServerCertificate", value.getServerCertificate()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/EphemeralKeyType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/EphemeralKeyType.java index 31fb71cee..b7b2b9981 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/EphemeralKeyType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/EphemeralKeyType.java @@ -106,8 +106,7 @@ public EphemeralKeyType decodeType(EncodingContext context, UaDecoder decoder) { } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - EphemeralKeyType value) { + public void encodeType(EncodingContext context, UaEncoder encoder, EphemeralKeyType value) { encoder.encodeByteString("PublicKey", value.getPublicKey()); encoder.encodeByteString("Signature", value.getSignature()); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/EventFilterResult.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/EventFilterResult.java index 7fbf17ed2..44d6c0f4c 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/EventFilterResult.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/EventFilterResult.java @@ -117,8 +117,7 @@ public EventFilterResult decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - EventFilterResult value) { + public void encodeType(EncodingContext context, UaEncoder encoder, EventFilterResult value) { encoder.encodeStatusCodeArray("SelectClauseResults", value.getSelectClauseResults()); encoder.encodeDiagnosticInfoArray("SelectClauseDiagnosticInfos", value.getSelectClauseDiagnosticInfos()); encoder.encodeStruct("WhereClauseResult", value.getWhereClauseResult(), ContentFilterResult.TYPE_ID); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/EventNotifierType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/EventNotifierType.java index 2abcc3544..eb028ec3d 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/EventNotifierType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/EventNotifierType.java @@ -1,3 +1,13 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + package org.eclipse.milo.opcua.stack.core.types.structured; import java.util.Arrays; @@ -6,7 +16,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; -import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUInteger; +import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUI8; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UByte; /** @@ -16,7 +26,7 @@ callSuper = true ) @ToString -public class EventNotifierType extends OptionSetUInteger { +public class EventNotifierType extends OptionSetUI8 { public EventNotifierType(UByte value) { super(value); } @@ -39,13 +49,13 @@ public UByte getValue() { } @Override - public Set toSet() { + public Set toSet() { return Arrays.stream(Field.values()) .filter(this::get) .collect(Collectors.toSet()); } - public static EventNotifierType of(EventNotifierType.Field... fields) { + public static EventNotifierType of(Field... fields) { long bits = 0L; for (Field f : fields) { @@ -55,7 +65,7 @@ public static EventNotifierType of(EventNotifierType.Field... fields) { return new EventNotifierType(UByte.valueOf(bits)); } - public enum Field implements OptionSetUInteger.BitIndex { + public enum Field implements BitIndex { SubscribeToEvents(0), HistoryRead(2), diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/FieldTargetDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/FieldTargetDataType.java index 12b318009..29be130ce 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/FieldTargetDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/FieldTargetDataType.java @@ -156,8 +156,7 @@ public FieldTargetDataType decodeType(EncodingContext context, UaDecoder decoder } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - FieldTargetDataType value) { + public void encodeType(EncodingContext context, UaEncoder encoder, FieldTargetDataType value) { encoder.encodeGuid("DataSetFieldId", value.getDataSetFieldId()); encoder.encodeString("ReceiverIndexRange", value.getReceiverIndexRange()); encoder.encodeNodeId("TargetNodeId", value.getTargetNodeId()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/FindServersOnNetworkResponse.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/FindServersOnNetworkResponse.java index 21c5b6e3e..e3e689f79 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/FindServersOnNetworkResponse.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/FindServersOnNetworkResponse.java @@ -108,8 +108,7 @@ public Class getType() { } @Override - public FindServersOnNetworkResponse decodeType(EncodingContext context, - UaDecoder decoder) { + public FindServersOnNetworkResponse decodeType(EncodingContext context, UaDecoder decoder) { ResponseHeader responseHeader = (ResponseHeader) decoder.decodeStruct("ResponseHeader", ResponseHeader.TYPE_ID); DateTime lastCounterResetTime = decoder.decodeDateTime("LastCounterResetTime"); ServerOnNetwork[] servers = (ServerOnNetwork[]) decoder.decodeStructArray("Servers", ServerOnNetwork.TYPE_ID); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/FindServersRequest.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/FindServersRequest.java index 691d89762..3369d1b83 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/FindServersRequest.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/FindServersRequest.java @@ -124,8 +124,7 @@ public FindServersRequest decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - FindServersRequest value) { + public void encodeType(EncodingContext context, UaEncoder encoder, FindServersRequest value) { encoder.encodeStruct("RequestHeader", value.getRequestHeader(), RequestHeader.TYPE_ID); encoder.encodeString("EndpointUrl", value.getEndpointUrl()); encoder.encodeStringArray("LocaleIds", value.getLocaleIds()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/FindServersResponse.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/FindServersResponse.java index 35d7af6ab..b492e619b 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/FindServersResponse.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/FindServersResponse.java @@ -105,8 +105,7 @@ public FindServersResponse decodeType(EncodingContext context, UaDecoder decoder } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - FindServersResponse value) { + public void encodeType(EncodingContext context, UaEncoder encoder, FindServersResponse value) { encoder.encodeStruct("ResponseHeader", value.getResponseHeader(), ResponseHeader.TYPE_ID); encoder.encodeStructArray("Servers", value.getServers(), ApplicationDescription.TYPE_ID); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/GenericAttributes.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/GenericAttributes.java index 9afac02ed..0d6f9021d 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/GenericAttributes.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/GenericAttributes.java @@ -109,8 +109,7 @@ public GenericAttributes decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - GenericAttributes value) { + public void encodeType(EncodingContext context, UaEncoder encoder, GenericAttributes value) { encoder.encodeUInt32("SpecifiedAttributes", value.getSpecifiedAttributes()); encoder.encodeLocalizedText("DisplayName", value.getDisplayName()); encoder.encodeLocalizedText("Description", value.getDescription()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/GetEndpointsRequest.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/GetEndpointsRequest.java index a554a72fa..2e7cd641b 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/GetEndpointsRequest.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/GetEndpointsRequest.java @@ -124,8 +124,7 @@ public GetEndpointsRequest decodeType(EncodingContext context, UaDecoder decoder } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - GetEndpointsRequest value) { + public void encodeType(EncodingContext context, UaEncoder encoder, GetEndpointsRequest value) { encoder.encodeStruct("RequestHeader", value.getRequestHeader(), RequestHeader.TYPE_ID); encoder.encodeString("EndpointUrl", value.getEndpointUrl()); encoder.encodeStringArray("LocaleIds", value.getLocaleIds()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/GetEndpointsResponse.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/GetEndpointsResponse.java index 85c37926d..95d44a05e 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/GetEndpointsResponse.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/GetEndpointsResponse.java @@ -105,8 +105,7 @@ public GetEndpointsResponse decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - GetEndpointsResponse value) { + public void encodeType(EncodingContext context, UaEncoder encoder, GetEndpointsResponse value) { encoder.encodeStruct("ResponseHeader", value.getResponseHeader(), ResponseHeader.TYPE_ID); encoder.encodeStructArray("Endpoints", value.getEndpoints(), EndpointDescription.TYPE_ID); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryModifiedData.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryModifiedData.java index b98da3753..b536be9aa 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryModifiedData.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryModifiedData.java @@ -100,8 +100,7 @@ public HistoryModifiedData decodeType(EncodingContext context, UaDecoder decoder } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - HistoryModifiedData value) { + public void encodeType(EncodingContext context, UaEncoder encoder, HistoryModifiedData value) { encoder.encodeDataValueArray("DataValues", value.getDataValues()); encoder.encodeStructArray("ModificationInfos", value.getModificationInfos(), ModificationInfo.TYPE_ID); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadDetails.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadDetails.java index ccde41a83..634b0bb22 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadDetails.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadDetails.java @@ -86,8 +86,7 @@ public HistoryReadDetails decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - HistoryReadDetails value) { + public void encodeType(EncodingContext context, UaEncoder encoder, HistoryReadDetails value) { } } } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadRequest.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadRequest.java index 14cb71a39..4e0a8a752 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadRequest.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadRequest.java @@ -136,8 +136,7 @@ public HistoryReadRequest decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - HistoryReadRequest value) { + public void encodeType(EncodingContext context, UaEncoder encoder, HistoryReadRequest value) { encoder.encodeStruct("RequestHeader", value.getRequestHeader(), RequestHeader.TYPE_ID); encoder.encodeExtensionObject("HistoryReadDetails", value.getHistoryReadDetails()); encoder.encodeEnum("TimestampsToReturn", value.getTimestampsToReturn()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadResponse.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadResponse.java index 5a75f5ab8..dc5cad587 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadResponse.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadResponse.java @@ -116,8 +116,7 @@ public HistoryReadResponse decodeType(EncodingContext context, UaDecoder decoder } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - HistoryReadResponse value) { + public void encodeType(EncodingContext context, UaEncoder encoder, HistoryReadResponse value) { encoder.encodeStruct("ResponseHeader", value.getResponseHeader(), ResponseHeader.TYPE_ID); encoder.encodeStructArray("Results", value.getResults(), HistoryReadResult.TYPE_ID); encoder.encodeDiagnosticInfoArray("DiagnosticInfos", value.getDiagnosticInfos()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadResult.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadResult.java index 1f06c0bd1..ece7c24a9 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadResult.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadResult.java @@ -118,8 +118,7 @@ public HistoryReadResult decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - HistoryReadResult value) { + public void encodeType(EncodingContext context, UaEncoder encoder, HistoryReadResult value) { encoder.encodeStatusCode("StatusCode", value.getStatusCode()); encoder.encodeByteString("ContinuationPoint", value.getContinuationPoint()); encoder.encodeExtensionObject("HistoryData", value.getHistoryData()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadValueId.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadValueId.java index 040aac21d..6082c3ca1 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadValueId.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryReadValueId.java @@ -126,8 +126,7 @@ public HistoryReadValueId decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - HistoryReadValueId value) { + public void encodeType(EncodingContext context, UaEncoder encoder, HistoryReadValueId value) { encoder.encodeNodeId("NodeId", value.getNodeId()); encoder.encodeString("IndexRange", value.getIndexRange()); encoder.encodeQualifiedName("DataEncoding", value.getDataEncoding()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryUpdateDetails.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryUpdateDetails.java index 84c1dd531..16eb71386 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryUpdateDetails.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryUpdateDetails.java @@ -96,8 +96,7 @@ public HistoryUpdateDetails decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - HistoryUpdateDetails value) { + public void encodeType(EncodingContext context, UaEncoder encoder, HistoryUpdateDetails value) { encoder.encodeNodeId("NodeId", value.getNodeId()); } } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryUpdateRequest.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryUpdateRequest.java index 3b401ebab..7983a94d4 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryUpdateRequest.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryUpdateRequest.java @@ -106,8 +106,7 @@ public HistoryUpdateRequest decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - HistoryUpdateRequest value) { + public void encodeType(EncodingContext context, UaEncoder encoder, HistoryUpdateRequest value) { encoder.encodeStruct("RequestHeader", value.getRequestHeader(), RequestHeader.TYPE_ID); encoder.encodeExtensionObjectArray("HistoryUpdateDetails", value.getHistoryUpdateDetails()); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryUpdateResult.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryUpdateResult.java index 78d3570f3..c949e373c 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryUpdateResult.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/HistoryUpdateResult.java @@ -117,8 +117,7 @@ public HistoryUpdateResult decodeType(EncodingContext context, UaDecoder decoder } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - HistoryUpdateResult value) { + public void encodeType(EncodingContext context, UaEncoder encoder, HistoryUpdateResult value) { encoder.encodeStatusCode("StatusCode", value.getStatusCode()); encoder.encodeStatusCodeArray("OperationResults", value.getOperationResults()); encoder.encodeDiagnosticInfoArray("DiagnosticInfos", value.getDiagnosticInfos()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/IssuedIdentityToken.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/IssuedIdentityToken.java index def43d84c..420cf4c74 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/IssuedIdentityToken.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/IssuedIdentityToken.java @@ -109,8 +109,7 @@ public IssuedIdentityToken decodeType(EncodingContext context, UaDecoder decoder } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - IssuedIdentityToken value) { + public void encodeType(EncodingContext context, UaEncoder encoder, IssuedIdentityToken value) { encoder.encodeString("PolicyId", value.getPolicyId()); encoder.encodeByteString("TokenData", value.getTokenData()); encoder.encodeString("EncryptionAlgorithm", value.getEncryptionAlgorithm()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonDataSetMessageContentMask.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonDataSetMessageContentMask.java index 893071d5e..1a5a93594 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonDataSetMessageContentMask.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonDataSetMessageContentMask.java @@ -1,3 +1,13 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + package org.eclipse.milo.opcua.stack.core.types.structured; import java.util.Arrays; @@ -6,7 +16,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; -import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUInteger; +import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUI32; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; /** @@ -16,7 +26,7 @@ callSuper = true ) @ToString -public class JsonDataSetMessageContentMask extends OptionSetUInteger { +public class JsonDataSetMessageContentMask extends OptionSetUI32 { public JsonDataSetMessageContentMask(UInteger value) { super(value); } @@ -59,13 +69,13 @@ public UInteger getValue() { } @Override - public Set toSet() { + public Set toSet() { return Arrays.stream(Field.values()) .filter(this::get) .collect(Collectors.toSet()); } - public static JsonDataSetMessageContentMask of(JsonDataSetMessageContentMask.Field... fields) { + public static JsonDataSetMessageContentMask of(Field... fields) { long bits = 0L; for (Field f : fields) { @@ -75,7 +85,7 @@ public static JsonDataSetMessageContentMask of(JsonDataSetMessageContentMask.Fie return new JsonDataSetMessageContentMask(UInteger.valueOf(bits)); } - public enum Field implements OptionSetUInteger.BitIndex { + public enum Field implements BitIndex { DataSetWriterId(0), MetaDataVersion(1), diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonDataSetReaderMessageDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonDataSetReaderMessageDataType.java index d23c971aa..8cb3733d0 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonDataSetReaderMessageDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonDataSetReaderMessageDataType.java @@ -99,8 +99,7 @@ public Class getType() { } @Override - public JsonDataSetReaderMessageDataType decodeType(EncodingContext context, - UaDecoder decoder) { + public JsonDataSetReaderMessageDataType decodeType(EncodingContext context, UaDecoder decoder) { JsonNetworkMessageContentMask networkMessageContentMask = new JsonNetworkMessageContentMask(decoder.decodeUInt32("NetworkMessageContentMask")); JsonDataSetMessageContentMask dataSetMessageContentMask = new JsonDataSetMessageContentMask(decoder.decodeUInt32("DataSetMessageContentMask")); return new JsonDataSetReaderMessageDataType(networkMessageContentMask, dataSetMessageContentMask); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonDataSetWriterMessageDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonDataSetWriterMessageDataType.java index ec8014efd..0f1d7ae19 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonDataSetWriterMessageDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonDataSetWriterMessageDataType.java @@ -90,8 +90,7 @@ public Class getType() { } @Override - public JsonDataSetWriterMessageDataType decodeType(EncodingContext context, - UaDecoder decoder) { + public JsonDataSetWriterMessageDataType decodeType(EncodingContext context, UaDecoder decoder) { JsonDataSetMessageContentMask dataSetMessageContentMask = new JsonDataSetMessageContentMask(decoder.decodeUInt32("DataSetMessageContentMask")); return new JsonDataSetWriterMessageDataType(dataSetMessageContentMask); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonNetworkMessageContentMask.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonNetworkMessageContentMask.java index 01aee93eb..ec8a6e849 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonNetworkMessageContentMask.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonNetworkMessageContentMask.java @@ -1,3 +1,13 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + package org.eclipse.milo.opcua.stack.core.types.structured; import java.util.Arrays; @@ -6,7 +16,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; -import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUInteger; +import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUI32; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; /** @@ -16,7 +26,7 @@ callSuper = true ) @ToString -public class JsonNetworkMessageContentMask extends OptionSetUInteger { +public class JsonNetworkMessageContentMask extends OptionSetUI32 { public JsonNetworkMessageContentMask(UInteger value) { super(value); } @@ -51,13 +61,13 @@ public UInteger getValue() { } @Override - public Set toSet() { + public Set toSet() { return Arrays.stream(Field.values()) .filter(this::get) .collect(Collectors.toSet()); } - public static JsonNetworkMessageContentMask of(JsonNetworkMessageContentMask.Field... fields) { + public static JsonNetworkMessageContentMask of(Field... fields) { long bits = 0L; for (Field f : fields) { @@ -67,7 +77,7 @@ public static JsonNetworkMessageContentMask of(JsonNetworkMessageContentMask.Fie return new JsonNetworkMessageContentMask(UInteger.valueOf(bits)); } - public enum Field implements OptionSetUInteger.BitIndex { + public enum Field implements BitIndex { NetworkMessageHeader(0), DataSetMessageHeader(1), diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonWriterGroupMessageDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonWriterGroupMessageDataType.java index 053b7cc65..350047f48 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonWriterGroupMessageDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/JsonWriterGroupMessageDataType.java @@ -90,8 +90,7 @@ public Class getType() { } @Override - public JsonWriterGroupMessageDataType decodeType(EncodingContext context, - UaDecoder decoder) { + public JsonWriterGroupMessageDataType decodeType(EncodingContext context, UaDecoder decoder) { JsonNetworkMessageContentMask networkMessageContentMask = new JsonNetworkMessageContentMask(decoder.decodeUInt32("NetworkMessageContentMask")); return new JsonWriterGroupMessageDataType(networkMessageContentMask); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/MethodAttributes.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/MethodAttributes.java index 69f121f26..8e827d7c0 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/MethodAttributes.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/MethodAttributes.java @@ -118,8 +118,7 @@ public MethodAttributes decodeType(EncodingContext context, UaDecoder decoder) { } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - MethodAttributes value) { + public void encodeType(EncodingContext context, UaEncoder encoder, MethodAttributes value) { encoder.encodeUInt32("SpecifiedAttributes", value.getSpecifiedAttributes()); encoder.encodeLocalizedText("DisplayName", value.getDisplayName()); encoder.encodeLocalizedText("Description", value.getDescription()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ModelChangeStructureDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ModelChangeStructureDataType.java index 8d89ea084..3aa6a6541 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ModelChangeStructureDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ModelChangeStructureDataType.java @@ -107,8 +107,7 @@ public Class getType() { } @Override - public ModelChangeStructureDataType decodeType(EncodingContext context, - UaDecoder decoder) { + public ModelChangeStructureDataType decodeType(EncodingContext context, UaDecoder decoder) { NodeId affected = decoder.decodeNodeId("Affected"); NodeId affectedType = decoder.decodeNodeId("AffectedType"); UByte verb = decoder.decodeByte("Verb"); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ModificationInfo.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ModificationInfo.java index c4470b86f..5e4de3bd1 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ModificationInfo.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ModificationInfo.java @@ -117,8 +117,7 @@ public ModificationInfo decodeType(EncodingContext context, UaDecoder decoder) { } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - ModificationInfo value) { + public void encodeType(EncodingContext context, UaEncoder encoder, ModificationInfo value) { encoder.encodeDateTime("ModificationTime", value.getModificationTime()); encoder.encodeEnum("UpdateType", value.getUpdateType()); encoder.encodeString("UserName", value.getUserName()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ModifyMonitoredItemsResponse.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ModifyMonitoredItemsResponse.java index 896cacf10..bdb8f9523 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ModifyMonitoredItemsResponse.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ModifyMonitoredItemsResponse.java @@ -108,8 +108,7 @@ public Class getType() { } @Override - public ModifyMonitoredItemsResponse decodeType(EncodingContext context, - UaDecoder decoder) { + public ModifyMonitoredItemsResponse decodeType(EncodingContext context, UaDecoder decoder) { ResponseHeader responseHeader = (ResponseHeader) decoder.decodeStruct("ResponseHeader", ResponseHeader.TYPE_ID); MonitoredItemModifyResult[] results = (MonitoredItemModifyResult[]) decoder.decodeStructArray("Results", MonitoredItemModifyResult.TYPE_ID); DiagnosticInfo[] diagnosticInfos = decoder.decodeDiagnosticInfoArray("DiagnosticInfos"); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/MonitoringFilter.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/MonitoringFilter.java index 57500c322..44a18f540 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/MonitoringFilter.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/MonitoringFilter.java @@ -86,8 +86,7 @@ public MonitoringFilter decodeType(EncodingContext context, UaDecoder decoder) { } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - MonitoringFilter value) { + public void encodeType(EncodingContext context, UaEncoder encoder, MonitoringFilter value) { } } } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/MonitoringParameters.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/MonitoringParameters.java index 925aa8549..96d001783 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/MonitoringParameters.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/MonitoringParameters.java @@ -134,8 +134,7 @@ public MonitoringParameters decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - MonitoringParameters value) { + public void encodeType(EncodingContext context, UaEncoder encoder, MonitoringParameters value) { encoder.encodeUInt32("ClientHandle", value.getClientHandle()); encoder.encodeDouble("SamplingInterval", value.getSamplingInterval()); encoder.encodeExtensionObject("Filter", value.getFilter()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/NetworkGroupDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/NetworkGroupDataType.java index 1fa729808..76c8fde85 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/NetworkGroupDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/NetworkGroupDataType.java @@ -105,8 +105,7 @@ public NetworkGroupDataType decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - NetworkGroupDataType value) { + public void encodeType(EncodingContext context, UaEncoder encoder, NetworkGroupDataType value) { encoder.encodeString("ServerUri", value.getServerUri()); encoder.encodeStructArray("NetworkPaths", value.getNetworkPaths(), EndpointUrlListDataType.TYPE_ID); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/NodeTypeDescription.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/NodeTypeDescription.java index 09e0a8ce2..36622993e 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/NodeTypeDescription.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/NodeTypeDescription.java @@ -115,8 +115,7 @@ public NodeTypeDescription decodeType(EncodingContext context, UaDecoder decoder } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - NodeTypeDescription value) { + public void encodeType(EncodingContext context, UaEncoder encoder, NodeTypeDescription value) { encoder.encodeExpandedNodeId("TypeDefinitionNode", value.getTypeDefinitionNode()); encoder.encodeBoolean("IncludeSubTypes", value.getIncludeSubTypes()); encoder.encodeStructArray("DataToReturn", value.getDataToReturn(), QueryDataDescription.TYPE_ID); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/NotificationData.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/NotificationData.java index eff6e3a94..9de691f92 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/NotificationData.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/NotificationData.java @@ -86,8 +86,7 @@ public NotificationData decodeType(EncodingContext context, UaDecoder decoder) { } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - NotificationData value) { + public void encodeType(EncodingContext context, UaEncoder encoder, NotificationData value) { } } } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/NotificationMessage.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/NotificationMessage.java index b1b876a86..a3cf59ac3 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/NotificationMessage.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/NotificationMessage.java @@ -117,8 +117,7 @@ public NotificationMessage decodeType(EncodingContext context, UaDecoder decoder } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - NotificationMessage value) { + public void encodeType(EncodingContext context, UaEncoder encoder, NotificationMessage value) { encoder.encodeUInt32("SequenceNumber", value.getSequenceNumber()); encoder.encodeDateTime("PublishTime", value.getPublishTime()); encoder.encodeExtensionObjectArray("NotificationData", value.getNotificationData()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ObjectAttributes.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ObjectAttributes.java index 487acdb72..983186802 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ObjectAttributes.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ObjectAttributes.java @@ -109,8 +109,7 @@ public ObjectAttributes decodeType(EncodingContext context, UaDecoder decoder) { } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - ObjectAttributes value) { + public void encodeType(EncodingContext context, UaEncoder encoder, ObjectAttributes value) { encoder.encodeUInt32("SpecifiedAttributes", value.getSpecifiedAttributes()); encoder.encodeLocalizedText("DisplayName", value.getDisplayName()); encoder.encodeLocalizedText("Description", value.getDescription()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ObjectTypeAttributes.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ObjectTypeAttributes.java index f90ce856d..7ffb16da3 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ObjectTypeAttributes.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ObjectTypeAttributes.java @@ -108,8 +108,7 @@ public ObjectTypeAttributes decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - ObjectTypeAttributes value) { + public void encodeType(EncodingContext context, UaEncoder encoder, ObjectTypeAttributes value) { encoder.encodeUInt32("SpecifiedAttributes", value.getSpecifiedAttributes()); encoder.encodeLocalizedText("DisplayName", value.getDisplayName()); encoder.encodeLocalizedText("Description", value.getDescription()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PasswordOptionsMask.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PasswordOptionsMask.java index b5f96deb4..ba8779792 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PasswordOptionsMask.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PasswordOptionsMask.java @@ -1,3 +1,13 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + package org.eclipse.milo.opcua.stack.core.types.structured; import java.util.Arrays; @@ -6,7 +16,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; -import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUInteger; +import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUI32; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; /** @@ -16,7 +26,7 @@ callSuper = true ) @ToString -public class PasswordOptionsMask extends OptionSetUInteger { +public class PasswordOptionsMask extends OptionSetUI32 { public PasswordOptionsMask(UInteger value) { super(value); } @@ -63,13 +73,13 @@ public UInteger getValue() { } @Override - public Set toSet() { + public Set toSet() { return Arrays.stream(Field.values()) .filter(this::get) .collect(Collectors.toSet()); } - public static PasswordOptionsMask of(PasswordOptionsMask.Field... fields) { + public static PasswordOptionsMask of(Field... fields) { long bits = 0L; for (Field f : fields) { @@ -79,7 +89,7 @@ public static PasswordOptionsMask of(PasswordOptionsMask.Field... fields) { return new PasswordOptionsMask(UInteger.valueOf(bits)); } - public enum Field implements OptionSetUInteger.BitIndex { + public enum Field implements BitIndex { SupportInitialPasswordChange(0), SupportDisableUser(1), diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PermissionType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PermissionType.java index 9ceab77cb..cfde776b7 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PermissionType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PermissionType.java @@ -1,3 +1,13 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + package org.eclipse.milo.opcua.stack.core.types.structured; import java.util.Arrays; @@ -6,7 +16,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; -import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUInteger; +import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUI32; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; /** @@ -16,7 +26,7 @@ callSuper = true ) @ToString -public class PermissionType extends OptionSetUInteger { +public class PermissionType extends OptionSetUI32 { public PermissionType(UInteger value) { super(value); } @@ -95,13 +105,13 @@ public UInteger getValue() { } @Override - public Set toSet() { + public Set toSet() { return Arrays.stream(Field.values()) .filter(this::get) .collect(Collectors.toSet()); } - public static PermissionType of(PermissionType.Field... fields) { + public static PermissionType of(Field... fields) { long bits = 0L; for (Field f : fields) { @@ -111,7 +121,7 @@ public static PermissionType of(PermissionType.Field... fields) { return new PermissionType(UInteger.valueOf(bits)); } - public enum Field implements OptionSetUInteger.BitIndex { + public enum Field implements BitIndex { Browse(0), ReadRolePermissions(1), diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PubSubConfiguration2DataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PubSubConfiguration2DataType.java index 0ba4ed200..831a2bddc 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PubSubConfiguration2DataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PubSubConfiguration2DataType.java @@ -147,8 +147,7 @@ public Class getType() { } @Override - public PubSubConfiguration2DataType decodeType(EncodingContext context, - UaDecoder decoder) { + public PubSubConfiguration2DataType decodeType(EncodingContext context, UaDecoder decoder) { PublishedDataSetDataType[] publishedDataSets = (PublishedDataSetDataType[]) decoder.decodeStructArray("PublishedDataSets", PublishedDataSetDataType.TYPE_ID); PubSubConnectionDataType[] connections = (PubSubConnectionDataType[]) decoder.decodeStructArray("Connections", PubSubConnectionDataType.TYPE_ID); Boolean enabled = decoder.decodeBoolean("Enabled"); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PubSubConfigurationRefDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PubSubConfigurationRefDataType.java index 4213e9284..709b6595a 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PubSubConfigurationRefDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PubSubConfigurationRefDataType.java @@ -116,8 +116,7 @@ public Class getType() { } @Override - public PubSubConfigurationRefDataType decodeType(EncodingContext context, - UaDecoder decoder) { + public PubSubConfigurationRefDataType decodeType(EncodingContext context, UaDecoder decoder) { PubSubConfigurationRefMask configurationMask = new PubSubConfigurationRefMask(decoder.decodeUInt32("ConfigurationMask")); UShort elementIndex = decoder.decodeUInt16("ElementIndex"); UShort connectionIndex = decoder.decodeUInt16("ConnectionIndex"); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PubSubConfigurationRefMask.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PubSubConfigurationRefMask.java index 0c53e9faf..f18d6cdcd 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PubSubConfigurationRefMask.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PubSubConfigurationRefMask.java @@ -1,3 +1,13 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + package org.eclipse.milo.opcua.stack.core.types.structured; import java.util.Arrays; @@ -6,7 +16,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; -import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUInteger; +import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUI32; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; /** @@ -16,7 +26,7 @@ callSuper = true ) @ToString -public class PubSubConfigurationRefMask extends OptionSetUInteger { +public class PubSubConfigurationRefMask extends OptionSetUI32 { public PubSubConfigurationRefMask(UInteger value) { super(value); } @@ -79,13 +89,13 @@ public UInteger getValue() { } @Override - public Set toSet() { + public Set toSet() { return Arrays.stream(Field.values()) .filter(this::get) .collect(Collectors.toSet()); } - public static PubSubConfigurationRefMask of(PubSubConfigurationRefMask.Field... fields) { + public static PubSubConfigurationRefMask of(Field... fields) { long bits = 0L; for (Field f : fields) { @@ -95,7 +105,7 @@ public static PubSubConfigurationRefMask of(PubSubConfigurationRefMask.Field... return new PubSubConfigurationRefMask(UInteger.valueOf(bits)); } - public enum Field implements OptionSetUInteger.BitIndex { + public enum Field implements BitIndex { ElementAdd(0), ElementMatch(1), diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PubSubConfigurationValueDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PubSubConfigurationValueDataType.java index 491582228..d477a382f 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PubSubConfigurationValueDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/PubSubConfigurationValueDataType.java @@ -108,8 +108,7 @@ public Class getType() { } @Override - public PubSubConfigurationValueDataType decodeType(EncodingContext context, - UaDecoder decoder) { + public PubSubConfigurationValueDataType decodeType(EncodingContext context, UaDecoder decoder) { PubSubConfigurationRefDataType configurationElement = (PubSubConfigurationRefDataType) decoder.decodeStruct("ConfigurationElement", PubSubConfigurationRefDataType.TYPE_ID); String name = decoder.decodeString("Name"); Variant identifier = decoder.decodeVariant("Identifier"); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryDataDescription.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryDataDescription.java index b7af81934..cf38c73d2 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryDataDescription.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryDataDescription.java @@ -114,8 +114,7 @@ public QueryDataDescription decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - QueryDataDescription value) { + public void encodeType(EncodingContext context, UaEncoder encoder, QueryDataDescription value) { encoder.encodeStruct("RelativePath", value.getRelativePath(), RelativePath.TYPE_ID); encoder.encodeUInt32("AttributeId", value.getAttributeId()); encoder.encodeString("IndexRange", value.getIndexRange()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryFirstRequest.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryFirstRequest.java index 714aea2cd..bd4f2bd6b 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryFirstRequest.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryFirstRequest.java @@ -143,8 +143,7 @@ public QueryFirstRequest decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - QueryFirstRequest value) { + public void encodeType(EncodingContext context, UaEncoder encoder, QueryFirstRequest value) { encoder.encodeStruct("RequestHeader", value.getRequestHeader(), RequestHeader.TYPE_ID); encoder.encodeStruct("View", value.getView(), ViewDescription.TYPE_ID); encoder.encodeStructArray("NodeTypes", value.getNodeTypes(), NodeTypeDescription.TYPE_ID); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryFirstResponse.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryFirstResponse.java index 055d2df50..0ac368c53 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryFirstResponse.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryFirstResponse.java @@ -145,8 +145,7 @@ public QueryFirstResponse decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - QueryFirstResponse value) { + public void encodeType(EncodingContext context, UaEncoder encoder, QueryFirstResponse value) { encoder.encodeStruct("ResponseHeader", value.getResponseHeader(), ResponseHeader.TYPE_ID); encoder.encodeStructArray("QueryDataSets", value.getQueryDataSets(), QueryDataSet.TYPE_ID); encoder.encodeByteString("ContinuationPoint", value.getContinuationPoint()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryNextRequest.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryNextRequest.java index 559e9e37b..e1eb1cee7 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryNextRequest.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryNextRequest.java @@ -116,8 +116,7 @@ public QueryNextRequest decodeType(EncodingContext context, UaDecoder decoder) { } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - QueryNextRequest value) { + public void encodeType(EncodingContext context, UaEncoder encoder, QueryNextRequest value) { encoder.encodeStruct("RequestHeader", value.getRequestHeader(), RequestHeader.TYPE_ID); encoder.encodeBoolean("ReleaseContinuationPoint", value.getReleaseContinuationPoint()); encoder.encodeByteString("ContinuationPoint", value.getContinuationPoint()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryNextResponse.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryNextResponse.java index 57bfca924..a22f92e50 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryNextResponse.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/QueryNextResponse.java @@ -116,8 +116,7 @@ public QueryNextResponse decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - QueryNextResponse value) { + public void encodeType(EncodingContext context, UaEncoder encoder, QueryNextResponse value) { encoder.encodeStruct("ResponseHeader", value.getResponseHeader(), ResponseHeader.TYPE_ID); encoder.encodeStructArray("QueryDataSets", value.getQueryDataSets(), QueryDataSet.TYPE_ID); encoder.encodeByteString("RevisedContinuationPoint", value.getRevisedContinuationPoint()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReadAtTimeDetails.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReadAtTimeDetails.java index 182b09444..39f6624ce 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReadAtTimeDetails.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReadAtTimeDetails.java @@ -106,8 +106,7 @@ public ReadAtTimeDetails decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - ReadAtTimeDetails value) { + public void encodeType(EncodingContext context, UaEncoder encoder, ReadAtTimeDetails value) { encoder.encodeDateTimeArray("ReqTimes", value.getReqTimes()); encoder.encodeBoolean("UseSimpleBounds", value.getUseSimpleBounds()); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReadEventDetails.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReadEventDetails.java index 48eb766e4..ebbeba6de 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReadEventDetails.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReadEventDetails.java @@ -125,8 +125,7 @@ public ReadEventDetails decodeType(EncodingContext context, UaDecoder decoder) { } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - ReadEventDetails value) { + public void encodeType(EncodingContext context, UaEncoder encoder, ReadEventDetails value) { encoder.encodeUInt32("NumValuesPerNode", value.getNumValuesPerNode()); encoder.encodeDateTime("StartTime", value.getStartTime()); encoder.encodeDateTime("EndTime", value.getEndTime()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReadProcessedDetails.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReadProcessedDetails.java index a98cc3306..4236147e0 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReadProcessedDetails.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReadProcessedDetails.java @@ -134,8 +134,7 @@ public ReadProcessedDetails decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - ReadProcessedDetails value) { + public void encodeType(EncodingContext context, UaEncoder encoder, ReadProcessedDetails value) { encoder.encodeDateTime("StartTime", value.getStartTime()); encoder.encodeDateTime("EndTime", value.getEndTime()); encoder.encodeDouble("ProcessingInterval", value.getProcessingInterval()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReaderGroupDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReaderGroupDataType.java index 3a05bb9e4..14f5f491a 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReaderGroupDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReaderGroupDataType.java @@ -134,8 +134,7 @@ public ReaderGroupDataType decodeType(EncodingContext context, UaDecoder decoder } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - ReaderGroupDataType value) { + public void encodeType(EncodingContext context, UaEncoder encoder, ReaderGroupDataType value) { encoder.encodeString("Name", value.getName()); encoder.encodeBoolean("Enabled", value.getEnabled()); encoder.encodeEnum("SecurityMode", value.getSecurityMode()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReferenceDescription.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReferenceDescription.java index a4b93d405..0b4857453 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReferenceDescription.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReferenceDescription.java @@ -154,8 +154,7 @@ public ReferenceDescription decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - ReferenceDescription value) { + public void encodeType(EncodingContext context, UaEncoder encoder, ReferenceDescription value) { encoder.encodeNodeId("ReferenceTypeId", value.getReferenceTypeId()); encoder.encodeBoolean("IsForward", value.getIsForward()); encoder.encodeExpandedNodeId("NodeId", value.getNodeId()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReferenceTypeNode.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReferenceTypeNode.java index b90d006fa..ce3d91da8 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReferenceTypeNode.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ReferenceTypeNode.java @@ -142,8 +142,7 @@ public ReferenceTypeNode decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - ReferenceTypeNode value) { + public void encodeType(EncodingContext context, UaEncoder encoder, ReferenceTypeNode value) { encoder.encodeNodeId("NodeId", value.getNodeId()); encoder.encodeEnum("NodeClass", value.getNodeClass()); encoder.encodeQualifiedName("BrowseName", value.getBrowseName()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RegisterNodesRequest.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RegisterNodesRequest.java index 2369ef2b4..c4bcfc842 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RegisterNodesRequest.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RegisterNodesRequest.java @@ -105,8 +105,7 @@ public RegisterNodesRequest decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - RegisterNodesRequest value) { + public void encodeType(EncodingContext context, UaEncoder encoder, RegisterNodesRequest value) { encoder.encodeStruct("RequestHeader", value.getRequestHeader(), RequestHeader.TYPE_ID); encoder.encodeNodeIdArray("NodesToRegister", value.getNodesToRegister()); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RegisteredServer.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RegisteredServer.java index 390a0823f..9410ea6f7 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RegisteredServer.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RegisteredServer.java @@ -162,8 +162,7 @@ public RegisteredServer decodeType(EncodingContext context, UaDecoder decoder) { } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - RegisteredServer value) { + public void encodeType(EncodingContext context, UaEncoder encoder, RegisteredServer value) { encoder.encodeString("ServerUri", value.getServerUri()); encoder.encodeString("ProductUri", value.getProductUri()); encoder.encodeLocalizedTextArray("ServerNames", value.getServerNames()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RelativePathElement.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RelativePathElement.java index c326c6044..ab91e8773 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RelativePathElement.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RelativePathElement.java @@ -125,8 +125,7 @@ public RelativePathElement decodeType(EncodingContext context, UaDecoder decoder } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - RelativePathElement value) { + public void encodeType(EncodingContext context, UaEncoder encoder, RelativePathElement value) { encoder.encodeNodeId("ReferenceTypeId", value.getReferenceTypeId()); encoder.encodeBoolean("IsInverse", value.getIsInverse()); encoder.encodeBoolean("IncludeSubtypes", value.getIncludeSubtypes()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RepublishRequest.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RepublishRequest.java index 34c9fb240..7ecb9ba76 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RepublishRequest.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RepublishRequest.java @@ -115,8 +115,7 @@ public RepublishRequest decodeType(EncodingContext context, UaDecoder decoder) { } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - RepublishRequest value) { + public void encodeType(EncodingContext context, UaEncoder encoder, RepublishRequest value) { encoder.encodeStruct("RequestHeader", value.getRequestHeader(), RequestHeader.TYPE_ID); encoder.encodeUInt32("SubscriptionId", value.getSubscriptionId()); encoder.encodeUInt32("RetransmitSequenceNumber", value.getRetransmitSequenceNumber()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RepublishResponse.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RepublishResponse.java index 95fdd94fd..f0039588a 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RepublishResponse.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RepublishResponse.java @@ -105,8 +105,7 @@ public RepublishResponse decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - RepublishResponse value) { + public void encodeType(EncodingContext context, UaEncoder encoder, RepublishResponse value) { encoder.encodeStruct("ResponseHeader", value.getResponseHeader(), ResponseHeader.TYPE_ID); encoder.encodeStruct("NotificationMessage", value.getNotificationMessage(), NotificationMessage.TYPE_ID); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RolePermissionType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RolePermissionType.java index 2e32d49e2..8204bf11a 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RolePermissionType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/RolePermissionType.java @@ -105,8 +105,7 @@ public RolePermissionType decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - RolePermissionType value) { + public void encodeType(EncodingContext context, UaEncoder encoder, RolePermissionType value) { encoder.encodeNodeId("RoleId", value.getRoleId()); encoder.encodeUInt32("Permissions", value.getPermissions().getValue()); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SemanticChangeStructureDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SemanticChangeStructureDataType.java index 3c11a0a55..64b1ca787 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SemanticChangeStructureDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SemanticChangeStructureDataType.java @@ -98,8 +98,7 @@ public Class getType() { } @Override - public SemanticChangeStructureDataType decodeType(EncodingContext context, - UaDecoder decoder) { + public SemanticChangeStructureDataType decodeType(EncodingContext context, UaDecoder decoder) { NodeId affected = decoder.decodeNodeId("Affected"); NodeId affectedType = decoder.decodeNodeId("AffectedType"); return new SemanticChangeStructureDataType(affected, affectedType); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ServerDiagnosticsSummaryDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ServerDiagnosticsSummaryDataType.java index f2563a184..53401d85c 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ServerDiagnosticsSummaryDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ServerDiagnosticsSummaryDataType.java @@ -183,8 +183,7 @@ public Class getType() { } @Override - public ServerDiagnosticsSummaryDataType decodeType(EncodingContext context, - UaDecoder decoder) { + public ServerDiagnosticsSummaryDataType decodeType(EncodingContext context, UaDecoder decoder) { UInteger serverViewCount = decoder.decodeUInt32("ServerViewCount"); UInteger currentSessionCount = decoder.decodeUInt32("CurrentSessionCount"); UInteger cumulatedSessionCount = decoder.decodeUInt32("CumulatedSessionCount"); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ServerStatusDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ServerStatusDataType.java index 90a834ea1..b3d0a4046 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ServerStatusDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ServerStatusDataType.java @@ -144,8 +144,7 @@ public ServerStatusDataType decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - ServerStatusDataType value) { + public void encodeType(EncodingContext context, UaEncoder encoder, ServerStatusDataType value) { encoder.encodeDateTime("StartTime", value.getStartTime()); encoder.encodeDateTime("CurrentTime", value.getCurrentTime()); encoder.encodeEnum("State", value.getState()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SessionlessInvokeRequestType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SessionlessInvokeRequestType.java index ebb4922b8..dadb9db69 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SessionlessInvokeRequestType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SessionlessInvokeRequestType.java @@ -123,8 +123,7 @@ public Class getType() { } @Override - public SessionlessInvokeRequestType decodeType(EncodingContext context, - UaDecoder decoder) { + public SessionlessInvokeRequestType decodeType(EncodingContext context, UaDecoder decoder) { UInteger urisVersion = decoder.decodeUInt32("UrisVersion"); String[] namespaceUris = decoder.decodeStringArray("NamespaceUris"); String[] serverUris = decoder.decodeStringArray("ServerUris"); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SessionlessInvokeResponseType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SessionlessInvokeResponseType.java index 00442b675..0b1a1f238 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SessionlessInvokeResponseType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SessionlessInvokeResponseType.java @@ -107,8 +107,7 @@ public Class getType() { } @Override - public SessionlessInvokeResponseType decodeType(EncodingContext context, - UaDecoder decoder) { + public SessionlessInvokeResponseType decodeType(EncodingContext context, UaDecoder decoder) { String[] namespaceUris = decoder.decodeStringArray("NamespaceUris"); String[] serverUris = decoder.decodeStringArray("ServerUris"); UInteger serviceId = decoder.decodeUInt32("ServiceId"); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SetTriggeringRequest.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SetTriggeringRequest.java index 66fc65c3d..8fd8cdef5 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SetTriggeringRequest.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SetTriggeringRequest.java @@ -133,8 +133,7 @@ public SetTriggeringRequest decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - SetTriggeringRequest value) { + public void encodeType(EncodingContext context, UaEncoder encoder, SetTriggeringRequest value) { encoder.encodeStruct("RequestHeader", value.getRequestHeader(), RequestHeader.TYPE_ID); encoder.encodeUInt32("SubscriptionId", value.getSubscriptionId()); encoder.encodeUInt32("TriggeringItemId", value.getTriggeringItemId()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/StructureDefinition.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/StructureDefinition.java index 80e67622a..4bbb25b75 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/StructureDefinition.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/StructureDefinition.java @@ -124,8 +124,7 @@ public StructureDefinition decodeType(EncodingContext context, UaDecoder decoder } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - StructureDefinition value) { + public void encodeType(EncodingContext context, UaEncoder encoder, StructureDefinition value) { encoder.encodeNodeId("DefaultEncodingId", value.getDefaultEncodingId()); encoder.encodeNodeId("BaseDataType", value.getBaseDataType()); encoder.encodeEnum("StructureType", value.getStructureType()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/StructureDescription.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/StructureDescription.java index 7ee72c64e..766d13a54 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/StructureDescription.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/StructureDescription.java @@ -103,8 +103,7 @@ public StructureDescription decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - StructureDescription value) { + public void encodeType(EncodingContext context, UaEncoder encoder, StructureDescription value) { encoder.encodeNodeId("DataTypeId", value.getDataTypeId()); encoder.encodeQualifiedName("Name", value.getName()); encoder.encodeStruct("StructureDefinition", value.getStructureDefinition(), StructureDefinition.TYPE_ID); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SubscribedDataSetMirrorDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SubscribedDataSetMirrorDataType.java index 7e18c19cd..6b5823aef 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SubscribedDataSetMirrorDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SubscribedDataSetMirrorDataType.java @@ -99,8 +99,7 @@ public Class getType() { } @Override - public SubscribedDataSetMirrorDataType decodeType(EncodingContext context, - UaDecoder decoder) { + public SubscribedDataSetMirrorDataType decodeType(EncodingContext context, UaDecoder decoder) { String parentNodeName = decoder.decodeString("ParentNodeName"); RolePermissionType[] rolePermissions = (RolePermissionType[]) decoder.decodeStructArray("RolePermissions", RolePermissionType.TYPE_ID); return new SubscribedDataSetMirrorDataType(parentNodeName, rolePermissions); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SubscriptionDiagnosticsDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SubscriptionDiagnosticsDataType.java index 33458a502..641bd2ccb 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SubscriptionDiagnosticsDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/SubscriptionDiagnosticsDataType.java @@ -343,8 +343,7 @@ public Class getType() { } @Override - public SubscriptionDiagnosticsDataType decodeType(EncodingContext context, - UaDecoder decoder) { + public SubscriptionDiagnosticsDataType decodeType(EncodingContext context, UaDecoder decoder) { NodeId sessionId = decoder.decodeNodeId("SessionId"); UInteger subscriptionId = decoder.decodeUInt32("SubscriptionId"); UByte priority = decoder.decodeByte("Priority"); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ThreeDOrientation.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ThreeDOrientation.java index c069fbcba..affd98663 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ThreeDOrientation.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/ThreeDOrientation.java @@ -114,8 +114,7 @@ public ThreeDOrientation decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - ThreeDOrientation value) { + public void encodeType(EncodingContext context, UaEncoder encoder, ThreeDOrientation value) { encoder.encodeDouble("A", value.getA()); encoder.encodeDouble("B", value.getB()); encoder.encodeDouble("C", value.getC()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/TimeZoneDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/TimeZoneDataType.java index f36808e6a..1461f0cde 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/TimeZoneDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/TimeZoneDataType.java @@ -105,8 +105,7 @@ public TimeZoneDataType decodeType(EncodingContext context, UaDecoder decoder) { } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - TimeZoneDataType value) { + public void encodeType(EncodingContext context, UaEncoder encoder, TimeZoneDataType value) { encoder.encodeInt16("Offset", value.getOffset()); encoder.encodeBoolean("DaylightSavingInOffset", value.getDaylightSavingInOffset()); } diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/TransferSubscriptionsRequest.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/TransferSubscriptionsRequest.java index a71e2ca47..aee85e436 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/TransferSubscriptionsRequest.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/TransferSubscriptionsRequest.java @@ -107,8 +107,7 @@ public Class getType() { } @Override - public TransferSubscriptionsRequest decodeType(EncodingContext context, - UaDecoder decoder) { + public TransferSubscriptionsRequest decodeType(EncodingContext context, UaDecoder decoder) { RequestHeader requestHeader = (RequestHeader) decoder.decodeStruct("RequestHeader", RequestHeader.TYPE_ID); UInteger[] subscriptionIds = decoder.decodeUInt32Array("SubscriptionIds"); Boolean sendInitialValues = decoder.decodeBoolean("SendInitialValues"); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/TransferSubscriptionsResponse.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/TransferSubscriptionsResponse.java index f8619bd15..62abdee7d 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/TransferSubscriptionsResponse.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/TransferSubscriptionsResponse.java @@ -108,8 +108,7 @@ public Class getType() { } @Override - public TransferSubscriptionsResponse decodeType(EncodingContext context, - UaDecoder decoder) { + public TransferSubscriptionsResponse decodeType(EncodingContext context, UaDecoder decoder) { ResponseHeader responseHeader = (ResponseHeader) decoder.decodeStruct("ResponseHeader", ResponseHeader.TYPE_ID); TransferResult[] results = (TransferResult[]) decoder.decodeStructArray("Results", TransferResult.TYPE_ID); DiagnosticInfo[] diagnosticInfos = decoder.decodeDiagnosticInfoArray("DiagnosticInfos"); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/TrustListDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/TrustListDataType.java index 9cde69057..d35ff9fa4 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/TrustListDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/TrustListDataType.java @@ -131,8 +131,7 @@ public TrustListDataType decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - TrustListDataType value) { + public void encodeType(EncodingContext context, UaEncoder encoder, TrustListDataType value) { encoder.encodeUInt32("SpecifiedLists", value.getSpecifiedLists()); encoder.encodeByteStringArray("TrustedCertificates", value.getTrustedCertificates()); encoder.encodeByteStringArray("TrustedCrls", value.getTrustedCrls()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UABinaryFileDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UABinaryFileDataType.java index 1d6fb6e1e..71893a60a 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UABinaryFileDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UABinaryFileDataType.java @@ -126,8 +126,7 @@ public UABinaryFileDataType decodeType(EncodingContext context, UaDecoder decode } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - UABinaryFileDataType value) { + public void encodeType(EncodingContext context, UaEncoder encoder, UABinaryFileDataType value) { encoder.encodeStringArray("Namespaces", value.getNamespaces()); encoder.encodeStructArray("StructureDataTypes", value.getStructureDataTypes(), StructureDescription.TYPE_ID); encoder.encodeStructArray("EnumDataTypes", value.getEnumDataTypes(), EnumDescription.TYPE_ID); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpDataSetMessageContentMask.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpDataSetMessageContentMask.java index 1c793f9ec..f2edef120 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpDataSetMessageContentMask.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpDataSetMessageContentMask.java @@ -1,3 +1,13 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + package org.eclipse.milo.opcua.stack.core.types.structured; import java.util.Arrays; @@ -6,7 +16,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; -import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUInteger; +import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUI32; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; /** @@ -16,7 +26,7 @@ callSuper = true ) @ToString -public class UadpDataSetMessageContentMask extends OptionSetUInteger { +public class UadpDataSetMessageContentMask extends OptionSetUI32 { public UadpDataSetMessageContentMask(UInteger value) { super(value); } @@ -51,13 +61,13 @@ public UInteger getValue() { } @Override - public Set toSet() { + public Set toSet() { return Arrays.stream(Field.values()) .filter(this::get) .collect(Collectors.toSet()); } - public static UadpDataSetMessageContentMask of(UadpDataSetMessageContentMask.Field... fields) { + public static UadpDataSetMessageContentMask of(Field... fields) { long bits = 0L; for (Field f : fields) { @@ -67,7 +77,7 @@ public static UadpDataSetMessageContentMask of(UadpDataSetMessageContentMask.Fie return new UadpDataSetMessageContentMask(UInteger.valueOf(bits)); } - public enum Field implements OptionSetUInteger.BitIndex { + public enum Field implements BitIndex { Timestamp(0), PicoSeconds(1), diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpDataSetReaderMessageDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpDataSetReaderMessageDataType.java index c8b674857..7dee5fbcc 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpDataSetReaderMessageDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpDataSetReaderMessageDataType.java @@ -161,8 +161,7 @@ public Class getType() { } @Override - public UadpDataSetReaderMessageDataType decodeType(EncodingContext context, - UaDecoder decoder) { + public UadpDataSetReaderMessageDataType decodeType(EncodingContext context, UaDecoder decoder) { UInteger groupVersion = decoder.decodeUInt32("GroupVersion"); UShort networkMessageNumber = decoder.decodeUInt16("NetworkMessageNumber"); UShort dataSetOffset = decoder.decodeUInt16("DataSetOffset"); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpDataSetWriterMessageDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpDataSetWriterMessageDataType.java index 357d9eaa7..a7c56341d 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpDataSetWriterMessageDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpDataSetWriterMessageDataType.java @@ -116,8 +116,7 @@ public Class getType() { } @Override - public UadpDataSetWriterMessageDataType decodeType(EncodingContext context, - UaDecoder decoder) { + public UadpDataSetWriterMessageDataType decodeType(EncodingContext context, UaDecoder decoder) { UadpDataSetMessageContentMask dataSetMessageContentMask = new UadpDataSetMessageContentMask(decoder.decodeUInt32("DataSetMessageContentMask")); UShort configuredSize = decoder.decodeUInt16("ConfiguredSize"); UShort networkMessageNumber = decoder.decodeUInt16("NetworkMessageNumber"); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpNetworkMessageContentMask.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpNetworkMessageContentMask.java index 885b049d2..e887b3211 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpNetworkMessageContentMask.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpNetworkMessageContentMask.java @@ -1,3 +1,13 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + package org.eclipse.milo.opcua.stack.core.types.structured; import java.util.Arrays; @@ -6,7 +16,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; -import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUInteger; +import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUI32; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; /** @@ -16,7 +26,7 @@ callSuper = true ) @ToString -public class UadpNetworkMessageContentMask extends OptionSetUInteger { +public class UadpNetworkMessageContentMask extends OptionSetUI32 { public UadpNetworkMessageContentMask(UInteger value) { super(value); } @@ -71,13 +81,13 @@ public UInteger getValue() { } @Override - public Set toSet() { + public Set toSet() { return Arrays.stream(Field.values()) .filter(this::get) .collect(Collectors.toSet()); } - public static UadpNetworkMessageContentMask of(UadpNetworkMessageContentMask.Field... fields) { + public static UadpNetworkMessageContentMask of(Field... fields) { long bits = 0L; for (Field f : fields) { @@ -87,7 +97,7 @@ public static UadpNetworkMessageContentMask of(UadpNetworkMessageContentMask.Fie return new UadpNetworkMessageContentMask(UInteger.valueOf(bits)); } - public enum Field implements OptionSetUInteger.BitIndex { + public enum Field implements BitIndex { PublisherId(0), GroupHeader(1), diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpWriterGroupMessageDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpWriterGroupMessageDataType.java index da80e65d2..756e2d22a 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpWriterGroupMessageDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UadpWriterGroupMessageDataType.java @@ -125,8 +125,7 @@ public Class getType() { } @Override - public UadpWriterGroupMessageDataType decodeType(EncodingContext context, - UaDecoder decoder) { + public UadpWriterGroupMessageDataType decodeType(EncodingContext context, UaDecoder decoder) { UInteger groupVersion = decoder.decodeUInt32("GroupVersion"); DataSetOrderingType dataSetOrdering = DataSetOrderingType.from(decoder.decodeEnum("DataSetOrdering")); UadpNetworkMessageContentMask networkMessageContentMask = new UadpNetworkMessageContentMask(decoder.decodeUInt32("NetworkMessageContentMask")); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UpdateDataDetails.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UpdateDataDetails.java index 368455180..5c1fb3046 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UpdateDataDetails.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UpdateDataDetails.java @@ -111,8 +111,7 @@ public UpdateDataDetails decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - UpdateDataDetails value) { + public void encodeType(EncodingContext context, UaEncoder encoder, UpdateDataDetails value) { encoder.encodeNodeId("NodeId", value.getNodeId()); encoder.encodeEnum("PerformInsertReplace", value.getPerformInsertReplace()); encoder.encodeDataValueArray("UpdateValues", value.getUpdateValues()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UpdateEventDetails.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UpdateEventDetails.java index 4aa705ae7..08fded066 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UpdateEventDetails.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UpdateEventDetails.java @@ -119,8 +119,7 @@ public UpdateEventDetails decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - UpdateEventDetails value) { + public void encodeType(EncodingContext context, UaEncoder encoder, UpdateEventDetails value) { encoder.encodeNodeId("NodeId", value.getNodeId()); encoder.encodeEnum("PerformInsertReplace", value.getPerformInsertReplace()); encoder.encodeStruct("Filter", value.getFilter(), EventFilter.TYPE_ID); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UserConfigurationMask.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UserConfigurationMask.java index edd0a1794..f81196672 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UserConfigurationMask.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/UserConfigurationMask.java @@ -1,3 +1,13 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + package org.eclipse.milo.opcua.stack.core.types.structured; import java.util.Arrays; @@ -6,7 +16,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; -import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUInteger; +import org.eclipse.milo.opcua.stack.core.types.builtin.OptionSetUI32; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; /** @@ -16,7 +26,7 @@ callSuper = true ) @ToString -public class UserConfigurationMask extends OptionSetUInteger { +public class UserConfigurationMask extends OptionSetUI32 { public UserConfigurationMask(UInteger value) { super(value); } @@ -43,13 +53,13 @@ public UInteger getValue() { } @Override - public Set toSet() { + public Set toSet() { return Arrays.stream(Field.values()) .filter(this::get) .collect(Collectors.toSet()); } - public static UserConfigurationMask of(UserConfigurationMask.Field... fields) { + public static UserConfigurationMask of(Field... fields) { long bits = 0L; for (Field f : fields) { @@ -59,7 +69,7 @@ public static UserConfigurationMask of(UserConfigurationMask.Field... fields) { return new UserConfigurationMask(UInteger.valueOf(bits)); } - public enum Field implements OptionSetUInteger.BitIndex { + public enum Field implements BitIndex { NoDelete(0), Disabled(1), diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/VariableAttributes.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/VariableAttributes.java index 8e11904f8..e8a370c86 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/VariableAttributes.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/VariableAttributes.java @@ -175,8 +175,7 @@ public VariableAttributes decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - VariableAttributes value) { + public void encodeType(EncodingContext context, UaEncoder encoder, VariableAttributes value) { encoder.encodeUInt32("SpecifiedAttributes", value.getSpecifiedAttributes()); encoder.encodeLocalizedText("DisplayName", value.getDisplayName()); encoder.encodeLocalizedText("Description", value.getDescription()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/VariableTypeNode.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/VariableTypeNode.java index 3111cd4ea..d16bc2fac 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/VariableTypeNode.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/VariableTypeNode.java @@ -161,8 +161,7 @@ public VariableTypeNode decodeType(EncodingContext context, UaDecoder decoder) { } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - VariableTypeNode value) { + public void encodeType(EncodingContext context, UaEncoder encoder, VariableTypeNode value) { encoder.encodeNodeId("NodeId", value.getNodeId()); encoder.encodeEnum("NodeClass", value.getNodeClass()); encoder.encodeQualifiedName("BrowseName", value.getBrowseName()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/WriterGroupDataType.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/WriterGroupDataType.java index ad8026275..9008beb31 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/WriterGroupDataType.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/WriterGroupDataType.java @@ -191,8 +191,7 @@ public WriterGroupDataType decodeType(EncodingContext context, UaDecoder decoder } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - WriterGroupDataType value) { + public void encodeType(EncodingContext context, UaEncoder encoder, WriterGroupDataType value) { encoder.encodeString("Name", value.getName()); encoder.encodeBoolean("Enabled", value.getEnabled()); encoder.encodeEnum("SecurityMode", value.getSecurityMode()); diff --git a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/X509IdentityToken.java b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/X509IdentityToken.java index 01e1d5716..924ec5b0f 100644 --- a/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/X509IdentityToken.java +++ b/opc-ua-stack/stack-core/src/main/java/org/eclipse/milo/opcua/stack/core/types/structured/X509IdentityToken.java @@ -100,8 +100,7 @@ public X509IdentityToken decodeType(EncodingContext context, UaDecoder decoder) } @Override - public void encodeType(EncodingContext context, UaEncoder encoder, - X509IdentityToken value) { + public void encodeType(EncodingContext context, UaEncoder encoder, X509IdentityToken value) { encoder.encodeString("PolicyId", value.getPolicyId()); encoder.encodeByteString("CertificateData", value.getCertificateData()); } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/encoding/binary/VariantSerializationTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/encoding/binary/VariantSerializationTest.java index 0e93ee798..46f4ff329 100644 --- a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/encoding/binary/VariantSerializationTest.java +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/encoding/binary/VariantSerializationTest.java @@ -15,6 +15,7 @@ import org.eclipse.milo.opcua.stack.core.BuiltinDataType; import org.eclipse.milo.opcua.stack.core.encoding.TestEncodingContext; import org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject; +import org.eclipse.milo.opcua.stack.core.types.builtin.Matrix; import org.eclipse.milo.opcua.stack.core.types.builtin.Variant; import org.eclipse.milo.opcua.stack.core.types.builtin.unsigned.UInteger; import org.eclipse.milo.opcua.stack.core.types.structured.ServiceCounterDataType; @@ -36,11 +37,11 @@ public Object[][] getVariants() { {new Variant("hello, world")}, {new Variant(42)}, {new Variant(new Integer[]{0, 1, 2, 3})}, - {new Variant(new Integer[][]{{0, 1}, {2, 3}})}, + {new Variant(Matrix.ofInt32(new Integer[][]{{0, 1}, {2, 3}}))}, {new Variant(new Long[]{0L, 1L, 2L, 3L})}, - {new Variant(new Long[][]{{0L, 1L}, {2L, 3L}})}, + {new Variant(Matrix.ofInt64(new Long[][]{{0L, 1L}, {2L, 3L}}))}, {new Variant(new UInteger[]{uint(0), uint(1), uint(2), uint(3)})}, - {new Variant(new UInteger[][]{{uint(0), uint(1)}, {uint(2), uint(3)}})}, + {new Variant(Matrix.ofUInt32(new UInteger[][]{{uint(0), uint(1)}, {uint(2), uint(3)}}))}, {new Variant(new Variant[]{new Variant(0), new Variant(1), new Variant(2)})} }; } @@ -77,14 +78,14 @@ public Object[][] getPrimitiveArrayVariants() { {new Variant(new int[]{0, 1, 2, 3}), new Variant(new Integer[]{0, 1, 2, 3})}, - {new Variant(new int[][]{{0, 1}, {2, 3}}), - new Variant(new Integer[][]{{0, 1}, {2, 3}})}, + {new Variant(Matrix.ofInt32(new int[][]{{0, 1}, {2, 3}})), + new Variant(Matrix.ofInt32(new Integer[][]{{0, 1}, {2, 3}}))}, {new Variant(new long[]{0L, 1L, 2L, 3L}), new Variant(new Long[]{0L, 1L, 2L, 3L})}, - {new Variant(new long[][]{{0L, 1L}, {2L, 3L}}), - new Variant(new Long[][]{{0L, 1L}, {2L, 3L}})} + {new Variant(Matrix.ofInt64(new long[][]{{0L, 1L}, {2L, 3L}})), + new Variant(Matrix.ofInt64(new Long[][]{{0L, 1L}, {2L, 3L}}))} }; } diff --git a/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/MatrixTest.java b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/MatrixTest.java new file mode 100644 index 000000000..a6959d7fa --- /dev/null +++ b/opc-ua-stack/stack-core/src/test/java/org/eclipse/milo/opcua/stack/core/types/builtin/MatrixTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2022 the Eclipse Milo Authors + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +package org.eclipse.milo.opcua.stack.core.types.builtin; + +import java.util.Arrays; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class MatrixTest { + private final int[][] primitiveInt2d = {{1, 2}, {3, 4}}; + private final Integer[][] boxedInt2d = {{1, 2}, {3, 4}}; + + private final Matrix primitiveMatrix2d = new Matrix(primitiveInt2d); + private final Matrix boxedMatrix2d = new Matrix(boxedInt2d); + + @Test + void transform() { + Matrix m = Matrix.ofInt32(new int[][]{ + {0, 1}, + {2, 3} + }); + + Matrix transformed = m.transform(Object::toString); + + Matrix expected = Matrix.ofString(new String[][]{ + new String[]{"0", "1"}, + new String[]{"2", "3"} + }); + + assertEquals(expected, transformed); + } + + @Test + void nestedArrayValue() { + String[][] value = { + new String[]{"0", "1"}, + new String[]{"2", "3"} + }; + + Matrix m = Matrix.ofString(value); + + assertTrue(Arrays.deepEquals(new String[]{"0", "1", "2", "3"}, (Object[]) m.getElements())); + assertTrue(Arrays.deepEquals(value, (String[][]) m.nestedArrayValue())); + } + + @Test + void matrixEquals() { + assertEquals(primitiveMatrix2d, new Matrix(primitiveInt2d)); + assertEquals(boxedMatrix2d, new Matrix(boxedInt2d)); + } + + @Test + void matrixToString() { + assertEquals( + "Matrix{builtinDataType=Int32, dimensions=[2, 2], flatArray=[1, 2, 3, 4]}", primitiveMatrix2d.toString()); + assertEquals( + "Matrix{builtinDataType=Int32, dimensions=[2, 2], flatArray=[1, 2, 3, 4]}", boxedMatrix2d.toString()); + } + +} \ No newline at end of file