Populating opcua address space with Nodes from an xml schema

狂风中的少年 提交于 2019-12-08 01:48:54

问题


Am working on a project to build an opc ua server from specification,

I've gone far enough on the implementation, am currently working on the write request, I already have a few nodes in the server address space.

There seem to be so many nodes, so many actually. It's almost impossible to create and add the Nodes one by one.

Anyways back to the question, I've downloaded an xml file from opc foundation containing schema for all the nodes in the address space, Here is a link to the xml file

What is the most efficient way to create nodes from the xml file ? I am writing on a c95 compiler.

Below is a quick view of how Nodes are represented in the nodeset Xml file,

<Nodes>
<Node i:type="DataTypeNode">
  <NodeId>
    <Identifier>i=1</Identifier>
  </NodeId>
  <NodeClass>DataType_64</NodeClass>
  <BrowseName>
    <NamespaceIndex>0</NamespaceIndex>
    <Name>Boolean</Name>
  </BrowseName>
  <DisplayName>
    <Locale></Locale>
    <Text>Boolean</Text>
  </DisplayName>
  <Description>
    <Locale></Locale>
    <Text>Describes a value that is either TRUE or FALSE.</Text>
  </Description>
  <WriteMask>0</WriteMask>
  <UserWriteMask>0</UserWriteMask>
  <RolePermissions />
  <UserRolePermissions />
  <AccessRestrictions>0</AccessRestrictions>
  <References>
    <ReferenceNode>
      <ReferenceTypeId>
        <Identifier>i=45</Identifier>
      </ReferenceTypeId>
      <IsInverse>true</IsInverse>
      <TargetId>
        <Identifier>i=24</Identifier>
      </TargetId>
    </ReferenceNode>
  </References>
  <IsAbstract>false</IsAbstract>
  <DataTypeDefinition i:nil="true" />
</Node>

回答1:


Programatically filling a running OPC-UA server with nodes is unacceptably slow.

you may want to investigate the ModelCompiler. I found it fairly straightforward to fill a modeldesign XML with data and generate code and NodeSet2.xml. So even if you have no need for the generated C# code, which I suspect to be your case, this approach may be useful.

You may also want to look at the UA-.NETStandard repository. It offers a method LoadFromXML method that reads your nodeset pretty quickly. You may find inspiration in this method.

Bon courage et un grand merci pour vos contributions au monde OPC-UA.




回答2:


Maybe I'm a bit late, but I answer if it can help someone.

If you are using C/C++ with open62541 SDK I found that it is possible to generate *.c and *.h files to include in your opcua server, as described with some examples here: you only need to run a python program, providing some parameters and the name of output files to be generated, then include these files in your opcua server.

Another way that I found is using UaModeler by Unified Automation, in that case you can generate source files to include in your project, drawing your information model in the program and exporting it to xml or source files.



来源:https://stackoverflow.com/questions/49983225/populating-opcua-address-space-with-nodes-from-an-xml-schema

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!