Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map aasx file to opcua #360

Open
hadifar opened this issue Nov 15, 2024 · 0 comments
Open

Map aasx file to opcua #360

hadifar opened this issue Nov 15, 2024 · 0 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@hadifar
Copy link

hadifar commented Nov 15, 2024

Hi all,
Thanks for your valuable contribution.
I'm trying to map aasx to opcua like the following picture:
image

However, when I export nodeset2.xml from package-explorer and import it to the OPC UA server using the following script in Python, it gives me an exception. Do you know how to do that?

I would greatly appreciate it if you can help me with this.

import logging

from opcua import Server

logging.basicConfig(level=logging.INFO)
_logger = logging.getLogger('asyncua')


def main():
    server = Server()
    filename = "Opc_export.xml"
    server.import_xml(filename)
    server.start()

if __name__ == '__main__':
    main()

Exception:

INFO:opcua.common.xmlparser:Parsing node: ns=1;s=AssetAdminShell 1:AssetAdminShell
INFO:opcua.common.xmlparser:Could not detect backward reference to parent for node 'ns=1;s=AssetAdminShell'
INFO:opcua.common.xmlimporter:Importing xml node (QualifiedName(1:AssetAdminShell), StringNodeId(ns=1;s=AssetAdminShell)) as (QualifiedName(2:AssetAdminShell) StringNodeId(ns=2;s=AssetAdminShell))
INFO:opcua.server.address_space:add_node: while adding node StringNodeId(ns=2;s=AssetAdminShell), requested parent node is null TwoByteNodeId(i=0) True
WARNING:opcua.common.xmlimporter:failure adding node NodeData(nodeid:StringNodeId(ns=1;s=AssetAdminShell))
Traceback (most recent call last):
File "C:\Users\hadifar\IdeaProjects\opc\python-src\opc-experiment\server2.py", line 22, in
main()
File "C:\Users\hadifar\IdeaProjects\opc\python-src\opc-experiment\server2.py", line 15, in main
server.import_xml('new2.xml')
File "C:\Users\hadifar\IdeaProjects\opc\venv\lib\site-packages\opcua\server\server.py", line 518, in import_xml
return importer.import_xml(path, xmlstring)
File "C:\Users\hadifar\IdeaProjects\opc\venv\lib\site-packages\opcua\common\xmlimporter.py", line 68, in import_xml
node = self._add_node_data(nodedata)
File "C:\Users\hadifar\IdeaProjects\opc\venv\lib\site-packages\opcua\common\xmlimporter.py", line 83, in _add_node_data
node = self.add_object(nodedata)
File "C:\Users\hadifar\IdeaProjects\opc\venv\lib\site-packages\opcua\common\xmlimporter.py", line 184, in add_object
res[0].StatusCode.check()
File "C:\Users\hadifar\IdeaProjects\opc\venv\lib\site-packages\opcua\ua\uatypes.py", line 218, in check
raise UaStatusCodeError(self.value)
opcua.ua.uaerrors._auto.BadParentNodeIdInvalid: "The parent node id does not to refer to a valid node."(BadParentNodeIdInvalid)

@hadifar hadifar added help wanted Extra attention is needed question Further information is requested labels Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant