Esempio n. 1
0
  public CompletableFuture<TestStackResponse> testStack(int input) {
    RequestHeader header =
        new RequestHeader(
            NodeId.NULL_VALUE,
            DateTime.now(),
            uint(requestHandle.getAndIncrement()),
            uint(0),
            null,
            uint(60),
            null);

    TestStackRequest request = new TestStackRequest(header, uint(0), 1, new Variant(input));

    return client.sendRequest(request);
  }
Esempio n. 2
0
  public ClientExample(X509Certificate certificate, KeyPair keyPair) throws Exception {
    // Query endpoints and select highest security level.
    EndpointDescription[] endpoints =
        UaTcpStackClient.getEndpoints("opc.tcp://localhost:12685/example").get();

    EndpointDescription endpoint =
        Arrays.stream(endpoints)
            .sorted((e1, e2) -> e2.getSecurityLevel().intValue() - e1.getSecurityLevel().intValue())
            .findFirst()
            .orElseThrow(() -> new Exception("no endpoints returned"));

    UaTcpStackClientConfig config =
        UaTcpStackClientConfig.builder()
            .setApplicationName(LocalizedText.english("Stack Example Client"))
            .setApplicationUri(String.format("urn:example-client:%s", UUID.randomUUID()))
            .setCertificate(certificate)
            .setKeyPair(keyPair)
            .setEndpoint(endpoint)
            .build();

    client = new UaTcpStackClient(config);
  }
Esempio n. 3
0
 public CompletableFuture<UaStackClient> disconnect() {
   return client.disconnect();
 }