访问OPCUA服务器地址空间中的节点

时间:2019-06-06 21:30:55

标签: java android opc-ua

我是JAVA,Android和OPCUA的新手。 我需要开发一个Android应用程序,该程序可以自动执行服务器中的少量操作。

首先,经过一些研究,我能够通过代码访问节点的值。通过提供名称空间值和nodeID。

现在,我期待通过APP本身对值进行更改。为此,我应该具有服务器中可用的节点列表。

我无法找到一种显示它们的方法。

请提出任何建议

关于代码的简要介绍


ApplicationDescription applicationDescription = new ApplicationDescription();
applicationDescription.setApplicationName(new LocalizedText(“AndroidClient”, Locale.ENGLISH));
applicationDescription.setApplicationUri(“urn:localhost:AndroidClient”);
applicationDescription.setProductUri(“urn:localhost:AndroidClient”);
applicationDescription.setApplicationType(ApplicationType.Client);
KeyPair myClientApplicationInstanceCertificate = ExampleKeys.getCert(getApplicationContext(), applicationDescription);

// Create Client
Client myClient = Client.createClientApplication(myClientApplicationInstanceCertificate);
EndpointDescription[] endpoints = myClient.discoverEndpoints(“opc.tcp://192.168.4.1:4840”) //connect to my server

// Filter out all but opc.tcp protocol endpoints
endpoints = EndpointUtil.selectByProtocol(endpoints, “opc.tcp”);

// Filter out all but Signed & Encrypted endpoints
endpoints = EndpointUtil.selectByMessageSecurityMode(endpoints, MessageSecurityMode.None);

// Filter out all but Basic256Sha256 cryption endpoints
endpoints = EndpointUtil.selectBySecurityPolicy(endpoints, SecurityPolicy.NONE);

// Sort endpoints by security level. The lowest level at the beginning, the highest at the end of the array
endpoints = EndpointUtil.sortBySecurityLevel(endpoints);

// Choose one endpoint.
EndpointDescription endpoint = endpoints[endpoints.length – 1];

SessionChannel mySession = myClient.createSessionChannel(endpoint);
mySession.activate();

0 个答案:

没有答案