Search in sources :

Example 1 with ServerStatusTypeNode

use of org.eclipse.milo.opcua.sdk.client.model.nodes.variables.ServerStatusTypeNode 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 ServerStatusTypeNode

use of org.eclipse.milo.opcua.sdk.client.model.nodes.variables.ServerStatusTypeNode 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 3 with ServerStatusTypeNode

use of org.eclipse.milo.opcua.sdk.client.model.nodes.variables.ServerStatusTypeNode in project milo by eclipse.

the class AddressSpaceTest method getVariableNode.

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

Example 4 with ServerStatusTypeNode

use of org.eclipse.milo.opcua.sdk.client.model.nodes.variables.ServerStatusTypeNode in project milo by eclipse.

the class ServerTypeNode method setServerStatus.

@Override
public void setServerStatus(ServerStatusDataType serverStatus) throws UaException {
    ServerStatusTypeNode node = getServerStatusNode();
    ExtensionObject value = ExtensionObject.encode(client.getStaticSerializationContext(), serverStatus);
    node.setValue(new Variant(value));
}
Also used : Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) ServerStatusTypeNode(org.eclipse.milo.opcua.sdk.client.model.nodes.variables.ServerStatusTypeNode) ExtensionObject(org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject)

Aggregations

ServerStatusTypeNode (org.eclipse.milo.opcua.sdk.client.model.nodes.variables.ServerStatusTypeNode)4 ServerTypeNode (org.eclipse.milo.opcua.sdk.client.model.nodes.objects.ServerTypeNode)2 AbstractClientServerTest (org.eclipse.milo.opcua.sdk.test.AbstractClientServerTest)2 Test (org.junit.jupiter.api.Test)2 UaNode (org.eclipse.milo.opcua.sdk.client.nodes.UaNode)1 DateTime (org.eclipse.milo.opcua.stack.core.types.builtin.DateTime)1 ExtensionObject (org.eclipse.milo.opcua.stack.core.types.builtin.ExtensionObject)1 Variant (org.eclipse.milo.opcua.stack.core.types.builtin.Variant)1 ServerState (org.eclipse.milo.opcua.stack.core.types.enumerated.ServerState)1 BuildInfo (org.eclipse.milo.opcua.stack.core.types.structured.BuildInfo)1 ServerStatusDataType (org.eclipse.milo.opcua.stack.core.types.structured.ServerStatusDataType)1