diff --git a/config_mgr.cpp b/config_mgr.cpp index 32f0025..e68e418 100644 --- a/config_mgr.cpp +++ b/config_mgr.cpp @@ -216,6 +216,7 @@ void ConfigMgr::Save(QString & file_path) { latching.append(thrust_ptr->danger_latching_); latching.append(thrust_ptr->timed_ok_); variables["zero_position"] = thrust_ptr->zero_position.value; + variables["negation"] = thrust_ptr->zero_position.negation; variables["latching"] = latching; }else if(ptr->base_config_[cid].channel_type == kVibPressurePulsation){ std::shared_ptr pressure_ptr = std::dynamic_pointer_cast(base_channel_ptr); @@ -371,7 +372,7 @@ void ConfigMgr::Save(QString & file_path) { }else{ for(int ch = 0;ch < RELAY_COUNT;++ch){ QJsonObject channel_item; - if(card_type_[i] == kCardRelaySingleNOK){ + if(card_type_[i] == kCardRelaySingle){ std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot); if (base_ptr == nullptr) { continue; @@ -380,26 +381,9 @@ void ConfigMgr::Save(QString & file_path) { if(ptr->single_relay[ch].logic_expression != ""){ qDebug() << "ch" << ch << ptr->single_relay[ch].logic_expression; channel_item.insert("logic_expression", ptr->single_relay[ch].logic_expression); + channel_item.insert("active", ptr->single_relay[ch].active); } - }else if(card_type_[i] == kCardRelaySingle){ - std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot); - if (base_ptr == nullptr) { - continue; - } - std::shared_ptr ptr = std::dynamic_pointer_cast(base_ptr); - if(ptr->tmr_relay[ch].logic_expression != "") - channel_item.insert("logic_expression", ptr->tmr_relay[ch].logic_expression); - }else if(card_type_[i] == kCardRelayTMRPrimary){ - std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot); - if (base_ptr == nullptr) { - continue; - } - std::shared_ptr ptr = std::dynamic_pointer_cast(base_ptr); - 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); - } } if(!channel_item.isEmpty() ){ slot_item[QString::number(ch + 1)] = channel_item; @@ -596,6 +580,7 @@ void ConfigMgr::Load(QString filename) { variable->danger_latching_ = latching["danger"].toBool(); variable->timed_ok_ = latching["timed_ok"].toBool(); variable->zero_position.value = tmp_variable["zero_position"].toDouble(); + variable->zero_position.negation = tmp_variable["negation"].toBool(); vib_data->variables_.push_back(variable); break; } @@ -726,7 +711,7 @@ void ConfigMgr::Load(QString filename) { keyphase_data->variables_[j].automatic_threshold = channel["automatic_threshold"].toBool(); } cards_.push_back(keyphase_data); - }else if (card_type_[i] == kCardRelaySingleNOK ){ + }else if (card_type_[i] == kCardRelaySingle ){ std::shared_ptr singlerelay_data = std::make_shared(); singlerelay_data->slot_ = slot; singlerelay_data->card_type_ = static_cast(card_type_[i]); @@ -734,35 +719,10 @@ void ConfigMgr::Load(QString filename) { for (int j = 0; j < RELAY_COUNT; ++j) { channel = temp_obj[QString::number(j + 1)].toObject(); singlerelay_data->single_relay[j].logic_expression = channel["logic_expression"].toString(); - } - cards_.push_back(singlerelay_data); - }else if(card_type_[i] == kCardRelaySingle){ - std::shared_ptr relay_data = std::make_shared(); - relay_data->slot_ = slot; - relay_data->card_type_ = static_cast(card_type_[i]); - relay_data->version_ = temp_obj["version"].toInt(); - 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(); - } - cards_.push_back(relay_data); - }else if(card_type_[i] == kCardRelayTMRPrimary){ - std::shared_ptr relay_data = std::make_shared(); - 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(); + singlerelay_data->single_relay[j].active = channel["active"].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); + cards_.push_back(singlerelay_data); } } } diff --git a/data_config.h b/data_config.h index 1acfadc..d8ecaef 100644 --- a/data_config.h +++ b/data_config.h @@ -197,6 +197,7 @@ typedef struct { typedef struct { float value; + bool negation; } ZeroPosition; typedef struct { @@ -319,8 +320,10 @@ typedef struct SpeedAlert_{ typedef struct SingleRelayNOK_{ QString logic_expression; + bool active; SingleRelayNOK_(){ logic_expression = ""; + active = false; } } SingleRelayNOK; diff --git a/mainwindow.cpp b/mainwindow.cpp index e48be63..0820363 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -192,10 +192,10 @@ void MainWindow::createMenu(const QString &rootTitle, QPushButton *parent) { // 创建第二层子菜单:/DOM810 继电器模块 QAction *relays_1 = relays->addAction("/DOM810 单板卡"); relays_1->setData(kCardRelaySingle); - QAction *relays_2 = relays->addAction("/DOM810 单板卡-非OK"); - relays_2->setData(kCardRelaySingleNOK); - QAction *relays_3 = relays->addAction("/DOM810 三冗余板卡"); - relays_3->setData(kCardRelayTMRPrimary); +// QAction *relays_2 = relays->addAction("/DOM810 单板卡-非OK"); +// relays_2->setData(kCardRelaySingleNOK); +// QAction *relays_3 = relays->addAction("/DOM810 三冗余板卡"); +// relays_3->setData(kCardRelayTMRPrimary); // 将子菜单加入上一级菜单 monitors->addMenu(proximitor_menu); // 将第二层加入第一层 monitors->addMenu(rpm_menu); // 第二层另一个子菜单 @@ -222,8 +222,8 @@ void MainWindow::createMenu(const QString &rootTitle, QPushButton *parent) { //QObject::connect(proximitor_2, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); QObject::connect(rpm_1, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); QObject::connect(relays_1, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); - QObject::connect(relays_2, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); - QObject::connect(relays_3, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); + //QObject::connect(relays_2, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); + //QObject::connect(relays_3, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); QObject::connect(keyphasor_1, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); //QObject::connect(keyphasor_2, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); QObject::connect(reset, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); @@ -421,13 +421,7 @@ void MainWindow::OnButtonGroup(QAbstractButton *slot_btn) { key_phase->show(); } else if (slot_config.slot_type == "DOM810") { // 继电器模块 switch (card_type) { - case kCardRelaySingle: - case kCardRelayTMRPrimary:{ - TMRRelayAssociation *single_tmr_relay = new TMRRelayAssociation(button_id,card_type); - single_tmr_relay->setWindowModality(Qt::ApplicationModal); - single_tmr_relay->show(); - }break; - case kCardRelaySingleNOK:{ + case kCardRelaySingle:{ SingleRelay *single_relay = new SingleRelay(button_id,card_type); single_relay->setWindowModality(Qt::ApplicationModal); single_relay->show(); @@ -464,19 +458,12 @@ void MainWindow::OnButtonGroup(QAbstractButton *slot_btn) { tachometer->show(); break; } - case kCardRelaySingleNOK:{ + case kCardRelaySingle:{ SingleRelay *single_relay = new SingleRelay(button_id,card_type); single_relay->setWindowModality(Qt::ApplicationModal); single_relay->show(); break; } - case kCardRelaySingle: - case kCardRelayTMRPrimary:{ - TMRRelayAssociation *single_tmr_relay = new TMRRelayAssociation(button_id,card_type); - single_tmr_relay->setWindowModality(Qt::ApplicationModal); - single_tmr_relay->show(); - break; - } } } if (slot_btn != NULL && ui->pushButton_alarm->isChecked()) { diff --git a/singlerelay.cpp b/singlerelay.cpp index 973b218..44d9a87 100644 --- a/singlerelay.cpp +++ b/singlerelay.cpp @@ -103,6 +103,8 @@ void SingleRelay::Init(){ relay_data = std::dynamic_pointer_cast(base_ptr); qDebug() << "logic" <single_relay[current_index].logic_expression; + qDebug() << "active" <single_relay[current_index].active << "index" << current_index; + for(int i = 0 ; i < SLOT_NUM ; i++){ std::shared_ptr cardbase_ptr = ConfigMgr::Instance()->GetSlotPtr(i + 1); if(cardbase_ptr != nullptr && @@ -134,6 +136,7 @@ void SingleRelay::Init(){ if(!relay_data->single_relay[current_index].logic_expression.isEmpty()){ setExpressionToTreeView(treeView_relay, relay_data->single_relay[current_index].logic_expression); } + ui->checkBox_active->setChecked(relay_data->single_relay[current_index].active); } void SingleRelay::on_pushButton_cancel_clicked() { this->close(); @@ -243,6 +246,7 @@ void SingleRelay::on_pushButton_confirm_clicked() return; } relay_data->single_relay[current_index].logic_expression = finalExpr; + relay_data->single_relay[current_index].active = ui->checkBox_active->isChecked(); qDebug() << "逻辑表达式:" << finalExpr; this->close(); } @@ -267,8 +271,10 @@ void SingleRelay::onComboBoxIndexChanged(int index){ } qDebug() << "finalExpr" << finalExpr; relay_data->single_relay[current_index].logic_expression = finalExpr; + relay_data->single_relay[current_index].active = ui->checkBox_active->isChecked(); current_index = index; - + qDebug() << "active" << relay_data->single_relay[index].active; + ui->checkBox_active->setChecked(relay_data->single_relay[index].active); if(relay_data->single_relay[index].logic_expression != "") setExpressionToTreeView(treeView_relay, relay_data->single_relay[index].logic_expression); else diff --git a/singlerelay.ui b/singlerelay.ui index 29e2654..aa8fe67 100644 --- a/singlerelay.ui +++ b/singlerelay.ui @@ -183,7 +183,7 @@ - + 26 diff --git a/trust.cpp b/trust.cpp index 32a15de..8d7faed 100644 --- a/trust.cpp +++ b/trust.cpp @@ -73,6 +73,7 @@ void Trust::Init() { ui->comboBox_recorder_output->setCurrentIndex(variable_ptr->recorder_out_.recorder_output); ui->checkBox_two_ma_clamp->setChecked(variable_ptr->recorder_out_.two_ma_clamp); ui->doubleSpinBox_zero_position->setValue(variable_ptr->zero_position.value); + ui->checkBox_negation->setChecked(variable_ptr->zero_position.negation); } void Trust::on_pushButton_confirm_clicked() { @@ -114,6 +115,7 @@ void Trust::on_pushButton_confirm_clicked() variable->alert_latching_ = ui->checkBox_alert_latching->isChecked(); variable->danger_latching_ = ui->checkBox_danger_latching->isChecked(); variable->zero_position.value = ui->doubleSpinBox_zero_position->value(); + variable->zero_position.negation = ui->checkBox_negation->isChecked(); ptr->variables_.push_back(variable); this->close(); return; @@ -140,6 +142,8 @@ void Trust::on_pushButton_confirm_clicked() variable->delay_.active_100ms = ui->checkBox_100ms->isChecked(); variable->alert_latching_ = ui->checkBox_alert_latching->isChecked(); variable->danger_latching_ = ui->checkBox_danger_latching->isChecked(); + variable->zero_position.value = ui->doubleSpinBox_zero_position->value(); + variable->zero_position.negation = ui->checkBox_negation->isChecked(); this->close(); } diff --git a/trust.ui b/trust.ui index ba6bd3b..2342452 100644 --- a/trust.ui +++ b/trust.ui @@ -562,7 +562,7 @@ 10 - 50 + 30 61 21 @@ -581,13 +581,26 @@ 80 - 50 + 30 91 16 - -6.33 - 13.99 V + 0 - 13.99 V + + + + + + 10 + 70 + 71 + 16 + + + + 取反