Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
authorlaurent
Tue, 11 Sep 2012 19:13:42 +0200
changeset 826 098f822ef308
parent 825 0623820aa14a
child 827 a2ce084fb598
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
PLCControler.py
controls/PouInstanceVariablesPanel.py
--- a/PLCControler.py	Tue Sep 11 18:10:20 2012 +0200
+++ b/PLCControler.py	Tue Sep 11 19:13:42 2012 +0200
@@ -454,6 +454,21 @@
                                 var_infos = self.GetPouVariableInfos(project, variable, var_class, debug)
                                 if var_infos is not None:
                                     vars.append(var_infos)
+                        if pou.getbodyType() == "SFC":
+                            for transition in pou.gettransitionList():
+                                vars.append({
+                                    "name": transition.getname(),
+                                    "type": None, 
+                                    "class": ITEM_TRANSITION,
+                                    "edit": True,
+                                    "debug": True})
+                            for action in pou.getactionList():
+                                vars.append({
+                                    "name": action.getname(),
+                                    "type": None, 
+                                    "class": ITEM_ACTION,
+                                    "edit": True,
+                                    "debug": True})
                         return {"class": POU_TYPES[pou_type],
                                 "type": words[1],
                                 "variables": vars,
@@ -480,6 +495,19 @@
                                 "variables": vars,
                                 "edit": False,
                                 "debug": False}
+            elif words[0] in ['A', 'T']:
+                pou_vars = self.GetPouVariables(self.ComputePouName(words[1]), debug)
+                if pou_vars is not None:
+                    if words[0] == 'A':
+                        element_type = ITEM_ACTION
+                    elif words[0] == 'T':
+                        element_type = ITEM_TRANSITION
+                    return {"class": element_type,
+                            "type": None,
+                            "variables": [var for var in pou_vars["variables"] 
+                                          if var["class"] not in [ITEM_ACTION, ITEM_TRANSITION]],
+                            "edit": True,
+                            "debug": True}
             elif words[0] in ['C', 'R']:
                 if words[0] == 'C':
                     element_type = ITEM_CONFIGURATION
@@ -579,6 +607,10 @@
                 return [words[1]]
             elif words[0] == 'R':
                 return ["%s.%s" % (words[1], words[2])]
+            elif words[0] in ['T', 'A']:
+                return ["%s.%s" % (instance, words[2])
+                        for instance in self.SearchPouInstances(
+                            self.ComputePouName(words[1]), debug)]
         return []
     
     def RecursiveGetPouInstanceTagName(self, project, pou_type, parts):
--- a/controls/PouInstanceVariablesPanel.py	Tue Sep 11 18:10:20 2012 +0200
+++ b/controls/PouInstanceVariablesPanel.py	Tue Sep 11 19:13:42 2012 +0200
@@ -26,7 +26,7 @@
 import wx.lib.buttons
 import wx.lib.agw.customtreectrl as CT
 
-from PLCControler import ITEMS_VARIABLE, ITEM_CONFIGURATION, ITEM_RESOURCE, ITEM_POU
+from PLCControler import ITEMS_VARIABLE, ITEM_CONFIGURATION, ITEM_RESOURCE, ITEM_POU, ITEM_TRANSITION, ITEM_ACTION
 from util.BitmapLibrary import GetBitmap
 
 class PouInstanceVariablesPanel(wx.Panel):
@@ -221,6 +221,14 @@
                 tagname = self.Controller.ComputeConfigurationResourceName(
                     self.InstanceChoice.GetStringSelection(), 
                     infos["name"])
+            elif var_class == ITEM_TRANSITION:
+                tagname = self.Controller.ComputePouTransitionName(
+                    self.PouTagName.split("::")[1],
+                    infos["name"])
+            elif var_class == ITEM_ACTION:
+                tagname = self.Controller.ComputePouActionName(
+                    self.PouTagName.split("::")[1],
+                    infos["name"])
             else:
                 var_class = ITEM_POU
                 tagname = self.Controller.ComputePouName(infos["type"])
@@ -236,9 +244,23 @@
                                       infos["name"])
                 if var_class in ITEMS_VARIABLE:
                     self.ParentWindow.AddDebugVariable(var_path, force=True)
+                elif var_class == ITEM_TRANSITION:
+                    self.ParentWindow.OpenDebugViewer(
+                        var_class,
+                        var_path,
+                        self.Controller.ComputePouTransitionName(
+                            self.PouTagName.split("::")[1],
+                            infos["name"]))
+                elif var_class == ITEM_ACTION:
+                    self.ParentWindow.OpenDebugViewer(
+                        var_class,
+                        var_path,
+                        self.Controller.ComputePouActionName(
+                            self.PouTagName.split("::")[1],
+                            infos["name"]))
                 else:
                     self.ParentWindow.OpenDebugViewer(
-                        infos["class"],
+                        var_class,
                         var_path,
                         self.Controller.ComputePouName(infos["type"]))
             event.Skip()