当前位置:网站首页>Open62541 import nodeset file directly

Open62541 import nodeset file directly

2022-06-28 07:15:00 Yaojiawan

upc ua Modeling is usually done using modeling tools ( such as uaModeler), Direct output C,C++,C# Source code , Then with OPC UA The server code is compiled together .opc ua The same is true for open source projects . It provides a python Compiling nodeset_compiler Tools . take nodeset.XML Compile it into myNS.c and .h file . Then combine to server In the code of .

  If you are developing a specific product , its opc ua The model is predetermined . Then it can be tolerated , After all, this is the work done by programmers . however , If the developed product is a general product , need OT Engineers to build OPC UA Model of . So for OT Engineers are too much trouble . They are not good at such work .

   The solution is by server Program to dynamically build opc ua Model . stay server In the program of nodeset.xml file , from server The program in is built automatically server End of the information model . Realization opc ua Dynamic modeling of server .

 

 

stay Server Use... In the program nodeset.xml What is built is the type of object (objectType), Then instantiate the object type , Additional information is needed . They use configuration.xml Provide .

Implementation details

use first uamodeler Software build one opcua Of nodeset Model . And output nodeset.xml file .

<?xml version="1.0" encoding="utf-8"?>
<UANodeSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd" xmlns="http://opcfoundation.org/UA/2011/03/UANodeSet.xsd" xmlns:s1="http://yourorganisation.org/demo2022/Types.xsd" xmlns:ua="http://unifiedautomation.com/Configuration/NodeSet.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <NamespaceUris>
        <Uri>http://yourorganisation.org/demo2022/</Uri>
    </NamespaceUris>
    <Aliases>
        <Alias Alias="Boolean">i=1</Alias>
        <Alias Alias="Double">i=11</Alias>
        <Alias Alias="HasTypeDefinition">i=40</Alias>
        <Alias Alias="HasComponent">i=47</Alias>
    </Aliases>
    <Extensions>
        <Extension>
            <ua:ModelInfo Tool="UaModeler" Hash="Yl8uWJaLMTz0jvkxYQoGkw==" Version="1.6.0"/>
        </Extension>
    </Extensions>
    <UAObject NodeId="ns=1;i=5001" BrowseName="1:Meter">
        <DisplayName>Meter</DisplayName>
        <References>
            <Reference ReferenceType="HasTypeDefinition">i=58</Reference>
            <Reference ReferenceType="HasComponent">ns=1;i=6001</Reference>
            <Reference ReferenceType="HasComponent">ns=1;i=5002</Reference>
            <Reference ReferenceType="HasComponent">ns=1;i=6002</Reference>
            <Reference ReferenceType="HasComponent" IsForward="false">i=85</Reference>
        </References>
    </UAObject>
    <UAVariable DataType="Double" NodeId="ns=1;i=6001" BrowseName="1:Current" AccessLevel="3">
        <DisplayName>Current</DisplayName>
        <References>
            <Reference ReferenceType="HasTypeDefinition">i=63</Reference>
            <Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=5001</Reference>
        </References>
    </UAVariable>
    <UAObject NodeId="ns=1;i=5002" BrowseName="1:Switch">
        <DisplayName>Switch</DisplayName>
        <References>
            <Reference ReferenceType="HasTypeDefinition">i=58</Reference>
            <Reference ReferenceType="HasComponent">ns=1;i=6004</Reference>
            <Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=5001</Reference>
        </References>
    </UAObject>
    <UAVariable DataType="Boolean" NodeId="ns=1;i=6004" BrowseName="1:Status" AccessLevel="3">
        <DisplayName>Status</DisplayName>
        <References>
            <Reference ReferenceType="HasTypeDefinition">i=63</Reference>
            <Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=5002</Reference>
        </References>
    </UAVariable>
    <UAVariable DataType="Double" NodeId="ns=1;i=6002" BrowseName="1:Voltage" AccessLevel="3">
        <DisplayName>Voltage</DisplayName>
        <References>
            <Reference ReferenceType="HasTypeDefinition">i=63</Reference>
            <Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=5001</Reference>
        </References>
    </UAVariable>
    <UAVariable DataType="Double" NodeId="ns=1;i=6003" BrowseName="1:Temperature" AccessLevel="3">
        <DisplayName>Temperature</DisplayName>
        <References>
            <Reference ReferenceType="HasTypeDefinition">i=63</Reference>
            <Reference ReferenceType="HasComponent" IsForward="false">i=85</Reference>
        </References>
    </UAVariable>
</UANodeSet>

The second step : Write a by hand configuration.xml file . After this step, you can use a small software tool , Generated in configuration mode .

<?xml version="1.0" encoding="utf-8"?>
<UAObject NodeId="ns=1;i=5001" BrowseName="1:Meter">
<Param BrowseName="Meter1">
<DisplayName>
Meter 1
</DisplayName>
<Description>Electricity Meter 1</Description>
</Param>
<UAVariable DataType="Double" NodeId="ns=1;i=6001" BrowseName="1:Current" AccessLevel="3">
<Value>10</Value>
<DataSource></DataSource>
</UAVariable>
<UAVariable DataType="Double" NodeId="ns=1;i=6002" BrowseName="1:Voltage" AccessLevel="3">
<Value>220</Value>
</UAVariable>
<UAObject NodeId="ns=1;i=5002" BrowseName="1:Switch">
<Param BrowseName="Meter1">
<DisplayName>
Meter 1
</DisplayName>
</Param>
<UAVariable DataType="Boolean" NodeId="ns=1;i=6004" BrowseName="1:Status" AccessLevel="3">
<Value>On</Value>
</UAVariable>
</UAObject>
<UAVariable DataType="Double" NodeId="ns=1;i=6003" BrowseName="1:Temperature" AccessLevel="3">
<Value>25.6</Value>
</UAVariable>
</UAObject>

From the code above ,configuration.XML The following content has been added to

1 Object The parameters of the node BrowseName,DisplayName,Description They use Param describe

<Param BrowseName="Meter1">
<DisplayName>
Meter 1
</DisplayName>
<Description>Electricity Meter 1</Description>
</Param>

2 Variable Node added Value and DataSource These are the initial values (Value) And the address corresponding to the hardware (DataSource)

<UAVariable DataType="Double" NodeId="ns=1;i=6001" BrowseName="1:Current" AccessLevel="3">
<Value>10</Value>
<DataSource></DataSource>
</UAVariable>

The third step : from Nodeset.xml produce ObjectType node ( Hang in the air )

Step four : from Configuration.XML produce Object example , And initialize .( Hang in the air )

Conclusion

  At present, it is only a technical solution , When finished, it will be updated . Please give me more comments !

原网站

版权声明
本文为[Yaojiawan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/179/202206280710217364.html