plugins/canfestival/config_utils.py
changeset 415 339fa2542481
parent 361 331d698e1118
equal deleted inserted replaced
414:6f54c173aa19 415:339fa2542481
   330         for location in locations:
   330         for location in locations:
   331             COlocationtype = IECToCOType[location["IEC_TYPE"]]
   331             COlocationtype = IECToCOType[location["IEC_TYPE"]]
   332             name = location["NAME"]
   332             name = location["NAME"]
   333             if name in self.IECLocations:
   333             if name in self.IECLocations:
   334                 if self.IECLocations[name]["type"] != COlocationtype:
   334                 if self.IECLocations[name]["type"] != COlocationtype:
   335                     raise PDOmappingException, _("Conflict type for location \"%s\"") % name 
   335                     raise PDOmappingException, _("Type conflict for location \"%s\"") % name 
   336             else:
   336             else:
   337                 # Get only the part of the location that concern this node
   337                 # Get only the part of the location that concern this node
   338                 loc = location["LOC"][len(current_location):]
   338                 loc = location["LOC"][len(current_location):]
   339                 # loc correspond to (ID, INDEX, SUBINDEX [,BIT])
   339                 # loc correspond to (ID, INDEX, SUBINDEX [,BIT])
   340                 if len(loc) not in (2, 3, 4):
   340                 if len(loc) not in (2, 3, 4):
   450                 if len(locations[pdotype]) > 0:
   450                 if len(locations[pdotype]) > 0:
   451                     pdosize = 0
   451                     pdosize = 0
   452                     pdomapping = []
   452                     pdomapping = []
   453                     result = self.GetEmptyPDO(nodeid, pdotype)
   453                     result = self.GetEmptyPDO(nodeid, pdotype)
   454                     if result is None:
   454                     if result is None:
   455                         raise PDOmappingException, _("Impossible to define PDO mapping for node %02x") % nodeid
   455                         raise PDOmappingException, _("Unable to define PDO mapping for node %02x") % nodeid
   456                     pdoindex, pdocobid, pdonbparams = result
   456                     pdoindex, pdocobid, pdonbparams = result
   457                     for name, loc_infos in locations[pdotype]:
   457                     for name, loc_infos in locations[pdotype]:
   458                         pdosize += loc_infos["size"]
   458                         pdosize += loc_infos["size"]
   459                         # If pdo's size > 64 bits
   459                         # If pdo's size > 64 bits
   460                         if pdosize > 64 or len(pdomapping) >= pdonbparams:
   460                         if pdosize > 64 or len(pdomapping) >= pdonbparams:
   464                             nbparams += nbaddedparams
   464                             nbparams += nbaddedparams
   465                             pdosize = loc_infos["size"]
   465                             pdosize = loc_infos["size"]
   466                             pdomapping = [(name, loc_infos)]
   466                             pdomapping = [(name, loc_infos)]
   467                             result = self.GetEmptyPDO(nodeid, pdotype, pdoindex + 1)
   467                             result = self.GetEmptyPDO(nodeid, pdotype, pdoindex + 1)
   468                             if result is None:
   468                             if result is None:
   469                                 raise PDOmappingException, _("Impossible to define PDO mapping for node %02x") % nodeid
   469                                 raise PDOmappingException, _("Unable to define PDO mapping for node %02x") % nodeid
   470                             pdoindex, pdocobid, pdonbparams = result
   470                             pdoindex, pdocobid, pdonbparams = result
   471                         else:
   471                         else:
   472                             pdomapping.append((name, loc_infos))
   472                             pdomapping.append((name, loc_infos))
   473                     # If there isn't locations yet but there is still a PDO to generate
   473                     # If there isn't locations yet but there is still a PDO to generate
   474                     if len(pdomapping) > 0:
   474                     if len(pdomapping) > 0:
   612     for location in locations:
   612     for location in locations:
   613         COlocationtype = IECToCOType[location["IEC_TYPE"]]
   613         COlocationtype = IECToCOType[location["IEC_TYPE"]]
   614         name = location["NAME"]
   614         name = location["NAME"]
   615         if name in IECLocations:
   615         if name in IECLocations:
   616             if IECLocations[name] != COlocationtype:
   616             if IECLocations[name] != COlocationtype:
   617                 raise PDOmappingException, _("Conflict type for location \"%s\"") % name 
   617                 raise PDOmappingException, _("Type conflict for location \"%s\"") % name 
   618         else:
   618         else:
   619             # Get only the part of the location that concern this node
   619             # Get only the part of the location that concern this node
   620             loc = location["LOC"][len(current_location):]
   620             loc = location["LOC"][len(current_location):]
   621             # loc correspond to (ID, INDEX, SUBINDEX [,BIT])
   621             # loc correspond to (ID, INDEX, SUBINDEX [,BIT])
   622             if len(loc) not in (2, 3, 4):
   622             if len(loc) not in (2, 3, 4):