I have created testing_nodeset2.xml using siemens SiOME modelling editor , so first of all i imported opcua device , opcua machinery and opcua pump xml files into editor and then created own namespace using companion specification . finally i exported testing_noeset2.xml file. Now i want to import xml files.
- is the correct way to create own namespace ?
- do i need to import all xml files into python code according opcua companion specification ?
here is the code:
import asyncio
async def main():
server = Server()
await server.init()
server.set_endpoint("opc.tcp://192.168.1.216:4000")
await server.import_xml("Opc.Ua.Nodeset2.xml")
await server.import_xml("Opc.Ua.Di.Nodeset2.xml")
await server.import_xml("Opc.Ua.Machinery.Nodeset2.xml")
await server.import_xml("Opc.Ua.Pumps.Nodeset2.xml")
await server.import_xml("testing_Nodeset.xml")
await server.start()
if __name__ == "__main__":
asyncio.run(main())```
here is the error i am getting :
AddNodesItem: Requested NodeId NodeId(Identifier=3062, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>) already exists
failure adding node NodeData(nodeid:NodeId(Identifier=3062, NamespaceIndex=0, NodeIdType=<NodeIdType.Numeric: 2>)) "The requested node id is already used by another node."(BadNodeIdExists)
Traceback (most recent call last):
File "c:\Users\user\OneDrive\Desktop\thesis\opcua\opc_server\opc_server\nodeset file testing\nodeset.py", line 50, in <module>
asyncio.run(main())
File "C:\Program Files\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Program Files\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
File "c:\Users\user\OneDrive\Desktop\thesis\opcua\opc_server\opc_server\nodeset file testing\nodeset.py", line 40, in main
await server.import_xml("Opc.Ua.Nodeset2.xml")
File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\asyncua\server\server.py", li node = await self._add_node_data(nodedata, no_namespace_migration=True)
File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\asyncua\common\xmlimporter.py", line 228, in _add_node_data
node = await self.add_object(nodedata, no_namespace_migration)
File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\asyncua\common\xmlimporter.py", line 349, in add_object
res[0].StatusCode.check()
File "C:\Users\user\AppData\Roaming\Python\Python310\site-packages\asyncua\ua\uatypes.py", line 328, in check
raise UaStatusCodeError(self.value)
asyncua.ua.uaerrors._auto.BadNodeIdExists: "The requested node id is already used by another node."(BadNodeIdExists)
does anybody has an idea , how can this error be solved?
your advice and solution would be apreciated.