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

Implement XML exporter #270

Merged
merged 5 commits into from
Aug 15, 2016
Merged

Implement XML exporter #270

merged 5 commits into from
Aug 15, 2016

Conversation

zerox1212
Copy link
Contributor

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.

@zerox1212 zerox1212 mentioned this pull request Aug 3, 2016
43 tasks
@maljac
Copy link
Contributor

maljac commented Aug 4, 2016

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)
Copy link
Member

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()

@oroulet
Copy link
Member

oroulet commented Aug 8, 2016

@zerox1212 the UI is now usable, we can start testing you exporter as soon as you have something

@zerox1212
Copy link
Contributor Author

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.
@oroulet
Copy link
Member

oroulet commented Aug 13, 2016

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)
Copy link
Contributor Author

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?

Copy link
Member

@oroulet oroulet Aug 13, 2016

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)

@oroulet
Copy link
Member

oroulet commented Aug 13, 2016

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)

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'
Copy link
Member

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?

Copy link
Contributor Author

@zerox1212 zerox1212 Aug 13, 2016

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.

Copy link
Member

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

@zerox1212
Copy link
Contributor Author

zerox1212 commented Aug 13, 2016

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)?

@oroulet
Copy link
Member

oroulet commented Aug 13, 2016

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):
Copy link
Member

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

Copy link
Contributor Author

@zerox1212 zerox1212 Aug 14, 2016

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?

Copy link
Member

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

@zerox1212
Copy link
Contributor Author

zerox1212 commented Aug 15, 2016

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?

@oroulet
Copy link
Member

oroulet commented Aug 15, 2016

Looks like a good start! Thanks!

@oroulet oroulet merged commit 5ed66ac into FreeOpcUa:master Aug 15, 2016
@zerox1212
Copy link
Contributor Author

Let me know when modeler GUI is ready. I would like to test it some.

@zerox1212 zerox1212 deleted the xml-exporter branch August 22, 2016 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants