def init_modules(self):
for module_id, module_cfg in list(self._module_cfgs.items()):<EOL><INDENT>if module_id in self._modules or module_id in self._tx_module_groups:<EOL><INDENT>if module_id in self._modules:<EOL><INDENT>module_id_str = "<STR_LIT>" + module_id<EOL><DEDENT>else:<EOL><INDENT>module_id_str = module_id.split('<STR_LIT:=>', <NUM_LIT:1>)<EOL>module_id_str[<NUM_LIT:0>] = module_id_str[<NUM_LIT:0>].replace("<STR_LIT:_>", "<STR_LIT:U+0020>")<EOL>module_id_str = "<STR_LIT:=>".join(module_id_str)<EOL><DEDENT>logging.info("<STR_LIT>" % module_id_str)<EOL>if '<STR_LIT>' in self._module_run_conf[module_id] and self._module_run_conf[module_id]['<STR_LIT>'] is not None:<EOL><INDENT>if isinstance(self._module_run_conf[module_id]['<STR_LIT>'], str):<EOL><INDENT>self._module_run_conf[module_id]['<STR_LIT>'] = ast.literal_eval(self._module_run_conf[module_id]['<STR_LIT>'])<EOL><DEDENT>sp = namedtuple('<STR_LIT>', field_names=list(zip(*self._module_run_conf[module_id]['<STR_LIT>']))[<NUM_LIT:0>])<EOL>self._scan_parameters[module_id] = sp(*list(zip(*self._module_run_conf[module_id]['<STR_LIT>']))[<NUM_LIT:1>])<EOL><DEDENT>else:<EOL><INDENT>sp = namedtuple_with_defaults('<STR_LIT>', field_names=[])<EOL>self._scan_parameters[module_id] = sp()<EOL><DEDENT>if module_id in self._modules:<EOL><INDENT>last_configuration = self.get_configuration(module_id=module_id)<EOL><DEDENT>else:<EOL><INDENT>last_configuration = None<EOL><DEDENT>if (('<STR_LIT>' not in module_cfg or module_cfg['<STR_LIT>'] is None) and last_configuration is None) or (isinstance(module_cfg['<STR_LIT>'], int) and module_cfg['<STR_LIT>'] <= <NUM_LIT:0>):<EOL><INDENT>if '<STR_LIT>' in module_cfg:<EOL><INDENT>if module_cfg['<STR_LIT>'] is None:<EOL><INDENT>chip_address = <NUM_LIT:0><EOL>broadcast = True<EOL><DEDENT>else:<EOL><INDENT>chip_address = module_cfg['<STR_LIT>']<EOL>broadcast = False<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % module_id)<EOL><DEDENT>if '<STR_LIT>' in module_cfg and module_cfg['<STR_LIT>']:<EOL><INDENT>module_cfg['<STR_LIT>'] = FEI4Register(fe_type=module_cfg['<STR_LIT>'], chip_address=chip_address, broadcast=broadcast)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % module_id)<EOL><DEDENT><DEDENT>elif not module_cfg['<STR_LIT>'] and last_configuration:<EOL><INDENT>module_cfg['<STR_LIT>'] = FEI4Register(configuration_file=last_configuration)<EOL><DEDENT>elif isinstance(module_cfg['<STR_LIT>'], str):<EOL><INDENT>if os.path.isabs(module_cfg['<STR_LIT>']):  <EOL><INDENT>module_cfg['<STR_LIT>'] = FEI4Register(configuration_file=module_cfg['<STR_LIT>'])<EOL><DEDENT>else:  <EOL><INDENT>module_cfg['<STR_LIT>'] = FEI4Register(configuration_file=os.path.join(module_cfg['<STR_LIT>'], module_cfg['<STR_LIT>']))<EOL><DEDENT><DEDENT>elif isinstance(module_cfg['<STR_LIT>'], int) and module_cfg['<STR_LIT>'] > <NUM_LIT:0>:<EOL><INDENT>module_cfg['<STR_LIT>'] = FEI4Register(configuration_file=self.get_configuration(module_id=module_id, run_number=module_cfg['<STR_LIT>']))<EOL><DEDENT>elif not isinstance(module_cfg['<STR_LIT>'], FEI4Register):<EOL><INDENT>raise ValueError('<STR_LIT>' % module_id)<EOL><DEDENT>self._registers[module_id] = self._module_cfgs[module_id]['<STR_LIT>']<EOL>self._register_utils[module_id] = FEI4RegisterUtils(self._module_dut[module_id], self._module_cfgs[module_id]['<STR_LIT>'])<EOL>if module_id in self._modules:<EOL><INDENT>module_path = self.get_module_path(module_id)<EOL>if not os.path.exists(module_path):<EOL><INDENT>os.makedirs(module_path)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>for module_id in self._tx_module_groups:<EOL><INDENT>with self.access_module(module_id=module_id):<EOL><INDENT>self.register_utils.set_conf_mode()<EOL><DEDENT><DEDENT>for module_id in self._modules:<EOL><INDENT>logging.info("<STR_LIT>" % module_id)<EOL>with self.access_module(module_id=module_id):<EOL><INDENT>if self._run_conf['<STR_LIT>']:<EOL><INDENT>self.register_utils.global_reset()<EOL>self.register_utils.configure_all()<EOL><DEDENT>else:<EOL><INDENT>self.register_utils.set_conf_mode()<EOL><DEDENT>if is_fe_ready(self):<EOL><INDENT>fe_not_ready = False<EOL><DEDENT>else:<EOL><INDENT>fe_not_ready = True<EOL><DEDENT>if self._run_conf['<STR_LIT>']:<EOL><INDENT>self.register_utils.reset_bunch_counter()<EOL>self.register_utils.reset_event_counter()<EOL><DEDENT>if fe_not_ready:<EOL><INDENT>self.register_utils.reset_service_records()<EOL>if not is_fe_ready(self):<EOL><INDENT>logging.warning('<STR_LIT>' % module_id)<EOL><DEDENT><DEDENT>self.register_utils.set_conf_mode()<EOL><DEDENT><DEDENT>
Initialize all modules consecutively