使用open62541 nodeset_compiler编译EUROMAP 82.3失败求助
解决open62541 nodeset_compiler编译EUROMAP 82.3时的未知目标节点错误
问题场景
使用open62541的nodeset_compiler编译EUROMAP 82.3标准时,执行以下命令:
PS C:\Users\User\Downloads\open62541-pack-v1.3.9\open62541-pack-v1.3.9\tools\nodeset_compiler> python ./nodeset_compiler.py --types-array=UA_TYPES --existing ../../deps/ua-nodeset/Schema/Opc.Ua.NodeSet2.xml --xml Opc.Ua.PlasticsRubber.LDS.NodeSet2.xml myNS
触发报错:
INFO:main:Preprocessing (existing) ../../deps/ua-nodeset/Schema/Opc.Ua.NodeSet2.xml INFO:main:Preprocessing Opc.Ua.PlasticsRubber.LDS.NodeSet2.xml ['http://opcfoundation.org/UA/', 'http://opcfoundation.org/UA/PlasticsRubber/LDS/', 'http://opcfoundation.org/UA/PlasticsRubber/GeneralTypes/', 'http://opcfoundation.org/UA/DI/'] Traceback (most recent call last): File "C:\Users\User\Downloads\open62541-pack-v1.3.9\open62541-pack-v1.3.9\tools\User\nodeset_compiler.py", line 168, in ns.sanitize() File "C:\Users\NickdeBoerMovacolor\Downloads\open62541-pack-v1.3.9\open62541-pack-v1.3.9\tools\nodeset_compiler\nodeset.py", line 137, in sanitize raise Exception("Reference " + str(ref) + " has an unknown target") Exception: Reference ns=1;i=5001--[ns=0;i=40]-->ns=2;i=1057 has an unknown target
经排查,目标节点ns=2;i=1057存在于../../deps/ua-nodeset/Scales/Opc.Ua.Scales.NodeSet2.xml中,但编译仍失败。
解决办法
问题根源是编译时未加载所有依赖的Nodeset文件。EUROMAP 82.3(即Opc.Ua.PlasticsRubber.LDS.NodeSet2.xml)不仅依赖核心的Opc.Ua.NodeSet2.xml,还依赖DI、PlasticsRubber GeneralTypes以及Scales这几个Nodeset。需要将所有依赖的Nodeset通过--existing参数逐一引入。
修改后的编译命令示例:
PS C:\Users\User\Downloads\open62541-pack-v1.3.9\open62541-pack-v1.3.9\tools\nodeset_compiler> python ./nodeset_compiler.py --types-array=UA_TYPES ^ --existing ../../deps/ua-nodeset/Schema/Opc.Ua.NodeSet2.xml ^ --existing ../../deps/ua-nodeset/DI/Opc.Ua.DI.NodeSet2.xml ^ --existing ../../deps/ua-nodeset/PlasticsRubber/GeneralTypes/Opc.Ua.PlasticsRubber.GeneralTypes.NodeSet2.xml ^ --existing ../../deps/ua-nodeset/Scales/Opc.Ua.Scales.NodeSet2.xml ^ --xml Opc.Ua.PlasticsRubber.LDS.NodeSet2.xml myNS
说明
nodeset_compiler在处理Nodeset时,需要能访问所有被引用节点所在的文件。如果某个被引用的节点所在的Nodeset未被加载,编译器无法解析该引用,就会抛出“未知目标”的错误。确保所有依赖的Nodeset都通过--existing参数添加,就能解决这个问题。
内容的提问来源于stack exchange,提问作者Nick de Boer
相关产品推荐
相关产品推荐

