|
40 | 40 |
|
41 | 41 | class ExperimentWindow(QMainWindow): |
42 | 42 | experiment_finished = pyqtSignal([bool]) |
| 43 | + |
43 | 44 | MAX_GENERATIONS = 30 |
44 | 45 |
|
45 | 46 | def __init__(self, mlc_local, |
@@ -285,29 +286,9 @@ def on_board_config_button_clicked(self): |
285 | 286 | logger.debug('[EXPERIMENT {0}] [BOARD_CONFIG_BUTTON] - Executing on_board_config_button_clicked function') |
286 | 287 | #FIXME Connection config name should not be related with "serial" |
287 | 288 | valid_connection = False |
288 | | - while not valid_connection: |
289 | | - board_config_window = ArduinoBoardManager(protocol_config=self._board_config, serial_config=self._serial_conn, parent_win=self) |
290 | | - board_config_window.start() |
291 | | - # The namedtuples are immutables, so we must replace to reference in order to keep the changes in the configuration |
292 | | - self._board_config = board_config_window.get_protocol_config() |
293 | | - self._serial_conn = board_config_window.get_connection_config() |
294 | | - print self._serial_conn |
295 | | - |
296 | | - try: |
297 | | - self._board_config = self._board_config._replace(connection = SerialConnection(**self._serial_conn._asdict())) |
298 | | - valid_connection = True |
299 | | - except: |
300 | | - selection = QMessageBox.critical(self, "Connection failure", |
301 | | - "The current connection setup failed during initialization. Do you want to change this configuration? \ |
302 | | - (Choosing \"no\" means that the board will not be usable in the experiment)" |
303 | | - .format(preev_path), |
304 | | - QMessageBox.Yes | No, QMessageBox.Yes) |
305 | | - if selection == QMessageBox.Yes: |
306 | | - pass |
307 | | - else: |
308 | | - #FIXME: If the pin setups aren't empty then the protocol init will fail |
309 | | - self._board_config = self._board_config._replace(connection = BaseConnection()) |
310 | | - valid_connection = True |
| 289 | + board_config_window = ArduinoBoardManager(protocol_config=self._board_config, serial_config=self._serial_conn, |
| 290 | + close_handler=self.on_board_config_button_clicked, parent_win=self) |
| 291 | + board_config_window.start() |
311 | 292 |
|
312 | 293 | def _config_table_edited(self, left, right): |
313 | 294 | config_table = self._autogenerated_object.config_table |
@@ -580,3 +561,34 @@ def _update_experiment(self, cancelled): |
580 | 561 | self._update_individuals_per_generation_list() |
581 | 562 | self._update_experiment_info() |
582 | 563 | self._update_individuals_figure() |
| 564 | + |
| 565 | + def _store_board_configuration(self, board_config, serial_conn): |
| 566 | + # Pass the parameter as a list to mock PyQt fixed data types |
| 567 | + logger.debug('[EXPERIMENT {0}] [BOARD_CONFIG] - ' |
| 568 | + 'Board has been configured' |
| 569 | + .format(self._experiment_name)) |
| 570 | + |
| 571 | + self._board_config = board_config[0] |
| 572 | + self._serial_conn = serial_conn[0] |
| 573 | + |
| 574 | + # Init the arduino singleton |
| 575 | + try: |
| 576 | + self._board_config = self._board_config._replace(connection = SerialConnection(**self._serial_conn._asdict())) |
| 577 | + #ArduinoInterfaceSingleton.get_instance(protocol_setup=self._board_config, |
| 578 | + # conn_setup=self._serial_conn) |
| 579 | + except Exception, err: |
| 580 | + logger.debug('[EXPERIMENT {0}] [BOARD_CONFIG] - ' |
| 581 | + 'Serial port could not be initialized. Error Msg: {1}' |
| 582 | + .format(self._experiment_name, err)) |
| 583 | + selection = QMessageBox.critical(self, "Connection failure", |
| 584 | + "The current connection setup failed during initialization. Do you want to change this configuration? \ |
| 585 | + (Choosing \"no\" means that the board will not be usable in the experiment)" |
| 586 | + .format(preev_path), |
| 587 | + QMessageBox.Yes | No, QMessageBox.Yes) |
| 588 | + if selection == QMessageBox.Yes: |
| 589 | + #self.on_board_config_button_clicked() |
| 590 | + print "FUCK" |
| 591 | + else: |
| 592 | + #FIXME: If the pin setups aren't empty then the protocol init will fail |
| 593 | + self._board_config = self._board_config._replace(connection = BaseConnection()) |
| 594 | + |
0 commit comments