equal
deleted
inserted
replaced
48 |
48 |
49 #------------------------------------------------------------------------------- |
49 #------------------------------------------------------------------------------- |
50 # Specific exception for PDO mapping errors |
50 # Specific exception for PDO mapping errors |
51 #------------------------------------------------------------------------------- |
51 #------------------------------------------------------------------------------- |
52 |
52 |
|
53 |
53 class PDOmappingException(Exception): |
54 class PDOmappingException(Exception): |
54 pass |
55 pass |
55 |
56 |
56 |
57 |
57 def LE_to_BE(value, size): |
58 def LE_to_BE(value, size): |
134 # Re-enable Mapping |
135 # Re-enable Mapping |
135 dcfdata += [LE_to_BE(idx + 0x200, 2) + LE_to_BE(0x00, 1) + LE_to_BE(0x01, 4) + LE_to_BE(len(pdomapping), 1)] |
136 dcfdata += [LE_to_BE(idx + 0x200, 2) + LE_to_BE(0x00, 1) + LE_to_BE(0x01, 4) + LE_to_BE(len(pdomapping), 1)] |
136 # Re-Enable PDO |
137 # Re-Enable PDO |
137 dcfdata += [LE_to_BE(idx, 2) + LE_to_BE(0x01, 1) + LE_to_BE(0x04, 4) + LE_to_BE(cobid, 4)] |
138 dcfdata += [LE_to_BE(idx, 2) + LE_to_BE(0x01, 1) + LE_to_BE(0x04, 4) + LE_to_BE(cobid, 4)] |
138 return "".join(dcfdata), len(dcfdata) |
139 return "".join(dcfdata), len(dcfdata) |
|
140 |
139 |
141 |
140 class ConciseDCFGenerator: |
142 class ConciseDCFGenerator: |
141 |
143 |
142 def __init__(self, nodelist, nodename): |
144 def __init__(self, nodelist, nodename): |
143 # Dictionary of location informations classed by name |
145 # Dictionary of location informations classed by name |
590 self.MasterNode.SetEntry(current_idx + 0x200, subindex, value) |
592 self.MasterNode.SetEntry(current_idx + 0x200, subindex, value) |
591 |
593 |
592 # Add variable to pointed variables |
594 # Add variable to pointed variables |
593 self.PointedVariables[(mapvariableidx, nbsubentries)] = "%s_%s" % (indexname, subindexname) |
595 self.PointedVariables[(mapvariableidx, nbsubentries)] = "%s_%s" % (indexname, subindexname) |
594 |
596 |
|
597 |
595 def GenerateConciseDCF(locations, current_location, nodelist, sync_TPDOs, nodename): |
598 def GenerateConciseDCF(locations, current_location, nodelist, sync_TPDOs, nodename): |
596 """ |
599 """ |
597 Fills a CanFestival network editor model, with DCF with requested PDO mappings. |
600 Fills a CanFestival network editor model, with DCF with requested PDO mappings. |
598 @param locations: List of complete variables locations \ |
601 @param locations: List of complete variables locations \ |
599 [{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...) |
602 [{"IEC_TYPE" : the IEC type (i.e. "INT", "STRING", ...) |
610 dcfgenerator.GenerateDCF(locations, current_location, sync_TPDOs) |
613 dcfgenerator.GenerateDCF(locations, current_location, sync_TPDOs) |
611 masternode,pointers = dcfgenerator.GetMasterNode(), dcfgenerator.GetPointedVariables() |
614 masternode,pointers = dcfgenerator.GetMasterNode(), dcfgenerator.GetPointedVariables() |
612 # allow access to local OD from Master PLC |
615 # allow access to local OD from Master PLC |
613 pointers.update(LocalODPointers(locations, current_location, masternode)) |
616 pointers.update(LocalODPointers(locations, current_location, masternode)) |
614 return masternode,pointers |
617 return masternode,pointers |
|
618 |
615 |
619 |
616 def LocalODPointers(locations, current_location, slave): |
620 def LocalODPointers(locations, current_location, slave): |
617 IECLocations = {} |
621 IECLocations = {} |
618 pointers = {} |
622 pointers = {} |
619 for location in locations: |
623 for location in locations: |