From 3609ab904733be47d9d4af5bcc3ed8ec8061ede2 Mon Sep 17 00:00:00 2001 From: zhangsheng Date: Sat, 7 Mar 2026 16:13:55 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=AE=E7=9B=B8=E5=92=8C=E8=BD=AC=E9=80=9F?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=8B=E9=99=8D=E6=B2=BF=E5=92=8C=E4=B8=8A?= =?UTF-8?q?=E5=8D=87=E6=B2=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config_mgr.cpp | 4 + data_config.h | 2 + keyphase.cpp | 36 ++++ keyphase.ui | 93 ++++------ tachometer.cpp | 44 ++++- tachometer.ui | 451 +++++++++++++++++++++++++++++++------------------ 6 files changed, 403 insertions(+), 227 deletions(-) diff --git a/config_mgr.cpp b/config_mgr.cpp index f8b5736..8fd83cd 100644 --- a/config_mgr.cpp +++ b/config_mgr.cpp @@ -486,6 +486,7 @@ int ConfigMgr::Save(QString & file_path) { channel_item.insert("keyphase_points",ptr->variables_[cid].keyphase_points); channel_item.insert("speed_delay",ptr->variables_[cid].speed_delay); channel_item.insert("zero_speed",ptr->variables_[cid].zero_speed); + channel_item.insert("fail",ptr->variables_[cid].fail); QJsonObject alarm; alarm["danger_high_level"] = ptr->danger_high[cid].level; alarm["danger_high_hysteresis"] = ptr->danger_high[cid].hysteresis; @@ -517,6 +518,7 @@ int ConfigMgr::Save(QString & file_path) { channel_item.insert("point_name",ptr->variables_[cid].point_name); channel_item.insert("keyphase_points",ptr->variables_[cid].keyphase_points); channel_item.insert("speed_delay",ptr->variables_[cid].speed_delay); + channel_item.insert("fail",ptr->variables_[cid].fail); } slot_item[QString::number(cid + 1)] = channel_item; @@ -1038,6 +1040,7 @@ void ConfigMgr::Load(QString filename) { speed_data->variables_[j].keyphase_points = channel["keyphase_points"].toInt(); speed_data->variables_[j].speed_delay = channel["speed_delay"].toInt(); speed_data->variables_[j].zero_speed = channel["zero_speed"].toInt(); + speed_data->variables_[j].fail = channel["fail"].toBool(); if(channel.contains("alarm")){ QJsonObject alarm = channel["alarm"].toObject(); speed_data->danger_high[j].level = alarm["danger_high_level"].toDouble(); @@ -1075,6 +1078,7 @@ void ConfigMgr::Load(QString filename) { keyphase_data->variables_[j].point_name = channel["point_name"].toString(); keyphase_data->variables_[j].keyphase_points = channel["keyphase_points"].toInt(); keyphase_data->variables_[j].speed_delay = channel["speed_delay"].toInt(); + keyphase_data->variables_[j].fail = channel["fail"].toBool(); } cards_.push_back(keyphase_data); diff --git a/data_config.h b/data_config.h index c2d049c..8c8971c 100644 --- a/data_config.h +++ b/data_config.h @@ -463,6 +463,7 @@ typedef struct { bool alert_latching; bool overspeed_latching; bool normal_latching; + bool fail; } TachometerVariables; typedef struct { @@ -476,6 +477,7 @@ typedef struct { int events_per_revolution; int keyphase_points; int speed_delay; + bool fail; } KeyphaseVariables; typedef struct { diff --git a/keyphase.cpp b/keyphase.cpp index 78ade46..b67d03e 100644 --- a/keyphase.cpp +++ b/keyphase.cpp @@ -92,6 +92,11 @@ void KeyPhase::UpdateData(std::shared_ptr &keyphase_data) { keyphase_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_1->value(); keyphase_data->variables_[i].keyphase_points = ui->spinBox_points->value(); keyphase_data->variables_[i].speed_delay = ui->spinBox_delay->value(); + if(ui->radioButton_falling_edge->isChecked()){ + keyphase_data->variables_[i].fail = true; + }else if(ui->radioButton_rising_edge->isChecked()){ + keyphase_data->variables_[i].fail = false; + } } else if (i + 1 == 2) { keyphase_data->variables_[i].active = ui->checkBox_enable_2->isChecked(); keyphase_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_2->value(); @@ -102,6 +107,11 @@ void KeyPhase::UpdateData(std::shared_ptr &keyphase_data) { keyphase_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_2->value(); keyphase_data->variables_[i].keyphase_points = ui->spinBox_points_2->value(); keyphase_data->variables_[i].speed_delay = ui->spinBox_delay_2->value(); + if(ui->radioButton_falling_edge_2->isChecked()){ + keyphase_data->variables_[i].fail = true; + }else if(ui->radioButton_rising_edge_2->isChecked()){ + keyphase_data->variables_[i].fail = false; + } } else if (i + 1 == 3) { keyphase_data->variables_[i].active = ui->checkBox_enable_3->isChecked(); keyphase_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_3->value(); @@ -112,6 +122,11 @@ void KeyPhase::UpdateData(std::shared_ptr &keyphase_data) { keyphase_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_3->value(); keyphase_data->variables_[i].keyphase_points = ui->spinBox_points_3->value(); keyphase_data->variables_[i].speed_delay = ui->spinBox_delay_3->value(); + if(ui->radioButton_falling_edge_3->isChecked()){ + keyphase_data->variables_[i].fail = true; + }else if(ui->radioButton_rising_edge_3->isChecked()){ + keyphase_data->variables_[i].fail = false; + } } else if (i + 1 == 4) { keyphase_data->variables_[i].active = ui->checkBox_enable_4->isChecked(); keyphase_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_4->value(); @@ -122,6 +137,11 @@ void KeyPhase::UpdateData(std::shared_ptr &keyphase_data) { keyphase_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_4->value(); keyphase_data->variables_[i].keyphase_points = ui->spinBox_points_4->value(); keyphase_data->variables_[i].speed_delay = ui->spinBox_delay_4->value(); + if(ui->radioButton_falling_edge_3->isChecked()){ + keyphase_data->variables_[i].fail = true; + }else if(ui->radioButton_rising_edge_3->isChecked()){ + keyphase_data->variables_[i].fail = false; + } } } } @@ -157,6 +177,10 @@ void KeyPhase::Init() { ui->doubleSpinBox_threshold_1->setValue(keyphase_data->variables_[i].threshold); 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); + else + ui->radioButton_rising_edge->setCheckable(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); @@ -175,6 +199,10 @@ void KeyPhase::Init() { ui->doubleSpinBox_threshold_2->setValue(keyphase_data->variables_[i].threshold); 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); + else + ui->radioButton_rising_edge_2->setCheckable(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); @@ -193,6 +221,10 @@ void KeyPhase::Init() { ui->doubleSpinBox_threshold_3->setValue(keyphase_data->variables_[i].threshold); 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); + else + ui->radioButton_rising_edge_3->setCheckable(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); @@ -211,6 +243,10 @@ void KeyPhase::Init() { ui->doubleSpinBox_threshold_4->setValue(keyphase_data->variables_[i].threshold); 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); + else + ui->radioButton_rising_edge_4->setCheckable(true); } } ui->comboBox_relative_number->setCurrentIndex(base_ptr->relative_number); diff --git a/keyphase.ui b/keyphase.ui index 853592f..2db2131 100644 --- a/keyphase.ui +++ b/keyphase.ui @@ -245,7 +245,7 @@ 通道 1 - + @@ -619,18 +619,21 @@ - + - + - ===> + 下降沿 + + + true - + - 通道 2 + 上升沿 @@ -655,7 +658,7 @@ 通道 2 - + @@ -1029,18 +1032,21 @@ - + - + - 通道 1 + 下降沿 + + + true - + - <=== + 上升沿 @@ -1071,39 +1077,6 @@ 0 - - - - 0 - 220 - 95 - 87 - - - - - - - ===> - - - - - - - === - - - - - - - <=== - - - - - @@ -1115,7 +1088,7 @@ 通道 3 - + @@ -1489,18 +1462,21 @@ - + - + - ===> + 下降沿 + + + true - + - 通道 4 + 上升沿 @@ -1525,7 +1501,7 @@ 通道 4 - + @@ -1899,18 +1875,21 @@ - + - + - 通道 3 + 下降沿 + + + true - + - <=== + 上升沿 diff --git a/tachometer.cpp b/tachometer.cpp index 3b0e245..659df6d 100644 --- a/tachometer.cpp +++ b/tachometer.cpp @@ -97,6 +97,12 @@ void Tachometer::UpdateData(std::shared_ptr &speed_data) { speed_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_1->value(); speed_data->variables_[i].record_output = ui->comboBox_record_output_1->currentIndex(); speed_data->variables_[i].two_ma_clamp = ui->checkBox_two_ma_clamp_1->isChecked(); + if(ui->radioButton_falling_edge->isChecked()){ + speed_data->variables_[i].fail = true; + }else if(ui->radioButton_rising_edge->isChecked()){ + speed_data->variables_[i].fail = false; + } + // -alarm speed_data->danger_high[i].level = ui->lineEdit_danger_high_level->text().toDouble(); speed_data->danger_high[i].hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble(); @@ -137,7 +143,11 @@ void Tachometer::UpdateData(std::shared_ptr &speed_data) { speed_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_2->value(); speed_data->variables_[i].record_output = ui->comboBox_record_output_2->currentIndex(); speed_data->variables_[i].two_ma_clamp = ui->checkBox_two_ma_clamp_2->isChecked(); - + if(ui->radioButton_falling_edge_2->isChecked()){ + speed_data->variables_[i].fail = true; + }else if(ui->radioButton_rising_edge_2->isChecked()){ + speed_data->variables_[i].fail = false; + } // -alarm speed_data->danger_high[i].level = ui->lineEdit_danger_high_level_2->text().toDouble(); speed_data->danger_high[i].hysteresis = ui->lineEdit_danger_high_hysteresis_2->text().toDouble(); @@ -178,7 +188,11 @@ void Tachometer::UpdateData(std::shared_ptr &speed_data) { speed_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_3->value(); speed_data->variables_[i].record_output = ui->comboBox_record_output_3->currentIndex(); speed_data->variables_[i].two_ma_clamp = ui->checkBox_two_ma_clamp_3->isChecked(); - + if(ui->radioButton_falling_edge_3->isChecked()){ + speed_data->variables_[i].fail = true; + }else if(ui->radioButton_rising_edge_3->isChecked()){ + speed_data->variables_[i].fail = false; + } // -alarm speed_data->danger_high[i].level = ui->lineEdit_danger_high_level_3->text().toDouble(); speed_data->danger_high[i].hysteresis = ui->lineEdit_danger_high_hysteresis_3->text().toDouble(); @@ -219,7 +233,11 @@ void Tachometer::UpdateData(std::shared_ptr &speed_data) { speed_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_4->value(); speed_data->variables_[i].record_output = ui->comboBox_record_output_4->currentIndex(); speed_data->variables_[i].two_ma_clamp = ui->checkBox_two_ma_clamp_4->isChecked(); - + if(ui->radioButton_falling_edge_3->isChecked()){ + speed_data->variables_[i].fail = true; + }else if(ui->radioButton_rising_edge_3->isChecked()){ + speed_data->variables_[i].fail = false; + } // -alarm speed_data->danger_high[i].level = ui->lineEdit_danger_high_level_4->text().toDouble(); speed_data->danger_high[i].hysteresis = ui->lineEdit_danger_high_hysteresis_4->text().toDouble(); @@ -281,7 +299,10 @@ 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); // -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)); @@ -329,7 +350,10 @@ void Tachometer::Init() { ui->spinBox_events_per_revolution_2->setValue(speed_data->variables_[i].events_per_revolution); 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); + else + ui->radioButton_rising_edge_2->setCheckable(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)); @@ -377,7 +401,10 @@ void Tachometer::Init() { ui->spinBox_events_per_revolution_3->setValue(speed_data->variables_[i].events_per_revolution); 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); + else + ui->radioButton_rising_edge_3->setCheckable(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)); @@ -425,7 +452,10 @@ void Tachometer::Init() { ui->spinBox_events_per_revolution_4->setValue(speed_data->variables_[i].events_per_revolution); 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); + else + ui->radioButton_rising_edge_4->setCheckable(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 aeb8965..7c658b9 100644 --- a/tachometer.ui +++ b/tachometer.ui @@ -254,7 +254,7 @@ 通道 1 - + @@ -611,7 +611,7 @@ - + @@ -860,48 +860,97 @@ - + - - - - 105 - 0 - - - - 键齿数: - - + + + + + + 105 + 0 + + + + + 16777215 + 30 + + + + 键齿数: + + + + + + + + 50 + 25 + + + + + 16777215 + 30 + + + + 1 + + + 10000 + + + + + + + + 50 + 0 + + + + + 16777215 + 30 + + + + 1 - 10000 + + + + - - - - 50 - 25 - - - - 1 - - - 10000 - - - - - - - - 50 - 0 - - - - 1 - 10000 - - + + + + + 下降沿 + + + true + + + buttonGroup_2 + + + + + + + 上升沿 + + + buttonGroup_2 + + + + @@ -1516,7 +1565,7 @@ 通道 2 - + @@ -2113,48 +2162,73 @@ - + - - - - 105 - 0 - - - - 键齿数: - - + + + + + + 105 + 0 + + + + 键齿数: + + + + + + + + 50 + 25 + + + + 1 + + + 10000 + + + + + + + + 50 + 0 + + + + 1 - 10000 + + + + - - - - 50 - 25 - - - - 1 - - - 10000 - - - - - - - - 50 - 0 - - - - 1 - 10000 - - + + + + + 下降沿 + + + true + + + + + + + 上升沿 + + + + @@ -2769,7 +2843,7 @@ 通道 3 - + @@ -3123,7 +3197,7 @@ - + @@ -3366,48 +3440,73 @@ - + - - - - 105 - 0 - - - - 键齿数: - - + + + + + + 105 + 0 + + + + 键齿数: + + + + + + + + 50 + 25 + + + + 1 + + + 10000 + + + + + + + + 50 + 0 + + + + 1 - 10000 + + + + - - - - 50 - 25 - - - - 1 - - - 10000 - - - - - - - - 50 - 0 - - - - 1 - 10000 - - + + + + + 下降沿 + + + true + + + + + + + 上升沿 + + + + @@ -4022,7 +4121,7 @@ 通道 4 - + @@ -4379,7 +4478,7 @@ - + @@ -4622,48 +4721,73 @@ - + - - - - 105 - 0 - - - - 键齿数: - - + + + + + + 105 + 0 + + + + 键齿数: + + + + + + + + 50 + 25 + + + + 1 + + + 10000 + + + + + + + + 50 + 0 + + + + 1 - 10000 + + + + - - - - 50 - 25 - - - - 1 - - - 10000 - - - - - - - - 50 - 0 - - - - 1 - 10000 - - + + + + + 下降沿 + + + true + + + + + + + 上升沿 + + + + @@ -5386,5 +5510,6 @@ +