1104 |
1104 |
1105 #------------------------------------------------------------------------------- |
1105 #------------------------------------------------------------------------------- |
1106 # Popup menu functions |
1106 # Popup menu functions |
1107 #------------------------------------------------------------------------------- |
1107 #------------------------------------------------------------------------------- |
1108 |
1108 |
1109 def GetForceVariableMenuFunction(self, iec_path): |
1109 def GetForceVariableMenuFunction(self, iec_path, element): |
1110 iec_type = self.GetDataType(iec_path) |
1110 iec_type = self.GetDataType(iec_path) |
1111 def ForceVariableFunction(event): |
1111 def ForceVariableFunction(event): |
1112 if iec_type is not None: |
1112 if iec_type is not None: |
1113 dialog = ForceVariableDialog(self.ParentWindow, iec_type) |
1113 dialog = ForceVariableDialog(self.ParentWindow, iec_type, str(element.GetValue())) |
1114 if dialog.ShowModal() == wx.ID_OK: |
1114 if dialog.ShowModal() == wx.ID_OK: |
|
1115 self.ParentWindow.AddDebugVariable(iec_path) |
1115 self.ForceDataValue(iec_path, dialog.GetValue()) |
1116 self.ForceDataValue(iec_path, dialog.GetValue()) |
1116 return ForceVariableFunction |
1117 return ForceVariableFunction |
1117 |
1118 |
1118 def GetReleaseVariableMenuFunction(self, iec_path): |
1119 def GetReleaseVariableMenuFunction(self, iec_path): |
1119 def ReleaseVariableFunction(event): |
1120 def ReleaseVariableFunction(event): |
1124 iec_path = self.GetElementIECPath(self.SelectedElement) |
1125 iec_path = self.GetElementIECPath(self.SelectedElement) |
1125 if iec_path is not None: |
1126 if iec_path is not None: |
1126 menu = wx.Menu(title='') |
1127 menu = wx.Menu(title='') |
1127 new_id = wx.NewId() |
1128 new_id = wx.NewId() |
1128 AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Force value")) |
1129 AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Force value")) |
1129 self.Bind(wx.EVT_MENU, self.GetForceVariableMenuFunction(iec_path.upper()), id=new_id) |
1130 self.Bind(wx.EVT_MENU, self.GetForceVariableMenuFunction(iec_path.upper(), self.SelectedElement), id=new_id) |
1130 new_id = wx.NewId() |
1131 new_id = wx.NewId() |
1131 AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Release value")) |
1132 AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Release value")) |
1132 self.Bind(wx.EVT_MENU, self.GetReleaseVariableMenuFunction(iec_path.upper()), id=new_id) |
1133 self.Bind(wx.EVT_MENU, self.GetReleaseVariableMenuFunction(iec_path.upper()), id=new_id) |
1133 if self.SelectedElement.IsForced(): |
1134 if self.SelectedElement.IsForced(): |
1134 menu.Enable(new_id, True) |
1135 menu.Enable(new_id, True) |