TSI_Config/radial_vibration.cpp

301 lines
17 KiB
C++
Raw Normal View History

2025-03-20 15:06:41 +08:00
#include "radial_vibration.h"
#include "ui_radial_vibration.h"
#include <QFile>
#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
2025-04-01 18:19:59 +08:00
#include "data_config.h"
#include "vibrationdata.h"
#include "config_mgr.h"
2025-04-02 10:13:03 +08:00
Radial::Radial(int slot_no_, int channel_, bool active, QWidget *parent)
2025-03-20 15:06:41 +08:00
: QWidget(parent)
2025-03-28 10:17:18 +08:00
, ui(new Ui::Radial_vibration) {
2025-03-20 15:06:41 +08:00
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);
2025-03-28 10:17:18 +08:00
if (active) {
2025-03-20 15:06:41 +08:00
ui->label_active->setText("(启用)");
2025-03-28 10:17:18 +08:00
} else {
2025-03-20 15:06:41 +08:00
ui->label_active->setText("(停用)");
2025-03-28 10:17:18 +08:00
}
2025-03-23 14:03:48 +08:00
Init();
2025-03-20 15:06:41 +08:00
}
2025-04-02 10:13:03 +08:00
Radial::~Radial() {
2025-03-20 15:06:41 +08:00
delete ui;
}
2025-03-28 10:17:18 +08:00
2025-04-02 10:13:03 +08:00
void Radial::on_pushButton_cancel_clicked() {
2025-03-28 10:17:18 +08:00
this->close();
}
2025-04-02 10:13:03 +08:00
void Radial::on_checkBox_1x_ampl_toggled(bool checked) {
2025-07-28 20:55:48 +08:00
2025-03-28 10:17:18 +08:00
}
2025-04-02 10:13:03 +08:00
void Radial::on_checkBox_2x_ampl_toggled(bool checked) {
2025-07-28 20:55:48 +08:00
2025-03-28 10:17:18 +08:00
}
2025-04-02 10:13:03 +08:00
void Radial::Init() {
2025-04-01 18:19:59 +08:00
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
if (base_ptr == nullptr) {
2025-04-02 10:27:10 +08:00
qCritical() << "[Radial::Init] should not be here";
2025-03-20 15:06:41 +08:00
return;
}
2025-04-01 18:19:59 +08:00
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
if (ptr->base_config_[channel - 1].channel_type != kVibRadial) {
2025-04-02 10:27:10 +08:00
qDebug() << "[Radial::Init] channel type changes";
2025-03-20 15:06:41 +08:00
return;
}
2025-04-01 18:19:59 +08:00
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(channel);
if (variable_base == nullptr) {
2025-04-02 10:27:10 +08:00
qDebug() << "[Radial::Init] no channel ptr";
2025-03-20 15:06:41 +08:00
return;
}
2025-04-01 18:19:59 +08:00
std::shared_ptr<RadialVariable> variable_ptr = std::dynamic_pointer_cast<RadialVariable>(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);
2025-07-28 22:05:26 +08:00
// processed output
// -general
if(variable_ptr->general.output_used)
ui->comboBox_output_used->setCurrentIndex(0);
else
ui->comboBox_output_used->setCurrentIndex(1);
2025-07-29 10:05:11 +08:00
ui->comboBox_engineering_unit->setCurrentText(variable_ptr->general.engineering_unit);
ui->comboBox_rectifier_funtion->setCurrentText(variable_ptr->general.rectifier_function);
2025-07-28 22:05:26 +08:00
// -alarm
ui->lineEdit_danger_high_level->setText(QString::number(variable_ptr->danger_high.level));
2025-07-29 10:05:11 +08:00
ui->lineEdit_danger_high_hysteresis->setText(QString::number(variable_ptr->danger_high.hysteresis));
ui->lineEdit_danger_high_delay->setText(QString::number(variable_ptr->danger_high.delay));
2025-07-28 22:05:26 +08:00
ui->checkBox_danger_high_enable->setChecked(variable_ptr->danger_high.enable);
ui->checkBox_danger_high_latch->setChecked(variable_ptr->danger_high.latch);
2025-07-28 20:55:48 +08:00
2025-07-28 22:05:26 +08:00
ui->lineEdit_alert_high_level->setText(QString::number(variable_ptr->alert_high.level));
2025-07-29 10:05:11 +08:00
ui->lineEdit_alert_high_hysteresis->setText(QString::number(variable_ptr->alert_high.hysteresis));
ui->lineEdit_alert_high_delay->setText(QString::number(variable_ptr->alert_high.delay));
2025-07-28 22:05:26 +08:00
ui->checkBox_alert_high_enable->setChecked(variable_ptr->alert_high.enable);
ui->checkBox_alert_high_latch->setChecked(variable_ptr->alert_high.latch);
ui->lineEdit_danger_low_level->setText(QString::number(variable_ptr->danger_low.level));
2025-07-29 10:05:11 +08:00
ui->lineEdit_danger_low_hysteresis->setText(QString::number(variable_ptr->danger_low.hysteresis));
ui->lineEdit_danger_low_delay->setText(QString::number(variable_ptr->danger_low.delay));
2025-07-28 22:05:26 +08:00
ui->checkBox_danger_low_enable->setChecked(variable_ptr->danger_low.enable);
ui->checkBox_danger_low_latch->setChecked(variable_ptr->danger_low.latch);
2025-07-29 10:05:11 +08:00
ui->lineEdit_alert_low_level->setText(QString::number(variable_ptr->alert_low.level));
ui->lineEdit_alert_low_hysteresis->setText(QString::number(variable_ptr->alert_low.hysteresis));
ui->lineEdit_alert_low_delay->setText(QString::number(variable_ptr->alert_low.delay));
ui->checkBox_alert_low_enable->setChecked(variable_ptr->alert_low.enable);
ui->checkBox_alert_low_latch->setChecked(variable_ptr->alert_low.latch);
2025-07-28 22:05:26 +08:00
// Gap
// -general
if(variable_ptr->gap_general.output_used)
ui->comboBox_output_used_2->setCurrentIndex(0);
else
ui->comboBox_output_used_2->setCurrentIndex(1);
2025-07-29 10:05:11 +08:00
ui->comboBox_engineering_unit_2->setCurrentText(variable_ptr->general.engineering_unit);
ui->comboBox_rectifier_funtion_2->setCurrentText(variable_ptr->general.rectifier_function);
2025-07-28 22:05:26 +08:00
// -alarm
ui->lineEdit_danger_high_level_2->setText(QString::number(variable_ptr->gap_danger_high.level));
2025-07-29 10:05:11 +08:00
ui->lineEdit_danger_high_hysteresis_2->setText(QString::number(variable_ptr->gap_danger_high.hysteresis));
ui->lineEdit_danger_high_delay_2->setText(QString::number(variable_ptr->gap_danger_high.delay));
2025-07-28 22:05:26 +08:00
ui->checkBox_danger_high_enable_2->setChecked(variable_ptr->gap_danger_high.enable);
ui->checkBox_danger_high_latch_2->setChecked(variable_ptr->gap_danger_high.latch);
ui->lineEdit_alert_high_level_2->setText(QString::number(variable_ptr->gap_alert_high.level));
2025-07-29 10:05:11 +08:00
ui->lineEdit_alert_high_hysteresis_2->setText(QString::number(variable_ptr->gap_alert_high.hysteresis));
ui->lineEdit_alert_high_delay_2->setText(QString::number(variable_ptr->gap_alert_high.delay));
2025-07-28 22:05:26 +08:00
ui->checkBox_alert_high_enable_2->setChecked(variable_ptr->gap_alert_high.enable);
ui->checkBox_alert_high_latch_2->setChecked(variable_ptr->gap_alert_high.latch);
ui->lineEdit_danger_low_level_2->setText(QString::number(variable_ptr->gap_danger_low.level));
2025-07-29 10:05:11 +08:00
ui->lineEdit_danger_low_hysteresis_2->setText(QString::number(variable_ptr->gap_danger_low.hysteresis));
ui->lineEdit_danger_low_delay_2->setText(QString::number(variable_ptr->gap_danger_low.delay));
2025-07-28 22:05:26 +08:00
ui->checkBox_danger_low_enable_2->setChecked(variable_ptr->gap_danger_low.enable);
ui->checkBox_danger_low_latch_2->setChecked(variable_ptr->gap_danger_low.latch);
2025-07-29 10:05:11 +08:00
ui->lineEdit_alert_low_level_2->setText(QString::number(variable_ptr->gap_alert_low.level));
ui->lineEdit_alert_low_hysteresis_2->setText(QString::number(variable_ptr->gap_alert_low.hysteresis));
ui->lineEdit_alert_low_delay_2->setText(QString::number(variable_ptr->gap_alert_low.delay));
ui->checkBox_alert_low_enable_2->setChecked(variable_ptr->gap_alert_low.enable);
ui->checkBox_alert_low_latch_2->setChecked(variable_ptr->gap_alert_low.latch);
2025-03-20 15:06:41 +08:00
}
2025-04-02 10:13:03 +08:00
void Radial::on_pushButton_confirm_clicked() {
2025-04-01 18:19:59 +08:00
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
if (base_ptr == nullptr) {
2025-04-14 20:30:41 +08:00
qCritical() << "[Radial::Init] should not be here";
2025-03-20 15:06:41 +08:00
return;
}
2025-04-01 18:19:59 +08:00
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_ != kVibRadial) {
if (variable_base == nullptr) {
qDebug() << "no channel ptr";
} else {
ptr->RemoveChannel(channel);
qDebug() << "channel type change";
}
2025-04-02 09:48:09 +08:00
std::shared_ptr<RadialVariable> variable = std::make_shared<RadialVariable>();
2025-04-01 18:19:59 +08:00
variable->id_ = channel;
variable->type_ = kVibRadial;
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();
2025-07-28 22:05:26 +08:00
// processed output
// -general
if(ui->comboBox_output_used->currentIndex() == 0)
variable->general.output_used = true;
else
variable->general.output_used = false;
2025-07-29 10:05:11 +08:00
variable->general.engineering_unit = ui->comboBox_engineering_unit->currentText();
variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentText();
2025-07-28 22:05:26 +08:00
// -alarm
variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble();
variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble();
variable->danger_high.delay = ui->lineEdit_danger_high_delay->text().toDouble();
variable->danger_high.enable = ui->checkBox_danger_high_enable->isChecked();
variable->danger_high.latch = ui->checkBox_danger_high_latch->isChecked();
variable->alert_high.level = ui->lineEdit_alert_high_level->text().toDouble();
variable->alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble();
variable->alert_high.delay = ui->lineEdit_alert_high_delay->text().toDouble();
variable->alert_high.enable = ui->checkBox_alert_high_enable->isChecked();
variable->alert_high.latch = ui->checkBox_alert_high_latch->isChecked();
variable->danger_low.level = ui->lineEdit_danger_low_level->text().toDouble();
variable->danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis->text().toDouble();
variable->danger_low.delay = ui->lineEdit_danger_low_delay->text().toDouble();
variable->danger_low.enable = ui->checkBox_danger_low_enable->isChecked();
variable->danger_low.latch = ui->checkBox_danger_low_latch->isChecked();
2025-07-29 10:05:11 +08:00
variable->alert_low.level = ui->lineEdit_alert_low_level->text().toDouble();
variable->alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis->text().toDouble();
variable->alert_low.delay = ui->lineEdit_alert_low_delay->text().toDouble();
variable->alert_low.enable = ui->checkBox_alert_low_enable->isChecked();
variable->alert_low.latch = ui->checkBox_alert_low_latch->isChecked();
2025-07-28 22:05:26 +08:00
// Gap
// -general
if(ui->comboBox_output_used_2->currentIndex() == 0)
variable->gap_general.output_used = true;
else
variable->gap_general.output_used = false;
2025-07-29 10:05:11 +08:00
variable->gap_general.engineering_unit = ui->comboBox_engineering_unit_2->currentText();
variable->gap_general.rectifier_function = ui->comboBox_rectifier_funtion_2->currentText();
2025-07-28 22:05:26 +08:00
// -alarm
variable->gap_danger_high.level = ui->lineEdit_danger_high_level_2->text().toDouble();
variable->gap_danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis_2->text().toDouble();
variable->gap_danger_high.delay = ui->lineEdit_danger_high_delay_2->text().toDouble();
variable->gap_danger_high.enable = ui->checkBox_danger_high_enable_2->isChecked();
variable->gap_danger_high.latch = ui->checkBox_danger_high_latch_2->isChecked();
variable->gap_alert_high.level = ui->lineEdit_alert_high_level_2->text().toDouble();
variable->gap_alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis_2->text().toDouble();
variable->gap_alert_high.delay = ui->lineEdit_alert_high_delay_2->text().toDouble();
variable->gap_alert_high.enable = ui->checkBox_alert_high_enable_2->isChecked();
variable->gap_alert_high.latch = ui->checkBox_alert_high_latch_2->isChecked();
variable->gap_danger_low.level = ui->lineEdit_danger_low_level_2->text().toDouble();
variable->gap_danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis_2->text().toDouble();
variable->gap_danger_low.delay = ui->lineEdit_danger_low_delay_2->text().toDouble();
variable->gap_danger_low.enable = ui->checkBox_danger_low_enable_2->isChecked();
variable->gap_danger_low.latch = ui->checkBox_danger_low_latch_2->isChecked();
2025-07-29 10:05:11 +08:00
variable->gap_alert_low.level = ui->lineEdit_alert_low_level_2->text().toDouble();
variable->gap_alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis_2->text().toDouble();
variable->gap_alert_low.delay = ui->lineEdit_alert_low_delay_2->text().toDouble();
variable->gap_alert_low.enable = ui->checkBox_alert_low_enable_2->isChecked();
variable->gap_alert_low.latch = ui->checkBox_alert_low_latch_2->isChecked();
2025-07-28 22:05:26 +08:00
// add to ptr
2025-04-01 18:19:59 +08:00
ptr->variables_.push_back(variable);
this->close();
2025-03-20 15:06:41 +08:00
return;
}
2025-04-02 09:48:09 +08:00
std::shared_ptr<RadialVariable> variable = std::dynamic_pointer_cast<RadialVariable>(variable_base);
2025-04-01 18:19:59 +08:00
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();
2025-07-28 22:05:26 +08:00
// processed output
// -general
if(ui->comboBox_output_used->currentIndex() == 0)
variable->general.output_used = true;
else
variable->general.output_used = false;
// -alarm
variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble();
variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble();
variable->danger_high.delay = ui->lineEdit_danger_high_delay->text().toDouble();
variable->danger_high.enable = ui->checkBox_danger_high_enable->isChecked();
variable->danger_high.latch = ui->checkBox_danger_high_latch->isChecked();
variable->alert_high.level = ui->lineEdit_alert_high_level->text().toDouble();
variable->alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble();
variable->alert_high.delay = ui->lineEdit_alert_high_delay->text().toDouble();
variable->alert_high.enable = ui->checkBox_alert_high_enable->isChecked();
variable->alert_high.latch = ui->checkBox_alert_high_latch->isChecked();
variable->danger_low.level = ui->lineEdit_danger_low_level->text().toDouble();
variable->danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis->text().toDouble();
variable->danger_low.delay = ui->lineEdit_danger_low_delay->text().toDouble();
variable->danger_low.enable = ui->checkBox_danger_low_enable->isChecked();
variable->danger_low.latch = ui->checkBox_danger_low_latch->isChecked();
2025-07-29 10:05:11 +08:00
variable->alert_low.level = ui->lineEdit_alert_low_level->text().toDouble();
variable->alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis->text().toDouble();
variable->alert_low.delay = ui->lineEdit_alert_low_delay->text().toDouble();
variable->alert_low.enable = ui->checkBox_alert_low_enable->isChecked();
variable->alert_low.latch = ui->checkBox_alert_low_latch->isChecked();
2025-07-28 22:05:26 +08:00
// Gap
// -general
if(ui->comboBox_output_used_2->currentIndex() == 0)
variable->gap_general.output_used = true;
else
variable->gap_general.output_used = false;
// -alarm
variable->gap_danger_high.level = ui->lineEdit_danger_high_level_2->text().toDouble();
variable->gap_danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis_2->text().toDouble();
variable->gap_danger_high.delay = ui->lineEdit_danger_high_delay_2->text().toDouble();
variable->gap_danger_high.enable = ui->checkBox_danger_high_enable_2->isChecked();
variable->gap_danger_high.latch = ui->checkBox_danger_high_latch_2->isChecked();
variable->gap_alert_high.level = ui->lineEdit_alert_high_level_2->text().toDouble();
variable->gap_alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis_2->text().toDouble();
variable->gap_alert_high.delay = ui->lineEdit_alert_high_delay_2->text().toDouble();
variable->gap_alert_high.enable = ui->checkBox_alert_high_enable_2->isChecked();
variable->gap_alert_high.latch = ui->checkBox_alert_high_latch_2->isChecked();
variable->gap_danger_low.level = ui->lineEdit_danger_low_level_2->text().toDouble();
variable->gap_danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis_2->text().toDouble();
variable->gap_danger_low.delay = ui->lineEdit_danger_low_delay_2->text().toDouble();
variable->gap_danger_low.enable = ui->checkBox_danger_low_enable_2->isChecked();
variable->gap_danger_low.latch = ui->checkBox_danger_low_latch_2->isChecked();
2025-07-29 10:05:11 +08:00
variable->gap_alert_low.level = ui->lineEdit_alert_low_level_2->text().toDouble();
variable->gap_alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis_2->text().toDouble();
variable->gap_alert_low.delay = ui->lineEdit_alert_low_delay_2->text().toDouble();
variable->gap_alert_low.enable = ui->checkBox_alert_low_enable_2->isChecked();
variable->gap_alert_low.latch = ui->checkBox_alert_low_latch_2->isChecked();
this->close();
2025-03-20 15:06:41 +08:00
}
2025-04-02 10:13:03 +08:00
void Radial::on_pushButton_set_default_clicked() {
2025-03-20 15:06:41 +08:00
}