add codes

This commit is contained in:
DESKTOP-7I8SUIC\zhang 2025-08-04 12:25:12 +08:00
parent fe33514c40
commit c96ed16d09
14 changed files with 475 additions and 80 deletions

View File

@ -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 \

View File

@ -37,6 +37,8 @@ class VariableBase {
AlarmAlertLow gap_alert_low;
FrequencybandOutput freband_output[10];
DCOutput dc_output[4];
};
// 位移

View File

@ -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();

View File

@ -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;

46
dc_output_channel.cpp Normal file
View File

@ -0,0 +1,46 @@
#include "dc_output_channel.h"
#include "ui_dc_output_channel.h"
#include <QMessageBox>
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();
}

28
dc_output_channel.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef DC_OUTPUT_CHANNEL_H
#define DC_OUTPUT_CHANNEL_H
#include <QWidget>
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

209
dc_output_channel.ui Normal file
View File

@ -0,0 +1,209 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DC_Output_Channel</class>
<widget class="QWidget" name="DC_Output_Channel">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>527</width>
<height>416</height>
</rect>
</property>
<property name="windowTitle">
<string>输出通道</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>30</x>
<y>50</y>
<width>391</width>
<height>181</height>
</rect>
</property>
<property name="title">
<string>4 - 20 mA 输出</string>
</property>
<widget class="QRadioButton" name="radioButton">
<property name="geometry">
<rect>
<x>40</x>
<y>30</y>
<width>89</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>通道1</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
<widget class="QRadioButton" name="radioButton_2">
<property name="geometry">
<rect>
<x>40</x>
<y>60</y>
<width>89</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>通道2</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
<widget class="QRadioButton" name="radioButton_3">
<property name="geometry">
<rect>
<x>40</x>
<y>90</y>
<width>89</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>通道3</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
<widget class="QRadioButton" name="radioButton_4">
<property name="geometry">
<rect>
<x>40</x>
<y>120</y>
<width>89</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>通道4</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</widget>
<widget class="QLineEdit" name="lineEdit_minmum">
<property name="geometry">
<rect>
<x>50</x>
<y>260</y>
<width>113</width>
<height>25</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_maxmum">
<property name="geometry">
<rect>
<x>50</x>
<y>300</y>
<width>113</width>
<height>25</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
</widget>
<widget class="QLabel" name="label_min_unit">
<property name="geometry">
<rect>
<x>190</x>
<y>270</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string>- -</string>
</property>
</widget>
<widget class="QLabel" name="label_max_unit">
<property name="geometry">
<rect>
<x>190</x>
<y>310</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string>- -</string>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>280</x>
<y>270</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string>最小值</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>280</x>
<y>310</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string>最大值</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_confirm">
<property name="geometry">
<rect>
<x>90</x>
<y>360</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>确认</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_cancel">
<property name="geometry">
<rect>
<x>240</x>
<y>360</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>取消</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
<buttongroups>
<buttongroup name="buttonGroup"/>
</buttongroups>
</ui>

View File

@ -1,14 +1,66 @@
#include "dc_outputs.h"
#include "ui_dc_outputs.h"
#include <QListView>
#include "dc_output_channel.h"
#include <QDebug>
#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>(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<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
if (base_ptr == nullptr) {
qCritical() << "[Acceleration::Init] should not be here";
return;
}
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
std::shared_ptr<VariableBase> 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){
}
}

View File

@ -2,6 +2,7 @@
#define DC_OUTPUTS_H
#include <QWidget>
#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

View File

@ -11,9 +11,9 @@
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
<string>直流输出</string>
</property>
<widget class="QComboBox" name="comboBox">
<widget class="QComboBox" name="comboBox_ch_output">
<property name="geometry">
<rect>
<x>60</x>
@ -39,12 +39,37 @@
<string>通道1 输出1</string>
</property>
</item>
<item>
<property name="text">
<string>通道2 输出1</string>
</property>
</item>
<item>
<property name="text">
<string>通道3 输出1</string>
</property>
</item>
<item>
<property name="text">
<string>通道4 输出1</string>
</property>
</item>
<item>
<property name="text">
<string>通道1 &amp; 通道4</string>
</property>
</item>
<item>
<property name="text">
<string>通道3 &amp; 通道4</string>
</property>
</item>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>50</x>
<y>150</y>
<y>160</y>
<width>54</width>
<height>12</height>
</rect>
@ -95,8 +120,8 @@
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>160</x>
<y>100</y>
<x>140</x>
<y>110</y>
<width>101</width>
<height>16</height>
</rect>
@ -109,8 +134,8 @@
<property name="geometry">
<rect>
<x>310</x>
<y>100</y>
<width>101</width>
<y>110</y>
<width>41</width>
<height>16</height>
</rect>
</property>
@ -122,8 +147,8 @@
<property name="geometry">
<rect>
<x>440</x>
<y>100</y>
<width>101</width>
<y>110</y>
<width>41</width>
<height>16</height>
</rect>
</property>
@ -131,20 +156,20 @@
<string>最大值</string>
</property>
</widget>
<widget class="QLabel" name="label_9">
<widget class="QLabel" name="label_ch_1">
<property name="geometry">
<rect>
<x>160</x>
<y>150</y>
<y>160</y>
<width>81</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>通道1 输出1</string>
<string>未使用</string>
</property>
</widget>
<widget class="QLabel" name="label_10">
<widget class="QLabel" name="label_ch_2">
<property name="geometry">
<rect>
<x>160</x>
@ -154,10 +179,10 @@
</rect>
</property>
<property name="text">
<string>通道1 输出2</string>
<string>未使用</string>
</property>
</widget>
<widget class="QLabel" name="label_11">
<widget class="QLabel" name="label_ch_3">
<property name="geometry">
<rect>
<x>160</x>
@ -170,7 +195,7 @@
<string>未使用</string>
</property>
</widget>
<widget class="QLabel" name="label_12">
<widget class="QLabel" name="label_ch_4">
<property name="geometry">
<rect>
<x>160</x>
@ -183,20 +208,20 @@
<string>未使用</string>
</property>
</widget>
<widget class="QLabel" name="label_13">
<widget class="QLabel" name="label_ch_1_min">
<property name="geometry">
<rect>
<x>300</x>
<y>140</y>
<y>160</y>
<width>101</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>0.0 m/s**2_RMSpk</string>
<string>----- -----</string>
</property>
</widget>
<widget class="QLabel" name="label_14">
<widget class="QLabel" name="label_ch_2_min">
<property name="geometry">
<rect>
<x>300</x>
@ -206,23 +231,23 @@
</rect>
</property>
<property name="text">
<string>0.000 g_RMS</string>
<string>----- -----</string>
</property>
</widget>
<widget class="QLabel" name="label_15">
<widget class="QLabel" name="label_ch_1_max">
<property name="geometry">
<rect>
<x>420</x>
<y>140</y>
<y>160</y>
<width>121</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>200.0 m/s**2_RMSpk</string>
<string>----- -----</string>
</property>
</widget>
<widget class="QLabel" name="label_16">
<widget class="QLabel" name="label_ch_2_max">
<property name="geometry">
<rect>
<x>420</x>
@ -232,10 +257,10 @@
</rect>
</property>
<property name="text">
<string>666.667 g_RMS</string>
<string>----- -----</string>
</property>
</widget>
<widget class="QLabel" name="label_8">
<widget class="QLabel" name="label_ch_3_min">
<property name="geometry">
<rect>
<x>300</x>
@ -248,7 +273,7 @@
<string>----- -----</string>
</property>
</widget>
<widget class="QLabel" name="label_17">
<widget class="QLabel" name="label_ch_4_min">
<property name="geometry">
<rect>
<x>300</x>
@ -261,10 +286,10 @@
<string>----- -----</string>
</property>
</widget>
<widget class="QLabel" name="label_18">
<widget class="QLabel" name="label_ch_3_max">
<property name="geometry">
<rect>
<x>430</x>
<x>420</x>
<y>240</y>
<width>71</width>
<height>16</height>
@ -274,10 +299,10 @@
<string>----- -----</string>
</property>
</widget>
<widget class="QLabel" name="label_19">
<widget class="QLabel" name="label_ch_4_max">
<property name="geometry">
<rect>
<x>430</x>
<x>420</x>
<y>280</y>
<width>71</width>
<height>16</height>
@ -287,6 +312,32 @@
<string>----- -----</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_confirm">
<property name="geometry">
<rect>
<x>160</x>
<y>380</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>确认</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_cancel">
<property name="geometry">
<rect>
<x>340</x>
<y>380</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>取消</string>
</property>
</widget>
</widget>
<resources/>
<connections/>

View File

@ -26,6 +26,7 @@
#include "ethconfig.h"
#include "macconfig.h"
#include <QDateTime>
#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();

View File

@ -30,6 +30,8 @@ Seismic_monitor::Seismic_monitor(int slot,int cardtype, QWidget *parent) :
car_type = static_cast<CardType>(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();
}

View File

@ -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();

View File

@ -287,52 +287,12 @@
</rect>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab_8">
<attribute name="title">
<string>常规</string>
</attribute>
<widget class="QLabel" name="label_26">
<property name="geometry">
<rect>
<x>170</x>
<y>150</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string>整流器</string>
</property>
</widget>
<widget class="QComboBox" name="comboBox_rectifier_funtion">
<property name="geometry">
<rect>
<x>10</x>
<y>140</y>
<width>125</width>
<height>25</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>125</width>
<height>25</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>125</width>
<height>25</height>
</size>
</property>
<item>
<property name="text">
<string>RMS</string>
</property>
</item>
</widget>
<widget class="QLabel" name="label_27">
<property name="geometry">
<rect>