--- a/etherlab/etherlab.py Wed Feb 01 00:04:58 2012 +0100
+++ b/etherlab/etherlab.py Tue Feb 07 19:45:45 2012 +0100
@@ -382,7 +382,7 @@
data_type = DATATYPECONVERSION.get(entry_infos["var_type"], None)
raise ValueError, _("Type of location \"%s\" not yet supported!") % entry_infos["var_name"]
str_completion["located_variables_declaration"].extend(
["IEC_%(var_type)s beremiz%(var_name)s;" % entry_infos,
"IEC_%(var_type)s *%(var_name)s = &beremiz%(var_name)s;" % entry_infos])
@@ -418,11 +418,11 @@
if entry_infos["dir"] == "I":
str_completion["retrieve_variables"].append(
- (" beremiz%(var_name)s = EC_READ_BIT(domain1_pd + " +
+ (" beremiz%(var_name)s = EC_READ_%(data_type)s(domain1_pd + " + "slave%(slave)d_%(index).4x_%(subindex).2x);") % entry_infos)
elif entry_infos["dir"] == "Q":
str_completion["publish_variables"].append(
- (" EC_WRITE_BIT(domain1_pd + slave%(slave)d_%(index).4x_%(subindex).2x, " +
+ (" EC_WRITE_%(data_type)s(domain1_pd + slave%(slave)d_%(index).4x_%(subindex).2x, " + "beremiz%(var_name)s);") % entry_infos)
@@ -529,61 +529,65 @@
sync_managers.append(sync_manager_infos)
- for pdo, pdo_type in ([(pdo, "Inputs") for pdo in device.getTxPdo()] +
- [(pdo, "Outputs") for pdo in device.getRxPdo()]):
- entries = pdo.getEntry()
- pdo_needed = pdo.getMandatory()
- pdo_index = ExtractHexDecValue(pdo.getIndex().getcontent())
- pdos_index.append(pdo_index)
- index = ExtractHexDecValue(entry.getIndex().getcontent())
- subindex = ExtractHexDecValue(entry.getSubIndex())
- "name": ExtractName(entry.getName()),
- "bitlen": entry.getBitLen(),
- entry_infos.update(type_infos)
- entries_infos.append(" {0x%(index).4x, 0x%(subindex).2x, %(bitlen)d}, /* %(name)s */" % entry_infos)
+ for only_mandatory in [True, False]: + for pdo, pdo_type in ([(pdo, "Inputs") for pdo in device.getTxPdo()] + + [(pdo, "Outputs") for pdo in device.getRxPdo()]): + entries = pdo.getEntry() + pdo_needed = pdo.getMandatory() + if only_mandatory != pdo_needed: - entry_declaration = slave_variables.get((index, subindex), None)
- if entry_declaration is not None:
- entry_infos.update(dict(zip(["var_type", "dir", "var_name"], entry_declaration["infos"])))
- entry_declaration["mapped"] = True
+ pdo_index = ExtractHexDecValue(pdo.getIndex().getcontent()) + pdos_index.append(pdo_index) + index = ExtractHexDecValue(entry.getIndex().getcontent()) + subindex = ExtractHexDecValue(entry.getSubIndex()) + "name": ExtractName(entry.getName()), + "bitlen": entry.getBitLen(), + entry_infos.update(type_infos) + entries_infos.append(" {0x%(index).4x, 0x%(subindex).2x, %(bitlen)d}, /* %(name)s */" % entry_infos) - if entry_infos["var_type"] != entry.getDataType().getcontent():
- raise ValueError, _("Wrong type for location \"%s\"!") % entry_infos["var_name"]
- if (entry_infos["dir"] == "I" and pdo_type != "Inputs" or
- entry_infos["dir"] == "Q" and pdo_type != "Outputs"):
- raise ValueError, _("Wrong direction for location \"%s\"!") % entry_infos["var_name"]
- ConfigureVariable(entry_infos, str_completion)
- for sm_idx, sync_manager in enumerate(sync_managers):
- if sync_manager["Name"] == pdo_type:
- raise ValueError, _("No sync manager available for %s pdo!") % pdo_type
- sync_managers[sm]["pdos_number"] += 1
- sync_managers[sm]["pdos"].append(
- "name": ExtractName(pdo.getName()),
- "entries": entries_infos,
- "entries_number": len(entries_infos),
- "fixed": pdo.getFixed() == True})
+ entry_declaration = slave_variables.get((index, subindex), None) + if entry_declaration is not None and not entry_declaration["mapped"]: + entry_infos.update(dict(zip(["var_type", "dir", "var_name"], entry_declaration["infos"]))) + entry_declaration["mapped"] = True + if entry_infos["var_type"] != entry.getDataType().getcontent(): + raise ValueError, _("Wrong type for location \"%s\"!") % entry_infos["var_name"] + if (entry_infos["dir"] == "I" and pdo_type != "Inputs" or + entry_infos["dir"] == "Q" and pdo_type != "Outputs"): + raise ValueError, _("Wrong direction for location \"%s\"!") % entry_infos["var_name"] + ConfigureVariable(entry_infos, str_completion) + for sm_idx, sync_manager in enumerate(sync_managers): + if sync_manager["name"] == pdo_type: + raise ValueError, _("No sync manager available for %s pdo!") % pdo_type + sync_managers[sm]["pdos_number"] += 1 + sync_managers[sm]["pdos"].append( + "name": ExtractName(pdo.getName()), + "entries": entries_infos, + "entries_number": len(entries_infos), + "fixed": pdo.getFixed() == True}) @@ -712,7 +716,7 @@
profile_content = profile.getcontent()
if profile_content is None:
for content_element in profile_content["value"]:
if content_element["name"] == "Dictionary":
@@ -824,9 +828,9 @@
def GroupItemCompare(x, y):
if x["type"] == y["type"]:
if x["type"] == ETHERCAT_GROUP:
- return x["order"].__cmp__(y["order"])
+ return cmp(x["order"], y["order"]) - return x["name"].__cmp__(y["name"])
+ return cmp(x["name"], y["name"]) elif x["type"] == ETHERCAT_GROUP:
@@ -861,19 +865,21 @@
entry["PDO name"] = pdo_name
entry["PDO type"] = pdo_type
- if pdo_type == "Transmit":
- entries[(index, subindex)] = {
- "SubIndex": entry_subindex,
- "Name": ExtractName(pdo_entry.getName()),
- "Type": pdo_entry.getDataType().getcontent(),
- "PDO index": pdo_index,
+ entry_type = pdo_entry.getDataType() + if entry_type is not None: + if pdo_type == "Transmit": + entries[(index, subindex)] = { + "SubIndex": entry_subindex, + "Name": ExtractName(pdo_entry.getName()), + "Type": entry_type.getcontent(), + "PDO index": pdo_index, @@ -931,8 +937,9 @@
if modules_infos is not None:
vendor = modules_infos.getVendor()
- vendor_category = self.ModulesLibrary.setdefault(vendor.getId(), {"name": ExtractName(vendor.getName(), _("Miscellaneous")),
+ vendor_category = self.ModulesLibrary.setdefault(ExtractHexDecValue(vendor.getId()), + {"name": ExtractName(vendor.getName(), _("Miscellaneous")), for group in modules_infos.getDescriptions().getGroups().getGroup():
group_type = group.getType()
@@ -981,11 +988,11 @@
if len(device_type_occurrences) > 1:
for occurrence in device_type_occurrences:
occurrence["name"] += _(" (rev. %s)") % occurrence["infos"]["revision_number"]
- library.sort(lambda x, y: x["name"].__cmp__(y["name"]))
+ library.sort(lambda x, y: cmp(x["name"], y["name"])) def GetModuleInfos(self, type_infos):
- vendor = self.ModulesLibrary.get(type_infos["vendor"], None)
+ vendor = self.ModulesLibrary.get(ExtractHexDecValue(type_infos["vendor"]), None) for group_name, group in vendor["groups"].iteritems():
for device_type, device in group["devices"]: