Open anshi43 opened 1 year ago
asyncua.ua.uaerrors._auto.BadNodeIdExists: "The requested node id is already used by another node."(BadNodeIdExists)
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") <-- already exist in default addressspace!!!
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()
asyncua.ua.uaerrors._auto.BadNodeIdExists: "The requested node id is already used by another node."(BadNodeIdExists)
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") <-- already exist in default addressspace!!! 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()
but then when i only import testing_Nodeset.xml , it shows an error : raise ValueError("Server doesn't satisfy required XML-Models. Import them first!") ValueError: Server doesn't satisfy required XML-Models. Import them first
and
when i import only last four xml file as you mentioned above then this error occur : raise UaError(f"Attribute '{attname}' defined in xml is not found in object '{objclass}'") asyncua.ua.uaerrors._base.UaError: Attribute 'EncodingMask' defined in xml is not found in object '<class 'PhysicalAddressDataType'>
what is the right way to import xml files ?
but that is you root cause!
each xml has the required models part built in! you need to look which versions you used in the testing_Nodeset.xml and below. the error is thorwn because there is a mismatch!
it looks like:
<Models>
<Model ModelUri="http://example.com/ShowcaseMachineTool/" PublicationDate="2022-03-14T12:41:36Z" Version="1.0.1">
<RequiredModel ModelUri="http://opcfoundation.org/UA/" PublicationDate="2020-07-15T00:00:00Z" Version="1.04.7"/>
<RequiredModel ModelUri="http://opcfoundation.org/UA/DI/" PublicationDate="2020-06-02T00:00:00Z" Version="1.02.2"/>
<RequiredModel ModelUri="http://opcfoundation.org/UA/Machinery/" PublicationDate="2021-02-25T00:00:00Z" Version="1.01.0"/>
<RequiredModel ModelUri="http://opcfoundation.org/UA/IA/" PublicationDate="2021-03-19T00:00:00Z" Version="1.01.0"/>
<RequiredModel ModelUri="http://opcfoundation.org/UA/MachineTool/" PublicationDate="2020-09-25T00:00:00Z" Version="1.00.0"/>
</Model>
</Models>
This should work:
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.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()
This should work:
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.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()
sure but the "testing_Nodeset.xml" has a invalid RequiredModel from http://opcfoundation.org/UA/ namespace!
Stumbeld across this error also, with an older asyncua version. https://github.com/umati/Sample-Server-asyncio/blob/ea348c9cfe6b2a59b56842cda531d27bdb439769/src/server.py#L108 Didn't try it recently.
Ok after we finaly know that Opc.Ua.Pumps.Nodeset2.xml can not be loaded. I can check what causes the error and add it to our test case.
Ok after we finaly know that Opc.Ua.Pumps.Nodeset2.xml can not be loaded. I can check what causes the error and add it to our test case.
could you please provide the solution ?
This is a open source project, either you wait until someone or I find time to fix it, or you fix it your self and make a pull request.....
Stumbeld across this error also, with an older asyncua version. https://github.com/umati/Sample-Server-asyncio/blob/ea348c9cfe6b2a59b56842cda531d27bdb439769/src/server.py#L108 Didn't try it recently.
I correct my comment. Just tried to load the Pumps NodeSet, which is now working fine. (https://github.com/umati/Sample-Server-asyncio/tree/feat/pumps)
@anshi43 please post your testing_Nodeset.xml
<Models> </Models>
part?
Stumbeld across this error also, with an older asyncua version. https://github.com/umati/Sample-Server-asyncio/blob/ea348c9cfe6b2a59b56842cda531d27bdb439769/src/server.py#L108 Didn't try it recently.
I correct my comment. Just tried to load the Pumps NodeSet, which is now working fine. (https://github.com/umati/Sample-Server-asyncio/tree/feat/pumps)
@anshi43 please post your
testing_Nodeset.xml
<Models> </Models>
part?
`
`
This is the header of your normative Pumps Nodeset:
<Models>
<Model ModelUri="http://opcfoundation.org/UA/Pumps/" Version="1.0.0" PublicationDate="2021-04-19T00:00:00Z">
<RequiredModel ModelUri="http://opcfoundation.org/UA/" Version="1.04.7" PublicationDate="2020-07-15T00:00:00Z" />
<RequiredModel ModelUri="http://opcfoundation.org/UA/DI/" Version="1.02.2" PublicationDate="2020-06-02T00:00:00Z" />
<RequiredModel ModelUri="http://opcfoundation.org/UA/Machinery/" Version="1.0.0" PublicationDate="2020-09-25T00:00:00Z" />
</Model>
</Models>
What is the testing_Nodeset.xml Models header?
This is the header of your normative Pumps Nodeset:
<Models> <Model ModelUri="http://opcfoundation.org/UA/Pumps/" Version="1.0.0" PublicationDate="2021-04-19T00:00:00Z"> <RequiredModel ModelUri="http://opcfoundation.org/UA/" Version="1.04.7" PublicationDate="2020-07-15T00:00:00Z" /> <RequiredModel ModelUri="http://opcfoundation.org/UA/DI/" Version="1.02.2" PublicationDate="2020-06-02T00:00:00Z" /> <RequiredModel ModelUri="http://opcfoundation.org/UA/Machinery/" Version="1.0.0" PublicationDate="2020-09-25T00:00:00Z" /> </Model> </Models>
What is the testing_Nodeset.xml Models header?
ohh sorry , here you can find :
`
<Model ModelUri="http://opcfoundation.org/UA/DI/" PublicationDate="2021-03-09T00:00:00Z" Version="1.03.0">
<RequiredModel ModelUri="http://opcfoundation.org/UA/" PublicationDate="2021-09-15T00:00:00Z" Version="1.04.10"/>
</Model>
<Model ModelUri="http://opcfoundation.org/UA/Machinery/" PublicationDate="2022-05-01T00:00:00Z" Version="1.02.0">
<RequiredModel ModelUri="http://opcfoundation.org/UA/" PublicationDate="2021-09-15T00:00:00Z" Version="1.04.10"/>
<RequiredModel ModelUri="http://opcfoundation.org/UA/DI/" PublicationDate="2021-03-09T00:00:00Z" Version="1.03.0"/>
</Model>
<Model ModelUri="http://opcfoundation.org/UA/Pumps/" PublicationDate="2021-04-19T00:00:00Z" Version="1.0.0">
<RequiredModel ModelUri="http://opcfoundation.org/UA/" PublicationDate="2021-09-15T00:00:00Z" Version="1.04.10"/>
<RequiredModel ModelUri="http://opcfoundation.org/UA/DI/" PublicationDate="2021-03-09T00:00:00Z" Version="1.03.0"/>
<RequiredModel ModelUri="http://opcfoundation.org/UA/Machinery/" PublicationDate="2022-05-01T00:00:00Z" Version="1.02.0"/>
</Model>
<Model ModelUri="https://pumps-systems.netzsch.com/pump" PublicationDate="2023-05-23T15:36:22+02:00" Version="1.00">
<RequiredModel ModelUri="http://opcfoundation.org/UA/" PublicationDate="2021-09-15T00:00:00Z" Version="1.04.10"/>
<RequiredModel ModelUri="http://opcfoundation.org/UA/DI/" PublicationDate="2021-03-09T00:00:00Z" Version="1.03.0"/>
<RequiredModel ModelUri="http://opcfoundation.org/UA/Machinery/" PublicationDate="2022-05-01T00:00:00Z" Version="1.02.0"/>
<RequiredModel ModelUri="http://opcfoundation.org/UA/Pumps/" PublicationDate="2021-04-19T00:00:00Z" Version="1.0.0"/>
</Model>
</Models>`
Stumbeld across this error also, with an older asyncua version. https://github.com/umati/Sample-Server-asyncio/blob/ea348c9cfe6b2a59b56842cda531d27bdb439769/src/server.py#L108 Didn't try it recently.
I correct my comment. Just tried to load the Pumps NodeSet, which is now working fine. (https://github.com/umati/Sample-Server-asyncio/tree/feat/pumps) @anshi43 please post your
testing_Nodeset.xml
<Models> </Models>
part?
<Models> <Model ModelUri="http://opcfoundation.org/UA/Pumps/" Version="1.0.0" PublicationDate="2021-04-19T00:00:00Z"> <RequiredModel ModelUri="http://opcfoundation.org/UA/" Version="1.04.7" PublicationDate="2020-07-15T00:00:00Z" /> <RequiredModel ModelUri="http://opcfoundation.org/UA/DI/" Version="1.02.2" PublicationDate="2020-06-02T00:00:00Z" /> <RequiredModel ModelUri="http://opcfoundation.org/UA/Machinery/" Version="1.0.0" PublicationDate="2020-09-25T00:00:00Z" /> </Model> </Models>
How did you manage to solve the problem ? could you please provide the solution with code so i can test ? thank you in advance.
@schroeder- @AndreasHeine do you know if the xmlimporter is tested with SiOME xml structure of the models?
As those is different then how normative and UaModeler XMLs are structured.
<Models>
<Model ModelUri="http://localuri" PublicationDate="2023-05-23T15:32:01+02:00" Version="1.00">
<RequiredModel ModelUri="http://opcfoundation.org/UA/" PublicationDate="2021-09-15T00:00:00Z" Version="1.04.10"/>
</Model>
<Model ModelUri="http://opcfoundation.org/UA/DI/" PublicationDate="2021-03-09T00:00:00Z" Version="1.03.0">
<RequiredModel ModelUri="http://opcfoundation.org/UA/" PublicationDate="2021-09-15T00:00:00Z" Version="1.04.10"/>
</Model>
<Model ModelUri="http://opcfoundation.org/UA/Machinery/" PublicationDate="2022-05-01T00:00:00Z" Version="1.02.0">
<RequiredModel ModelUri="http://opcfoundation.org/UA/" PublicationDate="2021-09-15T00:00:00Z" Version="1.04.10"/>
<RequiredModel ModelUri="http://opcfoundation.org/UA/DI/" PublicationDate="2021-03-09T00:00:00Z" Version="1.03.0"/>
</Model>
<Model ModelUri="http://opcfoundation.org/UA/Pumps/" PublicationDate="2021-04-19T00:00:00Z" Version="1.0.0">
<RequiredModel ModelUri="http://opcfoundation.org/UA/" PublicationDate="2021-09-15T00:00:00Z" Version="1.04.10"/>
<RequiredModel ModelUri="http://opcfoundation.org/UA/DI/" PublicationDate="2021-03-09T00:00:00Z" Version="1.03.0"/>
<RequiredModel ModelUri="http://opcfoundation.org/UA/Machinery/" PublicationDate="2022-05-01T00:00:00Z" Version="1.02.0"/>
</Model>
<Model ModelUri="https://pumps-systems.netzsch.com/pump" PublicationDate="2023-05-23T15:36:22+02:00" Version="1.00">
<RequiredModel ModelUri="http://opcfoundation.org/UA/" PublicationDate="2021-09-15T00:00:00Z" Version="1.04.10"/>
<RequiredModel ModelUri="http://opcfoundation.org/UA/DI/" PublicationDate="2021-03-09T00:00:00Z" Version="1.03.0"/>
<RequiredModel ModelUri="http://opcfoundation.org/UA/Machinery/" PublicationDate="2022-05-01T00:00:00Z" Version="1.02.0"/>
<RequiredModel ModelUri="http://opcfoundation.org/UA/Pumps/" PublicationDate="2021-04-19T00:00:00Z" Version="1.0.0"/>
</Model>
</Models>
@anshi43 This your instance namespace ModelUri="https://pumps-systems.netzsch.com/pump"
?
What is your namespace ModelUri="http://localuri"
for?
Please make sure, that you only export your instance namespace from SiOME, as it otherwise includes all other nodesets in a single xml.
@schroeder- @AndreasHeine do you know if the xmlimporter is tested with SiOME xml structure of the models?
As those is different then how normative and UaModeler XMLs are structured.
<Models> <Model ModelUri="http://localuri" PublicationDate="2023-05-23T15:32:01+02:00" Version="1.00"> <RequiredModel ModelUri="http://opcfoundation.org/UA/" PublicationDate="2021-09-15T00:00:00Z" Version="1.04.10"/> </Model> <Model ModelUri="http://opcfoundation.org/UA/DI/" PublicationDate="2021-03-09T00:00:00Z" Version="1.03.0"> <RequiredModel ModelUri="http://opcfoundation.org/UA/" PublicationDate="2021-09-15T00:00:00Z" Version="1.04.10"/> </Model> <Model ModelUri="http://opcfoundation.org/UA/Machinery/" PublicationDate="2022-05-01T00:00:00Z" Version="1.02.0"> <RequiredModel ModelUri="http://opcfoundation.org/UA/" PublicationDate="2021-09-15T00:00:00Z" Version="1.04.10"/> <RequiredModel ModelUri="http://opcfoundation.org/UA/DI/" PublicationDate="2021-03-09T00:00:00Z" Version="1.03.0"/> </Model> <Model ModelUri="http://opcfoundation.org/UA/Pumps/" PublicationDate="2021-04-19T00:00:00Z" Version="1.0.0"> <RequiredModel ModelUri="http://opcfoundation.org/UA/" PublicationDate="2021-09-15T00:00:00Z" Version="1.04.10"/> <RequiredModel ModelUri="http://opcfoundation.org/UA/DI/" PublicationDate="2021-03-09T00:00:00Z" Version="1.03.0"/> <RequiredModel ModelUri="http://opcfoundation.org/UA/Machinery/" PublicationDate="2022-05-01T00:00:00Z" Version="1.02.0"/> </Model> <Model ModelUri="https://pumps-systems.netzsch.com/pump" PublicationDate="2023-05-23T15:36:22+02:00" Version="1.00"> <RequiredModel ModelUri="http://opcfoundation.org/UA/" PublicationDate="2021-09-15T00:00:00Z" Version="1.04.10"/> <RequiredModel ModelUri="http://opcfoundation.org/UA/DI/" PublicationDate="2021-03-09T00:00:00Z" Version="1.03.0"/> <RequiredModel ModelUri="http://opcfoundation.org/UA/Machinery/" PublicationDate="2022-05-01T00:00:00Z" Version="1.02.0"/> <RequiredModel ModelUri="http://opcfoundation.org/UA/Pumps/" PublicationDate="2021-04-19T00:00:00Z" Version="1.0.0"/> </Model> </Models>
@anshi43 This your instance namespace
ModelUri="https://pumps-systems.netzsch.com/pump"
? What is your namespaceModelUri="http://localuri"
for? Please make sure, that you only export your instance namespace from SiOME, as it otherwise includes all other nodesets in a single xml.
yes this is my instance namespace ModelUri="https://pumps-systems.netzsch.com/pump. according to pump companion specification i created local uri :
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.
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
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.