From 4086443af6a1c2de99c146ba65a4c2b97734c088 Mon Sep 17 00:00:00 2001 From: "SHENG-PC\\admin" Date: Fri, 5 Dec 2025 21:06:52 +0800 Subject: [PATCH] modify relay vote --- config_mgr.cpp | 1 + data_config.h | 2 ++ singlerelay.cpp | 30 +++++++++++++++++++++--------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/config_mgr.cpp b/config_mgr.cpp index 424491b..1d68894 100644 --- a/config_mgr.cpp +++ b/config_mgr.cpp @@ -587,6 +587,7 @@ void ConfigMgr::Save(QString & file_path) { } } channel_item.insert("logic_vote", array_logic); + channel_item.insert("vote",ptr->single_relay[ch].vote); }else{ if(ptr->single_relay[ch].logic_expression != ""){ qDebug() << "ch" << ch << ptr->single_relay[ch].logic_expression; diff --git a/data_config.h b/data_config.h index cc0ad12..1709f34 100644 --- a/data_config.h +++ b/data_config.h @@ -518,6 +518,7 @@ typedef struct SingleRelayS_{ logic_expression = ""; active = false; vote = false; + count_vote = 0; } } SingleRelayS; @@ -532,6 +533,7 @@ typedef struct SingleRelayNOK_{ logic_expression = ""; active = false; vote = false; + count_vote = 0; } } SingleRelayNOK; diff --git a/singlerelay.cpp b/singlerelay.cpp index 4d708bf..b6c30f1 100644 --- a/singlerelay.cpp +++ b/singlerelay.cpp @@ -55,7 +55,7 @@ SingleRelay::SingleRelay(int slot,CardType cardtype,QWidget *parent) vote_current_index = ui->comboBox_vote_group->currentIndex(); Init(); onComboBoxIndexChanged(current_index); - + on_comboBox_vote_group_currentIndexChanged(current_index); } SingleRelay::~SingleRelay() { @@ -149,8 +149,16 @@ void SingleRelay::Init(){ if(!relay_data->single_relay[current_index].logic_expression.isEmpty()){ setExpressionToTreeView(treeView_relay, relay_data->single_relay[current_index].logic_expression); } + if(!relay_data->single_relay[current_index].logic[vote_current_index].isEmpty()){ + setExpressionToTreeView(treeView_relay, relay_data->single_relay[current_index].logic[vote_current_index]); + } + qDebug() << "relay_data->single_relay[current_index].active" << relay_data->single_relay[current_index].active; ui->checkBox_active->setChecked(relay_data->single_relay[current_index].active); ui->comboBox_group->setCurrentIndex(relay_data->single_relay[current_index].group - 1); + ui->lineEdit_vote_count->setText(QString::number(relay_data->single_relay[current_index].count_vote)); + ui->checkBox_vote->setChecked(relay_data->single_relay[current_index].vote); + on_checkBox_vote_clicked(relay_data->single_relay[current_index].vote); + } void SingleRelay::on_pushButton_cancel_clicked() { this->close(); @@ -274,14 +282,16 @@ void SingleRelay::on_pushButton_confirm_clicked() QString("错误位置:%1\n错误描述:%2").arg(result.errorPos).arg(result.errorMsg)); return; } - if(ui->checkBox_vote->checkState()){ + if(ui->checkBox_vote->isChecked()){ relay_data->single_relay[current_index].logic[ui->comboBox_vote_group->currentIndex()] = finalExpr; + relay_data->single_relay[current_index].count_vote = ui->lineEdit_vote_count->text().toInt(); }else{ relay_data->single_relay[current_index].logic_expression = finalExpr; } - relay_data->single_relay[current_index].active = ui->checkBox_active->isChecked(); + relay_data->single_relay[current_index].vote = ui->checkBox_vote->isChecked(); relay_data->single_relay[current_index].group = ui->comboBox_group->currentIndex() + 1; - qDebug() << "逻辑表达式:" << finalExpr; + relay_data->single_relay[current_index].count_vote = ui->lineEdit_vote_count->text().toInt(); + qDebug() << "逻辑表达式:" << finalExpr ; this->close(); } void SingleRelay::onComboBoxIndexChanged(int index){ @@ -304,9 +314,9 @@ void SingleRelay::onComboBoxIndexChanged(int index){ return; } qDebug() << "finalExpr" << finalExpr; - if(ui->checkBox_vote->checkState()){ - relay_data->single_relay[current_index].logic[ui->comboBox_vote_group->currentIndex()] = finalExpr; - if(relay_data->single_relay[index].logic[ui->comboBox_vote_group->currentIndex()] != "") + if(ui->checkBox_vote->isChecked()){ + relay_data->single_relay[current_index].logic[vote_current_index] = finalExpr; + if(relay_data->single_relay[index].logic[0] != "") setExpressionToTreeView(treeView_relay, relay_data->single_relay[index].logic[ui->comboBox_vote_group->currentIndex()]); else model_Relay->clear(); @@ -317,11 +327,13 @@ void SingleRelay::onComboBoxIndexChanged(int index){ else model_Relay->clear(); } - relay_data->single_relay[current_index].active = ui->checkBox_active->isChecked(); + relay_data->single_relay[current_index].vote = ui->checkBox_vote->isChecked(); relay_data->single_relay[current_index].group = ui->comboBox_group->currentIndex() + 1; + relay_data->single_relay[current_index].count_vote = ui->lineEdit_vote_count->text().toInt(); current_index = index; qDebug() << "active" << relay_data->single_relay[index].active; ui->checkBox_active->setChecked(relay_data->single_relay[index].active); + ui->lineEdit_vote_count->setText(QString::number(relay_data->single_relay[index].count_vote)); } ExprNode* SingleRelay::parseExpression(const QString& expr, int& pos) { @@ -522,7 +534,7 @@ void SingleRelay::on_comboBox_vote_group_currentIndexChanged(int index) QString("错误位置:%1\n错误描述:%2").arg(result.errorPos).arg(result.errorMsg)); return; } - qDebug() << "finalExpr" << finalExpr; + qDebug() << "finalExpr" << finalExpr << index; relay_data->single_relay[current_index].logic[vote_current_index] = finalExpr; if(relay_data->single_relay[current_index].logic[index] != "") setExpressionToTreeView(treeView_relay, relay_data->single_relay[current_index].logic[index]);