From 7122e9647248c94c9519b72ab9620df40af5b423 Mon Sep 17 00:00:00 2001 From: zhangsheng Date: Thu, 20 Mar 2025 15:06:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=80=9F=E5=BA=A6=E5=92=8C?= =?UTF-8?q?=E4=BD=8D=E7=A7=BB=E8=AF=BB=E5=86=99=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/acceleration_variables.jsonc | 1 + doc/filter.jsonc | 1 + doc/radial_vibration_variables.jsonc | 1 + doc/velocity_variables_filter.jsonc | 1 + radial_vibration.cpp | 283 +++++++ radial_vibration.h | 35 + radial_vibration.ui | 1171 ++++++++++++++++++++++++++ velocity.cpp | 277 ++++++ velocity.h | 36 + velocity.ui | 1119 ++++++++++++++++++++++++ 10 files changed, 2925 insertions(+) create mode 100644 radial_vibration.cpp create mode 100644 radial_vibration.h create mode 100644 radial_vibration.ui create mode 100644 velocity.cpp create mode 100644 velocity.h create mode 100644 velocity.ui diff --git a/doc/acceleration_variables.jsonc b/doc/acceleration_variables.jsonc index 238c16f..4abc311 100644 --- a/doc/acceleration_variables.jsonc +++ b/doc/acceleration_variables.jsonc @@ -1,4 +1,5 @@ { + "version": 1, "slot":1, "id":1, "rms_active":true, diff --git a/doc/filter.jsonc b/doc/filter.jsonc index 86ee443..800bffc 100644 --- a/doc/filter.jsonc +++ b/doc/filter.jsonc @@ -1,4 +1,5 @@ { + "version": 1, "slot":1, "id":1, "filter":[ diff --git a/doc/radial_vibration_variables.jsonc b/doc/radial_vibration_variables.jsonc index 8fa7f4d..ad50349 100644 --- a/doc/radial_vibration_variables.jsonc +++ b/doc/radial_vibration_variables.jsonc @@ -1,4 +1,5 @@ { + "version": 1, "slot":1, "id":1, "variables":[ diff --git a/doc/velocity_variables_filter.jsonc b/doc/velocity_variables_filter.jsonc index b36eede..d040e67 100644 --- a/doc/velocity_variables_filter.jsonc +++ b/doc/velocity_variables_filter.jsonc @@ -1,4 +1,5 @@ { + "version": 1, "slot":1, "id":1, "filter":[ diff --git a/radial_vibration.cpp b/radial_vibration.cpp new file mode 100644 index 0000000..33ff303 --- /dev/null +++ b/radial_vibration.cpp @@ -0,0 +1,283 @@ +#include "radial_vibration.h" +#include "ui_radial_vibration.h" +#include +#include +#include +#include +#include + +Radial_vibration::Radial_vibration(int slot_no_,int channel_,bool active,QWidget *parent) + : QWidget(parent) + , ui(new Ui::Radial_vibration) +{ + 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("(停用)"); + QString filePath_filter = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel); + readJsonFile(filePath_filter); + QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\radial_vibration_variables_%2.json").arg(slot_no).arg(channel); + readJsonFile(filePath_variables); +} + +Radial_vibration::~Radial_vibration() +{ + delete ui; +} +void Radial_vibration::readJsonFile(const QString &filePath) +{ + // 创建文件对象 + QFile file(filePath); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + qDebug() << "Cannot open file for reading:" << filePath; + return; + } + QString content = file.readAll(); + file.close(); + QByteArray jsonData = content.toUtf8(); + QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData); + if (jsonDoc.isNull()) { + qDebug() << "Cannot parse JSON document"; + return; + } + if (!jsonDoc.isObject() && !jsonDoc.isArray()) { + qDebug() << "JSON document is not an object or an array"; + return; + } + QJsonObject json_obj = jsonDoc.object(); + if(filePath.contains("filter_")){ + QJsonArray filter_array = json_obj["filter"].toArray(); + for(int i = 0; i < filter_array.size(); i++){ + QJsonObject temp_obj = filter_array[i].toObject(); + filter[i].type = temp_obj["type"].toString(); + filter[i].low = temp_obj["low"].toInt(); + filter[i].high = temp_obj["high"].toInt(); + filter[i].checked = temp_obj["checked"].toBool(); + } + }else if(filePath.contains("radial_vibration_variables_")){ + QJsonArray variables_array = json_obj["variables"].toArray(); + for(int i = 0; i < variables_array.size(); i++){ + QJsonObject temp_obj = variables_array[i].toObject(); + variables[i].type = temp_obj["type"].toString(); + if(variables[i].type == "direct"){ + variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString(); + variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); + }else if(variables[i].type == "bias_volt"){ + variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); + variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString(); + }else if(variables[i].type == "1x_ampl" || variables[i].type == "2x_ampl"){ + variables[i].checked = temp_obj["checked"].toBool(); + variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString(); + variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); + variables[i].phase_lag = temp_obj["phase_lag"].toDouble(); + }else if(variables[i].type == "not_1x_ampl"){ + variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); + variables[i].checked = temp_obj["checked"].toBool(); + variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString(); + }else if(variables[i].type == "smax_ampl"){ + variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); + variables[i].checked = temp_obj["checked"].toBool(); + variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString(); + } + } + QJsonObject delay_obj = json_obj["delay"].toObject(); + delay.alert = delay_obj["alert"].toInt(); + delay.danger = delay_obj["danger"].toDouble(); + delay.active_100ms = delay_obj["active_100ms"].toBool(); + alert_variables.alert_latching = json_obj["alert_latching"].toBool(); + alert_variables.danger_latching = json_obj["danger_latching"].toBool(); + alert_variables.timed_ok = json_obj["timed_ok"].toBool(); + alert_variables.recorder_output = json_obj["recorder_output"].toString(); + alert_variables.two_ma_clamp = json_obj["two_ma_clamp"].toBool(); + alert_variables.trip_multiply = json_obj["trip_multiply"].toDouble(); + alert_variables.comparision = json_obj["comparision"].toString(); + alert_variables.comparision_percentage = json_obj["comparision_percentage"].toInt(); + } +} + +void Radial_vibration::Init() +{ + for (int i = 0; i < 3; i++) { + if(filter[i].checked){ + if(filter[i].type == "band_pass"){ + ui->checkBox_band_pass->setChecked(filter[i].checked); + ui->spinBox_band_pass_low->setValue(filter[i].low); + ui->spinBox_band_pass_high->setValue(filter[i].high); + }else if(filter[i].type == "low_pass"){ + ui->checkBox_low_pass->setChecked(filter[i].checked); + ui->spinBox_low_pass_low->setValue(filter[i].low); + ui->spinBox_low_pass_high->setValue(filter[i].high); + }else if(filter[i].type == "high_pass"){ + ui->checkBox_high_pass->setChecked(filter[i].checked); + ui->spinBox_high_pass_low->setValue(filter[i].low); + ui->spinBox_high_pass_high->setValue(filter[i].high); + } + } + } + for (int i = 0; i < 6; i++) { + if(variables[i].type == "direct"){ + ui->comboBox_direct_value_range->setCurrentText(variables[i].full_sacle_range); + ui->doubleSpinBox_direct_clamp->setValue(variables[i].clamp_value); + }else if(variables[i].type == "gap"){ + ui->comboBox_gap_range->setCurrentText(variables[i].full_sacle_range); + ui->doubleSpinBox_gap_clamp->setValue(variables[i].clamp_value); + }else if(variables[i].type == "1x_ampl"){ + ui->checkBox_1x_ampl->setCheckable(variables[i].checked); + ui->comboBox_1x_value_range->setCurrentText(variables[i].full_sacle_range); + ui->doubleSpinBox_1x_ampl_clamp->setValue(variables[i].clamp_value); + ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variables[i].phase_lag); + }else if(variables[i].type == "2x_ampl"){ + ui->checkBox_2x_ampl->setCheckable(variables[i].checked); + ui->comboBox_2x_value_range->setCurrentText(variables[i].full_sacle_range); + ui->doubleSpinBox_2x_ampl_clamp->setValue(variables[i].clamp_value); + ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variables[i].phase_lag); + }else if(variables[i].type == "not_1x_ampl"){ + ui->checkBox_not_1x_ampl->setCheckable(variables[i].checked); + ui->comboBox_not_1x_ampl->setCurrentText(variables[i].full_sacle_range); + ui->doubleSpinBox_not_1x_ampl_clamp->setValue(variables[i].clamp_value); + }else if(variables[i].type == "smax_ampl"){ + ui->checkBox_smax_ampl->setCheckable(variables[i].checked); + ui->comboBox_smax_range->setCurrentText(variables[i].full_sacle_range); + ui->doubleSpinBox_smax_clamp->setValue(variables[i].clamp_value); + } + } + ui->spinBox_alert_delay->setValue(delay.alert); + ui->doubleSpinBox_danger_delay->setValue(delay.danger); + ui->checkBox_100ms_delay->setChecked(delay.active_100ms); + ui->checkBox_alert_latching->setChecked(alert_variables.alert_latching); + ui->checkBox_danger_latching->setChecked(alert_variables.danger_latching); + ui->comboBox_recorder_output->setCurrentText(alert_variables.recorder_output); + ui->checkBox_two_ma_clamp->setChecked(alert_variables.two_ma_clamp); + ui->doubleSpinBox_trip_multiply->setValue(alert_variables.trip_multiply); + ui->comboBox_comparision->setCurrentText(alert_variables.comparision); + ui->spinBox_comparision_percentage->setValue(alert_variables.comparision_percentage); +} + +void Radial_vibration::on_pushButton_confirm_clicked() +{ + for (int i = 0; i < 3; i++) { + if(filter[i].checked){ + if(filter[i].type == "band_pass"){ + filter[i].checked = ui->checkBox_band_pass->isChecked(); + filter[i].low = ui->spinBox_band_pass_low->value(); + filter[i].high = ui->spinBox_band_pass_high->value(); + }else if(filter[i].type == "low_pass"){ + filter[i].checked = ui->checkBox_low_pass->isChecked(); + filter[i].low = ui->spinBox_low_pass_low->value(); + filter[i].high = ui->spinBox_low_pass_high->value(); + }else if(filter[i].type == "high_pass"){ + filter[i].checked = ui->checkBox_high_pass->isChecked(); + filter[i].low = ui->spinBox_high_pass_low->value(); + filter[i].high = ui->spinBox_high_pass_high->value(); + } + } + } + for (int i = 0; i < 6; i++) { + if(variables[i].type == "direct"){ + variables[i].full_sacle_range = ui->comboBox_direct_value_range->currentText(); + variables[i].clamp_value = ui->doubleSpinBox_direct_clamp->value(); + }else if(variables[i].type == "gap"){ + variables[i].full_sacle_range = ui->comboBox_gap_range->currentText(); + variables[i].clamp_value = ui->doubleSpinBox_gap_clamp->value(); + }else if(variables[i].type == "1x_ampl"){ + variables[i].checked = ui->checkBox_1x_ampl->isChecked(); + variables[i].full_sacle_range = ui->comboBox_1x_value_range->currentText(); + variables[i].clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value(); + variables[i].phase_lag = ui->doubleSpinBox_1x_phase_lag_clamp->value(); + }else if(variables[i].type == "2x_ampl"){ + variables[i].checked = ui->checkBox_2x_ampl->isChecked(); + variables[i].full_sacle_range = ui->comboBox_2x_value_range->currentText(); + variables[i].clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value(); + variables[i].phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value(); + }else if(variables[i].type == "not_1x_ampl"){ + variables[i].checked = ui->checkBox_not_1x_ampl->isChecked(); + variables[i].full_sacle_range = ui->comboBox_not_1x_ampl->currentText(); + variables[i].clamp_value = ui->doubleSpinBox_not_1x_ampl_clamp->value(); + }else if(variables[i].type == "smax_ampl"){ + variables[i].checked = ui->checkBox_smax_ampl->isChecked(); + variables[i].full_sacle_range = ui->comboBox_smax_range->currentText(); + variables[i].clamp_value = ui->doubleSpinBox_smax_clamp->value(); + } + } + delay.alert = ui->spinBox_alert_delay->value(); + delay.danger = ui->doubleSpinBox_danger_delay->value(); + delay.active_100ms = ui->checkBox_100ms_delay->isChecked(); + alert_variables.alert_latching = ui->checkBox_alert_latching->isChecked(); + alert_variables.danger_latching = ui->checkBox_danger_latching->isChecked(); + alert_variables.recorder_output = ui->comboBox_recorder_output->currentText(); + alert_variables.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked(); + alert_variables.trip_multiply = ui->doubleSpinBox_trip_multiply->value(); + alert_variables.comparision = ui->comboBox_comparision->currentText(); + alert_variables.comparision_percentage = ui->spinBox_comparision_percentage->value(); + QJsonObject filter_obj,variables_obj; + QJsonArray filter_array; + for(int i = 0; i < 3; i++){ + QJsonObject temp_obj; + temp_obj.insert("type",filter[i].type); + temp_obj.insert("low",filter[i].low); + temp_obj.insert("high",filter[i].high); + temp_obj.insert("checked",filter[i].checked); + filter_array.append(temp_obj); + } + filter_obj.insert("filter",filter_array); + filter_obj.insert("slot",slot_no); + filter_obj.insert("id",channel); + QJsonArray variables_array; + for(int i = 0; i < 6; i++){ + QJsonObject temp_obj; + temp_obj.insert("type",variables[i].type); + temp_obj.insert("full_sacle_range",variables[i].full_sacle_range); + temp_obj.insert("bias_voltage",variables[i].bias_voltage); + temp_obj.insert("clamp_value",variables[i].clamp_value); + temp_obj.insert("phase_lag",variables[i].phase_lag); + temp_obj.insert("checked",variables[i].checked); + variables_array.append(temp_obj); + } + variables_obj.insert("variables",variables_array); + QJsonObject delay_obj; + delay_obj.insert("alert",delay.alert); + delay_obj.insert("danger",delay.danger); + delay_obj.insert("100ms",delay.active_100ms); + variables_obj.insert("delay",delay_obj); + variables_obj.insert("alert_latching",alert_variables.alert_latching); + variables_obj.insert("danger_latching",alert_variables.danger_latching); + variables_obj.insert("recorder_output",alert_variables.recorder_output); + variables_obj.insert("two_ma_clamp",alert_variables.two_ma_clamp); + variables_obj.insert("trip_multiply",alert_variables.trip_multiply); + variables_obj.insert("comparision",alert_variables.comparision); + variables_obj.insert("comparision_percentage",alert_variables.comparision_percentage); + variables_obj.insert("slot",slot_no); + variables_obj.insert("id",channel); + QString filePath_filter = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel); + QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\radial_vibration_variables_%2.json").arg(slot_no).arg(channel); + QFile file_filter(filePath_filter); + QFile file_variables(filePath_variables); + if (!file_filter.open(QIODevice::WriteOnly | QIODevice::Text)) { + qDebug() << "Cannot open file for writing:" << filePath_filter; + return; + } + if (!file_variables.open(QIODevice::WriteOnly | QIODevice::Text)) { + qDebug() << "Cannot open file for writing:" << filePath_variables; + return; + } + QJsonDocument jsonDoc_filter(filter_obj); + QJsonDocument jsonDoc_variables(variables_obj); + file_filter.write(jsonDoc_filter.toJson()); + file_variables.write(jsonDoc_variables.toJson()); + file_filter.close(); + file_variables.close(); +} + + +void Radial_vibration::on_pushButton_set_default_clicked() +{ + +} + diff --git a/radial_vibration.h b/radial_vibration.h new file mode 100644 index 0000000..cb3b077 --- /dev/null +++ b/radial_vibration.h @@ -0,0 +1,35 @@ +#ifndef RADIAL_VIBRATION_H +#define RADIAL_VIBRATION_H + +#include +#include "data_config.h" +namespace Ui { +class Radial_vibration; +} + +class Radial_vibration : public QWidget +{ + Q_OBJECT + +public: + explicit Radial_vibration(int slot_no_,int channel_,bool active,QWidget *parent = nullptr); + ~Radial_vibration(); + int slot_no; + int channel; +private slots: + void on_pushButton_confirm_clicked(); + + void on_pushButton_set_default_clicked(); + +private: + Ui::Radial_vibration *ui; + + Filter filter[3]; + Dealy delay; + Variables variables[6]; + Alert_Variables alert_variables; + void readJsonFile(const QString &filePath); + void Init(); +}; + +#endif // RADIAL_VIBRATION_H diff --git a/radial_vibration.ui b/radial_vibration.ui new file mode 100644 index 0000000..914b81d --- /dev/null +++ b/radial_vibration.ui @@ -0,0 +1,1171 @@ + + + Radial_vibration + + + + 0 + 0 + 665 + 570 + + + + 位移配置 + + + + + 10 + 60 + 631 + 451 + + + + 1 + + + + 传感器和滤波配置 + + + + + 10 + 180 + 241 + 131 + + + + 传感器方向 + + + + + 40 + 50 + 61 + 22 + + + + + + + 130 + 50 + 89 + 16 + + + + + + + + + + 130 + 70 + 89 + 16 + + + + + + + + + + 40 + 30 + 54 + 12 + + + + 角度 + + + + + + + 10 + 30 + 353 + 116 + + + + 滤波 + + + + + + + + 高通: + + + + + + + + 60 + 0 + + + + + 60 + 16777215 + + + + 3 + + + 3000 + + + + + + + - + + + + + + + + 60 + 0 + + + + + 60 + 16777215 + + + + 3 + + + 3000 + + + 3000 + + + + + + + 3 - 3000Hz + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + 低通: + + + + + + + + 60 + 0 + + + + + 60 + 16777215 + + + + + + + + - + + + + + + + + 60 + 0 + + + + + 60 + 16777215 + + + + + + + + 30 - 30000Hz + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + 带通: + + + + + + + + 60 + 0 + + + + 3 + + + 3000 + + + + + + + - + + + + + + + + 60 + 0 + + + + 3 + + + 3000 + + + 3000 + + + + + + + 3 - 3000Hz + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + 特征值和警报配置 + + + + + 20 + 10 + 411 + 411 + + + + 特征值 + + + + + 20 + 50 + 54 + 12 + + + + 直接值 + + + + + + 20 + 80 + 81 + 16 + + + + 间隙 + + + + + + 20 + 110 + 81 + 16 + + + + 1倍频幅值 + + + + + + 20 + 180 + 81 + 16 + + + + 2倍频幅值 + + + + + + 141 + 31 + 48 + 16 + + + + 取值范围 + + + + + + 260 + 31 + 61 + 16 + + + + 默认值 + + + + + + 130 + 50 + 111 + 22 + + + + + 0 - 500 um + + + + + + + 260 + 50 + 62 + 22 + + + + + + + 260 + 80 + 62 + 22 + + + + + + + 130 + 110 + 111 + 22 + + + + + 0 - 500 um + + + + + + + 260 + 110 + 62 + 22 + + + + + + + 20 + 150 + 91 + 16 + + + + 1倍频相位 + + + + + + 20 + 210 + 91 + 16 + + + + 2倍频相位 + + + + + + 260 + 150 + 62 + 22 + + + + 0 + + + 100.000000000000000 + + + + + + 260 + 180 + 62 + 22 + + + + + + + 260 + 210 + 62 + 22 + + + + 0 + + + 100.000000000000000 + + + + + + 130 + 180 + 111 + 22 + + + + + 0 - 500 um + + + + + + + 130 + 80 + 111 + 22 + + + + + 0 - 500 um + + + + + + + 20 + 240 + 91 + 16 + + + + 非1倍频幅值 + + + + + + 130 + 240 + 111 + 22 + + + + + 0 - 500 um + + + + + + + 260 + 240 + 62 + 22 + + + + + + + 130 + 270 + 111 + 22 + + + + + 0 - 500 um + + + + + + + 20 + 270 + 91 + 16 + + + + Smax 幅值 + + + + + + 260 + 270 + 62 + 22 + + + + + + + 10 + 300 + 221 + 101 + + + + 延时 + + + + + 20 + 20 + 54 + 12 + + + + 告警 + + + + + + 20 + 50 + 54 + 12 + + + + 危险 + + + + + + 60 + 50 + 61 + 21 + + + + 1 + + + 1.000000000000000 + + + 99.900000000000006 + + + + + + 60 + 80 + 71 + 16 + + + + 100 ms + + + + + + 130 + 20 + 54 + 12 + + + + 1 - 60s + + + + + + 130 + 50 + 71 + 16 + + + + 1.0 - 60.0s + + + + + + 60 + 20 + 61 + 21 + + + + 1 + + + + + + + + 470 + 20 + 131 + 16 + + + + 告警锁定 + + + + + + 470 + 40 + 131 + 16 + + + + 危险锁定 + + + + + + 460 + 220 + 121 + 16 + + + + 倍增 + + + + + + 460 + 240 + 62 + 16 + + + + 1.000000000000000 + + + + + + 460 + 260 + 141 + 16 + + + + 1.00 - 3.00 (步进0.25) + + + + + + 460 + 130 + 54 + 12 + + + + 记录输出 + + + + + + 460 + 150 + 141 + 22 + + + + + None + + + + + 直接值 + + + + + 间隙 + + + + + 1倍频幅值 + + + + + 1倍频相位 + + + + + 2倍频幅值 + + + + + 2倍频相位 + + + + + 非1倍频幅值 + + + + + Smax幅值 + + + + + + + 460 + 180 + 91 + 16 + + + + 2 mA 默认值 + + + true + + + + + + 460 + 290 + 121 + 16 + + + + 比较 + + + + + + 530 + 360 + 54 + 12 + + + + % + + + + + + 460 + 310 + 141 + 22 + + + + + None + + + + + 直接值 + + + + + 间隙 + + + + + 1倍频幅值 + + + + + 1倍频相位 + + + + + 2倍频幅值 + + + + + 2倍频相位 + + + + + 非1倍频幅值 + + + + + Smax幅值 + + + + + + + 460 + 350 + 61 + 22 + + + + + + + + + 21 + 10 + 105 + 17 + + + + + + + 通道: + + + + + + + 1 + + + + + + + (启用) + + + + + + + + + 341 + 10 + 63 + 17 + + + + + + + 槽位号: + + + + + + + 3 + + + + + + + + + 13 + 521 + 632 + 37 + + + + + + + + 100 + 35 + + + + 确定 + + + + + + + + 100 + 35 + + + + 设置为默认值 + + + + + + + + 100 + 35 + + + + 测点名称 + + + + + + + + 100 + 35 + + + + 取消 + + + + + + + + 100 + 35 + + + + 打印 + + + + + + + + 100 + 35 + + + + 帮助 + + + + + + + + + diff --git a/velocity.cpp b/velocity.cpp new file mode 100644 index 0000000..25a34ed --- /dev/null +++ b/velocity.cpp @@ -0,0 +1,277 @@ +#include "velocity.h" +#include "ui_velocity.h" +#include +#include +#include +#include +#include + +Velocity::Velocity(int slot_no_,int channel_,bool active,QWidget *parent) + : QWidget(parent) + , ui(new Ui::Velocity) +{ + 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("(停用)"); + QString filePath_filter = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel); + readJsonFile(filePath_filter); + QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\acceleration_variables_%2.json").arg(slot_no).arg(channel); + readJsonFile(filePath_variables); + Init(); +} + +Velocity::~Velocity() +{ + delete ui; +} +void Velocity::readJsonFile(const QString &filePath) +{ + // 创建文件对象 + QFile file(filePath); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + qDebug() << "Cannot open file for reading:" << filePath; + return; + } + QString content = file.readAll(); + file.close(); + QByteArray jsonData = content.toUtf8(); + QJsonDocument jsonDoc = QJsonDocument::fromJson(jsonData); + if (jsonDoc.isNull()) { + qDebug() << "Cannot parse JSON document"; + return; + } + if (!jsonDoc.isObject() && !jsonDoc.isArray()) { + qDebug() << "JSON document is not an object or an array"; + return; + } + QJsonObject json_obj = jsonDoc.object(); + if(filePath.contains("filter_")){ + QJsonArray filter_array = json_obj["filter"].toArray(); + for(int i = 0; i < filter_array.size(); i++){ + QJsonObject temp_obj = filter_array[i].toObject(); + filter[i].type = temp_obj["type"].toString(); + filter[i].low = temp_obj["low"].toInt(); + filter[i].high = temp_obj["high"].toInt(); + filter[i].checked = temp_obj["checked"].toBool(); + } + }else if(filePath.contains("acceleration_variables_")){ + + QJsonArray variables_array = json_obj["variables"].toArray(); + for(int i = 0; i < variables_array.size(); i++){ + QJsonObject temp_obj = variables_array[i].toObject(); + variables[i].type = temp_obj["type"].toString(); + if(variables[i].type == "direct"){ + variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString(); + variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); + }else if(variables[i].type == "bias_volt"){ + variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); + }else if(variables[i].type == "1x_ampl"){ + variables[i].checked = temp_obj["checked"].toBool(); + variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString(); + variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); + variables[i].phase_lag = temp_obj["phase_lag"].toDouble(); + }else if(variables[i].type == "2x_ampl"){ + variables[i].checked = temp_obj["checked"].toBool(); + variables[i].full_sacle_range = temp_obj["full_sacle_range"].toString(); + variables[i].clamp_value = temp_obj["clamp_value"].toDouble(); + variables[i].phase_lag = temp_obj["phase_lag"].toDouble(); + } + } + QJsonObject delay_obj = json_obj["delay"].toObject(); + delay.alert = delay_obj["alert"].toInt(); + delay.danger = delay_obj["danger"].toDouble(); + delay.active_100ms = delay_obj["100ms"].toBool(); + alert_variables.rms_active = json_obj["rms_active"].toBool(); + alert_variables.integrate_active = json_obj["integrate_active"].toBool(); + alert_variables.alert_latching = json_obj["alert_latching"].toBool(); + alert_variables.danger_latching = json_obj["danger_latching"].toBool(); + alert_variables.timed_ok = json_obj["timed_ok"].toBool(); + alert_variables.recorder_output = json_obj["recorder_output"].toString(); + alert_variables.two_ma_clamp = json_obj["two_ma_clamp"].toBool(); + alert_variables.trip_multiply = json_obj["trip_multiply"].toDouble(); + alert_variables.comparision = json_obj["comparision"].toString(); + alert_variables.comparision_percentage = json_obj["comparision_percentage"].toInt(); + } +} +void Velocity::Init() +{ + for (int i = 0; i < 3; i++) { + if(filter[i].checked){ + if(filter[i].type == "band_pass"){ + ui->checkBox_band_pass->setChecked(filter[i].checked); + ui->spinBox_band_pass_low->setValue(filter[i].low); + ui->spinBox_band_pass_high->setValue(filter[i].high); + }else if(filter[i].type == "low_pass"){ + ui->checkBox_low_pass->setChecked(filter[i].checked); + ui->spinBox_low_pass_low->setValue(filter[i].low); + ui->spinBox_low_pass_high->setValue(filter[i].high); + }else if(filter[i].type == "high_pass"){ + ui->checkBox_high_pass->setChecked(filter[i].checked); + ui->spinBox_high_pass_low->setValue(filter[i].low); + ui->spinBox_high_pass_high->setValue(filter[i].high); + } + } + } + for (int i = 0; i < 4; i++) { + if(variables[i].type == "direct"){ + ui->comboBox_direct_value_range->setCurrentText(variables[i].full_sacle_range); + ui->doubleSpinBox_direct_clamp->setValue(variables[i].clamp_value); + }else if(variables[i].type == "bias_volt"){ + ui->label_bias_voltage->setText(QString::number(variables[i].bias_voltage)); + ui->doubleSpinBox_bias_volt_clamp->setValue(variables[i].clamp_value); + }else if(variables[i].type == "1x_ampl"){ + ui->checkBox_1x_ampl->setChecked(variables[i].checked); + ui->comboBox_1x_value_range->setCurrentText(variables[i].full_sacle_range); + ui->doubleSpinBox_1x_ampl_clamp->setValue(variables[i].clamp_value); + ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variables[i].phase_lag); + }else if(variables[i].type == "2x_ampl"){ + ui->checkBox_2x_ampl->setChecked(variables[i].checked); + ui->comboBox_2x_value_range->setCurrentText(variables[i].full_sacle_range); + ui->doubleSpinBox_2x_ampl_clamp->setValue(variables[i].clamp_value); + ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variables[i].phase_lag); + } + } + ui->spinBox_alert->setValue(delay.alert); + ui->doubleSpinBox_danger->setValue(delay.danger); + ui->checkBox_100ms->setChecked(delay.active_100ms); + ui->checkBox_alert_latching->setChecked(alert_variables.alert_latching); + ui->checkBox_danger_latching->setChecked(alert_variables.danger_latching); + ui->checkBox_timed_ok->setChecked(alert_variables.timed_ok); + ui->comboBox_recorder_output->setCurrentText(alert_variables.recorder_output); + ui->checkBox_two_ma_clamp->setChecked(alert_variables.two_ma_clamp); + ui->doubleSpinBox_trip_multiply->setValue(alert_variables.trip_multiply); + ui->comboBox_comparision->setCurrentText(alert_variables.comparision); + ui->spinBox_comparision_percentage->setValue(alert_variables.comparision_percentage); + +} +void Velocity::on_pushButton_confirm_clicked() +{ + for (int i = 0; i < 3; i++) { + if(filter[i].type == "band_pass"){ + filter[i].checked = ui->checkBox_band_pass->isChecked(); + filter[i].low = ui->spinBox_band_pass_low->value(); + filter[i].high = ui->spinBox_band_pass_high->value(); + }else if(filter[i].type == "low_pass"){ + filter[i].checked = ui->checkBox_low_pass->isChecked(); + filter[i].low = ui->spinBox_low_pass_low->value(); + filter[i].high = ui->spinBox_low_pass_high->value(); + }else if(filter[i].type == "high_pass"){ + filter[i].checked = ui->checkBox_high_pass->isChecked(); + filter[i].low = ui->spinBox_high_pass_low->value(); + filter[i].high = ui->spinBox_high_pass_high->value(); + } + } + for (int i = 0; i < 4; i++) { + if(variables[i].type == "direct"){ + variables[i].full_sacle_range = ui->comboBox_direct_value_range->currentText(); + variables[i].clamp_value = ui->doubleSpinBox_direct_clamp->value(); + }else if(variables[i].type == "bias_volt"){ + variables[i].clamp_value = ui->doubleSpinBox_bias_volt_clamp->value(); + }else if(variables[i].type == "1x_ampl"){ + variables[i].checked = ui->checkBox_1x_ampl->isChecked(); + variables[i].full_sacle_range = ui->comboBox_1x_value_range->currentText(); + variables[i].clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value(); + variables[i].phase_lag = ui->doubleSpinBox_1x_phase_lag_clamp->value(); + }else if(variables[i].type == "2x_ampl"){ + variables[i].checked = ui->checkBox_2x_ampl->isChecked(); + variables[i].full_sacle_range = ui->comboBox_2x_value_range->currentText(); + variables[i].clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value(); + variables[i].phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value(); + } + } + delay.alert = ui->spinBox_alert->value(); + delay.danger = ui->doubleSpinBox_danger->value(); + delay.active_100ms = ui->checkBox_100ms->isChecked(); + alert_variables.alert_latching = ui->checkBox_alert_latching->isChecked(); + alert_variables.danger_latching = ui->checkBox_danger_latching->isChecked(); + alert_variables.timed_ok = ui->checkBox_timed_ok->isChecked(); + alert_variables.recorder_output = ui->comboBox_recorder_output->currentText(); + alert_variables.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked(); + alert_variables.trip_multiply = ui->doubleSpinBox_trip_multiply->value(); + alert_variables.comparision = ui->comboBox_comparision->currentText(); + alert_variables.comparision_percentage = ui->spinBox_comparision_percentage->value(); + // 保存到文件 + QString filePath_filter = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel); + QJsonObject filter_obj; + QJsonArray filter_array; + for(int i = 0; i < 3; i++){ + QJsonObject temp_obj; + temp_obj.insert("type",filter[i].type); + temp_obj.insert("low",filter[i].low); + temp_obj.insert("high",filter[i].high); + temp_obj.insert("checked",filter[i].checked); + filter_array.append(temp_obj); + } + filter_obj.insert("filter",filter_array); + QJsonDocument filter_doc; + filter_doc.setObject(filter_obj); + QByteArray filter_data = filter_doc.toJson(); + QFile filter_file(filePath_filter); + if (!filter_file.open(QIODevice::WriteOnly | QIODevice::Text)) { + qDebug() << "Cannot open file for writing:" << filePath_filter; + return; + } + filter_file.write(filter_data); + filter_file.close(); + QString filePath_variables = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\acceleration_variables_%2.json").arg(slot_no).arg(channel); + QJsonObject variables_obj; + QJsonArray variables_array; + for(int i = 0; i < 4; i++){ + QJsonObject temp_obj; + temp_obj.insert("type",variables[i].type); + if(variables[i].type == "direct"){ + temp_obj.insert("full_sacle_range",variables[i].full_sacle_range); + temp_obj.insert("clamp_value",variables[i].clamp_value); + }else if(variables[i].type == "bias_volt"){ + temp_obj.insert("clamp_value",variables[i].clamp_value); + }else if(variables[i].type == "1x_ampl"){ + temp_obj.insert("checked",variables[i].checked); + temp_obj.insert("full_sacle_range",variables[i].full_sacle_range); + temp_obj.insert("clamp_value",variables[i].clamp_value); + temp_obj.insert("phase_lag",variables[i].phase_lag); + }else if(variables[i].type == "2x_ampl"){ + temp_obj.insert("checked",variables[i].checked); + temp_obj.insert("full_sacle_range",variables[i].full_sacle_range); + temp_obj.insert("clamp_value",variables[i].clamp_value); + temp_obj.insert("phase_lag",variables[i].phase_lag); + } + variables_array.append(temp_obj); + } + variables_obj.insert("variables",variables_array); + QJsonObject delay_obj; + delay_obj.insert("alert",delay.alert); + delay_obj.insert("danger",delay.danger); + delay_obj.insert("100ms",delay.active_100ms); + variables_obj.insert("delay",delay_obj); + variables_obj.insert("rms_active",alert_variables.rms_active); + variables_obj.insert("integrate_active",alert_variables.integrate_active); + variables_obj.insert("alert_latching",alert_variables.alert_latching); + variables_obj.insert("danger_latching",alert_variables.danger_latching); + variables_obj.insert("timed_ok",alert_variables.timed_ok); + variables_obj.insert("recorder_output",alert_variables.recorder_output); + variables_obj.insert("two_ma_clamp",alert_variables.two_ma_clamp); + variables_obj.insert("trip_multiply",alert_variables.trip_multiply); + variables_obj.insert("comparision",alert_variables.comparision); + variables_obj.insert("comparision_percentage",alert_variables.comparision_percentage); + variables_obj.insert("slot",slot_no); + variables_obj.insert("channel",channel); + QJsonDocument variables_doc; + variables_doc.setObject(variables_obj); + QByteArray variables_data = variables_doc.toJson(); + QFile variables_file(filePath_variables); + if (!variables_file.open(QIODevice::WriteOnly | QIODevice::Text)) { + qDebug() << "Cannot open file for writing:" << filePath_variables; + return; + } + variables_file.write(variables_data); + variables_file.close(); +} + diff --git a/velocity.h b/velocity.h new file mode 100644 index 0000000..b2a176a --- /dev/null +++ b/velocity.h @@ -0,0 +1,36 @@ +#ifndef VELOCITY_H +#define VELOCITY_H + +#include +#include "data_config.h" + +namespace Ui { +class Velocity; +} + +class Velocity : public QWidget +{ + Q_OBJECT + +public: + explicit Velocity(int slot_no_,int channel_,bool active,QWidget *parent = nullptr); + ~Velocity(); + int slot_no; + int channel; + +private slots: + void on_pushButton_confirm_clicked(); + +private: + Ui::Velocity *ui; + + Filter filter[3]; + Dealy delay; + Variables variables[4]; + Alert_Variables alert_variables; + + void readJsonFile(const QString &filePath); + void Init(); +}; + +#endif // VELOCITY_H diff --git a/velocity.ui b/velocity.ui new file mode 100644 index 0000000..501a7f3 --- /dev/null +++ b/velocity.ui @@ -0,0 +1,1119 @@ + + + Velocity + + + + 0 + 0 + 754 + 582 + + + + 速度配置 + + + + + 10 + 90 + 671 + 401 + + + + 1 + + + + 滤波配置 + + + + + 10 + 10 + 353 + 116 + + + + 滤波 + + + + + + + + 高通: + + + + + + + + 60 + 0 + + + + + 60 + 16777215 + + + + 3 + + + 3000 + + + + + + + - + + + + + + + + 60 + 0 + + + + + 60 + 16777215 + + + + 3 + + + 3000 + + + 3000 + + + + + + + 3 - 3000Hz + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + 低通: + + + + + + + + 60 + 0 + + + + + 60 + 16777215 + + + + + + + + - + + + + + + + + 60 + 0 + + + + + 60 + 16777215 + + + + + + + + 30 - 30000Hz + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + 带通: + + + + + + + + 60 + 0 + + + + 3 + + + 3000 + + + + + + + - + + + + + + + + 60 + 0 + + + + 3 + + + 3000 + + + 3000 + + + + + + + 3 - 3000Hz + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + 特征值和警报配置 + + + + + 10 + 10 + 431 + 351 + + + + 特征值 + + + + + 20 + 50 + 54 + 12 + + + + 直接值 + + + + + + 10 + 80 + 81 + 16 + + + + 偏置电压 + + + + + + 20 + 110 + 81 + 16 + + + + 1倍频幅值 + + + + + + 20 + 180 + 81 + 16 + + + + 2倍频幅值 + + + + + + 141 + 31 + 48 + 16 + + + + 取值范围 + + + + + + 269 + 31 + 48 + 16 + + + + 默认值 + + + + + + 130 + 50 + 111 + 22 + + + + + 0 - 20 mm/s + + + + + + + 260 + 50 + 62 + 22 + + + + + + + 130 + 80 + 54 + 12 + + + + -24 + + + + + + 260 + 80 + 62 + 22 + + + + 1 + + + + + + 130 + 110 + 111 + 22 + + + + + 0 - 20 mm/s + + + + + + + 260 + 110 + 62 + 22 + + + + + + + 20 + 150 + 91 + 16 + + + + 1倍频相位 + + + + + + 20 + 210 + 91 + 16 + + + + 2倍频相位 + + + + + + 260 + 150 + 62 + 22 + + + + 0 + + + + + + 260 + 180 + 62 + 22 + + + + + + + 260 + 210 + 62 + 22 + + + + 0 + + + + + + 130 + 180 + 111 + 22 + + + + + 0 - 20 mm/s + + + + + + + 20 + 250 + 71 + 16 + + + + 有效值 + + + + + + 130 + 250 + 71 + 16 + + + + 积分 + + + + + + 200 + 240 + 221 + 101 + + + + 延时 + + + + + 20 + 20 + 54 + 12 + + + + 告警 + + + + + + 20 + 50 + 54 + 12 + + + + 危险 + + + + + + 60 + 50 + 61 + 21 + + + + 1 + + + 1.000000000000000 + + + + + + 60 + 80 + 71 + 16 + + + + 100 ms + + + + + + 130 + 20 + 54 + 12 + + + + 1 - 60s + + + + + + 130 + 50 + 71 + 16 + + + + 1.0 - 60.0s + + + + + + 60 + 20 + 61 + 21 + + + + 1 + + + + + + + 170 + 80 + 53 + 15 + + + + Vdc + + + + + + + 460 + 20 + 131 + 16 + + + + 告警锁定 + + + true + + + + + + 460 + 40 + 131 + 16 + + + + 危险锁定 + + + true + + + + + + 460 + 190 + 121 + 16 + + + + 倍增 + + + + + + 460 + 210 + 62 + 16 + + + + 1.000000000000000 + + + + + + 460 + 230 + 141 + 16 + + + + 1.00 - 3.00 (步进0.25) + + + + + + 460 + 110 + 54 + 12 + + + + 记录输出 + + + + + + 460 + 130 + 141 + 22 + + + + + None + + + + + 直接值 + + + + + 偏置电压 + + + + + 1倍频幅值 + + + + + 1倍频相位 + + + + + 2倍频幅值 + + + + + 2倍频相位 + + + + + + + 460 + 160 + 101 + 16 + + + + 2 mA 默认值 + + + true + + + + + + 460 + 80 + 181 + 16 + + + + Timed OK channel Defeat + + + + + + 460 + 60 + 131 + 16 + + + + 非正常锁定 + + + + + + 460 + 260 + 121 + 16 + + + + 比较 + + + + + + 460 + 280 + 141 + 22 + + + + + None + + + + + 直接值 + + + + + 偏置电压 + + + + + 1倍频幅值 + + + + + 1倍频相位 + + + + + 2倍频幅值 + + + + + 2倍频相位 + + + + + + + 460 + 320 + 61 + 22 + + + + + + + 530 + 330 + 54 + 12 + + + + % + + + + + + + + 21 + 10 + 105 + 17 + + + + + + + 通道: + + + + + + + 1 + + + + + + + (启用) + + + + + + + + + 341 + 10 + 63 + 17 + + + + + + + 槽位号: + + + + + + + 3 + + + + + + + + + 11 + 531 + 100 + 35 + + + + + 100 + 35 + + + + 确定 + + + + + + 117 + 531 + 100 + 35 + + + + + 100 + 35 + + + + 设置为默认值 + + + + + + 223 + 531 + 100 + 35 + + + + + 100 + 35 + + + + 加载预定义模板 + + + + + + 329 + 531 + 100 + 35 + + + + + 100 + 35 + + + + 测点名称 + + + + + + 435 + 531 + 100 + 35 + + + + + 100 + 35 + + + + 取消 + + + + + + 541 + 531 + 100 + 35 + + + + + 100 + 35 + + + + 打印 + + + + + + 647 + 531 + 100 + 35 + + + + + 100 + 35 + + + + 帮助 + + + + + +