# HG changeset patch # User lbessard # Date 1166032081 -3600 # Node ID 3a553c789116eb59454437b63bf5aee53109bf49 # Parent 142fa58877d2452395b7dbcac232133bc0906e4b Some bugs reported by Francis Dupin corrected. diff -r 142fa58877d2 -r 3a553c789116 objdictgen/node.py --- a/objdictgen/node.py Wed Dec 13 16:22:09 2006 +0100 +++ b/objdictgen/node.py Wed Dec 13 18:48:01 2006 +0100 @@ -85,7 +85,7 @@ 0x000B : {"name" : "UNICODE_STRING", "struct" : nosub, "size" : 16, "default" : "", "values" : []}, 0x000C : {"name" : "TIME_OF_DAY", "struct" : nosub, "size" : 48, "default" : 0, "values" : []}, 0x000D : {"name" : "TIME_DIFFERENCE", "struct" : nosub, "size" : 48, "default" : 0, "values" : []}, - 0x000F : {"name" : "DOMAIN", "struct" : nosub, "size" : 0, "default" : "", "values" : []}, +# 0x000F : {"name" : "DOMAIN", "struct" : nosub, "size" : 0, "default" : "", "values" : []}, 0x0010 : {"name" : "INTEGER24", "struct" : nosub, "size" : 24, "default" : 0, "values" : []}, 0x0011 : {"name" : "REAL64", "struct" : nosub, "size" : 64, "default" : 0.0, "values" : []}, 0x0012 : {"name" : "INTEGER40", "struct" : nosub, "size" : 40, "default" : 0, "values" : []}, @@ -157,10 +157,10 @@ [{"name" : "Number of Entries", "type" : 0x02, "access" : 'ro', "pdo" : False}, {"name" : "Configuration Date", "type" : 0x04, "access" : 'ro', "pdo" : False}, {"name" : "Configuration Time", "type" : 0x04, "access" : 'ro', "pdo" : False}]}, - 0x1021 : {"name" : "Store EDS", "struct" : var, "need" : False, "values" : - [{"name" : "Store EDS", "type" : 0x0F, "access" : 'rw', "pdo" : False}]}, - 0x1022 : {"name" : "Storage Format", "struct" : var, "need" : False, "values" : - [{"name" : "Storage Format", "type" : 0x04, "access" : 'rw', "pdo" : False}]}, +# 0x1021 : {"name" : "Store EDS", "struct" : var, "need" : False, "values" : +# [{"name" : "Store EDS", "type" : 0x0F, "access" : 'rw', "pdo" : False}]}, +# 0x1022 : {"name" : "Storage Format", "struct" : var, "need" : False, "values" : +# [{"name" : "Storage Format", "type" : 0x04, "access" : 'rw', "pdo" : False}]}, 0x1023 : {"name" : "OS Command", "struct" : array, "need" : False, "values" : [{"name" : "Number of Entries", "type" : 0x02, "access" : 'ro', "pdo" : False}, {"name" : "Command", "type" : 0x0A, "access" : 'rw', "pdo" : False}, diff -r 142fa58877d2 -r 3a553c789116 objdictgen/nodemanager.py --- a/objdictgen/nodemanager.py Wed Dec 13 16:22:09 2006 +0100 +++ b/objdictgen/nodemanager.py Wed Dec 13 18:48:01 2006 +0100 @@ -1119,12 +1119,10 @@ result = type_model.match(dic["type"]) if result: values = result.groups() - if values[0] == "INTEGER": + if values[0] in ["INTEGER", "UNSIGNED"]: format = "0x%0" + str(int(values[1])/4) + "X" dic["value"] = format%dic["value"] editor["value"] = "string" - elif values[0] == "UNSIGNED": - editor["value"] = "number" elif values[0] == "REAL": editor["value"] = "float" elif values[0] == "VISIBLE_STRING": diff -r 142fa58877d2 -r 3a553c789116 objdictgen/objdictedit.py --- a/objdictgen/objdictedit.py Wed Dec 13 16:22:09 2006 +0100 +++ b/objdictgen/objdictedit.py Wed Dec 13 18:48:01 2006 +0100 @@ -464,6 +464,7 @@ return None def OnAddButtonClick(self, event): + self.SubindexGrid.SetGridCursor(0, 0) selected = self.IndexChoice.GetStringSelection() if selected != "": if selected == "User Type": @@ -820,8 +821,8 @@ parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS2, kind=wx.ITEM_NORMAL, text='Close\tCTRL+W') parent.AppendSeparator() - parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS7, - kind=wx.ITEM_NORMAL, text='Import XML file') +# parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS7, +# kind=wx.ITEM_NORMAL, text='Import XML file') parent.Append(help='', id=wxID_OBJDICTEDITFILEMENUITEMS8, kind=wx.ITEM_NORMAL, text='Build Dictionary\tCTRL+B') parent.AppendSeparator() @@ -839,8 +840,8 @@ id=wxID_OBJDICTEDITFILEMENUITEMS5) self.Bind(wx.EVT_MENU, self.OnSaveAsMenu, id=wxID_OBJDICTEDITFILEMENUITEMS6) - self.Bind(wx.EVT_MENU, self.OnImportMenu, - id=wxID_OBJDICTEDITFILEMENUITEMS7) +# self.Bind(wx.EVT_MENU, self.OnImportMenu, +# id=wxID_OBJDICTEDITFILEMENUITEMS7) self.Bind(wx.EVT_MENU, self.OnExportMenu, id=wxID_OBJDICTEDITFILEMENUITEMS8) @@ -1173,33 +1174,22 @@ dialog = CreateNodeDialog(self) if dialog.ShowModal() == wxID_OK: name, id, type = dialog.GetValues() - if name != "": - good = not name[0].isdigit() - for item in name.split("_"): - good &= item.isalnum() + profile, filepath = dialog.GetProfile() + NMT = dialog.GetNMTManagement() + options = dialog.GetOptions() + result = self.Manager.CreateNewNode(name, id, type, profile, filepath, NMT, options) + if not IsOfType(result, StringType): + new_editingpanel = EditingPanel(self, self.Manager) + self.FileOpened.AddPage(new_editingpanel, "") + self.FileOpened.SetSelection(self.Manager.GetCurrentNodeIndex()) + self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS8, False) + if "DS302" in options: + self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS8, True) + self.RefreshBufferState() + self.RefreshProfileMenu() + self.RefreshMainMenu() else: - good = False - if good: - profile,filepath = dialog.GetProfile() - NMT = dialog.GetNMTManagement() - options = dialog.GetOptions() - result = self.Manager.CreateNewNode(name, id, type, profile, filepath, NMT, options) - if not IsOfType(result, StringType): - new_editingpanel = EditingPanel(self, self.Manager) - self.FileOpened.AddPage(new_editingpanel, "") - self.FileOpened.SetSelection(self.Manager.GetCurrentNodeIndex()) - self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS8, False) - if "DS302" in options: - self.EditMenu.Enable(wxID_OBJDICTEDITEDITMENUITEMS8, True) - self.RefreshBufferState() - self.RefreshProfileMenu() - self.RefreshMainMenu() - else: - message = wxMessageDialog(self, result, "ERROR", wxOK|wxICON_ERROR) - message.ShowModal() - message.Destroy() - else: - message = wxMessageDialog(self, "Node name can't be undefined or start with a digit and must be composed of alphanumerical characters or underscore!", "ERROR", wxOK|wxICON_ERROR) + message = wxMessageDialog(self, result, "ERROR", wxOK|wxICON_ERROR) message.ShowModal() message.Destroy() event.Skip() @@ -1210,7 +1200,7 @@ directory = os.path.dirname(filepath) else: directory = os.getcwd() - dialog = wxFileDialog(self, "Choose a file", directory, "", "OD files (*.od)|*.od|All files|*.*", wxOPEN) + dialog = wxFileDialog(self, "Choose a file", directory, "", "OD files (*.od)|*.od|All files|*.*", wxOPEN|wxCHANGE_DIR) if dialog.ShowModal() == wxID_OK: filepath = dialog.GetPath() if os.path.isfile(filepath): @@ -1259,7 +1249,7 @@ directory, filename = os.path.split(filepath) else: directory, filename = os.getcwd(), "%s.od"%self.Manager.GetCurrentNodeInfos()[0] - dialog = wxFileDialog(self, "Choose a file", directory, filename, "OD files (*.od)|*.od|All files|*.*", wxSAVE|wxOVERWRITE_PROMPT) + dialog = wxFileDialog(self, "Choose a file", directory, filename, "OD files (*.od)|*.od|All files|*.*", wxSAVE|wxOVERWRITE_PROMPT|wxCHANGE_DIR) if dialog.ShowModal() == wxID_OK: filepath = dialog.GetPath() if os.path.isdir(os.path.dirname(filepath)): @@ -1304,7 +1294,7 @@ #------------------------------------------------------------------------------- def OnImportMenu(self, event): - dialog = wxFileDialog(self, "Choose a file", os.getcwd(), "", "XML OD files (*.xml)|*.xml|All files|*.*", wxOPEN) + dialog = wxFileDialog(self, "Choose a file", os.getcwd(), "", "XML OD files (*.xml)|*.xml|All files|*.*", wxOPEN|wxCHANGE_DIR) if dialog.ShowModal() == wxID_OK: filepath = dialog.GetPath() if os.path.isfile(filepath): @@ -1325,7 +1315,7 @@ event.Skip() def OnExportMenu(self, event): - dialog = wxFileDialog(self, "Choose a file", os.getcwd(), self.Manager.GetCurrentNodeInfos()[0], "CANFestival OD files (*.c)|*.c|All files|*.*", wxSAVE|wxOVERWRITE_PROMPT) + dialog = wxFileDialog(self, "Choose a file", os.getcwd(), self.Manager.GetCurrentNodeInfos()[0], "CANFestival OD files (*.c)|*.c|All files|*.*", wxSAVE|wxOVERWRITE_PROMPT|wxCHANGE_DIR) if dialog.ShowModal() == wxID_OK: filepath = dialog.GetPath() if os.path.isdir(os.path.dirname(filepath)): @@ -1520,12 +1510,12 @@ id=wxID_COMMUNICATIONDIALOGUNSELECT) self.staticText1 = wx.StaticText(id=wxID_COMMUNICATIONDIALOGSTATICTEXT1, - label='Possible Profile Indexes :', name='staticText1', + label='Possible Profile Indexes:', name='staticText1', parent=self.MainPanel, pos=wx.Point(40, 24), size=wx.Size(156, 17), style=0) self.staticText2 = wx.StaticText(id=wxID_COMMUNICATIONDIALOGSTATICTEXT2, - label='Current Profile Indexes :', name='staticText2', + label='Current Profile Indexes:', name='staticText2', parent=self.MainPanel, pos=wx.Point(400, 24), size=wx.Size(152, 17), style=0) @@ -1638,7 +1628,7 @@ self.MainPanel.SetAutoLayout(True) self.staticText1 = wx.StaticText(id=wxID_MAPVARIABLEDIALOGSTATICTEXT1, - label='Index :', name='staticText1', parent=self.MainPanel, + label='Index:', name='staticText1', parent=self.MainPanel, pos=wx.Point(24, 24), size=wx.Size(156, 17), style=0) self.Index = wx.TextCtrl(id=wxID_MAPVARIABLEDIALOGINDEX, name='Index', @@ -1646,7 +1636,7 @@ 25), style=0, value='0x2000') self.staticText3 = wx.StaticText(id=wxID_MAPVARIABLEDIALOGSTATICTEXT3, - label='Name :', name='staticText3', parent=self.MainPanel, + label='Name:', name='staticText3', parent=self.MainPanel, pos=wx.Point(24, 80), size=wx.Size(47, 17), style=0) self.IndexName = wx.TextCtrl(id=wxID_MAPVARIABLEDIALOGINDEXNAME, @@ -1654,7 +1644,7 @@ size=wx.Size(152, 24), style=0, value='Undefined') self.staticText2 = wx.StaticText(id=wxID_MAPVARIABLEDIALOGSTATICTEXT2, - label='Type :', name='staticText2', parent=self.MainPanel, + label='Type:', name='staticText2', parent=self.MainPanel, pos=wx.Point(208, 24), size=wx.Size(38, 17), style=0) self.radioButton1 = wx.RadioButton(id=wxID_MAPVARIABLEDIALOGRADIOBUTTON1, @@ -1679,7 +1669,7 @@ id=wxID_MAPVARIABLEDIALOGRADIOBUTTON3) self.staticText4 = wx.StaticText(id=wxID_MAPVARIABLEDIALOGSTATICTEXT4, - label='Number :', name='staticText4', parent=self.MainPanel, + label='Number:', name='staticText4', parent=self.MainPanel, pos=wx.Point(312, 80), size=wx.Size(88, 16), style=0) self.Number = wx.TextCtrl(id=wxID_MAPVARIABLEDIALOGNUMBER, @@ -1766,7 +1756,7 @@ self.MainPanel.SetAutoLayout(True) self.staticText1 = wx.StaticText(id=wxID_USERTYPEDIALOGSTATICTEXT1, - label='Type :', name='staticText1', parent=self.MainPanel, + label='Type:', name='staticText1', parent=self.MainPanel, pos=wx.Point(24, 24), size=wx.Size(156, 17), style=0) self.Type = wx.Choice(choices=[], id=wxID_USERTYPEDIALOGTYPE, @@ -1780,7 +1770,7 @@ pos=wx.Point(200, 24), size=wx.Size(224, 144), style=0) self.staticText2 = wx.StaticText(id=wxID_USERTYPEDIALOGSTATICTEXT2, - label='Minimum :', name='staticText2', parent=self.MainPanel, + label='Minimum:', name='staticText2', parent=self.MainPanel, pos=wx.Point(216, 48), size=wx.Size(67, 17), style=0) self.Min = wx.TextCtrl(id=wxID_USERTYPEDIALOGMIN, name='Min', @@ -1788,7 +1778,7 @@ 24), style=wx.TE_RIGHT, value='0') self.staticText3 = wx.StaticText(id=wxID_USERTYPEDIALOGSTATICTEXT3, - label='Maximum :', name='staticText3', parent=self.MainPanel, + label='Maximum:', name='staticText3', parent=self.MainPanel, pos=wx.Point(216, 88), size=wx.Size(71, 17), style=0) self.Max = wx.TextCtrl(id=wxID_USERTYPEDIALOGMAX, name='Max', @@ -1796,7 +1786,7 @@ 25), style=wx.TE_RIGHT, value='0') self.staticText4 = wx.StaticText(id=wxID_USERTYPEDIALOGSTATICTEXT4, - label='Length :', name='staticText4', parent=self.MainPanel, + label='Length:', name='staticText4', parent=self.MainPanel, pos=wx.Point(216, 128), size=wx.Size(52, 17), style=0) self.Length = wx.TextCtrl(id=wxID_USERTYPEDIALOGLENGTH, name='Length', @@ -1912,7 +1902,8 @@ self.MainPanel.SetAutoLayout(True) self.staticText1 = wx.StaticText(id=wxID_NODEINFOSDIALOGSTATICTEXT1, - label='Name :', name='staticText1', parent=self.MainPanel, + label='Name:', + name='staticText1', parent=self.MainPanel, pos=wx.Point(24, 24), size=wx.Size(156, 17), style=0) self.Name = wx.TextCtrl(id=wxID_NODEINFOSDIALOGNAME, name='Name', @@ -1920,7 +1911,7 @@ 25), style=0, value='') self.staticText2 = wx.StaticText(id=wxID_NODEINFOSDIALOGSTATICTEXT2, - label='Node ID :', name='staticText2', parent=self.MainPanel, + label='Node ID:', name='staticText2', parent=self.MainPanel, pos=wx.Point(24, 80), size=wx.Size(67, 17), style=0) self.NodeID = wx.TextCtrl(id=wxID_NODEINFOSDIALOGNODEID, name='NodeID', @@ -1928,7 +1919,7 @@ 25), style=wx.TE_RIGHT, value='') self.staticText3 = wx.StaticText(id=wxID_NODEINFOSDIALOGSTATICTEXT3, - label='Type :', name='staticText3', parent=self.MainPanel, + label='Type:', name='staticText3', parent=self.MainPanel, pos=wx.Point(24, 136), size=wx.Size(71, 17), style=0) self.Type = wx.Choice(choices=[], id=wxID_NODEINFOSDIALOGTYPE, @@ -1936,7 +1927,7 @@ size=wx.Size(200, 25), style=0) self.staticText4 = wx.StaticText(id=wxID_NODEINFOSDIALOGSTATICTEXT4, - label='Profile :', name='staticText4', parent=self.MainPanel, + label='Profile:', name='staticText4', parent=self.MainPanel, pos=wx.Point(24, 192), size=wx.Size(47, 17), style=0) self.Profile = wx.Choice(choices=[], id=wxID_NODEINFOSDIALOGPROFILE, @@ -1953,6 +1944,24 @@ self.Type.Append("slave") self.staticText4.Hide() self.Profile.Hide() + + EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK) + + def OnOK(self, event): + name = self.Name.GetValue() + if name != "": + good = not name[0].isdigit() + for item in name.split("_"): + good &= item.isalnum() + else: + good = False + if not good: + message = wxMessageDialog(self, "Node name can't be undefined or start with a digit and must be composed of alphanumerical characters or underscore!", "ERROR", wxOK|wxICON_ERROR) + message.ShowModal() + message.Destroy() + self.Name.SetFocus() + else: + self.EndModal(wxID_OK) def SetProfiles(self, profiles): for profile in profiles: @@ -2018,15 +2027,15 @@ self.MainPanel.SetAutoLayout(True) self.staticText1 = wx.StaticText(id=wxID_CREATENODEDIALOGSTATICTEXT1, - label='Name :', name='staticText1', parent=self.MainPanel, + label='Name:', name='staticText1', parent=self.MainPanel, pos=wx.Point(24, 24), size=wx.Size(156, 17), style=0) self.staticText2 = wx.StaticText(id=wxID_CREATENODEDIALOGSTATICTEXT2, - label='Node ID :', name='staticText2', parent=self.MainPanel, + label='Node ID:', name='staticText2', parent=self.MainPanel, pos=wx.Point(24, 80), size=wx.Size(67, 17), style=0) self.staticText3 = wx.StaticText(id=wxID_CREATENODEDIALOGSTATICTEXT3, - label='Type :', name='staticText3', parent=self.MainPanel, + label='Type:', name='staticText3', parent=self.MainPanel, pos=wx.Point(24, 136), size=wx.Size(71, 17), style=0) self.Type = wx.Choice(choices=[], id=wxID_CREATENODEDIALOGTYPE, @@ -2042,7 +2051,7 @@ 25), style=wx.TE_RIGHT, value='') self.staticText4 = wx.StaticText(id=wxID_CREATENODEDIALOGSTATICTEXT4, - label='Profile :', name='staticText4', parent=self.MainPanel, + label='Profile:', name='staticText4', parent=self.MainPanel, pos=wx.Point(24, 192), size=wx.Size(47, 17), style=0) self.Profile = wx.Choice(choices=[], id=wxID_CREATENODEDIALOGPROFILE, @@ -2052,7 +2061,7 @@ id=wxID_CREATENODEDIALOGPROFILE) self.staticText5 = wx.StaticText(id=wxID_CREATENODEDIALOGSTATICTEXT5, - label='Network Management :', name='staticText5', + label='Network Management:', name='staticText5', parent=self.MainPanel, pos=wx.Point(256, 24), size=wx.Size(152, 16), style=0) @@ -2073,13 +2082,14 @@ self.NMT_Heartbeat.SetValue(False) self.staticText6 = wx.StaticText(id=wxID_CREATENODEDIALOGSTATICTEXT6, - label='Options :', name='staticText6', parent=self.MainPanel, + label='Options:', name='staticText6', parent=self.MainPanel, pos=wx.Point(256, 128), size=wx.Size(72, 17), style=0) self.DS302 = wx.CheckBox(id=wxID_CREATENODEDIALOGGENSYNC, label='DS-302 Profile', name='DS302', parent=self.MainPanel, pos=wx.Point(256, 144), size=wx.Size(128, 24), style=0) self.DS302.SetValue(False) + self.DS302.Enable(False) self.GenSYNC = wx.CheckBox(id=wxID_CREATENODEDIALOGGENSYNC, label='Generate SYNC', name='GenSYNC', parent=self.MainPanel, @@ -2091,24 +2101,27 @@ parent=self.MainPanel, pos=wx.Point(256, 192), size=wx.Size(152, 24), style=0) self.Emergency.SetValue(False) + self.Emergency.Enable(False) self.SaveConfig = wx.CheckBox(id=wxID_CREATENODEDIALOGSAVECONFIG, label='Save Configuration', name='SaveConfig', parent=self.MainPanel, pos=wx.Point(256, 216), size=wx.Size(152, 24), style=0) self.SaveConfig.SetValue(False) - - self.StoreEDS = wx.CheckBox(id=wxID_CREATENODEDIALOGSTOREEDS, - label='Store EDS', name='StoreEDS', parent=self.MainPanel, - pos=wx.Point(256, 240), size=wx.Size(144, 24), style=0) - self.StoreEDS.SetValue(False) - + self.SaveConfig.Enable(False) + +# self.StoreEDS = wx.CheckBox(id=wxID_CREATENODEDIALOGSTOREEDS, +# label='Store EDS', name='StoreEDS', parent=self.MainPanel, +# pos=wx.Point(256, 240), size=wx.Size(144, 24), style=0) +# self.StoreEDS.SetValue(False) + self._init_sizers() def __init__(self, parent): self._init_ctrls(parent) self.ButtonSizer = self.CreateButtonSizer(wxOK|wxCANCEL) self.flexGridSizer1.Add(self.ButtonSizer, 1, wxALIGN_CENTER) + self.NodeID.SetValue("0x00") self.Type.Append("master") self.Type.Append("slave") self.Type.SetStringSelection("slave") @@ -2124,6 +2137,25 @@ self.Profile.Append(name) self.Profile.Append("Other") self.Profile.SetStringSelection("None") + self.Name.SetFocus() + + EVT_BUTTON(self, self.ButtonSizer.GetAffirmativeButton().GetId(), self.OnOK) + + def OnOK(self, event): + name = self.Name.GetValue() + if name != "": + good = not name[0].isdigit() + for item in name.split("_"): + good &= item.isalnum() + else: + good = False + if not good: + message = wxMessageDialog(self, "Node name can't be undefined or start with a digit and must be composed of alphanumerical characters or underscore!", "ERROR", wxOK|wxICON_ERROR) + message.ShowModal() + message.Destroy() + self.Name.SetFocus() + else: + self.EndModal(wxID_OK) def GetValues(self): name = self.Name.GetValue() @@ -2156,13 +2188,13 @@ options.append("Emergency") if self.SaveConfig.GetValue(): options.append("SaveConfig") - if self.StoreEDS.GetValue(): - options.append("StoreEDS") +# if self.StoreEDS.GetValue(): +# options.append("StoreEDS") return options def OnProfileChoice(self, event): if self.Profile.GetStringSelection() == "Other": - dialog = wxFileDialog(self, "Choose a file", self.Directory, "", "OD Profile files (*.prf)|*.prf|All files|*.*", wxOPEN) + dialog = wxFileDialog(self, "Choose a file", self.Directory, "", "OD Profile files (*.prf)|*.prf|All files|*.*", wxOPEN|wxCHANGE_DIR) dialog.ShowModal() filepath = dialog.GetPath() dialog.Destroy()