# HG changeset patch # User Andrey Skvortsov # Date 1538216960 -10800 # Node ID cfa68a06a24d924f0f90794d63bb9fe47d785a5e # Parent aed3ca79a10a6dec1c696871a451b34a58c04008 clean etherlab: pep8, E203 whitespace before ',' diff -r aed3ca79a10a -r cfa68a06a24d etherlab/CommonEtherCATFunction.py --- a/etherlab/CommonEtherCATFunction.py Sat Sep 29 13:04:33 2018 +0300 +++ b/etherlab/CommonEtherCATFunction.py Sat Sep 29 13:29:20 2018 +0300 @@ -199,11 +199,11 @@ master_state = {} # parse the reslut for each_line in return_val.splitlines(): - if len(each_line) > 0 : + if len(each_line) > 0: chunks = each_line.strip().split(':', 1) key = chunks[0] value = [] - if len(chunks) > 1 : + if len(chunks) > 1: value = chunks[1].split() if '(attached)' in value: value.remove('(attached)') @@ -290,7 +290,7 @@ self.ClearDataSet() # if 'device' object is valid, call SavePDOData() to parse PDO data - if device is not None : + if device is not None: self.SavePDOData(device) def SavePDOData(self, device): @@ -316,18 +316,18 @@ index = ExtractHexDecValue(entry.getIndex().getcontent()) subindex = ExtractHexDecValue(entry.getSubIndex()) # if entry name exists, save entry data - if ExtractName(entry.getName()) is not None : + if ExtractName(entry.getName()) is not None: entry_infos = { - "entry_index" : index, - "subindex" : subindex, - "name" : ExtractName(entry.getName()), - "bitlen" : entry.getBitLen(), - "type" : entry.getDataType().getcontent() + "entry_index": index, + "subindex": subindex, + "name": ExtractName(entry.getName()), + "bitlen": entry.getBitLen(), + "type": entry.getDataType().getcontent() } self.TxPDOInfo.append(entry_infos) count += 1 - categorys = {"pdo_index" : pdo_index, "name" : pdo_name, "number_of_entry" : count} + categorys = {"pdo_index": pdo_index, "name": pdo_name, "number_of_entry": count} self.TxPDOCategory.append(categorys) # Parsing RxPDO entries @@ -346,18 +346,18 @@ index = ExtractHexDecValue(entry.getIndex().getcontent()) subindex = ExtractHexDecValue(entry.getSubIndex()) # if entry name exists, save entry data - if ExtractName(entry.getName()) is not None : + if ExtractName(entry.getName()) is not None: entry_infos = { - "entry_index" : index, - "subindex" : subindex, - "name" : ExtractName(entry.getName()), - "bitlen" : str(entry.getBitLen()), - "type" : entry.getDataType().getcontent() + "entry_index": index, + "subindex": subindex, + "name": ExtractName(entry.getName()), + "bitlen": str(entry.getBitLen()), + "type": entry.getDataType().getcontent() } self.RxPDOInfo.append(entry_infos) count += 1 - categorys = {"pdo_index" : pdo_index, "name" : pdo_name, "number_of_entry" : count} + categorys = {"pdo_index": pdo_index, "name": pdo_name, "number_of_entry": count} self.RxPDOCategory.append(categorys) def GetTxPDOCategory(self): @@ -601,7 +601,7 @@ hexview_table_col = 17 - for index in range(0, len(binary)) : + for index in range(0, len(binary)): if len(binary[index]) != 1: break else: @@ -617,7 +617,7 @@ else: row_text = row_text + "." - if index != 0 : + if index != 0: if len(row_code) == (hexview_table_col - 1): row_code.append(row_text) hex_code.append(row_code) @@ -785,7 +785,7 @@ # get supported mailbox protocols for EEPROM offset 0x0038-0x0039; data = 0 mb = device.getMailbox() - if mb is not None : + if mb is not None: for bit, mbprot in enumerate(mailbox_protocols): if getattr(mb, "get%s" % mbprot)() is not None: data += 1 << bit @@ -1179,7 +1179,7 @@ coe_details = 0 mb = device.getMailbox() coe_details = 1 # sdo enabled - if mb is not None : + if mb is not None: coe = mb.getCoE() if coe is not None: for bit, flag in enumerate(["SdoInfo", "PdoAssign", "PdoConfig", @@ -1208,9 +1208,9 @@ eeprom.append("00") # DS402Channels; -----: DS402Channels ds402ch = False - if mb is not None : + if mb is not None: coe = mb.getCoE() - if coe is not None : + if coe is not None: ds402ch = coe.getDS402Channels() eeprom.append("01" if ds402ch in [True, 1] else "00") @@ -1569,16 +1569,16 @@ # Command example : "ethercat xml -p 0" error, return_val = self.Controler.RemoteExec(SLAVE_XML % (self.Controler.GetSlavePos()), return_val=None) number_of_lines = return_val.split("\n") - if len(number_of_lines) <= 2 : # No slave connected to the master controller - if not cyclic_flag : + if len(number_of_lines) <= 2: # No slave connected to the master controller + if not cyclic_flag: self.CreateErrorDialog('No connected slaves') return False - elif len(number_of_lines) > 2 : + elif len(number_of_lines) > 2: return True else: # The master controller is not connected to Beremiz host - if not cyclic_flag : + if not cyclic_flag: self.CreateErrorDialog('PLC not connected!') return False diff -r aed3ca79a10a -r cfa68a06a24d etherlab/ConfigEditor.py --- a/etherlab/ConfigEditor.py Sat Sep 29 13:04:33 2018 +0300 +++ b/etherlab/ConfigEditor.py Sat Sep 29 13:29:20 2018 +0300 @@ -26,6 +26,7 @@ # ----------------------------------------------------------------------- from EtherCATManagementEditor import EtherCATManagementTreebook, MasterStatePanelClass +from util.TranslationCatalogs import NoTranslate # ----------------------------------------------------------------------- [ETHERCAT_VENDOR, ETHERCAT_GROUP, ETHERCAT_DEVICE] = range(3) @@ -39,7 +40,7 @@ def GetVariablesTableColnames(position=False): - _ = lambda x : x + _ = NoTranslate colname = ["#"] if position: colname.append(_("Position")) @@ -335,7 +336,7 @@ def GetProcessVariablesTableColnames(): - _ = lambda x : x + _ = NoTranslate return ["#", _("Name"), _("Read from (nodeid, index, subindex)"), _("Write to (nodeid, index, subindex)"), @@ -457,7 +458,7 @@ def GetStartupCommandsTableColnames(): - _ = lambda x : x + _ = NoTranslate return [_("Position"), _("Index"), _("Subindex"), _("Value"), _("Description")] diff -r aed3ca79a10a -r cfa68a06a24d etherlab/EtherCATManagementEditor.py --- a/etherlab/EtherCATManagementEditor.py Sat Sep 29 13:04:33 2018 +0300 +++ b/etherlab/EtherCATManagementEditor.py Sat Sep 29 13:29:20 2018 +0300 @@ -25,6 +25,7 @@ # ------------ for register management --------------- from xml.dom import minidom +from util.TranslationCatalogs import NoTranslate # ------------------------------------------------------------- @@ -33,7 +34,7 @@ """ Returns column names of SyncManager Table in Slave state panel. """ - _ = lambda x : x + _ = NoTranslate return ["#", _("Name"), _("Start Address"), _("Default Size"), _("Control Byte"), _("Enable")] @@ -117,13 +118,13 @@ # iniitalize BoxSizer and FlexGridSizer self.SizerDic = { - "SlaveState_main_sizer" : wx.BoxSizer(wx.VERTICAL), - "SlaveState_inner_main_sizer" : wx.FlexGridSizer(cols=1, hgap=50, rows=3, vgap=10), - "SlaveInfosDetailsInnerSizer" : wx.FlexGridSizer(cols=4, hgap=10, rows=2, vgap=10), - "SyncManagerInnerSizer" : wx.FlexGridSizer(cols=1, hgap=5, rows=1, vgap=5), - "SlaveState_sizer" : wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=10), - "SlaveState_up_sizer" : wx.FlexGridSizer(cols=4, hgap=10, rows=2, vgap=10), - "SlaveState_down_sizer" : wx.FlexGridSizer(cols=2, hgap=10, rows=1, vgap=10)} + "SlaveState_main_sizer": wx.BoxSizer(wx.VERTICAL), + "SlaveState_inner_main_sizer": wx.FlexGridSizer(cols=1, hgap=50, rows=3, vgap=10), + "SlaveInfosDetailsInnerSizer": wx.FlexGridSizer(cols=4, hgap=10, rows=2, vgap=10), + "SyncManagerInnerSizer": wx.FlexGridSizer(cols=1, hgap=5, rows=1, vgap=5), + "SlaveState_sizer": wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=10), + "SlaveState_up_sizer": wx.FlexGridSizer(cols=4, hgap=10, rows=2, vgap=10), + "SlaveState_down_sizer": wx.FlexGridSizer(cols=2, hgap=10, rows=1, vgap=10)} # initialize StaticBox and StaticBoxSizer for box_name, box_label in [ @@ -150,18 +151,20 @@ self.SizerDic["SyncManagerInnerSizer"].Add(self.SyncManagersGrid) self.SizerDic["SyncManagerBox"].Add(self.SizerDic["SyncManagerInnerSizer"]) - for button_name, button_id, button_label, button_tooltipstring, event_method, sub_item in [ - ("InitButton", 0, "INIT", "State Transition to \"Init\" State", self.OnButtonClick, []), - ("PreOPButton", 1, "PREOP", "State Transition to \"PreOP\" State", self.OnButtonClick, [ - ("TargetStateLabel", "Target State:" , "TargetState")]), - ("SafeOPButton", 2, "SAFEOP", "State Transition to \"SafeOP\" State", self.OnButtonClick, []), - ("OPButton", 3, "OP", "State Transition to \"OP\" State", self.OnButtonClick, [ - ("CurrentStateLabel", "Current State:", "CurrentState")])]: + buttons = [ + ("InitButton", 0, "INIT", "State Transition to \"Init\" State", self.OnButtonClick, []), + ("PreOPButton", 1, "PREOP", "State Transition to \"PreOP\" State", self.OnButtonClick, [ + ("TargetStateLabel", "Target State:", "TargetState")]), + ("SafeOPButton", 2, "SAFEOP", "State Transition to \"SafeOP\" State", self.OnButtonClick, []), + ("OPButton", 3, "OP", "State Transition to \"OP\" State", self.OnButtonClick, [ + ("CurrentStateLabel", "Current State:", "CurrentState")]) + ] + for button_name, button_id, button_label, button_tooltipstring, event_method, sub_item in buttons: self.ButtonDic[button_name] = wx.Button(self, id=button_id, label=_(button_label)) self.ButtonDic[button_name].Bind(wx.EVT_BUTTON, event_method) self.ButtonDic[button_name].SetToolTipString(button_tooltipstring) self.SizerDic["SlaveState_up_sizer"].Add(self.ButtonDic[button_name]) - for statictext_name, statictext_label, textctrl_name in sub_item : + for statictext_name, statictext_label, textctrl_name in sub_item: self.StaticTextDic[statictext_name] = wx.StaticText(self, label=_(statictext_label)) self.TextCtrlDic[textctrl_name] = wx.TextCtrl(self, size=wx.DefaultSize, style=wx.TE_READONLY) self.SizerDic["SlaveState_up_sizer"].AddMany([self.StaticTextDic[statictext_name], @@ -241,23 +244,23 @@ @param event : wx.EVT_BUTTON object """ check_connect_flag = self.Controler.CommonMethod.CheckConnect(False) - if check_connect_flag : + if check_connect_flag: state_dic = ["INIT", "PREOP", "SAFEOP", "OP"] # If target state is one of {INIT, PREOP, SAFEOP}, request slave state transition immediately. - if event.GetId() < 3 : + if event.GetId() < 3: self.Controler.CommonMethod.RequestSlaveState(state_dic[event.GetId()]) self.TextCtrlDic["TargetState"].SetValue(state_dic[event.GetId()]) # If target state is OP, first check "PLC status". # (1) If current PLC status is "Started", then request slave state transition # (2) Otherwise, show error message and return - else : + else: status, count = self.Controler.GetCTRoot()._connector.GetPLCstatus() - if status == "Started" : + if status == "Started": self.Controler.CommonMethod.RequestSlaveState("OP") self.TextCtrlDic["TargetState"].SetValue("OP") - else : + else: self.Controler.CommonMethod.CreateErrorDialog("PLC is Not Started") def GetCurrentState(self, event): @@ -269,7 +272,7 @@ if check_connect_flag: returnVal = self.Controler.CommonMethod.GetSlaveStateFromSlave() line = returnVal.split("\n") - try : + try: self.SetCurrentState(line[self.Controler.GetSlavePos()]) except Exception: pass @@ -280,7 +283,7 @@ @param line : result of "ethercat slaves" command """ state_array = ["INIT", "PREOP", "SAFEOP", "OP"] - try : + try: # parse the execution result of "ethercat slaves" command # Result example : 0 0:0 PREOP + EL9800 (V4.30) (PIC24, SPI, ET1100) token = line.split(" ") @@ -359,7 +362,7 @@ # SDOFlag is "False", user click "Cancel" button self.SDOFlag = self.SDOParser() - if self.SDOFlag : + if self.SDOFlag: self.CallSDONoteBook.CreateNoteBook() self.Refresh() @@ -389,7 +392,7 @@ if len(line_token[2]) == 0: title_name = line_token[1] # else case : 0x1000:00,r-r-r-,uint32,32 bit,"Device type",0x00020192, 131474 - else : + else: # line_token = ['0x1000:00,r-r-r-,uint32,32 bit,', 'Device type', ',0x00020192, 131474'] token_head, name, token_tail = line_token @@ -401,7 +404,7 @@ # token_tail = ['', '0x00020192', '131474'] token_tail = token_tail.split(",") - try : + try: empty, hex_val, dec_val = token_tail # SDO data is not return "dec value" @@ -425,7 +428,7 @@ category_divide_value = [0x1000, 0x2000, 0x6000, 0xa000, 0xffff] - for count in range(len(category_divide_value)) : + for count in range(len(category_divide_value)): if int(idx, 0) < category_divide_value[count]: self.Controler.CommonMethod.SaveSDOData[count].append(self.Data) break @@ -457,7 +460,7 @@ result = check_string for i in range(0, len(check_string)): # string.isalnum() is check whether string is alphanumeric or not - if check_string[len(check_string)-1-i:len(check_string)-i] in allow_range : + if check_string[len(check_string)-1-i:len(check_string)-i] in allow_range: result = check_string[:len(check_string) - i] break return result @@ -540,9 +543,9 @@ self.Controler = parent.Controler self.parent = parent self.SDOFlag = True - if data is None : + if data is None: self.SDOs = [] - else : + else: self.SDOs = data self.CreateGrid(len(self.SDOs), 8) @@ -583,7 +586,7 @@ for col_idx in range(len(self.SDOs[row_idx])): self.SetCellValue(row_idx, col_idx, self.SDOs[row_idx][sdo_list[col_idx]]) self.SetReadOnly(row_idx, col_idx, True) - if col_idx < 5 : + if col_idx < 5: self.SetCellAlignment(row_idx, col_idx, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE) def CheckSDODataAccess(self, row): @@ -598,13 +601,13 @@ """ write_flag = False check = self.SDOs[row]['access'] - if check[1:2] == 'w' : + if check[1:2] == 'w': self.Controler.CommonMethod.Check_PREOP = True write_flag = True - if check[3:4] == 'w' : + if check[3:4] == 'w': self.Controler.CommonMethod.Check_SAFEOP = True write_flag = True - if check[5:] == 'w' : + if check[5:] == 'w': self.Controler.CommonMethod.Check_OP = True write_flag = True @@ -619,11 +622,11 @@ """ # Example of 'state' parameter : "0 0:0 PREOP + EL9800 (V4.30) (PIC24, SPI, ET1100)" state = state[self.Controler.GetSlavePos()].split(" ")[2] - if state == "PREOP" and self.Controler.CommonMethod.Check_PREOP : + if state == "PREOP" and self.Controler.CommonMethod.Check_PREOP: return True - elif state == "SAFEOP" and self.Controler.CommonMethod.Check_SAFEOP : + elif state == "SAFEOP" and self.Controler.CommonMethod.Check_SAFEOP: return True - elif state == "OP" and self.Controler.CommonMethod.Check_OP : + elif state == "OP" and self.Controler.CommonMethod.Check_OP: return True return False @@ -646,7 +649,7 @@ self.ClearStateFlag() # CheckSDODataAccess is checking that OD(Object Dictionary) has "w" - if event.GetCol() == 7 and self.CheckSDODataAccess(event.GetRow()) : + if event.GetCol() == 7 and self.CheckSDODataAccess(event.GetRow()): dlg = wx.TextEntryDialog (self, "Enter hex or dec value (if enter dec value, it automatically conversed hex value)", "SDOModifyDialog", style=wx.OK | wx.CANCEL) @@ -654,15 +657,15 @@ dlg.SetValue(start_value) if dlg.ShowModal() == wx.ID_OK: - try : + try: int(dlg.GetValue(), 0) # check "Access" field - if self.DecideSDODownload(self.Controler.CommonMethod.SlaveState[self.Controler.GetSlavePos()]) : + if self.DecideSDODownload(self.Controler.CommonMethod.SlaveState[self.Controler.GetSlavePos()]): # Request "SDODownload" self.Controler.CommonMethod.SDODownload(self.SDOs[event.GetRow()]['type'], self.SDOs[event.GetRow()]['idx'], self.SDOs[event.GetRow()]['subIdx'], dlg.GetValue()) self.SetCellValue(event.GetRow(), event.GetCol(), hex(int(dlg.GetValue(), 0))) - else : + else: self.Controler.CommonMethod.CreateErrorDialog('You cannot SDO download this state') # Error occured process of "int(variable)" # User input is not hex, dec value @@ -758,19 +761,19 @@ self.Controler.CommonMethod.RequestPDOInfo() - if name == "Tx" : + if name == "Tx": # obtain pdo_info and pdo_entry # pdo_info include (PDO index, name, number of entry) pdo_info = self.Controler.CommonMethod.GetTxPDOCategory() pdo_entry = self.Controler.CommonMethod.GetTxPDOInfo() - for tmp in pdo_info : + for tmp in pdo_info: title = str(hex(tmp['pdo_index'])) page_texts.append(title) # RX PDO case - else : + else: pdo_info = self.Controler.CommonMethod.GetRxPDOCategory() pdo_entry = self.Controler.CommonMethod.GetRxPDOInfo() - for tmp in pdo_info : + for tmp in pdo_info: title = str(hex(tmp['pdo_index'])) page_texts.append(title) @@ -846,7 +849,7 @@ """ list_index = 0 # number of entry - for i in range(self.Count + 1) : + for i in range(self.Count + 1): list_index += self.PDOInfo[i]['number_of_entry'] start_value = list_index - self.PDOInfo[self.Count]['number_of_entry'] @@ -855,13 +858,13 @@ for row_idx in range(self.PDOInfo[self.Count]['number_of_entry']): for col_idx in range(len(self.PDOEntry[row_idx])): # entry index is converted hex value. - if col_idx == 0 : + if col_idx == 0: self.SetCellValue(row_idx, col_idx, hex(self.PDOEntry[start_value][pdo_list[col_idx]])) - else : + else: self.SetCellValue(row_idx, col_idx, str(self.PDOEntry[start_value][pdo_list[col_idx]])) - if col_idx != 4 : + if col_idx != 4: self.SetCellAlignment(row_idx, col_idx, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE) - else : + else: self.SetCellAlignment(row_idx, col_idx, wx.ALIGN_LEFT, wx.ALIGN_CENTRE) self.SetReadOnly(row_idx, col_idx, True) self.SetRowSize(row_idx, 25) @@ -906,19 +909,19 @@ self.Controler = controler self.PDIType = { - 0 : ['none', '00000000'], - 4 : ['Digital I/O', '00000100'], - 5 : ['SPI Slave', '00000101'], - 7 : ['EtherCAT Bridge (port3)', '00000111'], - 8 : ['uC async. 16bit', '00001000'], - 9 : ['uC async. 8bit', '00001001'], - 10 : ['uC sync. 16bit', '00001010'], - 11 : ['uC sync. 8bit', '00001011'], - 16 : ['32 Digtal Input and 0 Digital Output', '00010000'], - 17 : ['24 Digtal Input and 8 Digital Output', '00010001'], - 18 : ['16 Digtal Input and 16 Digital Output', '00010010'], - 19 : ['8 Digtal Input and 24 Digital Output', '00010011'], - 20 : ['0 Digtal Input and 32 Digital Output', '00010100'], + 0: ['none', '00000000'], + 4: ['Digital I/O', '00000100'], + 5: ['SPI Slave', '00000101'], + 7: ['EtherCAT Bridge (port3)', '00000111'], + 8: ['uC async. 16bit', '00001000'], + 9: ['uC async. 8bit', '00001001'], + 10: ['uC sync. 16bit', '00001010'], + 11: ['uC sync. 8bit', '00001011'], + 16: ['32 Digtal Input and 0 Digital Output', '00010000'], + 17: ['24 Digtal Input and 8 Digital Output', '00010001'], + 18: ['16 Digtal Input and 16 Digital Output', '00010010'], + 19: ['8 Digtal Input and 24 Digital Output', '00010011'], + 20: ['0 Digtal Input and 32 Digital Output', '00010100'], 128: ['On-chip bus', '11111111'] } @@ -1051,33 +1054,33 @@ """ # sii_dict = { Parameter : (WordAddress, WordSize) } sii_dict = { - 'PDIControl' : ('0', 1), - 'PDIConfiguration' : ('1', 1), - 'PulseLengthOfSYNCSignals' : ('2', 1), - 'ExtendedPDIConfiguration' : ('3', 1), - 'ConfiguredStationAlias' : ('4', 1), - 'Checksum' : ('7', 1), - 'VendorID' : ('8', 2), - 'ProductCode' : ('a', 2), - 'RevisionNumber' : ('c', 2), - 'SerialNumber' : ('e', 2), - 'Execution Delay' : ('10', 1), - 'Port0Delay' : ('11', 1), - 'Port1Delay' : ('12', 1), - 'BootstrapReceiveMailboxOffset' : ('14', 1), - 'BootstrapReceiveMailboxSize' : ('15', 1), - 'BootstrapSendMailboxOffset' : ('16', 1), - 'BootstrapSendMailboxSize' : ('17', 1), - 'StandardReceiveMailboxOffset' : ('18', 1), - 'StandardReceiveMailboxSize' : ('19', 1), - 'StandardSendMailboxOffset' : ('1a', 1), - 'StandardSendMailboxSize' : ('1b', 1), - 'MailboxProtocol' : ('1c', 1), - 'Size' : ('3e', 1), - 'Version' : ('3f', 1), - 'First Category Type/Vendor Specific' : ('40', 1), - 'Following Category Word Size' : ('41', 1), - 'Category Data' : ('42', 1), + 'PDIControl': ('0', 1), + 'PDIConfiguration': ('1', 1), + 'PulseLengthOfSYNCSignals': ('2', 1), + 'ExtendedPDIConfiguration': ('3', 1), + 'ConfiguredStationAlias': ('4', 1), + 'Checksum': ('7', 1), + 'VendorID': ('8', 2), + 'ProductCode': ('a', 2), + 'RevisionNumber': ('c', 2), + 'SerialNumber': ('e', 2), + 'Execution Delay': ('10', 1), + 'Port0Delay': ('11', 1), + 'Port1Delay': ('12', 1), + 'BootstrapReceiveMailboxOffset': ('14', 1), + 'BootstrapReceiveMailboxSize': ('15', 1), + 'BootstrapSendMailboxOffset': ('16', 1), + 'BootstrapSendMailboxSize': ('17', 1), + 'StandardReceiveMailboxOffset': ('18', 1), + 'StandardReceiveMailboxSize': ('19', 1), + 'StandardSendMailboxOffset': ('1a', 1), + 'StandardSendMailboxSize': ('1b', 1), + 'MailboxProtocol': ('1c', 1), + 'Size': ('3e', 1), + 'Version': ('3f', 1), + 'First Category Type/Vendor Specific': ('40', 1), + 'Following Category Word Size': ('41', 1), + 'Category Data': ('42', 1), } # Config Data: EEPROM Size, PDI Type, Device Emulation @@ -1258,8 +1261,8 @@ self.HexRow = 8 self.HexCol = 17 - self.HexViewSizer = {"view" : wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=10), - "siiButton" : wx.BoxSizer()} + self.HexViewSizer = {"view": wx.FlexGridSizer(cols=1, hgap=10, rows=2, vgap=10), + "siiButton": wx.BoxSizer()} self.HexViewButton = {} for key, evt_handler in [("Sii Upload", self.OnButtonSiiUpload), @@ -1728,7 +1731,7 @@ # set data into UI if self.CompactFlag: self.ToggleCompactViewCheckbox(True) - else : + else: for index in range(4): self.RegisterNotebook.RegPage[index].UpdateMainTable(self.MainRow[index], self.MainCol, self.PageRange[index][0], self.PageRange[index][1], @@ -2121,7 +2124,7 @@ self.TextCtrl = {} # ----------------------- Main Sizer and Update Button -------------------------------------------- - self.MasterStateSizer = {"main" : wx.BoxSizer(wx.VERTICAL)} + self.MasterStateSizer = {"main": wx.BoxSizer(wx.VERTICAL)} for key, attr in [ ("innerMain", [1, 10, 2, 10]), ("innerTopHalf", [2, 10, 1, 10]), @@ -2212,5 +2215,5 @@ self.TextCtrl[key][index].SetValue(self.MasterState[key][int(index)]) else: self.TextCtrl[key].SetValue(self.MasterState[key][0]) - else : + else: self.Controler.CommonMethod.CreateErrorDialog('PLC not connected!') diff -r aed3ca79a10a -r cfa68a06a24d etherlab/EthercatCIA402Slave.py --- a/etherlab/EthercatCIA402Slave.py Sat Sep 29 13:04:33 2018 +0300 +++ b/etherlab/EthercatCIA402Slave.py Sat Sep 29 13:29:20 2018 +0300 @@ -112,16 +112,20 @@ EditorType = CIA402NodeEditor ConfNodeMethods = [ - {"bitmap" : "CIA402AxisRef", - "name" : _("Axis Ref"), - "tooltip" : _("Initiate Drag'n drop of Axis ref located variable"), - "method" : "_getCIA402AxisRef", - "push": True}, - {"bitmap" : "CIA402NetPos", - "name" : _("Axis Pos"), - "tooltip" : _("Initiate Drag'n drop of Network position located variable"), - "method" : "_getCIA402NetworkPosition", - "push": True}, + { + "bitmap": "CIA402AxisRef", + "name": _("Axis Ref"), + "tooltip": _("Initiate Drag'n drop of Axis ref located variable"), + "method": "_getCIA402AxisRef", + "push": True, + }, + { + "bitmap": "CIA402NetPos", + "name": _("Axis Pos"), + "tooltip": _("Initiate Drag'n drop of Network position located variable"), + "method": "_getCIA402NetworkPosition", + "push": True, + }, ] # -------------------------------------------------- diff -r aed3ca79a10a -r cfa68a06a24d etherlab/EthercatMaster.py --- a/etherlab/EthercatMaster.py Sat Sep 29 13:04:33 2018 +0300 +++ b/etherlab/EthercatMaster.py Sat Sep 29 13:29:20 2018 +0300 @@ -751,10 +751,12 @@ return LocationCFilesAndCFLAGS, LDFLAGS, extra_files ConfNodeMethods = [ - {"bitmap" : "ScanNetwork", - "name" : _("Scan Network"), - "tooltip" : _("Scan Network"), - "method" : "_ScanNetwork"}, + { + "bitmap": "ScanNetwork", + "name": _("Scan Network"), + "tooltip": _("Scan Network"), + "method": "_ScanNetwork", + }, ] def CTNGenerate_C(self, buildpath, locations): diff -r aed3ca79a10a -r cfa68a06a24d etherlab/EthercatSlave.py --- a/etherlab/EthercatSlave.py Sat Sep 29 13:04:33 2018 +0300 +++ b/etherlab/EthercatSlave.py Sat Sep 29 13:29:20 2018 +0300 @@ -21,13 +21,13 @@ # ------------------------------------------ -TYPECONVERSION = {"BOOL" : "X", "SINT" : "B", "INT" : "W", "DINT" : "D", "LINT" : "L", - "USINT" : "B", "UINT" : "W", "UDINT" : "D", "ULINT" : "L", - "BYTE" : "B", "WORD" : "W", "DWORD" : "D", "LWORD" : "L"} +TYPECONVERSION = {"BOOL": "X", "SINT": "B", "INT": "W", "DINT": "D", "LINT": "L", + "USINT": "B", "UINT": "W", "UDINT": "D", "ULINT": "L", + "BYTE": "B", "WORD": "W", "DWORD": "D", "LWORD": "L"} -DATATYPECONVERSION = {"BOOL" : "BIT", "SINT" : "S8", "INT" : "S16", "DINT" : "S32", "LINT" : "S64", - "USINT" : "U8", "UINT" : "U16", "UDINT" : "U32", "ULINT" : "U64", - "BYTE" : "U8", "WORD" : "U16", "DWORD" : "U32", "LWORD" : "U64"} +DATATYPECONVERSION = {"BOOL": "BIT", "SINT": "S8", "INT": "S16", "DINT": "S32", "LINT": "S64", + "USINT": "U8", "UINT": "U16", "UDINT": "U32", "ULINT": "U64", + "BYTE": "U8", "WORD": "U16", "DWORD": "U32", "LWORD": "U64"} VARCLASSCONVERSION = {"T": LOCATION_VAR_INPUT, "R": LOCATION_VAR_OUTPUT, "RT": LOCATION_VAR_MEMORY} diff -r aed3ca79a10a -r cfa68a06a24d etherlab/runtime_etherlab.py --- a/etherlab/runtime_etherlab.py Sat Sep 29 13:04:33 2018 +0300 +++ b/etherlab/runtime_etherlab.py Sat Sep 29 13:29:20 2018 +0300 @@ -44,7 +44,7 @@ Result = res == 0 SDOAnswered() - if res != 0 : + if res != 0: PLCObject.LogMessage( LogLevelsDict["WARNING"], "%s : %s" % (command, output)) @@ -88,9 +88,9 @@ while not StopKMSGThread: bytes_to_read = klog(3, s, len(s)-1) log = s.value[:bytes_to_read-1] - if last : + if last: log = log.rpartition(last)[2] - if log : + if log: last = log.rpartition('\n')[2] for lvl, msg in re.findall( r'<(\d)>\[\s*\d*\.\d*\]\s*(EtherCAT\s*.*)$',