19 # -------------------------------------------------------------------- |
19 # -------------------------------------------------------------------- |
20 |
20 |
21 # ------------ for SDO Management -------------------- |
21 # ------------ for SDO Management -------------------- |
22 import string |
22 import string |
23 import wx.grid as gridlib |
23 import wx.grid as gridlib |
24 #------------------------------------------------------------- |
24 # ------------------------------------------------------------- |
25 |
25 |
26 # ------------ for register management --------------- |
26 # ------------ for register management --------------- |
27 from xml.dom import minidom |
27 from xml.dom import minidom |
28 #------------------------------------------------------------- |
28 # ------------------------------------------------------------- |
29 |
29 |
30 # ----------------------------- For Sync Manager Table ----------------------------------- |
30 # ----------------------------- For Sync Manager Table ----------------------------------- |
31 def GetSyncManagersTableColnames(): |
31 def GetSyncManagersTableColnames(): |
32 """ |
32 """ |
33 Returns column names of SyncManager Table in Slave state panel. |
33 Returns column names of SyncManager Table in Slave state panel. |
34 """ |
34 """ |
35 _ = lambda x : x |
35 _ = lambda x : x |
36 return ["#", _("Name"), _("Start Address"), _("Default Size"), _("Control Byte"), _("Enable")] |
36 return ["#", _("Name"), _("Start Address"), _("Default Size"), _("Control Byte"), _("Enable")] |
37 |
37 |
38 #------------------------------------------------------------------------------- |
38 # ------------------------------------------------------------------------------- |
39 # Sync Managers Table |
39 # Sync Managers Table |
40 #------------------------------------------------------------------------------- |
40 # ------------------------------------------------------------------------------- |
41 class SyncManagersTable(CustomTable): |
41 class SyncManagersTable(CustomTable): |
42 def GetValue(self, row, col): |
42 def GetValue(self, row, col): |
43 if row < self.GetNumberRows(): |
43 if row < self.GetNumberRows(): |
44 if col == 0: |
44 if col == 0: |
45 return row |
45 return row |
46 return self.data[row].get(self.GetColLabelValue(col, False), "") |
46 return self.data[row].get(self.GetColLabelValue(col, False), "") |
47 |
47 |
48 #------------------------------------------------------------------------------- |
48 # ------------------------------------------------------------------------------- |
49 # EtherCAT Management Treebook |
49 # EtherCAT Management Treebook |
50 #------------------------------------------------------------------------------- |
50 # ------------------------------------------------------------------------------- |
51 class EtherCATManagementTreebook(wx.Treebook): |
51 class EtherCATManagementTreebook(wx.Treebook): |
52 def __init__(self, parent, controler, node_editor): |
52 def __init__(self, parent, controler, node_editor): |
53 """ |
53 """ |
54 Constructor |
54 Constructor |
55 @param parent: Reference to the parent wx.ScrolledWindow object |
55 @param parent: Reference to the parent wx.ScrolledWindow object |
89 old = event.GetOldSelection() |
89 old = event.GetOldSelection() |
90 new = event.GetSelection() |
90 new = event.GetSelection() |
91 sel = event.GetSelection() |
91 sel = event.GetSelection() |
92 event.Skip() |
92 event.Skip() |
93 |
93 |
94 #------------------------------------------------------------------------------- |
94 # ------------------------------------------------------------------------------- |
95 # For SlaveState Panel |
95 # For SlaveState Panel |
96 #------------------------------------------------------------------------------- |
96 # ------------------------------------------------------------------------------- |
97 class SlaveStatePanelClass(wx.Panel): |
97 class SlaveStatePanelClass(wx.Panel): |
98 def __init__(self, parent, controler): |
98 def __init__(self, parent, controler): |
99 """ |
99 """ |
100 Constructor |
100 Constructor |
101 @param parent: Reference to the parent EtherCATManagementTreebook class |
101 @param parent: Reference to the parent EtherCATManagementTreebook class |
304 try: |
304 try: |
305 self.SlaveStateThread.Stop() |
305 self.SlaveStateThread.Stop() |
306 except Exception: |
306 except Exception: |
307 pass |
307 pass |
308 |
308 |
309 #------------------------------------------------------------------------------- |
309 # ------------------------------------------------------------------------------- |
310 # For SDO Management Panel |
310 # For SDO Management Panel |
311 #------------------------------------------------------------------------------- |
311 # ------------------------------------------------------------------------------- |
312 class SDOPanelClass(wx.Panel): |
312 class SDOPanelClass(wx.Panel): |
313 def __init__(self, parent, controler): |
313 def __init__(self, parent, controler): |
314 """ |
314 """ |
315 Constructor |
315 Constructor |
316 @param parent: Reference to the parent EtherCATManagementTreebook class |
316 @param parent: Reference to the parent EtherCATManagementTreebook class |
444 Test value 'name' is alphanumeric |
444 Test value 'name' is alphanumeric |
445 @param check_string : input data for check |
445 @param check_string : input data for check |
446 @return result : output data after check |
446 @return result : output data after check |
447 """ |
447 """ |
448 # string.printable is print this result |
448 # string.printable is print this result |
449 #'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |
449 # '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |
450 #!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c |
450 # !"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c |
451 allow_range = string.printable |
451 allow_range = string.printable |
452 result = check_string |
452 result = check_string |
453 for i in range(0, len(check_string)): |
453 for i in range(0, len(check_string)): |
454 # string.isalnum() is check whether string is alphanumeric or not |
454 # string.isalnum() is check whether string is alphanumeric or not |
455 if check_string[len(check_string)-1-i:len(check_string)-i] in allow_range : |
455 if check_string[len(check_string)-1-i:len(check_string)-i] in allow_range : |
456 result = check_string[:len(check_string) - i] |
456 result = check_string[:len(check_string) - i] |
457 break |
457 break |
458 return result |
458 return result |
459 |
459 |
460 |
460 |
461 #------------------------------------------------------------------------------- |
461 # ------------------------------------------------------------------------------- |
462 # For SDO Notebook (divide category) |
462 # For SDO Notebook (divide category) |
463 #------------------------------------------------------------------------------- |
463 # ------------------------------------------------------------------------------- |
464 class SDONoteBook(wx.Notebook): |
464 class SDONoteBook(wx.Notebook): |
465 def __init__(self, parent, controler): |
465 def __init__(self, parent, controler): |
466 """ |
466 """ |
467 Constructor |
467 Constructor |
468 @param parent: Reference to the parent SDOPanelClass class |
468 @param parent: Reference to the parent SDOPanelClass class |
516 old = event.GetOldSelection() |
516 old = event.GetOldSelection() |
517 new = event.GetSelection() |
517 new = event.GetSelection() |
518 sel = self.GetSelection() |
518 sel = self.GetSelection() |
519 event.Skip() |
519 event.Skip() |
520 |
520 |
521 #------------------------------------------------------------------------------- |
521 # ------------------------------------------------------------------------------- |
522 # For SDO Grid (fill index, subindex, etc...) |
522 # For SDO Grid (fill index, subindex, etc...) |
523 #------------------------------------------------------------------------------- |
523 # ------------------------------------------------------------------------------- |
524 class SlaveSDOTable(wx.grid.Grid): |
524 class SlaveSDOTable(wx.grid.Grid): |
525 def __init__(self, parent, data): |
525 def __init__(self, parent, data): |
526 """ |
526 """ |
527 Constructor |
527 Constructor |
528 @param parent: Reference to the parent SDOPanelClass class |
528 @param parent: Reference to the parent SDOPanelClass class |
662 # User input is not hex, dec value |
662 # User input is not hex, dec value |
663 except ValueError: |
663 except ValueError: |
664 self.Controler.CommonMethod.CreateErrorDialog('You can input only hex, dec value') |
664 self.Controler.CommonMethod.CreateErrorDialog('You can input only hex, dec value') |
665 |
665 |
666 |
666 |
667 #------------------------------------------------------------------------------- |
667 # ------------------------------------------------------------------------------- |
668 # For PDO Monitoring Panel |
668 # For PDO Monitoring Panel |
669 # PDO Class UI : Panel -> Choicebook (RxPDO, TxPDO) -> |
669 # PDO Class UI : Panel -> Choicebook (RxPDO, TxPDO) -> |
670 # Notebook (PDO Index) -> Grid (PDO entry) |
670 # Notebook (PDO Index) -> Grid (PDO entry) |
671 #------------------------------------------------------------------------------- |
671 # ------------------------------------------------------------------------------- |
672 class PDOPanelClass(wx.Panel): |
672 class PDOPanelClass(wx.Panel): |
673 def __init__(self, parent, controler): |
673 def __init__(self, parent, controler): |
674 """ |
674 """ |
675 Constructor |
675 Constructor |
676 @param parent: Reference to the parent EtherCATManagementTreebook class |
676 @param parent: Reference to the parent EtherCATManagementTreebook class |
697 self.CallPDOChoicebook.Destroy() |
697 self.CallPDOChoicebook.Destroy() |
698 self.CallPDOChoicebook = PDOChoicebook(self, controler=self.Controler) |
698 self.CallPDOChoicebook = PDOChoicebook(self, controler=self.Controler) |
699 self.Refresh() |
699 self.Refresh() |
700 |
700 |
701 |
701 |
702 #------------------------------------------------------------------------------- |
702 # ------------------------------------------------------------------------------- |
703 # For PDO Choicebook (divide Tx, Rx PDO) |
703 # For PDO Choicebook (divide Tx, Rx PDO) |
704 #------------------------------------------------------------------------------- |
704 # ------------------------------------------------------------------------------- |
705 class PDOChoicebook(wx.Choicebook): |
705 class PDOChoicebook(wx.Choicebook): |
706 def __init__(self, parent, controler): |
706 def __init__(self, parent, controler): |
707 """ |
707 """ |
708 Constructor |
708 Constructor |
709 @param parent: Reference to the parent PDOPanelClass class |
709 @param parent: Reference to the parent PDOPanelClass class |
731 new = event.GetSelection() |
731 new = event.GetSelection() |
732 sel = self.GetSelection() |
732 sel = self.GetSelection() |
733 event.Skip() |
733 event.Skip() |
734 |
734 |
735 |
735 |
736 #------------------------------------------------------------------------------- |
736 # ------------------------------------------------------------------------------- |
737 # For PDO Notebook (divide PDO index) |
737 # For PDO Notebook (divide PDO index) |
738 #------------------------------------------------------------------------------- |
738 # ------------------------------------------------------------------------------- |
739 class PDONoteBook(wx.Notebook): |
739 class PDONoteBook(wx.Notebook): |
740 def __init__(self, parent, name, controler): |
740 def __init__(self, parent, name, controler): |
741 """ |
741 """ |
742 Constructor |
742 Constructor |
743 @param parent: Reference to the parent PDOChoicebook class |
743 @param parent: Reference to the parent PDOChoicebook class |
788 new = event.GetSelection() |
788 new = event.GetSelection() |
789 sel = self.GetSelection() |
789 sel = self.GetSelection() |
790 event.Skip() |
790 event.Skip() |
791 |
791 |
792 |
792 |
793 #------------------------------------------------------------------------------- |
793 # ------------------------------------------------------------------------------- |
794 # For PDO Grid (fill entry index, subindex etc...) |
794 # For PDO Grid (fill entry index, subindex etc...) |
795 #------------------------------------------------------------------------------- |
795 # ------------------------------------------------------------------------------- |
796 class PDOEntryTable(wx.grid.Grid): |
796 class PDOEntryTable(wx.grid.Grid): |
797 def __init__(self, parent, info, entry, count): |
797 def __init__(self, parent, info, entry, count): |
798 """ |
798 """ |
799 Constructor |
799 Constructor |
800 @param parent: Reference to the parent PDONoteBook class |
800 @param parent: Reference to the parent PDONoteBook class |
860 self.SetReadOnly(row_idx, col_idx, True) |
860 self.SetReadOnly(row_idx, col_idx, True) |
861 self.SetRowSize(row_idx, 25) |
861 self.SetRowSize(row_idx, 25) |
862 start_value += 1 |
862 start_value += 1 |
863 |
863 |
864 |
864 |
865 #------------------------------------------------------------------------------- |
865 # ------------------------------------------------------------------------------- |
866 # For EEPROM Access Main Panel |
866 # For EEPROM Access Main Panel |
867 # (This class explain EEPROM Access) |
867 # (This class explain EEPROM Access) |
868 #------------------------------------------------------------------------------- |
868 # ------------------------------------------------------------------------------- |
869 class EEPROMAccessPanel(wx.Panel): |
869 class EEPROMAccessPanel(wx.Panel): |
870 def __init__(self, parent, controler): |
870 def __init__(self, parent, controler): |
871 """ |
871 """ |
872 Constructor |
872 Constructor |
873 @param parent: Reference to the parent EtherCATManagementTreebook class |
873 @param parent: Reference to the parent EtherCATManagementTreebook class |
883 sizer.Add(line) |
883 sizer.Add(line) |
884 |
884 |
885 self.SetSizer(sizer) |
885 self.SetSizer(sizer) |
886 |
886 |
887 |
887 |
888 #------------------------------------------------------------------------------- |
888 # ------------------------------------------------------------------------------- |
889 # For Smart View Panel |
889 # For Smart View Panel |
890 #------------------------------------------------------------------------------- |
890 # ------------------------------------------------------------------------------- |
891 class SlaveSiiSmartView(wx.Panel): |
891 class SlaveSiiSmartView(wx.Panel): |
892 def __init__(self, parent, controler): |
892 def __init__(self, parent, controler): |
893 """ |
893 """ |
894 Constructor |
894 Constructor |
895 @param parent: Reference to the parent EtherCATManagementTreebook class |
895 @param parent: Reference to the parent EtherCATManagementTreebook class |
1161 return str(int(str(''.join(data)), 16)) |
1161 return str(int(str(''.join(data)), 16)) |
1162 elif format == 2: |
1162 elif format == 2: |
1163 ''.join(data) |
1163 ''.join(data) |
1164 |
1164 |
1165 |
1165 |
1166 #------------------------------------------------------------------------------- |
1166 # ------------------------------------------------------------------------------- |
1167 # For Smart View TreeListCtrl |
1167 # For Smart View TreeListCtrl |
1168 #------------------------------------------------------------------------------- |
1168 # ------------------------------------------------------------------------------- |
1169 class SmartViewTreeListCtrl(wx.Panel): |
1169 class SmartViewTreeListCtrl(wx.Panel): |
1170 def __init__(self, parent, Controler): |
1170 def __init__(self, parent, Controler): |
1171 """ |
1171 """ |
1172 Constructor |
1172 Constructor |
1173 @param parent: Reference to the parent SlaveSiiSmartView class |
1173 @param parent: Reference to the parent SlaveSiiSmartView class |
1227 self.Mailbox["Bootstrap Configuration"], |
1227 self.Mailbox["Bootstrap Configuration"], |
1228 self.Mailbox["Standard Configuration"]]: |
1228 self.Mailbox["Standard Configuration"]]: |
1229 self.Tree.Expand(tree) |
1229 self.Tree.Expand(tree) |
1230 |
1230 |
1231 |
1231 |
1232 #------------------------------------------------------------------------------- |
1232 # ------------------------------------------------------------------------------- |
1233 # For Hex View Panel |
1233 # For Hex View Panel |
1234 # shows EEPROM binary as hex data and characters. |
1234 # shows EEPROM binary as hex data and characters. |
1235 #------------------------------------------------------------------------------- |
1235 # ------------------------------------------------------------------------------- |
1236 class HexView(wx.Panel): |
1236 class HexView(wx.Panel): |
1237 def __init__(self, parent, controler): |
1237 def __init__(self, parent, controler): |
1238 """ |
1238 """ |
1239 Constructor |
1239 Constructor |
1240 @param parent: Reference to the parent EtherCATManagementTreebook class |
1240 @param parent: Reference to the parent EtherCATManagementTreebook class |
1368 self.UpdateSiiGridTable(self.HexRow, self.HexCol) |
1368 self.UpdateSiiGridTable(self.HexRow, self.HexCol) |
1369 self.SiiGrid.SetValue(self.HexCode) |
1369 self.SiiGrid.SetValue(self.HexCode) |
1370 self.SiiGrid.Update() |
1370 self.SiiGrid.Update() |
1371 |
1371 |
1372 |
1372 |
1373 #------------------------------------------------------------------------------- |
1373 # ------------------------------------------------------------------------------- |
1374 # For Hex View grid (fill hex data) |
1374 # For Hex View grid (fill hex data) |
1375 #------------------------------------------------------------------------------- |
1375 # ------------------------------------------------------------------------------- |
1376 class SiiGridTable(wx.grid.Grid): |
1376 class SiiGridTable(wx.grid.Grid): |
1377 def __init__(self, parent, controler, row, col): |
1377 def __init__(self, parent, controler, row, col): |
1378 """ |
1378 """ |
1379 Constructor |
1379 Constructor |
1380 @param parent: Reference to the parent HexView class |
1380 @param parent: Reference to the parent HexView class |
1420 self.SetReadOnly(row, col, True) |
1420 self.SetReadOnly(row, col, True) |
1421 col = col + 1 |
1421 col = col + 1 |
1422 row = row + 1 |
1422 row = row + 1 |
1423 |
1423 |
1424 |
1424 |
1425 #------------------------------------------------------------------------------- |
1425 # ------------------------------------------------------------------------------- |
1426 # For Register Access Panel |
1426 # For Register Access Panel |
1427 #------------------------------------------------------------------------------- |
1427 # ------------------------------------------------------------------------------- |
1428 class RegisterAccessPanel(wx.Panel): |
1428 class RegisterAccessPanel(wx.Panel): |
1429 def __init__(self, parent, controler): |
1429 def __init__(self, parent, controler): |
1430 """ |
1430 """ |
1431 Constructor |
1431 Constructor |
1432 @param parent: EEPROMAccessPanel object |
1432 @param parent: EEPROMAccessPanel object |
1492 def LoadData(self): |
1492 def LoadData(self): |
1493 """ |
1493 """ |
1494 Get data from the register. |
1494 Get data from the register. |
1495 """ |
1495 """ |
1496 self.Controler.CommonMethod.RegData = "" |
1496 self.Controler.CommonMethod.RegData = "" |
1497 #ethercat reg_read |
1497 # ethercat reg_read |
1498 #ex : ethercat reg_read -p 0 0x0000 0x0001 |
1498 # ex : ethercat reg_read -p 0 0x0000 0x0001 |
1499 #return value : 0x11 |
1499 # return value : 0x11 |
1500 for index in range(4): |
1500 for index in range(4): |
1501 self.Controler.CommonMethod.RegData = self.Controler.CommonMethod.RegData + " " + self.Controler.CommonMethod.RegRead("0x"+"{:0>4x}".format(index*1024), "0x0400") |
1501 self.Controler.CommonMethod.RegData = self.Controler.CommonMethod.RegData + " " + self.Controler.CommonMethod.RegRead("0x"+"{:0>4x}".format(index*1024), "0x0400") |
1502 |
1502 |
1503 # store previous value |
1503 # store previous value |
1504 # (ESC type, port number of FMMU, port number of SM, and PDI type)) |
1504 # (ESC type, port number of FMMU, port number of SM, and PDI type)) |
1781 self.RegisterNotebook.RegPage[index].UpdateMainTable(self.MainRow[index], self.MainCol, |
1781 self.RegisterNotebook.RegPage[index].UpdateMainTable(self.MainRow[index], self.MainCol, |
1782 self.PageRange[index][0], self.PageRange[index][1], |
1782 self.PageRange[index][0], self.PageRange[index][1], |
1783 self.RegMonitorData) |
1783 self.RegMonitorData) |
1784 |
1784 |
1785 |
1785 |
1786 #------------------------------------------------------------------------------- |
1786 # ------------------------------------------------------------------------------- |
1787 # For Register Access Notebook (divide index range) |
1787 # For Register Access Notebook (divide index range) |
1788 #------------------------------------------------------------------------------- |
1788 # ------------------------------------------------------------------------------- |
1789 class RegisterNotebook(wx.Notebook): |
1789 class RegisterNotebook(wx.Notebook): |
1790 def __init__(self, parent, controler): |
1790 def __init__(self, parent, controler): |
1791 """ |
1791 """ |
1792 Constructor |
1792 Constructor |
1793 @param parent: RegisterAccessPanel object |
1793 @param parent: RegisterAccessPanel object |
1823 new = event.GetSelection() |
1823 new = event.GetSelection() |
1824 sel = self.GetSelection() |
1824 sel = self.GetSelection() |
1825 event.Skip() |
1825 event.Skip() |
1826 |
1826 |
1827 |
1827 |
1828 #------------------------------------------------------------------------------- |
1828 # ------------------------------------------------------------------------------- |
1829 # For Register Access Notebook Panel |
1829 # For Register Access Notebook Panel |
1830 # (Main UI : including main, sub table) |
1830 # (Main UI : including main, sub table) |
1831 #------------------------------------------------------------------------------- |
1831 # ------------------------------------------------------------------------------- |
1832 class RegisterNotebookPanel(wx.Panel): |
1832 class RegisterNotebookPanel(wx.Panel): |
1833 def __init__(self, parent, controler, row, col): |
1833 def __init__(self, parent, controler, row, col): |
1834 """ |
1834 """ |
1835 Constructor |
1835 Constructor |
1836 @param parent: RegisterAccessPanel object |
1836 @param parent: RegisterAccessPanel object |
1892 self.SubTable.CreateGrid(row, col) |
1892 self.SubTable.CreateGrid(row, col) |
1893 self.SubTable.SetValue(self, data) |
1893 self.SubTable.SetValue(self, data) |
1894 self.SubTable.Update() |
1894 self.SubTable.Update() |
1895 |
1895 |
1896 |
1896 |
1897 #------------------------------------------------------------------------------- |
1897 # ------------------------------------------------------------------------------- |
1898 # For Register Access Notebook Panel (Main Table) |
1898 # For Register Access Notebook Panel (Main Table) |
1899 #------------------------------------------------------------------------------- |
1899 # ------------------------------------------------------------------------------- |
1900 class RegisterMainTable(wx.grid.Grid): |
1900 class RegisterMainTable(wx.grid.Grid): |
1901 def __init__(self, parent, row, col, controler): |
1901 def __init__(self, parent, row, col, controler): |
1902 """ |
1902 """ |
1903 Constructor |
1903 Constructor |
1904 @param parent: RegisterNotebook object |
1904 @param parent: RegisterNotebook object |
2043 |
2043 |
2044 except ValueError: |
2044 except ValueError: |
2045 self.Controler.CommonMethod.CreateErrorDialog('You entered wrong value. You can enter dec or hex value only.') |
2045 self.Controler.CommonMethod.CreateErrorDialog('You entered wrong value. You can enter dec or hex value only.') |
2046 |
2046 |
2047 |
2047 |
2048 #------------------------------------------------------------------------------- |
2048 # ------------------------------------------------------------------------------- |
2049 # For Register Access Notebook Panel (Sub Table) |
2049 # For Register Access Notebook Panel (Sub Table) |
2050 #------------------------------------------------------------------------------- |
2050 # ------------------------------------------------------------------------------- |
2051 class RegisterSubTable(wx.grid.Grid): |
2051 class RegisterSubTable(wx.grid.Grid): |
2052 def __init__(self, parent, row, col): |
2052 def __init__(self, parent, row, col): |
2053 """ |
2053 """ |
2054 Constructor |
2054 Constructor |
2055 @param parent: RegisterNotebook object |
2055 @param parent: RegisterNotebook object |
2089 self.SetReadOnly(row, col, True) |
2089 self.SetReadOnly(row, col, True) |
2090 col = col + 1 |
2090 col = col + 1 |
2091 row = row + 1 |
2091 row = row + 1 |
2092 |
2092 |
2093 |
2093 |
2094 #------------------------------------------------------------------------------- |
2094 # ------------------------------------------------------------------------------- |
2095 # For Master State Panel |
2095 # For Master State Panel |
2096 #------------------------------------------------------------------------------- |
2096 # ------------------------------------------------------------------------------- |
2097 class MasterStatePanelClass(wx.Panel): |
2097 class MasterStatePanelClass(wx.Panel): |
2098 def __init__(self, parent, controler): |
2098 def __init__(self, parent, controler): |
2099 """ |
2099 """ |
2100 Constructor |
2100 Constructor |
2101 @param parent: wx.ScrollWindow object |
2101 @param parent: wx.ScrollWindow object |