From c96ed16d0961239990e5b071978c91c5ff4c7332 Mon Sep 17 00:00:00 2001 From: "DESKTOP-7I8SUIC\\zhang" Date: Mon, 4 Aug 2025 12:25:12 +0800 Subject: [PATCH] add codes --- TSI_Config.pro | 3 + cardbase.h | 2 + config_mgr.cpp | 2 - data_config.h | 33 +++++++ dc_output_channel.cpp | 46 ++++++++++ dc_output_channel.h | 28 ++++++ dc_output_channel.ui | 209 ++++++++++++++++++++++++++++++++++++++++++ dc_outputs.cpp | 54 ++++++++++- dc_outputs.h | 12 ++- dc_outputs.ui | 115 ++++++++++++++++------- mainwindow.cpp | 4 + seismic_monitor.cpp | 2 + trust.cpp | 3 - trust.ui | 42 +-------- 14 files changed, 475 insertions(+), 80 deletions(-) create mode 100644 dc_output_channel.cpp create mode 100644 dc_output_channel.h create mode 100644 dc_output_channel.ui diff --git a/TSI_Config.pro b/TSI_Config.pro index 4b5bb4f..f612b0c 100644 --- a/TSI_Config.pro +++ b/TSI_Config.pro @@ -15,6 +15,7 @@ SOURCES += \ common.cpp \ config_mgr.cpp \ connect.cpp \ + dc_output_channel.cpp \ dc_outputs.cpp \ ethconfig.cpp \ keyphase.cpp \ @@ -48,6 +49,7 @@ HEADERS += \ config_mgr.h \ connect.h \ data_config.h \ + dc_output_channel.h \ dc_outputs.h \ displacement_ds.h \ ethconfig.h \ @@ -77,6 +79,7 @@ HEADERS += \ FORMS += \ acceleration.ui \ connect.ui \ + dc_output_channel.ui \ dc_outputs.ui \ ethconfig.ui \ keyphase.ui \ diff --git a/cardbase.h b/cardbase.h index fdf2398..e6761ea 100644 --- a/cardbase.h +++ b/cardbase.h @@ -37,6 +37,8 @@ class VariableBase { AlarmAlertLow gap_alert_low; FrequencybandOutput freband_output[10]; + + DCOutput dc_output[4]; }; // 位移 diff --git a/config_mgr.cpp b/config_mgr.cpp index cc6d81a..152f374 100644 --- a/config_mgr.cpp +++ b/config_mgr.cpp @@ -211,7 +211,6 @@ void ConfigMgr::Save(QString & file_path) { QJsonObject gap,gap_general,gap_alarm; gap_general["output_used"] = thrust_ptr->gap_general.output_used; gap_general["engieneering_unit"] = thrust_ptr->gap_general.engineering_unit; - gap_general["rectifier_function"] = thrust_ptr->gap_general.rectifier_function; gap_alarm["danger_high_level"] = thrust_ptr->gap_danger_high.level; gap_alarm["danger_high_hysteresis"] = thrust_ptr->gap_danger_high.hysteresis; @@ -671,7 +670,6 @@ void ConfigMgr::Load(QString filename) { g_alarm = gap["alarm"].toObject(); variable->gap_general.output_used = g_general["output_used"].toBool(); variable->gap_general.engineering_unit = g_general["engieneering_unit"].toInt(); - variable->gap_general.rectifier_function = g_general["rectifier_function"].toInt(); variable->gap_danger_high.level = g_alarm["danger_high_level"].toDouble(); variable->gap_danger_high.hysteresis = g_alarm["danger_high_hysteresis"].toDouble(); variable->gap_danger_high.delay = g_alarm["danger_high_delay"].toInt(); diff --git a/data_config.h b/data_config.h index 03390b8..39386a8 100644 --- a/data_config.h +++ b/data_config.h @@ -55,6 +55,28 @@ typedef enum { kVibPressurePulsation = 4 //动态压力脉动 } VibChannelType; +typedef enum{ + kTruePeak = 0, + kTruePeakToPeak = 1, + kRMSScalePeak = 2, + kRMSScalePeakToPeak = 3, + kAVG = 4, + kRMSScaleAVG = 5, + kRMS = 6 +} RectifierFuntion; + +typedef enum{ + kUnit1 = 0, // g + kUnit2 = 1, // m/s**2 + kUnit3 = 2, // mm/s + kUnit4 = 3, // inch/s + kUnit5 = 4, // um + kUnit6 = 5, // mm + kUnit7 = 6, // mils + kUnit8 = 7, // inch/s**2 + kUnit9 = 8 // user defined +} EngineeringUnit; + typedef struct SlotConfig_{ int slot; QString slot_type; @@ -176,6 +198,17 @@ typedef struct FrequencybandOutput_{ end = 0; } }FrequencybandOutput ; + +typedef struct DCOutput_{ + int output_channel; + float minmum; + float maxmum; + DCOutput_(){ + output_channel = 0; + minmum = 0; + maxmum = 0; + } +} DCOutput; //typedef struct { // Filter filter[3]; // 0: kFilterTypeLowPass, 1: kFilterTypeHighPass, 2: kFilterTypeBandPass //} AllFilter; diff --git a/dc_output_channel.cpp b/dc_output_channel.cpp new file mode 100644 index 0000000..39e925e --- /dev/null +++ b/dc_output_channel.cpp @@ -0,0 +1,46 @@ +#include "dc_output_channel.h" +#include "ui_dc_output_channel.h" +#include + +DC_Output_Channel::DC_Output_Channel(QWidget *parent) : + QWidget(parent), + ui(new Ui::DC_Output_Channel) +{ + ui->setupUi(this); +} + +DC_Output_Channel::~DC_Output_Channel() +{ + delete ui; +} + +void DC_Output_Channel::on_pushButton_confirm_clicked() +{ + int channel = 0; + if((ui->lineEdit_minmum->text().toFloat() >= ui->lineEdit_maxmum->text().toFloat()) || + (ui->lineEdit_minmum->text().toFloat() == 0 && ui->lineEdit_maxmum->text().toFloat() == 0)){ + QMessageBox::information(this, QStringLiteral("提示"), "请填写正确的最小值和最大值"); + return; + } + if(ui->radioButton->isChecked()){ + channel = 1; + }else if(ui->radioButton_2->isChecked()){ + channel = 2; + }else if(ui->radioButton_3->isChecked()){ + channel = 3; + }else if(ui->radioButton_4->isChecked()){ + channel = 4; + }else { + QMessageBox::information(this, QStringLiteral("提示"), "请选择正确的通道"); + return; + } + emit output_channel_data_sg(channel,ui->lineEdit_minmum->text().toFloat(),ui->lineEdit_maxmum->text().toFloat()); + this->close(); +} + + +void DC_Output_Channel::on_pushButton_cancel_clicked() +{ + this->close(); +} + diff --git a/dc_output_channel.h b/dc_output_channel.h new file mode 100644 index 0000000..54555a8 --- /dev/null +++ b/dc_output_channel.h @@ -0,0 +1,28 @@ +#ifndef DC_OUTPUT_CHANNEL_H +#define DC_OUTPUT_CHANNEL_H + +#include + +namespace Ui { +class DC_Output_Channel; +} + +class DC_Output_Channel : public QWidget +{ + Q_OBJECT + +public: + explicit DC_Output_Channel(QWidget *parent = nullptr); + ~DC_Output_Channel(); +signals: + void output_channel_data_sg(int channel,float minmun,float maxmum); +private slots: + void on_pushButton_confirm_clicked(); + + void on_pushButton_cancel_clicked(); + +private: + Ui::DC_Output_Channel *ui; +}; + +#endif // DC_OUTPUT_CHANNEL_H diff --git a/dc_output_channel.ui b/dc_output_channel.ui new file mode 100644 index 0000000..404219a --- /dev/null +++ b/dc_output_channel.ui @@ -0,0 +1,209 @@ + + + DC_Output_Channel + + + + 0 + 0 + 527 + 416 + + + + 输出通道 + + + + + 30 + 50 + 391 + 181 + + + + 4 - 20 mA 输出 + + + + + 40 + 30 + 89 + 16 + + + + 通道1 + + + buttonGroup + + + + + + 40 + 60 + 89 + 16 + + + + 通道2 + + + buttonGroup + + + + + + 40 + 90 + 89 + 16 + + + + 通道3 + + + buttonGroup + + + + + + 40 + 120 + 89 + 16 + + + + 通道4 + + + buttonGroup + + + + + + + 50 + 260 + 113 + 25 + + + + + 0 + 25 + + + + + + + 50 + 300 + 113 + 25 + + + + + 0 + 25 + + + + + + + 190 + 270 + 54 + 12 + + + + - - + + + + + + 190 + 310 + 54 + 12 + + + + - - + + + + + + 280 + 270 + 54 + 12 + + + + 最小值 + + + + + + 280 + 310 + 54 + 12 + + + + 最大值 + + + + + + 90 + 360 + 75 + 23 + + + + 确认 + + + + + + 240 + 360 + 75 + 23 + + + + 取消 + + + + + + + + + diff --git a/dc_outputs.cpp b/dc_outputs.cpp index e292240..3f68c9a 100644 --- a/dc_outputs.cpp +++ b/dc_outputs.cpp @@ -1,14 +1,66 @@ #include "dc_outputs.h" #include "ui_dc_outputs.h" +#include +#include "dc_output_channel.h" +#include +#include "config_mgr.h" +#include "data_config.h" +#include "vibrationdata.h" -DC_Outputs::DC_Outputs(QWidget *parent) : +DC_Outputs::DC_Outputs(int slot_no_,int cardtype,QWidget *parent) : QWidget(parent), ui(new Ui::DC_Outputs) { ui->setupUi(this); + ui->comboBox_ch_output->setView(new QListView()); + slot_no = slot_no_; + car_type = static_cast(cardtype); + memset(channel_used,0,sizeof(channel_used)); + current_index = ui->comboBox_ch_output->currentIndex(); + Init(); } DC_Outputs::~DC_Outputs() { delete ui; } + +void DC_Outputs::Init(){ + std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); + if (base_ptr == nullptr) { + qCritical() << "[Acceleration::Init] should not be here"; + return; + } + std::shared_ptr ptr = std::dynamic_pointer_cast(base_ptr); + std::shared_ptr variable_base = ptr->GetChannelPtr(current_index + 1); + if (variable_base == nullptr) { + qDebug() << "[Acceleration::Init] no channel ptr"; + return; + } + if(variable_base->dc_output[0].output_channel == 1){ + ui->label_ch_1->setText("通道1"); + ui->label_ch_1_min->setText(QString::number(variable_base->dc_output[0].minmum)); + ui->label_ch_1_max->setText(QString::number(variable_base->dc_output[0].maxmum)); + } +} + +void DC_Outputs::on_comboBox_ch_output_activated(int index) +{ + DC_Output_Channel *dc_output_channel = new DC_Output_Channel(); + dc_output_channel->setWindowModality(Qt::ApplicationModal); + connect(dc_output_channel,SIGNAL(output_channel_data_sg(int,float,float)),this,SLOT(output_channel_data(int,float,float))); + dc_output_channel->show(); +} + +void DC_Outputs::output_channel_data(int channel,float minmun,float maxmum){ + qDebug() << channel << minmun << maxmum ; + if(channel == 1){ + + }else if(channel == 2){ + + }else if(channel == 3){ + + }else if(channel == 4){ + + } +} diff --git a/dc_outputs.h b/dc_outputs.h index 6f155f8..fa5496a 100644 --- a/dc_outputs.h +++ b/dc_outputs.h @@ -2,6 +2,7 @@ #define DC_OUTPUTS_H #include +#include "data_config.h" namespace Ui { class DC_Outputs; @@ -12,11 +13,20 @@ class DC_Outputs : public QWidget Q_OBJECT public: - explicit DC_Outputs(QWidget *parent = nullptr); + explicit DC_Outputs(int slot_no_,int cardtype,QWidget *parent = nullptr); ~DC_Outputs(); + int slot_no; + CardType car_type; +private slots: + void on_comboBox_ch_output_activated(int index); + + void output_channel_data(int channel,float minmun,float maxmum); private: Ui::DC_Outputs *ui; + void Init(); + bool channel_used[4]; + int current_index; }; #endif // DC_OUTPUTS_H diff --git a/dc_outputs.ui b/dc_outputs.ui index 98711df..d29c893 100644 --- a/dc_outputs.ui +++ b/dc_outputs.ui @@ -11,9 +11,9 @@ - Form + 直流输出 - + 60 @@ -39,12 +39,37 @@ 通道1 输出1 + + + 通道2 输出1 + + + + + 通道3 输出1 + + + + + 通道4 输出1 + + + + + 通道1 & 通道4 + + + + + 通道3 & 通道4 + + 50 - 150 + 160 54 12 @@ -95,8 +120,8 @@ - 160 - 100 + 140 + 110 101 16 @@ -109,8 +134,8 @@ 310 - 100 - 101 + 110 + 41 16 @@ -122,8 +147,8 @@ 440 - 100 - 101 + 110 + 41 16 @@ -131,20 +156,20 @@ 最大值 - + 160 - 150 + 160 81 16 - 通道1 输出1 + 未使用 - + 160 @@ -154,10 +179,10 @@ - 通道1 输出2 + 未使用 - + 160 @@ -170,7 +195,7 @@ 未使用 - + 160 @@ -183,20 +208,20 @@ 未使用 - + 300 - 140 + 160 101 16 - 0.0 m/s**2_RMSpk + ----- ----- - + 300 @@ -206,23 +231,23 @@ - 0.000 g_RMS + ----- ----- - + 420 - 140 + 160 121 16 - 200.0 m/s**2_RMSpk + ----- ----- - + 420 @@ -232,10 +257,10 @@ - 666.667 g_RMS + ----- ----- - + 300 @@ -248,7 +273,7 @@ ----- ----- - + 300 @@ -261,10 +286,10 @@ ----- ----- - + - 430 + 420 240 71 16 @@ -274,10 +299,10 @@ ----- ----- - + - 430 + 420 280 71 16 @@ -287,6 +312,32 @@ ----- ----- + + + + 160 + 380 + 75 + 23 + + + + 确认 + + + + + + 340 + 380 + 75 + 23 + + + + 取消 + + diff --git a/mainwindow.cpp b/mainwindow.cpp index e71af28..bbc4e02 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -26,6 +26,7 @@ #include "ethconfig.h" #include "macconfig.h" #include +#include "dc_outputs.h" QString g_strServerIp; QString g_version; @@ -475,6 +476,9 @@ void MainWindow::OnButtonGroup(QAbstractButton *slot_btn) { case kCardVibSingle:{ QString object_name = slot_btn->objectName(); int button_id = object_name.right(object_name.length() - 15).toInt(); + DC_Outputs *dc_output = new DC_Outputs(button_id,ConfigMgr::Instance()->card_type_[button_id - 1]); + dc_output->setWindowModality(Qt::ApplicationModal); + dc_output->show(); // Setpoint *setpoint = new Setpoint(button_id,ConfigMgr::Instance()->card_type_[button_id - 1]); // setpoint->setWindowModality(Qt::ApplicationModal); // setpoint->show(); diff --git a/seismic_monitor.cpp b/seismic_monitor.cpp index 8651773..a2ac7a8 100644 --- a/seismic_monitor.cpp +++ b/seismic_monitor.cpp @@ -30,6 +30,8 @@ Seismic_monitor::Seismic_monitor(int slot,int cardtype, QWidget *parent) : car_type = static_cast(cardtype); QString slot_no_ = QString("%1").arg(slot_no); ui->label_slot_no->setText(slot_no_); + ui->checkBox_standby_1->hide(); + ui->checkBox_standby_2->hide(); Init(); } diff --git a/trust.cpp b/trust.cpp index 8f31fe2..2d8f104 100644 --- a/trust.cpp +++ b/trust.cpp @@ -70,7 +70,6 @@ void Trust::Init() { else ui->comboBox_output_used->setCurrentIndex(1); ui->comboBox_engineering_unit->setCurrentIndex(variable_ptr->gap_general.engineering_unit); - ui->comboBox_rectifier_funtion->setCurrentIndex(variable_ptr->gap_general.rectifier_function); // -alarm ui->lineEdit_danger_high_level->setText(QString::number(variable_ptr->gap_danger_high.level)); ui->lineEdit_danger_high_hysteresis->setText(QString::number(variable_ptr->gap_danger_high.hysteresis)); @@ -136,7 +135,6 @@ void Trust::on_pushButton_confirm_clicked() else variable->gap_general.output_used = false; variable->gap_general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); - variable->gap_general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); // -alarm variable->gap_danger_high.level = ui->lineEdit_danger_high_level->text().toDouble(); variable->gap_danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble(); @@ -183,7 +181,6 @@ void Trust::on_pushButton_confirm_clicked() else variable->gap_general.output_used = false; variable->gap_general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); - variable->gap_general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); // -alarm variable->gap_danger_high.level = ui->lineEdit_danger_high_level->text().toDouble(); variable->gap_danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble(); diff --git a/trust.ui b/trust.ui index 4f70b64..fb7f077 100644 --- a/trust.ui +++ b/trust.ui @@ -287,52 +287,12 @@ - 1 + 0 常规 - - - - 170 - 150 - 54 - 12 - - - - 整流器 - - - - - - 10 - 140 - 125 - 25 - - - - - 125 - 25 - - - - - 125 - 25 - - - - - RMS - - -