Coder Social home page Coder Social logo

Comments (8)

0DennisLee0 avatar 0DennisLee0 commented on August 20, 2024 2

Hello Kevin, I have successfully import the NodeSet, and I have define some utils method, I wish it might be helpful for you.

@Slf4j
public class NodeUtils {

    public static void parseNodeSet(UaNodeSet nodeSet, UaNodeContext context, UaNodeManager nodeManager){
        Map<NodeId, NodeAttributes> nodes = nodeSet.getNodes();
        ListMultimap<NodeId, Reference> allReferences = nodeSet.getAllReferences();

        Map<NodeClass, List<NodeAttributes>> collect = nodes.values().stream()
                .collect(groupingBy(NodeAttributes::getNodeClass));

        for (NodeClass nodeClass : collect.keySet()) {
            if (nodeClass.equals(NodeClass.ObjectType)) {
                collect.get(NodeClass.ObjectType).stream()
                        .map(node -> ((ObjectTypeNodeAttributes) node))
                        .map(node -> node.getUaObjectTypeNode(context))
                        .forEach(nodeManager::addNode);
                log.info("ObjectType success");
            } else if (nodeClass.equals(NodeClass.VariableType)) {
                collect.get(NodeClass.VariableType).stream()
                        .map(node -> ((VariableTypeNodeAttributes) node))
                        .map(node -> node.getUaVariableTypeNode(context))
                        .forEach(nodeManager::addNode);
                log.info("VariableType success");
            } else if (nodeClass.equals(NodeClass.Object)) {
                collect.get(NodeClass.Object).stream()
                        .map(node -> ((ObjectNodeAttributes) node))
                        .map(node -> node.getObjectNode(context))
                        .forEach(nodeManager::addNode);
                log.info("Object success");
            } else if (nodeClass.equals(NodeClass.Variable)) {
                collect.get(NodeClass.Variable).stream()
                        .map(node -> ((VariableNodeAttributes) node))
                        .map(node -> node.getUaVariableNode(context))
                        .forEach(nodeManager::addNode);
                log.info("Variable success");
            } else if (nodeClass.equals(NodeClass.Method)) {
                collect.get(NodeClass.Method).stream()
                        .map(node -> ((MethodNodeAttributes) node))
                        .map(node -> node.getUaMethodNode(context))
                        .forEach(nodeManager::addNode);
                log.info("Method success");
            } else if (nodeClass.equals(NodeClass.DataType)) {
                collect.get(NodeClass.DataType).stream()
                        .map(node -> ((DataTypeNodeAttributes) node))
                        .map(node -> node.getDataTypeNode(context))
                        .forEach(nodeManager::addNode);
                log.info("DataType success");
            } else if (nodeClass.equals(NodeClass.View)) {
                collect.get(NodeClass.View).stream()
                        .map(node -> ((ViewNodeAttributes) node))
                        .map(node -> node.getUaViewNode(context))
                        .forEach(nodeManager::addNode);
                log.info("View success");
            } else if (nodeClass.equals(NodeClass.ReferenceType)) {
                collect.get(NodeClass.ReferenceType).stream()
                        .map(node -> ((ReferenceTypeNodeAttributes) node))
                        .map(node -> node.getReferenceTypeNode(context))
                        .forEach(nodeManager::addNode);
                log.info("ReferenceType success");
            }
        }

        allReferences.values()
                .forEach(nodeManager::addReference);
    }
}

and for each type of node, I have added some functions like this:

public class ObjectNodeAttributes extends NodeAttributes {
    
    /* Ignored parts */
    
    public UaObjectNode getObjectNode(UaNodeContext context){
        return new UaObjectNode(
                context,
                getNodeId(),
                getBrowseName(),
                getDisplayName(),
                getDescription(),
                getWriteMask(),
                getUserWriteMask(),
                getEventNotifier()
        );
    }
}

from opc-ua-nodeset-parser.

kevinherron avatar kevinherron commented on August 20, 2024 1

This library is used by the code generator but the generator itself not currently open source yet.

I may be able to generate these Nodes for you, though, and if you’re willing to use the dev/0.4 branch of Milo they might be usable.

from opc-ua-nodeset-parser.

kevinherron avatar kevinherron commented on August 20, 2024 1

Those classes are generated at build time. If you run mvn clean build from the root of your check out they will get generated.

from opc-ua-nodeset-parser.

0DennisLee0 avatar 0DennisLee0 commented on August 20, 2024

This library is used by the code generator but the generator itself not currently open source yet.

I may be able to generate these Nodes for you, though, and if you’re willing to use the dev/0.4 branch of Milo they might be usable.

3Q for your reply. And I found the import in milo is
import org.opcfoundation.**opcua**.binaryschema.TypeDictionary;
However the sdk of opcfoundation is named
'
import org.opcfoundation.ua
'
And has no class named TypeDeictionary and so does the others,

from opc-ua-nodeset-parser.

0DennisLee0 avatar 0DennisLee0 commented on August 20, 2024

i will take some time to make it out, 3Q for your help~

from opc-ua-nodeset-parser.

0DennisLee0 avatar 0DennisLee0 commented on August 20, 2024

And I found the ua-server-sdk 0.4.0-SNAPSHOT hasn't been published yet. I'm pretty looking forward to its coming out~^_^

from opc-ua-nodeset-parser.

kevinherron avatar kevinherron commented on August 20, 2024

@0DennisLee0 I posted some example code of how I'm using this library to build an AddressSpace from a UANodeSet in another issue: #7 (comment)

from opc-ua-nodeset-parser.

0DennisLee0 avatar 0DennisLee0 commented on August 20, 2024

Thank you for your kindly reply~

from opc-ua-nodeset-parser.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.