添加setpoint

This commit is contained in:
zhangsheng 2025-04-16 13:55:32 +08:00
parent ac94c60151
commit 64f60fe3af
9 changed files with 78 additions and 632 deletions

View File

@ -64,6 +64,19 @@ void ConfigMgr::Save() {
voltage_range.append(ptr->base_config_[cid].normal_voltage_low);
voltage_range.append(ptr->base_config_[cid].normal_voltage_high);
channel_item["normal_voltage_range"] = voltage_range;
QJsonObject setpoint_data;
setpoint_data["direct_upper"] = ptr->vib_alert_danger[cid].direct_upper;
setpoint_data["direct_enable"] = ptr->vib_alert_danger[cid].direct_enable;
setpoint_data["1x_ampl_upper"] = ptr->vib_alert_danger[cid].x1_ampl_upper;
setpoint_data["1x_ampl_lower"] = ptr->vib_alert_danger[cid].x1_ampl_lower;
setpoint_data["1x_ampl_enable"] = ptr->vib_alert_danger[cid].x1_ampl_enable;
setpoint_data["2x_ampl_upper"] = ptr->vib_alert_danger[cid].x2_ampl_upper;
setpoint_data["2x_ampl_lower"] = ptr->vib_alert_danger[cid].x2_ampl_lower;
setpoint_data["2x_ampl_enable"] = ptr->vib_alert_danger[cid].x2_ampl_enable;
setpoint_data["danger_param"] = ptr->vib_alert_danger[cid].danger_param;
setpoint_data["danger_upper"] = ptr->vib_alert_danger[cid].danger_upper;
setpoint_data["danger_enable"] = ptr->vib_alert_danger[cid].danger_enable;
channel_item["setpoint"] = setpoint_data;
// variables
QJsonObject variables;
std::shared_ptr<VariableBase> base_channel_ptr = ptr->GetChannelPtr(cid + 1);
@ -226,6 +239,7 @@ void ConfigMgr::Save() {
channel_item.insert("normal_latching", ptr->variables_[cid].normal_latching);
channel_item.insert("speed_peak", ptr->variables_[cid].speed_peek);
channel_item.insert("default_speed", ptr->variables_[cid].default_speed);
} else if (card_type_[i] == kCardKeyphaseSingle) {
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot);
if (base_ptr == nullptr) {
@ -324,6 +338,19 @@ void ConfigMgr::Load(QString filename) {
vib_data->base_config_[j].normal_voltage_low = voltage_range_array[0].toDouble();
vib_data->base_config_[j].normal_voltage_high = voltage_range_array[1].toDouble();
vib_data->base_config_[j].power = channel["power"].toBool();
//setpoint
QJsonObject setpoint_data = channel["setpoint"].toObject();
vib_data->vib_alert_danger[j].direct_upper = setpoint_data["direct_upper"].toDouble();
vib_data->vib_alert_danger[j].direct_enable = setpoint_data["direct_enable"].toBool();
vib_data->vib_alert_danger[j].x1_ampl_upper = setpoint_data["1x_ampl_upper"].toDouble();
vib_data->vib_alert_danger[j].x1_ampl_lower = setpoint_data["1x_ampl_lower"].toDouble();
vib_data->vib_alert_danger[j].x1_ampl_enable = setpoint_data["1x_ampl_enable"].toBool();
vib_data->vib_alert_danger[j].x2_ampl_upper = setpoint_data["2x_ampl_upper"].toDouble();
vib_data->vib_alert_danger[j].x2_ampl_lower = setpoint_data["2x_ampl_lower"].toDouble();
vib_data->vib_alert_danger[j].x2_ampl_enable = setpoint_data["2x_ampl_enable"].toBool();
vib_data->vib_alert_danger[j].danger_param = setpoint_data["danger_param"].toInt();
vib_data->vib_alert_danger[j].danger_upper = setpoint_data["danger_upper"].toDouble();
vib_data->vib_alert_danger[j].danger_enable = setpoint_data["danger_enable"].toBool();
// variables
QJsonObject tmp_variable = channel["variable"].toObject();
switch (vib_data->base_config_[j].channel_type) {

View File

@ -217,6 +217,39 @@ typedef struct {
double scale_factor;
} Transducer;
typedef struct VibAlertDanger_{
float direct_upper;
bool direct_enable;
float x1_ampl_upper;
float x1_ampl_lower;
bool x1_ampl_enable;
float x2_ampl_upper;
float x2_ampl_lower;
bool x2_ampl_enable;
int danger_param; //0 直接值1 1倍频幅值2 2倍频幅值
float danger_upper;
bool danger_enable;
VibAlertDanger_(){
direct_enable = false;
x1_ampl_enable = false;
x2_ampl_enable = false;
danger_enable = false;
}
} VibAlertDanger;
typedef struct{
float speed_upper;
float speed_lower;
bool speed_upper_enable;
bool speed_lower_enable;
float speed_bnd_upper;
float speed_bnd_lower;
bool speed_bnd_enable;
float danger_speed_upper;
float danger_speed_lower;
bool danger_speed_upper_enable;
bool danger_speed_lower_enable;
} SpeedAlert;
#pragma pack(1)
typedef struct {

View File

@ -434,8 +434,8 @@ void MainWindow::OnButtonGroup(QAbstractButton *slot_btn) {
}
if (slot_btn != NULL && ui->pushButton_alarm->isChecked()) {
QString object_name = slot_btn->objectName();
qDebug() << object_name ;
Setpoint *setpoint = new Setpoint();
int button_id = object_name.right(object_name.length() - 15).toInt();
Setpoint *setpoint = new Setpoint(button_id,ConfigMgr::Instance()->card_type_[button_id]);
setpoint->setWindowModality(Qt::ApplicationModal);
setpoint->show();
}

View File

@ -1128,10 +1128,11 @@
<property name="title">
<string>文件</string>
</property>
<addaction name="actionNEW"/>
<addaction name="actionOpen"/>
<addaction name="actiondaoru"/>
<addaction name="actionlianjie"/>
<addaction name="action_new"/>
<addaction name="action_open"/>
<addaction name="action_import"/>
<addaction name="action_connect"/>
<addaction name="action_disconnect"/>
</widget>
<widget class="QMenu" name="menu_2">
<property name="title">
@ -1150,12 +1151,12 @@
<addaction name="menu_tool"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionNEW">
<action name="action_new">
<property name="text">
<string>新建</string>
</property>
</action>
<action name="actionOpen">
<action name="action_open">
<property name="text">
<string>打开</string>
</property>
@ -1170,16 +1171,21 @@
<string>校时功能</string>
</property>
</action>
<action name="actiondaoru">
<action name="action_import">
<property name="text">
<string>保存</string>
</property>
</action>
<action name="actionlianjie">
<action name="action_connect">
<property name="text">
<string>连接</string>
</property>
</action>
<action name="action_disconnect">
<property name="text">
<string>断开</string>
</property>
</action>
</widget>
<resources/>
<connections/>

View File

@ -1,70 +0,0 @@
#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()
{
delete ui;
}

View File

@ -1,22 +0,0 @@
#ifndef setpoint_H
#define setpoint_H
#include <QWidget>
namespace Ui {
class Setpoint;
}
class Setpoint : public QWidget
{
Q_OBJECT
public:
explicit Setpoint(QWidget *parent = nullptr);
~Setpoint();
private:
Ui::Setpoint *ui;
};
#endif // setpoint_H

View File

@ -1,530 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Setpoint</class>
<widget class="QWidget" name="Setpoint">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>722</width>
<height>560</height>
</rect>
</property>
<property name="windowTitle">
<string>触发配置</string>
</property>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>540</x>
<y>10</y>
<width>161</width>
<height>451</height>
</rect>
</property>
<property name="title">
<string>危险 / 警报 2</string>
</property>
<widget class="QComboBox" name="comboBox_4">
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>69</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QComboBox" name="comboBox_5">
<property name="geometry">
<rect>
<x>80</x>
<y>30</y>
<width>69</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_19">
<property name="geometry">
<rect>
<x>20</x>
<y>72</y>
<width>36</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>mil pp</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_danger">
<property name="geometry">
<rect>
<x>20</x>
<y>415</y>
<width>47</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>启用</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_danger_upper">
<property name="geometry">
<rect>
<x>12</x>
<y>90</y>
<width>50</width>
<height>20</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
</widget>
<widget class="QWidget" name="widget_danger" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>116</y>
<width>80</width>
<height>260</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>260</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>260</height>
</size>
</property>
</widget>
</widget>
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>520</y>
<width>119</width>
<height>22</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_20">
<property name="text">
<string>槽位号2</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_6">
<item>
<property name="text">
<string>通道 1</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
<widget class="QToolButton" name="toolButton_5">
<property name="geometry">
<rect>
<x>500</x>
<y>520</y>
<width>61</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>帮助</string>
</property>
</widget>
<widget class="QToolButton" name="toolButton_4">
<property name="geometry">
<rect>
<x>420</x>
<y>520</y>
<width>61</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>打印</string>
</property>
</widget>
<widget class="QToolButton" name="toolButton_2">
<property name="geometry">
<rect>
<x>260</x>
<y>520</y>
<width>61</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>521</width>
<height>451</height>
</rect>
</property>
<property name="title">
<string>告警 / 警报 1</string>
</property>
<widget class="QWidget" name="widget_1x_ampl" native="true">
<property name="geometry">
<rect>
<x>100</x>
<y>110</y>
<width>80</width>
<height>260</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>260</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>260</height>
</size>
</property>
</widget>
<widget class="QLabel" name="label_27">
<property name="geometry">
<rect>
<x>121</x>
<y>41</y>
<width>54</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>1倍频幅值</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_1x_ampl_upper">
<property name="geometry">
<rect>
<x>121</x>
<y>77</y>
<width>50</width>
<height>20</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
</widget>
<widget class="QLabel" name="label_25">
<property name="geometry">
<rect>
<x>130</x>
<y>59</y>
<width>36</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>mil pp</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_1x_ampl_lower">
<property name="geometry">
<rect>
<x>120</x>
<y>380</y>
<width>50</width>
<height>20</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_1x_ampl">
<property name="geometry">
<rect>
<x>121</x>
<y>420</y>
<width>47</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>启用</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_2x_ampl">
<property name="geometry">
<rect>
<x>221</x>
<y>420</y>
<width>47</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>启用</string>
</property>
</widget>
<widget class="QLabel" name="label_32">
<property name="geometry">
<rect>
<x>221</x>
<y>41</y>
<width>54</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>2倍频幅值</string>
</property>
</widget>
<widget class="QLabel" name="label_31">
<property name="geometry">
<rect>
<x>230</x>
<y>59</y>
<width>36</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>mil pp</string>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_2x_ampl_upper">
<property name="geometry">
<rect>
<x>221</x>
<y>77</y>
<width>50</width>
<height>20</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
</widget>
<widget class="QWidget" name="widget_2x_ampl" native="true">
<property name="geometry">
<rect>
<x>200</x>
<y>110</y>
<width>80</width>
<height>260</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>260</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>260</height>
</size>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_2x_ampl_lower">
<property name="geometry">
<rect>
<x>220</x>
<y>380</y>
<width>50</width>
<height>20</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit_direct_upper">
<property name="geometry">
<rect>
<x>30</x>
<y>80</y>
<width>50</width>
<height>20</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>16777215</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QWidget" name="widget_direct" native="true">
<property name="geometry">
<rect>
<x>10</x>
<y>107</y>
<width>80</width>
<height>260</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>80</width>
<height>260</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>260</height>
</size>
</property>
</widget>
<widget class="QLabel" name="label_21">
<property name="geometry">
<rect>
<x>40</x>
<y>40</y>
<width>36</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>直接值</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_22">
<property name="geometry">
<rect>
<x>40</x>
<y>60</y>
<width>36</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>mil pp</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_direct">
<property name="geometry">
<rect>
<x>30</x>
<y>420</y>
<width>65</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>启用</string>
</property>
</widget>
</widget>
<widget class="QToolButton" name="toolButton_3">
<property name="geometry">
<rect>
<x>340</x>
<y>520</y>
<width>61</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>取消</string>
</property>
</widget>
<widget class="QToolButton" name="toolButton">
<property name="geometry">
<rect>
<x>180</x>
<y>520</y>
<width>61</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>复制</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -8,6 +8,7 @@ class TachometerData : public CardBase {
TachometerData();
TachometerVariables variables_[4];
SpeedAlert speed_alert;
};
#endif // TACHOMETERDATA_H

View File

@ -12,6 +12,7 @@ class VibrationData : public CardBase {
void RemoveChannel(int cid);
SeismicMonitor base_config_[CHANNEL_COUNT];
std::vector<std::shared_ptr<VariableBase>> variables_;
VibAlertDanger vib_alert_danger[CHANNEL_COUNT];
};
#endif // VIBRATIONDATA_H