From 16bad754f0e0c1620d26d1fd3a52bb858861cca7 Mon Sep 17 00:00:00 2001 From: zhangsheng Date: Mon, 21 Apr 2025 20:30:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config_mgr.cpp | 20 ++++++++++++++----- config_mgr.h | 3 ++- data_config.h | 2 -- mainwindow.cpp | 43 +++++++++++++++++++++++++++++++++-------- mainwindow.ui | 10 ++++++++-- seismic_monitor.cpp | 2 ++ singlerelay.cpp | 6 +++++- tmrrelayassociation.cpp | 23 ++++++++++++++++++---- 8 files changed, 86 insertions(+), 23 deletions(-) diff --git a/config_mgr.cpp b/config_mgr.cpp index 6720be5..ff03c70 100644 --- a/config_mgr.cpp +++ b/config_mgr.cpp @@ -38,6 +38,7 @@ void ConfigMgr::Save(QString & file_path) { card_type_[i] != kCardKeyphaseSingle && card_type_[i] != kCardRelaySingle && card_type_[i] != kCardRelayTMRPrimary && + card_type_[i] != kCardRelayTMRBackup && card_type_[i] != kCardRelaySingleNOK) { continue; } @@ -300,12 +301,12 @@ void ConfigMgr::Save(QString & file_path) { continue; } std::shared_ptr ptr = std::dynamic_pointer_cast(base_ptr); - if(ptr->tmr_relay[ch].logic_expression != "" && !ptr->tmr_relay[ch].sgcc_enable){ + slot_item["sgcc_enable"] = ptr->sgcc_enable; + if(ptr->tmr_relay[ch].logic_expression != ""){ channel_item.insert("logic_expression", ptr->tmr_relay[ch].logic_expression); - channel_item.insert("sgcc_enable", ptr->tmr_relay[ch].sgcc_enable); - }else if(ptr->tmr_relay[ch].logic_expression == "" && ptr->tmr_relay[ch].sgcc_enable){ - channel_item.insert("sgcc_enable", ptr->tmr_relay[ch].sgcc_enable); } + }else if(card_type_[i] == kCardRelayTMRBackup){ + continue; } if(!channel_item.isEmpty()) slot_item[QString::number(ch + 1)] = channel_item; @@ -586,12 +587,18 @@ void ConfigMgr::Load(QString filename) { relay_data->slot_ = slot; relay_data->card_type_ = static_cast(card_type_[i]); relay_data->version_ = temp_obj["version"].toInt(); + relay_data->sgcc_enable = temp_obj["sgcc_enable"].toBool(); for (int j = 0; j < RELAY_COUNT; ++j) { channel = temp_obj[QString::number(j + 1)].toObject(); relay_data->tmr_relay[j].logic_expression = channel["logic_expression"].toString(); - relay_data->tmr_relay[j].sgcc_enable = channel["sgcc_enable"].toBool(); + } cards_.push_back(relay_data); + }else if(card_type_[i] == kCardRelayTMRBackup){ + std::shared_ptr relay_data = std::make_shared(); + relay_data->slot_ = slot; + relay_data->card_type_ = static_cast(card_type_[i]); + cards_.push_back(relay_data); } } } @@ -608,3 +615,6 @@ std::shared_ptr ConfigMgr::GetSlotPtr(int slot) { void ConfigMgr::AddCard(std::shared_ptr ptr) { cards_.push_back(ptr); } +void ConfigMgr::RemoveCard(std::shared_ptr ptr) { + cards_.erase(remove(cards_.begin(), cards_.end(), ptr)); +} diff --git a/config_mgr.h b/config_mgr.h index 1e2454c..2af430f 100644 --- a/config_mgr.h +++ b/config_mgr.h @@ -49,8 +49,9 @@ class ConfigMgr { ~ConfigMgr(); void Save(QString & file_path); void Load(QString filename); - std::shared_ptr GetSlotPtr(int slot); + std::shared_ptr GetSlotPtr(int slot);//1-15 void AddCard(std::shared_ptr ptr); + void RemoveCard(std::shared_ptr ptr); private: QString filename_; diff --git a/data_config.h b/data_config.h index 7089351..6b864ad 100644 --- a/data_config.h +++ b/data_config.h @@ -276,10 +276,8 @@ typedef struct SingleRelayNOK_{ typedef struct TMRRelay_{ QString logic_expression; - bool sgcc_enable; TMRRelay_(){ logic_expression = ""; - sgcc_enable = false; } } TMRRelay; diff --git a/mainwindow.cpp b/mainwindow.cpp index 320dbb1..878e52a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -313,11 +313,11 @@ void MainWindow::onMenuActionTriggered() { } else if (slot_type == "OPM844") { chan_display = "转速"; } - if (rack_type == "三冗余板卡" && (map_slot_config[button_id].slot_type != "" || map_slot_config[button_id + 1].slot_type != "" \ + if (card_type == kCardRelayTMRPrimary && (map_slot_config[button_id].slot_type != "" || map_slot_config[button_id + 1].slot_type != "" \ || map_slot_config[button_id + 2].slot_type != "")) { QMessageBox::information(this, QStringLiteral("提示"), "不要重叠三冗余板卡配置,请在创建新配置之前移除现有的配置!"); return; - } else if (rack_type == "三冗余板卡" && map_slot_config[button_id + 1].slot_type == "" \ + } else if (card_type == kCardRelayTMRPrimary && map_slot_config[button_id + 1].slot_type == "" \ && map_slot_config[button_id + 2].slot_type == "") { map_slot_config[button_id].slot_type = slot_type; map_slot_config[button_id].rack_type = "TMR1"; @@ -331,6 +331,11 @@ void MainWindow::onMenuActionTriggered() { map_slot_config[button_id + 2].rack_type = "TMR3"; map_slot_config[button_id + 2].slot_btn->setText(chan_display); map_slot_config[button_id + 2].chan_display = chan_display; + + ConfigMgr::Instance()->card_type_[button_id - 1] = kCardRelayTMRPrimary; + ConfigMgr::Instance()->card_type_[button_id] = kCardRelayTMRBackup; + ConfigMgr::Instance()->card_type_[button_id + 1] = kCardRelayTMRBackup; + } if (rack_type == "两板卡" && (map_slot_config[button_id].slot_type != "" || map_slot_config[button_id + 1].slot_type != "")) { QMessageBox::information(this, QStringLiteral("提示"), "不要重叠两板卡配置,请在创建新配置之前移除现有的配置!"); @@ -348,16 +353,14 @@ void MainWindow::onMenuActionTriggered() { if (rack_type == "单板卡" && map_slot_config[button_id].slot_type != "") { QMessageBox::information(this, QStringLiteral("提示"), "不要重叠单板卡配置,请在创建新配置之前移除现有的配置!"); return; - } else if (rack_type == "单板卡" && map_slot_config[button_id].slot_type == "") { - map_slot_config[button_id].slot_type = slot_type; - map_slot_config[button_id].rack_type = "Single"; - map_slot_config[button_id].chan_display = chan_display; - button->setText(chan_display); - }else if (rack_type == "单板卡-非OK" && map_slot_config[button_id].slot_type == "") { + } else if ((card_type == kCardVibSingle || card_type == kCardSpeedSingle || + card_type == kCardKeyphaseSingle || card_type == kCardRelaySingle || + kCardRelaySingleNOK) && map_slot_config[button_id].slot_type == "") { map_slot_config[button_id].slot_type = slot_type; map_slot_config[button_id].rack_type = "Single"; map_slot_config[button_id].chan_display = chan_display; button->setText(chan_display); + ConfigMgr::Instance()->card_type_[button_id - 1] = card_type; } if (action->text() == "重置模块") { if (ConfigMgr::Instance()->card_type_[button_id - 1] == kCardRelayTMRPrimary) { @@ -373,6 +376,23 @@ void MainWindow::onMenuActionTriggered() { map_slot_config[button_id + 2].rack_type = "0"; map_slot_config[button_id + 2].slot_btn->setText(""); map_slot_config[button_id + 2].chan_display = ""; + std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id); + if(base_ptr != nullptr){ + ConfigMgr::Instance()->RemoveCard(base_ptr); + ConfigMgr::Instance()->card_type_[button_id - 1] = kCardNone; + } + std::shared_ptr base_ptr_backup = ConfigMgr::Instance()->GetSlotPtr(button_id + 1); + if(base_ptr_backup != nullptr){ + ConfigMgr::Instance()->RemoveCard(base_ptr_backup); + ConfigMgr::Instance()->card_type_[button_id] = kCardNone; + } + std::shared_ptr base_ptr_backup2 = ConfigMgr::Instance()->GetSlotPtr(button_id + 2); + if(base_ptr_backup2 != nullptr){ + ConfigMgr::Instance()->RemoveCard(base_ptr_backup2); + ConfigMgr::Instance()->card_type_[button_id + 1] = kCardNone; + + } + } else if (ConfigMgr::Instance()->card_type_[button_id - 1] == kCardRelayTMRBackup) { map_slot_config[button_id - 1].slot_type = ""; map_slot_config[button_id - 1].rack_type = "0"; @@ -391,11 +411,17 @@ void MainWindow::onMenuActionTriggered() { ConfigMgr::Instance()->card_type_[button_id - 1] == kCardKeyphaseSingle) { ConfigMgr::Instance()->card_type_[button_id - 1] = kCardNone; map_slot_config[button_id].slot_btn->setText(""); + std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id); + if(base_ptr != nullptr) + ConfigMgr::Instance()->RemoveCard(base_ptr); }else if (ConfigMgr::Instance()->card_type_[button_id - 1] == kCardRelaySingle || ConfigMgr::Instance()->card_type_[button_id - 1] == kCardRelaySingleNOK || ConfigMgr::Instance()->card_type_[button_id - 1] == kCardRelayTMRPrimary) { ConfigMgr::Instance()->card_type_[button_id - 1] = kCardNone; map_slot_config[button_id].slot_btn->setText(""); + std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id); + if(base_ptr != nullptr) + ConfigMgr::Instance()->RemoveCard(base_ptr); } } else if (action->text() == "升级固件") { sendUpgradePackage(button_id); @@ -664,6 +690,7 @@ void MainWindow::on_pushButton_open_clicked() { } case kCardRelaySingle: case kCardRelaySingleNOK: + case kCardRelayTMRBackup: case kCardRelayTMRPrimary:{ buttonList[i + 1]->setText("继电器"); break; diff --git a/mainwindow.ui b/mainwindow.ui index 7dbd10a..ff8aaa2 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -1145,10 +1145,11 @@ + - + @@ -1168,7 +1169,7 @@ - 校时功能 + 校时 @@ -1186,6 +1187,11 @@ 断开 + + + 网络配置 + + diff --git a/seismic_monitor.cpp b/seismic_monitor.cpp index 1ed5f19..acfefb7 100644 --- a/seismic_monitor.cpp +++ b/seismic_monitor.cpp @@ -64,6 +64,7 @@ void Seismic_monitor::Init() { if (i + 1 == 1) { qDebug() << vib_data->base_config_[i].channel_type ; ui->comboBox_chan_type_1->setCurrentIndex(vib_data->base_config_[i].channel_type); + ui->checkBox_standby_1->setChecked(vib_data->base_config_[i].standby); ui->comboBox_transducer_name_1->setCurrentIndex(vib_data->base_config_[i].transducer_id); ui->doubleSpinBox_scale_factor_1->setValue(vib_data->base_config_[i].scale_factor); ui->checkBox_enable_1->setChecked(vib_data->base_config_[i].active); @@ -81,6 +82,7 @@ void Seismic_monitor::Init() { ui->comboBox_sample_rate_2->setCurrentIndex(vib_data->base_config_[i].sampling_rate); ui->checkBox_power_2->setChecked(vib_data->base_config_[i].power); } else if (i + 1 == 3) { + ui->checkBox_standby_2->setChecked(vib_data->base_config_[i].standby); ui->comboBox_chan_type_3->setCurrentIndex(vib_data->base_config_[i].channel_type); ui->comboBox_transducer_name_3->setCurrentIndex(vib_data->base_config_[i].transducer_id); ui->doubleSpinBox_scale_factor_3->setValue(vib_data->base_config_[i].scale_factor); diff --git a/singlerelay.cpp b/singlerelay.cpp index 0251061..8902f83 100644 --- a/singlerelay.cpp +++ b/singlerelay.cpp @@ -1,6 +1,6 @@ #include "singlerelay.h" #include "ui_singlerelay.h" - +#include "vibrationdata.h" SingleRelay::SingleRelay(int slot,int cardtype,QWidget *parent) : QDialog(parent) @@ -101,6 +101,10 @@ void SingleRelay::OnButtonGroup(QAbstractButton *slot_btn) { qDebug() << object_name ; int button_id = object_name.right(object_name.length() - 15).toInt(); for(int var = 0; var < CHANNEL_COUNT ; ++var){ + std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id); + std::shared_ptr vib_data = std::dynamic_pointer_cast(base_ptr); + if((vib_data->base_config_[var].standby && vib_data->base_config_[var + 1].standby && !(var % 2))) + continue; QString item_str = QString("S%1C%2P##NO (Slot %3 Channel %4 Not OK)").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')).arg(button_id).arg(var+1); QListWidgetItem *item = new QListWidgetItem(item_str); QString item_data = QString("S%1C%2P##NO").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); diff --git a/tmrrelayassociation.cpp b/tmrrelayassociation.cpp index 767c724..6c185e3 100644 --- a/tmrrelayassociation.cpp +++ b/tmrrelayassociation.cpp @@ -102,11 +102,22 @@ void TMRRelayAssociation::Init(){ relay_data->card_type_ = car_type; relay_data->slot_ = slot_no; ConfigMgr::Instance()->AddCard(relay_data); + + std::shared_ptr relay_data_backup = std::make_shared(); + relay_data_backup->card_type_ = kCardRelayTMRBackup; + relay_data_backup->slot_ = slot_no + 1; + ConfigMgr::Instance()->AddCard(relay_data_backup); + + std::shared_ptr relay_data_backup2 = std::make_shared(); + relay_data_backup2->card_type_ = kCardRelayTMRBackup; + relay_data_backup2->slot_ = slot_no + 2; + ConfigMgr::Instance()->AddCard(relay_data_backup2); + return; } relay_data = std::dynamic_pointer_cast(base_ptr); qDebug() << "logic" <tmr_relay[current_index].logic_expression; - ui->checkBox_sgcc->setChecked(relay_data->tmr_relay[current_index].sgcc_enable); + ui->checkBox_sgcc->setChecked(relay_data->sgcc_enable); setExpressionToTreeView(treeView_relay, relay_data->tmr_relay[current_index].logic_expression); } @@ -405,7 +416,7 @@ void TMRRelayAssociation::on_pushButton_confirm_clicked() return; } relay_data->tmr_relay[current_index].logic_expression = finalExpr; - relay_data->tmr_relay[current_index].sgcc_enable = ui->checkBox_sgcc->checkState(); + relay_data->sgcc_enable = ui->checkBox_sgcc->checkState(); qDebug() << "逻辑表达式:" << finalExpr; this->close(); } @@ -430,14 +441,12 @@ void TMRRelayAssociation::onComboBoxIndexChanged(int index){ return; } relay_data->tmr_relay[current_index].logic_expression = finalExpr; - relay_data->tmr_relay[current_index].sgcc_enable = ui->checkBox_sgcc->checkState(); current_index = index; if(relay_data->tmr_relay[index].logic_expression != "") setExpressionToTreeView(treeView_relay, relay_data->tmr_relay[index].logic_expression); else model_Relay->clear(); - ui->checkBox_sgcc->setChecked(relay_data->tmr_relay[index].sgcc_enable); } void TMRRelayAssociation::on_pushButton_and_clicked() @@ -477,9 +486,15 @@ void TMRRelayAssociation::on_checkBox_sgcc_stateChanged(int arg1) if(ui->checkBox_sgcc->checkState()){ treeView_relay->setEnabled(false); list_widget_available->setEnabled(false); + ui->comboBox_relay_ch->setEnabled(false); + ui->pushButton_logic->setEnabled(false); + ui->textEdit_logic->setEnabled(false); }else{ treeView_relay->setEnabled(true); list_widget_available->setEnabled(true); + ui->comboBox_relay_ch->setEnabled(true); + ui->pushButton_logic->setEnabled(true); + ui->textEdit_logic->setEnabled(true); } }