controls/DebugVariablePanel.py
changeset 1102 cd4a996ddaa7
parent 1089 5cd1f8df71aa
child 1174 9cc1a3fa9619
equal deleted inserted replaced
1101:5a0b439cf576 1102:cd4a996ddaa7
   551         def IsEmpty(self):
   551         def IsEmpty(self):
   552             return len(self.Items) == 0
   552             return len(self.Items) == 0
   553         
   553         
   554         def UnregisterObsoleteData(self):
   554         def UnregisterObsoleteData(self):
   555             for item in self.Items[:]:
   555             for item in self.Items[:]:
   556                 iec_path = item.GetVariable().upper()
   556                 iec_path = item.GetVariable()
   557                 if self.ParentWindow.GetDataType(iec_path) is None:
   557                 if self.ParentWindow.GetDataType(iec_path) is None:
   558                     self.ParentWindow.RemoveDataConsumer(item)
   558                     self.ParentWindow.RemoveDataConsumer(item)
   559                     self.RemoveItem(item)
   559                     self.RemoveItem(item)
   560                 else:
   560                 else:
   561                     self.ParentWindow.AddDataConsumer(iec_path, item)
   561                     self.ParentWindow.AddDataConsumer(iec_path.upper(), item)
   562                     item.RefreshVariableType()
   562                     item.RefreshVariableType()
   563             
   563             
   564         def ResetData(self):
   564         def ResetData(self):
   565             for item in self.Items:
   565             for item in self.Items:
   566                 item.ResetData()
   566                 item.ResetData()
   698         def OnResize(self, event):
   698         def OnResize(self, event):
   699             wx.CallAfter(self.RefreshButtonsState, True)
   699             wx.CallAfter(self.RefreshButtonsState, True)
   700             event.Skip()
   700             event.Skip()
   701         
   701         
   702         def ForceValue(self, item):
   702         def ForceValue(self, item):
   703             iec_path = item.GetVariable().upper()
   703             iec_path = item.GetVariable()
   704             iec_type = self.ParentWindow.GetDataType(iec_path)
   704             iec_type = self.ParentWindow.GetDataType(iec_path)
   705             if iec_type is not None:
   705             if iec_type is not None:
   706                 dialog = ForceVariableDialog(self, iec_type, str(item.GetValue()))
   706                 dialog = ForceVariableDialog(self, iec_type, str(item.GetValue()))
   707                 if dialog.ShowModal() == wx.ID_OK:
   707                 if dialog.ShowModal() == wx.ID_OK:
   708                     self.ParentWindow.ForceDataValue(iec_path, dialog.GetValue())
   708                     self.ParentWindow.ForceDataValue(iec_path.upper(), dialog.GetValue())
   709         
   709         
   710         def ReleaseValue(self, item):
   710         def ReleaseValue(self, item):
   711             iec_path = item.GetVariable().upper()
   711             iec_path = item.GetVariable().upper()
   712             self.ParentWindow.ReleaseDataValue(iec_path)
   712             self.ParentWindow.ReleaseDataValue(iec_path)
   713     
   713     
  1830             
  1830             
  1831         else:
  1831         else:
  1832             items = [(idx, item) for idx, item in enumerate(self.Table.GetData())]
  1832             items = [(idx, item) for idx, item in enumerate(self.Table.GetData())]
  1833             items.reverse()
  1833             items.reverse()
  1834             for idx, item in items:
  1834             for idx, item in items:
  1835                 iec_path = item.GetVariable().upper()
  1835                 iec_path = item.GetVariable()
  1836                 if self.GetDataType(iec_path) is None:
  1836                 if self.GetDataType(iec_path) is None:
  1837                     self.RemoveDataConsumer(item)
  1837                     self.RemoveDataConsumer(item)
  1838                     self.Table.RemoveItem(idx)
  1838                     self.Table.RemoveItem(idx)
  1839                 else:
  1839                 else:
  1840                     self.AddDataConsumer(iec_path, item)
  1840                     self.AddDataConsumer(iec_path.upper(), item)
  1841                     item.RefreshVariableType()
  1841                     item.RefreshVariableType()
  1842             self.Freeze()
  1842             self.Freeze()
  1843             self.Table.ResetView(self.VariablesGrid)
  1843             self.Table.ResetView(self.VariablesGrid)
  1844             self.VariablesGrid.RefreshButtons()
  1844             self.VariablesGrid.RefreshButtons()
  1845             self.Thaw()
  1845             self.Thaw()
  1891         iec_type = self.GetDataType(iec_path)
  1891         iec_type = self.GetDataType(iec_path)
  1892         def ForceVariableFunction(event):
  1892         def ForceVariableFunction(event):
  1893             if iec_type is not None:
  1893             if iec_type is not None:
  1894                 dialog = ForceVariableDialog(self, iec_type, str(item.GetValue()))
  1894                 dialog = ForceVariableDialog(self, iec_type, str(item.GetValue()))
  1895                 if dialog.ShowModal() == wx.ID_OK:
  1895                 if dialog.ShowModal() == wx.ID_OK:
  1896                     self.ForceDataValue(iec_path, dialog.GetValue())
  1896                     self.ForceDataValue(iec_path.upper(), dialog.GetValue())
  1897         return ForceVariableFunction
  1897         return ForceVariableFunction
  1898 
  1898 
  1899     def GetReleaseVariableMenuFunction(self, iec_path):
  1899     def GetReleaseVariableMenuFunction(self, iec_path):
  1900         def ReleaseVariableFunction(event):
  1900         def ReleaseVariableFunction(event):
  1901             self.ReleaseDataValue(iec_path)
  1901             self.ReleaseDataValue(iec_path)