etherlab/EtherCATManagementEditor.py
changeset 2383 6cc3460be285
parent 2382 e783c6beacf1
child 2384 d7d9f0e60bc9
equal deleted inserted replaced
2382:e783c6beacf1 2383:6cc3460be285
  1451 #                    For Register Access Panel
  1451 #                    For Register Access Panel
  1452 # -------------------------------------------------------------------------------
  1452 # -------------------------------------------------------------------------------
  1453 class RegisterAccessPanel(wx.Panel):
  1453 class RegisterAccessPanel(wx.Panel):
  1454     def __init__(self, parent, controler):
  1454     def __init__(self, parent, controler):
  1455         """
  1455         """
  1456 	    Constructor
  1456         Constructor
  1457 	    @param parent: EEPROMAccessPanel object
  1457         @param parent: EEPROMAccessPanel object
  1458 	    @param controler: _EthercatSlaveCTN class in EthercatSlave.py
  1458         @param controler: _EthercatSlaveCTN class in EthercatSlave.py
  1459 	    """
  1459         """
  1460         self.parent = parent
  1460         self.parent = parent
  1461         self.Controler = controler
  1461         self.Controler = controler
  1462         self.__init_data()
  1462         self.__init_data()
  1463 
  1463 
  1464         wx.Panel.__init__(self, parent, -1)
  1464         wx.Panel.__init__(self, parent, -1)
  1492             for index in range(4):
  1492             for index in range(4):
  1493                 self.RegisterNotebook.RegPage[index].MainTable.SetValue(self, self.RegMonitorData, index*512, (index+1)*512)
  1493                 self.RegisterNotebook.RegPage[index].MainTable.SetValue(self, self.RegMonitorData, index*512, (index+1)*512)
  1494 
  1494 
  1495     def __init_data(self):
  1495     def __init_data(self):
  1496         """
  1496         """
  1497 	    Declare initial data.
  1497         Declare initial data.
  1498 	    """
  1498         """
  1499         # flag for compact view
  1499         # flag for compact view
  1500         self.CompactFlag = False
  1500         self.CompactFlag = False
  1501 
  1501 
  1502         # main grid의 rows and cols
  1502         # main grid의 rows and cols
  1503         self.MainRow = [512, 512, 512, 512]
  1503         self.MainRow = [512, 512, 512, 512]
  1866         """
  1866         """
  1867         Constructor
  1867         Constructor
  1868         @param parent: RegisterAccessPanel object
  1868         @param parent: RegisterAccessPanel object
  1869         @param controler: _EthercatSlaveCTN class in EthercatSlave.py
  1869         @param controler: _EthercatSlaveCTN class in EthercatSlave.py
  1870         @param row, col: size of the table
  1870         @param row, col: size of the table
  1871     	"""
  1871         """
  1872         wx.Panel.__init__(self, parent, -1)
  1872         wx.Panel.__init__(self, parent, -1)
  1873 
  1873 
  1874         self.parent = parent
  1874         self.parent = parent
  1875         self.Controler = controler
  1875         self.Controler = controler
  1876         self.Row = row
  1876         self.Row = row
  1896         It's done by deleting the main table and creating it again.
  1896         It's done by deleting the main table and creating it again.
  1897         @param row, col: size of the table
  1897         @param row, col: size of the table
  1898         @param low_index: the lowest index of the page
  1898         @param low_index: the lowest index of the page
  1899         @param high_index: the highest index of the page
  1899         @param high_index: the highest index of the page
  1900         @param data: data
  1900         @param data: data
  1901     	"""
  1901         """
  1902         self.MainTable.Destroy()
  1902         self.MainTable.Destroy()
  1903         self.MainTable = RegisterMainTable(self, row, col, self.Controler)
  1903         self.MainTable = RegisterMainTable(self, row, col, self.Controler)
  1904         self.Sizer.Detach(self.SubTable)
  1904         self.Sizer.Detach(self.SubTable)
  1905         self.Sizer.AddMany([self.MainTable, self.SubTable])
  1905         self.Sizer.AddMany([self.MainTable, self.SubTable])
  1906         self.SetSizer(self.Sizer)
  1906         self.SetSizer(self.Sizer)
  1912         """
  1912         """
  1913         Updates sub table.
  1913         Updates sub table.
  1914         It's done by deleting the sub table and creating it again.
  1914         It's done by deleting the sub table and creating it again.
  1915         @param row, col: size of the table
  1915         @param row, col: size of the table
  1916         @param data: data
  1916         @param data: data
  1917     	"""
  1917         """
  1918         self.SubTable.Destroy()
  1918         self.SubTable.Destroy()
  1919         self.SubTable = RegisterSubTable(self, row, col)
  1919         self.SubTable = RegisterSubTable(self, row, col)
  1920         self.Sizer.Detach(self.MainTable)
  1920         self.Sizer.Detach(self.MainTable)
  1921         self.Sizer.AddMany([self.MainTable, self.SubTable])
  1921         self.Sizer.AddMany([self.MainTable, self.SubTable])
  1922         self.Sizer.Layout()
  1922         self.Sizer.Layout()
  1930 #                    For Register Access Notebook Panel (Main Table)
  1930 #                    For Register Access Notebook Panel (Main Table)
  1931 # -------------------------------------------------------------------------------
  1931 # -------------------------------------------------------------------------------
  1932 class RegisterMainTable(wx.grid.Grid):
  1932 class RegisterMainTable(wx.grid.Grid):
  1933     def __init__(self, parent, row, col, controler):
  1933     def __init__(self, parent, row, col, controler):
  1934         """
  1934         """
  1935 	    Constructor
  1935             Constructor
  1936 	    @param parent: RegisterNotebook object
  1936             @param parent: RegisterNotebook object
  1937 	    @param row, col: size of the table
  1937             @param row, col: size of the table
  1938 	    @param controler: _EthercatSlaveCTN class in EthercatSlave.py
  1938             @param controler: _EthercatSlaveCTN class in EthercatSlave.py
  1939 	    """
  1939             """
  1940         self.parent = parent
  1940         self.parent = parent
  1941         self.Data = {}
  1941         self.Data = {}
  1942         self.Row = row
  1942         self.Row = row
  1943         self.Col = col
  1943         self.Col = col
  1944         self.Controler = controler
  1944         self.Controler = controler
  1952                                     (gridlib.EVT_GRID_CELL_LEFT_DCLICK, self.OnRegModifyDialog)]:
  1952                                     (gridlib.EVT_GRID_CELL_LEFT_DCLICK, self.OnRegModifyDialog)]:
  1953             self.Bind(evt, mapping_method)
  1953             self.Bind(evt, mapping_method)
  1954 
  1954 
  1955     def SetValue(self, parent, reg_monitor_data, low_index, high_index):
  1955     def SetValue(self, parent, reg_monitor_data, low_index, high_index):
  1956         """
  1956         """
  1957 	    Set the RegMonitorData into the main table.
  1957             Set the RegMonitorData into the main table.
  1958 	    @param parent: RegisterNotebook object
  1958             @param parent: RegisterNotebook object
  1959 	    @param reg_monitor_data: data
  1959             @param reg_monitor_data: data
  1960 	    @param low_index: the lowest index of the page
  1960             @param low_index: the lowest index of the page
  1961 	    @param high_index: the highest index of the page
  1961             @param high_index: the highest index of the page
  1962 	    """
  1962             """
  1963         self.RegMonitorData = reg_monitor_data
  1963         self.RegMonitorData = reg_monitor_data
  1964 
  1964 
  1965         # set label name and size
  1965         # set label name and size
  1966         register_maintable_label = [(0, "Description"), (1, "Dec"),
  1966         register_maintable_label = [(0, "Description"), (1, "Dec"),
  1967                                     (2, "Hex"), (3, "Char")]
  1967                                     (2, "Hex"), (3, "Char")]
  1987                 col = col + 1
  1987                 col = col + 1
  1988             row = row + 1
  1988             row = row + 1
  1989 
  1989 
  1990     def OnSelectCell(self, event):
  1990     def OnSelectCell(self, event):
  1991         """
  1991         """
  1992 	    Handles the event of the cell of the main table.
  1992             Handles the event of the cell of the main table.
  1993 	    @param event: gridlib object (left click)
  1993             @param event: gridlib object (left click)
  1994 	    """
  1994             """
  1995         # if reg_monitor_data is 0, it is initialization of register access.
  1995         # if reg_monitor_data is 0, it is initialization of register access.
  1996         if self.RegMonitorData == 0:
  1996         if self.RegMonitorData == 0:
  1997             event.Skip()
  1997             event.Skip()
  1998             return 0
  1998             return 0
  1999 
  1999 
  2031     def OnRegModifyDialog(self, event):
  2031     def OnRegModifyDialog(self, event):
  2032         """
  2032         """
  2033         Handle the event of the cell of the main table.
  2033         Handle the event of the cell of the main table.
  2034         Display the window where the user modifies the value of the cell.
  2034         Display the window where the user modifies the value of the cell.
  2035         @param event: gridlib object (double click)
  2035         @param event: gridlib object (double click)
  2036 	    """
  2036             """
  2037         # user can enter a value in case that user double-clicked 'Dec' or 'Hex' value.
  2037         # user can enter a value in case that user double-clicked 'Dec' or 'Hex' value.
  2038         if event.GetCol() == 1 or event.GetCol() == 2:
  2038         if event.GetCol() == 1 or event.GetCol() == 2:
  2039             dlg = wx.TextEntryDialog(self, "Enter hex(0xnnnn) or dec(n) value",
  2039             dlg = wx.TextEntryDialog(self, "Enter hex(0xnnnn) or dec(n) value",
  2040                                      "Register Modify Dialog", style=wx.OK | wx.CANCEL)
  2040                                      "Register Modify Dialog", style=wx.OK | wx.CANCEL)
  2041 
  2041 
  2081 #                    For Register Access Notebook Panel (Sub Table)
  2081 #                    For Register Access Notebook Panel (Sub Table)
  2082 # -------------------------------------------------------------------------------
  2082 # -------------------------------------------------------------------------------
  2083 class RegisterSubTable(wx.grid.Grid):
  2083 class RegisterSubTable(wx.grid.Grid):
  2084     def __init__(self, parent, row, col):
  2084     def __init__(self, parent, row, col):
  2085         """
  2085         """
  2086     	 Constructor
  2086          Constructor
  2087     	 @param parent: RegisterNotebook object
  2087          @param parent: RegisterNotebook object
  2088     	 @param row, col: size of the table
  2088          @param row, col: size of the table
  2089     	"""
  2089         """
  2090         self.parent = parent
  2090         self.parent = parent
  2091         self.Data = {}
  2091         self.Data = {}
  2092         self.Row = row
  2092         self.Row = row
  2093         self.Col = col
  2093         self.Col = col
  2094 
  2094 
  2095         wx.grid.Grid.__init__(self, parent, -1, size=(820, 150),
  2095         wx.grid.Grid.__init__(self, parent, -1, size=(820, 150),
  2096                               style=wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)
  2096                               style=wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)
  2097 
  2097 
  2098     def SetValue(self, parent, data):
  2098     def SetValue(self, parent, data):
  2099         """
  2099         """
  2100 	    Set the data into the subtable.
  2100             Set the data into the subtable.
  2101 	    @param parent: RegisterNotebook object
  2101             @param parent: RegisterNotebook object
  2102 	    @param data: data
  2102             @param data: data
  2103 	    """
  2103             """
  2104         # lset label name and size
  2104         # lset label name and size
  2105         Register_SubTable_Label = [(0, "Bits"), (1, "Name"),
  2105         Register_SubTable_Label = [(0, "Bits"), (1, "Name"),
  2106                                    (2, "Value"), (3, "Enum")]
  2106                                    (2, "Value"), (3, "Enum")]
  2107 
  2107 
  2108         for (index, label) in Register_SubTable_Label:
  2108         for (index, label) in Register_SubTable_Label: