make it possible to update XSD schema in project controller after new
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Thu, 21 Sep 2017 17:19:18 +0300
changeset 1824 5765bea3dbd1
parent 1823 1e9a67d68612
child 1825 bcb50e736a46
make it possible to update XSD schema in project controller after new
target PLC is added or removed.

For example:


...
import targets
targets.targets["PLC"] = {"xsd": os.path.join(self.customBeremizPath, "PLCtarget", xsd),
"class": lambda: PLC_target,
"code": {"plc_PLC_main.c": os.path.join(self.customBeremizPath, "PLCtarget", "plc_PLC_main.c")}
}

from ProjectController import ProjectController, GetProjectControllerXSD
ProjectController.XSD = GetProjectControllerXSD()
ProjectController.py
--- a/ProjectController.py	Thu Sep 21 16:06:51 2017 +0300
+++ b/ProjectController.py	Thu Sep 21 17:19:18 2017 +0300
@@ -177,21 +177,7 @@
         return self.ieclib_c_path
 
 
-class ProjectController(ConfigTreeNode, PLCControler):
-    """
-    This class define Root object of the confnode tree.
-    It is responsible of :
-    - Managing project directory
-    - Building project
-    - Handling PLCOpenEditor controler and view
-    - Loading user confnodes and instanciante them as children
-    - ...
-
-    """
-
-    # For root object, available Children Types are modules of the confnode packages.
-    CTNChildrenTypes = ExtractChildrenTypesFromCatalog(features.catalog)
-
+def GetProjectControllerXSD():
     XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
       <xsd:element name="BeremizRoot">
@@ -219,6 +205,23 @@
       </xsd:element>
     </xsd:schema>
     """
+    return XSD
+
+
+class ProjectController(ConfigTreeNode, PLCControler):
+    """
+    This class define Root object of the confnode tree.
+    It is responsible of :
+    - Managing project directory
+    - Building project
+    - Handling PLCOpenEditor controler and view
+    - Loading user confnodes and instanciante them as children
+    - ...
+
+    """
+    # For root object, available Children Types are modules of the confnode packages.
+    CTNChildrenTypes = ExtractChildrenTypesFromCatalog(features.catalog)
+    XSD = GetProjectControllerXSD()
     EditorType = ProjectNodeEditor
     iec2c_cfg = None