85 @param type: type of PDO searched (RPDO or TPDO or both) |
85 @param type: type of PDO searched (RPDO or TPDO or both) |
86 @param parameters: indicate which indexes are expected (PDO paramaters : True or PDO mappings : False) |
86 @param parameters: indicate which indexes are expected (PDO paramaters : True or PDO mappings : False) |
87 @return: a list of indexes found |
87 @return: a list of indexes found |
88 """ |
88 """ |
89 |
89 |
90 typeinfos = node.GetEntryInfos(loc_infos["type"]) |
90 model = (loc_infos["index"] << 16) + (loc_infos["subindex"] << 8) |
91 model = (loc_infos["index"] << 16) + (loc_infos["subindex"] << 8) + typeinfos["size"] |
|
92 |
91 |
93 for PDOidx in GetNodePDOIndexes(node, loc_infos["pdotype"]): |
92 for PDOidx in GetNodePDOIndexes(node, loc_infos["pdotype"]): |
94 values = node.GetEntry(PDOidx) |
93 values = node.GetEntry(PDOidx) |
95 if values != None: |
94 if values != None: |
96 for subindex, mapping in enumerate(values): |
95 for subindex, mapping in enumerate(values): |
97 if subindex != 0 and mapping == model: |
96 if subindex != 0 and mapping & 0xFFFFFF00 == model: |
98 return PDOidx, subindex |
97 return PDOidx, subindex |
99 return None |
98 return None |
100 |
99 |
101 |
100 |
102 def GeneratePDOMappingDCF(idx, cobid, transmittype, pdomapping): |
101 def GeneratePDOMappingDCF(idx, cobid, transmittype, pdomapping): |
422 if value != 0: |
421 if value != 0: |
423 mapping.append(value % 0x100) |
422 mapping.append(value % 0x100) |
424 self.MasterMapping[cobid] = {"type" : InvertPDOType[locationinfos["pdotype"]], "mapping" : mapping} |
423 self.MasterMapping[cobid] = {"type" : InvertPDOType[locationinfos["pdotype"]], "mapping" : mapping} |
425 |
424 |
426 # Indicate that this PDO entry must be saved |
425 # Indicate that this PDO entry must be saved |
427 self.MasterMapping[cobid]["mapping"][subindex] = (locationinfos["type"], name) |
426 if locationinfos["bit"] is not None: |
|
427 if not isinstance(self.MasterMapping[cobid]["mapping"][subindex], ListType): |
|
428 self.MasterMapping[cobid]["mapping"][subindex] = [1] * self.MasterMapping[cobid]["mapping"][subindex] |
|
429 if locationinfos["bit"] < len(self.MasterMapping[cobid]["mapping"][subindex]): |
|
430 self.MasterMapping[cobid]["mapping"][subindex][locationinfos["bit"]] = (locationinfos["type"], name) |
|
431 else: |
|
432 self.MasterMapping[cobid]["mapping"][subindex] = (locationinfos["type"], name) |
428 |
433 |
429 else: |
434 else: |
430 # Add location to those that haven't been mapped yet |
435 # Add location to those that haven't been mapped yet |
431 if locationinfos["nodeid"] not in self.LocationsNotMapped.keys(): |
436 if locationinfos["nodeid"] not in self.LocationsNotMapped.keys(): |
432 self.LocationsNotMapped[locationinfos["nodeid"]] = {TPDO : [], RPDO : []} |
437 self.LocationsNotMapped[locationinfos["nodeid"]] = {TPDO : [], RPDO : []} |
496 if sync_TPDOs: |
501 if sync_TPDOs: |
497 self.MasterNode.SetEntry(current_idx, 0x02, 0x01) |
502 self.MasterNode.SetEntry(current_idx, 0x02, 0x01) |
498 else: |
503 else: |
499 self.MasterNode.SetEntry(current_idx, 0x02, 0xFF) |
504 self.MasterNode.SetEntry(current_idx, 0x02, 0xFF) |
500 |
505 |
|
506 mapping = [] |
|
507 for item in pdo_infos["mapping"]: |
|
508 if isinstance(item, ListType): |
|
509 mapping.extend(item) |
|
510 else: |
|
511 mapping.append(item) |
|
512 |
501 # Add some subentries to PDO mapping if there is not enough |
513 # Add some subentries to PDO mapping if there is not enough |
502 if len(pdo_infos["mapping"]) > 1: |
514 if len(mapping) > 1: |
503 self.Manager.AddSubentriesToCurrent(current_idx + 0x200, len(pdo_infos["mapping"]) - 1, self.MasterNode) |
515 self.Manager.AddSubentriesToCurrent(current_idx + 0x200, len(mapping) - 1, self.MasterNode) |
504 |
516 |
505 # Generate MasterNode's PDO mapping |
517 # Generate MasterNode's PDO mapping |
506 for subindex, variable in enumerate(pdo_infos["mapping"]): |
518 for subindex, variable in enumerate(mapping): |
507 if subindex == 0: |
519 if subindex == 0: |
508 continue |
520 continue |
509 new_index = False |
521 new_index = False |
510 |
522 |
511 if isinstance(variable, (IntType, LongType)): |
523 if isinstance(variable, (IntType, LongType)): |