PLCControler.py
changeset 68 66308e07402c
parent 67 3a1b0afdaf84
child 70 0e48629c1e6d
--- a/PLCControler.py	Thu Aug 09 18:07:44 2007 +0200
+++ b/PLCControler.py	Fri Aug 10 16:14:33 2007 +0200
@@ -269,23 +269,6 @@
                 pou_type = pou.getPouType().getValue()
                 pou_infos = {"name": pou.getName(), "type": ITEM_POU}
                 pou_values = []
-##                var_types = {"Input": {"name": "Input", "type": ITEM_CLASS, "values": []},
-##                         "Output": {"name": "Output", "type": ITEM_CLASS, "values": []},
-##                         "InOut": {"name": "InOut", "type": ITEM_CLASS, "values": []},
-##                         "External": {"name": "External", "type": ITEM_CLASS, "values": []},
-##                         "Local": {"name": "Local", "type": ITEM_CLASS, "values": []},
-##                         "Temp": {"name": "Temp", "type": ITEM_CLASS, "values": []},
-##                         "Global": {"name": "Global", "type": ITEM_CLASS, "values": []}}
-##                for var in self.GetPouInterfaceVars(pou):
-##                    var_values = {"name": var["Name"], "type": ITEM_VARIABLE, "values": []}
-##                    if var["Class"] in var_types.keys():
-##                        var_types[var["Class"]]["values"].append(var_values)
-##                pou_values.append({"name": "Interface", "type": ITEM_CLASS, 
-##                    "values": [var_types["Input"], var_types["Output"], var_types["InOut"], var_types["External"]]})
-##                pou_values.append({"name": "Variables", "type": ITEM_CLASS, 
-##                    "values": [var_types["Local"], var_types["Temp"]]})
-##                if pou_type == "program":
-##                    pou_values.append(var_types["Global"])
                 if pou.getBodyType() == "SFC":
                     transitions = []
                     for transition in pou.getTransitionList():
@@ -302,21 +285,11 @@
             for config in self.Project.getConfigurations():
                 config_name = config.getName()
                 config_infos = {"name": config_name, "type": ITEM_CONFIGURATION, "values": []}
-##                config_vars = {"name": "Global", "type": ITEM_CLASS, "values": []}
-##                for var in self.GetConfigurationGlobalVars(config_name):
-##                    var_values = {"name": var["Name"], "type": ITEM_VARIABLE, "values": []}
-##                    config_vars["values"].append(var_values)
                 resources = {"name": "Resources", "type": ITEM_UNEDITABLE, "values": []}
                 for resource in config.getResource():
                     resource_name = resource.getName()
                     resource_infos = {"name": resource_name, "type": ITEM_RESOURCE, "values": []}
-##                    resource_vars = {"name": "Global", "type": ITEM_CLASS, "values": []}
-##                    for var in self.GetConfigurationResourceGlobalVars(config_name, resource_name):
-##                        var_values = {"name": var["Name"], "type": ITEM_VARIABLE, "values": []}
-##                        resource_vars["values"].append(var_values)
-##                    resource_infos["values"].append(resource_vars)
                     resources["values"].append(resource_infos)
-##                config_infos["values"] = [config_vars, resources]
                 config_infos["values"] = [resources]
                 configurations["values"].append(config_infos)
             infos["values"] = [{"name": "Properties", "type": ITEM_UNEDITABLE, "values": []},
@@ -672,6 +645,7 @@
                         tempvar["Type"] = var_type
                     else:
                         tempvar["Type"] = var_type.getName()
+                    tempvar["Edit"] = True
                     initial = var.getInitialValue()
                     if initial:
                         tempvar["Initial Value"] = initial.getValue()
@@ -719,6 +693,7 @@
                         tempvar["Type"] = var_type
                     else:
                         tempvar["Type"] = var_type.getName()
+                    tempvar["Edit"] = True
                     initial = var.getInitialValue()
                     if initial:
                         tempvar["Initial Value"] = initial.getValue()
@@ -757,8 +732,10 @@
                     var_type = var.getType().getValue()
                     if isinstance(var_type, (StringType, UnicodeType)):
                         tempvar["Type"] = var_type
+                        tempvar["Edit"] = True
                     else:
                         tempvar["Type"] = var_type.getName()
+                        tempvar["Edit"] = not pou.hasBlock(tempvar["Name"])
                     initial = var.getInitialValue()
                     if initial:
                         tempvar["Initial Value"] = initial.getValue()
@@ -896,6 +873,34 @@
             return blocktypes
         return []
 
+    # Return Function Block types checking for recursion
+    def GetFunctionBlockTypes(self):
+        if self.CurrentElementEditing != None:
+            if self.Project:
+                current_name = self.ElementsOpened[self.CurrentElementEditing]
+                words = current_name.split("::")
+                if len(words) == 1:
+                    name = current_name
+                else:
+                    name = words[1]
+                type = self.GetPouType(name)
+            else:
+                name = ""
+                type = None
+            blocktypes = []
+            for category in BlockTypes[:-1]:
+                if category["name"] != "SVGUI function blocks":
+                    for block in category["list"]:
+                        if block["type"] != "function":
+                            blocktypes.append(block["name"])
+            if self.Project:
+                for blocktype in BlockTypes[-1]["list"]:
+                    if blocktype["name"] != name and not self.PouIsUsedBy(name, blocktype["name"]) and not (type == "function" and blocktype["type"] != "function"):
+                        blocktypes.append(blocktype["name"])
+            return blocktypes
+        return []
+
+
     # Return Block types checking for recursion
     def GetBlockResource(self):
         blocktypes = []