etherlab/EthercatCFileGenerator.py
changeset 2139 1565239349a8
parent 2137 b65abacdbdf9
child 2140 56643934495c
equal deleted inserted replaced
2138:79dc2d15c580 2139:1565239349a8
   320                                 index = ExtractHexDecValue(entry.getIndex().getcontent())
   320                                 index = ExtractHexDecValue(entry.getIndex().getcontent())
   321                                 subindex = ExtractHexDecValue(entry.getSubIndex())
   321                                 subindex = ExtractHexDecValue(entry.getSubIndex())
   322                                 if slave_variables.get((index, subindex), None) is not None:
   322                                 if slave_variables.get((index, subindex), None) is not None:
   323                                     pdo_mapping_match["matching"] += 1
   323                                     pdo_mapping_match["matching"] += 1
   324                         
   324                         
       
   325                             if pdo.getFixed() == True:
       
   326                                 pdo_mapping_match["matching"] += \
       
   327                                     module_extra_params["max_pdo_size"] - \
       
   328                                     pdo_mapping_match["count"]
       
   329                         
   325                         elif pdo.getMandatory():
   330                         elif pdo.getMandatory():
   326                             selected_pdos.append(pdo_index)
   331                             selected_pdos.append(pdo_index)
   327                     
   332                     
   328                     excluded_pdos = []
   333                     excluded_pdos = []
   329                     for exclusion_scope in exclusive_pdos.itervalues():
   334                     for exclusion_scope in exclusive_pdos.itervalues():
   330                         exclusion_scope.sort(ExclusionSortFunction)
   335                         exclusion_scope.sort(ExclusionSortFunction)
   331                         start_excluding_index = 0
   336                         start_excluding_index = 0
   332                         if exclusion_scope[0]["matching"] > 0:
   337                         if exclusion_scope[0]["matching"] > 0:
   333                             selected_pdos.append(exclusion_scope[0]["index"])
   338                             selected_pdos.append(exclusion_scope[0]["index"])
   334                             start_excluding_index = 1
   339                             start_excluding_index = 1
   335                         excluded_pdos.extend([pdo["index"] for pdo in exclusion_scope[start_excluding_index:] if PdoAssign or not pdo["assigned"]])
   340                         excluded_pdos.extend([pdo["index"] 
       
   341                             for pdo in exclusion_scope[start_excluding_index:] 
       
   342                             if PdoAssign or not pdo["assigned"]])
   336                     
   343                     
   337                     for pdo, pdo_type in ([(pdo, "Inputs") for pdo in device.getTxPdo()] +
   344                     for pdo, pdo_type in ([(pdo, "Inputs") for pdo in device.getTxPdo()] +
   338                                           [(pdo, "Outputs") for pdo in device.getRxPdo()]):
   345                                           [(pdo, "Outputs") for pdo in device.getRxPdo()]):
   339                         entries = pdo.getEntry()
   346                         entries = pdo.getEntry()
   340                         
   347                         
   473                                 
   480                                 
   474                                 ConfigureVariable(entry_infos, str_completion)
   481                                 ConfigureVariable(entry_infos, str_completion)
   475                                 
   482                                 
   476                                 if len(dynamic_pdos[pdo_type]["pdos"]) > 0:
   483                                 if len(dynamic_pdos[pdo_type]["pdos"]) > 0:
   477                                     pdo = dynamic_pdos[pdo_type]["pdos"][0]
   484                                     pdo = dynamic_pdos[pdo_type]["pdos"][0]
   478                                 else:
   485                                 elif module_extra_params["add_pdo"]:
   479                                     while dynamic_pdos[pdo_type]["current_index"] in pdos_index:
   486                                     while dynamic_pdos[pdo_type]["current_index"] in pdos_index:
   480                                         dynamic_pdos[pdo_type]["current_index"] += 1
   487                                         dynamic_pdos[pdo_type]["current_index"] += 1
   481                                     if dynamic_pdos[pdo_type]["current_index"] >= dynamic_pdos[pdo_type]["max_index"]:
   488                                     if dynamic_pdos[pdo_type]["current_index"] >= dynamic_pdos[pdo_type]["max_index"]:
   482                                         raise ValueError, _("No more free PDO index available for %s!") % pdo_type
   489                                         raise ValueError, _("No more free PDO index available for %s!") % pdo_type
   483                                     pdos_index.append(dynamic_pdos[pdo_type]["current_index"])
   490                                     pdos_index.append(dynamic_pdos[pdo_type]["current_index"])
   491                                            "entries_number": 0,
   498                                            "entries_number": 0,
   492                                            "fixed": False}
   499                                            "fixed": False}
   493                                     dynamic_pdos[pdo_type]["sync_manager"]["pdos_number"] += 1
   500                                     dynamic_pdos[pdo_type]["sync_manager"]["pdos_number"] += 1
   494                                     dynamic_pdos[pdo_type]["sync_manager"]["pdos"].append(pdo)
   501                                     dynamic_pdos[pdo_type]["sync_manager"]["pdos"].append(pdo)
   495                                     dynamic_pdos[pdo_type]["pdos"].append(pdo)
   502                                     dynamic_pdos[pdo_type]["pdos"].append(pdo)
       
   503                                 else:
       
   504                                     break
   496                                 
   505                                 
   497                                 pdo["entries"].append("    {0x%(index).4x, 0x%(subindex).2x, %(bitlen)d}, /* %(name)s */" % entry_infos)
   506                                 pdo["entries"].append("    {0x%(index).4x, 0x%(subindex).2x, %(bitlen)d}, /* %(name)s */" % entry_infos)
   498                                 if entry_infos["bitlen"] < module_extra_params["pdo_alignment"]:
   507                                 if entry_infos["bitlen"] < module_extra_params["pdo_alignment"]:
   499                                     pdo["entries"].append("    {0x0000, 0x00, %d}, /* None */" % (
   508                                     pdo["entries"].append("    {0x0000, 0x00, %d}, /* None */" % (
   500                                             module_extra_params["pdo_alignment"] - entry_infos["bitlen"]))
   509                                             module_extra_params["pdo_alignment"] - entry_infos["bitlen"]))
   501                                 pdo["entries_number"] += 1
   510                                 pdo["entries_number"] += 1
   502                                 
   511                                 
   503                                 if pdo["entries_number"] == 255:
   512                                 if pdo["entries_number"] == module_extra_params["max_pdo_size"]:
   504                                     dynamic_pdos[pdo_type]["pdos"].pop(0)
   513                                     dynamic_pdos[pdo_type]["pdos"].pop(0)
   505                     
   514                     
   506                     pdo_offset = 0
   515                     pdo_offset = 0
   507                     entry_offset = 0
   516                     entry_offset = 0
   508                     for sync_manager_infos in sync_managers:
   517                     for sync_manager_infos in sync_managers: