From ac94c601513282cd798f61302ea41f5d14986b38 Mon Sep 17 00:00:00 2001 From: zhangsheng Date: Mon, 14 Apr 2025 20:30:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TSI_Config.pro | 2 + config_mgr.cpp | 12 +- mainwindow.cpp | 2 +- radial_vibration.cpp | 2 +- relaysetting.cpp | 14 +- setpoint.cpp | 56 +++++ setpoint.ui | 527 +++++++++++++++++++++++++------------------ 7 files changed, 382 insertions(+), 233 deletions(-) diff --git a/TSI_Config.pro b/TSI_Config.pro index 28c34e0..ef70588 100644 --- a/TSI_Config.pro +++ b/TSI_Config.pro @@ -19,6 +19,7 @@ SOURCES += \ main.cpp \ mainwindow.cpp \ radial_vibration.cpp \ + rangeslider.cpp \ relaysetting.cpp \ seismic_monitor.cpp \ setpoint.cpp \ @@ -41,6 +42,7 @@ HEADERS += \ keyphase_data.h \ mainwindow.h \ radial_vibration.h \ + rangeslider.h \ relaysetting.h \ seismic_monitor.h \ setpoint.h \ diff --git a/config_mgr.cpp b/config_mgr.cpp index 84bb2c7..63bf5c0 100644 --- a/config_mgr.cpp +++ b/config_mgr.cpp @@ -72,6 +72,9 @@ void ConfigMgr::Save() { } if (base_channel_ptr->type_ == kVibRadial) { std::shared_ptr radial_ptr = std::dynamic_pointer_cast(base_channel_ptr); + if(radial_ptr == nullptr){ + continue; + } // filter QJsonArray filter; QJsonObject low_pass; @@ -89,7 +92,7 @@ void ConfigMgr::Save() { band_pass["high"] = radial_ptr->filter_[2].high; band_pass["checked"] = radial_ptr->filter_[2].checked; filter.append(band_pass); - channel_item["filter"] = filter; + variables["filter"] = filter; QJsonObject direct; QJsonObject x1; QJsonObject x2; @@ -139,6 +142,9 @@ void ConfigMgr::Save() { variables["latching"] = latching; } else { std::shared_ptr av_ptr = std::dynamic_pointer_cast(base_channel_ptr); + if(av_ptr == nullptr){ + continue; + } // filter QJsonArray filter; QJsonObject low_pass; @@ -156,7 +162,7 @@ void ConfigMgr::Save() { band_pass["high"] = av_ptr->filter_[2].high; band_pass["checked"] = av_ptr->filter_[2].checked; filter.append(band_pass); - channel_item["filter"] = filter; + variables["filter"] = filter; QJsonObject direct; QJsonObject x1; QJsonObject x2; @@ -324,7 +330,7 @@ void ConfigMgr::Load(QString filename) { case kVibRadial: { std::shared_ptr variable = std::make_shared(); // filter - QJsonArray filter_array = channel["filter"].toArray(); + QJsonArray filter_array = tmp_variable["filter"].toArray(); for (int k = 0; k < filter_array.size(); k++) { QJsonObject filter_ele = filter_array[k].toObject(); variable->filter_[k].low = filter_ele["low"].toInt(); diff --git a/mainwindow.cpp b/mainwindow.cpp index d6dd5ed..0b9e205 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -87,7 +87,7 @@ MainWindow::MainWindow(QWidget *parent) connect(btnGroup_slot, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(OnButtonGroup(QAbstractButton *))); QSettings settingsread(QCoreApplication::applicationDirPath() + "\\config\\config.ini", QSettings::IniFormat); g_strServerIp = settingsread.value("Server/IP").toString(); - connectServer(); + //connectServer(); // 设置自定义日志处理函数 #ifndef QT_DEBUG qInstallMessageHandler(messageHandler); diff --git a/radial_vibration.cpp b/radial_vibration.cpp index c8387be..9c5a1f3 100644 --- a/radial_vibration.cpp +++ b/radial_vibration.cpp @@ -142,7 +142,7 @@ void Radial::Init() { void Radial::on_pushButton_confirm_clicked() { std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); if (base_ptr == nullptr) { - qCritical() << "[Acceleration::Init] should not be here"; + qCritical() << "[Radial::Init] should not be here"; return; } std::shared_ptr ptr = std::dynamic_pointer_cast(base_ptr); diff --git a/relaysetting.cpp b/relaysetting.cpp index da499d5..11c6c6b 100644 --- a/relaysetting.cpp +++ b/relaysetting.cpp @@ -115,7 +115,7 @@ void RelaySetting::onRadioButtonClicked(QAbstractButton *button) { } PackageHead header = { {0xAA, 0x55, 0xAA}, kRelaySetting, sizeof(RelaySettingReq), 0, {} }; int slot = ui->comboBox_slot->currentText().toInt(); - qDebug() << "slot" << slot << endl; + qDebug() << "slot" << slot ; RelaySettingReq relay_setting_req; if (slot == 0) { relay_setting_req.card_id = 0xFF; @@ -123,7 +123,7 @@ void RelaySetting::onRadioButtonClicked(QAbstractButton *button) { relay_setting_req.card_id = slot & 0xFF; } QString led_id = group->objectName().mid(12); - qDebug() << "led_id" << led_id << endl; + qDebug() << "led_id" << led_id ; if (led_id == "OK") { relay_setting_req.led_id = 0xff; } else if (led_id == "TX_RX") { @@ -168,9 +168,9 @@ void RelaySetting::onRadioButtonClicked(QAbstractButton *button) { PackageHead header; RelaySettingRsp relay_setting_rsp; memcpy(&header, response.data(), sizeof(PackageHead)); - qDebug() << "header len" << header.len << endl; + qDebug() << "header len" << header.len ; memcpy(&relay_setting_rsp, response.data() + sizeof(PackageHead), sizeof(RelaySettingRsp)); - qDebug() << "relay_setting_rsp code" << relay_setting_rsp.code << endl; + qDebug() << "relay_setting_rsp code" << relay_setting_rsp.code ; } } @@ -184,7 +184,7 @@ void RelaySetting::on_pushButton_status_clicked() { } PackageHead header = { {0xAA, 0x55, 0xAA}, kRelayStatus, sizeof(RelaySettingReq), 0, {} }; int slot = ui->comboBox_slot->currentText().toInt(); - qDebug() << "slot" << slot << endl; + qDebug() << "slot" << slot ; RelayStatusReq relay_status_req; if (slot == 0) { relay_status_req.card_id = 0xFF; @@ -202,9 +202,9 @@ void RelaySetting::on_pushButton_status_clicked() { PackageHead header; RelayStatusRsp relay_status_rsp; memcpy(&header, response.data(), sizeof(PackageHead)); - qDebug() << "header len" << header.len << endl; + qDebug() << "header len" << header.len ; memcpy(&relay_status_rsp, response.data() + sizeof(PackageHead), sizeof(RelayStatusRsp)); - qDebug() << "relay_setting_rsp status" << relay_status_rsp.status << endl; + qDebug() << "relay_setting_rsp status" << relay_status_rsp.status ; if (relay_status_rsp.status == 7) { ui->label_status->setText("测试"); } else if (relay_status_rsp.status == 8) { diff --git a/setpoint.cpp b/setpoint.cpp index 2107a6a..87a4cba 100644 --- a/setpoint.cpp +++ b/setpoint.cpp @@ -1,11 +1,67 @@ #include "Setpoint.h" #include "ui_Setpoint.h" +#include "rangeslider.h" Setpoint::Setpoint(QWidget *parent) : QWidget(parent), ui(new Ui::Setpoint) { ui->setupUi(this); + + QVBoxLayout *layout_direct = new QVBoxLayout(ui->widget_direct); + RangeSlider *slider_direct = new RangeSlider; + layout_direct->addWidget(slider_direct); + + QVBoxLayout *layout_1x_ampl = new QVBoxLayout(ui->widget_1x_ampl); + RangeSlider *slider_1x_ampl = new RangeSlider; + layout_1x_ampl->addWidget(slider_1x_ampl); + + QVBoxLayout *layout_2x_ampl = new QVBoxLayout(ui->widget_2x_ampl); + RangeSlider *slider_2x_ampl = new RangeSlider; + layout_2x_ampl->addWidget(slider_2x_ampl); + + QVBoxLayout *layout_danger = new QVBoxLayout(ui->widget_danger); + RangeSlider *slider_danger = new RangeSlider; + layout_danger->addWidget(slider_danger); + + + QObject::connect(ui->lineEdit_direct_upper, &QLineEdit::editingFinished, [&]() { + slider_direct->setUpperValue(ui->lineEdit_direct_upper->text().toInt()); + }); + QObject::connect(slider_direct, &RangeSlider::rangeChanged, [&](int low, int high) { + ui->lineEdit_direct_upper->setText(QString::number(high)); + }); + + QObject::connect(slider_1x_ampl, &RangeSlider::rangeChanged, [&](int low, int high) { + ui->lineEdit_1x_ampl_upper->setText(QString::number(high)); + ui->lineEdit_1x_ampl_lower->setText(QString::number(low)); + }); + QObject::connect(ui->lineEdit_1x_ampl_upper, &QLineEdit::editingFinished, [&]() { + slider_1x_ampl->setUpperValue(ui->lineEdit_1x_ampl_upper->text().toInt()); + }); + QObject::connect(ui->lineEdit_1x_ampl_lower, &QLineEdit::editingFinished, [&]() { + slider_1x_ampl->setLowerValue(ui->lineEdit_1x_ampl_lower->text().toInt()); + }); + + QObject::connect(slider_2x_ampl, &RangeSlider::rangeChanged, [&](int low, int high) { + ui->lineEdit_2x_ampl_upper->setText(QString::number(high)); + ui->lineEdit_2x_ampl_lower->setText(QString::number(low)); + }); + QObject::connect(ui->lineEdit_2x_ampl_upper, &QLineEdit::editingFinished, [&]() { + slider_1x_ampl->setUpperValue(ui->lineEdit_2x_ampl_upper->text().toInt()); + }); + QObject::connect(ui->lineEdit_2x_ampl_lower, &QLineEdit::editingFinished, [&]() { + slider_1x_ampl->setLowerValue(ui->lineEdit_2x_ampl_lower->text().toInt()); + }); + + QObject::connect(slider_danger, &RangeSlider::rangeChanged, [&](int low, int high) { + ui->lineEdit_danger_upper->setText(QString::number(high)); + }); + QObject::connect(ui->lineEdit_danger_upper, &QLineEdit::editingFinished, [&]() { + slider_danger->setUpperValue(ui->lineEdit_danger_upper->text().toInt()); + }); + + } Setpoint::~Setpoint() diff --git a/setpoint.ui b/setpoint.ui index db4b548..c8f4da5 100644 --- a/setpoint.ui +++ b/setpoint.ui @@ -45,66 +45,74 @@ - + - 30 - 390 - 21 + 20 + 72 + 36 16 - + mil pp - + 20 - 140 - 54 - 231 - - - - 刻度 - - - - - - 20 - 100 - 41 - 20 - - - - - - - 23 - 420 - 61 - 20 + 415 + 47 + 16 启用 - + - 20 - 70 - 54 - 12 + 12 + 90 + 50 + 20 - - mil pp + + + 50 + 0 + + + + + 50 + 16777215 + + + + + + + 0 + 116 + 80 + 260 + + + + + 80 + 260 + + + + + 80 + 260 + @@ -187,231 +195,308 @@ 告警 / 警报 1 - + - 20 - 40 - 54 - 12 + 100 + 110 + 80 + 260 - - 直接值 + + + 80 + 260 + - - - - - 20 - 70 - 54 - 12 - - - - mil pp - - - - - - 20 - 100 - 41 - 20 - - - - - - - 30 - 390 - 21 - 16 - - - - - - - - - - 23 - 420 - 61 - 20 - - - - 启用 - - - - - - 20 - 140 - 54 - 231 - - - - 刻度 - - - - - - 120 - 390 - 21 - 16 - - - - - - - - - - 110 - 70 - 54 - 12 - - - - mil pp - - - - - - 110 - 100 - 41 - 20 - - - - - - - 110 - 140 - 54 - 231 - - - - 刻度 + + + 80 + 260 + - 110 - 40 + 121 + 41 54 - 12 + 16 1倍频幅值 - + - 113 - 420 - 61 + 121 + 77 + 50 20 - - 启用 + + + 50 + 0 + + + + + 50 + 16777215 + - + - 190 - 420 - 61 - 20 - - - - 启用 - - - - - - 197 - 390 - 21 + 130 + 59 + 36 16 - - - - - - - - 187 - 140 - 54 - 231 - - - - 刻度 - - - - - - 187 - 100 - 41 - 20 - - - - - - - 187 - 70 - 54 - 12 - - mil pp + + + + 120 + 380 + 50 + 20 + + + + + 50 + 0 + + + + + 50 + 16777215 + + + + + + + 121 + 420 + 47 + 16 + + + + 启用 + + + + + + 221 + 420 + 47 + 16 + + + + 启用 + + - 187 - 40 + 221 + 41 54 - 12 + 16 2倍频幅值 + + + + 230 + 59 + 36 + 16 + + + + mil pp + + + + + + 221 + 77 + 50 + 20 + + + + + 50 + 0 + + + + + 50 + 16777215 + + + + + + + 200 + 110 + 80 + 260 + + + + + 80 + 260 + + + + + 80 + 260 + + + + + + + 220 + 380 + 50 + 20 + + + + + 50 + 0 + + + + + 50 + 16777215 + + + + + + + 30 + 80 + 50 + 20 + + + + + 50 + 0 + + + + + 50 + 16777215 + + + + Qt::AlignCenter + + + + + + 10 + 107 + 80 + 260 + + + + + 80 + 260 + + + + + 80 + 260 + + + + + + + 40 + 40 + 36 + 16 + + + + 直接值 + + + Qt::AlignCenter + + + + + + 40 + 60 + 36 + 16 + + + + mil pp + + + Qt::AlignCenter + + + + + + 30 + 420 + 65 + 16 + + + + 启用 + +