diff --git a/trust.cpp b/trust.cpp new file mode 100644 index 0000000..c2d4b1c --- /dev/null +++ b/trust.cpp @@ -0,0 +1,145 @@ +#include "trust.h" +#include "ui_trust.h" +#include +#include +#include +#include +#include + +#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 base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); + if (base_ptr == nullptr) { + qCritical() << "[Radial::Init] should not be here"; + return; + } + std::shared_ptr ptr = std::dynamic_pointer_cast(base_ptr); + if (ptr->base_config_[channel - 1].channel_type != kVibThrust) { + qDebug() << "[Radial::Init] channel type changes"; + return; + } + std::shared_ptr variable_base = ptr->GetChannelPtr(channel); + if (variable_base == nullptr) { + qDebug() << "[Radial::Init] no channel ptr"; + return; + } + std::shared_ptr variable_ptr = std::dynamic_pointer_cast(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->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); +} +void Trust::on_pushButton_confirm_clicked() +{ + std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); + if (base_ptr == nullptr) { + qCritical() << "[Radial::Init] should not be here"; + return; + } + std::shared_ptr ptr = std::dynamic_pointer_cast(base_ptr); + std::shared_ptr 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 variable = std::make_shared(); + 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->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(); + ptr->variables_.push_back(variable); + this->close(); + return; + } + std::shared_ptr variable = std::dynamic_pointer_cast(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->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(); + this->close(); +} + + +void Trust::on_pushButton_cancel_clicked() +{ + +} + diff --git a/trust.h b/trust.h new file mode 100644 index 0000000..8ef1319 --- /dev/null +++ b/trust.h @@ -0,0 +1,30 @@ +#ifndef TRUST_H +#define TRUST_H + +#include + +namespace Ui { +class Trust; +} + +class Trust : public QWidget +{ + Q_OBJECT + +public: + explicit Trust(int slot_no_, int channel_, bool active,QWidget *parent = nullptr); + ~Trust(); + int slot_no; + int channel; + +private slots: + void on_pushButton_confirm_clicked(); + + void on_pushButton_cancel_clicked(); + +private: + Ui::Trust *ui; + void Init(); +}; + +#endif // TRUST_H diff --git a/trust.ui b/trust.ui new file mode 100644 index 0000000..230ce4d --- /dev/null +++ b/trust.ui @@ -0,0 +1,818 @@ + + + Trust + + + + 0 + 0 + 691 + 505 + + + + Form + + + + + 10 + 60 + 651 + 381 + + + + 1 + + + + 传感器和滤波配置 + + + + + 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 + 321 + + + + 特征值 + + + + + 20 + 50 + 54 + 12 + + + + 直接值 + + + + + + 20 + 80 + 81 + 16 + + + + 间隙 + + + + + + 141 + 31 + 48 + 16 + + + + 取值范围 + + + + + + 260 + 31 + 61 + 16 + + + + 默认值 + + + + + + 130 + 50 + 111 + 22 + + + + 0 + + + + 25-0-25 mil + + + + + 30-0-30 mil + + + + + 40-0-40 mil + + + + + 0.5-0-0.5 mm + + + + + 1.0-0-1.0 mm + + + + + 自定义 + + + + + + + 260 + 50 + 62 + 22 + + + + 0 + + + 1000.000000000000000 + + + + + + 260 + 80 + 62 + 22 + + + + 1 + + + + + + 130 + 80 + 111 + 22 + + + + 0 + + + + -24 Vdc + + + + + 0-100 um + + + + + 0-150 um + + + + + 0-200 um + + + + + 0-400 um + + + + + 0-500 um + + + + + 自定义 + + + + + + + 10 + 190 + 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 + 130 + 54 + 12 + + + + 记录输出 + + + + + + 460 + 150 + 141 + 22 + + + + + + + + + + 直接幅值 + + + + + 间隙 + + + + + + + 460 + 180 + 91 + 16 + + + + 2 mA 默认值 + + + true + + + + + + 470 + 60 + 181 + 16 + + + + Timed OK channel Defeat + + + + + + + + 21 + 10 + 105 + 17 + + + + + + + 通道: + + + + + + + 1 + + + + + + + (启用) + + + + + + + + + 20 + 450 + 632 + 37 + + + + + + + + 100 + 35 + + + + 确定 + + + + + + + false + + + + 100 + 35 + + + + 设置为默认值 + + + + + + + + 100 + 35 + + + + 取消 + + + + + + + false + + + + 100 + 35 + + + + 打印 + + + + + + + false + + + + 100 + 35 + + + + 帮助 + + + + + + + + + 341 + 10 + 63 + 17 + + + + + + + 槽位号: + + + + + + + 3 + + + + + + + + + diff --git a/trust_ds.h b/trust_ds.h new file mode 100644 index 0000000..c5189b4 --- /dev/null +++ b/trust_ds.h @@ -0,0 +1,22 @@ +#ifndef TRUST_DS_H +#define TRUST_DS_H + +// 位移峰峰值的量程范围 +typedef enum { + kDisPP25 = 0, // 25-0-25 mil + kDisPP30 = 1, // 30-0-30 mil + kDisPP40 = 2, // 40-0-40 mil + kDisPP0p5 = 3, // 0.5-0-0.5 mm + kDisPP1p0 = 4, // 1.0-0-1.0 mm + kDisPPCustom = 5 // custom +} DisPPFullScaleRange; + +// recorder out +typedef enum { + kDisRecorderOutNone = 0, + kDisRecorderOutDirectAmpl = 1, + kDisRecorderOutGap = 2 +} DisRecorderOut; + + +#endif // TRUST_DS_H