--- a/etherlab/CommonEtherCATFunction.py Sat Sep 29 17:52:33 2018 +0300
+++ b/etherlab/CommonEtherCATFunction.py Sat Sep 29 18:59:41 2018 +0300
@@ -195,7 +195,7 @@
"""
# exectute "ethercat master" command
- error, return_val = self.Controler.RemoteExec(MASTER_STATE, return_val=None)
+ _error, return_val = self.Controler.RemoteExec(MASTER_STATE, return_val=None)
master_state = {}
# parse the reslut
for each_line in return_val.splitlines():
@@ -220,7 +220,9 @@
Command example : "ethercat states -p 0 PREOP" (target slave position and target state are given.)
@param command : target slave state
"""
- error, return_val = self.Controler.RemoteExec(SLAVE_STATE % (self.Controler.GetSlavePos(), command), return_val=None)
+ _error, _return_val = self.Controler.RemoteExec(
+ SLAVE_STATE % (self.Controler.GetSlavePos(), command),
+ return_val=None)
def GetSlaveStateFromSlave(self):
"""
@@ -228,7 +230,7 @@
(self.SlaveState) for "Slave State"
return_val example : 0 0:0 PREOP + EL9800 (V4.30) (PIC24, SPI, ET1100)
"""
- error, return_val = self.Controler.RemoteExec(GET_SLAVE, return_val=None)
+ _error, return_val = self.Controler.RemoteExec(GET_SLAVE, return_val=None)
self.SlaveState = return_val
return return_val
@@ -241,7 +243,7 @@
Command example : "ethercat sdos -p 0"
@return return_val : execution results of "ethercat sdos" command (need to be parsed later)
"""
- error, return_val = self.Controler.RemoteExec(SLAVE_SDO % (self.Controler.GetSlavePos()), return_val=None)
+ _error, return_val = self.Controler.RemoteExec(SLAVE_SDO % (self.Controler.GetSlavePos()), return_val=None)
return return_val
def SDODownload(self, data_type, idx, sub_idx, value):
@@ -253,7 +255,9 @@
@param sub_idx : subindex of the SDO entry
@param value : value of SDO entry
"""
- error, return_val = self.Controler.RemoteExec(SDO_DOWNLOAD % (data_type, self.Controler.GetSlavePos(), idx, sub_idx, value), return_val=None)
+ _error, _return_val = self.Controler.RemoteExec(
+ SDO_DOWNLOAD % (data_type, self.Controler.GetSlavePos(), idx, sub_idx, value),
+ return_val=None)
def BackupSDODataSet(self):
"""
@@ -271,7 +275,7 @@
"""
Clear the specified SDO entry information.
"""
- for count in range(6):
+ for dummy in range(6):
self.SaveSDOData.append([])
# -------------------------------------------------------------------------------
@@ -285,7 +289,7 @@
slave = self.Controler.CTNParent.GetSlave(self.Controler.GetSlavePos())
type_infos = slave.getType()
- device, alignment = self.Controler.CTNParent.GetModuleInfos(type_infos)
+ device, _alignment = self.Controler.CTNParent.GetModuleInfos(type_infos)
# Initialize PDO data set
self.ClearDataSet()
@@ -301,7 +305,7 @@
@param device : Slave information extracted from ESI XML file
"""
# Parsing TXPDO entries
- for pdo, pdo_info in ([(pdo, "Inputs") for pdo in device.getTxPdo()]):
+ for pdo, _pdo_info in ([(pdo, "Inputs") for pdo in device.getTxPdo()]):
# Save pdo_index, entry, and name of each entry
pdo_index = ExtractHexDecValue(pdo.getIndex().getcontent())
entries = pdo.getEntry()
@@ -331,7 +335,7 @@
self.TxPDOCategory.append(categorys)
# Parsing RxPDO entries
- for pdo, pdo_info in ([(rxpdo, "Outputs") for rxpdo in device.getRxPdo()]):
+ for pdo, _pdo_info in ([(rxpdo, "Outputs") for rxpdo in device.getRxPdo()]):
# Save pdo_index, entry, and name of each entry
pdo_index = ExtractHexDecValue(pdo.getIndex().getcontent())
entries = pdo.getEntry()
@@ -462,7 +466,7 @@
slave = self.Controler.CTNParent.GetSlave(self.Controler.GetSlavePos())
type_infos = slave.getType()
- device, alignment = self.Controler.CTNParent.GetModuleInfos(type_infos)
+ device, _alignment = self.Controler.CTNParent.GetModuleInfos(type_infos)
# 'device' represents current slave device selected by user
if device is not None:
@@ -558,7 +562,7 @@
Command example : "ethercat sii_read -p 0"
@return return_val : result of "ethercat sii_read" (binary data)
"""
- error, return_val = self.Controler.RemoteExec(SII_READ % (self.Controler.GetSlavePos()), return_val=None)
+ _error, return_val = self.Controler.RemoteExec(SII_READ % (self.Controler.GetSlavePos()), return_val=None)
self.SiiData = return_val
return return_val
@@ -569,7 +573,10 @@
@param binary : EEPROM contents in binary data format
@return return_val : result of "ethercat sii_write" (If it succeeds, the return value is NULL.)
"""
- error, return_val = self.Controler.RemoteExec(SII_WRITE % (self.Controler.GetSlavePos()), return_val=None, sii_data=binary)
+ _error, return_val = self.Controler.RemoteExec(
+ SII_WRITE % (self.Controler.GetSlavePos()),
+ return_val=None,
+ sii_data=binary)
return return_val
def LoadData(self):
@@ -582,7 +589,7 @@
self.Controler.SiiData = self.BinaryCode
# append zero-filled padding data up to EEPROM size
- for index in range(self.SmartViewInfosFromXML["eeprom_size"] - len(self.BinaryCode)):
+ for dummy in range(self.SmartViewInfosFromXML["eeprom_size"] - len(self.BinaryCode)):
self.BinaryCode = self.BinaryCode + 'ff'.decode('hex')
return self.BinaryCode
@@ -642,7 +649,7 @@
eeprom_list = []
if direction is 0 or 1:
- for i in range(length/2):
+ for dummy in range(length/2):
if data == "":
eeprom_list.append("00")
else:
@@ -671,7 +678,7 @@
# 'device' is the slave device of the current EtherCAT slave plugin
slave = self.Controler.CTNParent.GetSlave(self.Controler.GetSlavePos())
type_infos = slave.getType()
- device, alignment = self.Controler.CTNParent.GetModuleInfos(type_infos)
+ device, _alignment = self.Controler.CTNParent.GetModuleInfos(type_infos)
if device is not None:
# get ConfigData for EEPROM offset 0x0000-0x000d; <Device>-<Eeprom>-<ConfigData>
@@ -688,7 +695,7 @@
crc = (crc << 1) | ((int(segment, 16) >> (7 - i)) & 0x01)
if bit:
crc ^= 0x07
- for k in range(8):
+ for dummy in range(8):
bit = crc & 0x80
crc <<= 1
if bit:
@@ -914,7 +921,6 @@
grouptypeflag = True
break
if grouptypeflag is False:
- grouptype = data
count += 1
self.Strings.append(data)
vendor_spec_strings.append(data)
@@ -927,7 +933,7 @@
# element2-2; <EtherCATInfo>-<Groups>-<Group>-<Type>
if grouptypeflag is False:
if self.Controler.CTNParent.CTNParent.ModulesLibrary.Library is not None:
- for vendor_id, vendor in self.Controler.CTNParent.CTNParent.ModulesLibrary.Library.iteritems():
+ for _vendor_id, vendor in self.Controler.CTNParent.CTNParent.ModulesLibrary.Library.iteritems():
for group_type, group_etc in vendor["groups"].iteritems():
for device_item in group_etc["devices"]:
if device == device_item[1]:
@@ -939,7 +945,6 @@
grouptypeflag = True
break
if grouptypeflag is False:
- grouptype = data
count += 1
self.Strings.append(data)
vendor_spec_strings.append(data)
@@ -952,7 +957,7 @@
# element3; <EtherCATInfo>-<Descriptions>-<Groups>-<Group>-<Name(LcId is "1033")>
if self.Controler.CTNParent.CTNParent.ModulesLibrary.Library is not None:
- for vendorId, vendor in self.Controler.CTNParent.CTNParent.ModulesLibrary.Library.iteritems():
+ for _vendorId, vendor in self.Controler.CTNParent.CTNParent.ModulesLibrary.Library.iteritems():
for group_type, group_etc in vendor["groups"].iteritems():
for device_item in group_etc["devices"]:
if device == device_item[1]:
@@ -1015,7 +1020,7 @@
# element5-2; <EtherCATInfo>-<Descriptions>-<Groups>-<Group>-<Image16x14>
if imageflag is False:
if self.Controler.CTNParent.CTNParent.ModulesLibrary.Library is not None:
- for vendor_id, vendor in self.Controler.CTNParent.CTNParent.ModulesLibrary.Library.iteritems():
+ for _vendor_id, vendor in self.Controler.CTNParent.CTNParent.ModulesLibrary.Library.iteritems():
for group_type, group_etc in vendor["groups"].iteritems():
for device_item in group_etc["devices"]:
if device == device_item[1]:
@@ -1136,7 +1141,7 @@
dc_related_elements,
input_elements,
output_elements]:
- for iter in range(len(element)/2):
+ for dummy in range(len(element)/2):
if element == "":
eeprom.append("00")
else:
@@ -1155,7 +1160,6 @@
@return eeprom : "Strings" category EEPROM image data
"""
eeprom = []
- data = ""
# category header
eeprom.append("1e")
@@ -1287,7 +1291,7 @@
else:
eeprom.append("{:0>4x}".format((count)/2)[2:4])
eeprom.append("{:0>4x}".format((count)/2)[0:2])
- for i in range(count):
+ for dummy in range(count):
if data == "":
eeprom.append("00")
else:
@@ -1331,7 +1335,7 @@
# category length
eeprom.append("{:0>4x}".format(len(data)/4)[2:4])
eeprom.append("{:0>4x}".format(len(data)/4)[0:2])
- for i in range(len(data)/2):
+ for dummy in range(len(data)/2):
if data == "":
eeprom.append("00")
else:
@@ -1440,7 +1444,7 @@
eeprom.append("{:0>4x}".format(len(data)/4)[2:4])
eeprom.append("{:0>4x}".format(len(data)/4)[0:2])
data = str(data.lower())
- for i in range(len(data)/2):
+ for dummy in range(len(data)/2):
if data == "":
eeprom.append("00")
else:
@@ -1514,7 +1518,7 @@
eeprom.append("{:0>4x}".format(len(data)/4)[2:4])
eeprom.append("{:0>4x}".format(len(data)/4)[0:2])
data = str(data.lower())
- for i in range(len(data)/2):
+ for dummy in range(len(data)/2):
if data == "":
eeprom.append("00")
else:
@@ -1534,7 +1538,9 @@
@param length : register length
@return return_val : register data
"""
- error, return_val = self.Controler.RemoteExec(REG_READ % (self.Controler.GetSlavePos(), offset, length), return_val=None)
+ _error, return_val = self.Controler.RemoteExec(
+ REG_READ % (self.Controler.GetSlavePos(), offset, length),
+ return_val=None)
return return_val
def RegWrite(self, address, data):
@@ -1545,7 +1551,9 @@
@param data : data to write
@return return_val : the execution result of "ethercat reg_write" (for error check)
"""
- error, return_val = self.Controler.RemoteExec(REG_WRITE % (self.Controler.GetSlavePos(), address, data), return_val=None)
+ _error, return_val = self.Controler.RemoteExec(
+ REG_WRITE % (self.Controler.GetSlavePos(), address, data),
+ return_val=None)
return return_val
def Rescan(self):
@@ -1553,7 +1561,7 @@
Synchronize EEPROM data in master controller with the data in slave device after EEPROM write.
Command example : "ethercat rescan -p 0"
"""
- error, return_val = self.Controler.RemoteExec(RESCAN % (self.Controler.GetSlavePos()), return_val=None)
+ _error, _return_val = self.Controler.RemoteExec(RESCAN % (self.Controler.GetSlavePos()), return_val=None)
# -------------------------------------------------------------------------------
# Common Use Methods
@@ -1567,7 +1575,7 @@
if self.Controler.GetCTRoot()._connector is not None:
# Check connection between the master and the slave.
# Command example : "ethercat xml -p 0"
- error, return_val = self.Controler.RemoteExec(SLAVE_XML % (self.Controler.GetSlavePos()), return_val=None)
+ _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:
--- a/etherlab/ConfigEditor.py Sat Sep 29 17:52:33 2018 +0300
+++ b/etherlab/ConfigEditor.py Sat Sep 29 18:59:41 2018 +0300
@@ -215,7 +215,7 @@
event.Skip()
def OnVariablesGridLeftClick(self, event):
- item, flags, col = self.VariablesGrid.HitTest(event.GetPosition())
+ item, _flags, col = self.VariablesGrid.HitTest(event.GetPosition())
if item.IsOk():
entry = self.VariablesGrid.GetItemPyData(item)
data_type = entry.get("Type", "")
@@ -1165,10 +1165,10 @@
for colname, colsize, colalign in zip(
[_("Name")] + [param_infos["column_label"]
- for param, param_infos in
+ for _param, param_infos in
self.ModuleLibrary.MODULES_EXTRA_PARAMS],
[400] + [param_infos["column_size"]
- for param, param_infos in
+ for _param, param_infos in
self.ModuleLibrary.MODULES_EXTRA_PARAMS],
[wx.ALIGN_LEFT] + [wx.ALIGN_RIGHT] * len(self.ModuleLibrary.MODULES_EXTRA_PARAMS)):
self.ModulesGrid.AddColumn(_(colname), colsize, colalign, edit=True)
@@ -1209,7 +1209,7 @@
item = self.ModulesGrid.AppendItem(root, "")
self.ModulesGrid.SetItemText(item, module["name"], 0)
if module["infos"] is not None:
- for param_idx, (param, param_infos) in enumerate(self.ModuleLibrary.MODULES_EXTRA_PARAMS):
+ for param_idx, (param, _param_infos) in enumerate(self.ModuleLibrary.MODULES_EXTRA_PARAMS):
self.ModulesGrid.SetItemText(item,
str(module["infos"][param]),
param_idx + 1)
@@ -1254,7 +1254,7 @@
def OnDeleteButton(self, event):
filepath = self.GetSelectedFilePath()
if os.path.isfile(filepath):
- folder, filename = os.path.split(filepath)
+ _folder, filename = os.path.split(filepath)
dialog = wx.MessageDialog(self.ParentWindow,
_("Do you really want to delete the file '%s'?") % filename,
@@ -1270,7 +1270,7 @@
event.Skip()
def OnModulesGridLeftDown(self, event):
- item, flags, col = self.ModulesGrid.HitTest(event.GetPosition())
+ item, _flags, col = self.ModulesGrid.HitTest(event.GetPosition())
if item.IsOk():
entry_infos = self.ModulesGrid.GetItemPyData(item)
if entry_infos is not None and col > 0:
@@ -1322,13 +1322,13 @@
event.Veto()
def OnModulesGridHeaderMotion(self, event):
- item, flags, col = self.ModulesGrid.HitTest(event.GetPosition())
+ _item, _flags, col = self.ModulesGrid.HitTest(event.GetPosition())
if col != self.LastToolTipCol and self.LastToolTipCol is not None:
self.ModulesGrid.GetHeaderWindow().SetToolTip(None)
self.LastToolTipCol = None
if col > 0 and self.LastToolTipCol != col:
self.LastToolTipCol = col
- param, param_infos = self.ModuleLibrary.MODULES_EXTRA_PARAMS[col - 1]
+ _param, param_infos = self.ModuleLibrary.MODULES_EXTRA_PARAMS[col - 1]
wx.CallAfter(self.ModulesGrid.GetHeaderWindow().SetToolTipString,
param_infos["description"])
event.Skip()
--- a/etherlab/EtherCATManagementEditor.py Sat Sep 29 17:52:33 2018 +0300
+++ b/etherlab/EtherCATManagementEditor.py Sat Sep 29 18:59:41 2018 +0300
@@ -80,21 +80,6 @@
for spname, spclass in subs:
self.AddSubPage(spclass(self, self.Controler), spname)
- self.Bind(wx.EVT_TREEBOOK_PAGE_CHANGED, self.OnPageChanged)
- self.Bind(wx.EVT_TREEBOOK_PAGE_CHANGING, self.OnPageChanging)
-
- def OnPageChanged(self, event):
- old = event.GetOldSelection()
- new = event.GetSelection()
- sel = event.GetSelection()
- event.Skip()
-
- def OnPageChanging(self, event):
- old = event.GetOldSelection()
- new = event.GetSelection()
- sel = event.GetSelection()
- event.Skip()
-
# -------------------------------------------------------------------------------
# For SlaveState Panel
@@ -256,7 +241,7 @@
# (1) If current PLC status is "Started", then request slave state transition
# (2) Otherwise, show error message and return
else:
- status, count = self.Controler.GetCTRoot()._connector.GetPLCstatus()
+ status, _log_count = self.Controler.GetCTRoot()._connector.GetPLCstatus()
if status == "Started":
self.Controler.CommonMethod.RequestSlaveState("OP")
self.TextCtrlDic["TargetState"].SetValue("OP")
@@ -399,20 +384,20 @@
# token_head = ['0x1000:00', 'r-r-r-', 'uint32', '32 bit', '']
token_head = token_head.split(",")
- ful_idx, access, type, size, empty = token_head
+ ful_idx, access, type, size, _empty = token_head
# ful_idx.split(":") = ['0x1000', '00']
idx, sub_idx = ful_idx.split(":")
# token_tail = ['', '0x00020192', '131474']
token_tail = token_tail.split(",")
try:
- empty, hex_val, dec_val = token_tail
+ _empty, hex_val, _dec_val = token_tail
# SDO data is not return "dec value"
# line example :
# 0x1702:01,rwr-r-,uint32,32 bit," 1st mapping", ----
except Exception:
- empty, hex_val = token_tail
+ _empty, hex_val = token_tail
name_after_check = self.StringTest(name)
@@ -437,9 +422,9 @@
self.Controler.CommonMethod.SaveSDOData[self.AllSDOData].append(self.Data)
if count >= len(self.SDOs.splitlines()) / 2:
- (keep_going, skip) = slaveSDO_progress.Update(count, "Please waiting a moment!!")
+ (keep_going, _skip) = slaveSDO_progress.Update(count, "Please waiting a moment!!")
else:
- (keep_going, skip) = slaveSDO_progress.Update(count)
+ (keep_going, _skip) = slaveSDO_progress.Update(count)
# If user click "Cancel" loop suspend immediately
if not keep_going:
@@ -483,9 +468,6 @@
self.CreateNoteBook()
- self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGED, self.OnPageChanged)
- self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGING, self.OnPageChanging)
-
def CreateNoteBook(self):
"""
Create each NoteBook page, divided SDO index
@@ -501,12 +483,12 @@
("0x6000 - 0x9fff", self.parent.ProfileSpecific),
("0xa000 - 0xffff", self.parent.Reserved)]
- page_tooltip_string = ["SDO Index 0x0000 - 0x0fff : Data Type Description",
- "SDO Index 0x1000 - 0x1fff : Communication object",
- "SDO Index 0x2000 - 0x5fff : Manufacturer specific",
- "SDO Index 0x6000 - 0x9fff : Profile specific",
- "SDO Index 0xa000 - 0xffff : Reserved",
- "All SDO Object"]
+ # page_tooltip_string = ["SDO Index 0x0000 - 0x0fff : Data Type Description",
+ # "SDO Index 0x1000 - 0x1fff : Communication object",
+ # "SDO Index 0x2000 - 0x5fff : Manufacturer specific",
+ # "SDO Index 0x6000 - 0x9fff : Profile specific",
+ # "SDO Index 0xa000 - 0xffff : Reserved",
+ # "All SDO Object"]
self.DeleteAllPages()
@@ -515,18 +497,6 @@
self.Win = SlaveSDOTable(self, self.Data)
self.AddPage(self.Win, txt)
- def OnPageChanged(self, event):
- old = event.GetOldSelection()
- new = event.GetSelection()
- sel = self.GetSelection()
- event.Skip()
-
- def OnPageChanging(self, event):
- old = event.GetOldSelection()
- new = event.GetSelection()
- sel = self.GetSelection()
- event.Skip()
-
# -------------------------------------------------------------------------------
# For SDO Grid (fill index, subindex, etc...)
@@ -734,21 +704,6 @@
self.AddPage(RxWin, "RxPDO")
self.AddPage(TxWin, "TxPDO")
- self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGED, self.OnPageChanged)
- self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGING, self.OnPageChanging)
-
- def OnPageChanged(self, event):
- old = event.GetOldSelection()
- new = event.GetSelection()
- sel = self.GetSelection()
- event.Skip()
-
- def OnPageChanging(self, event):
- old = event.GetOldSelection()
- new = event.GetSelection()
- sel = self.GetSelection()
- event.Skip()
-
# -------------------------------------------------------------------------------
# For PDO Notebook (divide PDO index)
@@ -791,21 +746,6 @@
self.AddPage(win, txt)
count += 1
- self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGED, self.OnPageChanged)
- self.Bind(wx.EVT_CHOICEBOOK_PAGE_CHANGING, self.OnPageChanging)
-
- def OnPageChanged(self, event):
- old = event.GetOldSelection()
- new = event.GetSelection()
- sel = self.GetSelection()
- event.Skip()
-
- def OnPageChanging(self, event):
- old = event.GetOldSelection()
- new = event.GetSelection()
- sel = self.GetSelection()
- event.Skip()
-
# -------------------------------------------------------------------------------
# For PDO Grid (fill entry index, subindex etc...)
@@ -965,7 +905,7 @@
# Check whether beremiz connected or not, and whether status is "Started" or not.
check_connect_flag = self.Controler.CommonMethod.CheckConnect(False)
if check_connect_flag:
- status, count = self.Controler.GetCTRoot()._connector.GetPLCstatus()
+ status, _log_count = self.Controler.GetCTRoot()._connector.GetPLCstatus()
if status is not "Started":
dialog = wx.FileDialog(self, _("Choose a binary file"), os.getcwd(), "", _("bin files (*.bin)|*.bin"), wx.OPEN)
@@ -1334,7 +1274,7 @@
# and whether status is "Started" or not.
check_connect_flag = self.Controler.CommonMethod.CheckConnect(False)
if check_connect_flag:
- status, count = self.Controler.GetCTRoot()._connector.GetPLCstatus()
+ status, _log_count = self.Controler.GetCTRoot()._connector.GetPLCstatus()
if status is not "Started":
self.Controler.CommonMethod.SiiWrite(self.SiiBinary)
self.Controler.CommonMethod.Rescan()
@@ -1830,30 +1770,16 @@
# Initialize pages
self.RegPage = []
- for iter in range(4):
+ pages = 4
+ for dummy in range(pages):
self.RegPage.append(None)
- for index in range(4):
+ for index in range(pages):
self.RegPage[index] = RegisterNotebookPanel(self, self.Controler,
parent.MainRow[index], parent.MainCol)
self.AddPage(self.RegPage[index],
"0x"+"{:0>4x}".format(index*1024)+" - 0x"+"{:0>4x}".format((index+1)*1024-1))
- self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
- self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnPageChanging)
-
- def OnPageChanged(self, event):
- old = event.GetOldSelection()
- new = event.GetSelection()
- sel = self.GetSelection()
- event.Skip()
-
- def OnPageChanging(self, event):
- old = event.GetOldSelection()
- new = event.GetSelection()
- sel = self.GetSelection()
- event.Skip()
-
# -------------------------------------------------------------------------------
# For Register Access Notebook Panel
--- a/etherlab/EthercatCIA402Slave.py Sat Sep 29 17:52:33 2018 +0300
+++ b/etherlab/EthercatCIA402Slave.py Sat Sep 29 18:59:41 2018 +0300
@@ -16,7 +16,7 @@
from PLCControler import LOCATION_CONFNODE, LOCATION_VAR_INPUT
-from MotionLibrary import Headers, AxisXSD
+from MotionLibrary import AxisXSD
from etherlab.EthercatSlave import _EthercatSlaveCTN, _CommonSlave
from etherlab.ConfigEditor import CIA402NodeEditor
@@ -205,7 +205,6 @@
location_str = "_".join(map(str, current_location))
slave_pos = self.GetSlavePos()
- MCL_headers = Headers
# Open CIA402 node code template file
plc_cia402node_filepath = os.path.join(os.path.split(__file__)[0],
@@ -241,13 +240,25 @@
return_outputs = "\n".join([
"""\
- __SET_VAR(data__->,%(output_name)s,,
- __GET_VAR(%(blockname)s->%(output_name)s));""" % locals()
+ __SET_VAR(data__->,%(output_name)s,,
+ __GET_VAR(%(blockname)s->%(output_name)s));""" % {
+ "output_name": output_name,
+ "blockname": blockname
+ }
for output_name in ["DONE", "BUSY", "ERROR"] + [
output["name"].upper()
for output in blocktype_infos["outputs"]]
])
+ loc_dict = {
+ "ucase_blocktype": ucase_blocktype,
+ "blocktype": blocktype,
+ "blockname": blockname,
+ "location_str": location_str,
+ "extract_inputs": extract_inputs,
+ "return_outputs": return_outputs,
+ }
+
fieldbus_interface_declaration.append("""
extern void ETHERLAB%(ucase_blocktype)s_body__(ETHERLAB%(ucase_blocktype)s* data__);
void __%(blocktype)s_%(location_str)s(MC_%(ucase_blocktype)s *data__) {
@@ -257,11 +268,11 @@
%(extract_inputs)s
ETHERLAB%(ucase_blocktype)s_body__(%(blockname)s);
%(return_outputs)s
-}""" % locals())
+}""" % loc_dict)
fieldbus_interface_definition.append("""\
AxsPub.axis->__mcl_func_MC_%(blocktype)s = __%(blocktype)s_%(location_str)s;\
-""" % locals())
+""" % loc_dict)
# Get a copy list of default variables to map
variables = NODE_VARIABLES[:]
@@ -288,14 +299,16 @@
variables.append(variable_infos["description"])
# Add code to publish or retrive variable
- for var_exchange_dir, str_list, default_template in [
- ("retrieve", extra_variables_retrieve,
- " AxsPub.axis->%(var_name)s = *(AxsPub.%(var_name)s);"),
- ("publish", extra_variables_publish,
- " *(AxsPub.%(var_name)s) = AxsPub.axis->%(var_name)s;")]:
-
- template = variable_infos.get(var_exchange_dir,
- default_template)
+ coded = [
+ ("retrieve",
+ extra_variables_retrieve,
+ " AxsPub.axis->%(var_name)s = *(AxsPub.%(var_name)s);"),
+ ("publish",
+ extra_variables_publish,
+ " *(AxsPub.%(var_name)s) = AxsPub.axis->%(var_name)s;")
+ ]
+ for var_exchange_dir, _str_list, default_template in coded:
+ template = variable_infos.get(var_exchange_dir, default_template)
if template is not None:
extra_variables_publish.append(template % locals())
@@ -306,21 +319,30 @@
else str(param["value"]))
init_axis_params.append("""\
- AxsPub.axis->%(param_name)s = %(param_value)s;""" % locals())
+ AxsPub.axis->%(param_name)s = %(param_value)s;""" % {"param_value": param_value})
# Add each variable in list of variables to map to master list of
# variables to add to network configuration
for name, index, subindex, var_type, dir in variables:
var_size = self.GetSizeOfType(var_type)
+ loc_dict = {
+ "var_size": var_size,
+ "var_type": var_type,
+ "name:": name,
+ "location_str": location_str,
+ "index": index,
+ "subindex": subindex,
+ }
var_name = """\
-__%(dir)s%(var_size)s%(location_str)s_%(index)d_%(subindex)d""" % locals()
+__%(dir)s%(var_size)s%(location_str)s_%(index)d_%(subindex)d""" % loc_dict
+ loc_dict["var_name"] = var_name
extern_located_variables_declaration.append(
- "IEC_%(var_type)s *%(var_name)s;" % locals())
+ "IEC_%(var_type)s *%(var_name)s;" % loc_dict)
entry_variables.append(
- " IEC_%(var_type)s *%(name)s;" % locals())
+ " IEC_%(var_type)s *%(name)s;" % loc_dict)
init_entry_variables.append(
- " AxsPub.%(name)s = %(var_name)s;" % locals())
+ " AxsPub.%(name)s = %(var_name)s;" % loc_dict)
self.CTNParent.FileGenerator.DeclareVariable(
slave_pos, index, subindex, var_type, dir, var_name)
--- a/etherlab/EthercatMaster.py Sat Sep 29 17:52:33 2018 +0300
+++ b/etherlab/EthercatMaster.py Sat Sep 29 18:59:41 2018 +0300
@@ -93,7 +93,6 @@
ethelabfile.write(etherlab_ext_code)
ethelabfile.close()
- runtimefile_path = os.path.join(os.path.split(__file__)[0], "runtime_etherlab.py")
return ((["etherlab_ext"], [(Gen_etherlabfile_path, IECCFLAGS)], True), "",
("runtime_etherlab.py", file(GetLocalPath("runtime_etherlab.py"))))
@@ -304,7 +303,7 @@
self.GetSlaveTypesLibrary())
if dialog.ShowModal() == wx.ID_OK:
type_infos = dialog.GetValueInfos()
- device, module_extra_params = self.GetModuleInfos(type_infos)
+ device, _module_extra_params = self.GetModuleInfos(type_infos)
if device is not None:
if HAS_MCL and _EthercatCIA402SlaveCTN.NODE_PROFILE in device.GetProfileNumbers():
ConfNodeType = "EthercatCIA402Slave"
@@ -335,7 +334,7 @@
type_infos = slave.getType()
if vendor is not None and ExtractHexDecValue(type_infos["vendor"]) != vendor:
return False
- device, module_extra_params = self.GetModuleInfos(type_infos)
+ device, _module_extra_params = self.GetModuleInfos(type_infos)
if slave_profile is not None and slave_profile not in device.GetProfileNumbers():
return False
return True
@@ -474,7 +473,7 @@
"product_code": slave["product_code"],
"revision_number": slave["revision_number"],
}
- device, module_extra_params = self.GetModuleInfos(type_infos)
+ device, _module_extra_params = self.GetModuleInfos(type_infos)
if device is not None:
if HAS_MCL and _EthercatCIA402SlaveCTN.NODE_PROFILE in device.GetProfileNumbers():
CTNType = "EthercatCIA402Slave"
@@ -568,7 +567,7 @@
slave = self.GetSlave(slave_pos)
if slave is not None:
type_infos = slave.getType()
- device, module_extra_params = self.GetModuleInfos(type_infos)
+ device, _module_extra_params = self.GetModuleInfos(type_infos)
if device is not None:
infos = type_infos.copy()
infos.update({"physics": device.getPhysics(),
@@ -582,7 +581,7 @@
slave = self.GetSlave(slave_pos)
if slave is not None:
type_infos = slave.getType()
- device, module_extra_params = self.GetModuleInfos(type_infos)
+ device, _module_extra_params = self.GetModuleInfos(type_infos)
if device is not None:
entries = device.GetEntriesList(limits)
entries_list = entries.items()
@@ -590,7 +589,7 @@
entries = []
current_index = None
current_entry = {}
- for (index, subindex), entry in entries_list:
+ for (index, _subindex), entry in entries_list:
entry["children"] = []
if slave_pos is not None:
entry["Position"] = str(slave_pos)
@@ -608,7 +607,7 @@
def GetSlaveVariableDataType(self, slave_pos, index, subindex):
slave = self.GetSlave(slave_pos)
if slave is not None:
- device, module_extra_params = self.GetModuleInfos(slave.getType())
+ device, _module_extra_params = self.GetModuleInfos(slave.getType())
if device is not None:
entries = device.GetEntriesList()
entry_infos = entries.get((index, subindex))
@@ -625,7 +624,7 @@
type_infos = slave.getType()
if vendor is not None and ExtractHexDecValue(type_infos["vendor"]) != vendor:
continue
- device, module_extra_params = self.GetModuleInfos(type_infos)
+ device, _module_extra_params = self.GetModuleInfos(type_infos)
if slave_profile is not None and slave_profile not in device.GetProfileNumbers():
continue
entries.extend(self.GetSlaveVariables(slave_position, limits, device))
@@ -646,7 +645,7 @@
if slave is not None:
type_infos = slave.getType()
- device, module_extra_params = self.GetModuleInfos(type_infos)
+ device, _module_extra_params = self.GetModuleInfos(type_infos)
if device is not None:
sync_managers = []
for sync_manager in device.getSm():
--- a/etherlab/etherlab.py Sat Sep 29 17:52:33 2018 +0300
+++ b/etherlab/etherlab.py Sat Sep 29 18:59:41 2018 +0300
@@ -320,7 +320,7 @@
vendor = ExtractHexDecValue(module_infos["vendor"])
vendor_infos = self.Library.get(vendor)
if vendor_infos is not None:
- for group_name, group_infos in vendor_infos["groups"].iteritems():
+ for _group_name, group_infos in vendor_infos["groups"].iteritems():
for device_type, device_infos in group_infos["devices"]:
product_code = ExtractHexDecValue(device_infos.getType().getProductCode())
revision_number = ExtractHexDecValue(device_infos.getType().getRevisionNo())
@@ -354,7 +354,7 @@
has_header = False
else:
params_values = {}
- for (param, param_infos), value in zip(
+ for (param, _param_infos), value in zip(
self.MODULES_EXTRA_PARAMS, row[3:]):
if value != "":
params_values[param] = int(value)
@@ -364,7 +364,7 @@
def SaveModulesExtraParams(self):
csvfile = open(self.GetModulesExtraParamsFilePath(), "wb")
- extra_params = [param for param, params_infos in self.MODULES_EXTRA_PARAMS]
+ extra_params = [param for param, _params_infos in self.MODULES_EXTRA_PARAMS]
writer = csv.writer(csvfile, delimiter=';')
writer.writerow(['Vendor', 'product_code', 'revision_number'] + extra_params)
for (vendor, product_code, revision_number), module_extra_params in self.ModulesExtraParams.iteritems():