diff --git a/milo-examples/client-examples/src/main/java/org/eclipse/milo/examples/client/IJTReadCustomDataTypeExample.java b/milo-examples/client-examples/src/main/java/org/eclipse/milo/examples/client/IJTReadCustomDataTypeExample.java index 2f39a28e4..508add83c 100644 --- a/milo-examples/client-examples/src/main/java/org/eclipse/milo/examples/client/IJTReadCustomDataTypeExample.java +++ b/milo-examples/client-examples/src/main/java/org/eclipse/milo/examples/client/IJTReadCustomDataTypeExample.java @@ -1,7 +1,16 @@ +/* + * Copyright (c) 2024 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.examples.client; import java.util.concurrent.CompletableFuture; - import org.eclipse.milo.opcua.sdk.client.OpcUaClient; import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy; import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue; @@ -15,40 +24,40 @@ public class IJTReadCustomDataTypeExample implements ClientExample { - public static void main(String[] args) throws Exception { - var example = new IJTReadCustomDataTypeExample(); - - new ClientExampleRunner(example, false).run(); - } + public static void main(String[] args) throws Exception { + var example = new IJTReadCustomDataTypeExample(); - private final Logger logger = LoggerFactory.getLogger(getClass()); + new ClientExampleRunner(example, false).run(); + } - @Override - public void run(OpcUaClient client, CompletableFuture future) throws Exception { - client.setDataTypeManagerInitializer(new OpcUaClient.DefaultDataTypeManagerInitializer(JsonCodecFactory::create)); + private final Logger logger = LoggerFactory.getLogger(getClass()); - client.connect(); + @Override + public void run(OpcUaClient client, CompletableFuture future) throws Exception { + client.setDataTypeManagerInitializer( + new OpcUaClient.DefaultDataTypeManagerInitializer(JsonCodecFactory::create)); - NodeId nodeId = NodeId.parse("ns=1;s=TighteningSystem/ResultManagement/Results/Result"); - DataValue value = client.readValue(0, TimestampsToReturn.Both, nodeId); + client.connect(); - if (value.getValue().getValue() instanceof ExtensionObject xo) { - JsonStruct struct = (JsonStruct) xo.decode(client.getDynamicEncodingContext()); + NodeId nodeId = NodeId.parse("ns=1;s=TighteningSystem/ResultManagement/Results/Result"); + DataValue value = client.readValue(0, TimestampsToReturn.Both, nodeId); - System.out.println(struct); - } + if (value.getValue().getValue() instanceof ExtensionObject xo) { + JsonStruct struct = (JsonStruct) xo.decode(client.getDynamicEncodingContext()); - future.complete(client); + System.out.println(struct); } - @Override - public String getEndpointUrl() { - return "opc.tcp://10.211.55.3:40451"; - } + future.complete(client); + } - @Override - public SecurityPolicy getSecurityPolicy() { - return SecurityPolicy.None; - } + @Override + public String getEndpointUrl() { + return "opc.tcp://10.211.55.3:40451"; + } + @Override + public SecurityPolicy getSecurityPolicy() { + return SecurityPolicy.None; + } }