Open hsd-dev opened 4 years ago
The parse need to be changed. Tried to look at it a few weeks ago and did not manage to find exactly where this is done. Also we need to stay backwards compatible
Have you documented the process to create new address spaces? This is the one I found. Is that correct? I directly ran the generate_address_spaces.py
script.
Also https://github.com/FreeOpcUa/python-opcua/pull/576 seems to update the repo for 1.04?
The error says there is not attribute UInt32
in opcua.ua
. Do we have to add the attribute somewhere in uatypes.py. Seems like the attributes are defined as classes in it.
the documented process seems fine. the issue (as far as I remember) is that the xml now looks like this.
<ArrayDimensions>
<UInt32>0</UInt32>
</ArrayDimensions>
While before itwas
<ArrayDimensions>0</ArrayDimensions>
So the current code is trying to create an object of type UInt32 which does not exist as this should be registered as a number and just write code like : obj.ArrayDimentsions = 0
(you get an attribute error since the code is written similar to: gettatr(ua, myobj)
)
This is touchy to fix since the syntax without the datatype is still used at several other places.
Also to complicate things, the entire xml address space is now only one file while before it was several small files. This is a big issue on machine with little memory..
see my current (completely broken) code there: https://github.com/FreeOpcUa/opcua-asyncio/pull/173
Help welcome I have no time to look at this currently
in fact the code changes in that merge request is very very small, I mainly spent time trying to understand where the issue was, so you are welcome to take over the merge request
Actually the parser is not the problem. I wrote a test.xml
<?xml version="1.0" encoding="utf-8" ?>
<UANodeSet xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" LastModified="2018-02-09T00:00:00Z" xmlns="http://opcfoundation.org/UA/2011/03/UANodeSet.xsd">
<Models>
<Model ModelUri="http://opcfoundation.org/UA/" Version="1.02" PublicationDate="2018-02-09T00:00:00Z" />
</Models>
<UAVariable NodeId="i=11491" BrowseName="OutputArguments" ParentNodeId="i=11489" DataType="i=296" ValueRank="1" ArrayDimensions="0">
<DisplayName>OutputArguments</DisplayName>
<Value>
<ListOfExtensionObject xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">
<ExtensionObject>
<TypeId>
<Identifier>i=297</Identifier>
</TypeId>
<Body>
<Argument>
<Name>ServerHandles</Name>
<DataType>
<Identifier>i=7</Identifier>
</DataType>
<ValueRank>1</ValueRank>
<ArrayDimensions>
<UInt32>0</UInt32>
</ArrayDimensions>
</Argument>
</Body>
</ExtensionObject>
</ListOfExtensionObject>
</Value>
</UAVariable>
</UANodeSet>
and run only xmlparser.py
and print the val
at https://github.com/FreeOpcUa/python-opcua/blob/4119e74be91091e7ae0f72dcfed24c5334d691df/opcua/common/xmlparser.py#L330 I get:
[('Name', 'ServerHandles'), ('DataType', [('Identifier', 'i=7')]), ('ValueRank', '1'), ('ArrayDimensions', [('UInt32', '0')])]
Also, if I print obj.dimensions
at https://github.com/FreeOpcUa/python-opcua/blob/4119e74be91091e7ae0f72dcfed24c5334d691df/opcua/common/xmlparser.py#L178 I get:
key val: ArrayDimensions 0
[0]
Which is actually this line from the XML
<UAVariable NodeId="i=11491" BrowseName="OutputArguments" ParentNodeId="i=11489" DataType="i=296" ValueRank="1" ArrayDimensions="0">
Since the error happens during gettatr(ua, myobj)
, we might have to add a new class in uatypes.py
.
when I say the parser, in fact I mean the code generating objects right after parsing. No in that case you do not want to add a type in uatype. it already exists . you want to ignore the uint32 stuff since we do not care to generate python code, we want to use the value as int
I am trying to use the Robotics specification from OPCUA foundation. When I try to generate the address spaces with generate_address_spaces.py script, I get the error:
The error occurs in Opc.Ua.NodeSet2.Part5.xml
which was previously
Also in NodeIds.csv
which was previously
I am not sure if I am looking in the right direction. How to handle these changes?