From 6c6acfea62f2db723ae500b5b95a2d84fa8cdd18 Mon Sep 17 00:00:00 2001 From: pandx Date: Fri, 28 Mar 2025 15:32:39 +0800 Subject: [PATCH] refine codes. --- acceleration.cpp | 40 +++++++++++++++--------------- acceleration.h | 8 +++--- acceleration.ui | 54 ++++++++++++++++++++++++++--------------- acceleration_ds.h | 12 +++++++++ data_config.h | 5 ++-- displacement_ds.h | 15 ++++++++++++ radial_vibration.cpp | 56 +++++++++++++++++++++--------------------- radial_vibration.h | 8 +++--- radial_vibration.ui | 42 ++++++++++++++++++++++++++------ seismic_monitor.ui | 58 +++++++++++++++++++++++++++++++++++++++++--- velocity.cpp | 49 ++++++++++++++++++++++--------------- velocity.h | 8 +++--- velocity.ui | 54 ++++++++++++++++++++++++++--------------- velocity_ds.h | 12 +++++++++ 14 files changed, 290 insertions(+), 131 deletions(-) diff --git a/acceleration.cpp b/acceleration.cpp index 0e59b8f..2e23542 100644 --- a/acceleration.cpp +++ b/acceleration.cpp @@ -26,17 +26,17 @@ Acceleration::Acceleration(int slot_no_, int channel_, bool active, QWidget *par QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\acceleration_variables_%2.json").arg(slot_no).arg(channel); readJsonFile(filePath_variables); Init(); - connect(ui->checkBox_1x_ampl, &QCheckBox::toggled, this, &Acceleration::on_1x_ampl_toggled); - connect(ui->checkBox_2x_ampl, &QCheckBox::toggled, this, &Acceleration::on_2x_ampl_toggled); - connect(ui->checkBox_rms, &QCheckBox::toggled, this, &Acceleration::on_rms_toggled); - connect(ui->checkBox_integrate, &QCheckBox::toggled, this, &Acceleration::on_integrate_toggled); +// connect(ui->checkBox_1x_ampl, &QCheckBox::toggled, this, &Acceleration::on_1x_ampl_toggled); +// connect(ui->checkBox_2x_ampl, &QCheckBox::toggled, this, &Acceleration::on_2x_ampl_toggled); +// connect(ui->checkBox_rms, &QCheckBox::toggled, this, &Acceleration::on_rms_toggled); +// connect(ui->checkBox_integrate, &QCheckBox::toggled, this, &Acceleration::on_integrate_toggled); } Acceleration::~Acceleration() { delete ui; } -void Acceleration::on_rms_toggled(bool checked) { +void Acceleration::on_checkBox_rms_toggled(bool checked) { // TODO: 自定义的回调 if (checked) { if (ui->checkBox_integrate->isChecked()) { @@ -89,7 +89,7 @@ void Acceleration::on_rms_toggled(bool checked) { } } -void Acceleration::on_integrate_toggled(bool checked) { +void Acceleration::on_checkBox_integrate_toggled(bool checked) { // TODO: 自定义的回调 if (checked) { if (ui->checkBox_rms->isChecked()) { @@ -142,7 +142,7 @@ void Acceleration::on_integrate_toggled(bool checked) { } } -void Acceleration::on_1x_ampl_toggled(bool checked) { +void Acceleration::on_checkBox_1x_ampl_toggled(bool checked) { if (checked) { ui->comboBox_1x_value_range->setEnabled(true); ui->doubleSpinBox_1x_ampl_clamp->setEnabled(true); @@ -154,7 +154,7 @@ void Acceleration::on_1x_ampl_toggled(bool checked) { ui->doubleSpinBox_1x_phase_lag_clamp->setEnabled(false); } -void Acceleration::on_2x_ampl_toggled(bool checked) { +void Acceleration::on_checkBox_2x_ampl_toggled(bool checked) { if (checked) { ui->comboBox_2x_value_range->setEnabled(true); ui->doubleSpinBox_2x_ampl_clamp->setEnabled(true); @@ -201,19 +201,19 @@ void Acceleration::readJsonFile(const QString &filePath) { QJsonObject temp_obj = variables_array[i].toObject(); variables[i].type = temp_obj["type"].toString(); if (variables[i].type == "direct") { - variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString(); + variables[i].full_sacle_range = temp_obj["full_sacle_range"].toInt(); variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); } else if (variables[i].type == "bias_volt") { variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); variables[i].bias_voltage = temp_obj["bias_voltage"].toInt(); } else if (variables[i].type == "1x_ampl") { variables[i].checked = temp_obj["checked"].toBool(); - variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString(); + variables[i].full_sacle_range = temp_obj["full_sacle_range"].toInt(); variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); variables[i].phase_lag = temp_obj["phase_lag"].toDouble(); } else if (variables[i].type == "2x_ampl") { variables[i].checked = temp_obj["checked"].toBool(); - variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString(); + variables[i].full_sacle_range = temp_obj["full_sacle_range"].toInt(); variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); variables[i].phase_lag = temp_obj["phase_lag"].toDouble(); } @@ -227,7 +227,7 @@ void Acceleration::readJsonFile(const QString &filePath) { alert_variables.alert_latching = json_obj["alert_latching"].toBool(); alert_variables.danger_latching = json_obj["danger_latching"].toBool(); alert_variables.timed_ok = json_obj["timed_ok"].toBool(); - alert_variables.recorder_output = json_obj["recorder_output"].toString(); + alert_variables.recorder_output = json_obj["recorder_output"].toInt(); alert_variables.two_ma_clamp = json_obj["two_ma_clamp"].toBool(); alert_variables.trip_multiply = json_obj["trip_multiply"].toDouble(); alert_variables.comparision = json_obj["comparision"].toString(); @@ -254,17 +254,17 @@ void Acceleration::Init() { } for (int i = 0; i < 4; i++) { if (variables[i].type == "direct") { - ui->comboBox_direct_value_range->setCurrentText(variables[i].full_sacle_range); + ui->comboBox_direct_value_range->setCurrentIndex(variables[i].full_sacle_range); ui->doubleSpinBox_direct_clamp->setValue(variables[i].clamp_value); } else if (variables[i].type == "bias_volt") { ui->label_bias_voltage->setText(QString::number(variables[i].bias_voltage)); ui->doubleSpinBox_bias_volt_clamp->setValue(variables[i].clamp_value); } else if (variables[i].type == "1x_ampl") { - ui->comboBox_1x_value_range->setCurrentText(variables[i].full_sacle_range); + ui->comboBox_1x_value_range->setCurrentIndex(variables[i].full_sacle_range); ui->doubleSpinBox_1x_ampl_clamp->setValue(variables[i].clamp_value); ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variables[i].clamp_value); } else if (variables[i].type == "2x_ampl") { - ui->comboBox_2x_value_range->setCurrentText(variables[i].full_sacle_range); + ui->comboBox_2x_value_range->setCurrentIndex(variables[i].full_sacle_range); ui->doubleSpinBox_2x_ampl_clamp->setValue(variables[i].clamp_value); ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variables[i].clamp_value); } @@ -277,7 +277,7 @@ void Acceleration::Init() { ui->checkBox_alert_latching->setChecked(alert_variables.alert_latching); ui->checkBox_danger_latching->setChecked(alert_variables.danger_latching); ui->checkBox_timed_ok->setChecked(alert_variables.timed_ok); - ui->comboBox_recorder_output->setCurrentText(alert_variables.recorder_output); + ui->comboBox_recorder_output->setCurrentIndex(alert_variables.recorder_output); ui->checkBox_two_ma_clamp->setChecked(alert_variables.two_ma_clamp); ui->doubleSpinBox_trip_multiply->setValue(alert_variables.trip_multiply); ui->comboBox_comparision->setCurrentText(alert_variables.comparision); @@ -302,18 +302,18 @@ void Acceleration::on_pushButton_confirm_clicked() { } for (int i = 0; i < 4; i++) { if (variables[i].type == "direct") { - variables[i].full_sacle_range = ui->comboBox_direct_value_range->currentText(); + variables[i].full_sacle_range = ui->comboBox_direct_value_range->currentIndex(); variables[i].clamp_value = ui->doubleSpinBox_direct_clamp->value(); } else if (variables[i].type == "bias_volt") { variables[i].clamp_value = ui->doubleSpinBox_bias_volt_clamp->value(); } else if (variables[i].type == "1x_ampl") { variables[i].checked = ui->checkBox_1x_ampl->isChecked(); - variables[i].full_sacle_range = ui->comboBox_1x_value_range->currentText(); + variables[i].full_sacle_range = ui->comboBox_1x_value_range->currentIndex(); variables[i].clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value(); variables[i].clamp_value = ui->doubleSpinBox_1x_phase_lag_clamp->value(); } else if (variables[i].type == "2x_ampl") { variables[i].checked = ui->checkBox_2x_ampl->isChecked(); - variables[i].full_sacle_range = ui->comboBox_2x_value_range->currentText(); + variables[i].full_sacle_range = ui->comboBox_2x_value_range->currentIndex(); variables[i].clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value(); variables[i].clamp_value = ui->doubleSpinBox_2x_phase_lag_clamp->value(); } @@ -326,7 +326,7 @@ void Acceleration::on_pushButton_confirm_clicked() { alert_variables.alert_latching = ui->checkBox_alert_latching->isChecked(); alert_variables.danger_latching = ui->checkBox_danger_latching->isChecked(); alert_variables.timed_ok = ui->checkBox_timed_ok->isChecked(); - alert_variables.recorder_output = ui->comboBox_recorder_output->currentText(); + alert_variables.recorder_output = ui->comboBox_recorder_output->currentIndex(); alert_variables.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked(); alert_variables.trip_multiply = ui->doubleSpinBox_trip_multiply->value(); alert_variables.comparision = ui->comboBox_comparision->currentText(); diff --git a/acceleration.h b/acceleration.h index 3b0feea..8ebb59a 100644 --- a/acceleration.h +++ b/acceleration.h @@ -23,10 +23,10 @@ class Acceleration : public QWidget { void on_pushButton_set_default_clicked(); void on_pushButton_cancel_clicked(); - void on_1x_ampl_toggled(bool checked); - void on_2x_ampl_toggled(bool checked); - void on_rms_toggled(bool checked); - void on_integrate_toggled(bool checked); + void on_checkBox_1x_ampl_toggled(bool checked); + void on_checkBox_2x_ampl_toggled(bool checked); + void on_checkBox_rms_toggled(bool checked); + void on_checkBox_integrate_toggled(bool checked); private: Ui::Acceleration *ui; diff --git a/acceleration.ui b/acceleration.ui index 8d1afc4..18ecbbf 100644 --- a/acceleration.ui +++ b/acceleration.ui @@ -107,7 +107,7 @@ - 0 + 1 @@ -982,17 +982,12 @@ - None + - 直接值 - - - - - 偏置电压 + 直接幅值 @@ -1002,7 +997,12 @@ - 1倍频相位 + 带回滞1倍频相位 + + + + + 不带回滞1倍频相位 @@ -1012,7 +1012,12 @@ - 2倍频相位 + 带回滞2倍频相位 + + + + + 不带回滞2倍频相位 @@ -1056,6 +1061,9 @@ + + false + 460 @@ -1066,6 +1074,9 @@ + + false + 460 @@ -1076,17 +1087,12 @@ - None + - 直接值 - - - - - 偏置电压 + 直接幅值 @@ -1096,7 +1102,12 @@ - 1倍频相位 + 带回滞1倍频相位 + + + + + 不带回滞1倍频相位 @@ -1106,7 +1117,12 @@ - 2倍频相位 + 带回滞2倍频相位 + + + + + 不带回滞2倍频相位 diff --git a/acceleration_ds.h b/acceleration_ds.h index ab4b0bd..df31f6a 100644 --- a/acceleration_ds.h +++ b/acceleration_ds.h @@ -35,4 +35,16 @@ typedef enum { kAccVelRMSCustom = 2 // custom } AccVelRMSFullScaleRange; +// recorder out +typedef enum { + kAccRecorderOutNone = 0, + kAccRecorderOutDirectAmpl = 1, + kAccRecorderOut1XAmpl = 2, + kAccRecorderOut1XPhaseLagWithHysteresis = 3, + kAccRecorderOut1XPhaseLagWithoutHysteresis = 4, + kAccRecorderOut2XAmpl = 5, + kAccRecorderOut2XPhaseLagWithHysteresis = 6, + kAccRecorderOut2XPhaseLagWithoutHysteresis = 7, +} AccRecorderOut; + #endif // ACCELERATION_DS_H diff --git a/data_config.h b/data_config.h index 032c708..2d38af8 100644 --- a/data_config.h +++ b/data_config.h @@ -55,11 +55,12 @@ typedef struct { typedef struct { QString type; - QString full_sacle_range; + int full_sacle_range; int bias_voltage; float clamp_value; int phase_lag; bool checked; + float custom; } Variables; typedef struct { @@ -73,7 +74,7 @@ typedef struct { bool alert_latching; bool danger_latching; bool timed_ok; - QString recorder_output; + int recorder_output; bool two_ma_clamp; float trip_multiply; QString comparision; diff --git a/displacement_ds.h b/displacement_ds.h index 9b13ff1..ff955ec 100644 --- a/displacement_ds.h +++ b/displacement_ds.h @@ -10,4 +10,19 @@ typedef enum { kDisPPCustom = 5 // custom } DisPPFullScaleRange; +// recorder out +typedef enum { + kDisRecorderOutNone = 0, + kDisRecorderOutDirectAmpl = 1, + kDisRecorderOutGap = 2, + kDisRecorderOut1XAmpl = 3, + kDisRecorderOut1XPhaseLagWithHysteresis = 4, + kDisRecorderOut1XPhaseLagWithoutHysteresis = 5, + kDisRecorderOut2XAmpl = 6, + kDisRecorderOut2XPhaseLagWithHysteresis = 7, + kDisRecorderOut2XPhaseLagWithoutHysteresis = 8, + kDisRecorderOutNot1XAmpl = 9, + kDisRecorderOutSmaxAmpl = 10 +} DisRecorderOut; + #endif // DISPLACEMENT_DS_H diff --git a/radial_vibration.cpp b/radial_vibration.cpp index c1e1b12..8a4d5f9 100644 --- a/radial_vibration.cpp +++ b/radial_vibration.cpp @@ -26,10 +26,10 @@ Radial_vibration::Radial_vibration(int slot_no_, int channel_, bool active, QWid QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\radial_vibration_variables_%2.json").arg(slot_no).arg(channel); readJsonFile(filePath_variables); Init(); - connect(ui->checkBox_1x_ampl, &QCheckBox::toggled, this, &Radial_vibration::on_1x_ampl_toggled); - connect(ui->checkBox_2x_ampl, &QCheckBox::toggled, this, &Radial_vibration::on_2x_ampl_toggled); - connect(ui->checkBox_not_1x_ampl, &QCheckBox::toggled, this, &Radial_vibration::on_not1x_ampl_toggled); - connect(ui->checkBox_smax_ampl, &QCheckBox::toggled, this, &Radial_vibration::on_smax_ampl_toggled); +// connect(ui->checkBox_1x_ampl, &QCheckBox::toggled, this, &Radial_vibration::on_1x_ampl_toggled); +// connect(ui->checkBox_2x_ampl, &QCheckBox::toggled, this, &Radial_vibration::on_2x_ampl_toggled); +// connect(ui->checkBox_not_1x_ampl, &QCheckBox::toggled, this, &Radial_vibration::on_not1x_ampl_toggled); +// connect(ui->checkBox_smax_ampl, &QCheckBox::toggled, this, &Radial_vibration::on_smax_ampl_toggled); } Radial_vibration::~Radial_vibration() { @@ -40,7 +40,7 @@ void Radial_vibration::on_pushButton_cancel_clicked() { this->close(); } -void Radial_vibration::on_1x_ampl_toggled(bool checked) { +void Radial_vibration::on_checkBox_1x_ampl_toggled(bool checked) { if (checked) { ui->comboBox_1x_value_range->setEnabled(true); ui->doubleSpinBox_1x_ampl_clamp->setEnabled(true); @@ -52,7 +52,7 @@ void Radial_vibration::on_1x_ampl_toggled(bool checked) { ui->doubleSpinBox_1x_phase_lag_clamp->setEnabled(false); } -void Radial_vibration::on_2x_ampl_toggled(bool checked) { +void Radial_vibration::on_checkBox_2x_ampl_toggled(bool checked) { if (checked) { ui->comboBox_2x_value_range->setEnabled(true); ui->doubleSpinBox_2x_ampl_clamp->setEnabled(true); @@ -64,7 +64,7 @@ void Radial_vibration::on_2x_ampl_toggled(bool checked) { ui->doubleSpinBox_2x_phase_lag_clamp->setEnabled(false); } -void Radial_vibration::on_not1x_ampl_toggled(bool checked) { +void Radial_vibration::on_checkBox_not_1x_ampl_toggled(bool checked) { if (checked) { ui->comboBox_not_1x_ampl->setEnabled(true); ui->doubleSpinBox_not_1x_ampl_clamp->setEnabled(true); @@ -74,7 +74,7 @@ void Radial_vibration::on_not1x_ampl_toggled(bool checked) { ui->doubleSpinBox_not_1x_ampl_clamp->setEnabled(false); } -void Radial_vibration::on_smax_ampl_toggled(bool checked) { +void Radial_vibration::on_checkBox_smax_ampl_toggled(bool checked) { if (checked) { ui->comboBox_smax_range->setEnabled(true); ui->doubleSpinBox_smax_clamp->setEnabled(true); @@ -119,24 +119,24 @@ void Radial_vibration::readJsonFile(const QString &filePath) { QJsonObject temp_obj = variables_array[i].toObject(); variables[i].type = temp_obj["type"].toString(); if (variables[i].type == "direct") { - variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString(); + variables[i].full_sacle_range = temp_obj["full_sacle_range"].toInt(); variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); } else if (variables[i].type == "bias_volt") { variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); - variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString(); + variables[i].full_sacle_range = temp_obj["full_sacle_range"].toInt(); } else if (variables[i].type == "1x_ampl" || variables[i].type == "2x_ampl") { variables[i].checked = temp_obj["checked"].toBool(); - variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString(); + variables[i].full_sacle_range = temp_obj["full_sacle_range"].toInt(); variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); variables[i].phase_lag = temp_obj["phase_lag"].toDouble(); } else if (variables[i].type == "not_1x_ampl") { variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); variables[i].checked = temp_obj["checked"].toBool(); - variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString(); + variables[i].full_sacle_range = temp_obj["full_sacle_range"].toInt(); } else if (variables[i].type == "smax_ampl") { variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); variables[i].checked = temp_obj["checked"].toBool(); - variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString(); + variables[i].full_sacle_range = temp_obj["full_sacle_range"].toInt(); } } QJsonObject delay_obj = json_obj["delay"].toObject(); @@ -146,7 +146,7 @@ void Radial_vibration::readJsonFile(const QString &filePath) { alert_variables.alert_latching = json_obj["alert_latching"].toBool(); alert_variables.danger_latching = json_obj["danger_latching"].toBool(); alert_variables.timed_ok = json_obj["timed_ok"].toBool(); - alert_variables.recorder_output = json_obj["recorder_output"].toString(); + alert_variables.recorder_output = json_obj["recorder_output"].toInt(); alert_variables.two_ma_clamp = json_obj["two_ma_clamp"].toBool(); alert_variables.trip_multiply = json_obj["trip_multiply"].toDouble(); alert_variables.comparision = json_obj["comparision"].toString(); @@ -172,28 +172,28 @@ void Radial_vibration::Init() { } for (int i = 0; i < 6; i++) { if (variables[i].type == "direct") { - ui->comboBox_direct_value_range->setCurrentText(variables[i].full_sacle_range); + ui->comboBox_direct_value_range->setCurrentIndex(variables[i].full_sacle_range); ui->doubleSpinBox_direct_clamp->setValue(variables[i].clamp_value); } else if (variables[i].type == "gap") { - ui->comboBox_gap_range->setCurrentText(variables[i].full_sacle_range); + ui->comboBox_gap_range->setCurrentIndex(variables[i].full_sacle_range); ui->doubleSpinBox_gap_clamp->setValue(variables[i].clamp_value); } else if (variables[i].type == "1x_ampl") { ui->checkBox_1x_ampl->setChecked(variables[i].checked); - ui->comboBox_1x_value_range->setCurrentText(variables[i].full_sacle_range); + ui->comboBox_1x_value_range->setCurrentIndex(variables[i].full_sacle_range); ui->doubleSpinBox_1x_ampl_clamp->setValue(variables[i].clamp_value); ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variables[i].phase_lag); } else if (variables[i].type == "2x_ampl") { ui->checkBox_2x_ampl->setChecked(variables[i].checked); - ui->comboBox_2x_value_range->setCurrentText(variables[i].full_sacle_range); + ui->comboBox_2x_value_range->setCurrentIndex(variables[i].full_sacle_range); ui->doubleSpinBox_2x_ampl_clamp->setValue(variables[i].clamp_value); ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variables[i].phase_lag); } else if (variables[i].type == "not_1x_ampl") { ui->checkBox_not_1x_ampl->setChecked(variables[i].checked); - ui->comboBox_not_1x_ampl->setCurrentText(variables[i].full_sacle_range); + ui->comboBox_not_1x_ampl->setCurrentIndex(variables[i].full_sacle_range); ui->doubleSpinBox_not_1x_ampl_clamp->setValue(variables[i].clamp_value); } else if (variables[i].type == "smax_ampl") { ui->checkBox_smax_ampl->setChecked(variables[i].checked); - ui->comboBox_smax_range->setCurrentText(variables[i].full_sacle_range); + ui->comboBox_smax_range->setCurrentIndex(variables[i].full_sacle_range); ui->doubleSpinBox_smax_clamp->setValue(variables[i].clamp_value); } } @@ -202,7 +202,7 @@ void Radial_vibration::Init() { ui->checkBox_100ms_delay->setChecked(delay.active_100ms); ui->checkBox_alert_latching->setChecked(alert_variables.alert_latching); ui->checkBox_danger_latching->setChecked(alert_variables.danger_latching); - ui->comboBox_recorder_output->setCurrentText(alert_variables.recorder_output); + ui->comboBox_recorder_output->setCurrentIndex(alert_variables.recorder_output); ui->checkBox_two_ma_clamp->setChecked(alert_variables.two_ma_clamp); ui->doubleSpinBox_trip_multiply->setValue(alert_variables.trip_multiply); ui->comboBox_comparision->setCurrentText(alert_variables.comparision); @@ -229,28 +229,28 @@ void Radial_vibration::on_pushButton_confirm_clicked() { } for (int i = 0; i < 6; i++) { if (variables[i].type == "direct") { - variables[i].full_sacle_range = ui->comboBox_direct_value_range->currentText(); + variables[i].full_sacle_range = ui->comboBox_direct_value_range->currentIndex(); variables[i].clamp_value = ui->doubleSpinBox_direct_clamp->value(); } else if (variables[i].type == "gap") { - variables[i].full_sacle_range = ui->comboBox_gap_range->currentText(); + variables[i].full_sacle_range = ui->comboBox_gap_range->currentIndex(); variables[i].clamp_value = ui->doubleSpinBox_gap_clamp->value(); } else if (variables[i].type == "1x_ampl") { variables[i].checked = ui->checkBox_1x_ampl->isChecked(); - variables[i].full_sacle_range = ui->comboBox_1x_value_range->currentText(); + variables[i].full_sacle_range = ui->comboBox_1x_value_range->currentIndex(); variables[i].clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value(); variables[i].phase_lag = ui->doubleSpinBox_1x_phase_lag_clamp->value(); } else if (variables[i].type == "2x_ampl") { variables[i].checked = ui->checkBox_2x_ampl->isChecked(); - variables[i].full_sacle_range = ui->comboBox_2x_value_range->currentText(); + variables[i].full_sacle_range = ui->comboBox_2x_value_range->currentIndex(); variables[i].clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value(); variables[i].phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value(); } else if (variables[i].type == "not_1x_ampl") { variables[i].checked = ui->checkBox_not_1x_ampl->isChecked(); - variables[i].full_sacle_range = ui->comboBox_not_1x_ampl->currentText(); + variables[i].full_sacle_range = ui->comboBox_not_1x_ampl->currentIndex(); variables[i].clamp_value = ui->doubleSpinBox_not_1x_ampl_clamp->value(); } else if (variables[i].type == "smax_ampl") { variables[i].checked = ui->checkBox_smax_ampl->isChecked(); - variables[i].full_sacle_range = ui->comboBox_smax_range->currentText(); + variables[i].full_sacle_range = ui->comboBox_smax_range->currentIndex(); variables[i].clamp_value = ui->doubleSpinBox_smax_clamp->value(); } } @@ -259,7 +259,7 @@ void Radial_vibration::on_pushButton_confirm_clicked() { delay.active_100ms = ui->checkBox_100ms_delay->isChecked(); alert_variables.alert_latching = ui->checkBox_alert_latching->isChecked(); alert_variables.danger_latching = ui->checkBox_danger_latching->isChecked(); - alert_variables.recorder_output = ui->comboBox_recorder_output->currentText(); + alert_variables.recorder_output = ui->comboBox_recorder_output->currentIndex(); alert_variables.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked(); alert_variables.trip_multiply = ui->doubleSpinBox_trip_multiply->value(); alert_variables.comparision = ui->comboBox_comparision->currentText(); diff --git a/radial_vibration.h b/radial_vibration.h index 4ac6980..113d48b 100644 --- a/radial_vibration.h +++ b/radial_vibration.h @@ -20,10 +20,10 @@ class Radial_vibration : public QWidget { void on_pushButton_cancel_clicked(); void on_pushButton_set_default_clicked(); - void on_1x_ampl_toggled(bool checked); - void on_2x_ampl_toggled(bool checked); - void on_not1x_ampl_toggled(bool checked); - void on_smax_ampl_toggled(bool checked); + void on_checkBox_1x_ampl_toggled(bool checked); + void on_checkBox_2x_ampl_toggled(bool checked); + void on_checkBox_not_1x_ampl_toggled(bool checked); + void on_checkBox_smax_ampl_toggled(bool checked); private: Ui::Radial_vibration *ui; diff --git a/radial_vibration.ui b/radial_vibration.ui index 20c0ff8..443de7a 100644 --- a/radial_vibration.ui +++ b/radial_vibration.ui @@ -1034,12 +1034,12 @@ - None + - 直接值 + 直接幅值 @@ -1054,7 +1054,12 @@ - 1倍频相位 + 带回滞1倍频相位 + + + + + 不带回滞1倍频相位 @@ -1064,7 +1069,12 @@ - 2倍频相位 + 带回滞2倍频相位 + + + + + 不带回滞2倍频相位 @@ -1121,6 +1131,9 @@ + + false + 460 @@ -1131,12 +1144,12 @@ - None + - 直接值 + 直接幅值 @@ -1151,7 +1164,12 @@ - 1倍频相位 + 带回滞1倍频相位 + + + + + 不带回滞1倍频相位 @@ -1161,7 +1179,12 @@ - 2倍频相位 + 带回滞2倍频相位 + + + + + 不带回滞2倍频相位 @@ -1176,6 +1199,9 @@ + + false + 460 diff --git a/seismic_monitor.ui b/seismic_monitor.ui index 6f0f3f4..9d2de00 100644 --- a/seismic_monitor.ui +++ b/seismic_monitor.ui @@ -332,7 +332,7 @@ - 0 + 1 @@ -436,8 +436,18 @@ - + xxx + + + xxx + + + + + yyy + + @@ -487,6 +497,9 @@ 16777215 + + 7.87 + @@ -787,6 +800,16 @@ 16777215 + + + xxx + + + + + yyy + + @@ -836,6 +859,9 @@ 16777215 + + 8 + @@ -1336,6 +1362,16 @@ 16777215 + + + xxx + + + + + yyy + + @@ -1385,12 +1421,15 @@ 16777215 + + 8 + - mv/ m/s + mv/ m/s^2 @@ -1685,6 +1724,16 @@ 16777215 + + + xxx + + + + + yyy + + @@ -1734,6 +1783,9 @@ 16777215 + + 8 + diff --git a/velocity.cpp b/velocity.cpp index 92be270..3940cc6 100644 --- a/velocity.cpp +++ b/velocity.cpp @@ -5,6 +5,7 @@ #include #include #include +#include "velocity_ds.h" Velocity::Velocity(int slot_no_, int channel_, bool active, QWidget *parent) : QWidget(parent) @@ -26,17 +27,17 @@ Velocity::Velocity(int slot_no_, int channel_, bool active, QWidget *parent) QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\velocity_variables_%2.json").arg(slot_no).arg(channel); readJsonFile(filePath_variables); Init(); - connect(ui->checkBox_1x_ampl, &QCheckBox::toggled, this, &Velocity::on_1x_ampl_toggled); - connect(ui->checkBox_2x_ampl, &QCheckBox::toggled, this, &Velocity::on_2x_ampl_toggled); - connect(ui->checkBox_rms, &QCheckBox::toggled, this, &Velocity::on_rms_toggled); - connect(ui->checkBox_integrate, &QCheckBox::toggled, this, &Velocity::on_integrate_toggled); +// connect(ui->checkBox_1x_ampl, &QCheckBox::toggled, this, &Velocity::on_1x_ampl_toggled); +// connect(ui->checkBox_2x_ampl, &QCheckBox::toggled, this, &Velocity::on_2x_ampl_toggled); +// connect(ui->checkBox_rms, &QCheckBox::toggled, this, &Velocity::on_rms_toggled); +// connect(ui->checkBox_integrate, &QCheckBox::toggled, this, &Velocity::on_integrate_toggled); } Velocity::~Velocity() { delete ui; } -void Velocity::on_rms_toggled(bool checked) { +void Velocity::on_checkBox_rms_toggled(bool checked) { // TODO: 自定义的回调 if (checked) { ui->checkBox_integrate->setEnabled(false); @@ -65,7 +66,7 @@ void Velocity::on_rms_toggled(bool checked) { ui->comboBox_2x_value_range->setCurrentIndex(1); } -void Velocity::on_integrate_toggled(bool checked) { +void Velocity::on_checkBox_integrate_toggled(bool checked) { // TODO: 自定义的回调 if (checked) { ui->checkBox_rms->setEnabled(false); @@ -98,7 +99,7 @@ void Velocity::on_pushButton_cancel_clicked() { this->close(); } -void Velocity::on_1x_ampl_toggled(bool checked) { +void Velocity::on_checkBox_1x_ampl_toggled(bool checked) { if (checked) { ui->comboBox_1x_value_range->setEnabled(true); ui->doubleSpinBox_1x_ampl_clamp->setEnabled(true); @@ -110,7 +111,7 @@ void Velocity::on_1x_ampl_toggled(bool checked) { ui->doubleSpinBox_1x_phase_lag_clamp->setEnabled(false); } -void Velocity::on_2x_ampl_toggled(bool checked) { +void Velocity::on_checkBox_2x_ampl_toggled(bool checked) { if (checked) { ui->comboBox_2x_value_range->setEnabled(true); ui->doubleSpinBox_2x_ampl_clamp->setEnabled(true); @@ -157,21 +158,24 @@ void Velocity::readJsonFile(const QString &filePath) { QJsonObject temp_obj = variables_array[i].toObject(); variables[i].type = temp_obj["type"].toString(); if (variables[i].type == "direct") { - variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString(); + variables[i].full_sacle_range = temp_obj["full_sacle_range"].toInt(); variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); + variables[i].custom = temp_obj["custom"].toDouble(); } else if (variables[i].type == "bias_volt") { variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); variables[i].bias_voltage = temp_obj["bias_voltage"].toInt(); } else if (variables[i].type == "1x_ampl") { variables[i].checked = temp_obj["checked"].toBool(); - variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString(); + variables[i].full_sacle_range = temp_obj["full_sacle_range"].toInt(); variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); variables[i].phase_lag = temp_obj["phase_lag"].toDouble(); + variables[i].custom = temp_obj["custom"].toDouble(); } else if (variables[i].type == "2x_ampl") { variables[i].checked = temp_obj["checked"].toBool(); - variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString(); + variables[i].full_sacle_range = temp_obj["full_sacle_range"].toInt(); variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); variables[i].phase_lag = temp_obj["phase_lag"].toDouble(); + variables[i].custom = temp_obj["custom"].toDouble(); } } QJsonObject delay_obj = json_obj["delay"].toObject(); @@ -183,13 +187,14 @@ void Velocity::readJsonFile(const QString &filePath) { alert_variables.alert_latching = json_obj["alert_latching"].toBool(); alert_variables.danger_latching = json_obj["danger_latching"].toBool(); alert_variables.timed_ok = json_obj["timed_ok"].toBool(); - alert_variables.recorder_output = json_obj["recorder_output"].toString(); + alert_variables.recorder_output = json_obj["recorder_output"].toInt(); alert_variables.two_ma_clamp = json_obj["two_ma_clamp"].toBool(); alert_variables.trip_multiply = json_obj["trip_multiply"].toDouble(); alert_variables.comparision = json_obj["comparision"].toString(); alert_variables.comparision_percentage = json_obj["comparision_percentage"].toInt(); } } + void Velocity::Init() { for (int i = 0; i < 3; i++) { if (filter[i].checked) { @@ -210,19 +215,19 @@ void Velocity::Init() { } for (int i = 0; i < 4; i++) { if (variables[i].type == "direct") { - ui->comboBox_direct_value_range->setCurrentText(variables[i].full_sacle_range); + ui->comboBox_direct_value_range->setCurrentIndex(variables[i].full_sacle_range); ui->doubleSpinBox_direct_clamp->setValue(variables[i].clamp_value); } else if (variables[i].type == "bias_volt") { ui->label_bias_voltage->setText(QString::number(variables[i].bias_voltage)); ui->doubleSpinBox_bias_volt_clamp->setValue(variables[i].clamp_value); } else if (variables[i].type == "1x_ampl") { ui->checkBox_1x_ampl->setChecked(variables[i].checked); - ui->comboBox_1x_value_range->setCurrentText(variables[i].full_sacle_range); + ui->comboBox_1x_value_range->setCurrentIndex(variables[i].full_sacle_range); ui->doubleSpinBox_1x_ampl_clamp->setValue(variables[i].clamp_value); ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variables[i].phase_lag); } else if (variables[i].type == "2x_ampl") { ui->checkBox_2x_ampl->setChecked(variables[i].checked); - ui->comboBox_2x_value_range->setCurrentText(variables[i].full_sacle_range); + ui->comboBox_2x_value_range->setCurrentIndex(variables[i].full_sacle_range); ui->doubleSpinBox_2x_ampl_clamp->setValue(variables[i].clamp_value); ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variables[i].phase_lag); } @@ -233,12 +238,13 @@ void Velocity::Init() { ui->checkBox_alert_latching->setChecked(alert_variables.alert_latching); ui->checkBox_danger_latching->setChecked(alert_variables.danger_latching); ui->checkBox_timed_ok->setChecked(alert_variables.timed_ok); - ui->comboBox_recorder_output->setCurrentText(alert_variables.recorder_output); + ui->comboBox_recorder_output->setCurrentIndex(alert_variables.recorder_output); ui->checkBox_two_ma_clamp->setChecked(alert_variables.two_ma_clamp); ui->doubleSpinBox_trip_multiply->setValue(alert_variables.trip_multiply); ui->comboBox_comparision->setCurrentText(alert_variables.comparision); ui->spinBox_comparision_percentage->setValue(alert_variables.comparision_percentage); } + void Velocity::on_pushButton_confirm_clicked() { for (int i = 0; i < 3; i++) { if (filter[i].type == "band_pass") { @@ -257,20 +263,23 @@ void Velocity::on_pushButton_confirm_clicked() { } for (int i = 0; i < 4; i++) { if (variables[i].type == "direct") { - variables[i].full_sacle_range = ui->comboBox_direct_value_range->currentText(); + variables[i].full_sacle_range = ui->comboBox_direct_value_range->currentIndex(); variables[i].clamp_value = ui->doubleSpinBox_direct_clamp->value(); + // TODO: custom } else if (variables[i].type == "bias_volt") { variables[i].clamp_value = ui->doubleSpinBox_bias_volt_clamp->value(); } else if (variables[i].type == "1x_ampl") { variables[i].checked = ui->checkBox_1x_ampl->isChecked(); - variables[i].full_sacle_range = ui->comboBox_1x_value_range->currentText(); + variables[i].full_sacle_range = ui->comboBox_1x_value_range->currentIndex(); variables[i].clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value(); variables[i].phase_lag = ui->doubleSpinBox_1x_phase_lag_clamp->value(); + // TODO: custom } else if (variables[i].type == "2x_ampl") { variables[i].checked = ui->checkBox_2x_ampl->isChecked(); - variables[i].full_sacle_range = ui->comboBox_2x_value_range->currentText(); + variables[i].full_sacle_range = ui->comboBox_2x_value_range->currentIndex(); variables[i].clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value(); variables[i].phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value(); + // TODO: custom } } delay.alert = ui->spinBox_alert->value(); @@ -279,7 +288,7 @@ void Velocity::on_pushButton_confirm_clicked() { alert_variables.alert_latching = ui->checkBox_alert_latching->isChecked(); alert_variables.danger_latching = ui->checkBox_danger_latching->isChecked(); alert_variables.timed_ok = ui->checkBox_timed_ok->isChecked(); - alert_variables.recorder_output = ui->comboBox_recorder_output->currentText(); + alert_variables.recorder_output = ui->comboBox_recorder_output->currentIndex(); alert_variables.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked(); alert_variables.trip_multiply = ui->doubleSpinBox_trip_multiply->value(); alert_variables.comparision = ui->comboBox_comparision->currentText(); diff --git a/velocity.h b/velocity.h index 1cee422..5f9e831 100644 --- a/velocity.h +++ b/velocity.h @@ -20,10 +20,10 @@ class Velocity : public QWidget { private slots: void on_pushButton_confirm_clicked(); void on_pushButton_cancel_clicked(); - void on_1x_ampl_toggled(bool checked); - void on_2x_ampl_toggled(bool checked); - void on_rms_toggled(bool checked); - void on_integrate_toggled(bool checked); + void on_checkBox_1x_ampl_toggled(bool checked); + void on_checkBox_2x_ampl_toggled(bool checked); + void on_checkBox_rms_toggled(bool checked); + void on_checkBox_integrate_toggled(bool checked); private: Ui::Velocity *ui; diff --git a/velocity.ui b/velocity.ui index bc2d851..ec08a63 100644 --- a/velocity.ui +++ b/velocity.ui @@ -23,7 +23,7 @@ - 0 + 1 @@ -846,17 +846,12 @@ - None + - 直接值 - - - - - 偏置电压 + 直接幅值 @@ -866,7 +861,12 @@ - 1倍频相位 + 带回滞1倍频相位 + + + + + 不带回滞1倍频相位 @@ -876,7 +876,12 @@ - 2倍频相位 + 带回滞2倍频相位 + + + + + 不带回滞2倍频相位 @@ -936,6 +941,9 @@ + + false + 460 @@ -946,17 +954,12 @@ - None + - 直接值 - - - - - 偏置电压 + 直接幅值 @@ -966,7 +969,12 @@ - 1倍频相位 + 带回滞1倍频相位 + + + + + 不带回滞1倍频相位 @@ -976,11 +984,19 @@ - 2倍频相位 + 带回滞2倍频相位 + + + + + 不带回滞2倍频相位 + + false + 460 diff --git a/velocity_ds.h b/velocity_ds.h index f786db6..b090a65 100644 --- a/velocity_ds.h +++ b/velocity_ds.h @@ -25,4 +25,16 @@ typedef enum { kVelDisPPCustom = 3 // custom } VelDisPPFullScaleRange; +// recorder out +typedef enum { + kVelRecorderOutNone = 0, + kVelRecorderOutDirectAmpl = 1, + kVelRecorderOut1XAmpl = 2, + kVelRecorderOut1XPhaseLagWithHysteresis = 3, + kVelRecorderOut1XPhaseLagWithoutHysteresis = 4, + kVelRecorderOut2XAmpl = 5, + kVelRecorderOut2XPhaseLagWithHysteresis = 6, + kVelRecorderOut2XPhaseLagWithoutHysteresis = 7, +} VelRecorderOut; + #endif // VELOCITY_DS_H