47 {"minIndex" : 0x1A00, "maxIndex" : 0x1BFF, "name" : "Transmit PDO Mapping"}, |
47 {"minIndex" : 0x1A00, "maxIndex" : 0x1BFF, "name" : "Transmit PDO Mapping"}, |
48 {"minIndex" : 0x1C00, "maxIndex" : 0x1FFF, "name" : "Other Communication Parameters"}, |
48 {"minIndex" : 0x1C00, "maxIndex" : 0x1FFF, "name" : "Other Communication Parameters"}, |
49 {"minIndex" : 0x2000, "maxIndex" : 0x5FFF, "name" : "Manufacturer Specific"}, |
49 {"minIndex" : 0x2000, "maxIndex" : 0x5FFF, "name" : "Manufacturer Specific"}, |
50 {"minIndex" : 0x6000, "maxIndex" : 0x9FFF, "name" : "Standardized Device Profile"}, |
50 {"minIndex" : 0x6000, "maxIndex" : 0x9FFF, "name" : "Standardized Device Profile"}, |
51 {"minIndex" : 0xA000, "maxIndex" : 0xBFFF, "name" : "Standardized Interface Profile"}] |
51 {"minIndex" : 0xA000, "maxIndex" : 0xBFFF, "name" : "Standardized Interface Profile"}] |
|
52 |
|
53 SizeConversion = {1 : "X", 8 : "B", 16 : "W", 24 : "D", 32 : "D", 40 : "L", 48 : "L", 56 : "L", 64 : "L"} |
52 |
54 |
53 class SubindexTable(wxPyGridTableBase): |
55 class SubindexTable(wxPyGridTableBase): |
54 |
56 |
55 """ |
57 """ |
56 A custom wxGrid Table using user supplied data |
58 A custom wxGrid Table using user supplied data |
247 |
249 |
248 [wxID_EDITINGPANELINDEXLISTMENUITEMS0, wxID_EDITINGPANELINDEXLISTMENUITEMS1, |
250 [wxID_EDITINGPANELINDEXLISTMENUITEMS0, wxID_EDITINGPANELINDEXLISTMENUITEMS1, |
249 wxID_EDITINGPANELINDEXLISTMENUITEMS2, |
251 wxID_EDITINGPANELINDEXLISTMENUITEMS2, |
250 ] = [wx.NewId() for _init_coll_IndexListMenu_Items in range(3)] |
252 ] = [wx.NewId() for _init_coll_IndexListMenu_Items in range(3)] |
251 |
253 |
252 [wxID_EDITINGPANELMENU1ITEMS0, wxID_EDITINGPANELMENU1ITEMS1, wxID_EDITINGPANELMENU1ITEMS2, |
254 [wxID_EDITINGPANELMENU1ITEMS0, wxID_EDITINGPANELMENU1ITEMS1, |
253 ] = [wx.NewId() for _init_coll_SubindexGridMenu_Items in range(3)] |
255 ] = [wx.NewId() for _init_coll_SubindexGridMenu_Items in range(2)] |
254 |
256 |
255 class EditingPanel(wx.SplitterWindow): |
257 class EditingPanel(wx.SplitterWindow): |
256 def _init_coll_AddToListSizer_Items(self, parent): |
258 def _init_coll_AddToListSizer_Items(self, parent): |
257 # generated method, don't edit |
259 # generated method, don't edit |
258 |
260 |
293 |
295 |
294 parent.Append(help='', id=wxID_EDITINGPANELMENU1ITEMS0, |
296 parent.Append(help='', id=wxID_EDITINGPANELMENU1ITEMS0, |
295 kind=wx.ITEM_NORMAL, text='Add') |
297 kind=wx.ITEM_NORMAL, text='Add') |
296 parent.Append(help='', id=wxID_EDITINGPANELMENU1ITEMS1, |
298 parent.Append(help='', id=wxID_EDITINGPANELMENU1ITEMS1, |
297 kind=wx.ITEM_NORMAL, text='Delete') |
299 kind=wx.ITEM_NORMAL, text='Delete') |
298 parent.Append(help='', id=wxID_EDITINGPANELMENU1ITEMS2, |
|
299 kind=wx.ITEM_NORMAL, text='Default Value') |
|
300 self.Bind(wx.EVT_MENU, self.OnAddSubindexMenu, |
300 self.Bind(wx.EVT_MENU, self.OnAddSubindexMenu, |
301 id=wxID_EDITINGPANELMENU1ITEMS0) |
301 id=wxID_EDITINGPANELMENU1ITEMS0) |
302 self.Bind(wx.EVT_MENU, self.OnDeleteSubindexMenu, |
302 self.Bind(wx.EVT_MENU, self.OnDeleteSubindexMenu, |
303 id=wxID_EDITINGPANELMENU1ITEMS1) |
303 id=wxID_EDITINGPANELMENU1ITEMS1) |
304 self.Bind(wx.EVT_MENU, self.OnDefaultValueSubindexMenu, |
|
305 id=wxID_EDITINGPANELMENU1ITEMS2) |
|
306 |
304 |
307 def _init_coll_IndexListMenu_Items(self, parent): |
305 def _init_coll_IndexListMenu_Items(self, parent): |
308 # generated method, don't edit |
306 # generated method, don't edit |
309 |
307 |
310 parent.Append(help='', id=wxID_EDITINGPANELINDEXLISTMENUITEMS0, |
308 parent.Append(help='', id=wxID_EDITINGPANELINDEXLISTMENUITEMS0, |
389 self.OnSubindexGridCellChange) |
387 self.OnSubindexGridCellChange) |
390 self.SubindexGrid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, |
388 self.SubindexGrid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, |
391 self.OnSubindexGridRightClick) |
389 self.OnSubindexGridRightClick) |
392 self.SubindexGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL, |
390 self.SubindexGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL, |
393 self.OnSubindexGridSelectCell) |
391 self.OnSubindexGridSelectCell) |
|
392 self.SubindexGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnSubindexGridCellLeftClick) |
394 |
393 |
395 self.CallbackCheck = wx.CheckBox(id=wxID_EDITINGPANELCALLBACKCHECK, |
394 self.CallbackCheck = wx.CheckBox(id=wxID_EDITINGPANELCALLBACKCHECK, |
396 label='Have Callbacks', name='CallbackCheck', |
395 label='Have Callbacks', name='CallbackCheck', |
397 parent=self.SubindexGridPanel, pos=wx.Point(0, 0), size=wx.Size(152, |
396 parent=self.SubindexGridPanel, pos=wx.Point(0, 0), size=wx.Size(152, |
398 24), style=0) |
397 24), style=0) |
454 if selected != wxNOT_FOUND: |
453 if selected != wxNOT_FOUND: |
455 index = self.ListIndex[selected] |
454 index = self.ListIndex[selected] |
456 subIndex = self.SubindexGrid.GetGridCursorRow() |
455 subIndex = self.SubindexGrid.GetGridCursorRow() |
457 return index, subIndex |
456 return index, subIndex |
458 return None |
457 return None |
|
458 |
|
459 def OnSubindexGridCellLeftClick(self, event): |
|
460 wxCallAfter(self.BeginDrag) |
|
461 event.Skip() |
459 |
462 |
460 def OnAddButtonClick(self, event): |
463 def OnAddButtonClick(self, event): |
461 if self.Editable: |
464 if self.Editable: |
462 self.SubindexGrid.SetGridCursor(0, 0) |
465 self.SubindexGrid.SetGridCursor(0, 0) |
463 selected = self.IndexChoice.GetStringSelection() |
466 selected = self.IndexChoice.GetStringSelection() |
492 self.SubindexGrid.SetGridCursor(0, 0) |
495 self.SubindexGrid.SetGridCursor(0, 0) |
493 self.RefreshTable() |
496 self.RefreshTable() |
494 event.Skip() |
497 event.Skip() |
495 |
498 |
496 def OnSubindexGridSelectCell(self, event): |
499 def OnSubindexGridSelectCell(self, event): |
|
500 wxCallAfter(self.BeginDrag) |
497 wxCallAfter(self.Parent.RefreshStatusBar) |
501 wxCallAfter(self.Parent.RefreshStatusBar) |
498 event.Skip() |
502 event.Skip() |
|
503 |
|
504 def BeginDrag(self): |
|
505 row = self.SubindexGrid.GetGridCursorRow() |
|
506 col = self.SubindexGrid.GetGridCursorCol() |
|
507 if not self.Editable and col == 0: |
|
508 selected = self.IndexList.GetSelection() |
|
509 if selected != wxNOT_FOUND: |
|
510 index = self.ListIndex[selected] |
|
511 subindex = self.SubindexGrid.GetGridCursorRow() |
|
512 entry_infos = self.Manager.GetEntryInfos(index) |
|
513 if not entry_infos["struct"] & OD_MultipleSubindexes or row != 0: |
|
514 subentry_infos = self.Manager.GetSubentryInfos(index, subindex) |
|
515 typeinfos = self.Manager.GetEntryInfos(subentry_infos["type"]) |
|
516 if subentry_infos["pdo"] and typeinfos: |
|
517 bus_id = self.Parent.GetBusId() |
|
518 node_id = self.Parent.GetCurrentNodeId() |
|
519 size = typeinfos["size"] |
|
520 data = wxTextDataObject(str(("%s%d.%d.%d.%d"%(SizeConversion[size], bus_id, node_id, index, subindex), "location"))) |
|
521 dragSource = wxDropSource(self.SubindexGrid) |
|
522 dragSource.SetData(data) |
|
523 dragSource.DoDragDrop() |
499 |
524 |
500 #------------------------------------------------------------------------------- |
525 #------------------------------------------------------------------------------- |
501 # Refresh Functions |
526 # Refresh Functions |
502 #------------------------------------------------------------------------------- |
527 #------------------------------------------------------------------------------- |
503 |
528 |
634 selected = self.IndexList.GetSelection() |
659 selected = self.IndexList.GetSelection() |
635 if selected != wxNOT_FOUND: |
660 if selected != wxNOT_FOUND: |
636 index = self.ListIndex[selected] |
661 index = self.ListIndex[selected] |
637 if self.Manager.IsCurrentEntry(index): |
662 if self.Manager.IsCurrentEntry(index): |
638 infos = self.Manager.GetEntryInfos(index) |
663 infos = self.Manager.GetEntryInfos(index) |
639 if 0x5fff >= index >= 0x2000 and infos["struct"] & OD_MultipleSubindexes or infos["struct"] & OD_IdenticalSubindexes: |
664 if index >= 0x2000 and infos["struct"] & OD_MultipleSubindexes or infos["struct"] & OD_IdenticalSubindexes: |
640 # enable add and delet entries |
665 self.PopupMenu(self.SubindexGridMenu) |
641 self.SubindexGridMenu.FindItemById(wxID_EDITINGPANELMENU1ITEMS0).Enable(True) |
|
642 self.SubindexGridMenu.FindItemById(wxID_EDITINGPANELMENU1ITEMS1).Enable(True) |
|
643 else: |
|
644 # disable add and delet entries |
|
645 self.SubindexGridMenu.FindItemById(wxID_EDITINGPANELMENU1ITEMS0).Enable(False) |
|
646 self.SubindexGridMenu.FindItemById(wxID_EDITINGPANELMENU1ITEMS1).Enable(False) |
|
647 self.SubindexGrid.SetGridCursor(event.GetRow(), event.GetCol()) |
|
648 wxCallAfter(self.PopupMenu,self.SubindexGridMenu) |
|
649 event.Skip() |
666 event.Skip() |
650 |
667 |
651 def OnRenameIndexMenu(self, event): |
668 def OnRenameIndexMenu(self, event): |
652 if self.Editable: |
669 if self.Editable: |
653 selected = self.IndexList.GetSelection() |
670 selected = self.IndexList.GetSelection() |