def setup_task(self): try: task = self.task_select.currentText() if self.uploaded: self.status_text.setText('Resetting task..') else: self.status_text.setText('Uploading..') self.task_hash = _djb2_file( os.path.join(tasks_dir, task + '.py')) self.start_button.setEnabled(False) self.variables_button.setEnabled(False) self.repaint() self.board.setup_state_machine(task, uploaded=self.uploaded) if self.variables_dialog: self.variables_button.clicked.disconnect() self.variables_dialog.deleteLater() self.variables_dialog = Variables_dialog(self, self.board) self.variables_button.clicked.connect(self.variables_dialog.exec_) self.variables_button.setEnabled(True) self.task_plot.set_state_machine(self.board.sm_info) self.file_groupbox.setEnabled(True) self.session_groupbox.setEnabled(True) self.start_button.setEnabled(True) self.stop_button.setEnabled(False) self.status_text.setText('Uploaded : ' + task) self.task = task self.fresh_task = True self.uploaded = True self.upload_button.setText('Reset') except PyboardError: self.status_text.setText('Error setting up state machine.')
def setup_task(self): task = self.task_select.text() if task == "select task": return try: if self.uploaded: self.status_text.setText("Resetting task..") else: self.status_text.setText("Uploading..") self.task_hash = _djb2_file( os.path.join(dirs["tasks"], task + ".py")) self.start_button.setEnabled(False) self.variables_button.setEnabled(False) self.repaint() self.board.setup_state_machine(task, uploaded=self.uploaded) if self.variables_dialog: self.variables_button.clicked.disconnect() self.variables_dialog.deleteLater() self.task = task if "custom_variables_dialog" in self.board.sm_info["variables"]: custom_variables_name = eval( self.board.sm_info["variables"]["custom_variables_dialog"]) potential_dialog = Custom_variables_dialog( self, custom_variables_name) if potential_dialog.using_custom_gui: self.variables_dialog = potential_dialog self.using_custom_gui = True else: self.variables_dialog = Variables_dialog(self, self.board) self.using_custom_gui = False else: self.variables_dialog = Variables_dialog(self, self.board) self.using_custom_gui = False self.variables_button.clicked.connect(self.variables_dialog.exec_) self.variables_button.setEnabled(True) self.task_plot.set_state_machine(self.board.sm_info) self.task_info.set_state_machine(self.board.sm_info) self.file_groupbox.setEnabled(True) self.session_groupbox.setEnabled(True) self.start_button.setEnabled(True) self.stop_button.setEnabled(False) self.status_text.setText("Uploaded : " + task) self.fresh_task = True self.uploaded = True self.upload_button.setText("Reset") self.upload_button.setIcon(QtGui.QIcon("gui/icons/refresh.svg")) except PyboardError: self.status_text.setText("Error setting up state machine.")
def refresh(self): # Called regularly when framework not running. if self.GUI_main.setups_tab.available_setups_changed: self.board_select.clear() self.board_select.addItems(self.GUI_main.setups_tab.setup_names) if self.GUI_main.available_tasks_changed: self.task_select.clear() self.task_select.addItems(sorted(self.GUI_main.available_tasks)) if self.task: try: task_path = os.path.join(tasks_dir, self.task + '.py') if not self.task_hash == _djb2_file( task_path): # Task file modified. self.task_changed() except FileNotFoundError: pass
def refresh(self): # Called regularly when framework not running. if self.GUI_main.setups_tab.available_setups_changed: self.board_select.clear() if self.GUI_main.setups_tab.setup_names: self.board_select.addItems( self.GUI_main.setups_tab.setup_names) if not self.connected: self.connect_button.setEnabled(True) else: # No setups available to connect to. self.connect_button.setEnabled(False) if self.GUI_main.available_tasks_changed: self.task_select.update_menu(dirs['tasks']) if self.GUI_main.data_dir_changed and not self.custom_dir: self.data_dir_text.setText(dirs['data']) if self.task: try: task_path = os.path.join(dirs['tasks'], self.task + '.py') if not self.task_hash == _djb2_file( task_path): # Task file modified. self.task_changed() except FileNotFoundError: pass