2025-07-08 09:24:34 +08:00
|
|
|
#include "trust.h"
|
|
|
|
#include "ui_trust.h"
|
|
|
|
#include <QFile>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QJsonObject>
|
|
|
|
#include <QJsonArray>
|
2025-08-06 22:11:14 +08:00
|
|
|
#include <QMessageBox>
|
2025-07-08 09:24:34 +08:00
|
|
|
#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);
|
2025-07-28 20:55:48 +08:00
|
|
|
|
2025-07-09 20:24:50 +08:00
|
|
|
ui->doubleSpinBox_zero_position->setValue(variable_ptr->zero_position.value);
|
2025-07-17 20:10:38 +08:00
|
|
|
ui->checkBox_negation->setChecked(variable_ptr->zero_position.negation);
|
2025-07-28 22:05:26 +08:00
|
|
|
|
2025-07-29 10:05:11 +08:00
|
|
|
// gap
|
2025-07-28 22:05:26 +08:00
|
|
|
// -general
|
2025-07-29 10:05:11 +08:00
|
|
|
if(variable_ptr->gap_general.output_used)
|
2025-07-28 22:05:26 +08:00
|
|
|
ui->comboBox_output_used->setCurrentIndex(0);
|
|
|
|
else
|
|
|
|
ui->comboBox_output_used->setCurrentIndex(1);
|
2025-07-29 22:01:19 +08:00
|
|
|
ui->comboBox_engineering_unit->setCurrentIndex(variable_ptr->gap_general.engineering_unit);
|
2025-08-06 22:11:14 +08:00
|
|
|
ui->comboBox_rectifier_funtion->setCurrentIndex(variable_ptr->general.rectifier_function);
|
2025-07-28 22:05:26 +08:00
|
|
|
// -alarm
|
2025-07-29 10:05:11 +08:00
|
|
|
ui->lineEdit_danger_high_level->setText(QString::number(variable_ptr->gap_danger_high.level));
|
|
|
|
ui->lineEdit_danger_high_hysteresis->setText(QString::number(variable_ptr->gap_danger_high.hysteresis));
|
|
|
|
ui->lineEdit_danger_high_delay->setText(QString::number(variable_ptr->gap_danger_high.delay));
|
|
|
|
ui->checkBox_danger_high_enable->setChecked(variable_ptr->gap_danger_high.enable);
|
|
|
|
ui->checkBox_danger_high_latch->setChecked(variable_ptr->gap_danger_high.latch);
|
|
|
|
|
|
|
|
ui->lineEdit_alert_high_level->setText(QString::number(variable_ptr->gap_alert_high.level));
|
|
|
|
ui->lineEdit_alert_high_hysteresis->setText(QString::number(variable_ptr->gap_alert_high.hysteresis));
|
|
|
|
ui->lineEdit_alert_high_delay->setText(QString::number(variable_ptr->gap_alert_high.delay));
|
|
|
|
ui->checkBox_alert_high_enable->setChecked(variable_ptr->gap_alert_high.enable);
|
|
|
|
ui->checkBox_alert_high_latch->setChecked(variable_ptr->gap_alert_high.latch);
|
|
|
|
|
|
|
|
ui->lineEdit_danger_low_level->setText(QString::number(variable_ptr->gap_danger_low.level));
|
|
|
|
ui->lineEdit_danger_low_hysteresis->setText(QString::number(variable_ptr->gap_danger_low.hysteresis));
|
|
|
|
ui->lineEdit_danger_low_delay->setText(QString::number(variable_ptr->gap_danger_low.delay));
|
|
|
|
ui->checkBox_danger_low_enable->setChecked(variable_ptr->gap_danger_low.enable);
|
|
|
|
ui->checkBox_danger_low_latch->setChecked(variable_ptr->gap_danger_low.latch);
|
|
|
|
|
|
|
|
ui->lineEdit_alert_low_level->setText(QString::number(variable_ptr->gap_alert_low.level));
|
|
|
|
ui->lineEdit_alert_low_hysteresis->setText(QString::number(variable_ptr->gap_alert_low.hysteresis));
|
|
|
|
ui->lineEdit_alert_low_delay->setText(QString::number(variable_ptr->gap_alert_low.delay));
|
|
|
|
ui->checkBox_alert_low_enable->setChecked(variable_ptr->gap_alert_low.enable);
|
|
|
|
ui->checkBox_alert_low_latch->setChecked(variable_ptr->gap_alert_low.latch);
|
|
|
|
|
2025-07-08 09:24:34 +08:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
2025-08-06 22:11:14 +08:00
|
|
|
if(ui->lineEdit_alert_high_level->text().toFloat() > ui->lineEdit_danger_high_level->text().toDouble()){
|
|
|
|
QMessageBox::warning(this, QStringLiteral("警告"), "危险 + 高 必须大于 警报 + 高");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(ui->lineEdit_alert_low_level->text().toFloat() > ui->lineEdit_alert_high_level->text().toDouble()){
|
|
|
|
QMessageBox::warning(this, QStringLiteral("警告"), "警报 + 高 必须大于 警报 + 低");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(ui->lineEdit_danger_low_level->text().toFloat() > ui->lineEdit_alert_low_level->text().toDouble()){
|
|
|
|
QMessageBox::warning(this, QStringLiteral("警告"), "警报 + 低 必须大于 危险 + 低");
|
|
|
|
return;
|
|
|
|
}
|
2025-07-08 09:24:34 +08:00
|
|
|
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
2025-08-06 22:11:14 +08:00
|
|
|
ptr->base_config_[channel - 1].channel_type = kVibThrust;
|
|
|
|
|
2025-07-08 09:24:34 +08:00
|
|
|
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(channel);
|
2025-08-06 22:11:14 +08:00
|
|
|
std::shared_ptr<ThrustVariable> variable = std::dynamic_pointer_cast<ThrustVariable>(variable_base);
|
|
|
|
|
|
|
|
if (variable_base == nullptr || variable_base->type_ != kVibThrust || variable == nullptr) {
|
2025-07-08 09:24:34 +08:00
|
|
|
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();
|
2025-07-28 20:55:48 +08:00
|
|
|
|
2025-07-09 20:24:50 +08:00
|
|
|
variable->zero_position.value = ui->doubleSpinBox_zero_position->value();
|
2025-07-17 20:10:38 +08:00
|
|
|
variable->zero_position.negation = ui->checkBox_negation->isChecked();
|
2025-07-28 22:05:26 +08:00
|
|
|
|
2025-07-29 10:05:11 +08:00
|
|
|
// gap
|
2025-07-28 22:05:26 +08:00
|
|
|
// -general
|
|
|
|
if(ui->comboBox_output_used->currentIndex() == 0)
|
2025-07-29 10:05:11 +08:00
|
|
|
variable->gap_general.output_used = true;
|
2025-07-28 22:05:26 +08:00
|
|
|
else
|
2025-07-29 10:05:11 +08:00
|
|
|
variable->gap_general.output_used = false;
|
2025-07-29 22:01:19 +08:00
|
|
|
variable->gap_general.engineering_unit = ui->comboBox_engineering_unit->currentIndex();
|
2025-08-06 22:11:14 +08:00
|
|
|
variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex();
|
|
|
|
|
2025-07-28 22:05:26 +08:00
|
|
|
// -alarm
|
2025-07-29 10:05:11 +08:00
|
|
|
variable->gap_danger_high.level = ui->lineEdit_danger_high_level->text().toDouble();
|
|
|
|
variable->gap_danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble();
|
|
|
|
variable->gap_danger_high.delay = ui->lineEdit_danger_high_delay->text().toDouble();
|
|
|
|
variable->gap_danger_high.enable = ui->checkBox_danger_high_enable->isChecked();
|
|
|
|
variable->gap_danger_high.latch = ui->checkBox_danger_high_latch->isChecked();
|
|
|
|
variable->gap_alert_high.level = ui->lineEdit_alert_high_level->text().toDouble();
|
|
|
|
variable->gap_alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble();
|
|
|
|
variable->gap_alert_high.delay = ui->lineEdit_alert_high_delay->text().toDouble();
|
|
|
|
variable->gap_alert_high.enable = ui->checkBox_alert_high_enable->isChecked();
|
|
|
|
variable->gap_alert_high.latch = ui->checkBox_alert_high_latch->isChecked();
|
|
|
|
variable->gap_danger_low.level = ui->lineEdit_danger_low_level->text().toDouble();
|
|
|
|
variable->gap_danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis->text().toDouble();
|
|
|
|
variable->gap_danger_low.delay = ui->lineEdit_danger_low_delay->text().toDouble();
|
|
|
|
variable->gap_danger_low.enable = ui->checkBox_danger_low_enable->isChecked();
|
|
|
|
variable->gap_danger_low.latch = ui->checkBox_danger_low_latch->isChecked();
|
|
|
|
variable->gap_alert_low.level = ui->lineEdit_alert_low_level->text().toDouble();
|
|
|
|
variable->gap_alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis->text().toDouble();
|
|
|
|
variable->gap_alert_low.delay = ui->lineEdit_alert_low_delay->text().toDouble();
|
|
|
|
variable->gap_alert_low.enable = ui->checkBox_alert_low_enable->isChecked();
|
|
|
|
variable->gap_alert_low.latch = ui->checkBox_alert_low_latch->isChecked();
|
2025-07-08 09:24:34 +08:00
|
|
|
ptr->variables_.push_back(variable);
|
|
|
|
this->close();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
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 20:55:48 +08:00
|
|
|
|
2025-07-17 20:10:38 +08:00
|
|
|
variable->zero_position.value = ui->doubleSpinBox_zero_position->value();
|
|
|
|
variable->zero_position.negation = ui->checkBox_negation->isChecked();
|
2025-07-28 22:05:26 +08:00
|
|
|
|
2025-07-29 10:05:11 +08:00
|
|
|
// gap
|
2025-07-28 22:05:26 +08:00
|
|
|
// -general
|
|
|
|
if(ui->comboBox_output_used->currentIndex() == 0)
|
2025-07-29 10:05:11 +08:00
|
|
|
variable->gap_general.output_used = true;
|
2025-07-28 22:05:26 +08:00
|
|
|
else
|
2025-07-29 10:05:11 +08:00
|
|
|
variable->gap_general.output_used = false;
|
2025-07-29 22:01:19 +08:00
|
|
|
variable->gap_general.engineering_unit = ui->comboBox_engineering_unit->currentIndex();
|
2025-08-06 22:11:14 +08:00
|
|
|
variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex();
|
|
|
|
|
2025-07-28 22:05:26 +08:00
|
|
|
// -alarm
|
2025-07-29 10:05:11 +08:00
|
|
|
variable->gap_danger_high.level = ui->lineEdit_danger_high_level->text().toDouble();
|
|
|
|
variable->gap_danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble();
|
|
|
|
variable->gap_danger_high.delay = ui->lineEdit_danger_high_delay->text().toDouble();
|
|
|
|
variable->gap_danger_high.enable = ui->checkBox_danger_high_enable->isChecked();
|
|
|
|
variable->gap_danger_high.latch = ui->checkBox_danger_high_latch->isChecked();
|
|
|
|
variable->gap_alert_high.level = ui->lineEdit_alert_high_level->text().toDouble();
|
|
|
|
variable->gap_alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble();
|
|
|
|
variable->gap_alert_high.delay = ui->lineEdit_alert_high_delay->text().toDouble();
|
|
|
|
variable->gap_alert_high.enable = ui->checkBox_alert_high_enable->isChecked();
|
|
|
|
variable->gap_alert_high.latch = ui->checkBox_alert_high_latch->isChecked();
|
|
|
|
variable->gap_danger_low.level = ui->lineEdit_danger_low_level->text().toDouble();
|
|
|
|
variable->gap_danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis->text().toDouble();
|
|
|
|
variable->gap_danger_low.delay = ui->lineEdit_danger_low_delay->text().toDouble();
|
|
|
|
variable->gap_danger_low.enable = ui->checkBox_danger_low_enable->isChecked();
|
|
|
|
variable->gap_danger_low.latch = ui->checkBox_danger_low_latch->isChecked();
|
|
|
|
variable->gap_alert_low.level = ui->lineEdit_alert_low_level->text().toDouble();
|
|
|
|
variable->gap_alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis->text().toDouble();
|
|
|
|
variable->gap_alert_low.delay = ui->lineEdit_alert_low_delay->text().toDouble();
|
|
|
|
variable->gap_alert_low.enable = ui->checkBox_alert_low_enable->isChecked();
|
|
|
|
variable->gap_alert_low.latch = ui->checkBox_alert_low_latch->isChecked();
|
2025-07-08 09:24:34 +08:00
|
|
|
this->close();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Trust::on_pushButton_cancel_clicked()
|
|
|
|
{
|
2025-07-09 20:24:50 +08:00
|
|
|
this->close();
|
2025-07-08 09:24:34 +08:00
|
|
|
}
|
|
|
|
|
2025-08-06 22:11:14 +08:00
|
|
|
|
|
|
|
void Trust::on_lineEdit_alert_high_level_editingFinished()
|
|
|
|
{
|
|
|
|
if(ui->lineEdit_alert_high_level->text().toFloat() > ui->lineEdit_danger_high_level->text().toDouble()){
|
|
|
|
ui->lineEdit_danger_high_level->setText(ui->lineEdit_alert_high_level->text());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Trust::on_lineEdit_danger_low_level_editingFinished()
|
|
|
|
{
|
|
|
|
if(ui->lineEdit_danger_low_level->text().toFloat() > ui->lineEdit_alert_low_level->text().toDouble()){
|
|
|
|
ui->lineEdit_alert_low_level->setText(ui->lineEdit_danger_low_level->text());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|