77 ] |
77 ] |
78 for pname, pclass, subs in panels: |
78 for pname, pclass, subs in panels: |
79 self.AddPage(pclass(self, self.Controler), pname) |
79 self.AddPage(pclass(self, self.Controler), pname) |
80 for spname, spclass in subs: |
80 for spname, spclass in subs: |
81 self.AddSubPage(spclass(self, self.Controler), spname) |
81 self.AddSubPage(spclass(self, self.Controler), spname) |
82 |
|
83 self.Bind(wx.EVT_TREEBOOK_PAGE_CHANGED, self.OnPageChanged) |
|
84 self.Bind(wx.EVT_TREEBOOK_PAGE_CHANGING, self.OnPageChanging) |
|
85 |
|
86 def OnPageChanged(self, event): |
|
87 old = event.GetOldSelection() |
|
88 new = event.GetSelection() |
|
89 sel = event.GetSelection() |
|
90 event.Skip() |
|
91 |
|
92 def OnPageChanging(self, event): |
|
93 old = event.GetOldSelection() |
|
94 new = event.GetSelection() |
|
95 sel = event.GetSelection() |
|
96 event.Skip() |
|
97 |
82 |
98 |
83 |
99 # ------------------------------------------------------------------------------- |
84 # ------------------------------------------------------------------------------- |
100 # For SlaveState Panel |
85 # For SlaveState Panel |
101 # ------------------------------------------------------------------------------- |
86 # ------------------------------------------------------------------------------- |
254 |
239 |
255 # If target state is OP, first check "PLC status". |
240 # If target state is OP, first check "PLC status". |
256 # (1) If current PLC status is "Started", then request slave state transition |
241 # (1) If current PLC status is "Started", then request slave state transition |
257 # (2) Otherwise, show error message and return |
242 # (2) Otherwise, show error message and return |
258 else: |
243 else: |
259 status, count = self.Controler.GetCTRoot()._connector.GetPLCstatus() |
244 status, _log_count = self.Controler.GetCTRoot()._connector.GetPLCstatus() |
260 if status == "Started": |
245 if status == "Started": |
261 self.Controler.CommonMethod.RequestSlaveState("OP") |
246 self.Controler.CommonMethod.RequestSlaveState("OP") |
262 self.TextCtrlDic["TargetState"].SetValue("OP") |
247 self.TextCtrlDic["TargetState"].SetValue("OP") |
263 else: |
248 else: |
264 self.Controler.CommonMethod.CreateErrorDialog("PLC is Not Started") |
249 self.Controler.CommonMethod.CreateErrorDialog("PLC is Not Started") |
397 # line_token = ['0x1000:00,r-r-r-,uint32,32 bit,', 'Device type', ',0x00020192, 131474'] |
382 # line_token = ['0x1000:00,r-r-r-,uint32,32 bit,', 'Device type', ',0x00020192, 131474'] |
398 token_head, name, token_tail = line_token |
383 token_head, name, token_tail = line_token |
399 |
384 |
400 # token_head = ['0x1000:00', 'r-r-r-', 'uint32', '32 bit', ''] |
385 # token_head = ['0x1000:00', 'r-r-r-', 'uint32', '32 bit', ''] |
401 token_head = token_head.split(",") |
386 token_head = token_head.split(",") |
402 ful_idx, access, type, size, empty = token_head |
387 ful_idx, access, type, size, _empty = token_head |
403 # ful_idx.split(":") = ['0x1000', '00'] |
388 # ful_idx.split(":") = ['0x1000', '00'] |
404 idx, sub_idx = ful_idx.split(":") |
389 idx, sub_idx = ful_idx.split(":") |
405 |
390 |
406 # token_tail = ['', '0x00020192', '131474'] |
391 # token_tail = ['', '0x00020192', '131474'] |
407 token_tail = token_tail.split(",") |
392 token_tail = token_tail.split(",") |
408 try: |
393 try: |
409 empty, hex_val, dec_val = token_tail |
394 _empty, hex_val, _dec_val = token_tail |
410 |
395 |
411 # SDO data is not return "dec value" |
396 # SDO data is not return "dec value" |
412 # line example : |
397 # line example : |
413 # 0x1702:01,rwr-r-,uint32,32 bit," 1st mapping", ---- |
398 # 0x1702:01,rwr-r-,uint32,32 bit," 1st mapping", ---- |
414 except Exception: |
399 except Exception: |
415 empty, hex_val = token_tail |
400 _empty, hex_val = token_tail |
416 |
401 |
417 name_after_check = self.StringTest(name) |
402 name_after_check = self.StringTest(name) |
418 |
403 |
419 # convert hex type |
404 # convert hex type |
420 sub_idx = "0x" + sub_idx |
405 sub_idx = "0x" + sub_idx |
435 break |
420 break |
436 |
421 |
437 self.Controler.CommonMethod.SaveSDOData[self.AllSDOData].append(self.Data) |
422 self.Controler.CommonMethod.SaveSDOData[self.AllSDOData].append(self.Data) |
438 |
423 |
439 if count >= len(self.SDOs.splitlines()) / 2: |
424 if count >= len(self.SDOs.splitlines()) / 2: |
440 (keep_going, skip) = slaveSDO_progress.Update(count, "Please waiting a moment!!") |
425 (keep_going, _skip) = slaveSDO_progress.Update(count, "Please waiting a moment!!") |
441 else: |
426 else: |
442 (keep_going, skip) = slaveSDO_progress.Update(count) |
427 (keep_going, _skip) = slaveSDO_progress.Update(count) |
443 |
428 |
444 # If user click "Cancel" loop suspend immediately |
429 # If user click "Cancel" loop suspend immediately |
445 if not keep_going: |
430 if not keep_going: |
446 break |
431 break |
447 |
432 |
481 self.Controler = controler |
466 self.Controler = controler |
482 self.parent = parent |
467 self.parent = parent |
483 |
468 |
484 self.CreateNoteBook() |
469 self.CreateNoteBook() |
485 |
470 |
486 self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGED, self.OnPageChanged) |
|
487 self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGING, self.OnPageChanging) |
|
488 |
|
489 def CreateNoteBook(self): |
471 def CreateNoteBook(self): |
490 """ |
472 """ |
491 Create each NoteBook page, divided SDO index |
473 Create each NoteBook page, divided SDO index |
492 According to EtherCAT Communication(03/2011), 158p |
474 According to EtherCAT Communication(03/2011), 158p |
493 """ |
475 """ |
499 ("0x1000 - 0x1fff", self.parent.CommunicationObject), |
481 ("0x1000 - 0x1fff", self.parent.CommunicationObject), |
500 ("0x2000 - 0x5fff", self.parent.ManufacturerSpecific), |
482 ("0x2000 - 0x5fff", self.parent.ManufacturerSpecific), |
501 ("0x6000 - 0x9fff", self.parent.ProfileSpecific), |
483 ("0x6000 - 0x9fff", self.parent.ProfileSpecific), |
502 ("0xa000 - 0xffff", self.parent.Reserved)] |
484 ("0xa000 - 0xffff", self.parent.Reserved)] |
503 |
485 |
504 page_tooltip_string = ["SDO Index 0x0000 - 0x0fff : Data Type Description", |
486 # page_tooltip_string = ["SDO Index 0x0000 - 0x0fff : Data Type Description", |
505 "SDO Index 0x1000 - 0x1fff : Communication object", |
487 # "SDO Index 0x1000 - 0x1fff : Communication object", |
506 "SDO Index 0x2000 - 0x5fff : Manufacturer specific", |
488 # "SDO Index 0x2000 - 0x5fff : Manufacturer specific", |
507 "SDO Index 0x6000 - 0x9fff : Profile specific", |
489 # "SDO Index 0x6000 - 0x9fff : Profile specific", |
508 "SDO Index 0xa000 - 0xffff : Reserved", |
490 # "SDO Index 0xa000 - 0xffff : Reserved", |
509 "All SDO Object"] |
491 # "All SDO Object"] |
510 |
492 |
511 self.DeleteAllPages() |
493 self.DeleteAllPages() |
512 |
494 |
513 for txt, count in page_texts: |
495 for txt, count in page_texts: |
514 self.Data = self.Controler.CommonMethod.SaveSDOData[count] |
496 self.Data = self.Controler.CommonMethod.SaveSDOData[count] |
515 self.Win = SlaveSDOTable(self, self.Data) |
497 self.Win = SlaveSDOTable(self, self.Data) |
516 self.AddPage(self.Win, txt) |
498 self.AddPage(self.Win, txt) |
517 |
|
518 def OnPageChanged(self, event): |
|
519 old = event.GetOldSelection() |
|
520 new = event.GetSelection() |
|
521 sel = self.GetSelection() |
|
522 event.Skip() |
|
523 |
|
524 def OnPageChanging(self, event): |
|
525 old = event.GetOldSelection() |
|
526 new = event.GetSelection() |
|
527 sel = self.GetSelection() |
|
528 event.Skip() |
|
529 |
499 |
530 |
500 |
531 # ------------------------------------------------------------------------------- |
501 # ------------------------------------------------------------------------------- |
532 # For SDO Grid (fill index, subindex, etc...) |
502 # For SDO Grid (fill index, subindex, etc...) |
533 # ------------------------------------------------------------------------------- |
503 # ------------------------------------------------------------------------------- |
731 |
701 |
732 RxWin = PDONoteBook(self, controler=self.Controler, name="Rx") |
702 RxWin = PDONoteBook(self, controler=self.Controler, name="Rx") |
733 TxWin = PDONoteBook(self, controler=self.Controler, name="Tx") |
703 TxWin = PDONoteBook(self, controler=self.Controler, name="Tx") |
734 self.AddPage(RxWin, "RxPDO") |
704 self.AddPage(RxWin, "RxPDO") |
735 self.AddPage(TxWin, "TxPDO") |
705 self.AddPage(TxWin, "TxPDO") |
736 |
|
737 self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGED, self.OnPageChanged) |
|
738 self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGING, self.OnPageChanging) |
|
739 |
|
740 def OnPageChanged(self, event): |
|
741 old = event.GetOldSelection() |
|
742 new = event.GetSelection() |
|
743 sel = self.GetSelection() |
|
744 event.Skip() |
|
745 |
|
746 def OnPageChanging(self, event): |
|
747 old = event.GetOldSelection() |
|
748 new = event.GetSelection() |
|
749 sel = self.GetSelection() |
|
750 event.Skip() |
|
751 |
706 |
752 |
707 |
753 # ------------------------------------------------------------------------------- |
708 # ------------------------------------------------------------------------------- |
754 # For PDO Notebook (divide PDO index) |
709 # For PDO Notebook (divide PDO index) |
755 # ------------------------------------------------------------------------------- |
710 # ------------------------------------------------------------------------------- |
788 # Add page depending on the number of pdo_info |
743 # Add page depending on the number of pdo_info |
789 for txt in page_texts: |
744 for txt in page_texts: |
790 win = PDOEntryTable(self, pdo_info, pdo_entry, count) |
745 win = PDOEntryTable(self, pdo_info, pdo_entry, count) |
791 self.AddPage(win, txt) |
746 self.AddPage(win, txt) |
792 count += 1 |
747 count += 1 |
793 |
|
794 self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGED, self.OnPageChanged) |
|
795 self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGING, self.OnPageChanging) |
|
796 |
|
797 def OnPageChanged(self, event): |
|
798 old = event.GetOldSelection() |
|
799 new = event.GetSelection() |
|
800 sel = self.GetSelection() |
|
801 event.Skip() |
|
802 |
|
803 def OnPageChanging(self, event): |
|
804 old = event.GetOldSelection() |
|
805 new = event.GetSelection() |
|
806 sel = self.GetSelection() |
|
807 event.Skip() |
|
808 |
748 |
809 |
749 |
810 # ------------------------------------------------------------------------------- |
750 # ------------------------------------------------------------------------------- |
811 # For PDO Grid (fill entry index, subindex etc...) |
751 # For PDO Grid (fill entry index, subindex etc...) |
812 # ------------------------------------------------------------------------------- |
752 # ------------------------------------------------------------------------------- |
963 @param event : wx.EVT_BUTTON object |
903 @param event : wx.EVT_BUTTON object |
964 """ |
904 """ |
965 # Check whether beremiz connected or not, and whether status is "Started" or not. |
905 # Check whether beremiz connected or not, and whether status is "Started" or not. |
966 check_connect_flag = self.Controler.CommonMethod.CheckConnect(False) |
906 check_connect_flag = self.Controler.CommonMethod.CheckConnect(False) |
967 if check_connect_flag: |
907 if check_connect_flag: |
968 status, count = self.Controler.GetCTRoot()._connector.GetPLCstatus() |
908 status, _log_count = self.Controler.GetCTRoot()._connector.GetPLCstatus() |
969 if status is not "Started": |
909 if status is not "Started": |
970 dialog = wx.FileDialog(self, _("Choose a binary file"), os.getcwd(), "", _("bin files (*.bin)|*.bin"), wx.OPEN) |
910 dialog = wx.FileDialog(self, _("Choose a binary file"), os.getcwd(), "", _("bin files (*.bin)|*.bin"), wx.OPEN) |
971 |
911 |
972 if dialog.ShowModal() == wx.ID_OK: |
912 if dialog.ShowModal() == wx.ID_OK: |
973 filepath = dialog.GetPath() |
913 filepath = dialog.GetPath() |
1332 """ |
1272 """ |
1333 # Check whether beremiz connected or not, |
1273 # Check whether beremiz connected or not, |
1334 # and whether status is "Started" or not. |
1274 # and whether status is "Started" or not. |
1335 check_connect_flag = self.Controler.CommonMethod.CheckConnect(False) |
1275 check_connect_flag = self.Controler.CommonMethod.CheckConnect(False) |
1336 if check_connect_flag: |
1276 if check_connect_flag: |
1337 status, count = self.Controler.GetCTRoot()._connector.GetPLCstatus() |
1277 status, _log_count = self.Controler.GetCTRoot()._connector.GetPLCstatus() |
1338 if status is not "Started": |
1278 if status is not "Started": |
1339 self.Controler.CommonMethod.SiiWrite(self.SiiBinary) |
1279 self.Controler.CommonMethod.SiiWrite(self.SiiBinary) |
1340 self.Controler.CommonMethod.Rescan() |
1280 self.Controler.CommonMethod.Rescan() |
1341 |
1281 |
1342 def OnButtonWriteToBinFile(self, event): |
1282 def OnButtonWriteToBinFile(self, event): |
1828 self.parent = parent |
1768 self.parent = parent |
1829 self.Controler = controler |
1769 self.Controler = controler |
1830 |
1770 |
1831 # Initialize pages |
1771 # Initialize pages |
1832 self.RegPage = [] |
1772 self.RegPage = [] |
1833 for iter in range(4): |
1773 pages = 4 |
|
1774 for dummy in range(pages): |
1834 self.RegPage.append(None) |
1775 self.RegPage.append(None) |
1835 |
1776 |
1836 for index in range(4): |
1777 for index in range(pages): |
1837 self.RegPage[index] = RegisterNotebookPanel(self, self.Controler, |
1778 self.RegPage[index] = RegisterNotebookPanel(self, self.Controler, |
1838 parent.MainRow[index], parent.MainCol) |
1779 parent.MainRow[index], parent.MainCol) |
1839 self.AddPage(self.RegPage[index], |
1780 self.AddPage(self.RegPage[index], |
1840 "0x"+"{:0>4x}".format(index*1024)+" - 0x"+"{:0>4x}".format((index+1)*1024-1)) |
1781 "0x"+"{:0>4x}".format(index*1024)+" - 0x"+"{:0>4x}".format((index+1)*1024-1)) |
1841 |
|
1842 self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged) |
|
1843 self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnPageChanging) |
|
1844 |
|
1845 def OnPageChanged(self, event): |
|
1846 old = event.GetOldSelection() |
|
1847 new = event.GetSelection() |
|
1848 sel = self.GetSelection() |
|
1849 event.Skip() |
|
1850 |
|
1851 def OnPageChanging(self, event): |
|
1852 old = event.GetOldSelection() |
|
1853 new = event.GetSelection() |
|
1854 sel = self.GetSelection() |
|
1855 event.Skip() |
|
1856 |
1782 |
1857 |
1783 |
1858 # ------------------------------------------------------------------------------- |
1784 # ------------------------------------------------------------------------------- |
1859 # For Register Access Notebook Panel |
1785 # For Register Access Notebook Panel |
1860 # (Main UI : including main, sub table) |
1786 # (Main UI : including main, sub table) |