Added support for module extra params in EthercatCFileGenerator
authorLaurent Bessard
Mon, 29 Apr 2013 11:03:06 +0200
changeset 2139 1565239349a8
parent 2138 79dc2d15c580
child 2140 56643934495c
Added support for module extra params in EthercatCFileGenerator
etherlab/EthercatCFileGenerator.py
etherlab/etherlab.py
--- a/etherlab/EthercatCFileGenerator.py	Fri Apr 26 23:23:09 2013 +0200
+++ b/etherlab/EthercatCFileGenerator.py	Mon Apr 29 11:03:06 2013 +0200
@@ -322,6 +322,11 @@
                                 if slave_variables.get((index, subindex), None) is not None:
                                     pdo_mapping_match["matching"] += 1
                         
+                            if pdo.getFixed() == True:
+                                pdo_mapping_match["matching"] += \
+                                    module_extra_params["max_pdo_size"] - \
+                                    pdo_mapping_match["count"]
+                        
                         elif pdo.getMandatory():
                             selected_pdos.append(pdo_index)
                     
@@ -332,7 +337,9 @@
                         if exclusion_scope[0]["matching"] > 0:
                             selected_pdos.append(exclusion_scope[0]["index"])
                             start_excluding_index = 1
-                        excluded_pdos.extend([pdo["index"] for pdo in exclusion_scope[start_excluding_index:] if PdoAssign or not pdo["assigned"]])
+                        excluded_pdos.extend([pdo["index"] 
+                            for pdo in exclusion_scope[start_excluding_index:] 
+                            if PdoAssign or not pdo["assigned"]])
                     
                     for pdo, pdo_type in ([(pdo, "Inputs") for pdo in device.getTxPdo()] +
                                           [(pdo, "Outputs") for pdo in device.getRxPdo()]):
@@ -475,7 +482,7 @@
                                 
                                 if len(dynamic_pdos[pdo_type]["pdos"]) > 0:
                                     pdo = dynamic_pdos[pdo_type]["pdos"][0]
-                                else:
+                                elif module_extra_params["add_pdo"]:
                                     while dynamic_pdos[pdo_type]["current_index"] in pdos_index:
                                         dynamic_pdos[pdo_type]["current_index"] += 1
                                     if dynamic_pdos[pdo_type]["current_index"] >= dynamic_pdos[pdo_type]["max_index"]:
@@ -493,6 +500,8 @@
                                     dynamic_pdos[pdo_type]["sync_manager"]["pdos_number"] += 1
                                     dynamic_pdos[pdo_type]["sync_manager"]["pdos"].append(pdo)
                                     dynamic_pdos[pdo_type]["pdos"].append(pdo)
+                                else:
+                                    break
                                 
                                 pdo["entries"].append("    {0x%(index).4x, 0x%(subindex).2x, %(bitlen)d}, /* %(name)s */" % entry_infos)
                                 if entry_infos["bitlen"] < module_extra_params["pdo_alignment"]:
@@ -500,7 +509,7 @@
                                             module_extra_params["pdo_alignment"] - entry_infos["bitlen"]))
                                 pdo["entries_number"] += 1
                                 
-                                if pdo["entries_number"] == 255:
+                                if pdo["entries_number"] == module_extra_params["max_pdo_size"]:
                                     dynamic_pdos[pdo_type]["pdos"].pop(0)
                     
                     pdo_offset = 0
--- a/etherlab/etherlab.py	Fri Apr 26 23:23:09 2013 +0200
+++ b/etherlab/etherlab.py	Mon Apr 29 11:03:06 2013 +0200
@@ -244,11 +244,10 @@
         ("max_pdo_size", {
             "column_label": _("Max entries by PDO"),
             "column_size": 150,
-            "default": -1,
+            "default": 255,
             "description": _(
 """Maximal number of entries mapped in a PDO
-including empty entries used for PDO alignment
-(-1=unbounded)""")}),
+including empty entries used for PDO alignment""")}),
         ("add_pdo", {
             "column_label": _("Creating new PDO"), 
             "column_size": 150,