def on_send_clicked(self): input_string = self._ui.txt_send.toPlainText() if input_string == '': now = time.strftime('%H:%M:%S', time.localtime()) self._ui.txt_receive.append('[' + now + ']\t' + '输入指令为空') return command_queue.push(input_string) self._update_current_cmd() self._execute_current_cmd()
def on_apply_clicked(self): temp_address = self._ui.radio_address.text() temp_power = self._ui.radio_power.text() if temp_address == '' or temp_power == '': QMessageBox.critical(self, 'Message', '网络地址或功率为空') return if not temp_address.isdigit() or not temp_power.isdigit(): QMessageBox.critical(self, 'Message', '网络地址或功率格式错误') return temp_mode = 0 if self._ui.radio_client.isChecked(): temp_mode = 2 temp_baud_rate_index = self._ui.radio_baud_rate.currentIndex() # 修改配置 if temp_mode != self._mode: command_queue.push('ats101=' + str(temp_mode)) if temp_baud_rate_index != self._baud_rate_index: command_queue.push('ats102=' + str(temp_baud_rate_index)) if temp_address != self._address: command_queue.push('ats104=' + temp_address) if temp_power != self._power: command_queue.push('ats108=' + temp_power) if command_queue.is_empty(): now = time.strftime('%H:%M:%S', time.localtime()) self._ui.txt_receive.append('[' + now + ']\t' + '参数未发生变化') return self._update_current_cmd() self._execute_current_cmd()
def on_config_mode_clicked(self): if self._ui.btn_config_mode.text() == '进入配置模式': command_queue.push('+++') self._update_current_cmd() self._execute_current_cmd() self._ui.btn_config_mode.setText('保存并退出') self._ui.btn_config_mode.setStyleSheet("color:green;") self._ui.tab_parameter_conf.setEnabled(True) else: command_queue.push('at&wa') self._update_current_cmd() self._execute_current_cmd() self._ui.btn_config_mode.setText('进入配置模式') self._ui.btn_config_mode.setStyleSheet("color:black;") self._ui.tab_parameter_conf.setEnabled(False)
def test_is_empty(self): self.assertEqual(command_queue.is_empty(), True) command_queue.push('command_test') self.assertEqual(command_queue.is_empty(), False) self.assertEqual(command_queue.pop(), 'command_test') self.assertEqual(command_queue.is_empty(), True)
def test_push_and_pop(self): command_queue.push('command_test') self.assertEqual(command_queue.pop(), 'command_test')
def on_update_clicked(self): # 更新电台信息 input_string = 'at&v' command_queue.push(input_string) self._update_current_cmd() self._execute_current_cmd()