beremiz 'plugins' refactoring to 'confnode'
authorEdouard Tisserant
Mon, 07 May 2012 18:53:16 +0200
changeset 681 c141dad94ff4
parent 680 b693147fb2c3
child 682 4d437bc0ef3f
beremiz 'plugins' refactoring to 'confnode'
PLCControler.py
controls/EditorPanel.py
controls/VariablePanel.py
dialogs/BrowseLocationsDialog.py
xmlclass/xmlclass.py
--- a/PLCControler.py	Fri May 04 19:20:46 2012 +0200
+++ b/PLCControler.py	Mon May 07 18:53:16 2012 +0200
@@ -75,7 +75,7 @@
                    "InOut" :    (plcopen.interface_inOutVars,    ITEM_VAR_INOUT)
                   }
 
-LOCATIONS_ITEMS = [LOCATION_PLUGIN,
+LOCATIONS_ITEMS = [LOCATION_CONFNODE,
                    LOCATION_MODULE,
                    LOCATION_GROUP,
                    LOCATION_VAR_INPUT,
@@ -204,7 +204,7 @@
         self.ProgramOffset = 0
         self.NextCompiledProject = None
         self.CurrentCompiledProject = None
-        self.PluginTypes = []
+        self.ConfNodeTypes = []
         self.ProgramFilePath = ""
         
     def GetQualifierTypes(self):
@@ -1129,7 +1129,7 @@
                 return tree, []
             datatype = project.getdataType(typename)
             if datatype is None:
-                datatype = self.GetPluginDataType(typename)
+                datatype = self.GetConfNodeDataType(typename)
             if datatype is not None:
                 tree = []
                 basetype_content = datatype.baseType.getcontent()
@@ -1251,28 +1251,28 @@
                     return returntype_content["name"]
         return None
 
-    # Function that add a new plugin to the plugin list
-    def AddPluginTypesList(self, typeslist):
-        self.PluginTypes.extend(typeslist)
+    # Function that add a new confnode to the confnode list
+    def AddConfNodeTypesList(self, typeslist):
+        self.ConfNodeTypes.extend(typeslist)
         
-    # Function that clear the plugin list
-    def ClearPluginTypes(self):
-        for i in xrange(len(self.PluginTypes)):
-            self.PluginTypes.pop(0)
-
-    def GetPluginBlockTypes(self):
-        return [{"name": _("%s POUs") % plugintypes["name"],
-                 "list": plugintypes["types"].GetCustomBlockTypes()}
-                for plugintypes in self.PluginTypes]
+    # Function that clear the confnode list
+    def ClearConfNodeTypes(self):
+        for i in xrange(len(self.ConfNodeTypes)):
+            self.ConfNodeTypes.pop(0)
+
+    def GetConfNodeBlockTypes(self):
+        return [{"name": _("%s POUs") % confnodetypes["name"],
+                 "list": confnodetypes["types"].GetCustomBlockTypes()}
+                for confnodetypes in self.ConfNodeTypes]
         
-    def GetPluginDataTypes(self, exclude = ""):
-        return [{"name": _("%s Data Types") % plugintypes["name"],
-                 "list": [datatype["name"] for datatype in plugintypes["types"].GetCustomDataTypes(exclude)]}
-                for plugintypes in self.PluginTypes]
-    
-    def GetPluginDataType(self, type):
-        for plugintype in self.PluginTypes:
-            datatype = plugintype["types"].getdataType(type)
+    def GetConfNodeDataTypes(self, exclude = ""):
+        return [{"name": _("%s Data Types") % confnodetypes["name"],
+                 "list": [datatype["name"] for datatype in confnodetypes["types"].GetCustomDataTypes(exclude)]}
+                for confnodetypes in self.ConfNodeTypes]
+    
+    def GetConfNodeDataType(self, type):
+        for confnodetype in self.ConfNodeTypes:
+            datatype = confnodetype["types"].getdataType(type)
             if datatype is not None:
                 return datatype
         return None
@@ -1283,7 +1283,7 @@
     # Function that returns the block definition associated to the block type given
     def GetBlockType(self, type, inputs = None, debug = False):
         result_blocktype = None
-        for category in BlockTypes + self.GetPluginBlockTypes():
+        for category in BlockTypes + self.GetConfNodeBlockTypes():
             for blocktype in category["list"]:
                 if blocktype["name"] == type:
                     if inputs is not None and inputs != "undefined":
@@ -1317,7 +1317,7 @@
                 type = self.GetPouType(name, debug)
         if type == "function" or words[0] == "T":
             blocktypes = []
-            for category in BlockTypes + self.GetPluginBlockTypes():
+            for category in BlockTypes + self.GetConfNodeBlockTypes():
                 cat = {"name" : category["name"], "list" : []}
                 for block in category["list"]:
                     if block["type"] == "function":
@@ -1325,7 +1325,7 @@
                 if len(cat["list"]) > 0:
                     blocktypes.append(cat)
         else:
-            blocktypes = [category for category in BlockTypes + self.GetPluginBlockTypes()]
+            blocktypes = [category for category in BlockTypes + self.GetConfNodeBlockTypes()]
         project = self.GetProject(debug)
         if project is not None:
             blocktypes.append({"name" : USER_DEFINED_POUS, "list": project.GetCustomBlockTypes(name, type == "function" or words[0] == "T")})
@@ -1334,7 +1334,7 @@
     # Return Function Block types checking for recursion
     def GetFunctionBlockTypes(self, tagname = "", debug = False):
         blocktypes = []
-        for category in BlockTypes + self.GetPluginBlockTypes():
+        for category in BlockTypes + self.GetConfNodeBlockTypes():
             for block in category["list"]:
                 if block["type"] == "functionBlock":
                     blocktypes.append(block["name"])
@@ -1381,8 +1381,8 @@
             result = project.GetBaseType(type)
             if result is not None:
                 return result
-        for plugintype in self.PluginTypes:
-            result = plugintype["types"].GetBaseType(type)
+        for confnodetype in self.ConfNodeTypes:
+            result = confnodetype["types"].GetBaseType(type)
             if result is not None:
                 return result
         return None
@@ -1406,8 +1406,8 @@
             project = self.GetProject(debug)
             if project is not None and project.IsOfType(type, reference):
                 return True
-            for plugintype in self.PluginTypes:
-                if plugintype["types"].IsOfType(type, reference):
+            for confnodetype in self.ConfNodeTypes:
+                if confnodetype["types"].IsOfType(type, reference):
                     return True
         return False
     
@@ -1423,7 +1423,7 @@
         if project is not None:
             datatype = project.getdataType(type)
             if datatype is None:
-                datatype = self.GetPluginDataType(type)
+                datatype = self.GetConfNodeDataType(type)
             if datatype is not None:
                 return project.IsLocatableType(datatype)
         return True
@@ -1433,7 +1433,7 @@
         if project is not None:
             datatype = project.getdataType(type)
             if datatype is None:
-                datatype = self.GetPluginDataType(type)
+                datatype = self.GetConfNodeDataType(type)
             if datatype is not None:
                 basetype_content = datatype.baseType.getcontent()
                 return basetype_content["name"] == "enum"
@@ -1448,8 +1448,8 @@
                 result = project.GetDataTypeRange(type)
                 if result is not None:
                     return result
-            for plugintype in self.PluginTypes:
-                result = plugintype["types"].GetDataTypeRange(type)
+            for confnodetype in self.ConfNodeTypes:
+                result = confnodetype["types"].GetDataTypeRange(type)
                 if result is not None:
                     return result
         return None
@@ -1460,8 +1460,8 @@
         project = self.GetProject(debug)
         if project is not None:
             subrange_basetypes.extend(project.GetSubrangeBaseTypes(exclude))
-        for plugintype in self.PluginTypes:
-            subrange_basetypes.extend(plugintype["types"].GetSubrangeBaseTypes(exclude))
+        for confnodetype in self.ConfNodeTypes:
+            subrange_basetypes.extend(confnodetype["types"].GetSubrangeBaseTypes(exclude))
         return DataTypeRange.keys() + subrange_basetypes
     
     # Return Enumerated Values
@@ -1472,8 +1472,8 @@
             values.extend(project.GetEnumeratedDataTypeValues(type))
             if type is None and len(values) > 0:
                 return values
-        for plugintype in self.PluginTypes:
-            values.extend(plugintype["types"].GetEnumeratedDataTypeValues(type))
+        for confnodetype in self.ConfNodeTypes:
+            values.extend(confnodetype["types"].GetEnumeratedDataTypeValues(type))
             if type is None and len(values) > 0:
                 return values
         return values
--- a/controls/EditorPanel.py	Fri May 04 19:20:46 2012 +0200
+++ b/controls/EditorPanel.py	Mon May 07 18:53:16 2012 +0200
@@ -137,10 +137,10 @@
         if self.VariableEditor is not None:
             self.VariableEditor.RefreshView()
     
-    def GetPluginMenuItems(self):
+    def GetConfNodeMenuItems(self):
         return self.MenuItems
     
-    def RefreshPluginMenu(self, plugin_menu):
+    def RefreshConfNodeMenu(self, confnode_menu):
         pass
     
     def _Refresh(self, *args):
--- a/controls/VariablePanel.py	Fri May 04 19:20:46 2012 +0200
+++ b/controls/VariablePanel.py	Mon May 07 18:53:16 2012 +0200
@@ -738,17 +738,17 @@
 
             type_menu.AppendMenu(wx.NewId(), _("User Data Types"), datatype_menu)
             
-            for category in self.Controler.GetPluginDataTypes():
+            for category in self.Controler.GetConfNodeDataTypes():
                
                if len(category["list"]) > 0:
-                   # build a submenu containing plugin types
-                   plugin_datatype_menu = wx.Menu(title='')
+                   # build a submenu containing confnode types
+                   confnode_datatype_menu = wx.Menu(title='')
                    for datatype in category["list"]:
                        new_id = wx.NewId()
-                       AppendMenu(plugin_datatype_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype)
+                       AppendMenu(confnode_datatype_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype)
                        self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id)
                    
-                   type_menu.AppendMenu(wx.NewId(), category["name"], plugin_datatype_menu)
+                   type_menu.AppendMenu(wx.NewId(), category["name"], confnode_datatype_menu)
 
             # build a submenu containing function block types
             bodytype = self.Controler.GetEditedElementBodyType(self.TagName)
--- a/dialogs/BrowseLocationsDialog.py	Fri May 04 19:20:46 2012 +0200
+++ b/dialogs/BrowseLocationsDialog.py	Mon May 07 18:53:16 2012 +0200
@@ -22,7 +22,7 @@
 import wx
 
 from plcopen.structures import LOCATIONDATATYPES
-from PLCControler import LOCATION_PLUGIN, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY
+from PLCControler import LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP, LOCATION_VAR_INPUT, LOCATION_VAR_OUTPUT, LOCATION_VAR_MEMORY
 
 CWD = os.path.split(os.path.split(os.path.realpath(__file__))[0])[0]
 
@@ -131,7 +131,7 @@
         
         # Icons for items
         for imgname, itemtype in [
-            ("CONFIGURATION", LOCATION_PLUGIN), 
+            ("CONFIGURATION", LOCATION_CONFNODE), 
             ("RESOURCE",      LOCATION_MODULE), 
             ("PROGRAM",       LOCATION_GROUP), 
             ("VAR_INPUT",     LOCATION_VAR_INPUT), 
@@ -157,7 +157,7 @@
         root = self.LocationsTree.GetRootItem()
         if not root.IsOk():
             if wx.Platform == '__WXMSW__':
-                root = self.LocationsTree.AddRoot(_('Plugins'))
+                root = self.LocationsTree.AddRoot(_('ConfNodes'))
             else:
                 root = self.LocationsTree.AddRoot("")
         self.GenerateLocationsTreeBranch(root, self.Locations)
@@ -171,7 +171,7 @@
             item, root_cookie = self.LocationsTree.GetFirstChild(root, 0)
         for loc_infos in locations:
             infos = loc_infos.copy()
-            if infos["type"] in [LOCATION_PLUGIN, LOCATION_MODULE, LOCATION_GROUP] or\
+            if infos["type"] in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP] or\
                infos["type"] in self.Filter and (infos["IEC_type"] == self.VarType or
                infos["IEC_type"] is None and LOCATION_SIZES[self.VarType] == infos["size"]):
                 children = [child for child in infos.pop("children")]
@@ -193,7 +193,7 @@
     
     def OnLocationsTreeItemActivated(self, event):
         infos = self.LocationsTree.GetPyData(event.GetItem())
-        if infos["type"] not in [LOCATION_PLUGIN, LOCATION_MODULE, LOCATION_GROUP]:
+        if infos["type"] not in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP]:
             wx.CallAfter(self.EndModal, wx.ID_OK)
         event.Skip()
     
@@ -210,7 +210,7 @@
         var_infos = None
         if selected.IsOk():
             var_infos = self.LocationsTree.GetPyData(selected)
-        if var_infos is None or var_infos["type"] in [LOCATION_PLUGIN, LOCATION_MODULE, LOCATION_GROUP]:
+        if var_infos is None or var_infos["type"] in [LOCATION_CONFNODE, LOCATION_MODULE, LOCATION_GROUP]:
             message = wx.MessageDialog(self, _("A location must be selected!"), _("Error"), wx.OK|wx.ICON_ERROR)
             message.ShowModal()
             message.Destroy()
--- a/xmlclass/xmlclass.py	Fri May 04 19:20:46 2012 +0200
+++ b/xmlclass/xmlclass.py	Mon May 07 18:53:16 2012 +0200
@@ -1837,14 +1837,8 @@
 """
 This function generate the classes from a class factory
 """
-def GenerateClasses(factory, declare=False):
+def GenerateClasses(factory):
     ComputedClasses = factory.CreateClasses()
-    #factory.PrintClasses()
-    if declare:
-        for ClassName, Class in pluginClasses.items():
-            sys._getframe(1).f_locals[ClassName] = Class
-        for TypeName, Type in pluginTypes.items():
-            sys._getframe(1).f_locals[TypeName] = Type
     if factory.FileName is not None and len(ComputedClasses) == 1:
         globals().update(ComputedClasses[factory.FileName])
         return ComputedClasses[factory.FileName]