From fe33514c40aaa2fe2fddf1adaaea5c28c2146716 Mon Sep 17 00:00:00 2001 From: "DESKTOP-7I8SUIC\\zhang" Date: Tue, 29 Jul 2025 22:01:19 +0800 Subject: [PATCH] add codes,modify config file --- acceleration.cpp | 12 ++-- acceleration.ui | 2 +- config_mgr.cpp | 131 +++++++++++++++++++------------------------ data_config.h | 12 +++- radial_vibration.cpp | 20 ++++--- seismic_monitor.cpp | 9 ++- trust.cpp | 12 ++-- velocity.cpp | 12 ++-- 8 files changed, 102 insertions(+), 108 deletions(-) diff --git a/acceleration.cpp b/acceleration.cpp index 76c8bc3..3e25a1a 100644 --- a/acceleration.cpp +++ b/acceleration.cpp @@ -65,8 +65,8 @@ void Acceleration::Init() { ui->comboBox_output_used->setCurrentIndex(0); else ui->comboBox_output_used->setCurrentIndex(1); - ui->comboBox_engineering_unit->setCurrentText(variable_ptr->general.engineering_unit); - ui->comboBox_rectifier_funtion->setCurrentText(variable_ptr->general.rectifier_function); + ui->comboBox_engineering_unit->setCurrentIndex(variable_ptr->general.engineering_unit); + ui->comboBox_rectifier_funtion->setCurrentIndex(variable_ptr->general.rectifier_function); // -alarm ui->lineEdit_danger_high_level->setText(QString::number(variable_ptr->danger_high.level)); ui->lineEdit_danger_high_hysteresis->setText(QString::number(variable_ptr->danger_high.hysteresis)); @@ -160,8 +160,8 @@ void Acceleration::on_pushButton_confirm_clicked() { variable->general.output_used = true; else variable->general.output_used = false; - variable->general.engineering_unit = ui->comboBox_engineering_unit->currentText(); - variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentText(); + variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); + variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); // -alarm variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble(); variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble(); @@ -234,8 +234,8 @@ void Acceleration::on_pushButton_confirm_clicked() { variable->general.output_used = true; else variable->general.output_used = false; - variable->general.engineering_unit = ui->comboBox_engineering_unit->currentText(); - variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentText(); + variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); + variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); // -alarm variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble(); variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble(); diff --git a/acceleration.ui b/acceleration.ui index fab8d3e..90138e4 100644 --- a/acceleration.ui +++ b/acceleration.ui @@ -403,7 +403,7 @@ - 1 + 0 diff --git a/config_mgr.cpp b/config_mgr.cpp index 61b6a31..cc6d81a 100644 --- a/config_mgr.cpp +++ b/config_mgr.cpp @@ -74,27 +74,15 @@ void ConfigMgr::Save(QString & file_path) { voltage_range.append(ptr->base_config_[cid].normal_voltage_low); voltage_range.append(ptr->base_config_[cid].normal_voltage_high); channel_item["normal_voltage_range"] = voltage_range; -// QJsonObject setpoint_data; -// if(ptr->base_config_[cid].channel_type == kVibRadial || ptr->base_config_[cid].channel_type == kVibThrust || -// ptr->base_config_[cid].channel_type == kVibAcc || ptr->base_config_[cid].channel_type == kVibVelocity ){ -// if(ptr->base_config_[cid].channel_type != kVibThrust){ -// setpoint_data["1x_ampl_upper"] = qRound(ptr->alert_danger[cid].x1_ampl_upper * 10)/10.0; -// setpoint_data["1x_ampl_lower"] = qRound(ptr->alert_danger[cid].x1_ampl_lower * 10)/10.0; -// setpoint_data["1x_ampl_enable"] = ptr->alert_danger[cid].x1_ampl_enable; -// setpoint_data["2x_ampl_upper"] = qRound(ptr->alert_danger[cid].x2_ampl_upper * 10)/10.0; -// setpoint_data["2x_ampl_lower"] = qRound(ptr->alert_danger[cid].x2_ampl_lower * 10)/10.0; -// setpoint_data["2x_ampl_enable"] = ptr->alert_danger[cid].x2_ampl_enable; -// channel_item["keyphase"] = ptr->base_config_[cid].keyphase; -// channel_item["keyphase_slot"] = ptr->base_config_[cid].keyphase_slot; -// channel_item["keyphase_ch"] = ptr->base_config_[cid].keyphase_ch; -// } -// setpoint_data["direct_upper"] = qRound(ptr->alert_danger[cid].direct_upper * 10)/10.0; -// setpoint_data["direct_enable"] = ptr->alert_danger[cid].direct_enable; -// setpoint_data["danger_param"] = ptr->alert_danger[cid].danger_param; -// setpoint_data["danger_upper"] = qRound(ptr->alert_danger[cid].danger_upper * 10)/10.0; -// setpoint_data["danger_enable"] = ptr->alert_danger[cid].danger_enable; - -// } + QJsonObject setpoint_data; + if(ptr->base_config_[cid].channel_type == kVibRadial || ptr->base_config_[cid].channel_type == kVibThrust || + ptr->base_config_[cid].channel_type == kVibAcc || ptr->base_config_[cid].channel_type == kVibVelocity ){ + if(ptr->base_config_[cid].channel_type != kVibThrust){ + channel_item["keyphase"] = ptr->base_config_[cid].keyphase; + channel_item["keyphase_slot"] = ptr->base_config_[cid].keyphase_slot; + channel_item["keyphase_ch"] = ptr->base_config_[cid].keyphase_ch; + } + } // if(ptr->base_config_[cid].channel_type == kVibPressurePulsation){ // setpoint_data["low_upper"] = qRound(ptr->alert_danger_press[cid].low_upper * 10)/10.0; // setpoint_data["low_enable"] = ptr->alert_danger_press[cid].low_enable; @@ -287,17 +275,17 @@ void ConfigMgr::Save(QString & file_path) { variables["sampling"] = sampling; variables["scaling"] = scaling; - QJsonArray freband_output_array; - QJsonObject freband_output; + QJsonObject freband_output,number; for (int var = 0; var < 10; ++var) { - if(pressure_ptr->freband_output[var].enable){ + if(pressure_ptr->freband_output[var].start != 0 || pressure_ptr->freband_output[var].end != 0){ freband_output["enable"] = pressure_ptr->freband_output[var].enable; freband_output["start"] = pressure_ptr->freband_output[var].start; freband_output["end"] = pressure_ptr->freband_output[var].end; - freband_output_array.append(freband_output); + number[QString::number(var + 1)] = freband_output; + //freband_output_array.append(freband_output); } } - variables["freband_output"] = freband_output_array; + variables["freband_output"] = number; } else if(ptr->base_config_[cid].channel_type == kVibAcc){ std::shared_ptr av_ptr = std::dynamic_pointer_cast(base_channel_ptr); @@ -351,17 +339,18 @@ void ConfigMgr::Save(QString & file_path) { processed_output["general"] = general; processed_output["alarm"] = alarm; variables["processed_output"] = processed_output; - QJsonArray freband_output_array; - QJsonObject freband_output; + //QJsonArray freband_output_array; + QJsonObject freband_output,number; for (int var = 0; var < 10; ++var) { - if(av_ptr->freband_output[var].enable){ + if(av_ptr->freband_output[var].start != 0 || av_ptr->freband_output[var].end != 0){ freband_output["enable"] = av_ptr->freband_output[var].enable; freband_output["start"] = av_ptr->freband_output[var].start; freband_output["end"] = av_ptr->freband_output[var].end; - freband_output_array.append(freband_output); + number[QString::number(var + 1)] = freband_output; + //freband_output_array.append(freband_output); } } - variables["freband_output"] = freband_output_array; + variables["freband_output"] = number; }else if(ptr->base_config_[cid].channel_type == kVibVelocity){ std::shared_ptr vel_ptr = std::dynamic_pointer_cast(base_channel_ptr); @@ -571,26 +560,17 @@ void ConfigMgr::Load(QString filename) { vib_data->base_config_[j].chan_id = channel["chan_id"].toString(); vib_data->base_config_[j].sensitivity_unit = channel["sensitivity_unit"].toInt(); vib_data->base_config_[j].signal_sensitivity = channel["signal_sensitivity"].toDouble(); - + vib_data->base_config_[j].keyphase = channel["keyphase"].toBool(); + vib_data->base_config_[j].keyphase_slot = channel["keyphase_slot"].toInt(); + vib_data->base_config_[j].keyphase_ch = channel["keyphase_ch"].toInt(); //setpoint -// QJsonObject setpoint_data = channel["setpoint"].toObject(); -// if(vib_data->base_config_[j].channel_type == kVibRadial || vib_data->base_config_[j].channel_type == kVibThrust || -// vib_data->base_config_[j].channel_type == kVibAcc ||vib_data->base_config_[j].channel_type == kVibVelocity ){ -// vib_data->alert_danger[j].direct_upper = setpoint_data["direct_upper"].toDouble(); -// vib_data->alert_danger[j].direct_enable = setpoint_data["direct_enable"].toBool(); -// vib_data->alert_danger[j].x1_ampl_upper = setpoint_data["1x_ampl_upper"].toDouble(); -// vib_data->alert_danger[j].x1_ampl_lower = setpoint_data["1x_ampl_lower"].toDouble(); -// vib_data->alert_danger[j].x1_ampl_enable = setpoint_data["1x_ampl_enable"].toBool(); -// vib_data->alert_danger[j].x2_ampl_upper = setpoint_data["2x_ampl_upper"].toDouble(); -// vib_data->alert_danger[j].x2_ampl_lower = setpoint_data["2x_ampl_lower"].toDouble(); -// vib_data->alert_danger[j].x2_ampl_enable = setpoint_data["2x_ampl_enable"].toBool(); -// vib_data->alert_danger[j].danger_param = setpoint_data["danger_param"].toInt(); -// vib_data->alert_danger[j].danger_upper = setpoint_data["danger_upper"].toDouble(); -// vib_data->alert_danger[j].danger_enable = setpoint_data["danger_enable"].toBool(); -// vib_data->base_config_[j].keyphase = channel["keyphase"].toBool(); -// vib_data->base_config_[j].keyphase_slot = channel["keyphase_slot"].toInt(); -// vib_data->base_config_[j].keyphase_ch = channel["keyphase_ch"].toInt(); -// } + QJsonObject setpoint_data = channel["setpoint"].toObject(); + if(vib_data->base_config_[j].channel_type == kVibRadial || vib_data->base_config_[j].channel_type == kVibThrust || + vib_data->base_config_[j].channel_type == kVibAcc ||vib_data->base_config_[j].channel_type == kVibVelocity ){ + vib_data->base_config_[j].keyphase = channel["keyphase"].toBool(); + vib_data->base_config_[j].keyphase_slot = channel["keyphase_slot"].toInt(); + vib_data->base_config_[j].keyphase_ch = channel["keyphase_ch"].toInt(); + } // if(vib_data->base_config_[j].channel_type == kVibPressurePulsation){ // vib_data->alert_danger_press[j].low_upper = setpoint_data["low_upper"].toDouble(); // vib_data->alert_danger_press[j].low_enable = setpoint_data["low_enable"].toBool(); @@ -624,8 +604,8 @@ void ConfigMgr::Load(QString filename) { g_general = gap["general"].toObject(); g_alarm = gap["alarm"].toObject(); variable->general.output_used = m_general["output_used"].toBool(); - variable->general.engineering_unit = m_general["engieneering_unit"].toString(); - variable->general.rectifier_function = m_general["rectifier_function"].toString(); + variable->general.engineering_unit = m_general["engieneering_unit"].toInt(); + variable->general.rectifier_function = m_general["rectifier_function"].toInt(); variable->danger_high.level = m_alarm["danger_high_level"].toDouble(); variable->danger_high.hysteresis = m_alarm["danger_high_hysteresis"].toDouble(); variable->danger_high.delay = m_alarm["danger_high_delay"].toInt(); @@ -648,8 +628,8 @@ void ConfigMgr::Load(QString filename) { variable->alert_low.latch = m_alarm["alert_low_latch"].toBool(); variable->gap_general.output_used = g_general["output_used"].toBool(); - variable->gap_general.engineering_unit = g_general["engieneering_unit"].toString(); - variable->gap_general.rectifier_function = g_general["rectifier_function"].toString(); + variable->gap_general.engineering_unit = g_general["engieneering_unit"].toInt(); + variable->gap_general.rectifier_function = g_general["rectifier_function"].toInt(); variable->gap_danger_high.level = g_alarm["danger_high_level"].toDouble(); variable->gap_danger_high.hysteresis = g_alarm["danger_high_hysteresis"].toDouble(); variable->gap_danger_high.delay = g_alarm["danger_high_delay"].toInt(); @@ -690,8 +670,8 @@ void ConfigMgr::Load(QString filename) { g_general = gap["general"].toObject(); g_alarm = gap["alarm"].toObject(); variable->gap_general.output_used = g_general["output_used"].toBool(); - variable->gap_general.engineering_unit = g_general["engieneering_unit"].toString(); - variable->gap_general.rectifier_function = g_general["rectifier_function"].toString(); + variable->gap_general.engineering_unit = g_general["engieneering_unit"].toInt(); + variable->gap_general.rectifier_function = g_general["rectifier_function"].toInt(); variable->gap_danger_high.level = g_alarm["danger_high_level"].toDouble(); variable->gap_danger_high.hysteresis = g_alarm["danger_high_hysteresis"].toDouble(); variable->gap_danger_high.delay = g_alarm["danger_high_delay"].toInt(); @@ -739,13 +719,16 @@ void ConfigMgr::Load(QString filename) { variable->measuring_max = scaling["measuring_max"].toInt(); variable->scale_min = scaling["scale_min"].toInt(); variable->scale_max = scaling["scale_max"].toInt(); - QJsonArray freband_output_array = tmp_variable["freband_output"].toArray(); - for (int k = 0; k < freband_output_array.size(); ++k) { - QJsonObject freband_output = freband_output_array[k].toObject(); + QJsonObject freband_output_obj = tmp_variable["freband_output"].toObject(); + QJsonObject number_obj; + for (int k = 0; k < 10; ++k) { + number_obj = freband_output_obj[QString::number(k + 1)].toObject(); + if(number_obj.isEmpty()) + continue; FrequencybandOutput output; - output.enable = freband_output["enable"].toBool(); - output.start = freband_output["start"].toInt(); - output.end = freband_output["end"].toInt(); + output.enable = number_obj["enable"].toBool(); + output.start = number_obj["start"].toInt(); + output.end = number_obj["end"].toInt(); variable->freband_output[k] = output; } vib_data->variables_.push_back(variable); @@ -767,8 +750,8 @@ void ConfigMgr::Load(QString filename) { general = processed_output["general"].toObject(); alarm = processed_output["alarm"].toObject(); variable->general.output_used = general["output_used"].toBool(); - variable->general.engineering_unit = general["engieneering_unit"].toString(); - variable->general.rectifier_function = general["rectifier_function"].toString(); + variable->general.engineering_unit = general["engieneering_unit"].toInt(); + variable->general.rectifier_function = general["rectifier_function"].toInt(); variable->danger_high.level = alarm["danger_high_level"].toDouble(); variable->danger_high.hysteresis = alarm["danger_high_hysteresis"].toDouble(); variable->danger_high.delay = alarm["danger_high_delay"].toInt(); @@ -808,8 +791,8 @@ void ConfigMgr::Load(QString filename) { general = processed_output["general"].toObject(); alarm = processed_output["alarm"].toObject(); variable->general.output_used = general["output_used"].toBool(); - variable->general.engineering_unit = general["engieneering_unit"].toString(); - variable->general.rectifier_function = general["rectifier_function"].toString(); + variable->general.engineering_unit = general["engieneering_unit"].toInt(); + variable->general.rectifier_function = general["rectifier_function"].toInt(); variable->danger_high.level = alarm["danger_high_level"].toDouble(); variable->danger_high.hysteresis = alarm["danger_high_hysteresis"].toDouble(); variable->danger_high.delay = alarm["danger_high_delay"].toInt(); @@ -830,14 +813,16 @@ void ConfigMgr::Load(QString filename) { variable->alert_low.delay = alarm["alert_low_delay"].toInt(); variable->alert_low.enable = alarm["alert_low_enable"].toBool(); variable->alert_low.latch = alarm["alert_low_latch"].toBool(); - - QJsonArray freband_output_array = tmp_variable["freband_output"].toArray(); - for (int k = 0; k < freband_output_array.size(); ++k) { - QJsonObject freband_output = freband_output_array[k].toObject(); + QJsonObject freband_output_obj = tmp_variable["freband_output"].toObject(); + QJsonObject number_obj; + for (int k = 0; k < 10; ++k) { + number_obj = freband_output_obj[QString::number(k + 1)].toObject(); + if(number_obj.isEmpty()) + continue; FrequencybandOutput output; - output.enable = freband_output["enable"].toBool(); - output.start = freband_output["start"].toInt(); - output.end = freband_output["end"].toInt(); + output.enable = number_obj["enable"].toBool(); + output.start = number_obj["start"].toInt(); + output.end = number_obj["end"].toInt(); variable->freband_output[k] = output; } vib_data->variables_.push_back(variable); diff --git a/data_config.h b/data_config.h index 69132e7..03390b8 100644 --- a/data_config.h +++ b/data_config.h @@ -153,8 +153,8 @@ typedef struct { typedef struct{ bool output_used; - QString engineering_unit; - QString rectifier_function; + int engineering_unit; + int rectifier_function; }General; typedef struct{ @@ -165,10 +165,16 @@ typedef struct{ bool latch; }AlarmDangerHigh,AlarmAlertHigh,AlarmDangerLow,AlarmAlertLow ; -typedef struct{ +typedef struct FrequencybandOutput_{ bool enable; int start; int end; + FrequencybandOutput_() + { + enable = false; + start = 0; + end = 0; + } }FrequencybandOutput ; //typedef struct { // Filter filter[3]; // 0: kFilterTypeLowPass, 1: kFilterTypeHighPass, 2: kFilterTypeBandPass diff --git a/radial_vibration.cpp b/radial_vibration.cpp index 927c452..8181658 100644 --- a/radial_vibration.cpp +++ b/radial_vibration.cpp @@ -76,8 +76,8 @@ void Radial::Init() { ui->comboBox_output_used->setCurrentIndex(0); else ui->comboBox_output_used->setCurrentIndex(1); - ui->comboBox_engineering_unit->setCurrentText(variable_ptr->general.engineering_unit); - ui->comboBox_rectifier_funtion->setCurrentText(variable_ptr->general.rectifier_function); + ui->comboBox_engineering_unit->setCurrentIndex(variable_ptr->general.engineering_unit); + ui->comboBox_rectifier_funtion->setCurrentIndex(variable_ptr->general.rectifier_function); // -alarm ui->lineEdit_danger_high_level->setText(QString::number(variable_ptr->danger_high.level)); ui->lineEdit_danger_high_hysteresis->setText(QString::number(variable_ptr->danger_high.hysteresis)); @@ -109,8 +109,8 @@ void Radial::Init() { ui->comboBox_output_used_2->setCurrentIndex(0); else ui->comboBox_output_used_2->setCurrentIndex(1); - ui->comboBox_engineering_unit_2->setCurrentText(variable_ptr->general.engineering_unit); - ui->comboBox_rectifier_funtion_2->setCurrentText(variable_ptr->general.rectifier_function); + ui->comboBox_engineering_unit_2->setCurrentIndex(variable_ptr->general.engineering_unit); + ui->comboBox_rectifier_funtion_2->setCurrentIndex(variable_ptr->general.rectifier_function); // -alarm ui->lineEdit_danger_high_level_2->setText(QString::number(variable_ptr->gap_danger_high.level)); ui->lineEdit_danger_high_hysteresis_2->setText(QString::number(variable_ptr->gap_danger_high.hysteresis)); @@ -170,8 +170,8 @@ void Radial::on_pushButton_confirm_clicked() { variable->general.output_used = true; else variable->general.output_used = false; - variable->general.engineering_unit = ui->comboBox_engineering_unit->currentText(); - variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentText(); + variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); + variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); // -alarm variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble(); variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble(); @@ -199,8 +199,8 @@ void Radial::on_pushButton_confirm_clicked() { variable->gap_general.output_used = true; else variable->gap_general.output_used = false; - variable->gap_general.engineering_unit = ui->comboBox_engineering_unit_2->currentText(); - variable->gap_general.rectifier_function = ui->comboBox_rectifier_funtion_2->currentText(); + variable->gap_general.engineering_unit = ui->comboBox_engineering_unit_2->currentIndex(); + variable->gap_general.rectifier_function = ui->comboBox_rectifier_funtion_2->currentIndex(); // -alarm variable->gap_danger_high.level = ui->lineEdit_danger_high_level_2->text().toDouble(); variable->gap_danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis_2->text().toDouble(); @@ -243,6 +243,8 @@ void Radial::on_pushButton_confirm_clicked() { variable->general.output_used = true; else variable->general.output_used = false; + variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); + variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); // -alarm variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble(); variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble(); @@ -270,6 +272,8 @@ void Radial::on_pushButton_confirm_clicked() { variable->gap_general.output_used = true; else variable->gap_general.output_used = false; + variable->gap_general.engineering_unit = ui->comboBox_engineering_unit_2->currentIndex(); + variable->gap_general.rectifier_function = ui->comboBox_rectifier_funtion_2->currentIndex(); // -alarm variable->gap_danger_high.level = ui->lineEdit_danger_high_level_2->text().toDouble(); variable->gap_danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis_2->text().toDouble(); diff --git a/seismic_monitor.cpp b/seismic_monitor.cpp index bcfc301..8651773 100644 --- a/seismic_monitor.cpp +++ b/seismic_monitor.cpp @@ -173,20 +173,19 @@ void Seismic_monitor::on_pushButton_confirm_clicked() { // UpdateData(vib_data); return; } - - if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot->currentText().toInt()] != kCardKeyphaseSingle && ui->checkBox_keyphase->isChecked()) { + if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot->currentIndex()] != kCardKeyphaseSingle && ui->checkBox_keyphase->isChecked()) { QMessageBox::information(this, QStringLiteral("提示"), "第一通道键相槽位选择错误!"); return; } - if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot_2->currentText().toInt()] != kCardKeyphaseSingle && ui->checkBox_keyphase_2->isChecked()) { + if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot_2->currentIndex()] != kCardKeyphaseSingle && ui->checkBox_keyphase_2->isChecked()) { QMessageBox::information(this, QStringLiteral("提示"), "第二通道键相槽位选择错误!"); return; } - if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot_3->currentText().toInt()] != kCardKeyphaseSingle && ui->checkBox_keyphase_3->isChecked()) { + if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot_3->currentIndex()] != kCardKeyphaseSingle && ui->checkBox_keyphase_3->isChecked()) { QMessageBox::information(this, QStringLiteral("提示"), "第三通道键相槽位选择错误!"); return; } - if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot_4->currentText().toInt()] != kCardKeyphaseSingle && ui->checkBox_keyphase_4->isChecked()) { + if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot_4->currentIndex()] != kCardKeyphaseSingle && ui->checkBox_keyphase_4->isChecked()) { QMessageBox::information(this, QStringLiteral("提示"), "第四通道键相槽位选择错误!"); return; } diff --git a/trust.cpp b/trust.cpp index 0d5a54b..8f31fe2 100644 --- a/trust.cpp +++ b/trust.cpp @@ -69,8 +69,8 @@ void Trust::Init() { ui->comboBox_output_used->setCurrentIndex(0); else ui->comboBox_output_used->setCurrentIndex(1); - ui->comboBox_engineering_unit->setCurrentText(variable_ptr->gap_general.engineering_unit); - ui->comboBox_rectifier_funtion->setCurrentText(variable_ptr->gap_general.rectifier_function); + ui->comboBox_engineering_unit->setCurrentIndex(variable_ptr->gap_general.engineering_unit); + ui->comboBox_rectifier_funtion->setCurrentIndex(variable_ptr->gap_general.rectifier_function); // -alarm ui->lineEdit_danger_high_level->setText(QString::number(variable_ptr->gap_danger_high.level)); ui->lineEdit_danger_high_hysteresis->setText(QString::number(variable_ptr->gap_danger_high.hysteresis)); @@ -135,8 +135,8 @@ void Trust::on_pushButton_confirm_clicked() variable->gap_general.output_used = true; else variable->gap_general.output_used = false; - variable->gap_general.engineering_unit = ui->comboBox_engineering_unit->currentText(); - variable->gap_general.rectifier_function = ui->comboBox_rectifier_funtion->currentText(); + variable->gap_general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); + variable->gap_general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); // -alarm variable->gap_danger_high.level = ui->lineEdit_danger_high_level->text().toDouble(); variable->gap_danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble(); @@ -182,8 +182,8 @@ void Trust::on_pushButton_confirm_clicked() variable->gap_general.output_used = true; else variable->gap_general.output_used = false; - variable->gap_general.engineering_unit = ui->comboBox_engineering_unit->currentText(); - variable->gap_general.rectifier_function = ui->comboBox_rectifier_funtion->currentText(); + variable->gap_general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); + variable->gap_general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); // -alarm variable->gap_danger_high.level = ui->lineEdit_danger_high_level->text().toDouble(); variable->gap_danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble(); diff --git a/velocity.cpp b/velocity.cpp index 6a7b904..7ac8283 100644 --- a/velocity.cpp +++ b/velocity.cpp @@ -69,8 +69,8 @@ void Velocity::Init() { ui->comboBox_output_used->setCurrentIndex(0); else ui->comboBox_output_used->setCurrentIndex(1); - ui->comboBox_engineering_unit->setCurrentText(variable_ptr->general.engineering_unit); - ui->comboBox_rectifier_funtion->setCurrentText(variable_ptr->general.rectifier_function); + ui->comboBox_engineering_unit->setCurrentIndex(variable_ptr->general.engineering_unit); + ui->comboBox_rectifier_funtion->setCurrentIndex(variable_ptr->general.rectifier_function); // -alarm ui->lineEdit_danger_high_level->setText(QString::number(variable_ptr->danger_high.level)); ui->lineEdit_danger_high_hysteresis->setText(QString::number(variable_ptr->danger_high.hysteresis)); @@ -132,8 +132,8 @@ void Velocity::on_pushButton_confirm_clicked() { variable->general.output_used = true; else variable->general.output_used = false; - variable->general.engineering_unit = ui->comboBox_engineering_unit->currentText(); - variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentText(); + variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); + variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); // -alarm variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble(); variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble(); @@ -175,8 +175,8 @@ void Velocity::on_pushButton_confirm_clicked() { variable->general.output_used = true; else variable->general.output_used = false; - variable->general.engineering_unit = ui->comboBox_engineering_unit->currentText(); - variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentText(); + variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); + variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); // -alarm variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble(); variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble();