Search in sources :

Example 1 with AnalogItemTypeNode

use of org.eclipse.milo.opcua.sdk.server.model.nodes.variables.AnalogItemTypeNode in project FAAAST-Service by FraunhoferIOSB.

the class ExampleNamespace method addDataAccessNodes.

private void addDataAccessNodes(UaFolderNode rootNode) {
    // DataAccess folder
    UaFolderNode dataAccessFolder = new UaFolderNode(getNodeContext(), newNodeId("HelloWorld/DataAccess"), newQualifiedName("DataAccess"), LocalizedText.english("DataAccess"));
    getNodeManager().addNode(dataAccessFolder);
    rootNode.addOrganizes(dataAccessFolder);
    try {
        AnalogItemTypeNode node = (AnalogItemTypeNode) getNodeFactory().createNode(newNodeId("HelloWorld/DataAccess/AnalogValue"), Identifiers.AnalogItemType, new NodeFactory.InstantiationCallback() {

            @Override
            public boolean includeOptionalNode(NodeId typeDefinitionId, QualifiedName browseName) {
                return true;
            }
        });
        node.setBrowseName(newQualifiedName("AnalogValue"));
        node.setDisplayName(LocalizedText.english("AnalogValue"));
        node.setDataType(Identifiers.Double);
        node.setValue(new DataValue(new Variant(3.14d)));
        node.setEURange(new Range(0.0, 100.0));
        getNodeManager().addNode(node);
        dataAccessFolder.addOrganizes(node);
    } catch (UaException e) {
        logger.error("Error creating AnalogItemType instance: {}", e.getMessage(), e);
    }
}
Also used : Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) AnalogItemTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.variables.AnalogItemTypeNode) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) UaException(org.eclipse.milo.opcua.stack.core.UaException) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) UaFolderNode(org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode) Range(org.eclipse.milo.opcua.stack.core.types.structured.Range)

Example 2 with AnalogItemTypeNode

use of org.eclipse.milo.opcua.sdk.server.model.nodes.variables.AnalogItemTypeNode in project milo by eclipse.

the class ExampleNamespace method addDataAccessNodes.

private void addDataAccessNodes(UaFolderNode rootNode) {
    // DataAccess folder
    UaFolderNode dataAccessFolder = new UaFolderNode(getNodeContext(), newNodeId("HelloWorld/DataAccess"), newQualifiedName("DataAccess"), LocalizedText.english("DataAccess"));
    getNodeManager().addNode(dataAccessFolder);
    rootNode.addOrganizes(dataAccessFolder);
    try {
        AnalogItemTypeNode node = (AnalogItemTypeNode) getNodeFactory().createNode(newNodeId("HelloWorld/DataAccess/AnalogValue"), Identifiers.AnalogItemType, new NodeFactory.InstantiationCallback() {

            @Override
            public boolean includeOptionalNode(NodeId typeDefinitionId, QualifiedName browseName) {
                return true;
            }
        });
        node.setBrowseName(newQualifiedName("AnalogValue"));
        node.setDisplayName(LocalizedText.english("AnalogValue"));
        node.setDataType(Identifiers.Double);
        node.setValue(new DataValue(new Variant(3.14d)));
        node.setEURange(new Range(0.0, 100.0));
        getNodeManager().addNode(node);
        dataAccessFolder.addOrganizes(node);
    } catch (UaException e) {
        logger.error("Error creating AnalogItemType instance: {}", e.getMessage(), e);
    }
}
Also used : Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) AnalogItemTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.variables.AnalogItemTypeNode) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) UaException(org.eclipse.milo.opcua.stack.core.UaException) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) UaFolderNode(org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode) Range(org.eclipse.milo.opcua.stack.core.types.structured.Range)

Example 3 with AnalogItemTypeNode

use of org.eclipse.milo.opcua.sdk.server.model.nodes.variables.AnalogItemTypeNode in project milo by eclipse.

the class UaNodeTest method testCreateDeleteComplexInstance.

@Test
public void testCreateDeleteComplexInstance() throws UaException {
    NodeId nodeId = new NodeId(1, "TestAnalog");
    UaNodeManager nodeManager = new UaNodeManager();
    server.getAddressSpaceManager().register(nodeManager);
    assertFalse(nodeManager.containsNode(nodeId));
    assertEquals(0, nodeManager.getReferences(nodeId).size());
    NodeFactory nodeFactory = new NodeFactory(new UaNodeContext() {

        @Override
        public OpcUaServer getServer() {
            return server;
        }

        @Override
        public NodeManager<UaNode> getNodeManager() {
            return nodeManager;
        }
    });
    AnalogItemTypeNode analogItem = (AnalogItemTypeNode) nodeFactory.createNode(nodeId, Identifiers.AnalogItemType, new NodeFactory.InstantiationCallback() {

        @Override
        public boolean includeOptionalNode(NodeId typeDefinitionId, QualifiedName browseName) {
            return true;
        }
    });
    assertTrue(nodeManager.containsNode(nodeId));
    assertTrue(nodeManager.getReferences(nodeId).size() > 0);
    analogItem.delete();
    assertFalse(nodeManager.containsNode(nodeId));
    assertEquals(0, nodeManager.getReferences(nodeId).size());
}
Also used : NodeManager(org.eclipse.milo.opcua.sdk.server.api.NodeManager) UaNodeManager(org.eclipse.milo.opcua.sdk.server.UaNodeManager) OpcUaServer(org.eclipse.milo.opcua.sdk.server.OpcUaServer) AnalogItemTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.variables.AnalogItemTypeNode) UaNodeManager(org.eclipse.milo.opcua.sdk.server.UaNodeManager) NodeFactory(org.eclipse.milo.opcua.sdk.server.nodes.factories.NodeFactory) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 4 with AnalogItemTypeNode

use of org.eclipse.milo.opcua.sdk.server.model.nodes.variables.AnalogItemTypeNode in project milo by eclipse.

the class NodeFactoryTest method testCreateAnalogItemType.

@Test
public void testCreateAnalogItemType() throws Exception {
    AnalogItemTypeNode analogItem = (AnalogItemTypeNode) nodeFactory.createNode(new NodeId(1, "TestAnalog"), Identifiers.AnalogItemType, new NodeFactory.InstantiationCallback() {

        @Override
        public boolean includeOptionalNode(NodeId typeDefinitionId, QualifiedName browseName) {
            return true;
        }
    });
    assertNotNull(analogItem);
    assertTrue(nodeManager.containsNode(analogItem));
}
Also used : AnalogItemTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.variables.AnalogItemTypeNode) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) ExpandedNodeId(org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 5 with AnalogItemTypeNode

use of org.eclipse.milo.opcua.sdk.server.model.nodes.variables.AnalogItemTypeNode in project tech-pdai-spring-demos by realpdai.

the class ExampleNamespace method addDataAccessNodes.

private void addDataAccessNodes(UaFolderNode rootNode) {
    // DataAccess folder
    UaFolderNode dataAccessFolder = new UaFolderNode(getNodeContext(), newNodeId("HelloWorld/DataAccess"), newQualifiedName("DataAccess"), LocalizedText.english("DataAccess"));
    getNodeManager().addNode(dataAccessFolder);
    rootNode.addOrganizes(dataAccessFolder);
    try {
        AnalogItemTypeNode node = (AnalogItemTypeNode) getNodeFactory().createNode(newNodeId("HelloWorld/DataAccess/AnalogValue"), Identifiers.AnalogItemType, new NodeFactory.InstantiationCallback() {

            @Override
            public boolean includeOptionalNode(NodeId typeDefinitionId, QualifiedName browseName) {
                return true;
            }
        });
        node.setBrowseName(newQualifiedName("AnalogValue"));
        node.setDisplayName(LocalizedText.english("AnalogValue"));
        node.setDataType(Identifiers.Double);
        node.setValue(new DataValue(new Variant(3.14d)));
        node.setEURange(new Range(0.0, 100.0));
        getNodeManager().addNode(node);
        dataAccessFolder.addOrganizes(node);
    } catch (UaException e) {
        logger.error("Error creating AnalogItemType instance: {}", e.getMessage(), e);
    }
}
Also used : Variant(org.eclipse.milo.opcua.stack.core.types.builtin.Variant) AnalogItemTypeNode(org.eclipse.milo.opcua.sdk.server.model.nodes.variables.AnalogItemTypeNode) DataValue(org.eclipse.milo.opcua.stack.core.types.builtin.DataValue) UaException(org.eclipse.milo.opcua.stack.core.UaException) QualifiedName(org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName) NodeId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId) UaFolderNode(org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode) Range(org.eclipse.milo.opcua.stack.core.types.structured.Range)

Aggregations

AnalogItemTypeNode (org.eclipse.milo.opcua.sdk.server.model.nodes.variables.AnalogItemTypeNode)5 NodeId (org.eclipse.milo.opcua.stack.core.types.builtin.NodeId)5 QualifiedName (org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName)5 UaFolderNode (org.eclipse.milo.opcua.sdk.server.nodes.UaFolderNode)3 UaException (org.eclipse.milo.opcua.stack.core.UaException)3 DataValue (org.eclipse.milo.opcua.stack.core.types.builtin.DataValue)3 Variant (org.eclipse.milo.opcua.stack.core.types.builtin.Variant)3 Range (org.eclipse.milo.opcua.stack.core.types.structured.Range)3 BeforeTest (org.testng.annotations.BeforeTest)2 Test (org.testng.annotations.Test)2 OpcUaServer (org.eclipse.milo.opcua.sdk.server.OpcUaServer)1 UaNodeManager (org.eclipse.milo.opcua.sdk.server.UaNodeManager)1 NodeManager (org.eclipse.milo.opcua.sdk.server.api.NodeManager)1 NodeFactory (org.eclipse.milo.opcua.sdk.server.nodes.factories.NodeFactory)1 ExpandedNodeId (org.eclipse.milo.opcua.stack.core.types.builtin.ExpandedNodeId)1