156 lines
7.6 KiB
C++
156 lines
7.6 KiB
C++
#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->comboBox_gap_range->setCurrentIndex(variable_ptr->gap_range.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);
|
|
ui->doubleSpinBox_zero_position->setValue(variable_ptr->zero_position.value);
|
|
ui->checkBox_negation->setChecked(variable_ptr->zero_position.negation);
|
|
}
|
|
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->gap_range.full_scale_range = ui->comboBox_gap_range->currentIndex();
|
|
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();
|
|
variable->zero_position.value = ui->doubleSpinBox_zero_position->value();
|
|
variable->zero_position.negation = ui->checkBox_negation->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->gap_range.full_scale_range = ui->comboBox_gap_range->currentIndex();
|
|
variable->gap_range.custom = 0;
|
|
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();
|
|
variable->zero_position.value = ui->doubleSpinBox_zero_position->value();
|
|
variable->zero_position.negation = ui->checkBox_negation->isChecked();
|
|
this->close();
|
|
}
|
|
|
|
|
|
void Trust::on_pushButton_cancel_clicked()
|
|
{
|
|
this->close();
|
|
}
|
|
|