PLCControler.py
changeset 552 a387f258814a
parent 549 b0d6819119c3
child 555 b6f9d08fd69f
--- a/PLCControler.py	Fri Sep 02 18:16:58 2011 +0200
+++ b/PLCControler.py	Wed Sep 07 15:53:28 2011 +0200
@@ -1298,7 +1298,7 @@
         return blocktypes
 
     # Return Data Types checking for recursion
-    def GetDataTypes(self, tagname = "", basetypes = True, debug = False):
+    def GetDataTypes(self, tagname = "", basetypes = True, only_locatables = False, debug = False):
         if basetypes:
             datatypes = self.GetBaseTypes()
         else:
@@ -1309,7 +1309,7 @@
             words = tagname.split("::")
             if words[0] in ["D"]:
                 name = words[1]
-            datatypes.extend(project.GetCustomDataTypes(name))
+            datatypes.extend(project.GetCustomDataTypes(name, only_locatables))
         return datatypes
 
     # Return Base Type of given possible derived type
@@ -1345,6 +1345,23 @@
             return not type.startswith("ANY")
         return True
 
+    def IsLocatableType(self, type, debug = False):
+        project = self.GetProject(debug)
+        if project is not None:
+            datatype = project.getdataType(type)
+            if datatype is not None:
+                return project.IsLocatableType(datatype)
+        return True
+    
+    def IsEnumeratedType(self, type, debug = False):
+        project = self.GetProject(debug)
+        if project is not None:
+            datatype = project.getdataType(type)
+            if datatype is not None:
+                basetype_content = datatype.baseType.getcontent()
+                return basetype_content["name"] == "enum"
+        return False
+
     def GetDataTypeRange(self, type, debug = False):
         project = self.GetProject(debug)
         if project is not None:
@@ -1361,10 +1378,10 @@
         return []
     
     # Return Enumerated Values
-    def GetEnumeratedDataValues(self, debug = False):
-        project = self.GetProject(debug)
-        if project is not None:
-            return project.GetEnumeratedDataTypeValues()
+    def GetEnumeratedDataValues(self, type = None, debug = False):
+        project = self.GetProject(debug)
+        if project is not None:
+            return project.GetEnumeratedDataTypeValues(type)
         return []
 
 #-------------------------------------------------------------------------------
@@ -1440,7 +1457,7 @@
                     for dimension in basetype_content["value"].getdimension():
                         infos["dimensions"].append((dimension.getlower(), dimension.getupper()))
                     base_type = basetype_content["value"].baseType.getcontent()
-                    if base_type["value"] is None or element_type["name"] in ["string", "wstring"]:
+                    if base_type["value"] is None or base_type["name"] in ["string", "wstring"]:
                         infos["base_type"] = base_type["name"].upper()
                     else:
                         infos["base_type"] = base_type["value"].getname()