From 129d4bbc93f7fa1981e658d4d1d99840c8be99b3 Mon Sep 17 00:00:00 2001 From: zhangsheng Date: Sat, 7 Mar 2026 17:07:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data_config.h | 5 ++++- keyphase.cpp | 16 ++++++++-------- mainwindow.cpp | 2 +- tachometer.cpp | 24 ++++++++++++++---------- tachometer.ui | 6 +++--- 5 files changed, 30 insertions(+), 23 deletions(-) diff --git a/data_config.h b/data_config.h index 8c8971c..1365f4e 100644 --- a/data_config.h +++ b/data_config.h @@ -443,7 +443,7 @@ typedef struct { int percentage; } RecorderOut; -typedef struct { +typedef struct TachometerVariables_{ int id; QString point_name; bool active; @@ -464,6 +464,9 @@ typedef struct { bool overspeed_latching; bool normal_latching; bool fail; + TachometerVariables_(){ + fail = true; + } } TachometerVariables; typedef struct { diff --git a/keyphase.cpp b/keyphase.cpp index b67d03e..ec2fb54 100644 --- a/keyphase.cpp +++ b/keyphase.cpp @@ -178,9 +178,9 @@ void KeyPhase::Init() { ui->doubleSpinBox_hysteresis_1->setValue(keyphase_data->variables_[i].hysteresis); ui->spinBox_events_per_revolution_1->setValue(keyphase_data->variables_[i].events_per_revolution); if(keyphase_data->variables_[i].fail) - ui->radioButton_falling_edge->setCheckable(true); + ui->radioButton_falling_edge->setChecked(true); else - ui->radioButton_rising_edge->setCheckable(true); + ui->radioButton_rising_edge->setChecked(true); } else if (i + 1 == 2) { ui->checkBox_enable_2->setChecked(keyphase_data->variables_[i].active); ui->doubleSpinBox_high_2->setValue(keyphase_data->variables_[i].normal_voltage_high); @@ -200,9 +200,9 @@ void KeyPhase::Init() { ui->doubleSpinBox_hysteresis_2->setValue(keyphase_data->variables_[i].hysteresis); ui->spinBox_events_per_revolution_2->setValue(keyphase_data->variables_[i].events_per_revolution); if(keyphase_data->variables_[i].fail) - ui->radioButton_falling_edge_2->setCheckable(true); + ui->radioButton_falling_edge_2->setChecked(true); else - ui->radioButton_rising_edge_2->setCheckable(true); + ui->radioButton_rising_edge_2->setChecked(true); } else if (i + 1 == 3) { ui->checkBox_enable_3->setChecked(keyphase_data->variables_[i].active); ui->doubleSpinBox_high_3->setValue(keyphase_data->variables_[i].normal_voltage_high); @@ -222,9 +222,9 @@ void KeyPhase::Init() { ui->doubleSpinBox_hysteresis_3->setValue(keyphase_data->variables_[i].hysteresis); ui->spinBox_events_per_revolution_3->setValue(keyphase_data->variables_[i].events_per_revolution); if(keyphase_data->variables_[i].fail) - ui->radioButton_falling_edge_3->setCheckable(true); + ui->radioButton_falling_edge_3->setChecked(true); else - ui->radioButton_rising_edge_3->setCheckable(true); + ui->radioButton_rising_edge_3->setChecked(true); } else if (i + 1 == 4) { ui->checkBox_enable_4->setChecked(keyphase_data->variables_[i].active); ui->doubleSpinBox_high_4->setValue(keyphase_data->variables_[i].normal_voltage_high); @@ -244,9 +244,9 @@ void KeyPhase::Init() { ui->doubleSpinBox_hysteresis_4->setValue(keyphase_data->variables_[i].hysteresis); ui->spinBox_events_per_revolution_4->setValue(keyphase_data->variables_[i].events_per_revolution); if(keyphase_data->variables_[i].fail) - ui->radioButton_falling_edge_4->setCheckable(true); + ui->radioButton_falling_edge_4->setChecked(true); else - ui->radioButton_rising_edge_4->setCheckable(true); + ui->radioButton_rising_edge_4->setChecked(true); } } ui->comboBox_relative_number->setCurrentIndex(base_ptr->relative_number); diff --git a/mainwindow.cpp b/mainwindow.cpp index 269d1c3..0651a8b 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -122,7 +122,7 @@ MainWindow::MainWindow(QWidget *parent) //qInstallMessageHandler(messageHandler); #endif QDate buildDate = QLocale( QLocale::English ).toDate( QString(__DATE__).replace(" ", " 0"), "MMM dd yyyy"); - QString Version = "V1.0_" + buildDate.toString("yyyyMMdd") + "_3609"; + QString Version = "V1.0_" + buildDate.toString("yyyyMMdd") + "_8102"; ui->label_version->setText(Version); } diff --git a/tachometer.cpp b/tachometer.cpp index 659df6d..ce0a95a 100644 --- a/tachometer.cpp +++ b/tachometer.cpp @@ -276,6 +276,7 @@ void Tachometer::Init() { } std::shared_ptr speed_data = std::dynamic_pointer_cast(base_ptr); for (int i = 0; i < CHANNEL_COUNT_SPEED; i++) { + qDebug() << "speed_data->variables_[i].fail" << i << speed_data->variables_[i].fail; if (i + 1 == 1) { ui->checkBox_chan_1->setChecked(speed_data->variables_[i].active); ui->doubleSpinBox_high_1->setValue(speed_data->variables_[i].normal_voltage_high); @@ -299,10 +300,13 @@ void Tachometer::Init() { ui->spinBox_events_per_revolution_1->setValue(speed_data->variables_[i].events_per_revolution); ui->comboBox_record_output_1->setCurrentIndex(speed_data->variables_[i].record_output); ui->checkBox_two_ma_clamp_1->setChecked(speed_data->variables_[i].two_ma_clamp); - if(speed_data->variables_[i].fail) - ui->radioButton_falling_edge->setCheckable(true); - else - ui->radioButton_rising_edge->setCheckable(true); + if(speed_data->variables_[i].fail){ + ui->radioButton_falling_edge->setChecked(true); + } + else{ + ui->radioButton_rising_edge->setChecked(true); + } + // -alarm ui->lineEdit_danger_high_level->setText(QString::number(speed_data->danger_high[i].level)); ui->lineEdit_danger_high_hysteresis->setText(QString::number(speed_data->danger_high[i].hysteresis)); @@ -351,9 +355,9 @@ void Tachometer::Init() { ui->comboBox_record_output_2->setCurrentIndex(speed_data->variables_[i].record_output); ui->checkBox_two_ma_clamp_2->setChecked(speed_data->variables_[i].two_ma_clamp); if(speed_data->variables_[i].fail) - ui->radioButton_falling_edge_2->setCheckable(true); + ui->radioButton_falling_edge_2->setChecked(true); else - ui->radioButton_rising_edge_2->setCheckable(true); + ui->radioButton_rising_edge_2->setChecked(true); // -alarm ui->lineEdit_danger_high_level_2->setText(QString::number(speed_data->danger_high[i].level)); ui->lineEdit_danger_high_hysteresis_2->setText(QString::number(speed_data->danger_high[i].hysteresis)); @@ -402,9 +406,9 @@ void Tachometer::Init() { ui->comboBox_record_output_3->setCurrentIndex(speed_data->variables_[i].record_output); ui->checkBox_two_ma_clamp_3->setChecked(speed_data->variables_[i].two_ma_clamp); if(speed_data->variables_[i].fail) - ui->radioButton_falling_edge_3->setCheckable(true); + ui->radioButton_falling_edge_3->setChecked(true); else - ui->radioButton_rising_edge_3->setCheckable(true); + ui->radioButton_rising_edge_3->setChecked(true); // -alarm ui->lineEdit_danger_high_level_3->setText(QString::number(speed_data->danger_high[i].level)); ui->lineEdit_danger_high_hysteresis_3->setText(QString::number(speed_data->danger_high[i].hysteresis)); @@ -453,9 +457,9 @@ void Tachometer::Init() { ui->comboBox_record_output_4->setCurrentIndex(speed_data->variables_[i].record_output); ui->checkBox_two_ma_clamp_4->setChecked(speed_data->variables_[i].two_ma_clamp); if(speed_data->variables_[i].fail) - ui->radioButton_falling_edge_4->setCheckable(true); + ui->radioButton_falling_edge_4->setChecked(true); else - ui->radioButton_rising_edge_4->setCheckable(true); + ui->radioButton_rising_edge_4->setChecked(true); // -alarm ui->lineEdit_danger_high_level_4->setText(QString::number(speed_data->danger_high[i].level)); ui->lineEdit_danger_high_hysteresis_4->setText(QString::number(speed_data->danger_high[i].hysteresis)); diff --git a/tachometer.ui b/tachometer.ui index 48d5a3f..7313ac6 100644 --- a/tachometer.ui +++ b/tachometer.ui @@ -874,7 +874,7 @@ 16777215 - 30 + 16777215 @@ -893,7 +893,7 @@ 16777215 - 30 + 16777215 @@ -915,7 +915,7 @@ 16777215 - 30 + 16777215