This commit is contained in:
zhangsheng 2025-07-08 09:24:34 +08:00
parent 9ea836be8c
commit 0df5b3bf51
4 changed files with 1015 additions and 0 deletions

145
trust.cpp Normal file
View File

@ -0,0 +1,145 @@
#include "trust.h"
#include "ui_trust.h"
#include <QFile>
#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include "data_config.h"
#include "vibrationdata.h"
#include "config_mgr.h"
Trust::Trust(int slot_no_, int channel_, bool active,QWidget *parent) :
QWidget(parent),
ui(new Ui::Trust)
{
ui->setupUi(this);
slot_no = slot_no_;
channel = channel_;
QString chan = QString("%1").arg(channel);
QString slot = QString("%1").arg(slot_no);
ui->label_channel->setText(chan);
ui->label_slot->setText(slot);
if (active) {
ui->label_active->setText("(启用)");
} else {
ui->label_active->setText("(停用)");
}
Init();
}
Trust::~Trust()
{
delete ui;
}
void Trust::Init() {
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
if (base_ptr == nullptr) {
qCritical() << "[Radial::Init] should not be here";
return;
}
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
if (ptr->base_config_[channel - 1].channel_type != kVibThrust) {
qDebug() << "[Radial::Init] channel type changes";
return;
}
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(channel);
if (variable_base == nullptr) {
qDebug() << "[Radial::Init] no channel ptr";
return;
}
std::shared_ptr<ThrustVariable> variable_ptr = std::dynamic_pointer_cast<ThrustVariable>(variable_base);
ui->checkBox_low_pass->setChecked(variable_ptr->filter_[0].checked);
ui->spinBox_low_pass_low->setValue(variable_ptr->filter_[0].low);
ui->spinBox_low_pass_high->setValue(variable_ptr->filter_[0].high);
ui->checkBox_high_pass->setChecked(variable_ptr->filter_[1].checked);
ui->spinBox_high_pass_low->setValue(variable_ptr->filter_[1].low);
ui->spinBox_high_pass_high->setValue(variable_ptr->filter_[1].high);
ui->checkBox_band_pass->setChecked(variable_ptr->filter_[2].checked);
ui->spinBox_band_pass_low->setValue(variable_ptr->filter_[2].low);
ui->spinBox_band_pass_high->setValue(variable_ptr->filter_[2].high);
ui->comboBox_direct_value_range->setCurrentIndex(variable_ptr->direct_.full_scale_range);
ui->doubleSpinBox_direct_clamp->setValue(variable_ptr->direct_.clamp_value);
// ui->label_bias_voltage->setText(QString::number(variable_ptr->direct_.bias_voltage));
// ui->doubleSpinBox_bias_volt_clamp->setValue(variables[i].clamp_value);
// ui->comboBox_bias_volt_range->setCurrentIndex();
ui->spinBox_alert->setValue(variable_ptr->delay_.alert);
ui->doubleSpinBox_danger->setValue(variable_ptr->delay_.danger);
ui->checkBox_100ms->setChecked(variable_ptr->delay_.active_100ms);
ui->checkBox_alert_latching->setChecked(variable_ptr->alert_latching_);
ui->checkBox_danger_latching->setChecked(variable_ptr->danger_latching_);
ui->comboBox_recorder_output->setCurrentIndex(variable_ptr->recorder_out_.recorder_output);
ui->checkBox_two_ma_clamp->setChecked(variable_ptr->recorder_out_.two_ma_clamp);
}
void Trust::on_pushButton_confirm_clicked()
{
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
if (base_ptr == nullptr) {
qCritical() << "[Radial::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(channel);
if (variable_base == nullptr || variable_base->type_ != kVibThrust) {
if (variable_base == nullptr) {
qDebug() << "no channel ptr";
} else {
ptr->RemoveChannel(channel);
qDebug() << "channel type change";
}
std::shared_ptr<ThrustVariable> variable = std::make_shared<ThrustVariable>();
variable->id_ = channel;
variable->type_ = kVibThrust;
variable->filter_[0].checked = ui->checkBox_low_pass->isChecked();
variable->filter_[0].low = ui->spinBox_low_pass_low->value();
variable->filter_[0].high = ui->spinBox_low_pass_high->value();
variable->filter_[1].checked = ui->checkBox_high_pass->isChecked();
variable->filter_[1].low = ui->spinBox_high_pass_low->value();
variable->filter_[1].high = ui->spinBox_high_pass_high->value();
variable->filter_[2].checked = ui->checkBox_band_pass->isChecked();
variable->filter_[2].low = ui->spinBox_band_pass_low->value();
variable->filter_[2].high = ui->spinBox_band_pass_high->value();
variable->direct_.full_scale_range = ui->comboBox_direct_value_range->currentIndex();
variable->direct_.clamp_value = ui->doubleSpinBox_direct_clamp->value();
variable->direct_.custom = 0; // TODO:
variable->recorder_out_.recorder_output = ui->comboBox_recorder_output->currentIndex();
variable->recorder_out_.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked();
variable->delay_.alert = ui->spinBox_alert->value();
variable->delay_.danger = ui->doubleSpinBox_danger->value();
variable->delay_.active_100ms = ui->checkBox_100ms->isChecked();
variable->alert_latching_ = ui->checkBox_alert_latching->isChecked();
variable->danger_latching_ = ui->checkBox_danger_latching->isChecked();
ptr->variables_.push_back(variable);
this->close();
return;
}
std::shared_ptr<ThrustVariable> variable = std::dynamic_pointer_cast<ThrustVariable>(variable_base);
variable->filter_[0].checked = ui->checkBox_low_pass->isChecked();
variable->filter_[0].low = ui->spinBox_low_pass_low->value();
variable->filter_[0].high = ui->spinBox_low_pass_high->value();
variable->filter_[1].checked = ui->checkBox_high_pass->isChecked();
variable->filter_[1].low = ui->spinBox_high_pass_low->value();
variable->filter_[1].high = ui->spinBox_high_pass_high->value();
variable->filter_[2].checked = ui->checkBox_band_pass->isChecked();
variable->filter_[2].low = ui->spinBox_band_pass_low->value();
variable->filter_[2].high = ui->spinBox_band_pass_high->value();
variable->direct_.full_scale_range = ui->comboBox_direct_value_range->currentIndex();
variable->direct_.clamp_value = ui->doubleSpinBox_direct_clamp->value();
variable->direct_.custom = 0; // TODO:
variable->recorder_out_.recorder_output = ui->comboBox_recorder_output->currentIndex();
variable->recorder_out_.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked();
variable->delay_.alert = ui->spinBox_alert->value();
variable->delay_.danger = ui->doubleSpinBox_danger->value();
variable->delay_.active_100ms = ui->checkBox_100ms->isChecked();
variable->alert_latching_ = ui->checkBox_alert_latching->isChecked();
variable->danger_latching_ = ui->checkBox_danger_latching->isChecked();
this->close();
}
void Trust::on_pushButton_cancel_clicked()
{
}

30
trust.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef TRUST_H
#define TRUST_H
#include <QWidget>
namespace Ui {
class Trust;
}
class Trust : public QWidget
{
Q_OBJECT
public:
explicit Trust(int slot_no_, int channel_, bool active,QWidget *parent = nullptr);
~Trust();
int slot_no;
int channel;
private slots:
void on_pushButton_confirm_clicked();
void on_pushButton_cancel_clicked();
private:
Ui::Trust *ui;
void Init();
};
#endif // TRUST_H

818
trust.ui Normal file
View File

@ -0,0 +1,818 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Trust</class>
<widget class="QWidget" name="Trust">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>691</width>
<height>505</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QTabWidget" name="tabWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>651</width>
<height>381</height>
</rect>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>传感器和滤波配置</string>
</attribute>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>353</width>
<height>116</height>
</rect>
</property>
<property name="title">
<string>滤波</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="checkBox_high_pass">
<property name="text">
<string>高通:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_high_pass_low">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="minimum">
<number>3</number>
</property>
<property name="maximum">
<number>3000</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_33">
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_high_pass_high">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="minimum">
<number>3</number>
</property>
<property name="maximum">
<number>3000</number>
</property>
<property name="value">
<number>3000</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_32">
<property name="text">
<string>3 - 3000Hz</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="checkBox_low_pass">
<property name="text">
<string>低通:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_low_pass_low">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_30">
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_low_pass_high">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_29">
<property name="text">
<string>30 - 30000Hz</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="checkBox_band_pass">
<property name="text">
<string>带通:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_band_pass_low">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="minimum">
<number>3</number>
</property>
<property name="maximum">
<number>3000</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_34">
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_band_pass_high">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="minimum">
<number>3</number>
</property>
<property name="maximum">
<number>3000</number>
</property>
<property name="value">
<number>3000</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_35">
<property name="text">
<string>3 - 3000Hz</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="tab_6">
<attribute name="title">
<string>特征值和警报配置</string>
</attribute>
<widget class="QGroupBox" name="groupBox_11">
<property name="geometry">
<rect>
<x>20</x>
<y>10</y>
<width>411</width>
<height>321</height>
</rect>
</property>
<property name="title">
<string> 特征值</string>
</property>
<widget class="QLabel" name="label_71">
<property name="geometry">
<rect>
<x>20</x>
<y>50</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string>直接值</string>
</property>
</widget>
<widget class="QLabel" name="label_72">
<property name="geometry">
<rect>
<x>20</x>
<y>80</y>
<width>81</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>间隙</string>
</property>
</widget>
<widget class="QLabel" name="label_73">
<property name="geometry">
<rect>
<x>141</x>
<y>31</y>
<width>48</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>取值范围</string>
</property>
</widget>
<widget class="QLabel" name="label_74">
<property name="geometry">
<rect>
<x>260</x>
<y>31</y>
<width>61</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string> 默认值</string>
</property>
</widget>
<widget class="QComboBox" name="comboBox_direct_value_range">
<property name="geometry">
<rect>
<x>130</x>
<y>50</y>
<width>111</width>
<height>22</height>
</rect>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>25-0-25 mil</string>
</property>
</item>
<item>
<property name="text">
<string>30-0-30 mil</string>
</property>
</item>
<item>
<property name="text">
<string>40-0-40 mil</string>
</property>
</item>
<item>
<property name="text">
<string>0.5-0-0.5 mm</string>
</property>
</item>
<item>
<property name="text">
<string>1.0-0-1.0 mm</string>
</property>
</item>
<item>
<property name="text">
<string>自定义</string>
</property>
</item>
</widget>
<widget class="QDoubleSpinBox" name="doubleSpinBox_direct_clamp">
<property name="geometry">
<rect>
<x>260</x>
<y>50</y>
<width>62</width>
<height>22</height>
</rect>
</property>
<property name="decimals">
<number>0</number>
</property>
<property name="maximum">
<double>1000.000000000000000</double>
</property>
</widget>
<widget class="QDoubleSpinBox" name="doubleSpinBox_gap_clamp">
<property name="geometry">
<rect>
<x>260</x>
<y>80</y>
<width>62</width>
<height>22</height>
</rect>
</property>
<property name="decimals">
<number>1</number>
</property>
</widget>
<widget class="QComboBox" name="comboBox_gap_range">
<property name="geometry">
<rect>
<x>130</x>
<y>80</y>
<width>111</width>
<height>22</height>
</rect>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>-24 Vdc</string>
</property>
</item>
<item>
<property name="text">
<string>0-100 um</string>
</property>
</item>
<item>
<property name="text">
<string>0-150 um</string>
</property>
</item>
<item>
<property name="text">
<string>0-200 um</string>
</property>
</item>
<item>
<property name="text">
<string>0-400 um</string>
</property>
</item>
<item>
<property name="text">
<string>0-500 um</string>
</property>
</item>
<item>
<property name="text">
<string>自定义</string>
</property>
</item>
</widget>
<widget class="QGroupBox" name="groupBox_12">
<property name="geometry">
<rect>
<x>10</x>
<y>190</y>
<width>221</width>
<height>101</height>
</rect>
</property>
<property name="title">
<string> 延时</string>
</property>
<widget class="QLabel" name="label_78">
<property name="geometry">
<rect>
<x>20</x>
<y>20</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string> 告警</string>
</property>
</widget>
<widget class="QLabel" name="label_79">
<property name="geometry">
<rect>
<x>20</x>
<y>50</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string> 危险</string>
</property>
</widget>
<widget class="QDoubleSpinBox" name="doubleSpinBox_danger">
<property name="geometry">
<rect>
<x>60</x>
<y>50</y>
<width>61</width>
<height>21</height>
</rect>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>1.000000000000000</double>
</property>
<property name="maximum">
<double>99.900000000000006</double>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_100ms">
<property name="geometry">
<rect>
<x>60</x>
<y>80</y>
<width>71</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>100 ms</string>
</property>
</widget>
<widget class="QLabel" name="label_80">
<property name="geometry">
<rect>
<x>130</x>
<y>20</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string>1 - 60s</string>
</property>
</widget>
<widget class="QLabel" name="label_81">
<property name="geometry">
<rect>
<x>130</x>
<y>50</y>
<width>71</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>1.0 - 60.0s</string>
</property>
</widget>
<widget class="QSpinBox" name="spinBox_alert">
<property name="geometry">
<rect>
<x>60</x>
<y>20</y>
<width>61</width>
<height>21</height>
</rect>
</property>
<property name="minimum">
<number>1</number>
</property>
</widget>
</widget>
</widget>
<widget class="QCheckBox" name="checkBox_alert_latching">
<property name="geometry">
<rect>
<x>470</x>
<y>20</y>
<width>131</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>告警锁定</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_danger_latching">
<property name="geometry">
<rect>
<x>470</x>
<y>40</y>
<width>131</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>危险锁定</string>
</property>
</widget>
<widget class="QLabel" name="label_84">
<property name="geometry">
<rect>
<x>460</x>
<y>130</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string>记录输出</string>
</property>
</widget>
<widget class="QComboBox" name="comboBox_recorder_output">
<property name="geometry">
<rect>
<x>460</x>
<y>150</y>
<width>141</width>
<height>22</height>
</rect>
</property>
<item>
<property name="text">
<string>无</string>
</property>
</item>
<item>
<property name="text">
<string>直接幅值</string>
</property>
</item>
<item>
<property name="text">
<string>间隙</string>
</property>
</item>
</widget>
<widget class="QCheckBox" name="checkBox_two_ma_clamp">
<property name="geometry">
<rect>
<x>460</x>
<y>180</y>
<width>91</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>2 mA 默认值</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_timed_ok">
<property name="geometry">
<rect>
<x>470</x>
<y>60</y>
<width>181</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string> Timed OK channel Defeat</string>
</property>
</widget>
</widget>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>21</x>
<y>10</y>
<width>105</width>
<height>17</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_58">
<property name="text">
<string>通道:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_channel">
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_active">
<property name="text">
<string>(启用)</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget_2">
<property name="geometry">
<rect>
<x>20</x>
<y>450</y>
<width>632</width>
<height>37</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPushButton" name="pushButton_confirm">
<property name="minimumSize">
<size>
<width>100</width>
<height>35</height>
</size>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_set_default">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>35</height>
</size>
</property>
<property name="text">
<string>设置为默认值</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_cancel">
<property name="minimumSize">
<size>
<width>100</width>
<height>35</height>
</size>
</property>
<property name="text">
<string>取消</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_print">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>35</height>
</size>
</property>
<property name="text">
<string>打印</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_help">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>35</height>
</size>
</property>
<property name="text">
<string>帮助</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget_3">
<property name="geometry">
<rect>
<x>341</x>
<y>10</y>
<width>63</width>
<height>17</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_57">
<property name="text">
<string>槽位号:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_slot">
<property name="text">
<string>3</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

22
trust_ds.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef TRUST_DS_H
#define TRUST_DS_H
// 位移峰峰值的量程范围
typedef enum {
kDisPP25 = 0, // 25-0-25 mil
kDisPP30 = 1, // 30-0-30 mil
kDisPP40 = 2, // 40-0-40 mil
kDisPP0p5 = 3, // 0.5-0-0.5 mm
kDisPP1p0 = 4, // 1.0-0-1.0 mm
kDisPPCustom = 5 // custom
} DisPPFullScaleRange;
// recorder out
typedef enum {
kDisRecorderOutNone = 0,
kDisRecorderOutDirectAmpl = 1,
kDisRecorderOutGap = 2
} DisRecorderOut;
#endif // TRUST_DS_H