11/*
2- * Copyright (c) 2024 the Eclipse Milo Authors
2+ * Copyright (c) 2025 the Eclipse Milo Authors
33 *
44 * This program and the accompanying materials are made
55 * available under the terms of the Eclipse Public License 2.0
1818import java .util .UUID ;
1919import java .util .concurrent .CompletableFuture ;
2020import org .eclipse .milo .opcua .sdk .client .OpcUaClient ;
21- import org .eclipse .milo .opcua .sdk .core .types .DynamicEnum ;
22- import org .eclipse .milo .opcua .sdk .core .types .DynamicOptionSet ;
23- import org .eclipse .milo .opcua .sdk .core .types .DynamicStruct ;
21+ import org .eclipse .milo .opcua .sdk .core .types .DynamicEnumType ;
22+ import org .eclipse .milo .opcua .sdk .core .types .DynamicOptionSetType ;
23+ import org .eclipse .milo .opcua .sdk .core .types .DynamicStructType ;
24+ import org .eclipse .milo .opcua .sdk .core .types .DynamicType ;
2425import org .eclipse .milo .opcua .stack .core .encoding .EncodingContext ;
2526import org .eclipse .milo .opcua .stack .core .security .SecurityPolicy ;
2627import org .eclipse .milo .opcua .stack .core .types .builtin .ByteString ;
@@ -64,40 +65,40 @@ public void run(OpcUaClient client, CompletableFuture<OpcUaClient> future) throw
6465 private void readWriteReadPerson (OpcUaClient client ) throws Exception {
6566 NodeId nodeId = NodeId .parse ("ns=3;s=Person1" );
6667
67- DynamicStruct value = readScalarValue (client , nodeId );
68+ DynamicStructType value = ( DynamicStructType ) readScalarValue (client , nodeId );
6869 logger .info ("Person1: {}" , value );
6970
7071 Random r = new Random ();
71- DynamicEnum gender = (DynamicEnum ) value .getMembers ().get ("Gender" );
72+ DynamicEnumType gender = (DynamicEnumType ) value .getMembers ().get ("Gender" );
7273 value .getMembers ().put ("Name" , "Fat Boy" + r .nextInt (100 ));
73- value .getMembers ().put ("Gender" , new DynamicEnum (gender .getDataType (), r .nextInt (2 )));
74+ value .getMembers ().put ("Gender" , new DynamicEnumType (gender .getDataType (), r .nextInt (2 )));
7475
7576 StatusCode status = writeValue (client , nodeId , value );
7677 System .out .println ("write status: " + status );
7778
78- value = readScalarValue (client , nodeId );
79+ value = ( DynamicStructType ) readScalarValue (client , nodeId );
7980 logger .info ("Person1': {}" , value );
8081 }
8182
8283 private void readWriteReadWorkOrder (OpcUaClient client ) throws Exception {
8384 NodeId nodeId = NodeId .parse ("ns=3;s=Demo.Static.Scalar.WorkOrder" );
8485
85- DynamicStruct value = readScalarValue (client , nodeId );
86+ DynamicStructType value = ( DynamicStructType ) readScalarValue (client , nodeId );
8687 logger .info ("WorkOrder: {}" , value );
8788
8889 value .getMembers ().put ("ID" , UUID .randomUUID ());
8990
9091 StatusCode status = writeValue (client , nodeId , value );
9192 System .out .println ("write status: " + status );
9293
93- value = readScalarValue (client , nodeId );
94+ value = ( DynamicStructType ) readScalarValue (client , nodeId );
9495 logger .info ("WorkOrder': {}" , value );
9596 }
9697
9798 private void readWriteCarExtras (OpcUaClient client ) throws Exception {
9899 NodeId nodeId = NodeId .parse ("ns=3;s=Demo.Static.Scalar.CarExtras" );
99100
100- DynamicOptionSet value = (DynamicOptionSet ) readScalarValue (client , nodeId );
101+ DynamicOptionSetType value = (DynamicOptionSetType ) readScalarValue (client , nodeId );
101102 logger .info ("CarExtras: {}" , value );
102103
103104 byte b = requireNonNull (value .getValue ().bytes ())[0 ];
@@ -106,33 +107,32 @@ private void readWriteCarExtras(OpcUaClient client) throws Exception {
106107 StatusCode status = writeValue (client , nodeId , value );
107108 System .out .println ("write status: " + status );
108109
109- value = (DynamicOptionSet ) readScalarValue (client , nodeId );
110+ value = (DynamicOptionSetType ) readScalarValue (client , nodeId );
110111 logger .info ("CarExtras': {}" , value );
111112 }
112113
113114 private void readWorkOrderArray (OpcUaClient client ) throws Exception {
114115 NodeId nodeId = NodeId .parse ("ns=3;s=Demo.Static.Arrays.WorkOrder" );
115116
116- DynamicStruct [] value = readArrayValue (client , nodeId );
117+ DynamicType [] value = readArrayValue (client , nodeId );
117118
118119 logger .info ("WorkOrderArray:" );
119120 for (int i = 0 ; i < value .length ; i ++) {
120121 logger .info (" WorkOrder[{}]: {}" , i , value [i ]);
121122 }
122123 }
123124
124- private static DynamicStruct readScalarValue (OpcUaClient client , NodeId nodeId ) throws Exception {
125+ private static DynamicType readScalarValue (OpcUaClient client , NodeId nodeId ) throws Exception {
125126 DataValue dataValue =
126127 client .readValues (0.0 , TimestampsToReturn .Neither , List .of (nodeId )).get (0 );
127128
128129 ExtensionObject xo = (ExtensionObject ) dataValue .getValue ().getValue ();
129130 assert xo != null ;
130131
131- return (DynamicStruct ) xo .decode (client .getDynamicEncodingContext ());
132+ return (DynamicType ) xo .decode (client .getDynamicEncodingContext ());
132133 }
133134
134- private static DynamicStruct [] readArrayValue (OpcUaClient client , NodeId nodeId )
135- throws Exception {
135+ private static DynamicType [] readArrayValue (OpcUaClient client , NodeId nodeId ) throws Exception {
136136 DataValue dataValue =
137137 client .readValues (0.0 , TimestampsToReturn .Neither , List .of (nodeId )).get (0 );
138138
@@ -141,13 +141,12 @@ private static DynamicStruct[] readArrayValue(OpcUaClient client, NodeId nodeId)
141141
142142 EncodingContext ctx = client .getDynamicEncodingContext ();
143143
144- return Arrays .stream (xos )
145- .map (xo -> (DynamicStruct ) xo .decode (ctx ))
146- .toArray (DynamicStruct []::new );
144+ return Arrays .stream (xos ).map (xo -> (DynamicType ) xo .decode (ctx )).toArray (DynamicType []::new );
147145 }
148146
149- private static StatusCode writeValue (OpcUaClient client , NodeId nodeId , DynamicStruct value )
147+ private static StatusCode writeValue (OpcUaClient client , NodeId nodeId , DynamicType value )
150148 throws Exception {
149+
151150 ExtensionObject xo =
152151 ExtensionObject .encodeDefaultBinary (
153152 client .getDynamicEncodingContext (), value , value .getDataType ().getBinaryEncodingId ());
0 commit comments