diff --git a/TSI_Config.pro b/TSI_Config.pro index a800707..8633346 100644 --- a/TSI_Config.pro +++ b/TSI_Config.pro @@ -36,6 +36,7 @@ SOURCES += \ setpoint_tachometer.cpp \ singlerelay.cpp \ singlerelay_data.cpp \ + singlerelay_nok.cpp \ tachometer.cpp \ tachometer_data.cpp \ tmrrelayassociation.cpp \ @@ -74,6 +75,7 @@ HEADERS += \ setpoint_tachometer.h \ singlerelay.h \ singlerelay_data.h \ + singlerelay_nok.h \ tachometer.h \ tachometer_data.h \ tmrrelayassociation.h \ @@ -104,6 +106,7 @@ FORMS += \ seismic_monitor.ui \ setpoint_tachometer.ui \ singlerelay.ui \ + singlerelay_nok.ui \ tachometer.ui \ tmrrelayassociation.ui \ trust.ui \ diff --git a/cardbase.h b/cardbase.h index 00d6e46..3d89ae8 100644 --- a/cardbase.h +++ b/cardbase.h @@ -15,6 +15,7 @@ class CardBase { int slot_; // 从1~15 CardType card_type_; int relative_number; + int group; }; class VariableBase { diff --git a/config_mgr.cpp b/config_mgr.cpp index c6069d1..1a80488 100644 --- a/config_mgr.cpp +++ b/config_mgr.cpp @@ -568,6 +568,7 @@ void ConfigMgr::Save(QString & file_path) { } slot_item["version"] = 1; slot_item["relative_number"] = base_ptr->relative_number; + slot_item["group"] = base_ptr->group; }else{ for(int ch = 0;ch < RELAY_COUNT;++ch){ QJsonObject channel_item; @@ -596,8 +597,18 @@ void ConfigMgr::Save(QString & file_path) { channel_item.insert("vote",ptr->single_relay[ch].vote); channel_item.insert("active", ptr->single_relay[ch].active); channel_item.insert("group",ptr->single_relay[ch].group); + }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() ){ + if(!channel_item.isEmpty()){ slot_item[QString::number(ch + 1)] = channel_item; } } @@ -1115,6 +1126,22 @@ void ConfigMgr::Load(QString filename) { singlerelay_data->single_relay[j].group = channel["group"].toInt(); } cards_.push_back(singlerelay_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(); + } + 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); } } } diff --git a/data_config.h b/data_config.h index 81e72b7..300cfb6 100644 --- a/data_config.h +++ b/data_config.h @@ -503,6 +503,20 @@ typedef struct SpeedAlert_{ } } SpeedAlert; +typedef struct SingleRelayS_{ + QString logic_expression; + bool active; + int group; + bool vote; + QString logic[10]; + int count_vote; + SingleRelayS_(){ + logic_expression = ""; + active = false; + vote = false; + } +} SingleRelayS; + typedef struct SingleRelayNOK_{ QString logic_expression; bool active; diff --git a/keyphase.cpp b/keyphase.cpp index 097dc6d..8130461 100644 --- a/keyphase.cpp +++ b/keyphase.cpp @@ -197,6 +197,7 @@ void KeyPhase::Init() { ui->spinBox_events_per_revolution_4->setValue(keyphase_data->variables_[i].events_per_revolution); } } + ui->comboBox_group->setCurrentIndex(base_ptr->group + 1); } void KeyPhase::on_pushButton_confirm_clicked() { std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); @@ -204,6 +205,7 @@ void KeyPhase::on_pushButton_confirm_clicked() { qCritical() << " should not be here"; return; } + base_ptr->group = ui->comboBox_group->currentIndex() + 1; std::shared_ptr keyphase_data = std::dynamic_pointer_cast(base_ptr); UpdateData(keyphase_data); this->close(); diff --git a/keyphase.ui b/keyphase.ui index 5e7049a..ebbabd4 100644 --- a/keyphase.ui +++ b/keyphase.ui @@ -81,7 +81,7 @@ - + 50 diff --git a/mainwindow.cpp b/mainwindow.cpp index 361710d..2d13d76 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -28,6 +28,7 @@ #include #include "dc_outputs.h" #include "mqtt_config.h" +#include "singlerelay_nok.h" #include QString g_strServerIp; @@ -195,10 +196,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); // 第二层另一个子菜单 @@ -228,8 +229,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); @@ -287,8 +288,8 @@ void MainWindow::onMenuActionTriggered() { qDebug() << "子菜单项被点击,所属按钮:" << button->objectName() << action->text(); QString slot_type = action->text().mid(1, 6); QString rack_type = action->text().right(action->text().length() - 8); - qDebug() << "rack_type" << action->data(); card_type = static_cast(action->data().toInt()); + qDebug() << "rack_type" << action->data() << "card type" << card_type; int button_id = button->objectName().right(button->objectName().length() - 15).toInt(); qDebug() << slot_type << rack_type << button_id << map_slot_config[button_id].slot_type << map_slot_config[button_id + 2].slot_type ; map_slot_config[button_id].slot_label->setStyleSheet("QLabel { color :#2980b9; font: bold 16px}"); @@ -421,7 +422,7 @@ void MainWindow::onMenuActionTriggered() { void MainWindow::OnButtonGroup(QAbstractButton *slot_btn) { if (slot_btn != NULL && ui->pushButton_chan->isChecked()) { QString object_name = slot_btn->objectName(); - qDebug() << object_name ; + qDebug() << object_name << card_type ; int button_id = object_name.right(object_name.length() - 15).toInt(); SlotConfig slot_config = map_slot_config[button_id]; map_slot_config[button_id].slot_label->setStyleSheet("QLabel { color :#2980b9; font: bold 16px}"); @@ -437,11 +438,21 @@ void MainWindow::OnButtonGroup(QAbstractButton *slot_btn) { key_phase->show(); } else if (slot_config.slot_type == "DOM810") { // 继电器模块 switch (card_type) { + case kCardRelayTMRPrimary:{ + TMRRelayAssociation *single_tmr_relay = new TMRRelayAssociation(button_id,card_type); + single_tmr_relay->setWindowModality(Qt::ApplicationModal); + single_tmr_relay->show(); + }break; case kCardRelaySingle:{ SingleRelay *single_relay = new SingleRelay(button_id,card_type); single_relay->setWindowModality(Qt::ApplicationModal); single_relay->show(); }break; + case kCardRelaySingleNOK:{ + SingleRelay_NOK *single_relay_nok = new SingleRelay_NOK(button_id,card_type); + single_relay_nok->setWindowModality(Qt::ApplicationModal); + single_relay_nok->show(); + }break; } } else if (slot_config.slot_type == "HAM824") { // 振动模块 @@ -455,6 +466,7 @@ void MainWindow::OnButtonGroup(QAbstractButton *slot_btn) { } return; } + qDebug() << "base_ptr->card_type_" << base_ptr->card_type_; switch(base_ptr->card_type_){ case kCardVibSingle:{ Seismic_monitor *seismic_monitor = new Seismic_monitor(button_id,card_type); @@ -480,6 +492,11 @@ void MainWindow::OnButtonGroup(QAbstractButton *slot_btn) { single_relay->show(); break; } + 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/seismic_monitor.cpp b/seismic_monitor.cpp index d6a95eb..313aa10 100644 --- a/seismic_monitor.cpp +++ b/seismic_monitor.cpp @@ -19,7 +19,7 @@ #include "channel_3_4.h" #include "copy_channel.h" -Seismic_monitor::Seismic_monitor(int slot,int cardtype, QWidget *parent) : +Seismic_monitor::Seismic_monitor(int slot,CardType cardtype, QWidget *parent) : QWidget(parent), ui(new Ui::Seismic_monitor) { ui->setupUi(this); @@ -30,7 +30,7 @@ Seismic_monitor::Seismic_monitor(int slot,int cardtype, QWidget *parent) : ui->comboBox_chan_type_4->setView(new QListView()); slot_no = slot; - car_type = static_cast(cardtype); + car_type = cardtype; QString slot_no_ = QString("%1").arg(slot_no); ui->label_slot_no->setText(slot_no_); Init(); @@ -49,6 +49,7 @@ void Seismic_monitor::Init() { std::shared_ptr vib_data = std::make_shared(); vib_data->slot_ = slot_no; vib_data->card_type_ = car_type; + qDebug() << "card type" << vib_data->card_type_; ConfigMgr::Instance()->AddCard(vib_data); UpdateData(vib_data); return; @@ -114,6 +115,7 @@ void Seismic_monitor::Init() { } } ui->comboBox_relative_number->setCurrentIndex(base_ptr->relative_number); + ui->comboBox_group->setCurrentIndex(base_ptr->group + 1); } void Seismic_monitor::UpdateData(std::shared_ptr vib_data) { @@ -226,8 +228,10 @@ void Seismic_monitor::on_pushButton_confirm_clicked() { } } base_ptr->relative_number = ui->comboBox_relative_number->currentIndex(); + base_ptr->group = ui->comboBox_group->currentIndex() + 1; std::shared_ptr vib_data = std::dynamic_pointer_cast(base_ptr); UpdateData(vib_data); + qDebug() <<"type" << base_ptr->card_type_; this->close(); } @@ -422,21 +426,6 @@ void Seismic_monitor::on_pushButton_cancel_clicked() { this->close(); } -void Seismic_monitor::on_comboBox_transducer_name_1_currentTextChanged(const QString &arg1) { - -} - -void Seismic_monitor::on_comboBox_transducer_name_2_currentTextChanged(const QString &arg1) { - -} - -void Seismic_monitor::on_comboBox_transducer_name_3_currentTextChanged(const QString &arg1) { - -} - -void Seismic_monitor::on_comboBox_transducer_name_4_currentTextChanged(const QString &arg1) { - -} void Seismic_monitor::EnableKeyphase(){ ui->checkBox_keyphase->setCheckable(true); ui->checkBox_keyphase->setEnabled(true); diff --git a/seismic_monitor.h b/seismic_monitor.h index 539d3a6..c9da054 100644 --- a/seismic_monitor.h +++ b/seismic_monitor.h @@ -13,7 +13,7 @@ class Seismic_monitor : public QWidget { Q_OBJECT public: - explicit Seismic_monitor(int slot,int cardtype, QWidget *parent = nullptr); + explicit Seismic_monitor(int slot,CardType cardtype, QWidget *parent = nullptr); ~Seismic_monitor(); int slot_no; int channel; @@ -41,14 +41,6 @@ class Seismic_monitor : public QWidget { void on_pushButton_cancel_clicked(); - void on_comboBox_transducer_name_1_currentTextChanged(const QString &arg1); - - void on_comboBox_transducer_name_2_currentTextChanged(const QString &arg1); - - void on_comboBox_transducer_name_3_currentTextChanged(const QString &arg1); - - void on_comboBox_transducer_name_4_currentTextChanged(const QString &arg1); - void on_comboBox_sensitivity_unit_1_currentTextChanged(const QString &arg1); void on_comboBox_sensitivity_unit_2_currentTextChanged(const QString &arg1); diff --git a/seismic_monitor.ui b/seismic_monitor.ui index 45b0213..e49715a 100644 --- a/seismic_monitor.ui +++ b/seismic_monitor.ui @@ -75,7 +75,7 @@ - + 50 diff --git a/singlerelay_data.h b/singlerelay_data.h index 7b08d65..34529ea 100644 --- a/singlerelay_data.h +++ b/singlerelay_data.h @@ -5,7 +5,7 @@ class SingleRelayData : public CardBase { public: SingleRelayData(); - SingleRelayNOK single_relay[RELAY_COUNT]; + SingleRelayS single_relay[RELAY_COUNT]; }; #endif // SINGLERELAY_DATA_H diff --git a/singlerelay_nok.cpp b/singlerelay_nok.cpp new file mode 100644 index 0000000..3b46291 --- /dev/null +++ b/singlerelay_nok.cpp @@ -0,0 +1,527 @@ +#include "singlerelay_nok.h" +#include "ui_singlerelay_nok.h" +#include "vibrationdata.h" +#include +#include +#include + +SingleRelay_NOK::SingleRelay_NOK(int slot,int cardtype,QWidget *parent) : + QWidget(parent), + ui(new Ui::SingleRelay_NOK) +{ + ui->setupUi(this); + slot_no = slot; + car_type = static_cast(cardtype); + ui->label_slot_no->setText(QString::number(slot_no)); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + QVBoxLayout *layout_available = new QVBoxLayout(ui->widget_available); + list_widget_available = new QListWidget(); + layout_available->addWidget(list_widget_available); + list_widget_available->setDragEnabled(true); + + QVBoxLayout *layout_relay = new QVBoxLayout(ui->widget_relay); + treeView_relay = new QTreeView; + layout_relay->addWidget(treeView_relay); + treeView_relay->setDragEnabled(true); // 启用拖动 + treeView_relay->setAcceptDrops(true); // 接受放下 + treeView_relay->setDropIndicatorShown(true); // 显示放置指示器 + treeView_relay->setDragDropMode(QAbstractItemView::DropOnly); + model_Relay = new DropTreeModel(this); //创建模型指定父类 + treeView_relay->setModel(model_Relay); + treeView_relay->setHeaderHidden(true); + + btnGroup_slot = new QButtonGroup(this); + btnGroup_slot->addButton(ui->pushButton_slot1); + btnGroup_slot->addButton(ui->pushButton_slot2); + btnGroup_slot->addButton(ui->pushButton_slot3); + btnGroup_slot->addButton(ui->pushButton_slot4); + btnGroup_slot->addButton(ui->pushButton_slot5); + btnGroup_slot->addButton(ui->pushButton_slot6); + btnGroup_slot->addButton(ui->pushButton_slot7); + btnGroup_slot->addButton(ui->pushButton_slot8); + btnGroup_slot->addButton(ui->pushButton_slot9); + btnGroup_slot->addButton(ui->pushButton_slot10); + btnGroup_slot->addButton(ui->pushButton_slot11); + btnGroup_slot->addButton(ui->pushButton_slot12); + btnGroup_slot->addButton(ui->pushButton_slot13); + btnGroup_slot->addButton(ui->pushButton_slot14); + btnGroup_slot->addButton(ui->pushButton_slot15); + + connect(btnGroup_slot, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(OnButtonGroup(QAbstractButton *))); + connect(ui->comboBox_relay_ch, QOverload::of(&QComboBox::currentIndexChanged), + this, &SingleRelay_NOK::onComboBoxIndexChanged); + treeView_relay->setContextMenuPolicy(Qt::CustomContextMenu); + connect(treeView_relay,&QTreeView::customContextMenuRequested,this,&SingleRelay_NOK::on_treeView_Relay_customContextMenuRequested); + current_index = ui->comboBox_relay_ch->currentIndex(); + vote_current_index = ui->comboBox_vote_group->currentIndex(); + Init(); + onComboBoxIndexChanged(current_index); +} +void SingleRelay_NOK::Init(){ + QList buttonList = btnGroup_slot->buttons(); + for (int i = 1; i < buttonList.count() + 1; i++) { + std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(i); + if(base_ptr != nullptr){ + switch (base_ptr->card_type_) { + case kCardVibSingle :{ + buttonList[i - 1]->setText("振动"); + break; + } + case kCardKeyphaseSingle:{ + buttonList[i - 1]->setText("键相"); + break; + } + case kCardSpeedSingle:{ + buttonList[i - 1]->setText("转速"); + break; + } + case kCardRelaySingle: + case kCardRelaySingleNOK: + case kCardRelayTMRPrimary:{ + buttonList[i - 1]->setText("继电器"); + break; + } + default: + break; + } + } + } + std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); + if (base_ptr == nullptr) { + // do nothing or use template to init it. + relay_data = std::make_shared(); + relay_data->card_type_ = car_type; + relay_data->slot_ = slot_no; + ConfigMgr::Instance()->AddCard(relay_data); + return; + } + 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 && + cardbase_ptr->card_type_ == kCardVibSingle){ + std::shared_ptr ptr = std::dynamic_pointer_cast(cardbase_ptr); + for (int var = 0; var < CHANNEL_COUNT; ++var) { + std::shared_ptr variable_base = ptr->GetChannelPtr(var + 1); + if(variable_base == nullptr) + continue; + QString item_data,item_str; + if(variable_base->alert_high.enable){ + item_str = QString("%1 (槽位 %2 通道 %3 警报高)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2)); + item_data = QString("%1A2").arg(ptr->base_config_[var].chan_id); + } + channelNameMap[item_data] = item_str; + if(variable_base->danger_high.enable){ + item_str = QString("%1 (槽位 %2 通道 %3 危险高)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2)); + item_data = QString("%1A1").arg(ptr->base_config_[var].chan_id); + } + channelNameMap[item_data] = item_str; + if(variable_base->alert_low.enable){ + item_str = QString("%1 (槽位 %2 通道 %3 警报低)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2)); + item_data = QString("%1A3").arg(ptr->base_config_[var].chan_id); + } + channelNameMap[item_data] = item_str; + if(variable_base->danger_low.enable){ + item_str = QString("%1 (槽位 %2 通道 %3 危险低)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2)); + item_data = QString("%1A4").arg(ptr->base_config_[var].chan_id); + } + if(var == 3){ + qDebug() << "alert" << variable_base->danger_high.enable<danger_high.enable; + } + channelNameMap[item_data] = item_str; + item_str = QString("%1 (槽位 %2 通道 %3 非OK)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2)); + item_data = QString("%1P##NO").arg(ptr->base_config_[var].chan_id); + channelNameMap[item_data] = item_str; + } + }else if(cardbase_ptr != nullptr && + cardbase_ptr->card_type_ == kCardSpeedSingle){ + } + } + 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); + ui->comboBox_group->setCurrentIndex(relay_data->single_relay[current_index].group - 1); +} +SingleRelay_NOK::~SingleRelay_NOK() +{ + delete ui; +} + +void SingleRelay_NOK::on_pushButton_confirm_clicked() +{ + QStandardItemModel *model = qobject_cast(treeView_relay->model()); + if (!model) return; + + QStandardItem *root = model->invisibleRootItem(); + QString finalExpr; + for (int i = 0; i < root->rowCount(); ++i) { + QStandardItem *topItem = root->child(i); + QString expr = buildLogicExpression(topItem); + finalExpr += expr; + } + ExprValidationResult result = validateLogicExpression(finalExpr); + if (!result.isValid && !finalExpr.isEmpty()) { + QMessageBox::warning(this, "表达式错误", + QString("错误位置:%1\n错误描述:%2").arg(result.errorPos).arg(result.errorMsg)); + return; + } + if(ui->checkBox_vote->checkState()){ + relay_data->single_relay[current_index].logic[ui->comboBox_vote_group->currentIndex()] = finalExpr; + }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].group = ui->comboBox_group->currentIndex() + 1; + qDebug() << "逻辑表达式:" << finalExpr; + this->close(); +} + + +void SingleRelay_NOK::on_pushButton_cancel_clicked() +{ + this->close(); +} +void SingleRelay_NOK::OnButtonGroup(QAbstractButton *slot_btn) { + if (slot_btn != NULL) { + list_widget_available->clear(); + QString object_name = slot_btn->objectName(); + qDebug() << object_name ; + int button_id = object_name.right(object_name.length() - 15).toInt(); + std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id); + std::shared_ptr ptr = std::dynamic_pointer_cast(base_ptr); + if(ptr == nullptr) + return; + QListWidgetItem *item_and = new QListWidgetItem("AND"); + item_and->setData(Qt::UserRole, "*"); + list_widget_available->addItem(item_and); + + QListWidgetItem *item_or = new QListWidgetItem("OR"); + item_or->setData(Qt::UserRole, "+"); + list_widget_available->addItem(item_or); + + for(int var = 0; var < CHANNEL_COUNT ; ++var){ + std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id); + std::shared_ptr variable_base = ptr->GetChannelPtr(var + 1); + if(variable_base == nullptr) + continue; + if(base_ptr->card_type_ == kCardVibSingle){ + QString item_data; + if(variable_base->alert_high.enable){ + QString item_str = QString("%1 (槽位 %3 通道 %4 警报高)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + QListWidgetItem *item = new QListWidgetItem(item_str); + item_data = QString("S%1C%2A2").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + item->setData(Qt::UserRole, item_data); + list_widget_available->addItem(item); + } + + if(variable_base->danger_high.enable){ + QString item_str = QString("%1 (槽位 %3 通道 %4 危险高)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + QListWidgetItem *item = new QListWidgetItem(item_str); + item_data = QString("S%1C%2A1").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + item->setData(Qt::UserRole, item_data); + list_widget_available->addItem(item); + } + if(variable_base->danger_low.enable){ + QString item_str = QString("%1 (槽位 %3 通道 %4 危险低)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + QListWidgetItem *item = new QListWidgetItem(item_str); + item_data = QString("S%1C%2A4").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + item->setData(Qt::UserRole, item_data); + list_widget_available->addItem(item); + } + if(variable_base->alert_low.enable){ + QString item_str = QString("%1 (槽位 %3 通道 %4 警报低)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + QListWidgetItem *item = new QListWidgetItem(item_str); + item_data = QString("S%1C%2A3").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + item->setData(Qt::UserRole, item_data); + list_widget_available->addItem(item); + } + QString item_str = QString("%1 (槽位 %2 通道 %3 非OK)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + QListWidgetItem *item = new QListWidgetItem(item_str); + QString item_data_nok = QString("S%1C%2P##NO").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + item->setData(Qt::UserRole, item_data_nok); + list_widget_available->addItem(item); + } + } + } +} +QString SingleRelay_NOK::buildLogicExpression(QStandardItem *item) { + if (!item) return ""; + + int childCount = item->rowCount(); + QVariant userData = item->data(Qt::UserRole); + QString text = userData.toString().trimmed(); + qDebug() << "item" << userData; + if (childCount == 0) { + // 叶子节点,直接返回表达式,比如 S01C01A1 + return text; + } + + // 判断当前是 +(OR)还是 *(AND) + QString opStr = (text == "+") ? "+" : + (text == "*") ? "*" : ""; + + // 如果不是 +/*,视为叶子节点 + if (opStr.isEmpty()) { + return text; + } + + QStringList subExprs; + for (int i = 0; i < childCount; ++i) { + QStandardItem *child = item->child(i); + subExprs << buildLogicExpression(child); + } + + return "(" + subExprs.join(" " + opStr + " ") + ")"; +} +void SingleRelay_NOK::onComboBoxIndexChanged(int index){ + + qDebug()<< "[SingleRelay]:index " << index; + + QStandardItemModel *model = qobject_cast(treeView_relay->model()); + if (!model) return; + QStandardItem *root = model->invisibleRootItem(); + QString finalExpr; + for (int i = 0; i < root->rowCount(); ++i) { + QStandardItem *topItem = root->child(i); + QString expr = buildLogicExpression(topItem); + finalExpr += expr; + } + ExprValidationResult result = validateLogicExpression(finalExpr); + if (!result.isValid && !finalExpr.isEmpty()) { + QMessageBox::warning(this, "表达式错误", + QString("错误位置:%1\n错误描述:%2").arg(result.errorPos).arg(result.errorMsg)); + 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()] != "") + setExpressionToTreeView(treeView_relay, relay_data->single_relay[index].logic[ui->comboBox_vote_group->currentIndex()]); + else + model_Relay->clear(); + }else{ + relay_data->single_relay[current_index].logic_expression = finalExpr; + if(relay_data->single_relay[index].logic_expression != "") + setExpressionToTreeView(treeView_relay, relay_data->single_relay[index].logic_expression); + else + model_Relay->clear(); + } + relay_data->single_relay[current_index].active = ui->checkBox_active->isChecked(); + relay_data->single_relay[current_index].group = ui->comboBox_group->currentIndex() + 1; + current_index = index; + qDebug() << "active" << relay_data->single_relay[index].active; + ui->checkBox_active->setChecked(relay_data->single_relay[index].active); + +} +ExprNode* SingleRelay_NOK::parseExpression(const QString& expr, int& pos) { + auto skipSpaces = [&]() { + while (pos < expr.length() && expr[pos].isSpace()) pos++; + }; + + QStack nodeStack; + QStack opStack; + + while (pos < expr.length()) { + skipSpaces(); + if (pos >= expr.length()) break; + + QChar ch = expr[pos]; + + if (ch == '(') { + pos++; + nodeStack.push(parseExpression(expr, pos)); + } else if (ch == ')') { + pos++; + break; + } else if (ch == '+' || ch == '*') { + opStack.push(QString(ch)); + pos++; + } else { + QString token; + while (pos < expr.length() && !QString("()+* ").contains(expr[pos])) { + token += expr[pos++]; + } + if (!token.isEmpty()) { + nodeStack.push(new ExprNode{token, {}}); + } + } + + while (opStack.size() > 0 && nodeStack.size() >= 2) { + QString op = opStack.pop(); + ExprNode* right = nodeStack.pop(); + ExprNode* left = nodeStack.pop(); + + if (left->value == op) { + left->children.append(right); + nodeStack.push(left); + } else if (right->value == op) { + right->children.prepend(left); + nodeStack.push(right); + } else { + ExprNode* parent = new ExprNode{op, {left, right}}; + nodeStack.push(parent); + } + } + } + + return nodeStack.isEmpty() ? nullptr : nodeStack.top(); +} +QStandardItem* SingleRelay_NOK::buildItemTree(ExprNode* node) { + if (!node) return nullptr; + QString displayText; + if (node->value == "+" || node->value == "*") { + displayText = (node->value == "+") ? "OR" : "AND"; // 运算符显示 + } else { + displayText = channelNameMap.value(node->value, node->value); // 显示名 + qDebug() << "display" <value; + } + QStandardItem* item = new QStandardItem(displayText); + item->setData(node->value, Qt::UserRole); // 原始表达式key + for (ExprNode* child : node->children) { + item->appendRow(buildItemTree(child)); + } + return item; +} + + +ExprValidationResult SingleRelay_NOK::validateLogicExpression(const QString& expr) { + int bracketCount = 0; + bool lastWasOperator = true; + bool lastWasOpenParen = false; + + for (int i = 0; i < expr.length(); ++i) { + QChar ch = expr[i]; + + if (ch.isSpace()) continue; + + if (ch == '(') { + bracketCount++; + lastWasOpenParen = true; + lastWasOperator = true; + } else if (ch == ')') { + bracketCount--; + if (bracketCount < 0) { + return {false, i, "多余的右括号 ')'"}; + } + lastWasOpenParen = false; + lastWasOperator = false; + } else if (ch == '+' || ch == '*') { + if (lastWasOperator || lastWasOpenParen) { + return {false, i, QString("无效的运算符 '%1' 的位置").arg(ch)}; + } + lastWasOperator = true; + lastWasOpenParen = false; + } else if (ch.isLetterOrNumber()) { + QString token; + int start = i; + while (i < expr.length() && expr[i].isLetterOrNumber()) { + token += expr[i]; + ++i; + } + --i; // 修正多读了一位 + if (token.isEmpty()) { + return {false, start, "变量名称缺失"}; + } + lastWasOperator = false; + lastWasOpenParen = false; + } else if (ch.isLetterOrNumber() || ch == '#' || ch.unicode() > 127) { + QString token; + int start = i; + while (i < expr.length() && + (expr[i].isLetterOrNumber() || expr[i] == '#' || expr[i].unicode() > 127)) { + token += expr[i]; + ++i; + } + --i; + if (token.isEmpty()) { + return {false, start, "变量名称缺失"}; + } + lastWasOperator = false; + lastWasOpenParen = false; + }else { + return {false, i, QString("不支持的字符 '%1'").arg(ch)}; + } + } + + if (bracketCount != 0) { + return {false, expr.length(), "括号不匹配"}; + } + + if (lastWasOperator) { + return {false, expr.length() - 1, "表达式不能以运算符结尾"}; + } + + return {true, -1, ""}; +} +void SingleRelay_NOK::setExpressionToTreeView(QTreeView* treeView, const QString& expr) { + int pos = 0; + model_Relay->clear(); + qDebug() << "expr" << expr; + ExprNode* root = parseExpression(expr, pos); + QStandardItem* rootItem = buildItemTree(root); + + model_Relay->appendRow(rootItem); + treeView_relay->expandAll(); +} +void SingleRelay_NOK::slotDeleteItem() +{ + QModelIndex curIndex = treeView_relay->currentIndex(); + if(curIndex.isValid()){ + model_Relay->removeRow(curIndex.row(),curIndex.parent()); + } +} +void SingleRelay_NOK::on_treeView_Relay_customContextMenuRequested(const QPoint &pos) +{ + qDebug() << "on_treeView_Relay_customContextMenuRequested" <indexAt(pos); //当前点击的元素的index + QModelIndex index = curIndex.sibling(curIndex.row(),0); //该行的第1列元素的index + QMenu menu(this); + if (index.isValid()){ + //添加一行菜单,进行展开 + menu.addAction(QStringLiteral("删除"), this, SLOT(slotDeleteItem())); + menu.addSeparator(); //添加一个分隔线 + } + menu.exec(QCursor::pos()); //显示菜单 +} +void SingleRelay_NOK::on_comboBox_vote_group_currentIndexChanged(int index) +{ + QStandardItemModel *model = qobject_cast(treeView_relay->model()); + if (!model) return; + QStandardItem *root = model->invisibleRootItem(); + QString finalExpr; + for (int i = 0; i < root->rowCount(); ++i) { + QStandardItem *topItem = root->child(i); + QString expr = buildLogicExpression(topItem); + finalExpr += expr; + } + ExprValidationResult result = validateLogicExpression(finalExpr); + if (!result.isValid && !finalExpr.isEmpty()) { + QMessageBox::warning(this, "表达式错误", + QString("错误位置:%1\n错误描述:%2").arg(result.errorPos).arg(result.errorMsg)); + return; + } + qDebug() << "finalExpr" << finalExpr; + 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]); + else + model_Relay->clear(); + vote_current_index = index; +} + + + +void SingleRelay_NOK::on_checkBox_vote_clicked(bool checked) +{ + if(checked){ + ui->comboBox_vote_group->setEnabled(true); + }else{ + ui->comboBox_vote_group->setEnabled(false); + } +} + diff --git a/singlerelay_nok.h b/singlerelay_nok.h new file mode 100644 index 0000000..962514c --- /dev/null +++ b/singlerelay_nok.h @@ -0,0 +1,65 @@ +#ifndef SINGLERELAY_NOK_H +#define SINGLERELAY_NOK_H + +#include +#include +#include +#include +#include "data_config.h" +#include "config_mgr.h" +#include "singlerelay_data.h" +#include //数据模型类 +#include + +namespace Ui { +class SingleRelay_NOK; +} + +class SingleRelay_NOK : public QWidget +{ + Q_OBJECT + +public: + explicit SingleRelay_NOK(int slot,int cardtype,QWidget *parent = nullptr); + ~SingleRelay_NOK(); + int slot_no; + CardType car_type; +private slots: + void on_pushButton_confirm_clicked(); + + void on_pushButton_cancel_clicked(); + + void on_comboBox_vote_group_currentIndexChanged(int index); + + void OnButtonGroup(QAbstractButton *); + + void onComboBoxIndexChanged(int index); + + void slotDeleteItem(); + + void on_checkBox_vote_clicked(bool checked); + + void on_treeView_Relay_customContextMenuRequested(const QPoint &pos); + + +private: + Ui::SingleRelay_NOK *ui; + QButtonGroup * btnGroup_slot = nullptr; + QListWidget *list_widget_available = nullptr; + QTreeView *treeView_relay; + QStandardItemModel *model_Relay; + std::shared_ptr relay_data = nullptr; + int current_index; + int vote_current_index; + QMap channelNameMap; + + void Init(); + void buildTreeFromExpression(QTreeView *treeView, const QString &expr); + ExprNode* parseExpression(const QString& expr, int& pos); + QStandardItem* buildItemTree(ExprNode* node); + void setExpressionToTreeView(QTreeView* treeView, const QString& expr); + QString buildLogicExpression(QStandardItem *item); + ExprValidationResult validateLogicExpression(const QString& expr); +}; + +#endif // SINGLERELAY_NOK_H diff --git a/singlerelay_nok.ui b/singlerelay_nok.ui new file mode 100644 index 0000000..17eeb78 --- /dev/null +++ b/singlerelay_nok.ui @@ -0,0 +1,1140 @@ + + + SingleRelay_NOK + + + + 0 + 0 + 903 + 606 + + + + Form + + + + + 630 + 70 + 111 + 32 + + + + + + + 逻辑: + + + + + + + false + + + + 50 + 30 + + + + + 16777215 + 30 + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + 6 + + + + + 7 + + + + + 8 + + + + + 9 + + + + + 10 + + + + + + + + + + 10 + 40 + 606 + 295 + + + + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 1 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 2 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 3 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 4 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 5 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 6 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 7 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 8 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 9 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 10 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 11 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 12 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 13 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 14 + + + Qt::AlignCenter + + + + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + 15 + + + Qt::AlignCenter + + + + + + + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + + + + + + + + + 30 + 220 + + + + + 30 + 220 + + + + + + + + + + + + + + + + 140 + 10 + 101 + 16 + + + + TextLabel + + + Qt::AlignCenter + + + + + + 220 + 514 + 420 + 51 + + + + + + + + 100 + 35 + + + + 确 定 + + + + + + + + 100 + 35 + + + + 取 消 + + + + + + + false + + + + 100 + 35 + + + + 打 印... + + + + + + + false + + + + 100 + 35 + + + + 帮 助 + + + + + + + + + 631 + 131 + 111 + 27 + + + + + + + 选择: + + + + + + + + 50 + 25 + + + + + 50 + 25 + + + + + + + + + + 620 + 180 + 91 + 16 + + + + 告警驱动逻辑: + + + + + + 10 + 350 + 201 + 151 + + + + 继电器关联 + + + + + 20 + 120 + 85 + 20 + + + + 激活 + + + + + + 10 + 70 + 42 + 16 + + + + 分组: + + + + + + 60 + 60 + 101 + 30 + + + + + 50 + 30 + + + + + 16777215 + 30 + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + + + 10 + 30 + 42 + 16 + + + + 通道: + + + + + + 60 + 20 + 103 + 30 + + + + + 50 + 30 + + + + + 16777215 + 30 + + + + + 通道 1 + + + + + 通道 2 + + + + + 通道 3 + + + + + 通道 4 + + + + + 通道 5 + + + + + 通道 6 + + + + + 通道 7 + + + + + 通道 8 + + + + + 通道 9 + + + + + 通道 10 + + + + + 通道 11 + + + + + 通道 12 + + + + + 通道 13 + + + + + 通道 14 + + + + + 通道 15 + + + + + 通道 16 + + + + + + + + 230 + 360 + 381 + 141 + + + + + + + 40 + 10 + 91 + 16 + + + + 继电器槽位: + + + + + + 640 + 30 + 121 + 16 + + + + 是否投票 + + + + + + 620 + 200 + 341 + 301 + + + + + + + 230 + 340 + 111 + 16 + + + + 可用的告警: + + + + + + diff --git a/tachometer.cpp b/tachometer.cpp index 2962027..dd98304 100644 --- a/tachometer.cpp +++ b/tachometer.cpp @@ -429,7 +429,7 @@ void Tachometer::Init() { } } ui->comboBox_relative_number->setCurrentIndex(base_ptr->relative_number); - + ui->comboBox_group->setCurrentIndex(base_ptr->group + 1); } void Tachometer::on_pushButton_confirm_clicked() { @@ -454,6 +454,8 @@ void Tachometer::on_pushButton_confirm_clicked() { } } base_ptr->relative_number = ui->comboBox_relative_number->currentIndex(); + base_ptr->group = ui->comboBox_group->currentIndex() + 1; + std::shared_ptr speed_data = std::dynamic_pointer_cast(base_ptr); UpdateData(speed_data); this->close(); diff --git a/tachometer.ui b/tachometer.ui index cf8c71a..04695de 100644 --- a/tachometer.ui +++ b/tachometer.ui @@ -7,7 +7,7 @@ 0 0 835 - 639 + 655 @@ -48,7 +48,7 @@ - + 50 diff --git a/tmrrelayassociation.cpp b/tmrrelayassociation.cpp index 3250ce4..bc38499 100644 --- a/tmrrelayassociation.cpp +++ b/tmrrelayassociation.cpp @@ -406,23 +406,37 @@ void TMRRelayAssociation::OnButtonGroup(QAbstractButton *slot_btn) { list_widget_available->addItem(item_or); for(int var = 0; var < CHANNEL_COUNT ; ++var){ std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id); + std::shared_ptr variable_base = ptr->GetChannelPtr(var + 1); + if(variable_base == nullptr) + continue; if(base_ptr->card_type_ == kCardVibSingle){ QString item_data; - if(ptr->base_config_[var].standby && (var % 2)) - continue; - if(ptr->alert_danger[var].direct_enable || - ptr->alert_danger[var].x1_ampl_enable || - ptr->alert_danger[var].x2_ampl_enable){ - QString item_str = QString("%1 (槽位 %3 通道 %4 警报)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + if(variable_base->alert_high.enable){ + QString item_str = QString("%1 (槽位 %3 通道 %4 警报高)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + QListWidgetItem *item = new QListWidgetItem(item_str); + item_data = QString("S%1C%2A2").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + item->setData(Qt::UserRole, item_data); + list_widget_available->addItem(item); + } + + if(variable_base->danger_high.enable){ + QString item_str = QString("%1 (槽位 %3 通道 %4 危险高)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); QListWidgetItem *item = new QListWidgetItem(item_str); item_data = QString("S%1C%2A1").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); item->setData(Qt::UserRole, item_data); list_widget_available->addItem(item); } - if(ptr->alert_danger[var].danger_enable){ - QString item_str = QString("%1 (槽位 %3 通道 %4 危险)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + if(variable_base->danger_low.enable){ + QString item_str = QString("%1 (槽位 %3 通道 %4 危险低)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); QListWidgetItem *item = new QListWidgetItem(item_str); - item_data = QString("S%1C%2A2").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + item_data = QString("S%1C%2A4").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + item->setData(Qt::UserRole, item_data); + list_widget_available->addItem(item); + } + if(variable_base->alert_low.enable){ + QString item_str = QString("%1 (槽位 %3 通道 %4 警报低)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + QListWidgetItem *item = new QListWidgetItem(item_str); + item_data = QString("S%1C%2A3").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); item->setData(Qt::UserRole, item_data); list_widget_available->addItem(item); } diff --git a/tmrrelayassociation.ui b/tmrrelayassociation.ui index 7679492..b2866e6 100644 --- a/tmrrelayassociation.ui +++ b/tmrrelayassociation.ui @@ -18,7 +18,7 @@ 50 20 - 71 + 111 16 @@ -266,7 +266,7 @@ 30 340 - 71 + 101 16 @@ -957,9 +957,9 @@ - 130 + 150 20 - 54 + 101 21