Added error message when a device informations can't be found in ESI files
authorLaurent Bessard
Thu, 02 May 2013 13:40:35 +0200
changeset 2144 bbd78ac226d0
parent 2143 83a2e3db4c8c
child 2145 65ed4f7c941b
Added error message when a device informations can't be found in ESI files
etherlab/EthercatCFileGenerator.py
--- a/etherlab/EthercatCFileGenerator.py	Thu May 02 10:21:47 2013 +0200
+++ b/etherlab/EthercatCFileGenerator.py	Thu May 02 13:40:35 2013 +0200
@@ -202,347 +202,348 @@
             
             # Extract slave device informations
             device, module_extra_params = self.Controler.GetModuleInfos(type_infos)
-            if device is not None:
-                
-                # Extract slaves variables to be mapped
-                slave_variables = self.UsedVariables.get(slave_idx, {})
-                
-                # Extract slave device object dictionary entries
-                device_entries = device.GetEntriesList()
-                
-                # Adding code for declaring slave in master code template strings
-                for element in ["vendor", "product_code", "revision_number"]:
-                    type_infos[element] = ExtractHexDecValue(type_infos[element])
-                type_infos.update(dict(zip(["slave", "alias", "position"], (slave_idx,) + slave_pos)))
-                
-                # Extract slave device CoE informations
-                device_coe = device.getCoE()
-                if device_coe is not None:
-                    
-                    # If device support CanOpen over Ethernet, adding code for calling 
-                    # init commands when initializing slave in master code template strings
-                    initCmds = []
-                    for initCmd in device_coe.getInitCmd():
-                        initCmds.append({
-                            "Index": ExtractHexDecValue(initCmd.getIndex()),
-                            "Subindex": ExtractHexDecValue(initCmd.getSubIndex()),
-                            "Value": initCmd.getData().getcontent()})
-                    initCmds.extend(slave.getStartupCommands())
-                    for initCmd in initCmds:
-                        index = initCmd["Index"]
-                        subindex = initCmd["Subindex"]
-                        entry = device_entries.get((index, subindex), None)
-                        if entry is not None:
-                            data_size = entry["BitSize"] / 8
-                            data_str = ("0x%%.%dx" % (data_size * 2)) % initCmd["Value"]
-                            init_cmd_infos = {
-                                "index": index,
-                                "subindex": subindex,
-                                "data": data_str,
-                                "data_type": DATATYPECONVERSION.get(entry["Type"]),
-                                "data_size": data_size
-                            }
-                            init_cmd_infos.update(type_infos)
-                            str_completion["slaves_initialization"] += SLAVE_INITIALIZATION_TEMPLATE % init_cmd_infos
-                
-                    # Extract slave device PDO configuration capabilities
-                    PdoAssign = device_coe.getPdoAssign()
-                    PdoConfig = device_coe.getPdoConfig()
-                else:
-                    PdoAssign = PdoConfig = False
-                
-                # Test if slave has a configuration or need one
-                if len(device.getTxPdo() + device.getRxPdo()) > 0 or len(slave_variables) > 0 and PdoConfig and PdoAssign:
-                    
-                    str_completion["slaves_declaration"] += "static ec_slave_config_t *slave%(slave)d = NULL;\n" % type_infos
-                    str_completion["slaves_configuration"] += SLAVE_CONFIGURATION_TEMPLATE % type_infos
-                    
-                    # Initializing 
-                    pdos_infos = {
-                        "pdos_entries_infos": [],
-                        "pdos_infos": [],
-                        "pdos_sync_infos": [], 
+            if device is None:
+                raise ValueError, _("No informations found for device %s!") % (type_infos["device_type"])
+            
+            # Extract slaves variables to be mapped
+            slave_variables = self.UsedVariables.get(slave_idx, {})
+            
+            # Extract slave device object dictionary entries
+            device_entries = device.GetEntriesList()
+            
+            # Adding code for declaring slave in master code template strings
+            for element in ["vendor", "product_code", "revision_number"]:
+                type_infos[element] = ExtractHexDecValue(type_infos[element])
+            type_infos.update(dict(zip(["slave", "alias", "position"], (slave_idx,) + slave_pos)))
+            
+            # Extract slave device CoE informations
+            device_coe = device.getCoE()
+            if device_coe is not None:
+                
+                # If device support CanOpen over Ethernet, adding code for calling 
+                # init commands when initializing slave in master code template strings
+                initCmds = []
+                for initCmd in device_coe.getInitCmd():
+                    initCmds.append({
+                        "Index": ExtractHexDecValue(initCmd.getIndex()),
+                        "Subindex": ExtractHexDecValue(initCmd.getSubIndex()),
+                        "Value": initCmd.getData().getcontent()})
+                initCmds.extend(slave.getStartupCommands())
+                for initCmd in initCmds:
+                    index = initCmd["Index"]
+                    subindex = initCmd["Subindex"]
+                    entry = device_entries.get((index, subindex), None)
+                    if entry is not None:
+                        data_size = entry["BitSize"] / 8
+                        data_str = ("0x%%.%dx" % (data_size * 2)) % initCmd["Value"]
+                        init_cmd_infos = {
+                            "index": index,
+                            "subindex": subindex,
+                            "data": data_str,
+                            "data_type": DATATYPECONVERSION.get(entry["Type"]),
+                            "data_size": data_size
+                        }
+                        init_cmd_infos.update(type_infos)
+                        str_completion["slaves_initialization"] += SLAVE_INITIALIZATION_TEMPLATE % init_cmd_infos
+            
+                # Extract slave device PDO configuration capabilities
+                PdoAssign = device_coe.getPdoAssign()
+                PdoConfig = device_coe.getPdoConfig()
+            else:
+                PdoAssign = PdoConfig = False
+            
+            # Test if slave has a configuration or need one
+            if len(device.getTxPdo() + device.getRxPdo()) > 0 or len(slave_variables) > 0 and PdoConfig and PdoAssign:
+                
+                str_completion["slaves_declaration"] += "static ec_slave_config_t *slave%(slave)d = NULL;\n" % type_infos
+                str_completion["slaves_configuration"] += SLAVE_CONFIGURATION_TEMPLATE % type_infos
+                
+                # Initializing 
+                pdos_infos = {
+                    "pdos_entries_infos": [],
+                    "pdos_infos": [],
+                    "pdos_sync_infos": [], 
+                }
+                pdos_infos.update(type_infos)
+                
+                sync_managers = []
+                for sync_manager_idx, sync_manager in enumerate(device.getSm()):
+                    sync_manager_infos = {
+                        "index": sync_manager_idx, 
+                        "name": sync_manager.getcontent(),
+                        "slave": slave_idx,
+                        "pdos": [], 
+                        "pdos_number": 0,
                     }
-                    pdos_infos.update(type_infos)
-                    
-                    sync_managers = []
-                    for sync_manager_idx, sync_manager in enumerate(device.getSm()):
-                        sync_manager_infos = {
-                            "index": sync_manager_idx, 
-                            "name": sync_manager.getcontent(),
-                            "slave": slave_idx,
-                            "pdos": [], 
-                            "pdos_number": 0,
+                    
+                    sync_manager_control_byte = ExtractHexDecValue(sync_manager.getControlByte())
+                    sync_manager_direction = sync_manager_control_byte & 0x0c
+                    sync_manager_watchdog = sync_manager_control_byte & 0x40
+                    if sync_manager_direction:
+                        sync_manager_infos["sync_manager_type"] = "EC_DIR_OUTPUT"
+                    else:
+                        sync_manager_infos["sync_manager_type"] = "EC_DIR_INPUT"
+                    if sync_manager_watchdog:
+                        sync_manager_infos["watchdog"] = "EC_WD_ENABLE"
+                    else:
+                        sync_manager_infos["watchdog"] = "EC_WD_DISABLE"
+                    
+                    sync_managers.append(sync_manager_infos)
+                
+                pdos_index = []
+                exclusive_pdos = {}
+                selected_pdos = []
+                for pdo, pdo_type in ([(pdo, "Inputs") for pdo in device.getTxPdo()] +
+                                      [(pdo, "Outputs") for pdo in device.getRxPdo()]):
+                    
+                    pdo_index = ExtractHexDecValue(pdo.getIndex().getcontent())
+                    pdos_index.append(pdo_index)
+                    
+                    excluded_list = pdo.getExclude()
+                    if len(excluded_list) > 0:
+                        exclusion_list = [pdo_index]
+                        for excluded in excluded_list:
+                            exclusion_list.append(ExtractHexDecValue(excluded.getcontent()))
+                        exclusion_list.sort()
+                        
+                        exclusion_scope = exclusive_pdos.setdefault(tuple(exclusion_list), [])
+                        
+                        entries = pdo.getEntry()
+                        pdo_mapping_match = {
+                            "index": pdo_index, 
+                            "matching": 0, 
+                            "count": len(entries), 
+                            "assigned": pdo.getSm() is not None
                         }
-                        
-                        sync_manager_control_byte = ExtractHexDecValue(sync_manager.getControlByte())
-                        sync_manager_direction = sync_manager_control_byte & 0x0c
-                        sync_manager_watchdog = sync_manager_control_byte & 0x40
-                        if sync_manager_direction:
-                            sync_manager_infos["sync_manager_type"] = "EC_DIR_OUTPUT"
-                        else:
-                            sync_manager_infos["sync_manager_type"] = "EC_DIR_INPUT"
-                        if sync_manager_watchdog:
-                            sync_manager_infos["watchdog"] = "EC_WD_ENABLE"
-                        else:
-                            sync_manager_infos["watchdog"] = "EC_WD_DISABLE"
-                        
-                        sync_managers.append(sync_manager_infos)
-                    
-                    pdos_index = []
-                    exclusive_pdos = {}
-                    selected_pdos = []
-                    for pdo, pdo_type in ([(pdo, "Inputs") for pdo in device.getTxPdo()] +
-                                          [(pdo, "Outputs") for pdo in device.getRxPdo()]):
-                        
-                        pdo_index = ExtractHexDecValue(pdo.getIndex().getcontent())
-                        pdos_index.append(pdo_index)
-                        
-                        excluded_list = pdo.getExclude()
-                        if len(excluded_list) > 0:
-                            exclusion_list = [pdo_index]
-                            for excluded in excluded_list:
-                                exclusion_list.append(ExtractHexDecValue(excluded.getcontent()))
-                            exclusion_list.sort()
-                            
-                            exclusion_scope = exclusive_pdos.setdefault(tuple(exclusion_list), [])
-                            
-                            entries = pdo.getEntry()
-                            pdo_mapping_match = {
-                                "index": pdo_index, 
-                                "matching": 0, 
-                                "count": len(entries), 
-                                "assigned": pdo.getSm() is not None
-                            }
-                            exclusion_scope.append(pdo_mapping_match)
-                            
-                            for entry in entries:
-                                index = ExtractHexDecValue(entry.getIndex().getcontent())
-                                subindex = ExtractHexDecValue(entry.getSubIndex())
-                                if slave_variables.get((index, subindex), None) is not None:
-                                    pdo_mapping_match["matching"] += 1
-                        
-                            if pdo.getFixed() != True:
-                                pdo_mapping_match["matching"] += \
-                                    module_extra_params["max_pdo_size"] - \
-                                    pdo_mapping_match["count"]
-                        
-                        elif pdo.getMandatory():
-                            selected_pdos.append(pdo_index)
-                    
-                    excluded_pdos = []
-                    for exclusion_scope in exclusive_pdos.itervalues():
-                        exclusion_scope.sort(ExclusionSortFunction)
-                        start_excluding_index = 0
-                        if exclusion_scope[0]["matching"] > 0:
-                            selected_pdos.append(exclusion_scope[0]["index"])
-                            start_excluding_index = 1
-                        excluded_pdos.extend([pdo["index"] 
-                            for pdo in exclusion_scope[start_excluding_index:] 
-                            if PdoAssign or not pdo["assigned"]])
-                    
-                    for pdo, pdo_type in ([(pdo, "Inputs") for pdo in device.getTxPdo()] +
-                                          [(pdo, "Outputs") for pdo in device.getRxPdo()]):
-                        entries = pdo.getEntry()
-                        
-                        pdo_index = ExtractHexDecValue(pdo.getIndex().getcontent())
-                        if pdo_index in excluded_pdos:
-                            continue
-                        
-                        pdo_needed = pdo_index in selected_pdos
-                        
-                        entries_infos = []
+                        exclusion_scope.append(pdo_mapping_match)
                         
                         for entry in entries:
                             index = ExtractHexDecValue(entry.getIndex().getcontent())
                             subindex = ExtractHexDecValue(entry.getSubIndex())
+                            if slave_variables.get((index, subindex), None) is not None:
+                                pdo_mapping_match["matching"] += 1
+                    
+                        if pdo.getFixed() != True:
+                            pdo_mapping_match["matching"] += \
+                                module_extra_params["max_pdo_size"] - \
+                                pdo_mapping_match["count"]
+                    
+                    elif pdo.getMandatory():
+                        selected_pdos.append(pdo_index)
+                
+                excluded_pdos = []
+                for exclusion_scope in exclusive_pdos.itervalues():
+                    exclusion_scope.sort(ExclusionSortFunction)
+                    start_excluding_index = 0
+                    if exclusion_scope[0]["matching"] > 0:
+                        selected_pdos.append(exclusion_scope[0]["index"])
+                        start_excluding_index = 1
+                    excluded_pdos.extend([pdo["index"] 
+                        for pdo in exclusion_scope[start_excluding_index:] 
+                        if PdoAssign or not pdo["assigned"]])
+                
+                for pdo, pdo_type in ([(pdo, "Inputs") for pdo in device.getTxPdo()] +
+                                      [(pdo, "Outputs") for pdo in device.getRxPdo()]):
+                    entries = pdo.getEntry()
+                    
+                    pdo_index = ExtractHexDecValue(pdo.getIndex().getcontent())
+                    if pdo_index in excluded_pdos:
+                        continue
+                    
+                    pdo_needed = pdo_index in selected_pdos
+                    
+                    entries_infos = []
+                    
+                    for entry in entries:
+                        index = ExtractHexDecValue(entry.getIndex().getcontent())
+                        subindex = ExtractHexDecValue(entry.getSubIndex())
+                        entry_infos = {
+                            "index": index,
+                            "subindex": subindex,
+                            "name": ExtractName(entry.getName()),
+                            "bitlen": entry.getBitLen(),
+                        }
+                        entry_infos.update(type_infos)
+                        entries_infos.append("    {0x%(index).4x, 0x%(subindex).2x, %(bitlen)d}, /* %(name)s */" % entry_infos)
+                        
+                        entry_declaration = slave_variables.get((index, subindex), None)
+                        if entry_declaration is not None and not entry_declaration["mapped"]:
+                            pdo_needed = True
+                            
+                            entry_infos.update(dict(zip(["var_type", "dir", "var_name", "no_decl", "extra_declarations"], 
+                                                        entry_declaration["infos"])))
+                            entry_declaration["mapped"] = True
+                            
+                            entry_type = entry.getDataType().getcontent()
+                            if entry_infos["var_type"] != entry_type:
+                                message = _("Wrong type for location \"%s\"!") % entry_infos["var_name"]
+                                if (self.Controler.GetSizeOfType(entry_infos["var_type"]) != 
+                                    self.Controler.GetSizeOfType(entry_type)):
+                                    raise ValueError, message
+                                else:
+                                    self.Controler.GetCTRoot().logger.write_warning(_("Warning: ") + message + "\n")
+                            
+                            if (entry_infos["dir"] == "I" and pdo_type != "Inputs" or 
+                                entry_infos["dir"] == "Q" and pdo_type != "Outputs"):
+                                raise ValueError, _("Wrong direction for location \"%s\"!") % entry_infos["var_name"]
+                            
+                            ConfigureVariable(entry_infos, str_completion)
+                        
+                        elif pdo_type == "Outputs" and entry.getDataType() is not None and device_coe is not None:
+                            data_type = entry.getDataType().getcontent()
+                            entry_infos["dir"] = "Q"
+                            entry_infos["data_size"] = max(1, entry_infos["bitlen"] / 8)
+                            entry_infos["data_type"] = DATATYPECONVERSION.get(data_type)
+                            entry_infos["var_type"] = data_type
+                            entry_infos["real_var"] = "slave%(slave)d_%(index).4x_%(subindex).2x_default" % entry_infos
+                            
+                            ConfigureVariable(entry_infos, str_completion)
+                            
+                            str_completion["slaves_output_pdos_default_values_extraction"] += \
+                                SLAVE_OUTPUT_PDO_DEFAULT_VALUE % entry_infos
+                            
+                    if pdo_needed:
+                        for excluded in pdo.getExclude():
+                            excluded_index = ExtractHexDecValue(excluded.getcontent())
+                            if excluded_index not in excluded_pdos:
+                                excluded_pdos.append(excluded_index)
+                        
+                        sm = pdo.getSm()
+                        if sm is None:
+                            for sm_idx, sync_manager in enumerate(sync_managers):
+                                if sync_manager["name"] == pdo_type:
+                                    sm = sm_idx
+                        if sm is None:
+                            raise ValueError, _("No sync manager available for %s pdo!") % pdo_type
+                            
+                        sync_managers[sm]["pdos_number"] += 1
+                        sync_managers[sm]["pdos"].append(
+                            {"slave": slave_idx,
+                             "index": pdo_index,
+                             "name": ExtractName(pdo.getName()),
+                             "type": pdo_type, 
+                             "entries": entries_infos,
+                             "entries_number": len(entries_infos),
+                             "fixed": pdo.getFixed() == True})
+            
+                if PdoConfig and PdoAssign:
+                    dynamic_pdos = {}
+                    dynamic_pdos_number = 0
+                    for category, min_index, max_index in [("Inputs", 0x1600, 0x1800), 
+                                                           ("Outputs", 0x1a00, 0x1C00)]:
+                        for sync_manager in sync_managers:
+                            if sync_manager["name"] == category:
+                                category_infos = dynamic_pdos.setdefault(category, {})
+                                category_infos["sync_manager"] = sync_manager
+                                category_infos["pdos"] = [pdo for pdo in category_infos["sync_manager"]["pdos"] 
+                                                          if not pdo["fixed"] and pdo["type"] == category]
+                                category_infos["current_index"] = min_index
+                                category_infos["max_index"] = max_index
+                                break
+                    
+                    for (index, subindex), entry_declaration in slave_variables.iteritems():
+                        
+                        if not entry_declaration["mapped"]:
+                            entry = device_entries.get((index, subindex), None)
+                            if entry is None:
+                                raise ValueError, _("Unknown entry index 0x%4.4x, subindex 0x%2.2x for device %s") % \
+                                                 (index, subindex, type_infos["device_type"])
+                            
                             entry_infos = {
                                 "index": index,
                                 "subindex": subindex,
-                                "name": ExtractName(entry.getName()),
-                                "bitlen": entry.getBitLen(),
+                                "name": entry["Name"],
+                                "bitlen": entry["BitSize"],
                             }
                             entry_infos.update(type_infos)
-                            entries_infos.append("    {0x%(index).4x, 0x%(subindex).2x, %(bitlen)d}, /* %(name)s */" % entry_infos)
-                            
-                            entry_declaration = slave_variables.get((index, subindex), None)
-                            if entry_declaration is not None and not entry_declaration["mapped"]:
-                                pdo_needed = True
+                            
+                            entry_infos.update(dict(zip(["var_type", "dir", "var_name", "no_decl", "extra_declarations"], 
+                                                        entry_declaration["infos"])))
+                            entry_declaration["mapped"] = True
+                            
+                            if entry_infos["var_type"] != entry["Type"]:
+                                message = _("Wrong type for location \"%s\"!") % entry_infos["var_name"]
+                                if (self.Controler.GetSizeOfType(entry_infos["var_type"]) != 
+                                    self.Controler.GetSizeOfType(entry["Type"])):
+                                    raise ValueError, message
+                                else:
+                                    self.Controler.GetCTRoot().logger.write_warning(message + "\n")
+                            
+                            if entry_infos["dir"] == "I" and entry["PDOMapping"] in ["T", "RT"]:
+                                pdo_type = "Inputs"
+                            elif entry_infos["dir"] == "Q" and entry["PDOMapping"] in ["R", "RT"]:
+                                pdo_type = "Outputs"
+                            else:
+                                raise ValueError, _("Wrong direction for location \"%s\"!") % entry_infos["var_name"]
+                            
+                            if not dynamic_pdos.has_key(pdo_type):
+                                raise ValueError, _("No Sync manager defined for %s!") % pdo_type
+                            
+                            ConfigureVariable(entry_infos, str_completion)
+                            
+                            if len(dynamic_pdos[pdo_type]["pdos"]) > 0:
+                                pdo = dynamic_pdos[pdo_type]["pdos"][0]
+                            elif module_extra_params["add_pdo"]:
+                                while dynamic_pdos[pdo_type]["current_index"] in pdos_index:
+                                    dynamic_pdos[pdo_type]["current_index"] += 1
+                                if dynamic_pdos[pdo_type]["current_index"] >= dynamic_pdos[pdo_type]["max_index"]:
+                                    raise ValueError, _("No more free PDO index available for %s!") % pdo_type
+                                pdos_index.append(dynamic_pdos[pdo_type]["current_index"])
                                 
-                                entry_infos.update(dict(zip(["var_type", "dir", "var_name", "no_decl", "extra_declarations"], 
-                                                            entry_declaration["infos"])))
-                                entry_declaration["mapped"] = True
-                                
-                                entry_type = entry.getDataType().getcontent()
-                                if entry_infos["var_type"] != entry_type:
-                                    message = _("Wrong type for location \"%s\"!") % entry_infos["var_name"]
-                                    if (self.Controler.GetSizeOfType(entry_infos["var_type"]) != 
-                                        self.Controler.GetSizeOfType(entry_type)):
-                                        raise ValueError, message
-                                    else:
-                                        self.Controler.GetCTRoot().logger.write_warning(_("Warning: ") + message + "\n")
-                                
-                                if (entry_infos["dir"] == "I" and pdo_type != "Inputs" or 
-                                    entry_infos["dir"] == "Q" and pdo_type != "Outputs"):
-                                    raise ValueError, _("Wrong direction for location \"%s\"!") % entry_infos["var_name"]
-                                
-                                ConfigureVariable(entry_infos, str_completion)
-                            
-                            elif pdo_type == "Outputs" and entry.getDataType() is not None and device_coe is not None:
-                                data_type = entry.getDataType().getcontent()
-                                entry_infos["dir"] = "Q"
-                                entry_infos["data_size"] = max(1, entry_infos["bitlen"] / 8)
-                                entry_infos["data_type"] = DATATYPECONVERSION.get(data_type)
-                                entry_infos["var_type"] = data_type
-                                entry_infos["real_var"] = "slave%(slave)d_%(index).4x_%(subindex).2x_default" % entry_infos
-                                
-                                ConfigureVariable(entry_infos, str_completion)
-                                
-                                str_completion["slaves_output_pdos_default_values_extraction"] += \
-                                    SLAVE_OUTPUT_PDO_DEFAULT_VALUE % entry_infos
-                                
-                        if pdo_needed:
-                            for excluded in pdo.getExclude():
-                                excluded_index = ExtractHexDecValue(excluded.getcontent())
-                                if excluded_index not in excluded_pdos:
-                                    excluded_pdos.append(excluded_index)
-                            
-                            sm = pdo.getSm()
-                            if sm is None:
-                                for sm_idx, sync_manager in enumerate(sync_managers):
-                                    if sync_manager["name"] == pdo_type:
-                                        sm = sm_idx
-                            if sm is None:
-                                raise ValueError, _("No sync manager available for %s pdo!") % pdo_type
-                                
-                            sync_managers[sm]["pdos_number"] += 1
-                            sync_managers[sm]["pdos"].append(
-                                {"slave": slave_idx,
-                                 "index": pdo_index,
-                                 "name": ExtractName(pdo.getName()),
-                                 "type": pdo_type, 
-                                 "entries": entries_infos,
-                                 "entries_number": len(entries_infos),
-                                 "fixed": pdo.getFixed() == True})
-                
-                    if PdoConfig and PdoAssign:
-                        dynamic_pdos = {}
-                        dynamic_pdos_number = 0
-                        for category, min_index, max_index in [("Inputs", 0x1600, 0x1800), 
-                                                               ("Outputs", 0x1a00, 0x1C00)]:
-                            for sync_manager in sync_managers:
-                                if sync_manager["name"] == category:
-                                    category_infos = dynamic_pdos.setdefault(category, {})
-                                    category_infos["sync_manager"] = sync_manager
-                                    category_infos["pdos"] = [pdo for pdo in category_infos["sync_manager"]["pdos"] 
-                                                              if not pdo["fixed"] and pdo["type"] == category]
-                                    category_infos["current_index"] = min_index
-                                    category_infos["max_index"] = max_index
-                                    break
-                        
-                        for (index, subindex), entry_declaration in slave_variables.iteritems():
-                            
-                            if not entry_declaration["mapped"]:
-                                entry = device_entries.get((index, subindex), None)
-                                if entry is None:
-                                    raise ValueError, _("Unknown entry index 0x%4.4x, subindex 0x%2.2x for device %s") % \
-                                                     (index, subindex, type_infos["device_type"])
-                                
-                                entry_infos = {
-                                    "index": index,
-                                    "subindex": subindex,
-                                    "name": entry["Name"],
-                                    "bitlen": entry["BitSize"],
-                                }
-                                entry_infos.update(type_infos)
-                                
-                                entry_infos.update(dict(zip(["var_type", "dir", "var_name", "no_decl", "extra_declarations"], 
-                                                            entry_declaration["infos"])))
-                                entry_declaration["mapped"] = True
-                                
-                                if entry_infos["var_type"] != entry["Type"]:
-                                    message = _("Wrong type for location \"%s\"!") % entry_infos["var_name"]
-                                    if (self.Controler.GetSizeOfType(entry_infos["var_type"]) != 
-                                        self.Controler.GetSizeOfType(entry["Type"])):
-                                        raise ValueError, message
-                                    else:
-                                        self.Controler.GetCTRoot().logger.write_warning(message + "\n")
-                                
-                                if entry_infos["dir"] == "I" and entry["PDOMapping"] in ["T", "RT"]:
-                                    pdo_type = "Inputs"
-                                elif entry_infos["dir"] == "Q" and entry["PDOMapping"] in ["R", "RT"]:
-                                    pdo_type = "Outputs"
-                                else:
-                                    raise ValueError, _("Wrong direction for location \"%s\"!") % entry_infos["var_name"]
-                                
-                                if not dynamic_pdos.has_key(pdo_type):
-                                    raise ValueError, _("No Sync manager defined for %s!") % pdo_type
-                                
-                                ConfigureVariable(entry_infos, str_completion)
-                                
-                                if len(dynamic_pdos[pdo_type]["pdos"]) > 0:
-                                    pdo = dynamic_pdos[pdo_type]["pdos"][0]
-                                elif module_extra_params["add_pdo"]:
-                                    while dynamic_pdos[pdo_type]["current_index"] in pdos_index:
-                                        dynamic_pdos[pdo_type]["current_index"] += 1
-                                    if dynamic_pdos[pdo_type]["current_index"] >= dynamic_pdos[pdo_type]["max_index"]:
-                                        raise ValueError, _("No more free PDO index available for %s!") % pdo_type
-                                    pdos_index.append(dynamic_pdos[pdo_type]["current_index"])
-                                    
-                                    dynamic_pdos_number += 1
-                                    pdo = {"slave": slave_idx,
-                                           "index": dynamic_pdos[pdo_type]["current_index"],
-                                           "name": "Dynamic PDO %d" % dynamic_pdos_number,
-                                           "type": pdo_type, 
-                                           "entries": [],
-                                           "entries_number": 0,
-                                           "fixed": False}
-                                    dynamic_pdos[pdo_type]["sync_manager"]["pdos_number"] += 1
-                                    dynamic_pdos[pdo_type]["sync_manager"]["pdos"].append(pdo)
-                                    dynamic_pdos[pdo_type]["pdos"].append(pdo)
-                                else:
-                                    break
-                                
-                                pdo["entries"].append("    {0x%(index).4x, 0x%(subindex).2x, %(bitlen)d}, /* %(name)s */" % entry_infos)
-                                if entry_infos["bitlen"] < module_extra_params["pdo_alignment"]:
-                                    pdo["entries"].append("    {0x0000, 0x00, %d}, /* None */" % (
-                                            module_extra_params["pdo_alignment"] - entry_infos["bitlen"]))
-                                pdo["entries_number"] += 1
-                                
-                                if pdo["entries_number"] == module_extra_params["max_pdo_size"]:
-                                    dynamic_pdos[pdo_type]["pdos"].pop(0)
-                    
-                    pdo_offset = 0
-                    entry_offset = 0
-                    for sync_manager_infos in sync_managers:
-                    
-                        for pdo_infos in sync_manager_infos["pdos"]:
-                            pdo_infos["offset"] = entry_offset
-                            pdo_entries = pdo_infos["entries"]
-                            pdos_infos["pdos_infos"].append(
-                                ("    {0x%(index).4x, %(entries_number)d, " + 
-                                 "slave_%(slave)d_pdo_entries + %(offset)d}, /* %(name)s */") % pdo_infos)
-                            entry_offset += len(pdo_entries)
-                            pdos_infos["pdos_entries_infos"].extend(pdo_entries)
-                        
-                        sync_manager_infos["offset"] = pdo_offset
-                        pdo_offset_shift = sync_manager_infos["pdos_number"]
-                        pdos_infos["pdos_sync_infos"].append(
-                            ("    {%(index)d, %(sync_manager_type)s, %(pdos_number)d, " + 
-                             ("slave_%(slave)d_pdos + %(offset)d" if pdo_offset_shift else "NULL") +
-                             ", %(watchdog)s},") % sync_manager_infos)
-                        pdo_offset += pdo_offset_shift  
-                    
-                    for element in ["pdos_entries_infos", "pdos_infos", "pdos_sync_infos"]:
-                        pdos_infos[element] = "\n".join(pdos_infos[element])
-                    
-                    str_completion["pdos_configuration_declaration"] += SLAVE_PDOS_CONFIGURATION_DECLARATION % pdos_infos
-                
-                for (index, subindex), entry_declaration in slave_variables.iteritems():
-                    if not entry_declaration["mapped"]:
-                        message = _("Entry index 0x%4.4x, subindex 0x%2.2x not mapped for device %s") % \
-                                        (index, subindex, type_infos["device_type"])
-                        self.Controler.GetCTRoot().logger.write_warning(_("Warning: ") + message + "\n")
+                                dynamic_pdos_number += 1
+                                pdo = {"slave": slave_idx,
+                                       "index": dynamic_pdos[pdo_type]["current_index"],
+                                       "name": "Dynamic PDO %d" % dynamic_pdos_number,
+                                       "type": pdo_type, 
+                                       "entries": [],
+                                       "entries_number": 0,
+                                       "fixed": False}
+                                dynamic_pdos[pdo_type]["sync_manager"]["pdos_number"] += 1
+                                dynamic_pdos[pdo_type]["sync_manager"]["pdos"].append(pdo)
+                                dynamic_pdos[pdo_type]["pdos"].append(pdo)
+                            else:
+                                break
+                            
+                            pdo["entries"].append("    {0x%(index).4x, 0x%(subindex).2x, %(bitlen)d}, /* %(name)s */" % entry_infos)
+                            if entry_infos["bitlen"] < module_extra_params["pdo_alignment"]:
+                                pdo["entries"].append("    {0x0000, 0x00, %d}, /* None */" % (
+                                        module_extra_params["pdo_alignment"] - entry_infos["bitlen"]))
+                            pdo["entries_number"] += 1
+                            
+                            if pdo["entries_number"] == module_extra_params["max_pdo_size"]:
+                                dynamic_pdos[pdo_type]["pdos"].pop(0)
+                
+                pdo_offset = 0
+                entry_offset = 0
+                for sync_manager_infos in sync_managers:
+                
+                    for pdo_infos in sync_manager_infos["pdos"]:
+                        pdo_infos["offset"] = entry_offset
+                        pdo_entries = pdo_infos["entries"]
+                        pdos_infos["pdos_infos"].append(
+                            ("    {0x%(index).4x, %(entries_number)d, " + 
+                             "slave_%(slave)d_pdo_entries + %(offset)d}, /* %(name)s */") % pdo_infos)
+                        entry_offset += len(pdo_entries)
+                        pdos_infos["pdos_entries_infos"].extend(pdo_entries)
+                    
+                    sync_manager_infos["offset"] = pdo_offset
+                    pdo_offset_shift = sync_manager_infos["pdos_number"]
+                    pdos_infos["pdos_sync_infos"].append(
+                        ("    {%(index)d, %(sync_manager_type)s, %(pdos_number)d, " + 
+                         ("slave_%(slave)d_pdos + %(offset)d" if pdo_offset_shift else "NULL") +
+                         ", %(watchdog)s},") % sync_manager_infos)
+                    pdo_offset += pdo_offset_shift  
+                
+                for element in ["pdos_entries_infos", "pdos_infos", "pdos_sync_infos"]:
+                    pdos_infos[element] = "\n".join(pdos_infos[element])
+                
+                str_completion["pdos_configuration_declaration"] += SLAVE_PDOS_CONFIGURATION_DECLARATION % pdos_infos
+            
+            for (index, subindex), entry_declaration in slave_variables.iteritems():
+                if not entry_declaration["mapped"]:
+                    message = _("Entry index 0x%4.4x, subindex 0x%2.2x not mapped for device %s") % \
+                                    (index, subindex, type_infos["device_type"])
+                    self.Controler.GetCTRoot().logger.write_warning(_("Warning: ") + message + "\n")
                     
         for element in ["used_pdo_entry_offset_variables_declaration", 
                         "used_pdo_entry_configuration",