PLCControler.py
changeset 681 c141dad94ff4
parent 661 7891872e6fd7
child 684 f10449b18dbe
--- 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