--- 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 @@
for each_line in return_val.splitlines():
- if len(each_line) > 0 :
chunks = each_line.strip().split(':', 1)
value = chunks[1].split()
if '(attached)' in value:
value.remove('(attached)')
@@ -290,7 +290,7 @@
# if 'device' object is valid, call SavePDOData() to parse PDO data
- if device is not None :
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:
- "name" : ExtractName(entry.getName()),
- "bitlen" : entry.getBitLen(),
- "type" : entry.getDataType().getcontent()
+ "name": ExtractName(entry.getName()), + "bitlen": entry.getBitLen(), + "type": entry.getDataType().getcontent() self.TxPDOInfo.append(entry_infos)
- 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)
@@ -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:
- "name" : ExtractName(entry.getName()),
- "bitlen" : str(entry.getBitLen()),
- "type" : entry.getDataType().getcontent()
+ "name": ExtractName(entry.getName()), + "bitlen": str(entry.getBitLen()), + "type": entry.getDataType().getcontent() self.RxPDOInfo.append(entry_infos)
- 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 @@
- for index in range(0, len(binary)) :
+ for index in range(0, len(binary)): if len(binary[index]) != 1:
@@ -617,7 +617,7 @@
row_text = row_text + "."
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;
for bit, mbprot in enumerate(mailbox_protocols):
if getattr(mb, "get%s" % mbprot)() is not None:
@@ -1179,7 +1179,7 @@
coe_details = 1 # sdo enabled
for bit, flag in enumerate(["SdoInfo", "PdoAssign", "PdoConfig",
@@ -1208,9 +1208,9 @@
# DS402Channels; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<CoE>: DS402Channels
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 len(number_of_lines) <= 2: # No slave connected to the master controller self.CreateErrorDialog('No connected slaves')
- elif len(number_of_lines) > 2 :
+ elif len(number_of_lines) > 2: # The master controller is not connected to Beremiz host
self.CreateErrorDialog('PLC not connected!')
--- 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.
return ["#", _("Name"), _("Start Address"), _("Default Size"), _("Control Byte"), _("Enable")]
@@ -117,13 +118,13 @@
# iniitalize BoxSizer and FlexGridSizer
- "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")])]:
+ ("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 :
state_dic = ["INIT", "PREOP", "SAFEOP", "OP"]
# If target state is one of {INIT, PREOP, SAFEOP}, request slave state transition immediately.
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
status, count = self.Controler.GetCTRoot()._connector.GetPLCstatus()
- if status == "Started" :
+ if status == "Started": self.Controler.CommonMethod.RequestSlaveState("OP")
self.TextCtrlDic["TargetState"].SetValue("OP")
self.Controler.CommonMethod.CreateErrorDialog("PLC is Not Started")
def GetCurrentState(self, event):
@@ -269,7 +272,7 @@
returnVal = self.Controler.CommonMethod.GetSlaveStateFromSlave()
line = returnVal.split("\n")
self.SetCurrentState(line[self.Controler.GetSlavePos()])
@@ -280,7 +283,7 @@
@param line : result of "ethercat slaves" command
state_array = ["INIT", "PREOP", "SAFEOP", "OP"]
# parse the execution result of "ethercat slaves" command
# Result example : 0 0:0 PREOP + EL9800 (V4.30) (PIC24, SPI, ET1100)
@@ -359,7 +362,7 @@
# SDOFlag is "False", user click "Cancel" button
self.SDOFlag = self.SDOParser()
self.CallSDONoteBook.CreateNoteBook()
@@ -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
# 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(",")
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)
@@ -457,7 +460,7 @@
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]
@@ -540,9 +543,9 @@
self.Controler = parent.Controler
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)
self.SetCellAlignment(row_idx, col_idx, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
def CheckSDODataAccess(self, row):
@@ -598,13 +601,13 @@
check = self.SDOs[row]['access']
self.Controler.CommonMethod.Check_PREOP = True
self.Controler.CommonMethod.Check_SAFEOP = True
self.Controler.CommonMethod.Check_OP = 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: - elif state == "SAFEOP" and self.Controler.CommonMethod.Check_SAFEOP :
+ elif state == "SAFEOP" and self.Controler.CommonMethod.Check_SAFEOP: - elif state == "OP" and self.Controler.CommonMethod.Check_OP :
+ elif state == "OP" and self.Controler.CommonMethod.Check_OP: @@ -646,7 +649,7 @@
# 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:
- if self.DecideSDODownload(self.Controler.CommonMethod.SlaveState[self.Controler.GetSlavePos()]) :
+ if self.DecideSDODownload(self.Controler.CommonMethod.SlaveState[self.Controler.GetSlavePos()]): 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)))
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()
# 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()
title = str(hex(tmp['pdo_index']))
pdo_info = self.Controler.CommonMethod.GetRxPDOCategory()
pdo_entry = self.Controler.CommonMethod.GetRxPDOInfo()
title = str(hex(tmp['pdo_index']))
@@ -846,7 +849,7 @@
- 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.
self.SetCellValue(row_idx, col_idx, hex(self.PDOEntry[start_value][pdo_list[col_idx]]))
self.SetCellValue(row_idx, col_idx, str(self.PDOEntry[start_value][pdo_list[col_idx]]))
self.SetCellAlignment(row_idx, col_idx, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
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
- 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) }
- 'PDIControl' : ('0', 1),
- 'PDIConfiguration' : ('1', 1),
- 'PulseLengthOfSYNCSignals' : ('2', 1),
- 'ExtendedPDIConfiguration' : ('3', 1),
- 'ConfiguredStationAlias' : ('4', 1),
- '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),
- '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), + '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), + '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.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()} for key, evt_handler in [("Sii Upload", self.OnButtonSiiUpload),
@@ -1728,7 +1731,7 @@
self.ToggleCompactViewCheckbox(True)
self.RegisterNotebook.RegPage[index].UpdateMainTable(self.MainRow[index], self.MainCol,
self.PageRange[index][0], self.PageRange[index][1],
@@ -2121,7 +2124,7 @@
# ----------------------- Main Sizer and Update Button --------------------------------------------
- self.MasterStateSizer = {"main" : wx.BoxSizer(wx.VERTICAL)}
+ self.MasterStateSizer = {"main": wx.BoxSizer(wx.VERTICAL)} ("innerMain", [1, 10, 2, 10]),
("innerTopHalf", [2, 10, 1, 10]),
@@ -2212,5 +2215,5 @@
self.TextCtrl[key][index].SetValue(self.MasterState[key][int(index)])
self.TextCtrl[key].SetValue(self.MasterState[key][0])
self.Controler.CommonMethod.CreateErrorDialog('PLC not connected!')