267 "program": {"name": "Programs", "type": ITEM_UNEDITABLE, "values":[]}} |
267 "program": {"name": "Programs", "type": ITEM_UNEDITABLE, "values":[]}} |
268 for pou in self.Project.getPous(): |
268 for pou in self.Project.getPous(): |
269 pou_type = pou.getPouType().getValue() |
269 pou_type = pou.getPouType().getValue() |
270 pou_infos = {"name": pou.getName(), "type": ITEM_POU} |
270 pou_infos = {"name": pou.getName(), "type": ITEM_POU} |
271 pou_values = [] |
271 pou_values = [] |
272 ## var_types = {"Input": {"name": "Input", "type": ITEM_CLASS, "values": []}, |
|
273 ## "Output": {"name": "Output", "type": ITEM_CLASS, "values": []}, |
|
274 ## "InOut": {"name": "InOut", "type": ITEM_CLASS, "values": []}, |
|
275 ## "External": {"name": "External", "type": ITEM_CLASS, "values": []}, |
|
276 ## "Local": {"name": "Local", "type": ITEM_CLASS, "values": []}, |
|
277 ## "Temp": {"name": "Temp", "type": ITEM_CLASS, "values": []}, |
|
278 ## "Global": {"name": "Global", "type": ITEM_CLASS, "values": []}} |
|
279 ## for var in self.GetPouInterfaceVars(pou): |
|
280 ## var_values = {"name": var["Name"], "type": ITEM_VARIABLE, "values": []} |
|
281 ## if var["Class"] in var_types.keys(): |
|
282 ## var_types[var["Class"]]["values"].append(var_values) |
|
283 ## pou_values.append({"name": "Interface", "type": ITEM_CLASS, |
|
284 ## "values": [var_types["Input"], var_types["Output"], var_types["InOut"], var_types["External"]]}) |
|
285 ## pou_values.append({"name": "Variables", "type": ITEM_CLASS, |
|
286 ## "values": [var_types["Local"], var_types["Temp"]]}) |
|
287 ## if pou_type == "program": |
|
288 ## pou_values.append(var_types["Global"]) |
|
289 if pou.getBodyType() == "SFC": |
272 if pou.getBodyType() == "SFC": |
290 transitions = [] |
273 transitions = [] |
291 for transition in pou.getTransitionList(): |
274 for transition in pou.getTransitionList(): |
292 transitions.append({"name": transition.getName(), "type": ITEM_TRANSITION, "values": []}) |
275 transitions.append({"name": transition.getName(), "type": ITEM_TRANSITION, "values": []}) |
293 pou_values.append({"name": "Transitions", "type": ITEM_UNEDITABLE, "values": transitions}) |
276 pou_values.append({"name": "Transitions", "type": ITEM_UNEDITABLE, "values": transitions}) |
300 pou_types[pou_type]["values"].append(pou_infos) |
283 pou_types[pou_type]["values"].append(pou_infos) |
301 configurations = {"name": "Configurations", "type": ITEM_UNEDITABLE, "values": []} |
284 configurations = {"name": "Configurations", "type": ITEM_UNEDITABLE, "values": []} |
302 for config in self.Project.getConfigurations(): |
285 for config in self.Project.getConfigurations(): |
303 config_name = config.getName() |
286 config_name = config.getName() |
304 config_infos = {"name": config_name, "type": ITEM_CONFIGURATION, "values": []} |
287 config_infos = {"name": config_name, "type": ITEM_CONFIGURATION, "values": []} |
305 ## config_vars = {"name": "Global", "type": ITEM_CLASS, "values": []} |
|
306 ## for var in self.GetConfigurationGlobalVars(config_name): |
|
307 ## var_values = {"name": var["Name"], "type": ITEM_VARIABLE, "values": []} |
|
308 ## config_vars["values"].append(var_values) |
|
309 resources = {"name": "Resources", "type": ITEM_UNEDITABLE, "values": []} |
288 resources = {"name": "Resources", "type": ITEM_UNEDITABLE, "values": []} |
310 for resource in config.getResource(): |
289 for resource in config.getResource(): |
311 resource_name = resource.getName() |
290 resource_name = resource.getName() |
312 resource_infos = {"name": resource_name, "type": ITEM_RESOURCE, "values": []} |
291 resource_infos = {"name": resource_name, "type": ITEM_RESOURCE, "values": []} |
313 ## resource_vars = {"name": "Global", "type": ITEM_CLASS, "values": []} |
|
314 ## for var in self.GetConfigurationResourceGlobalVars(config_name, resource_name): |
|
315 ## var_values = {"name": var["Name"], "type": ITEM_VARIABLE, "values": []} |
|
316 ## resource_vars["values"].append(var_values) |
|
317 ## resource_infos["values"].append(resource_vars) |
|
318 resources["values"].append(resource_infos) |
292 resources["values"].append(resource_infos) |
319 ## config_infos["values"] = [config_vars, resources] |
|
320 config_infos["values"] = [resources] |
293 config_infos["values"] = [resources] |
321 configurations["values"].append(config_infos) |
294 configurations["values"].append(config_infos) |
322 infos["values"] = [{"name": "Properties", "type": ITEM_UNEDITABLE, "values": []}, |
295 infos["values"] = [{"name": "Properties", "type": ITEM_UNEDITABLE, "values": []}, |
323 pou_types["function"], pou_types["functionBlock"], |
296 pou_types["function"], pou_types["functionBlock"], |
324 pou_types["program"], configurations] |
297 pou_types["program"], configurations] |
670 var_type = var.getType().getValue() |
643 var_type = var.getType().getValue() |
671 if isinstance(var_type, (StringType, UnicodeType)): |
644 if isinstance(var_type, (StringType, UnicodeType)): |
672 tempvar["Type"] = var_type |
645 tempvar["Type"] = var_type |
673 else: |
646 else: |
674 tempvar["Type"] = var_type.getName() |
647 tempvar["Type"] = var_type.getName() |
|
648 tempvar["Edit"] = True |
675 initial = var.getInitialValue() |
649 initial = var.getInitialValue() |
676 if initial: |
650 if initial: |
677 tempvar["Initial Value"] = initial.getValue() |
651 tempvar["Initial Value"] = initial.getValue() |
678 else: |
652 else: |
679 tempvar["Initial Value"] = "" |
653 tempvar["Initial Value"] = "" |
717 var_type = var.getType().getValue() |
691 var_type = var.getType().getValue() |
718 if isinstance(var_type, (StringType, UnicodeType)): |
692 if isinstance(var_type, (StringType, UnicodeType)): |
719 tempvar["Type"] = var_type |
693 tempvar["Type"] = var_type |
720 else: |
694 else: |
721 tempvar["Type"] = var_type.getName() |
695 tempvar["Type"] = var_type.getName() |
|
696 tempvar["Edit"] = True |
722 initial = var.getInitialValue() |
697 initial = var.getInitialValue() |
723 if initial: |
698 if initial: |
724 tempvar["Initial Value"] = initial.getValue() |
699 tempvar["Initial Value"] = initial.getValue() |
725 else: |
700 else: |
726 tempvar["Initial Value"] = "" |
701 tempvar["Initial Value"] = "" |
755 for var in varlist.getVariable(): |
730 for var in varlist.getVariable(): |
756 tempvar = {"Name":var.getName(),"Class":type} |
731 tempvar = {"Name":var.getName(),"Class":type} |
757 var_type = var.getType().getValue() |
732 var_type = var.getType().getValue() |
758 if isinstance(var_type, (StringType, UnicodeType)): |
733 if isinstance(var_type, (StringType, UnicodeType)): |
759 tempvar["Type"] = var_type |
734 tempvar["Type"] = var_type |
|
735 tempvar["Edit"] = True |
760 else: |
736 else: |
761 tempvar["Type"] = var_type.getName() |
737 tempvar["Type"] = var_type.getName() |
|
738 tempvar["Edit"] = not pou.hasBlock(tempvar["Name"]) |
762 initial = var.getInitialValue() |
739 initial = var.getInitialValue() |
763 if initial: |
740 if initial: |
764 tempvar["Initial Value"] = initial.getValue() |
741 tempvar["Initial Value"] = initial.getValue() |
765 else: |
742 else: |
766 tempvar["Initial Value"] = "" |
743 tempvar["Initial Value"] = "" |
893 for blocktype in BlockTypes[-1]["list"]: |
870 for blocktype in BlockTypes[-1]["list"]: |
894 if blocktype["name"] != name and not self.PouIsUsedBy(name, blocktype["name"]) and not (type == "function" and blocktype["type"] != "function"): |
871 if blocktype["name"] != name and not self.PouIsUsedBy(name, blocktype["name"]) and not (type == "function" and blocktype["type"] != "function"): |
895 blocktypes[-1]["list"].append(blocktype) |
872 blocktypes[-1]["list"].append(blocktype) |
896 return blocktypes |
873 return blocktypes |
897 return [] |
874 return [] |
|
875 |
|
876 # Return Function Block types checking for recursion |
|
877 def GetFunctionBlockTypes(self): |
|
878 if self.CurrentElementEditing != None: |
|
879 if self.Project: |
|
880 current_name = self.ElementsOpened[self.CurrentElementEditing] |
|
881 words = current_name.split("::") |
|
882 if len(words) == 1: |
|
883 name = current_name |
|
884 else: |
|
885 name = words[1] |
|
886 type = self.GetPouType(name) |
|
887 else: |
|
888 name = "" |
|
889 type = None |
|
890 blocktypes = [] |
|
891 for category in BlockTypes[:-1]: |
|
892 if category["name"] != "SVGUI function blocks": |
|
893 for block in category["list"]: |
|
894 if block["type"] != "function": |
|
895 blocktypes.append(block["name"]) |
|
896 if self.Project: |
|
897 for blocktype in BlockTypes[-1]["list"]: |
|
898 if blocktype["name"] != name and not self.PouIsUsedBy(name, blocktype["name"]) and not (type == "function" and blocktype["type"] != "function"): |
|
899 blocktypes.append(blocktype["name"]) |
|
900 return blocktypes |
|
901 return [] |
|
902 |
898 |
903 |
899 # Return Block types checking for recursion |
904 # Return Block types checking for recursion |
900 def GetBlockResource(self): |
905 def GetBlockResource(self): |
901 blocktypes = [] |
906 blocktypes = [] |
902 for category in BlockTypes[:-1]: |
907 for category in BlockTypes[:-1]: |