Compare commits

..

2 Commits

Author SHA1 Message Date
0ec1b26709 修复非OK板卡bug 2026-01-26 16:53:50 +08:00
2c6a047852 添加版本 2026-01-26 14:08:07 +08:00
7 changed files with 75 additions and 26 deletions

View File

@ -566,6 +566,7 @@ int ConfigMgr::Save(QString & file_path) {
qDebug() << "ch" << ch << ptr->single_relay[ch].logic_expression; qDebug() << "ch" << ch << ptr->single_relay[ch].logic_expression;
channel_item.insert("logic_expression", ptr->single_relay[ch].logic_expression); channel_item.insert("logic_expression", ptr->single_relay[ch].logic_expression);
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);
} }
}else if(card_type_[i] == kCardRelayTMRPrimary){ }else if(card_type_[i] == kCardRelayTMRPrimary){

View File

@ -559,6 +559,7 @@ typedef struct SingleRelayS_{
active = false; active = false;
vote = false; vote = false;
count_vote = 0; count_vote = 0;
group = 1;
} }
} SingleRelayS; } SingleRelayS;

View File

@ -122,7 +122,7 @@ MainWindow::MainWindow(QWidget *parent)
//qInstallMessageHandler(messageHandler); //qInstallMessageHandler(messageHandler);
#endif #endif
QDate buildDate = QLocale( QLocale::English ).toDate( QString(__DATE__).replace(" ", " 0"), "MMM dd yyyy"); QDate buildDate = QLocale( QLocale::English ).toDate( QString(__DATE__).replace(" ", " 0"), "MMM dd yyyy");
QString Version = "V1.0_" + buildDate.toString("yyyyMMdd") + "_84da"; QString Version = "V1.0_" + buildDate.toString("yyyyMMdd") + "_546e";
ui->label_version->setText(Version); ui->label_version->setText(Version);
} }

View File

@ -4,6 +4,7 @@
#include <QStack> #include <QStack>
#include <QMessageBox> #include <QMessageBox>
#include <QMenu> #include <QMenu>
#include <QListView>
SingleRelay::SingleRelay(int slot,CardType cardtype,QWidget *parent) SingleRelay::SingleRelay(int slot,CardType cardtype,QWidget *parent)
: QDialog(parent) : QDialog(parent)
@ -12,6 +13,7 @@ SingleRelay::SingleRelay(int slot,CardType cardtype,QWidget *parent)
slot_no = slot; slot_no = slot;
car_type = cardtype; car_type = cardtype;
ui->label_slot_no->setText(QString::number(slot_no)); ui->label_slot_no->setText(QString::number(slot_no));
ui->comboBox_relay_ch->setView(new QListView());
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
QVBoxLayout *layout_available = new QVBoxLayout(ui->widget_available); QVBoxLayout *layout_available = new QVBoxLayout(ui->widget_available);
list_widget_available = new QListWidget(); list_widget_available = new QListWidget();

View File

@ -4,6 +4,7 @@
#include <QStack> #include <QStack>
#include <QMessageBox> #include <QMessageBox>
#include <QMenu> #include <QMenu>
#include <QListView>
SingleRelay_NOK::SingleRelay_NOK(int slot,CardType cardtype,QWidget *parent) : SingleRelay_NOK::SingleRelay_NOK(int slot,CardType cardtype,QWidget *parent) :
QWidget(parent), QWidget(parent),
@ -13,6 +14,9 @@ SingleRelay_NOK::SingleRelay_NOK(int slot,CardType cardtype,QWidget *parent) :
slot_no = slot; slot_no = slot;
car_type = cardtype; car_type = cardtype;
ui->label_slot_no->setText(QString::number(slot_no)); ui->label_slot_no->setText(QString::number(slot_no));
ui->comboBox_relay_ch->setView(new QListView());
ui->comboBox_group->setView(new QListView());
current_slot_btn = nullptr;
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
QVBoxLayout *layout_available = new QVBoxLayout(ui->widget_available); QVBoxLayout *layout_available = new QVBoxLayout(ui->widget_available);
list_widget_available = new QListWidget(); list_widget_available = new QListWidget();
@ -182,39 +186,74 @@ void SingleRelay_NOK::on_pushButton_cancel_clicked()
{ {
this->close(); this->close();
} }
void SingleRelay_NOK::OnButtonGroup(QAbstractButton *slot_btn) { void SingleRelay_NOK::updateAvailable(QAbstractButton *slot_btn){
if (slot_btn != NULL) { list_widget_available->clear();
list_widget_available->clear(); QString object_name = slot_btn->objectName();
QString object_name = slot_btn->objectName(); qDebug() << object_name ;
qDebug() << object_name ; int button_id = object_name.right(object_name.length() - 15).toInt();
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<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id);
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr); std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(var + 1);
if(ptr == nullptr) if(variable_base == nullptr)
return; continue;
QListWidgetItem *item_and = new QListWidgetItem("AND"); if(base_ptr->card_type_ == kCardVibSingle){
item_and->setData(Qt::UserRole, "*"); 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'));
list_widget_available->addItem(item_and); 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);
QListWidgetItem *item_or = new QListWidgetItem("OR"); QString item_data;
item_or->setData(Qt::UserRole, "+"); if(variable_base->alert_high.enable && (ui->comboBox_relay_ch->currentIndex() == 10 || ui->comboBox_relay_ch->currentIndex() == 11)){
list_widget_available->addItem(item_or); 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'));
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_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); 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_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_nok); item->setData(Qt::UserRole, item_data);
list_widget_available->addItem(item);
}
if(variable_base->danger_high.enable && (ui->comboBox_relay_ch->currentIndex() == 10 || ui->comboBox_relay_ch->currentIndex() == 11)){
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 && (ui->comboBox_relay_ch->currentIndex() == 10 || ui->comboBox_relay_ch->currentIndex() == 11)){
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 && (ui->comboBox_relay_ch->currentIndex() == 10 || ui->comboBox_relay_ch->currentIndex() == 11)){
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); list_widget_available->addItem(item);
} }
} }
} }
} }
void SingleRelay_NOK::OnButtonGroup(QAbstractButton *slot_btn) {
if (slot_btn != NULL) {
current_slot_btn = slot_btn;
updateAvailable(slot_btn);
}
}
QString SingleRelay_NOK::buildLogicExpression(QStandardItem *item) { QString SingleRelay_NOK::buildLogicExpression(QStandardItem *item) {
if (!item) return ""; if (!item) return "";
@ -277,6 +316,8 @@ void SingleRelay_NOK::onComboBoxIndexChanged(int index){
qDebug() << "active" << relay_data->single_relay[index].active; qDebug() << "active" << relay_data->single_relay[index].active;
ui->checkBox_active->setChecked(relay_data->single_relay[index].active); ui->checkBox_active->setChecked(relay_data->single_relay[index].active);
if(current_slot_btn != nullptr)
updateAvailable(current_slot_btn);
} }
ExprNode* SingleRelay_NOK::parseExpression(const QString& expr, int& pos) { ExprNode* SingleRelay_NOK::parseExpression(const QString& expr, int& pos) {
auto skipSpaces = [&]() { auto skipSpaces = [&]() {

View File

@ -50,6 +50,7 @@ private:
int current_index; int current_index;
int vote_current_index; int vote_current_index;
QMap<QString, QString> channelNameMap; QMap<QString, QString> channelNameMap;
QAbstractButton *current_slot_btn;
void Init(); void Init();
void buildTreeFromExpression(QTreeView *treeView, const QString &expr); void buildTreeFromExpression(QTreeView *treeView, const QString &expr);
@ -58,6 +59,7 @@ private:
void setExpressionToTreeView(QTreeView* treeView, const QString& expr); void setExpressionToTreeView(QTreeView* treeView, const QString& expr);
QString buildLogicExpression(QStandardItem *item); QString buildLogicExpression(QStandardItem *item);
ExprValidationResult validateLogicExpression(const QString& expr); ExprValidationResult validateLogicExpression(const QString& expr);
void updateAvailable(QAbstractButton *slot_btn);
}; };
#endif // SINGLERELAY_NOK_H #endif // SINGLERELAY_NOK_H

View File

@ -4,6 +4,7 @@
#include <QStack> #include <QStack>
#include <QMenu> #include <QMenu>
#include <QMessageBox> #include <QMessageBox>
#include <QListView>
TMRRelayAssociation::TMRRelayAssociation(int slot,CardType cardtype,QWidget *parent) TMRRelayAssociation::TMRRelayAssociation(int slot,CardType cardtype,QWidget *parent)
: QDialog(parent) : QDialog(parent)
@ -16,6 +17,7 @@ TMRRelayAssociation::TMRRelayAssociation(int slot,CardType cardtype,QWidget *par
ui->checkBox_sgcc->setVisible(0); ui->checkBox_sgcc->setVisible(0);
} }
ui->label_slot_no->setText(QString::number(slot_no)); ui->label_slot_no->setText(QString::number(slot_no));
ui->comboBox_relay_ch->setView(new QListView());
QVBoxLayout *layout_available = new QVBoxLayout(ui->widget_available); QVBoxLayout *layout_available = new QVBoxLayout(ui->widget_available);
list_widget_available = new QListWidget(); list_widget_available = new QListWidget();
layout_available->addWidget(list_widget_available); layout_available->addWidget(list_widget_available);