115 |
115 |
116 model = (loc_infos["index"] << 16) + (loc_infos["subindex"] << 8) |
116 model = (loc_infos["index"] << 16) + (loc_infos["subindex"] << 8) |
117 |
117 |
118 for PDOidx in GetNodePDOIndexes(node, loc_infos["pdotype"]): |
118 for PDOidx in GetNodePDOIndexes(node, loc_infos["pdotype"]): |
119 values = node.GetEntry(PDOidx) |
119 values = node.GetEntry(PDOidx) |
120 if values != None: |
120 if values is not None: |
121 for subindex, mapping in enumerate(values): |
121 for subindex, mapping in enumerate(values): |
122 if subindex != 0 and mapping & 0xFFFFFF00 == model: |
122 if subindex != 0 and mapping & 0xFFFFFF00 == model: |
123 return PDOidx, subindex |
123 return PDOidx, subindex |
124 return None |
124 return None |
125 |
125 |
264 """ |
264 """ |
265 # Get current DCF for slave |
265 # Get current DCF for slave |
266 nodeDCF = self.MasterNode.GetEntry(0x1F22, nodeid) |
266 nodeDCF = self.MasterNode.GetEntry(0x1F22, nodeid) |
267 |
267 |
268 # Extract data and number of params in current DCF |
268 # Extract data and number of params in current DCF |
269 if nodeDCF != None and nodeDCF != '': |
269 if nodeDCF is not None and nodeDCF != '': |
270 tmpnbparams = [i for i in nodeDCF[:4]] |
270 tmpnbparams = [i for i in nodeDCF[:4]] |
271 tmpnbparams.reverse() |
271 tmpnbparams.reverse() |
272 nbparams += int(''.join(["%2.2x" % ord(i) for i in tmpnbparams]), 16) |
272 nbparams += int(''.join(["%2.2x" % ord(i) for i in tmpnbparams]), 16) |
273 data = nodeDCF[4:] + data |
273 data = nodeDCF[4:] + data |
274 |
274 |
293 |
293 |
294 # Search for all PDO possible index until find a configurable PDO |
294 # Search for all PDO possible index until find a configurable PDO |
295 # starting from start_index |
295 # starting from start_index |
296 while index < PDOTypeBaseIndex[pdotype] + 0x200: |
296 while index < PDOTypeBaseIndex[pdotype] + 0x200: |
297 values = self.NodeList.GetSlaveNodeEntry(nodeid, index + 0x200) |
297 values = self.NodeList.GetSlaveNodeEntry(nodeid, index + 0x200) |
298 if values != None and values[0] > 0: |
298 if values is not None and values[0] > 0: |
299 # Check that all subindex upper than 0 equal 0 => configurable PDO |
299 # Check that all subindex upper than 0 equal 0 => configurable PDO |
300 if reduce(lambda x, y: x and y, map(lambda x: x == 0, values[1:]), True): |
300 if reduce(lambda x, y: x and y, map(lambda x: x == 0, values[1:]), True): |
301 cobid = self.NodeList.GetSlaveNodeEntry(nodeid, index, 1) |
301 cobid = self.NodeList.GetSlaveNodeEntry(nodeid, index, 1) |
302 # If no COB ID defined in PDO, generate a new one (not used) |
302 # If no COB ID defined in PDO, generate a new one (not used) |
303 if cobid == 0: |
303 if cobid == 0: |
418 for name, locationinfos in self.IECLocations.items(): |
418 for name, locationinfos in self.IECLocations.items(): |
419 node = self.NodeList.SlaveNodes[locationinfos["nodeid"]]["Node"] |
419 node = self.NodeList.SlaveNodes[locationinfos["nodeid"]]["Node"] |
420 |
420 |
421 # Search if slave has a PDO mapping this locations |
421 # Search if slave has a PDO mapping this locations |
422 result = SearchNodePDOMapping(locationinfos, node) |
422 result = SearchNodePDOMapping(locationinfos, node) |
423 if result != None: |
423 if result is not None: |
424 index, subindex = result |
424 index, subindex = result |
425 # Get COB ID of the PDO |
425 # Get COB ID of the PDO |
426 cobid = self.NodeList.GetSlaveNodeEntry(locationinfos["nodeid"], index - 0x200, 1) |
426 cobid = self.NodeList.GetSlaveNodeEntry(locationinfos["nodeid"], index - 0x200, 1) |
427 |
427 |
428 # Add PDO to MasterMapping |
428 # Add PDO to MasterMapping |
591 break |
591 break |
592 |
592 |
593 # Verify that a not full entry has been found |
593 # Verify that a not full entry has been found |
594 if mapvariableidx < VariableStartIndex[variable_infos["pdotype"]] + 0x2000: |
594 if mapvariableidx < VariableStartIndex[variable_infos["pdotype"]] + 0x2000: |
595 # Generate subentry name |
595 # Generate subentry name |
596 if variable_infos["bit"] != None: |
596 if variable_infos["bit"] is not None: |
597 subindexname = "%(index)d_%(subindex)d_%(bit)d" % variable_infos |
597 subindexname = "%(index)d_%(subindex)d_%(bit)d" % variable_infos |
598 else: |
598 else: |
599 subindexname = "%(index)d_%(subindex)d" % variable_infos |
599 subindexname = "%(index)d_%(subindex)d" % variable_infos |
600 # If entry have just been created, no subentry have to be added |
600 # If entry have just been created, no subentry have to be added |
601 if not new_index: |
601 if not new_index: |
605 self.MasterNode.SetMappingEntry(mapvariableidx, nbsubentries, values = {"name": subindexname}) |
605 self.MasterNode.SetMappingEntry(mapvariableidx, nbsubentries, values = {"name": subindexname}) |
606 self.MasterNode.SetMappingEntry(mapvariableidx, nbsubentries, values = {"type": typeidx}) |
606 self.MasterNode.SetMappingEntry(mapvariableidx, nbsubentries, values = {"type": typeidx}) |
607 |
607 |
608 # Set value of the PDO mapping |
608 # Set value of the PDO mapping |
609 typeinfos = self.Manager.GetEntryInfos(typeidx) |
609 typeinfos = self.Manager.GetEntryInfos(typeidx) |
610 if typeinfos != None: |
610 if typeinfos is not None: |
611 value = (mapvariableidx << 16) + ((nbsubentries) << 8) + typeinfos["size"] |
611 value = (mapvariableidx << 16) + ((nbsubentries) << 8) + typeinfos["size"] |
612 self.MasterNode.SetEntry(current_idx + 0x200, subindex, value) |
612 self.MasterNode.SetEntry(current_idx + 0x200, subindex, value) |
613 |
613 |
614 # Add variable to pointed variables |
614 # Add variable to pointed variables |
615 self.PointedVariables[(mapvariableidx, nbsubentries)] = "%s_%s" % (indexname, subindexname) |
615 self.PointedVariables[(mapvariableidx, nbsubentries)] = "%s_%s" % (indexname, subindexname) |