plcopen/plcopen.py
changeset 251 cc5377a296ea
parent 246 9cf9694e8d66
child 278 e3ed4747086f
--- a/plcopen/plcopen.py	Sat Sep 06 16:30:57 2008 +0200
+++ b/plcopen/plcopen.py	Sun Sep 07 15:25:40 2008 +0200
@@ -493,7 +493,7 @@
     setattr(cls, "GetCustomBlockType", GetCustomBlockType)
 
     # Return Block types checking for recursion
-    def GetCustomBlockTypes(self, exclude = ""):
+    def GetCustomBlockTypes(self, exclude = "", onlyfunctions = False):
         type = None
         if exclude != "":
             pou = self.getpou(exclude)
@@ -501,20 +501,16 @@
                 type = pou.getpouType()
         customblocktypes = []
         for customblocktype in self.CustomBlockTypes:
-            if customblocktype["name"] != exclude and not self.ElementIsUsedBy(exclude, customblocktype["name"]) and not (type == "function" and customblocktype["type"] != "function"):
+            if customblocktype["name"] != exclude and not self.ElementIsUsedBy(exclude, customblocktype["name"]) and not (onlyfunctions and customblocktype["type"] != "function"):
                 customblocktypes.append(customblocktype)
         return customblocktypes
     setattr(cls, "GetCustomBlockTypes", GetCustomBlockTypes)
 
     # Return Function Block types checking for recursion
     def GetCustomFunctionBlockTypes(self, exclude = ""):
-        type = None
-        if exclude != "":
-            pou = self.getpou(exclude)
-            type = pou.getpouType()
         customblocktypes = []
         for customblocktype in self.CustomBlockTypes:
-            if customblocktype["name"] != exclude and not self.ElementIsUsedBy(exclude, customblocktype["name"]) and not (type == "function" and customblocktype["type"] != "function"):
+            if customblocktype["name"] != exclude and not self.ElementIsUsedBy(exclude, customblocktype["name"]):
                 customblocktypes.append(customblocktype["name"])
         return customblocktypes
     setattr(cls, "GetCustomFunctionBlockTypes", GetCustomFunctionBlockTypes)