def on_btn_simulate_clicked(self): if not self.simulator_config.protocol_valid(): QMessageBox.critical(self, self.tr("Invalid protocol configuration"), self.tr( "There are some problems with your protocol configuration. Please fix them first.")) return if not len(self.simulator_config.get_all_messages()): QMessageBox.critical(self, self.tr("No messages found"), self.tr("Please add at least one message.")) return num_simulated = len([p for p in self.project_manager.participants if p.simulate]) if num_simulated == 0: if self.ui.listViewSimulate.model().rowCount() == 0: QMessageBox.critical(self, self.tr("No active participants"), self.tr("You have no active participants.<br>" "Please add a participant in the <i>Participants tab</i> and " "assign it to at least one message as <i>source</i> or <i>destination.</i>")) return else: QMessageBox.critical(self, self.tr("No participant for simulation selected"), self.tr("Please check at least one participant from the " "<i>Simulate these participants</i> list.")) return try: self.get_simulator_dialog().exec_() except Exception as e: Errors.exception(e)
def show_open_dialog(self, directory=False): dialog = FileOperator.get_open_dialog(directory_mode=directory, parent=self, name_filter="full") if dialog.exec_(): try: file_names = dialog.selectedFiles() folders = [ folder for folder in file_names if os.path.isdir(folder) ] if len(folders) > 0: folder = folders[0] for f in self.signal_tab_controller.signal_frames: self.close_signal_frame(f) self.project_manager.set_project_folder(folder) else: self.setCursor(Qt.WaitCursor) file_names = FileOperator.uncompress_archives( file_names, QDir.tempPath()) self.add_files(file_names) self.unsetCursor() except Exception as e: Errors.exception(e) self.unsetCursor()
def close_signal_frame(self, signal_frame: SignalFrame): try: self.project_manager.write_signal_information_to_project_file( signal_frame.signal) try: proto = self.signal_protocol_dict[signal_frame] except KeyError: proto = None if proto is not None: self.close_protocol(proto) del self.signal_protocol_dict[signal_frame] if self.signal_tab_controller.ui.scrlAreaSignals.minimumHeight( ) > signal_frame.height(): self.signal_tab_controller.ui.scrlAreaSignals.setMinimumHeight( self.signal_tab_controller.ui.scrlAreaSignals. minimumHeight() - signal_frame.height()) if signal_frame.signal is not None: # Non-Empty Frame (when a signal and not a protocol is opened) self.file_proxy_model.open_files.discard( signal_frame.signal.filename) signal_frame.eliminate() self.compare_frame_controller.ui.treeViewProtocols.expandAll() self.set_frame_numbers() self.refresh_main_menu() except Exception as e: Errors.exception(e) self.unsetCursor()
def on_selected_tx_device_changed(self): old_name = self.simulator.sender.device_name try: dev_name = self.device_settings_tx_widget.ui.cbDevice.currentText() self.simulator.sender.device_name = dev_name self.device_settings_tx_widget.device = self.simulator.sender.device except Exception as e: self.device_settings_tx_widget.ui.cbDevice.setCurrentText(old_name) Errors.exception(e)
def on_open_recent_action_triggered(self): action = self.sender() try: if os.path.isdir(action.data()): self.project_manager.set_project_folder(action.data()) elif os.path.isfile(action.data()): self.setCursor(Qt.WaitCursor) self.add_files(FileOperator.uncompress_archives([action.data()], QDir.tempPath())) self.unsetCursor() except Exception as e: Errors.exception(e) self.unsetCursor()
def on_btn_send_clicked(self): try: total_samples = self.total_modulated_samples buffer = self.prepare_modulation_buffer(total_samples) if buffer is not None: modulated_data = self.modulate_data(buffer) else: # Enter continuous mode modulated_data = None try: if modulated_data is not None: try: dialog = SendDialog( self.project_manager, modulated_data=modulated_data, modulation_msg_indices=self.modulation_msg_indices, parent=self) except MemoryError: # Not enough memory for device buffer so we need to create a continuous send dialog del modulated_data Errors.not_enough_ram_for_sending_precache(None) dialog = ContinuousSendDialog( self.project_manager, self.table_model.protocol.messages, self.modulators, total_samples, parent=self) else: dialog = ContinuousSendDialog( self.project_manager, self.table_model.protocol.messages, self.modulators, total_samples, parent=self) except OSError as e: logger.exception(e) return if dialog.has_empty_device_list: Errors.no_device() dialog.close() return dialog.device_parameters_changed.connect( self.project_manager.set_device_parameters) dialog.show() dialog.graphics_view.show_full_scene(reinitialize=True) except Exception as e: Errors.exception(e) self.unsetCursor()
def generate_file(self): try: total_samples = self.total_modulated_samples buffer = self.prepare_modulation_buffer(total_samples, show_error=False) if buffer is None: Errors.generic_error(self.tr("File too big"), self.tr("This file would get too big to save.")) self.unsetCursor() return modulated_samples = self.modulate_data(buffer) try: sample_rate = self.modulators[0].sample_rate except Exception as e: logger.exception(e) sample_rate = 1e6 FileOperator.save_data_dialog("generated", modulated_samples, sample_rate=sample_rate, parent=self) except Exception as e: Errors.exception(e) self.unsetCursor()