26 |
26 |
27 from subindextable import EditingPanel |
27 from subindextable import EditingPanel |
28 from nodeeditortemplate import NodeEditorTemplate |
28 from nodeeditortemplate import NodeEditorTemplate |
29 from editors.ConfTreeNodeEditor import ConfTreeNodeEditor |
29 from editors.ConfTreeNodeEditor import ConfTreeNodeEditor |
30 |
30 |
31 [ID_SLAVEEDITORCONFNODEMENUNODEINFOS, ID_SLAVEEDITORCONFNODEMENUDS301PROFILE, |
31 [ |
32 ID_SLAVEEDITORCONFNODEMENUDS302PROFILE, ID_SLAVEEDITORCONFNODEMENUDSOTHERPROFILE, |
32 ID_SLAVEEDITORCONFNODEMENUNODEINFOS, ID_SLAVEEDITORCONFNODEMENUDS301PROFILE, |
33 ID_SLAVEEDITORCONFNODEMENUADD, |
33 ID_SLAVEEDITORCONFNODEMENUDS302PROFILE, ID_SLAVEEDITORCONFNODEMENUDSOTHERPROFILE, |
|
34 ID_SLAVEEDITORCONFNODEMENUADD, |
34 ] = [wx.NewId() for _init_coll_ConfNodeMenu_Items in range(5)] |
35 ] = [wx.NewId() for _init_coll_ConfNodeMenu_Items in range(5)] |
35 |
36 |
36 [ID_SLAVEEDITORADDMENUSDOSERVER, ID_SLAVEEDITORADDMENUSDOCLIENT, |
37 [ |
37 ID_SLAVEEDITORADDMENUPDOTRANSMIT, ID_SLAVEEDITORADDMENUPDORECEIVE, |
38 ID_SLAVEEDITORADDMENUSDOSERVER, ID_SLAVEEDITORADDMENUSDOCLIENT, |
38 ID_SLAVEEDITORADDMENUMAPVARIABLE, ID_SLAVEEDITORADDMENUUSERTYPE, |
39 ID_SLAVEEDITORADDMENUPDOTRANSMIT, ID_SLAVEEDITORADDMENUPDORECEIVE, |
|
40 ID_SLAVEEDITORADDMENUMAPVARIABLE, ID_SLAVEEDITORADDMENUUSERTYPE, |
39 ] = [wx.NewId() for _init_coll_AddMenu_Items in range(6)] |
41 ] = [wx.NewId() for _init_coll_AddMenu_Items in range(6)] |
40 |
42 |
|
43 |
41 class SlaveEditor(ConfTreeNodeEditor, NodeEditorTemplate): |
44 class SlaveEditor(ConfTreeNodeEditor, NodeEditorTemplate): |
42 |
45 |
43 CONFNODEEDITOR_TABS = [ |
46 CONFNODEEDITOR_TABS = [ |
44 (_("CANOpen slave"), "_create_SlaveNodeEditor")] |
47 (_("CANOpen slave"), "_create_SlaveNodeEditor")] |
45 |
48 |
46 def _create_SlaveNodeEditor(self, prnt): |
49 def _create_SlaveNodeEditor(self, prnt): |
47 self.SlaveNodeEditor = EditingPanel(prnt, self, self.Controler, self.Editable) |
50 self.SlaveNodeEditor = EditingPanel(prnt, self, self.Controler, self.Editable) |
48 return self.SlaveNodeEditor |
51 return self.SlaveNodeEditor |
49 |
52 |
50 def __init__(self, parent, controler, window, editable=True): |
53 def __init__(self, parent, controler, window, editable=True): |
51 self.Editable = editable |
54 self.Editable = editable |
52 ConfTreeNodeEditor.__init__(self, parent, controler, window) |
55 ConfTreeNodeEditor.__init__(self, parent, controler, window) |
53 NodeEditorTemplate.__init__(self, controler, window, False) |
56 NodeEditorTemplate.__init__(self, controler, window, False) |
54 |
57 |
55 def __del__(self): |
58 def __del__(self): |
56 self.Controler.OnCloseEditor(self) |
59 self.Controler.OnCloseEditor(self) |
57 |
60 |
58 def GetConfNodeMenuItems(self): |
61 def GetConfNodeMenuItems(self): |
59 if self.Editable: |
62 if self.Editable: |
60 add_menu = [(wx.ITEM_NORMAL, (_('SDO Server'), ID_SLAVEEDITORADDMENUSDOSERVER, '', self.OnAddSDOServerMenu)), |
63 add_menu = [(wx.ITEM_NORMAL, (_('SDO Server'), ID_SLAVEEDITORADDMENUSDOSERVER, '', self.OnAddSDOServerMenu)), |
61 (wx.ITEM_NORMAL, (_('SDO Client'), ID_SLAVEEDITORADDMENUSDOCLIENT, '', self.OnAddSDOClientMenu)), |
64 (wx.ITEM_NORMAL, (_('SDO Client'), ID_SLAVEEDITORADDMENUSDOCLIENT, '', self.OnAddSDOClientMenu)), |
62 (wx.ITEM_NORMAL, (_('PDO Transmit'), ID_SLAVEEDITORADDMENUPDOTRANSMIT, '', self.OnAddPDOTransmitMenu)), |
65 (wx.ITEM_NORMAL, (_('PDO Transmit'), ID_SLAVEEDITORADDMENUPDOTRANSMIT, '', self.OnAddPDOTransmitMenu)), |
63 (wx.ITEM_NORMAL, (_('PDO Receive'), ID_SLAVEEDITORADDMENUPDORECEIVE, '', self.OnAddPDOReceiveMenu)), |
66 (wx.ITEM_NORMAL, (_('PDO Receive'), ID_SLAVEEDITORADDMENUPDORECEIVE, '', self.OnAddPDOReceiveMenu)), |
64 (wx.ITEM_NORMAL, (_('Map Variable'), ID_SLAVEEDITORADDMENUMAPVARIABLE, '', self.OnAddMapVariableMenu)), |
67 (wx.ITEM_NORMAL, (_('Map Variable'), ID_SLAVEEDITORADDMENUMAPVARIABLE, '', self.OnAddMapVariableMenu)), |
65 (wx.ITEM_NORMAL, (_('User Type'), ID_SLAVEEDITORADDMENUUSERTYPE, '', self.OnAddUserTypeMenu))] |
68 (wx.ITEM_NORMAL, (_('User Type'), ID_SLAVEEDITORADDMENUUSERTYPE, '', self.OnAddUserTypeMenu))] |
66 |
69 |
67 profile = self.Controler.GetCurrentProfileName() |
70 profile = self.Controler.GetCurrentProfileName() |
68 if profile not in ("None", "DS-301"): |
71 if profile not in ("None", "DS-301"): |
69 other_profile_text = _("%s Profile") % profile |
72 other_profile_text = _("%s Profile") % profile |
70 add_menu.append((wx.ITEM_SEPARATOR, None)) |
73 add_menu.append((wx.ITEM_SEPARATOR, None)) |
71 for text, indexes in self.Manager.GetCurrentSpecificMenu(): |
74 for text, indexes in self.Manager.GetCurrentSpecificMenu(): |
72 add_menu.append((wx.ITEM_NORMAL, (text, wx.NewId(), '', self.GetProfileCallBack(text)))) |
75 add_menu.append((wx.ITEM_NORMAL, (text, wx.NewId(), '', self.GetProfileCallBack(text)))) |
73 else: |
76 else: |
74 other_profile_text = _('Other Profile') |
77 other_profile_text = _('Other Profile') |
75 |
78 |
76 return [(wx.ITEM_NORMAL, (_('DS-301 Profile'), ID_SLAVEEDITORCONFNODEMENUDS301PROFILE, '', self.OnCommunicationMenu)), |
79 return [(wx.ITEM_NORMAL, (_('DS-301 Profile'), ID_SLAVEEDITORCONFNODEMENUDS301PROFILE, '', self.OnCommunicationMenu)), |
77 (wx.ITEM_NORMAL, (_('DS-302 Profile'), ID_SLAVEEDITORCONFNODEMENUDS302PROFILE, '', self.OnOtherCommunicationMenu)), |
80 (wx.ITEM_NORMAL, (_('DS-302 Profile'), ID_SLAVEEDITORCONFNODEMENUDS302PROFILE, '', self.OnOtherCommunicationMenu)), |
78 (wx.ITEM_NORMAL, (other_profile_text, ID_SLAVEEDITORCONFNODEMENUDSOTHERPROFILE, '', self.OnEditProfileMenu)), |
81 (wx.ITEM_NORMAL, (other_profile_text, ID_SLAVEEDITORCONFNODEMENUDSOTHERPROFILE, '', self.OnEditProfileMenu)), |
79 (wx.ITEM_SEPARATOR, None), |
82 (wx.ITEM_SEPARATOR, None), |
80 (add_menu, (_('Add'), ID_SLAVEEDITORCONFNODEMENUADD))] |
83 (add_menu, (_('Add'), ID_SLAVEEDITORCONFNODEMENUADD))] |
81 return [] |
84 return [] |
82 |
85 |
83 def RefreshConfNodeMenu(self, confnode_menu): |
86 def RefreshConfNodeMenu(self, confnode_menu): |
84 if self.Editable: |
87 if self.Editable: |
85 confnode_menu.Enable(ID_SLAVEEDITORCONFNODEMENUDSOTHERPROFILE, False) |
88 confnode_menu.Enable(ID_SLAVEEDITORCONFNODEMENUDSOTHERPROFILE, False) |
86 |
89 |
87 def RefreshView(self): |
90 def RefreshView(self): |
88 ConfTreeNodeEditor.RefreshView(self) |
91 ConfTreeNodeEditor.RefreshView(self) |
89 self.SlaveNodeEditor.RefreshIndexList() |
92 self.SlaveNodeEditor.RefreshIndexList() |
90 |
93 |
91 def RefreshCurrentIndexList(self): |
94 def RefreshCurrentIndexList(self): |
92 self.RefreshView() |
95 self.RefreshView() |
93 |
96 |
94 def RefreshBufferState(self): |
97 def RefreshBufferState(self): |
95 self.ParentWindow.RefreshTitle() |
98 self.ParentWindow.RefreshTitle() |
96 self.ParentWindow.RefreshFileMenu() |
99 self.ParentWindow.RefreshFileMenu() |
97 self.ParentWindow.RefreshEditMenu() |
100 self.ParentWindow.RefreshEditMenu() |
98 self.ParentWindow.RefreshPageTitles() |
101 self.ParentWindow.RefreshPageTitles() |
99 |
102 |
|
103 |
100 class MasterViewer(SlaveEditor): |
104 class MasterViewer(SlaveEditor): |
101 SHOW_BASE_PARAMS = False |
105 SHOW_BASE_PARAMS = False |
102 SHOW_PARAMS = False |
106 SHOW_PARAMS = False |
103 |
107 |
104 def __init__(self, parent, controler, window, tagname): |
108 def __init__(self, parent, controler, window, tagname): |
105 SlaveEditor.__init__(self, parent, controler, window, False) |
109 SlaveEditor.__init__(self, parent, controler, window, False) |
106 |
110 |
107 self.TagName = tagname |
111 self.TagName = tagname |
108 |
112 |
109 def GetTagName(self): |
113 def GetTagName(self): |
110 return self.TagName |
114 return self.TagName |
111 |
115 |
112 def GetCurrentNodeId(self): |
116 def GetCurrentNodeId(self): |
113 return None |
117 return None |
114 |
118 |
115 def GetInstancePath(self): |
119 def GetInstancePath(self): |
116 return self.Controler.CTNFullName() + ".generated_master" |
120 return self.Controler.CTNFullName() + ".generated_master" |
117 |
121 |
118 def GetTitle(self): |
122 def GetTitle(self): |
119 return self.GetInstancePath() |
123 return self.GetInstancePath() |
120 |
124 |
121 def IsViewing(self, tagname): |
125 def IsViewing(self, tagname): |
122 return self.GetInstancePath() == tagname |
126 return self.GetInstancePath() == tagname |
123 |
127 |
124 def RefreshView(self): |
128 def RefreshView(self): |
125 self.SlaveNodeEditor.RefreshIndexList() |
129 self.SlaveNodeEditor.RefreshIndexList() |
126 |
|