-
Notifications
You must be signed in to change notification settings - Fork 662
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
Implement XML exporter #270
Conversation
One question: I found some code that sounds like "dump" etc. Is this related to the xml exporter? |
:param obj: | ||
:return: | ||
""" | ||
return 'ns=' + str(obj.nodeid.NamespaceIndex) + ';' + str(obj.nodeid.Identifier) |
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.
simply write nodeid.to_string()
@zerox1212 the UI is now usable, we can start testing you exporter as soon as you have something |
I won't be able to work on it until later this week. Too many things going on in my regular job. |
Exporter can now export regular objects. First attempt at exporting references added for review. Split some methods so building etree and dump/write are separate.
Looks good :-) |
ref_name = o_ids.ObjectIdNames[ref.ReferenceTypeId.Identifier] | ||
ref_forward = str(ref.IsForward) | ||
refx_el = Et.SubElement(refs_el, 'Reference', IsForward=ref_forward, ReferenceType=ref_name) |
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.
When I look at UAExpert exports it doesn't always include "IsForward". How do I know if this is required or not?
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.
I think we will need to check attributes values against the default and only export if they are different.
How to get default is another question:
- Hard coded in exporter
- Modified attrs in ui
- Create ua.ObjectAttributes or ua.VariableTypeAttribute depending on noce class and compare attribute from node in address space and value of attributes in the created object ( I think I vote for that one)
I think we will need to check attributes values against the default and only export if they are different. How to get default is another question:
|
node_set_attributes['xmlns:uax'] = 'http://opcfoundation.org/UA/2008/02/Types.xsd' | ||
node_set_attributes['xmlns:s1'] = 'http://yourorganisation.org/dataobject/Types.xsd' | ||
node_set_attributes['xmlns:xsd'] = 'http://www.w3.org/2001/XMLSchema' | ||
node_set_attributes['xmlns'] = 'http://opcfoundation.org/UA/2011/03/UANodeSet.xsd' |
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.
Why do we need this, can't you put this inside exporter class?
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.
It was mainly for testing, plus I think UA Expert lets you add custom schemas? I can move it inside the class later.
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.
Uamodeler you mean. Yes let's move it inside for now
I started working on exporting object types and I have run into a problem. What is the easiest way to make sure all children of an object type get exported? Then all instances of that object also need to be searched for children. I don't know the proper approach here, Do we search for children on every node in our export list? Or do we just go through the entire address space (ignoring standard address space)? |
Do not export children. Just references. The GUI takes care of keeping track of children |
self.server = server | ||
self.aliases = {} | ||
|
||
def build_etree(self, node_list): |
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.
Somewhere I would like to be able to add a list of namespace to etree 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.
I have not used the namespace stuff. How can I get a list of the namespaces in the server?
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.
Same here, only add a method add_namespaces(list of string and maybe idx). So the users or GUI take care of consistency
This is about as far as I can go for now. Not sure when I'll get to exporting methods, maybe later this week. Also, I don't know what "references" are. I have never made a reference node in the server before. While testing with UA Expert I found it exporting a few things that I didn't understand in certain cases, such as "SymbolicName". Maybe someone with more UA experience can polish up the last few things. What tests do you want for this? Can probably just roll an entire export into a single test. Can we merge this soon and test the basic functionality with modeler? |
Looks like a good start! Thanks! |
Let me know when modeler GUI is ready. I would like to test it some. |
This is for review. Only UAVariable method is partially done as an example.
Please give feedback on this design before I implement the remaining XML export methods.
FYI, I modeled the exporter after the importer, so a lot of junk from that is commented out. I left it there because the XML exporter basically has to reverse whatever the importer functions do so it makes it easier to write the methods.