-
Notifications
You must be signed in to change notification settings - Fork 663
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
Standard address space 1.04 #574
Conversation
|
@@ -924,7 +924,7 @@ def test_data_type_to_variant_type(self): | |||
ua.ObjectIds.Structure: ua.VariantType.ExtensionObject, | |||
ua.ObjectIds.EnumValueType: ua.VariantType.ExtensionObject, | |||
ua.ObjectIds.Enumeration: ua.VariantType.Int32, # enumeration | |||
ua.ObjectIds.AttributeWriteMask: ua.VariantType.Int32, # enumeration | |||
ua.ObjectIds.AttributeWriteMask: ua.VariantType.UInt32, # enumeration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to remove comment too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I forgot that. I'll remove it.
@@ -302,7 +302,7 @@ def test_xml_enum(self): | |||
self._test_xml_var_type(o, "enum") | |||
|
|||
def test_xml_enumvalues(self): | |||
o = self.opc.nodes.objects.add_variable(2, "xmlenumvalues", 0, varianttype=ua.VariantType.Int32, datatype=ua.ObjectIds.AttributeWriteMask) | |||
o = self.opc.nodes.objects.add_variable(2, "xmlenumvalues", 0, varianttype=ua.VariantType.UInt32, datatype=ua.ObjectIds.AttributeWriteMask) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact that test is broken. AttributeWriteMask does not seem to inherit enum anymore...
Regarding DataTypeDefinition, the change was on generate_model.py, which don't seem to include uatypes. My solution feels like a hack and I'm all for something better, but I don't see how changing uatypes.py will make a difference. The Should I simply add a DataTypeDefinition to uatypes.py and see if it works? |
It will work. Everything in uatypes is imported in the autogenerated files |
I'm preparing a new branch where I'll rework these modifications with smaller commits. |
I created a new branch. I intent to use this branch for sharing tests results and make a better PR later. In that new branch, I only committed the new xml files and (in a different commit) added a DataTypeDefinition to uatypes.py. That did not work.
That was the same error I got without adding DataTypeDefinition to uatypes. Maybe I did something while adding it, but I don't think so. uatypes.py is not imported (nor even read) by any of the generate_* scripts in schemas. The automatic code generation process seems therefore to be independent of uatypes.py. |
I looked at code. I wrote that stuff several years ago and xml parsing is never easy to read.... |
Nothing to be sorry about :) My solution does feel like a hack. DataTypeDefinition is defined, I think, in Opc.Ua.Types.xsd. I looks like an empty struct: <xs:complexType name="DataTypeDefinition">
<xs:sequence>
</xs:sequence>
</xs:complexType>
<xs:element name="DataTypeDefinition" type="tns:DataTypeDefinition" /> Also, as far as I understand, DataTypeDefinition is only used as a superclass for other types. It doesn't have any functionality of its own. I don't understand the difference between bsd and xsd files. Maybe there is a better option reading the xsd file instead, but I have now idea how to do it. There are other problems with my PR that I would like to tackle. The most important being autogenerated code that I had to manually edit. So I suggest leaving my hack for DataTypeDefinition there as a temporary solution while I go forward with the other issues. I'll publish my work on this branch in order to share it, but I intend to make another PR from a clean branch when the issues are solved. |
I made commits to my development branch. I reverted the uatypes.py modification, added my DataTypeDefinition hack, made minor adjustments to the code generating scripts and ran the code generation in the following order:
Then I committed the automatically generated code. As it stands, there is a syntax error in
After fixing this (manually) the next error is:
After working around this (changing the test value to 2153), I get the really complicated error:
What I found out was that the node i=15957 ( Once that was made, I got rid of this error but the length of server.postponed list in standard_address_space.py changed to 2134. After adjusting that assertion again I could start a server without problems. So I detect two problems in automatic code generation. One was the string with embedded newline. The other was two nodes inserted out of order. Both problems in part 5. I committed the manual modifications as well. I'll look into why the problems happened. |
Ok. Then a better solution could be to change parser to print a warning if parent struct is not found and do not add it to list of parents. That should fix the issue. |
Concerning the assert: please remove it entirely. It looks stupid. Better to print a warning of there is a small error |
And commit all code generation stuff in one commit so i can pull it and have sa look |
I've solved the first error on the autogenerated code, namely the syntax error. It was caused by a string in xml file having an embedded new line character. The relevant part of the xml file is: <UAVariable NodeId="i=15964" BrowseName="StaticStringNodeIdPattern" ParentNodeId="i=15957" DataType="String">
<DisplayName>StaticStringNodeIdPattern</DisplayName>
<Description>A regular expression which matches string node ids are the same in every server that exposes them.</Description>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
<Reference ReferenceType="HasProperty" IsForward="false">i=15957</Reference>
</References>
<Value>
<String xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">
</String>
</Value>
</UAVariable> The resulting python file has attrs.Value = ua.Variant("
", ua.VariantType.String) which have a syntax error. In fact, every multiline string would get printed with unescaped newlines and the resulting python file would be invalid. What I did was simply replace the This solved the syntax error problem. I pushed another separate commit for this. I'll look at the other problem next (nodes out of order). I'll make yet another branch later with the modifications grouped in a single commit when I'm finished with this problem. |
I've found the problem with adding nodes failing. This happens because the order of the nodes in part 5 xml file is such that some nodes are listed before their parents. So when create_standard_address_space_Part5 runs those nodes can not be added. The problem is similar to the insertion of references that motivated #509, but this time with the nodes themselves. The solution I made applies the same principle of postponing to the nodes. With this modification, the autogenerated files no longer have to be manually edited. I've pushed this to my fork for documentation. |
I created a new branch with all these modifications in what I hope is a sane order. Is it OK to create a new PR from it? Or is there a better way? I'm new to this PR stuff... |
Yes closer this one and make a new one. You can in fact create s pr from first line of code and flag it with WIP: |
For previous discussion, see #572