Added highlighting of wrong SINGLE task trigger
authorEdouard Tisserant
Fri, 27 Jun 2014 13:56:49 +0200
changeset 1423 4e33f644f7cf
parent 1422 458d93275f71
child 1424 0f2ced10db48
child 1428 e14003eb4d42
Added highlighting of wrong SINGLE task trigger
editors/ResourceEditor.py
--- a/editors/ResourceEditor.py	Wed Jun 25 17:28:26 2014 +0200
+++ b/editors/ResourceEditor.py	Fri Jun 27 13:56:49 2014 +0200
@@ -72,6 +72,12 @@
     return [_("Interrupt"), _("Cyclic")]
 TASKTRIGGERINGOPTIONS_DICT = dict([(_(option), option) for option in GetTaskTriggeringOptions()])
 
+SingleCellEditor = lambda *x : wx.grid.GridCellChoiceEditor()
+
+def CheckSingle(single, varlist):
+    return single in varlist
+
+
 def GetInstancesTableColnames():
     _ = lambda x : x
     return [_("Name"), _("Type"), _("Task")]
@@ -114,8 +120,6 @@
                 value = TASKTRIGGERINGOPTIONS_DICT[value]
             self.data[row][colname] = value
 
-    SingleCellEditor = lambda x,c : wx.grid.GridCellChoiceEditor(x)
-
     def _updateColAttrs(self, grid):
         """
         wx.grid.Grid -> update the column attributes to add the
@@ -150,10 +154,13 @@
                     if interval != "" and IEC_TIME_MODEL.match(interval.upper()) is None:
                         error = True
                 elif colname == "Single":
-                    editor = self.SingleCellEditor(self,colname)
+                    editor = SingleCellEditor(self,colname)
                     editor.SetParameters(self.Parent.VariableList)
                     if self.GetValueByName(row, "Triggering") != "Interrupt":
                         grid.SetReadOnly(row, col, True)
+                    single = self.GetValueByName(row, colname)
+                    if single != "" and not CheckSingle(single,self.Parent.VariableList):
+                        error = True
                 elif colname == "Triggering":
                     editor = wx.grid.GridCellChoiceEditor()
                     editor.SetParameters(",".join(map(_, GetTaskTriggeringOptions())))
@@ -441,7 +448,7 @@
                         self.InstancesTable.SetValueByName(i, "Task", new_name)
         self.RefreshModel()
         colname = self.TasksTable.GetColLabelValue(col, False)
-        if colname in ["Triggering", "Name", "Interval"]:
+        if colname in ["Triggering", "Name", "Single", "Interval"]:
             wx.CallAfter(self.RefreshView, False)
         event.Skip()