etherlab/EtherCATManagementEditor.py
changeset 2389 f86eefc8d378
parent 2386 d00f1430d57a
child 2390 81116c5db60f
equal deleted inserted replaced
2388:13acfd8d33e6 2389:f86eefc8d378
    18 from controls import CustomGrid, CustomTable
    18 from controls import CustomGrid, CustomTable
    19 # --------------------------------------------------------------------
    19 # --------------------------------------------------------------------
    20 
    20 
    21 # ------------ for SDO Management --------------------
    21 # ------------ for SDO Management --------------------
    22 import string
    22 import string
    23 import wx.grid as gridlib
       
    24 # -------------------------------------------------------------
    23 # -------------------------------------------------------------
    25 
    24 
    26 # ------------ for register management ---------------
    25 # ------------ for register management ---------------
    27 from xml.dom import minidom
    26 from xml.dom import minidom
    28 from util.TranslationCatalogs import NoTranslate
    27 from util.TranslationCatalogs import NoTranslate
   569             self.SetColLabelAlignment(index, wx.ALIGN_CENTRE)
   568             self.SetColLabelAlignment(index, wx.ALIGN_CENTRE)
   570 
   569 
   571         attr = wx.grid.GridCellAttr()
   570         attr = wx.grid.GridCellAttr()
   572 
   571 
   573         # for SDO download
   572         # for SDO download
   574         self.Bind(gridlib.EVT_GRID_CELL_LEFT_DCLICK, self.SDOModifyDialog)
   573         self.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.SDOModifyDialog)
   575 
   574 
   576         for i in range(7):
   575         for i in range(7):
   577             self.SetColAttr(i, attr)
   576             self.SetColAttr(i, attr)
   578 
   577 
   579         self.SetColLabelAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER)
   578         self.SetColLabelAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER)
   645 
   644 
   646     def SDOModifyDialog(self, event):
   645     def SDOModifyDialog(self, event):
   647         """
   646         """
   648         Create dialog for SDO value modify
   647         Create dialog for SDO value modify
   649         if user enter data, perform command "ethercat download"
   648         if user enter data, perform command "ethercat download"
   650         @param event : gridlib.EVT_GRID_CELL_LEFT_DCLICK object
   649         @param event : wx.grid.EVT_GRID_CELL_LEFT_DCLICK object
   651         """
   650         """
   652         self.ClearStateFlag()
   651         self.ClearStateFlag()
   653 
   652 
   654         # CheckSDODataAccess is checking that OD(Object Dictionary) has "w"
   653         # CheckSDODataAccess is checking that OD(Object Dictionary) has "w"
   655         if event.GetCol() == 7 and self.CheckSDODataAccess(event.GetRow()):
   654         if event.GetCol() == 7 and self.CheckSDODataAccess(event.GetRow()):
  1945         self.RegisterAccessPanel = self.parent.parent.parent
  1944         self.RegisterAccessPanel = self.parent.parent.parent
  1946 
  1945 
  1947         wx.grid.Grid.__init__(self, parent, -1, size=(820, 300),
  1946         wx.grid.Grid.__init__(self, parent, -1, size=(820, 300),
  1948                               style=wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)
  1947                               style=wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)
  1949 
  1948 
  1950         for evt, mapping_method in [(gridlib.EVT_GRID_CELL_LEFT_CLICK, self.OnSelectCell),
  1949         for evt, mapping_method in [(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnSelectCell),
  1951                                     (gridlib.EVT_GRID_CELL_LEFT_CLICK, self.OnSelectCell),
  1950                                     (wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnSelectCell),
  1952                                     (gridlib.EVT_GRID_CELL_LEFT_DCLICK, self.OnRegModifyDialog)]:
  1951                                     (wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.OnRegModifyDialog)]:
  1953             self.Bind(evt, mapping_method)
  1952             self.Bind(evt, mapping_method)
  1954 
  1953 
  1955     def SetValue(self, parent, reg_monitor_data, low_index, high_index):
  1954     def SetValue(self, parent, reg_monitor_data, low_index, high_index):
  1956         """
  1955         """
  1957             Set the RegMonitorData into the main table.
  1956             Set the RegMonitorData into the main table.
  1988             row = row + 1
  1987             row = row + 1
  1989 
  1988 
  1990     def OnSelectCell(self, event):
  1989     def OnSelectCell(self, event):
  1991         """
  1990         """
  1992             Handles the event of the cell of the main table.
  1991             Handles the event of the cell of the main table.
  1993             @param event: gridlib object (left click)
  1992             @param event: wx.grid object (left click)
  1994             """
  1993             """
  1995         # if reg_monitor_data is 0, it is initialization of register access.
  1994         # if reg_monitor_data is 0, it is initialization of register access.
  1996         if self.RegMonitorData == 0:
  1995         if self.RegMonitorData == 0:
  1997             event.Skip()
  1996             event.Skip()
  1998             return 0
  1997             return 0
  2030 
  2029 
  2031     def OnRegModifyDialog(self, event):
  2030     def OnRegModifyDialog(self, event):
  2032         """
  2031         """
  2033         Handle the event of the cell of the main table.
  2032         Handle the event of the cell of the main table.
  2034         Display the window where the user modifies the value of the cell.
  2033         Display the window where the user modifies the value of the cell.
  2035         @param event: gridlib object (double click)
  2034         @param event: wx.grid object (double click)
  2036             """
  2035             """
  2037         # user can enter a value in case that user double-clicked 'Dec' or 'Hex' value.
  2036         # user can enter a value in case that user double-clicked 'Dec' or 'Hex' value.
  2038         if event.GetCol() == 1 or event.GetCol() == 2:
  2037         if event.GetCol() == 1 or event.GetCol() == 2:
  2039             dlg = wx.TextEntryDialog(self, "Enter hex(0xnnnn) or dec(n) value",
  2038             dlg = wx.TextEntryDialog(self, "Enter hex(0xnnnn) or dec(n) value",
  2040                                      "Register Modify Dialog", style=wx.OK | wx.CANCEL)
  2039                                      "Register Modify Dialog", style=wx.OK | wx.CANCEL)