From 033bb1c02d1c739004de1efe8d4f32d4c1af7052 Mon Sep 17 00:00:00 2001 From: zhangsheng Date: Thu, 9 Apr 2026 11:00:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BD=AC=E9=80=9F=E8=AD=A6?= =?UTF-8?q?=E6=8A=A5=E5=BB=B6=E6=97=B6=E5=B0=8F=E6=95=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config_mgr.cpp | 4 ++-- mainwindow.cpp | 19 +++++++++++++++++-- mainwindow.h | 1 + 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/config_mgr.cpp b/config_mgr.cpp index b23843d..738f259 100644 --- a/config_mgr.cpp +++ b/config_mgr.cpp @@ -1087,12 +1087,12 @@ void ConfigMgr::Load(QString filename) { QJsonObject alarm = channel["alarm"].toObject(); speed_data->danger_high[j].level = alarm["danger_high_level"].toDouble(); speed_data->danger_high[j].hysteresis = alarm["danger_high_hysteresis"].toDouble(); - speed_data->danger_high[j].delay = alarm["danger_high_delay"].toInt(); + speed_data->danger_high[j].delay = alarm["danger_high_delay"].toDouble(); speed_data->danger_high[j].enable = alarm["danger_high_enable"].toBool(); speed_data->danger_high[j].latch = alarm["danger_high_latch"].toBool(); speed_data->alert_high[j].level = alarm["alert_high_level"].toDouble(); speed_data->alert_high[j].hysteresis = alarm["alert_high_hysteresis"].toDouble(); - speed_data->alert_high[j].delay = alarm["alert_high_delay"].toInt(); + speed_data->alert_high[j].delay = alarm["alert_high_delay"].toDouble(); speed_data->alert_high[j].enable = alarm["alert_high_enable"].toBool(); speed_data->alert_high[j].latch = alarm["alert_high_latch"].toBool(); } diff --git a/mainwindow.cpp b/mainwindow.cpp index 959ec62..ac3ae4c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -240,6 +240,8 @@ void MainWindow::createMenu(const QString &rootTitle, QPushButton *parent) { QAction *get_sub_card_voltage = mainMenu->addAction("获取电压范围"); QAction *get_vib_version = mainMenu->addAction("获取振动板卡辅助程序版本"); QAction *get_card_processID = mainMenu->addAction("获取进程号"); + mainMenu->addSeparator(); + QAction *vib_relay = mainMenu->addAction("继电器配置"); // 绑定 **鼠标事件过滤器**,确保只响应右键 // 设置右键菜单策略 @@ -271,6 +273,7 @@ void MainWindow::createMenu(const QString &rootTitle, QPushButton *parent) { QObject::connect(copy_sub_card, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); QObject::connect(move_sub_card, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); QObject::connect(high_speed_current, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); + QObject::connect(vib_relay, &QAction::triggered, this, &MainWindow::onMenuActionTriggered); } void MainWindow::createMenuSet(const QString &rootTitle, QPushButton *parent) { @@ -467,8 +470,8 @@ void MainWindow::onMenuActionTriggered() { GetCardProcessID(button_id); }else if(action->text() == "复制板卡配置"){ CopySubCard(button_id); - }else if(action->text() == "移动板卡配置"){ - MoveSubCard(button_id); + }else if(action->text() == "继电器配置"){ + VibRealy(button_id); } break; // 找到按钮后,跳出循环 } @@ -1117,6 +1120,18 @@ void MainWindow::MoveSubCard(int slot){ } } } +void MainWindow::VibRealy(int slot){ + slot_no = slot; + std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); + if(base_ptr != nullptr){ + QMessageBox::warning(this, QStringLiteral("警告"), QStringLiteral("当前板卡为空板卡!")); + return ; + } + if(base_ptr->card_type_ != kCardVibSingle){ + QMessageBox::warning(this, QStringLiteral("警告"), QStringLiteral("请选择振动板卡进行配置!")); + return ; + } +} void MainWindow::readData(const QByteArray &data) { qDebug() << "Received from server:" << data; diff --git a/mainwindow.h b/mainwindow.h index 53583d6..f8647f3 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -68,6 +68,7 @@ private: void GetCardProcessID(int slot); void CopySubCard(int slot); void MoveSubCard(int slot); + void VibRealy(int slot); private slots: