From 8e2df6d291e07096abda36720d6d9a93c15c9fb2 Mon Sep 17 00:00:00 2001 From: "DESKTOP-7I8SUIC\\zhang" Date: Thu, 10 Jul 2025 15:23:58 +0800 Subject: [PATCH] add point name --- config_mgr.cpp | 2 ++ data_config.h | 1 + mainwindow.cpp | 7 ------- pointname.cpp | 38 +++++++++++++++++++++++++++----------- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/config_mgr.cpp b/config_mgr.cpp index 9a91fe4..a8b6ba1 100644 --- a/config_mgr.cpp +++ b/config_mgr.cpp @@ -349,6 +349,7 @@ void ConfigMgr::Save(QString & file_path) { channel_item.insert("speed_peak", ptr->variables_[cid].speed_peek); channel_item.insert("default_speed", ptr->variables_[cid].default_speed); channel_item.insert("automatic_threshold",ptr->variables_[cid].automatic_threshold); + channel_item.insert("point_name",ptr->variables_[cid].point_name); } else if (card_type_[i] == kCardKeyphaseSingle) { std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot); @@ -701,6 +702,7 @@ void ConfigMgr::Load(QString filename) { speed_data->variables_[j].speed_peek = channel["speed_peak"].toInt(); speed_data->variables_[j].default_speed = channel["default_speed"].toInt(); speed_data->variables_[j].automatic_threshold = channel["automatic_threshold"].toBool(); + speed_data->variables_[j].point_name = channel["point_name"].toString(); QJsonObject setpoint_data = channel["setpoint"].toObject(); diff --git a/data_config.h b/data_config.h index 9285396..1acfadc 100644 --- a/data_config.h +++ b/data_config.h @@ -222,6 +222,7 @@ typedef struct { typedef struct { int id; + QString point_name; bool active; float normal_voltage_low; float normal_voltage_high; diff --git a/mainwindow.cpp b/mainwindow.cpp index 951a9ed..e48be63 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -27,7 +27,6 @@ #include "ethconfig.h" #include "macconfig.h" #include -#include "setpoint_pressure.h" QString g_strServerIp; QString g_version; @@ -504,12 +503,6 @@ void MainWindow::OnButtonGroup(QAbstractButton *slot_btn) { break; } } -// std::shared_ptr ptr = std::dynamic_pointer_cast(base_ptr); -// if(ptr->base_config_[button_id].channel_type == kVibPressurePulsation){ -// SetpointPressure *setpoint_press = new SetpointPressure(button_id,ConfigMgr::Instance()->card_type_[button_id - 1]); -// setpoint_press->setWindowModality(Qt::ApplicationModal); -// setpoint_press->show(); -// } } if(slot_btn != NULL && ui->pushButton_point_name->isChecked()){ QString object_name = slot_btn->objectName(); diff --git a/pointname.cpp b/pointname.cpp index aa5cd2a..48db0e6 100644 --- a/pointname.cpp +++ b/pointname.cpp @@ -2,6 +2,7 @@ #include "ui_pointname.h" #include "config_mgr.h" #include "vibrationdata.h" +#include "tachometer_data.h" PointName::PointName(int slot_no_,int cardtype,QWidget *parent) : QWidget(parent), @@ -25,12 +26,20 @@ void PointName::Init() if (base_ptr == nullptr) { return; } - std::shared_ptr vib_data = std::dynamic_pointer_cast(base_ptr); + if(base_ptr->card_type_ == kCardVibSingle){ + std::shared_ptr vib_data = std::dynamic_pointer_cast(base_ptr); - ui->lineEdit_pointname_1->setText(vib_data->base_config_[0].point_name); - ui->lineEdit_pointname_2->setText(vib_data->base_config_[1].point_name); - ui->lineEdit_pointname_3->setText(vib_data->base_config_[2].point_name); - ui->lineEdit_pointname_4->setText(vib_data->base_config_[3].point_name); + ui->lineEdit_pointname_1->setText(vib_data->base_config_[0].point_name); + ui->lineEdit_pointname_2->setText(vib_data->base_config_[1].point_name); + ui->lineEdit_pointname_3->setText(vib_data->base_config_[2].point_name); + ui->lineEdit_pointname_4->setText(vib_data->base_config_[3].point_name); + }else if(base_ptr->card_type_ == kCardSpeedSingle){ + std::shared_ptr tac_data = std::dynamic_pointer_cast(base_ptr); + ui->lineEdit_pointname_1->setText(tac_data->variables_[0].point_name); + ui->lineEdit_pointname_2->setText(tac_data->variables_[1].point_name); + ui->lineEdit_pointname_3->setText(tac_data->variables_[2].point_name); + ui->lineEdit_pointname_4->setText(tac_data->variables_[3].point_name); + } } void PointName::on_pushButton_cancel_clicked() @@ -45,12 +54,19 @@ void PointName::on_pushButton_confirm_clicked() if (base_ptr == nullptr) { return; } - std::shared_ptr vib_data = std::dynamic_pointer_cast(base_ptr); - - vib_data->base_config_[0].point_name = ui->lineEdit_pointname_1->text(); - vib_data->base_config_[1].point_name = ui->lineEdit_pointname_2->text(); - vib_data->base_config_[2].point_name = ui->lineEdit_pointname_3->text(); - vib_data->base_config_[3].point_name = ui->lineEdit_pointname_4->text(); + if(base_ptr->card_type_ == kCardVibSingle){ + std::shared_ptr vib_data = std::dynamic_pointer_cast(base_ptr); + vib_data->base_config_[0].point_name = ui->lineEdit_pointname_1->text(); + vib_data->base_config_[1].point_name = ui->lineEdit_pointname_2->text(); + vib_data->base_config_[2].point_name = ui->lineEdit_pointname_3->text(); + vib_data->base_config_[3].point_name = ui->lineEdit_pointname_4->text(); + }else if(base_ptr->card_type_ == kCardSpeedSingle){ + std::shared_ptr tac_data = std::dynamic_pointer_cast(base_ptr); + tac_data->variables_[0].point_name = ui->lineEdit_pointname_1->text(); + tac_data->variables_[1].point_name = ui->lineEdit_pointname_2->text(); + tac_data->variables_[2].point_name = ui->lineEdit_pointname_3->text(); + tac_data->variables_[3].point_name = ui->lineEdit_pointname_4->text(); + } this->close(); }