添加继电器三冗余和非OK板卡配置
This commit is contained in:
parent
108ac397b6
commit
a264bffb15
@ -36,6 +36,7 @@ SOURCES += \
|
|||||||
setpoint_tachometer.cpp \
|
setpoint_tachometer.cpp \
|
||||||
singlerelay.cpp \
|
singlerelay.cpp \
|
||||||
singlerelay_data.cpp \
|
singlerelay_data.cpp \
|
||||||
|
singlerelay_nok.cpp \
|
||||||
tachometer.cpp \
|
tachometer.cpp \
|
||||||
tachometer_data.cpp \
|
tachometer_data.cpp \
|
||||||
tmrrelayassociation.cpp \
|
tmrrelayassociation.cpp \
|
||||||
@ -74,6 +75,7 @@ HEADERS += \
|
|||||||
setpoint_tachometer.h \
|
setpoint_tachometer.h \
|
||||||
singlerelay.h \
|
singlerelay.h \
|
||||||
singlerelay_data.h \
|
singlerelay_data.h \
|
||||||
|
singlerelay_nok.h \
|
||||||
tachometer.h \
|
tachometer.h \
|
||||||
tachometer_data.h \
|
tachometer_data.h \
|
||||||
tmrrelayassociation.h \
|
tmrrelayassociation.h \
|
||||||
@ -104,6 +106,7 @@ FORMS += \
|
|||||||
seismic_monitor.ui \
|
seismic_monitor.ui \
|
||||||
setpoint_tachometer.ui \
|
setpoint_tachometer.ui \
|
||||||
singlerelay.ui \
|
singlerelay.ui \
|
||||||
|
singlerelay_nok.ui \
|
||||||
tachometer.ui \
|
tachometer.ui \
|
||||||
tmrrelayassociation.ui \
|
tmrrelayassociation.ui \
|
||||||
trust.ui \
|
trust.ui \
|
||||||
|
|||||||
@ -15,6 +15,7 @@ class CardBase {
|
|||||||
int slot_; // 从1~15
|
int slot_; // 从1~15
|
||||||
CardType card_type_;
|
CardType card_type_;
|
||||||
int relative_number;
|
int relative_number;
|
||||||
|
int group;
|
||||||
};
|
};
|
||||||
|
|
||||||
class VariableBase {
|
class VariableBase {
|
||||||
|
|||||||
@ -568,6 +568,7 @@ void ConfigMgr::Save(QString & file_path) {
|
|||||||
}
|
}
|
||||||
slot_item["version"] = 1;
|
slot_item["version"] = 1;
|
||||||
slot_item["relative_number"] = base_ptr->relative_number;
|
slot_item["relative_number"] = base_ptr->relative_number;
|
||||||
|
slot_item["group"] = base_ptr->group;
|
||||||
}else{
|
}else{
|
||||||
for(int ch = 0;ch < RELAY_COUNT;++ch){
|
for(int ch = 0;ch < RELAY_COUNT;++ch){
|
||||||
QJsonObject channel_item;
|
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("vote",ptr->single_relay[ch].vote);
|
||||||
channel_item.insert("active", ptr->single_relay[ch].active);
|
channel_item.insert("active", ptr->single_relay[ch].active);
|
||||||
channel_item.insert("group",ptr->single_relay[ch].group);
|
channel_item.insert("group",ptr->single_relay[ch].group);
|
||||||
|
}else if(card_type_[i] == kCardRelayTMRPrimary){
|
||||||
|
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
|
||||||
|
if (base_ptr == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
std::shared_ptr<TmrrelayassociationData> ptr = std::dynamic_pointer_cast<TmrrelayassociationData>(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;
|
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();
|
singlerelay_data->single_relay[j].group = channel["group"].toInt();
|
||||||
}
|
}
|
||||||
cards_.push_back(singlerelay_data);
|
cards_.push_back(singlerelay_data);
|
||||||
|
}else if(card_type_[i] == kCardRelayTMRPrimary){
|
||||||
|
std::shared_ptr<TmrrelayassociationData> relay_data = std::make_shared<TmrrelayassociationData>();
|
||||||
|
relay_data->slot_ = slot;
|
||||||
|
relay_data->card_type_ = static_cast<CardType>(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<TmrrelayassociationData> relay_data = std::make_shared<TmrrelayassociationData>();
|
||||||
|
relay_data->slot_ = slot;
|
||||||
|
relay_data->card_type_ = static_cast<CardType>(card_type_[i]);
|
||||||
|
cards_.push_back(relay_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -503,6 +503,20 @@ typedef struct SpeedAlert_{
|
|||||||
}
|
}
|
||||||
} 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_{
|
typedef struct SingleRelayNOK_{
|
||||||
QString logic_expression;
|
QString logic_expression;
|
||||||
bool active;
|
bool active;
|
||||||
|
|||||||
@ -197,6 +197,7 @@ void KeyPhase::Init() {
|
|||||||
ui->spinBox_events_per_revolution_4->setValue(keyphase_data->variables_[i].events_per_revolution);
|
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() {
|
void KeyPhase::on_pushButton_confirm_clicked() {
|
||||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||||
@ -204,6 +205,7 @@ void KeyPhase::on_pushButton_confirm_clicked() {
|
|||||||
qCritical() << " should not be here";
|
qCritical() << " should not be here";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
base_ptr->group = ui->comboBox_group->currentIndex() + 1;
|
||||||
std::shared_ptr<KeyphaseData> keyphase_data = std::dynamic_pointer_cast<KeyphaseData>(base_ptr);
|
std::shared_ptr<KeyphaseData> keyphase_data = std::dynamic_pointer_cast<KeyphaseData>(base_ptr);
|
||||||
UpdateData(keyphase_data);
|
UpdateData(keyphase_data);
|
||||||
this->close();
|
this->close();
|
||||||
|
|||||||
@ -81,7 +81,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="comboBox_3">
|
<widget class="QComboBox" name="comboBox_group">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>50</width>
|
<width>50</width>
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include "dc_outputs.h"
|
#include "dc_outputs.h"
|
||||||
#include "mqtt_config.h"
|
#include "mqtt_config.h"
|
||||||
|
#include "singlerelay_nok.h"
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
|
||||||
QString g_strServerIp;
|
QString g_strServerIp;
|
||||||
@ -195,10 +196,10 @@ void MainWindow::createMenu(const QString &rootTitle, QPushButton *parent) {
|
|||||||
// 创建第二层子菜单:/DOM810 继电器模块
|
// 创建第二层子菜单:/DOM810 继电器模块
|
||||||
QAction *relays_1 = relays->addAction("/DOM810 单板卡");
|
QAction *relays_1 = relays->addAction("/DOM810 单板卡");
|
||||||
relays_1->setData(kCardRelaySingle);
|
relays_1->setData(kCardRelaySingle);
|
||||||
// QAction *relays_2 = relays->addAction("/DOM810 单板卡-非OK");
|
QAction *relays_2 = relays->addAction("/DOM810 单板卡-非OK");
|
||||||
// relays_2->setData(kCardRelaySingleNOK);
|
relays_2->setData(kCardRelaySingleNOK);
|
||||||
// QAction *relays_3 = relays->addAction("/DOM810 三冗余板卡");
|
QAction *relays_3 = relays->addAction("/DOM810 三冗余板卡");
|
||||||
// relays_3->setData(kCardRelayTMRPrimary);
|
relays_3->setData(kCardRelayTMRPrimary);
|
||||||
// 将子菜单加入上一级菜单
|
// 将子菜单加入上一级菜单
|
||||||
monitors->addMenu(proximitor_menu); // 将第二层加入第一层
|
monitors->addMenu(proximitor_menu); // 将第二层加入第一层
|
||||||
monitors->addMenu(rpm_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(proximitor_2, &QAction::triggered, this, &MainWindow::onMenuActionTriggered);
|
||||||
QObject::connect(rpm_1, &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_1, &QAction::triggered, this, &MainWindow::onMenuActionTriggered);
|
||||||
//QObject::connect(relays_2, &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_3, &QAction::triggered, this, &MainWindow::onMenuActionTriggered);
|
||||||
QObject::connect(keyphasor_1, &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(keyphasor_2, &QAction::triggered, this, &MainWindow::onMenuActionTriggered);
|
||||||
QObject::connect(reset, &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();
|
qDebug() << "子菜单项被点击,所属按钮:" << button->objectName() << action->text();
|
||||||
QString slot_type = action->text().mid(1, 6);
|
QString slot_type = action->text().mid(1, 6);
|
||||||
QString rack_type = action->text().right(action->text().length() - 8);
|
QString rack_type = action->text().right(action->text().length() - 8);
|
||||||
qDebug() << "rack_type" << action->data();
|
|
||||||
card_type = static_cast<CardType>(action->data().toInt());
|
card_type = static_cast<CardType>(action->data().toInt());
|
||||||
|
qDebug() << "rack_type" << action->data() << "card type" << card_type;
|
||||||
int button_id = button->objectName().right(button->objectName().length() - 15).toInt();
|
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 ;
|
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}");
|
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) {
|
void MainWindow::OnButtonGroup(QAbstractButton *slot_btn) {
|
||||||
if (slot_btn != NULL && ui->pushButton_chan->isChecked()) {
|
if (slot_btn != NULL && ui->pushButton_chan->isChecked()) {
|
||||||
QString object_name = slot_btn->objectName();
|
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();
|
int button_id = object_name.right(object_name.length() - 15).toInt();
|
||||||
SlotConfig slot_config = map_slot_config[button_id];
|
SlotConfig slot_config = map_slot_config[button_id];
|
||||||
map_slot_config[button_id].slot_label->setStyleSheet("QLabel { color :#2980b9; font: bold 16px}");
|
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();
|
key_phase->show();
|
||||||
} else if (slot_config.slot_type == "DOM810") { // 继电器模块
|
} else if (slot_config.slot_type == "DOM810") { // 继电器模块
|
||||||
switch (card_type) {
|
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:{
|
case kCardRelaySingle:{
|
||||||
SingleRelay *single_relay = new SingleRelay(button_id,card_type);
|
SingleRelay *single_relay = new SingleRelay(button_id,card_type);
|
||||||
single_relay->setWindowModality(Qt::ApplicationModal);
|
single_relay->setWindowModality(Qt::ApplicationModal);
|
||||||
single_relay->show();
|
single_relay->show();
|
||||||
}break;
|
}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") { // 振动模块
|
} else if (slot_config.slot_type == "HAM824") { // 振动模块
|
||||||
@ -455,6 +466,7 @@ void MainWindow::OnButtonGroup(QAbstractButton *slot_btn) {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
qDebug() << "base_ptr->card_type_" << base_ptr->card_type_;
|
||||||
switch(base_ptr->card_type_){
|
switch(base_ptr->card_type_){
|
||||||
case kCardVibSingle:{
|
case kCardVibSingle:{
|
||||||
Seismic_monitor *seismic_monitor = new Seismic_monitor(button_id,card_type);
|
Seismic_monitor *seismic_monitor = new Seismic_monitor(button_id,card_type);
|
||||||
@ -480,6 +492,11 @@ void MainWindow::OnButtonGroup(QAbstractButton *slot_btn) {
|
|||||||
single_relay->show();
|
single_relay->show();
|
||||||
break;
|
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()) {
|
if (slot_btn != NULL && ui->pushButton_alarm->isChecked()) {
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
#include "channel_3_4.h"
|
#include "channel_3_4.h"
|
||||||
#include "copy_channel.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),
|
QWidget(parent),
|
||||||
ui(new Ui::Seismic_monitor) {
|
ui(new Ui::Seismic_monitor) {
|
||||||
ui->setupUi(this);
|
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());
|
ui->comboBox_chan_type_4->setView(new QListView());
|
||||||
|
|
||||||
slot_no = slot;
|
slot_no = slot;
|
||||||
car_type = static_cast<CardType>(cardtype);
|
car_type = cardtype;
|
||||||
QString slot_no_ = QString("%1").arg(slot_no);
|
QString slot_no_ = QString("%1").arg(slot_no);
|
||||||
ui->label_slot_no->setText(slot_no_);
|
ui->label_slot_no->setText(slot_no_);
|
||||||
Init();
|
Init();
|
||||||
@ -49,6 +49,7 @@ void Seismic_monitor::Init() {
|
|||||||
std::shared_ptr<VibrationData> vib_data = std::make_shared<VibrationData>();
|
std::shared_ptr<VibrationData> vib_data = std::make_shared<VibrationData>();
|
||||||
vib_data->slot_ = slot_no;
|
vib_data->slot_ = slot_no;
|
||||||
vib_data->card_type_ = car_type;
|
vib_data->card_type_ = car_type;
|
||||||
|
qDebug() << "card type" << vib_data->card_type_;
|
||||||
ConfigMgr::Instance()->AddCard(vib_data);
|
ConfigMgr::Instance()->AddCard(vib_data);
|
||||||
UpdateData(vib_data);
|
UpdateData(vib_data);
|
||||||
return;
|
return;
|
||||||
@ -114,6 +115,7 @@ void Seismic_monitor::Init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui->comboBox_relative_number->setCurrentIndex(base_ptr->relative_number);
|
ui->comboBox_relative_number->setCurrentIndex(base_ptr->relative_number);
|
||||||
|
ui->comboBox_group->setCurrentIndex(base_ptr->group + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Seismic_monitor::UpdateData(std::shared_ptr<VibrationData> vib_data) {
|
void Seismic_monitor::UpdateData(std::shared_ptr<VibrationData> vib_data) {
|
||||||
@ -226,8 +228,10 @@ void Seismic_monitor::on_pushButton_confirm_clicked() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
base_ptr->relative_number = ui->comboBox_relative_number->currentIndex();
|
base_ptr->relative_number = ui->comboBox_relative_number->currentIndex();
|
||||||
|
base_ptr->group = ui->comboBox_group->currentIndex() + 1;
|
||||||
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
std::shared_ptr<VibrationData> vib_data = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||||
UpdateData(vib_data);
|
UpdateData(vib_data);
|
||||||
|
qDebug() <<"type" << base_ptr->card_type_;
|
||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,21 +426,6 @@ void Seismic_monitor::on_pushButton_cancel_clicked() {
|
|||||||
this->close();
|
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(){
|
void Seismic_monitor::EnableKeyphase(){
|
||||||
ui->checkBox_keyphase->setCheckable(true);
|
ui->checkBox_keyphase->setCheckable(true);
|
||||||
ui->checkBox_keyphase->setEnabled(true);
|
ui->checkBox_keyphase->setEnabled(true);
|
||||||
|
|||||||
@ -13,7 +13,7 @@ class Seismic_monitor : public QWidget {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Seismic_monitor(int slot,int cardtype, QWidget *parent = nullptr);
|
explicit Seismic_monitor(int slot,CardType cardtype, QWidget *parent = nullptr);
|
||||||
~Seismic_monitor();
|
~Seismic_monitor();
|
||||||
int slot_no;
|
int slot_no;
|
||||||
int channel;
|
int channel;
|
||||||
@ -41,14 +41,6 @@ class Seismic_monitor : public QWidget {
|
|||||||
|
|
||||||
void on_pushButton_cancel_clicked();
|
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_1_currentTextChanged(const QString &arg1);
|
||||||
|
|
||||||
void on_comboBox_sensitivity_unit_2_currentTextChanged(const QString &arg1);
|
void on_comboBox_sensitivity_unit_2_currentTextChanged(const QString &arg1);
|
||||||
|
|||||||
@ -75,7 +75,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="comboBox_3">
|
<widget class="QComboBox" name="comboBox_group">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>50</width>
|
<width>50</width>
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
class SingleRelayData : public CardBase {
|
class SingleRelayData : public CardBase {
|
||||||
public:
|
public:
|
||||||
SingleRelayData();
|
SingleRelayData();
|
||||||
SingleRelayNOK single_relay[RELAY_COUNT];
|
SingleRelayS single_relay[RELAY_COUNT];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SINGLERELAY_DATA_H
|
#endif // SINGLERELAY_DATA_H
|
||||||
|
|||||||
527
singlerelay_nok.cpp
Normal file
527
singlerelay_nok.cpp
Normal file
@ -0,0 +1,527 @@
|
|||||||
|
#include "singlerelay_nok.h"
|
||||||
|
#include "ui_singlerelay_nok.h"
|
||||||
|
#include "vibrationdata.h"
|
||||||
|
#include <QStack>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
|
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>(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<int>::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<QAbstractButton *> buttonList = btnGroup_slot->buttons();
|
||||||
|
for (int i = 1; i < buttonList.count() + 1; i++) {
|
||||||
|
std::shared_ptr<CardBase> 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<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||||
|
if (base_ptr == nullptr) {
|
||||||
|
// do nothing or use template to init it.
|
||||||
|
relay_data = std::make_shared<SingleRelayData>();
|
||||||
|
relay_data->card_type_ = car_type;
|
||||||
|
relay_data->slot_ = slot_no;
|
||||||
|
ConfigMgr::Instance()->AddCard(relay_data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
relay_data = std::dynamic_pointer_cast<SingleRelayData>(base_ptr);
|
||||||
|
|
||||||
|
qDebug() << "logic" <<relay_data->single_relay[current_index].logic_expression;
|
||||||
|
qDebug() << "active" <<relay_data->single_relay[current_index].active << "index" << current_index;
|
||||||
|
|
||||||
|
for(int i = 0 ; i < SLOT_NUM ; i++){
|
||||||
|
std::shared_ptr<CardBase> cardbase_ptr = ConfigMgr::Instance()->GetSlotPtr(i + 1);
|
||||||
|
if(cardbase_ptr != nullptr &&
|
||||||
|
cardbase_ptr->card_type_ == kCardVibSingle){
|
||||||
|
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(cardbase_ptr);
|
||||||
|
for (int var = 0; var < CHANNEL_COUNT; ++var) {
|
||||||
|
std::shared_ptr<VariableBase> 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<<variable_base->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<QStandardItemModel *>(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<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id);
|
||||||
|
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(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<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id);
|
||||||
|
std::shared_ptr<VariableBase> 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<QStandardItemModel *>(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<ExprNode*> nodeStack;
|
||||||
|
QStack<QString> 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" <<displayText << node->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" <<endl;
|
||||||
|
QModelIndex curIndex = treeView_relay->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<QStandardItemModel *>(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
65
singlerelay_nok.h
Normal file
65
singlerelay_nok.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
#ifndef SINGLERELAY_NOK_H
|
||||||
|
#define SINGLERELAY_NOK_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QTextEdit>
|
||||||
|
#include <QButtonGroup>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include "data_config.h"
|
||||||
|
#include "config_mgr.h"
|
||||||
|
#include "singlerelay_data.h"
|
||||||
|
#include <QStandardItemModel> //数据模型类
|
||||||
|
#include <QTreeView>
|
||||||
|
|
||||||
|
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<SingleRelayData> relay_data = nullptr;
|
||||||
|
int current_index;
|
||||||
|
int vote_current_index;
|
||||||
|
QMap<QString, QString> 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
|
||||||
1140
singlerelay_nok.ui
Normal file
1140
singlerelay_nok.ui
Normal file
File diff suppressed because it is too large
Load Diff
@ -429,7 +429,7 @@ void Tachometer::Init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui->comboBox_relative_number->setCurrentIndex(base_ptr->relative_number);
|
ui->comboBox_relative_number->setCurrentIndex(base_ptr->relative_number);
|
||||||
|
ui->comboBox_group->setCurrentIndex(base_ptr->group + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tachometer::on_pushButton_confirm_clicked() {
|
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->relative_number = ui->comboBox_relative_number->currentIndex();
|
||||||
|
base_ptr->group = ui->comboBox_group->currentIndex() + 1;
|
||||||
|
|
||||||
std::shared_ptr<TachometerData> speed_data = std::dynamic_pointer_cast<TachometerData>(base_ptr);
|
std::shared_ptr<TachometerData> speed_data = std::dynamic_pointer_cast<TachometerData>(base_ptr);
|
||||||
UpdateData(speed_data);
|
UpdateData(speed_data);
|
||||||
this->close();
|
this->close();
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>835</width>
|
<width>835</width>
|
||||||
<height>639</height>
|
<height>655</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -48,7 +48,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="comboBox_3">
|
<widget class="QComboBox" name="comboBox_group">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>50</width>
|
<width>50</width>
|
||||||
|
|||||||
@ -406,23 +406,37 @@ void TMRRelayAssociation::OnButtonGroup(QAbstractButton *slot_btn) {
|
|||||||
list_widget_available->addItem(item_or);
|
list_widget_available->addItem(item_or);
|
||||||
for(int var = 0; var < CHANNEL_COUNT ; ++var){
|
for(int var = 0; var < CHANNEL_COUNT ; ++var){
|
||||||
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id);
|
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id);
|
||||||
|
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(var + 1);
|
||||||
|
if(variable_base == nullptr)
|
||||||
|
continue;
|
||||||
if(base_ptr->card_type_ == kCardVibSingle){
|
if(base_ptr->card_type_ == kCardVibSingle){
|
||||||
QString item_data;
|
QString item_data;
|
||||||
if(ptr->base_config_[var].standby && (var % 2))
|
if(variable_base->alert_high.enable){
|
||||||
continue;
|
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(ptr->alert_danger[var].direct_enable ||
|
QListWidgetItem *item = new QListWidgetItem(item_str);
|
||||||
ptr->alert_danger[var].x1_ampl_enable ||
|
item_data = QString("S%1C%2A2").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0'));
|
||||||
ptr->alert_danger[var].x2_ampl_enable){
|
item->setData(Qt::UserRole, item_data);
|
||||||
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'));
|
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);
|
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_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);
|
item->setData(Qt::UserRole, item_data);
|
||||||
list_widget_available->addItem(item);
|
list_widget_available->addItem(item);
|
||||||
}
|
}
|
||||||
if(ptr->alert_danger[var].danger_enable){
|
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'));
|
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);
|
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);
|
item->setData(Qt::UserRole, item_data);
|
||||||
list_widget_available->addItem(item);
|
list_widget_available->addItem(item);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>50</x>
|
<x>50</x>
|
||||||
<y>20</y>
|
<y>20</y>
|
||||||
<width>71</width>
|
<width>111</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -266,7 +266,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>30</x>
|
<x>30</x>
|
||||||
<y>340</y>
|
<y>340</y>
|
||||||
<width>71</width>
|
<width>101</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -957,9 +957,9 @@
|
|||||||
<widget class="QLabel" name="label_slot_no">
|
<widget class="QLabel" name="label_slot_no">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>130</x>
|
<x>150</x>
|
||||||
<y>20</y>
|
<y>20</y>
|
||||||
<width>54</width>
|
<width>101</width>
|
||||||
<height>21</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user