350 # Extract and check nodeid |
350 # Extract and check nodeid |
351 nodeid, index, subindex = loc[:3] |
351 nodeid, index, subindex = loc[:3] |
352 |
352 |
353 # Check Id is in slave node list |
353 # Check Id is in slave node list |
354 if nodeid not in self.NodeList.SlaveNodes.keys(): |
354 if nodeid not in self.NodeList.SlaveNodes.keys(): |
355 raise PDOmappingException, _("Non existing node ID : %d (variable %s)") % (nodeid,name) |
355 raise PDOmappingException, _("Non existing node ID : {a1} (variable {a2})").format(a1 = nodeid, a2 = name) |
356 |
356 |
357 # Get the model for this node (made from EDS) |
357 # Get the model for this node (made from EDS) |
358 node = self.NodeList.SlaveNodes[nodeid]["Node"] |
358 node = self.NodeList.SlaveNodes[nodeid]["Node"] |
359 |
359 |
360 # Extract and check index and subindex |
360 # Extract and check index and subindex |
361 if not node.IsEntry(index, subindex): |
361 if not node.IsEntry(index, subindex): |
362 raise PDOmappingException, _("No such index/subindex (%x,%x) in ID : %d (variable %s)") % (index,subindex,nodeid,name) |
362 msg = _("No such index/subindex ({a1},{a2}) in ID : {a3} (variable {a4})").\ |
|
363 format(a1 = "%x" % index, a2 ="%x" % subindex, a3 = nodeid, a4 = name) |
|
364 raise PDOmappingException, msg |
363 |
365 |
364 # Get the entry info |
366 # Get the entry info |
365 subentry_infos = node.GetSubentryInfos(index, subindex) |
367 subentry_infos = node.GetSubentryInfos(index, subindex) |
366 |
368 |
367 # If a PDO mappable |
369 # If a PDO mappable |
368 if subentry_infos and subentry_infos["pdo"]: |
370 if subentry_infos and subentry_infos["pdo"]: |
369 if sizelocation == "X" and len(loc) > 3: |
371 if sizelocation == "X" and len(loc) > 3: |
370 numbit = loc[3] |
372 numbit = loc[3] |
371 elif sizelocation != "X" and len(loc) > 3: |
373 elif sizelocation != "X" and len(loc) > 3: |
372 raise PDOmappingException, _("Cannot set bit offset for non bool '%s' variable (ID:%d,Idx:%x,sIdx:%x))") % (name,nodeid,index,subindex) |
374 msg = _("Cannot set bit offset for non bool '{a1}' variable (ID:{a2},Idx:{a3},sIdx:{a4}))").\ |
|
375 format(a1 = name, a2 = nodeid, a3 = "%x" % index, a4 = "%x" % subindex) |
|
376 raise PDOmappingException, msg |
373 else: |
377 else: |
374 numbit = None |
378 numbit = None |
375 |
379 |
376 if location["IEC_TYPE"] != "BOOL" and subentry_infos["type"] != COlocationtype: |
380 if location["IEC_TYPE"] != "BOOL" and subentry_infos["type"] != COlocationtype: |
377 raise PDOmappingException, _("Invalid type \"%s\"-> %d != %d for location\"%s\"") % (location["IEC_TYPE"], COlocationtype, subentry_infos["type"] , name) |
381 raise PDOmappingException, _("Invalid type \"{a1}\"-> {a2} != {a3} for location\"{a4}\"").\ |
|
382 format(a1 = location["IEC_TYPE"], a2 = COlocationtype, a3 = subentry_infos["type"] , a4 = name) |
378 |
383 |
379 typeinfos = node.GetEntryInfos(COlocationtype) |
384 typeinfos = node.GetEntryInfos(COlocationtype) |
380 self.IECLocations[name] = {"type":COlocationtype, "pdotype":SlavePDOType[direction], |
385 self.IECLocations[name] = {"type":COlocationtype, "pdotype":SlavePDOType[direction], |
381 "nodeid": nodeid, "index": index,"subindex": subindex, |
386 "nodeid": nodeid, "index": index,"subindex": subindex, |
382 "bit": numbit, "size": typeinfos["size"], "sizelocation": sizelocation} |
387 "bit": numbit, "size": typeinfos["size"], "sizelocation": sizelocation} |
383 else: |
388 else: |
384 raise PDOmappingException, _("Not PDO mappable variable : '%s' (ID:%d,Idx:%x,sIdx:%x))") % (name,nodeid,index,subindex) |
389 raise PDOmappingException, _("Not PDO mappable variable : '{a1}' (ID:{a2},Idx:{a3},sIdx:{a4}))").\ |
|
390 format(a1 = name, a2 = nodeid, a3 = "%x" % index, a4 = "%x" % subindex) |
385 |
391 |
386 #------------------------------------------------------------------------------- |
392 #------------------------------------------------------------------------------- |
387 # Search for locations already mapped |
393 # Search for locations already mapped |
388 #------------------------------------------------------------------------------- |
394 #------------------------------------------------------------------------------- |
389 |
395 |
628 # Extract and check nodeid |
634 # Extract and check nodeid |
629 index, subindex = loc[:2] |
635 index, subindex = loc[:2] |
630 |
636 |
631 # Extract and check index and subindex |
637 # Extract and check index and subindex |
632 if not slave.IsEntry(index, subindex): |
638 if not slave.IsEntry(index, subindex): |
633 raise PDOmappingException, _("No such index/subindex (%x,%x) (variable %s)") % (index, subindex, name) |
639 raise PDOmappingException, _("No such index/subindex ({a1},{a2}) (variable {a3})").\ |
|
640 format(a1 = "%x" % index, a2 = "%x" % subindex, a3 = name) |
634 |
641 |
635 # Get the entry info |
642 # Get the entry info |
636 subentry_infos = slave.GetSubentryInfos(index, subindex) |
643 subentry_infos = slave.GetSubentryInfos(index, subindex) |
637 if subentry_infos["type"] != COlocationtype: |
644 if subentry_infos["type"] != COlocationtype: |
638 raise PDOmappingException, _("Invalid type \"%s\"-> %d != %d for location\"%s\"") % (location["IEC_TYPE"], COlocationtype, subentry_infos["type"] , name) |
645 raise PDOmappingException, _("Invalid type \"{a1}\"-> {a2} != {a3} for location \"{a4}\"").\ |
|
646 format( a1 = location["IEC_TYPE"], a2 = COlocationtype, a3 = subentry_infos["type"] , a4 = name) |
639 |
647 |
640 IECLocations[name] = COlocationtype |
648 IECLocations[name] = COlocationtype |
641 pointers[(index, subindex)] = name |
649 pointers[(index, subindex)] = name |
642 return pointers |
650 return pointers |
643 |
651 |