Search in sources :

Example 1 with ServerTypeNode

use of org.eclipse.milo.opcua.sdk.client.model.nodes.objects.ServerTypeNode in project milo by eclipse.

the class ReadNodeExample method run.

@Override
public void run(OpcUaClient client, CompletableFuture<OpcUaClient> future) throws Exception {
    // synchronous connect
    client.connect().get();
    // Get a typed reference to the Server object: ServerNode
    ServerTypeNode serverNode = (ServerTypeNode) client.getAddressSpace().getObjectNode(Identifiers.Server, Identifiers.ServerType);
    // Read properties of the Server object...
    String[] serverArray = serverNode.getServerArray();
    String[] namespaceArray = serverNode.getNamespaceArray();
    logger.info("ServerArray={}", Arrays.toString(serverArray));
    logger.info("NamespaceArray={}", Arrays.toString(namespaceArray));
    // Read the value of attribute the ServerStatus variable component
    ServerStatusDataType serverStatus = serverNode.getServerStatus();
    logger.info("ServerStatus={}", serverStatus);
    // Get a typed reference to the ServerStatus variable
    // component and read value attributes individually
    ServerStatusTypeNode serverStatusNode = serverNode.getServerStatusNode();
    BuildInfo buildInfo = serverStatusNode.getBuildInfo();
    DateTime startTime = serverStatusNode.getStartTime();
    DateTime currentTime = serverStatusNode.getCurrentTime();
    ServerState state = serverStatusNode.getState();
    logger.info("ServerStatus.BuildInfo={}", buildInfo);
    logger.info("ServerStatus.StartTime={}", startTime);
    logger.info("ServerStatus.CurrentTime={}", currentTime);
    logger.info("ServerStatus.State={}", state);
    future.complete(client);
}
Also used : ServerStatusDataType(org.eclipse.milo.opcua.stack.core.types.structured.ServerStatusDataType) ServerTypeNode(org.eclipse.milo.opcua.sdk.client.model.nodes.objects.ServerTypeNode) ServerStatusTypeNode(org.eclipse.milo.opcua.sdk.client.model.nodes.variables.ServerStatusTypeNode) BuildInfo(org.eclipse.milo.opcua.stack.core.types.structured.BuildInfo) ServerState(org.eclipse.milo.opcua.stack.core.types.enumerated.ServerState) DateTime(org.eclipse.milo.opcua.stack.core.types.builtin.DateTime)

Example 2 with ServerTypeNode

use of org.eclipse.milo.opcua.sdk.client.model.nodes.objects.ServerTypeNode in project milo by eclipse.

the class UaNodeTest method serverNode_ServerStatusNode_BuildInfo.

@Test
public void serverNode_ServerStatusNode_BuildInfo() throws UaException {
    AddressSpace addressSpace = client.getAddressSpace();
    ServerTypeNode serverNode = (ServerTypeNode) addressSpace.getNode(Identifiers.Server);
    BuildInfo buildInfo1 = serverNode.getServerStatusNode().getBuildInfo();
    assertNotNull(buildInfo1);
    BuildInfo buildInfo2 = serverNode.getServerStatusNode().readBuildInfo();
    assertNotNull(buildInfo2);
    assertEquals(buildInfo1, buildInfo2);
}
Also used : ServerTypeNode(org.eclipse.milo.opcua.sdk.client.model.nodes.objects.ServerTypeNode) BuildInfo(org.eclipse.milo.opcua.stack.core.types.structured.BuildInfo) Test(org.junit.jupiter.api.Test) AbstractClientServerTest(org.eclipse.milo.opcua.sdk.test.AbstractClientServerTest)

Example 3 with ServerTypeNode

use of org.eclipse.milo.opcua.sdk.client.model.nodes.objects.ServerTypeNode in project milo by eclipse.

the class UaNodeTest method invalidate.

@Test
public void invalidate() throws UaException {
    AddressSpace addressSpace = client.getAddressSpace();
    ServerTypeNode serverNode1 = (ServerTypeNode) addressSpace.getNode(Identifiers.Server);
    serverNode1.invalidate();
    ServerTypeNode serverNode2 = (ServerTypeNode) addressSpace.getNode(Identifiers.Server);
    assertNotSame(serverNode1, serverNode2);
}
Also used : ServerTypeNode(org.eclipse.milo.opcua.sdk.client.model.nodes.objects.ServerTypeNode) Test(org.junit.jupiter.api.Test) AbstractClientServerTest(org.eclipse.milo.opcua.sdk.test.AbstractClientServerTest)

Example 4 with ServerTypeNode

use of org.eclipse.milo.opcua.sdk.client.model.nodes.objects.ServerTypeNode in project milo by eclipse.

the class AddressSpaceTest method getNode.

@Test
public void getNode() throws UaException {
    AddressSpace addressSpace = client.getAddressSpace();
    UaNode serverNode = addressSpace.getNode(Identifiers.Server);
    assertNotNull(serverNode);
    assertTrue(serverNode instanceof ServerTypeNode);
    UaNode serverStatusNode = addressSpace.getNode(Identifiers.Server_ServerStatus);
    assertNotNull(serverStatusNode);
    assertTrue(serverStatusNode instanceof ServerStatusTypeNode);
}
Also used : ServerTypeNode(org.eclipse.milo.opcua.sdk.client.model.nodes.objects.ServerTypeNode) ServerStatusTypeNode(org.eclipse.milo.opcua.sdk.client.model.nodes.variables.ServerStatusTypeNode) UaNode(org.eclipse.milo.opcua.sdk.client.nodes.UaNode) Test(org.junit.jupiter.api.Test) AbstractClientServerTest(org.eclipse.milo.opcua.sdk.test.AbstractClientServerTest)

Example 5 with ServerTypeNode

use of org.eclipse.milo.opcua.sdk.client.model.nodes.objects.ServerTypeNode in project milo by eclipse.

the class AddressSpaceTest method getObjectNode.

@Test
public void getObjectNode() throws UaException {
    AddressSpace addressSpace = client.getAddressSpace();
    ServerTypeNode serverNode = (ServerTypeNode) addressSpace.getObjectNode(Identifiers.Server);
    assertNotNull(serverNode);
    assertEquals(Identifiers.Server, serverNode.getNodeId());
    // should be cached now, check instance equality
    assertSame(serverNode, addressSpace.getObjectNode(Identifiers.Server));
}
Also used : ServerTypeNode(org.eclipse.milo.opcua.sdk.client.model.nodes.objects.ServerTypeNode) Test(org.junit.jupiter.api.Test) AbstractClientServerTest(org.eclipse.milo.opcua.sdk.test.AbstractClientServerTest)

Aggregations

ServerTypeNode (org.eclipse.milo.opcua.sdk.client.model.nodes.objects.ServerTypeNode)7 AbstractClientServerTest (org.eclipse.milo.opcua.sdk.test.AbstractClientServerTest)5 Test (org.junit.jupiter.api.Test)5 ServerStatusTypeNode (org.eclipse.milo.opcua.sdk.client.model.nodes.variables.ServerStatusTypeNode)2 BuildInfo (org.eclipse.milo.opcua.stack.core.types.structured.BuildInfo)2 Path (java.nio.file.Path)1 ExecutionException (java.util.concurrent.ExecutionException)1 OpcUaClientConfigBuilder (org.eclipse.milo.opcua.sdk.client.api.config.OpcUaClientConfigBuilder)1 AnonymousProvider (org.eclipse.milo.opcua.sdk.client.api.identity.AnonymousProvider)1 UaNode (org.eclipse.milo.opcua.sdk.client.nodes.UaNode)1 UaException (org.eclipse.milo.opcua.stack.core.UaException)1 DateTime (org.eclipse.milo.opcua.stack.core.types.builtin.DateTime)1 ServerState (org.eclipse.milo.opcua.stack.core.types.enumerated.ServerState)1 EndpointDescription (org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription)1 ServerStatusDataType (org.eclipse.milo.opcua.stack.core.types.structured.ServerStatusDataType)1 Connect (org.openmuc.framework.driver.annotation.Connect)1 ConnectionException (org.openmuc.framework.driver.spi.ConnectionException)1