--- a/etherlab/CommonEtherCATFunction.py Fri Sep 28 18:00:50 2018 +0300
+++ b/etherlab/CommonEtherCATFunction.py Fri Sep 28 18:04:28 2018 +0300
@@ -13,6 +13,7 @@
mailbox_protocols = ["AoE", "EoE", "CoE", "FoE", "SoE", "VoE"]
+
def ExtractHexDecValue(value):
"""
convert numerical value in string format into decimal or hex format.
@@ -29,6 +30,7 @@
except Exception:
raise ValueError, "Invalid value for HexDecValue \"%s\"" % value
+
def ExtractName(names, default=None):
"""
Extract "name" field from XML entries.
@@ -136,6 +138,7 @@
returnVal =result
"""
+
# --------------------------------------------------
# Common Method For EtherCAT Management
# --------------------------------------------------
--- a/etherlab/ConfigEditor.py Fri Sep 28 18:00:50 2018 +0300
+++ b/etherlab/ConfigEditor.py Fri Sep 28 18:04:28 2018 +0300
@@ -30,12 +30,14 @@
[ETHERCAT_VENDOR, ETHERCAT_GROUP, ETHERCAT_DEVICE] = range(3)
+
def AppendMenu(parent, help, id, kind, text):
if wx.VERSION >= (2, 6, 0):
parent.Append(help=help, id=id, kind=kind, text=text)
else:
parent.Append(helpString=help, id=id, kind=kind, item=text)
+
def GetVariablesTableColnames(position=False):
_ = lambda x : x
colname = ["#"]
@@ -48,6 +50,7 @@
'wo': 'W',
'rw': 'R/W'}
+
def GetAccessValue(access, pdo_mapping):
value = "SDO: %s" % ACCESS_TYPES.get(access, "")
if pdo_mapping != "":
@@ -66,6 +69,7 @@
ETHERCAT_SUBINDEX_MODEL = re.compile("#x([0-9a-fA-F]{0,2})$")
LOCATION_MODEL = re.compile("(?:%[IQM](?:[XBWLD]?([0-9]+(?:\.[0-9]+)*)))$")
+
class NodeVariablesSizer(wx.FlexGridSizer):
def __init__(self, parent, controler, position_column=False):
@@ -252,6 +256,7 @@
event.Skip()
+
class NodeEditor(ConfTreeNodeEditor):
CONFNODEEDITOR_TABS = [
@@ -333,6 +338,7 @@
_("Write to (nodeid, index, subindex)"),
_("Description")]
+
class ProcessVariablesTable(CustomTable):
def GetValue(self, row, col):
@@ -386,6 +392,7 @@
self.ResizeRow(grid, row)
+
class ProcessVariableDropTarget(wx.TextDropTarget):
def __init__(self, parent):
@@ -445,10 +452,12 @@
message.ShowModal()
message.Destroy()
+
def GetStartupCommandsTableColnames():
_ = lambda x : x
return [_("Position"), _("Index"), _("Subindex"), _("Value"), _("Description")]
+
class StartupCommandDropTarget(wx.TextDropTarget):
def __init__(self, parent):
@@ -495,6 +504,7 @@
message.ShowModal()
message.Destroy()
+
class StartupCommandsTable(CustomTable):
"""
@@ -567,6 +577,7 @@
return row
return None
+
class MasterNodesVariablesSizer(NodeVariablesSizer):
def __init__(self, parent, controler):
@@ -586,6 +597,7 @@
NODE_POSITION_FILTER_FORMAT = _("Node Position: %d")
+
class MasterEditor(ConfTreeNodeEditor):
CONFNODEEDITOR_TABS = [
@@ -1081,6 +1093,7 @@
# self.FrameLoss2.SetValue(self.MasterState["frameloss2"])
# self.FrameLoss3.SetValue(self.MasterState["frameloss3"])
+
class LibraryEditorSizer(wx.FlexGridSizer):
def __init__(self, parent, module_library, buttons):
@@ -1316,6 +1329,7 @@
param_infos["description"])
event.Skip()
+
class DatabaseManagementDialog(wx.Dialog):
def __init__(self, parent, database):
@@ -1347,6 +1361,7 @@
def GetValue(self):
return self.DatabaseSizer.GetSelectedFilePath()
+
class LibraryEditor(ConfTreeNodeEditor):
CONFNODEEDITOR_TABS = [
--- a/etherlab/EtherCATManagementEditor.py Fri Sep 28 18:00:50 2018 +0300
+++ b/etherlab/EtherCATManagementEditor.py Fri Sep 28 18:04:28 2018 +0300
@@ -27,6 +27,7 @@
from xml.dom import minidom
# -------------------------------------------------------------
+
# ----------------------------- For Sync Manager Table -----------------------------------
def GetSyncManagersTableColnames():
"""
@@ -35,6 +36,7 @@
_ = lambda x : x
return ["#", _("Name"), _("Start Address"), _("Default Size"), _("Control Byte"), _("Enable")]
+
# -------------------------------------------------------------------------------
# Sync Managers Table
# -------------------------------------------------------------------------------
@@ -45,6 +47,7 @@
return row
return self.data[row].get(self.GetColLabelValue(col, False), "")
+
# -------------------------------------------------------------------------------
# EtherCAT Management Treebook
# -------------------------------------------------------------------------------
@@ -91,6 +94,7 @@
sel = event.GetSelection()
event.Skip()
+
# -------------------------------------------------------------------------------
# For SlaveState Panel
# -------------------------------------------------------------------------------
@@ -306,6 +310,7 @@
except Exception:
pass
+
# -------------------------------------------------------------------------------
# For SDO Management Panel
# -------------------------------------------------------------------------------
@@ -518,6 +523,7 @@
sel = self.GetSelection()
event.Skip()
+
# -------------------------------------------------------------------------------
# For SDO Grid (fill index, subindex, etc...)
# -------------------------------------------------------------------------------
--- a/etherlab/EthercatCFileGenerator.py Fri Sep 28 18:00:50 2018 +0300
+++ b/etherlab/EthercatCFileGenerator.py Fri Sep 28 18:04:28 2018 +0300
@@ -68,6 +68,7 @@
}
"""
+
def ConfigureVariable(entry_infos, str_completion):
entry_infos["data_type"] = DATATYPECONVERSION.get(entry_infos["var_type"], None)
if entry_infos["data_type"] is None:
@@ -124,6 +125,7 @@
(" EC_WRITE_%(data_type)s(domain1_pd + slave%(slave)d_%(index).4x_%(subindex).2x, " +
"%(real_var)s);") % entry_infos)
+
def ExclusionSortFunction(x, y):
if x["matching"] == y["matching"]:
if x["assigned"] and not y["assigned"]:
@@ -133,6 +135,7 @@
return cmp(x["count"], y["count"])
return -cmp(x["matching"], y["matching"])
+
class _EthercatCFileGenerator:
def __init__(self, controler):
--- a/etherlab/EthercatCIA402Slave.py Fri Sep 28 18:00:50 2018 +0300
+++ b/etherlab/EthercatCIA402Slave.py Fri Sep 28 18:04:28 2018 +0300
@@ -93,6 +93,7 @@
# Ethercat CIA402 Node
# --------------------------------------------------
+
class _EthercatCIA402SlaveCTN(_EthercatSlaveCTN):
XSD = """<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
--- a/etherlab/EthercatMaster.py Fri Sep 28 18:00:50 2018 +0300
+++ b/etherlab/EthercatMaster.py Fri Sep 28 18:04:28 2018 +0300
@@ -68,9 +68,11 @@
# Etherlab Specific Blocks Library
# --------------------------------------------------
+
def GetLocalPath(filename):
return os.path.join(os.path.split(__file__)[0], filename)
+
class EtherlabLibrary(POULibrary):
def GetLibraryPath(self):
return GetLocalPath("pous.xml")
@@ -95,6 +97,7 @@
EtherCATConfigParser = GenerateParserFromXSD(os.path.join(os.path.dirname(__file__), "EtherCATConfig.xsd"))
+
def sort_commands(x, y):
if x["Index"] == y["Index"]:
return cmp(x["Subindex"], y["Subindex"])
@@ -220,6 +223,7 @@
ProcessVariablesParser = GenerateParserFromXSDstring(ProcessVariablesXSD)
+
class _EthercatCTN:
CTNChildrenTypes = [("EthercatSlave", _EthercatSlaveCTN, "Ethercat Slave")]
--- a/etherlab/EthercatSlave.py Fri Sep 28 18:00:50 2018 +0300
+++ b/etherlab/EthercatSlave.py Fri Sep 28 18:04:28 2018 +0300
@@ -31,6 +31,7 @@
VARCLASSCONVERSION = {"T": LOCATION_VAR_INPUT, "R": LOCATION_VAR_OUTPUT, "RT": LOCATION_VAR_MEMORY}
+
def ExtractHexDecValue(value):
try:
return int(value)
@@ -41,6 +42,7 @@
except Exception:
raise ValueError, "Invalid value for HexDecValue \"%s\"" % value
+
def GenerateHexDecValue(value, base=10):
if base == 10:
return str(value)
@@ -49,6 +51,7 @@
else:
raise ValueError, "Not supported base"
+
def ExtractName(names, default=None):
if len(names) == 1:
return names[0].getcontent()
--- a/etherlab/etherlab.py Fri Sep 28 18:00:50 2018 +0300
+++ b/etherlab/etherlab.py Fri Sep 28 18:04:28 2018 +0300
@@ -34,9 +34,11 @@
EtherCATInfoParser = GenerateParserFromXSD(os.path.join(os.path.dirname(__file__), "EtherCATInfo.xsd"))
EtherCATInfo_XPath = lambda xpath: etree.XPath(xpath)
+
def HexDecValue(context, *args):
return str(ExtractHexDecValue(args[0][0]))
+
def EntryName(context, *args):
return ExtractName(args[0],
args[1][0] if len(args) > 1 else None)
@@ -53,6 +55,7 @@
("PDO name", str, ""),
("PDO type", str, "")]
+
class EntryListFactory:
def __init__(self, entries):
@@ -128,6 +131,7 @@
return sync_managers
setattr(cls, "GetSyncManagers", GetSyncManagers)
+
def GroupItemCompare(x, y):
if x["type"] == y["type"]:
if x["type"] == ETHERCAT_GROUP:
@@ -138,12 +142,14 @@
return -1
return 1
+
def SortGroupItems(group):
for item in group["children"]:
if item["type"] == ETHERCAT_GROUP:
SortGroupItems(item)
group["children"].sort(GroupItemCompare)
+
class ModulesLibrary:
MODULES_EXTRA_PARAMS = [
@@ -384,6 +390,7 @@
ModulesDatabase = ModulesLibrary(
os.path.join(USERDATA_DIR, "ethercat_modules"))
+
class RootClass:
CTNChildrenTypes = [("EthercatNode",_EthercatCTN,"Ethercat Master")]
--- a/etherlab/runtime_etherlab.py Fri Sep 28 18:00:50 2018 +0300
+++ b/etherlab/runtime_etherlab.py Fri Sep 28 18:04:28 2018 +0300
@@ -16,6 +16,7 @@
SDOProc = None
Result = None
+
def SDOThreadProc(*params):
global Result, SDOProc
if params[0] == "upload":
@@ -48,22 +49,27 @@
LogLevelsDict["WARNING"],
"%s : %s" % (command,output))
+
def EthercatSDOUpload(pos, index, subindex, var_type):
global SDOThread
SDOThread = Thread(target=SDOThreadProc, args=["upload", pos, var_type, index, subindex])
SDOThread.start()
+
def EthercatSDODownload(pos, index, subindex, var_type, value):
global SDOThread
SDOThread = Thread(target=SDOThreadProc, args=["download", pos, var_type, index, subindex, value])
SDOThread.start()
+
def GetResult():
global Result
return Result
KMSGPollThread=None
StopKMSGThread=False
+
+
def KMSGPollThreadProc():
"""
Logs Kernel messages starting with EtherCAT
@@ -95,12 +101,14 @@
msg)
time.sleep(0.5)
+
def _runtime_etherlab_init():
global KMSGPollThread, StopKMSGThread
StopKMSGThread = False
KMSGPollThread = Thread(target = KMSGPollThreadProc)
KMSGPollThread.start()
+
def _runtime_etherlab_cleanup():
global KMSGPollThread, StopKMSGThread, SDOProc, SDOThread
try: