Skip to content

Commit

Permalink
save current node in uamodel and navigate to it when opening
Browse files Browse the repository at this point in the history
  • Loading branch information
oroulet committed Feb 1, 2019
1 parent 95e327c commit 9b08f72
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions uamodeler/model_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ def _open_ua_model(self, path):
dirname = os.path.dirname(path)
xmlpath = os.path.join(dirname, mod_el.attrib['path'])
self._open_xml(xmlpath)
if "current_node" in mod_el.attrib:
current_node_str = mod_el.attrib['current_node']
nodeid = ua.NodeId.from_string(current_node_str)
current_node = self.server_mgr.get_node(nodeid)
self.modeler.tree_ui.expand_to_node(current_node)

def _get_path(self, path):
if path is None:
Expand Down Expand Up @@ -228,6 +233,9 @@ def save_ua_model(self, path=None):
etree = Et.ElementTree(Et.Element('UAModel'))
node_el = Et.SubElement(etree.getroot(), "Model")
node_el.attrib["path"] = os.path.basename(path) + ".xml"
c_node = self.modeler.tree_ui.get_current_node()
if c_node:
node_el.attrib["current_node"] = c_node.nodeid.to_string()
for refpath in self.modeler.nodesets_ui.nodesets:
node_el = Et.SubElement(etree.getroot(), "Reference")
node_el.attrib["path"] = refpath
Expand Down

0 comments on commit 9b08f72

Please sign in to comment.