TSI_Config/tachometer.cpp

493 lines
33 KiB
C++

#include "tachometer.h"
#include "ui_tachometer.h"
#include <QDebug>
#include <QFile>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonParseError>
#include <QJsonArray>
#include "data_config.h"
#include "config_mgr.h"
#include "tachometer_data.h"
Tachometer::Tachometer(int slot_no_,int cardtype, QWidget *parent)
: QDialog(parent)
, ui(new Ui::Tachometer) {
ui->setupUi(this);
ui->widget_body->setProperty("flag", "body");
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
slot_no = slot_no_;
car_type = static_cast<CardType>(cardtype);
QString slot = QString("%1").arg(slot_no);
ui->label_slot->setText(slot);
Init();
connect(ui->radioButton_manual_threshold_1, &QRadioButton::toggled, this, &Tachometer::on_manual_threshold_1_clicked);
connect(ui->radioButton_manual_threshold_2, &QRadioButton::toggled, this, &Tachometer::on_manual_threshold_2_clicked);
connect(ui->radioButton_manual_threshold_3, &QRadioButton::toggled, this, &Tachometer::on_manual_threshold_3_clicked);
connect(ui->radioButton_manual_threshold_4, &QRadioButton::toggled, this, &Tachometer::on_manual_threshold_4_clicked);
}
Tachometer::~Tachometer() {
delete ui;
}
void Tachometer::on_manual_threshold_1_clicked(bool checked) {
if (checked) {
ui->doubleSpinBox_threshold_1->setEnabled(true);
ui->doubleSpinBox_hysteresis_1->setEnabled(true);
return;
}
ui->doubleSpinBox_threshold_1->setEnabled(false);
ui->doubleSpinBox_hysteresis_1->setEnabled(false);
}
void Tachometer::on_manual_threshold_2_clicked(bool checked) {
if (checked) {
ui->doubleSpinBox_threshold_2->setEnabled(true);
ui->doubleSpinBox_hysteresis_2->setEnabled(true);
return;
}
ui->doubleSpinBox_threshold_2->setEnabled(false);
ui->doubleSpinBox_hysteresis_2->setEnabled(false);
}
void Tachometer::on_manual_threshold_3_clicked(bool checked) {
if (checked) {
ui->doubleSpinBox_threshold_3->setEnabled(true);
ui->doubleSpinBox_hysteresis_3->setEnabled(true);
return;
}
ui->doubleSpinBox_threshold_3->setEnabled(false);
ui->doubleSpinBox_hysteresis_3->setEnabled(false);
}
void Tachometer::on_manual_threshold_4_clicked(bool checked) {
if (checked) {
ui->doubleSpinBox_threshold_4->setEnabled(true);
ui->doubleSpinBox_hysteresis_4->setEnabled(true);
return;
}
ui->doubleSpinBox_threshold_4->setEnabled(false);
ui->doubleSpinBox_hysteresis_4->setEnabled(false);
}
void Tachometer::UpdateData(std::shared_ptr<TachometerData> &speed_data) {
speed_data->card_type_ = kCardSpeedSingle;
speed_data->slot_ = slot_no;
speed_data->version_ = 1;
for (int i = 0; i < CHANNEL_COUNT_SPEED; i++) {
if (i + 1 == 1) {
speed_data->variables_[i].active = ui->checkBox_chan_1->isChecked();
speed_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_1->value();
speed_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_1->value();
speed_data->variables_[i].speed_peek = ui->full_scale_range_1->value();
speed_data->variables_[i].default_speed = ui->default_value_1->value();
if(ui->radioButton_automatic_threshold_1->isChecked()){
speed_data->variables_[i].automatic_threshold = true;
}else{
speed_data->variables_[i].automatic_threshold = false;
}
speed_data->variables_[i].threshold = ui->doubleSpinBox_threshold_1->value();
speed_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_1->value();
speed_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_1->value();
speed_data->variables_[i].record_output = ui->comboBox_record_output_1->currentIndex();
speed_data->variables_[i].two_ma_clamp = ui->checkBox_two_ma_clamp_1->isChecked();
speed_data->variables_[i].alert_latching = ui->radioButton_alert_latching_1->isChecked();
speed_data->variables_[i].overspeed_latching = ui->radioButton_overspeed_latching_1->isChecked();
// -alarm
speed_data->danger_high[i].level = ui->lineEdit_danger_high_level->text().toDouble();
speed_data->danger_high[i].hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble();
speed_data->danger_high[i].delay = ui->lineEdit_danger_high_delay->text().toDouble();
speed_data->danger_high[i].enable = ui->checkBox_danger_high_enable->isChecked();
speed_data->danger_high[i].latch = ui->checkBox_danger_high_latch->isChecked();
speed_data->alert_high[i].level = ui->lineEdit_alert_high_level->text().toDouble();
speed_data->alert_high[i].hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble();
speed_data->alert_high[i].delay = ui->lineEdit_alert_high_delay->text().toDouble();
speed_data->alert_high[i].enable = ui->checkBox_alert_high_enable->isChecked();
speed_data->alert_high[i].latch = ui->checkBox_alert_high_latch->isChecked();
speed_data->danger_low[i].level = ui->lineEdit_danger_low_level->text().toDouble();
speed_data->danger_low[i].hysteresis = ui->lineEdit_danger_low_hysteresis->text().toDouble();
speed_data->danger_low[i].delay = ui->lineEdit_danger_low_delay->text().toDouble();
speed_data->danger_low[i].enable = ui->checkBox_danger_low_enable->isChecked();
speed_data->danger_low[i].latch = ui->checkBox_danger_low_latch->isChecked();
speed_data->alert_low[i].level = ui->lineEdit_alert_low_level->text().toDouble();
speed_data->alert_low[i].hysteresis = ui->lineEdit_alert_low_hysteresis->text().toDouble();
speed_data->alert_low[i].delay = ui->lineEdit_alert_low_delay->text().toDouble();
speed_data->alert_low[i].enable = ui->checkBox_alert_low_enable->isChecked();
speed_data->alert_low[i].latch = ui->checkBox_alert_low_latch->isChecked();
} else if (i + 1 == 2) {
speed_data->variables_[i].active = ui->checkBox_chan_2->isChecked();
speed_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_2->value();
speed_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_2->value();
speed_data->variables_[i].speed_peek = ui->full_scale_range_2->value();
speed_data->variables_[i].default_speed = ui->default_value_2->value();
if(ui->radioButton_automatic_threshold_2->isChecked()){
speed_data->variables_[i].automatic_threshold = true;
}else{
speed_data->variables_[i].automatic_threshold = false;
}
speed_data->variables_[i].threshold = ui->doubleSpinBox_threshold_2->value();
speed_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_2->value();
speed_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_2->value();
speed_data->variables_[i].record_output = ui->comboBox_record_output_2->currentIndex();
speed_data->variables_[i].two_ma_clamp = ui->checkBox_two_ma_clamp_2->isChecked();
speed_data->variables_[i].alert_latching = ui->radioButton_alert_latching_2->isChecked();
speed_data->variables_[i].overspeed_latching = ui->radioButton_overspeed_latching_2->isChecked();
// -alarm
speed_data->danger_high[i].level = ui->lineEdit_danger_high_level_2->text().toDouble();
speed_data->danger_high[i].hysteresis = ui->lineEdit_danger_high_hysteresis_2->text().toDouble();
speed_data->danger_high[i].delay = ui->lineEdit_danger_high_delay_2->text().toDouble();
speed_data->danger_high[i].enable = ui->checkBox_danger_high_enable_2->isChecked();
speed_data->danger_high[i].latch = ui->checkBox_danger_high_latch_2->isChecked();
speed_data->alert_high[i].level = ui->lineEdit_alert_high_level_2->text().toDouble();
speed_data->alert_high[i].hysteresis = ui->lineEdit_alert_high_hysteresis_2->text().toDouble();
speed_data->alert_high[i].delay = ui->lineEdit_alert_high_delay_2->text().toDouble();
speed_data->alert_high[i].enable = ui->checkBox_alert_high_enable_2->isChecked();
speed_data->alert_high[i].latch = ui->checkBox_alert_high_latch_2->isChecked();
speed_data->danger_low[i].level = ui->lineEdit_danger_low_level_2->text().toDouble();
speed_data->danger_low[i].hysteresis = ui->lineEdit_danger_low_hysteresis_2->text().toDouble();
speed_data->danger_low[i].delay = ui->lineEdit_danger_low_delay_2->text().toDouble();
speed_data->danger_low[i].enable = ui->checkBox_danger_low_enable_2->isChecked();
speed_data->danger_low[i].latch = ui->checkBox_danger_low_latch_2->isChecked();
speed_data->alert_low[i].level = ui->lineEdit_alert_low_level_2->text().toDouble();
speed_data->alert_low[i].hysteresis = ui->lineEdit_alert_low_hysteresis_2->text().toDouble();
speed_data->alert_low[i].delay = ui->lineEdit_alert_low_delay_2->text().toDouble();
speed_data->alert_low[i].enable = ui->checkBox_alert_low_enable_2->isChecked();
speed_data->alert_low[i].latch = ui->checkBox_alert_low_latch_2->isChecked();
} else if (i + 1 == 3) {
speed_data->variables_[i].active = ui->checkBox_chan_3->isChecked();
speed_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_3->value();
speed_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_3->value();
speed_data->variables_[i].speed_peek = ui->full_scale_range_3->value();
speed_data->variables_[i].default_speed = ui->default_value_3->value();
if(ui->radioButton_automatic_threshold_3->isChecked()){
speed_data->variables_[i].automatic_threshold = true;
}else{
speed_data->variables_[i].automatic_threshold = false;
}
speed_data->variables_[i].threshold = ui->doubleSpinBox_threshold_3->value();
speed_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_3->value();
speed_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_3->value();
speed_data->variables_[i].record_output = ui->comboBox_record_output_3->currentIndex();
speed_data->variables_[i].two_ma_clamp = ui->checkBox_two_ma_clamp_3->isChecked();
speed_data->variables_[i].alert_latching = ui->radioButton_alert_latching_3->isChecked();
speed_data->variables_[i].overspeed_latching = ui->radioButton_overspeed_latching_3->isChecked();
// -alarm
speed_data->danger_high[i].level = ui->lineEdit_danger_high_level_3->text().toDouble();
speed_data->danger_high[i].hysteresis = ui->lineEdit_danger_high_hysteresis_3->text().toDouble();
speed_data->danger_high[i].delay = ui->lineEdit_danger_high_delay_3->text().toDouble();
speed_data->danger_high[i].enable = ui->checkBox_danger_high_enable_3->isChecked();
speed_data->danger_high[i].latch = ui->checkBox_danger_high_latch_3->isChecked();
speed_data->alert_high[i].level = ui->lineEdit_alert_high_level_3->text().toDouble();
speed_data->alert_high[i].hysteresis = ui->lineEdit_alert_high_hysteresis_3->text().toDouble();
speed_data->alert_high[i].delay = ui->lineEdit_alert_high_delay_3->text().toDouble();
speed_data->alert_high[i].enable = ui->checkBox_alert_high_enable_3->isChecked();
speed_data->alert_high[i].latch = ui->checkBox_alert_high_latch_3->isChecked();
speed_data->danger_low[i].level = ui->lineEdit_danger_low_level_3->text().toDouble();
speed_data->danger_low[i].hysteresis = ui->lineEdit_danger_low_hysteresis_3->text().toDouble();
speed_data->danger_low[i].delay = ui->lineEdit_danger_low_delay_3->text().toDouble();
speed_data->danger_low[i].enable = ui->checkBox_danger_low_enable_3->isChecked();
speed_data->danger_low[i].latch = ui->checkBox_danger_low_latch_3->isChecked();
speed_data->alert_low[i].level = ui->lineEdit_alert_low_level_3->text().toDouble();
speed_data->alert_low[i].hysteresis = ui->lineEdit_alert_low_hysteresis_3->text().toDouble();
speed_data->alert_low[i].delay = ui->lineEdit_alert_low_delay_3->text().toDouble();
speed_data->alert_low[i].enable = ui->checkBox_alert_low_enable_3->isChecked();
speed_data->alert_low[i].latch = ui->checkBox_alert_low_latch_3->isChecked();
} else if (i + 1 == 4) {
speed_data->variables_[i].active = ui->checkBox_chan_4->isChecked();
speed_data->variables_[i].normal_voltage_high = ui->doubleSpinBox_high_4->value();
speed_data->variables_[i].normal_voltage_low = ui->doubleSpinBox_low_4->value();
speed_data->variables_[i].speed_peek = ui->full_scale_range_4->value();
speed_data->variables_[i].default_speed = ui->default_value_4->value();
if(ui->radioButton_automatic_threshold_4->isChecked()){
speed_data->variables_[i].automatic_threshold = true;
}else{
speed_data->variables_[i].automatic_threshold = false;
}
speed_data->variables_[i].threshold = ui->doubleSpinBox_threshold_4->value();
speed_data->variables_[i].hysteresis = ui->doubleSpinBox_hysteresis_4->value();
speed_data->variables_[i].events_per_revolution = ui->spinBox_events_per_revolution_4->value();
speed_data->variables_[i].record_output = ui->comboBox_record_output_4->currentIndex();
speed_data->variables_[i].two_ma_clamp = ui->checkBox_two_ma_clamp_4->isChecked();
speed_data->variables_[i].alert_latching = ui->radioButton_alert_latching_4->isChecked();
speed_data->variables_[i].overspeed_latching = ui->radioButton_overspeed_latching_4->isChecked();
// -alarm
speed_data->danger_high[i].level = ui->lineEdit_danger_high_level_4->text().toDouble();
speed_data->danger_high[i].hysteresis = ui->lineEdit_danger_high_hysteresis_4->text().toDouble();
speed_data->danger_high[i].delay = ui->lineEdit_danger_high_delay_4->text().toDouble();
speed_data->danger_high[i].enable = ui->checkBox_danger_high_enable_4->isChecked();
speed_data->danger_high[i].latch = ui->checkBox_danger_high_latch_4->isChecked();
speed_data->alert_high[i].level = ui->lineEdit_alert_high_level_4->text().toDouble();
speed_data->alert_high[i].hysteresis = ui->lineEdit_alert_high_hysteresis_4->text().toDouble();
speed_data->alert_high[i].delay = ui->lineEdit_alert_high_delay_4->text().toDouble();
speed_data->alert_high[i].enable = ui->checkBox_alert_high_enable_4->isChecked();
speed_data->alert_high[i].latch = ui->checkBox_alert_high_latch_4->isChecked();
speed_data->danger_low[i].level = ui->lineEdit_danger_low_level_4->text().toDouble();
speed_data->danger_low[i].hysteresis = ui->lineEdit_danger_low_hysteresis_4->text().toDouble();
speed_data->danger_low[i].delay = ui->lineEdit_danger_low_delay_4->text().toDouble();
speed_data->danger_low[i].enable = ui->checkBox_danger_low_enable_4->isChecked();
speed_data->danger_low[i].latch = ui->checkBox_danger_low_latch_4->isChecked();
speed_data->alert_low[i].level = ui->lineEdit_alert_low_level_4->text().toDouble();
speed_data->alert_low[i].hysteresis = ui->lineEdit_alert_low_hysteresis_4->text().toDouble();
speed_data->alert_low[i].delay = ui->lineEdit_alert_low_delay_4->text().toDouble();
speed_data->alert_low[i].enable = ui->checkBox_alert_low_enable_4->isChecked();
speed_data->alert_low[i].latch = ui->checkBox_alert_low_latch_4->isChecked();
}
}
}
void Tachometer::Init() {
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
if (base_ptr == nullptr) {
// do nothing or use template to init it.
std::shared_ptr<TachometerData> speed_data = std::make_shared<TachometerData>();
speed_data->card_type_ = car_type;
speed_data->slot_ = slot_no;
ConfigMgr::Instance()->AddCard(speed_data);
UpdateData(speed_data);
return;
}
std::shared_ptr<TachometerData> speed_data = std::dynamic_pointer_cast<TachometerData>(base_ptr);
for (int i = 0; i < CHANNEL_COUNT_SPEED; i++) {
if (i + 1 == 1) {
ui->checkBox_chan_1->setChecked(speed_data->variables_[i].active);
ui->doubleSpinBox_high_1->setValue(speed_data->variables_[i].normal_voltage_high);
ui->doubleSpinBox_low_1->setValue(speed_data->variables_[i].normal_voltage_low);
ui->full_scale_range_1->setValue(speed_data->variables_[i].speed_peek);
ui->default_value_1->setValue(speed_data->variables_[i].default_speed);
if (speed_data->variables_[i].automatic_threshold) {
ui->radioButton_automatic_threshold_1->setChecked(true);
ui->doubleSpinBox_threshold_1->setEnabled(false);
ui->doubleSpinBox_hysteresis_1->setEnabled(false);
} else {
ui->radioButton_manual_threshold_1->setChecked(true);
ui->doubleSpinBox_threshold_1->setEnabled(true);
ui->doubleSpinBox_hysteresis_1->setEnabled(true);
}
ui->doubleSpinBox_threshold_1->setValue(speed_data->variables_[i].threshold);
ui->doubleSpinBox_hysteresis_1->setValue(speed_data->variables_[i].hysteresis);
ui->spinBox_events_per_revolution_1->setValue(speed_data->variables_[i].events_per_revolution);
ui->comboBox_record_output_1->setCurrentIndex(speed_data->variables_[i].record_output);
ui->checkBox_two_ma_clamp_1->setChecked(speed_data->variables_[i].two_ma_clamp);
if (speed_data->variables_[i].alert_latching) {
ui->radioButton_alert_latching_1->setCheckable(true);
} else {
ui->radioButton_alert_latching_1->setCheckable(false);
}
if (speed_data->variables_[i].overspeed_latching) {
ui->radioButton_overspeed_latching_1->setCheckable(true);
} else {
ui->radioButton_overspeed_latching_1->setCheckable(false);
}
// -alarm
ui->lineEdit_danger_high_level->setText(QString::number(speed_data->danger_high[i].level));
ui->lineEdit_danger_high_hysteresis->setText(QString::number(speed_data->danger_high[i].hysteresis));
ui->lineEdit_danger_high_delay->setText(QString::number(speed_data->danger_high[i].delay));
ui->checkBox_danger_high_enable->setChecked(speed_data->danger_high[i].enable);
ui->checkBox_danger_high_latch->setChecked(speed_data->danger_high[i].latch);
ui->lineEdit_alert_high_level->setText(QString::number(speed_data->alert_high[i].level));
ui->lineEdit_alert_high_hysteresis->setText(QString::number(speed_data->alert_high[i].hysteresis));
ui->lineEdit_alert_high_delay->setText(QString::number(speed_data->alert_high[i].delay));
ui->checkBox_alert_high_enable->setChecked(speed_data->alert_high[i].enable);
ui->checkBox_alert_high_latch->setChecked(speed_data->alert_high[i].latch);
// ui->lineEdit_danger_low_level->setText(QString::number(speed_data->danger_low[i].level));
// ui->lineEdit_danger_low_hysteresis->setText(QString::number(speed_data->danger_low[i].hysteresis));
// ui->lineEdit_danger_low_delay->setText(QString::number(speed_data->danger_low[i].delay));
// ui->checkBox_danger_low_enable->setChecked(speed_data->danger_low[i].enable);
// ui->checkBox_danger_low_latch->setChecked(speed_data->danger_low[i].latch);
// ui->lineEdit_alert_low_level->setText(QString::number(speed_data->alert_low[i].level));
// ui->lineEdit_alert_low_hysteresis->setText(QString::number(speed_data->alert_low[i].hysteresis));
// ui->lineEdit_alert_low_delay->setText(QString::number(speed_data->alert_low[i].delay));
// ui->checkBox_alert_low_enable->setChecked(speed_data->alert_low[i].enable);
// ui->checkBox_alert_low_latch->setChecked(speed_data->alert_low[i].latch);
} else if (i + 1 == 2) {
ui->checkBox_chan_2->setChecked(speed_data->variables_[i].active);
ui->doubleSpinBox_high_2->setValue(speed_data->variables_[i].normal_voltage_high);
ui->doubleSpinBox_low_2->setValue(speed_data->variables_[i].normal_voltage_low);
ui->full_scale_range_2->setValue(speed_data->variables_[i].speed_peek);
ui->default_value_2->setValue(speed_data->variables_[i].default_speed);
if (speed_data->variables_[i].automatic_threshold) {
ui->radioButton_automatic_threshold_2->setChecked(true);
ui->doubleSpinBox_threshold_2->setEnabled(false);
ui->doubleSpinBox_hysteresis_2->setEnabled(false);
} else {
ui->radioButton_manual_threshold_2->setChecked(true);
ui->doubleSpinBox_threshold_2->setEnabled(true);
ui->doubleSpinBox_hysteresis_2->setEnabled(true);
}
ui->doubleSpinBox_threshold_2->setValue(speed_data->variables_[i].threshold);
ui->doubleSpinBox_hysteresis_2->setValue(speed_data->variables_[i].hysteresis);
ui->spinBox_events_per_revolution_2->setValue(speed_data->variables_[i].events_per_revolution);
ui->comboBox_record_output_2->setCurrentIndex(speed_data->variables_[i].record_output);
ui->checkBox_two_ma_clamp_2->setChecked(speed_data->variables_[i].two_ma_clamp);
if (speed_data->variables_[i].alert_latching) {
ui->radioButton_alert_latching_2->setCheckable(true);
} else {
ui->radioButton_alert_latching_2->setCheckable(false);
}
if (speed_data->variables_[i].overspeed_latching) {
ui->radioButton_overspeed_latching_2->setCheckable(true);
} else {
ui->radioButton_overspeed_latching_2->setCheckable(false);
}
// -alarm
ui->lineEdit_danger_high_level_2->setText(QString::number(speed_data->danger_high[i].level));
ui->lineEdit_danger_high_hysteresis_2->setText(QString::number(speed_data->danger_high[i].hysteresis));
ui->lineEdit_danger_high_delay_2->setText(QString::number(speed_data->danger_high[i].delay));
ui->checkBox_danger_high_enable_2->setChecked(speed_data->danger_high[i].enable);
ui->checkBox_danger_high_latch_2->setChecked(speed_data->danger_high[i].latch);
ui->lineEdit_alert_high_level_2->setText(QString::number(speed_data->alert_high[i].level));
ui->lineEdit_alert_high_hysteresis_2->setText(QString::number(speed_data->alert_high[i].hysteresis));
ui->lineEdit_alert_high_delay_2->setText(QString::number(speed_data->alert_high[i].delay));
ui->checkBox_alert_high_enable_2->setChecked(speed_data->alert_high[i].enable);
ui->checkBox_alert_high_latch_2->setChecked(speed_data->alert_high[i].latch);
// ui->lineEdit_danger_low_level_2->setText(QString::number(speed_data->danger_low[i].level));
// ui->lineEdit_danger_low_hysteresis_2->setText(QString::number(speed_data->danger_low[i].hysteresis));
// ui->lineEdit_danger_low_delay_2->setText(QString::number(speed_data->danger_low[i].delay));
// ui->checkBox_danger_low_enable_2->setChecked(speed_data->danger_low[i].enable);
// ui->checkBox_danger_low_latch_2->setChecked(speed_data->danger_low[i].latch);
// ui->lineEdit_alert_low_level_2->setText(QString::number(speed_data->alert_low[i].level));
// ui->lineEdit_alert_low_hysteresis_2->setText(QString::number(speed_data->alert_low[i].hysteresis));
// ui->lineEdit_alert_low_delay_2->setText(QString::number(speed_data->alert_low[i].delay));
// ui->checkBox_alert_low_enable_2->setChecked(speed_data->alert_low[i].enable);
// ui->checkBox_alert_low_latch_2->setChecked(speed_data->alert_low[i].latch);
} else if (i + 1 == 3) {
ui->checkBox_chan_3->setChecked(speed_data->variables_[i].active);
ui->doubleSpinBox_high_3->setValue(speed_data->variables_[i].normal_voltage_high);
ui->doubleSpinBox_low_3->setValue(speed_data->variables_[i].normal_voltage_low);
ui->full_scale_range_3->setValue(speed_data->variables_[i].speed_peek);
ui->default_value_3->setValue(speed_data->variables_[i].default_speed);
if (speed_data->variables_[i].automatic_threshold) {
ui->radioButton_automatic_threshold_3->setChecked(true);
ui->doubleSpinBox_threshold_3->setEnabled(false);
ui->doubleSpinBox_hysteresis_3->setEnabled(false);
} else {
ui->radioButton_manual_threshold_3->setChecked(true);
ui->doubleSpinBox_threshold_3->setEnabled(true);
ui->doubleSpinBox_hysteresis_3->setEnabled(true);
}
ui->doubleSpinBox_threshold_3->setValue(speed_data->variables_[i].threshold);
ui->doubleSpinBox_hysteresis_3->setValue(speed_data->variables_[i].hysteresis);
ui->spinBox_events_per_revolution_3->setValue(speed_data->variables_[i].events_per_revolution);
ui->comboBox_record_output_3->setCurrentIndex(speed_data->variables_[i].record_output);
ui->checkBox_two_ma_clamp_3->setChecked(speed_data->variables_[i].two_ma_clamp);
if (speed_data->variables_[i].alert_latching) {
ui->radioButton_alert_latching_3->setCheckable(true);
} else {
ui->radioButton_alert_latching_3->setCheckable(false);
}
if (speed_data->variables_[i].overspeed_latching) {
ui->radioButton_overspeed_latching_3->setCheckable(true);
} else {
ui->radioButton_overspeed_latching_3->setCheckable(false);
}
// -alarm
ui->lineEdit_danger_high_level_3->setText(QString::number(speed_data->danger_high[i].level));
ui->lineEdit_danger_high_hysteresis_3->setText(QString::number(speed_data->danger_high[i].hysteresis));
ui->lineEdit_danger_high_delay_3->setText(QString::number(speed_data->danger_high[i].delay));
ui->checkBox_danger_high_enable_3->setChecked(speed_data->danger_high[i].enable);
ui->checkBox_danger_high_latch_3->setChecked(speed_data->danger_high[i].latch);
ui->lineEdit_alert_high_level_3->setText(QString::number(speed_data->alert_high[i].level));
ui->lineEdit_alert_high_hysteresis_3->setText(QString::number(speed_data->alert_high[i].hysteresis));
ui->lineEdit_alert_high_delay_3->setText(QString::number(speed_data->alert_high[i].delay));
ui->checkBox_alert_high_enable_3->setChecked(speed_data->alert_high[i].enable);
ui->checkBox_alert_high_latch_3->setChecked(speed_data->alert_high[i].latch);
// ui->lineEdit_danger_low_level_3->setText(QString::number(speed_data->danger_low[i].level));
// ui->lineEdit_danger_low_hysteresis_3->setText(QString::number(speed_data->danger_low[i].hysteresis));
// ui->lineEdit_danger_low_delay_3->setText(QString::number(speed_data->danger_low[i].delay));
// ui->checkBox_danger_low_enable_3->setChecked(speed_data->danger_low[i].enable);
// ui->checkBox_danger_low_latch_3->setChecked(speed_data->danger_low[i].latch);
// ui->lineEdit_alert_low_level_3->setText(QString::number(speed_data->alert_low[i].level));
// ui->lineEdit_alert_low_hysteresis_3->setText(QString::number(speed_data->alert_low[i].hysteresis));
// ui->lineEdit_alert_low_delay_3->setText(QString::number(speed_data->alert_low[i].delay));
// ui->checkBox_alert_low_enable_3->setChecked(speed_data->alert_low[i].enable);
// ui->checkBox_alert_low_latch_3->setChecked(speed_data->alert_low[i].latch);
} else if (i + 1 == 4) {
ui->checkBox_chan_4->setChecked(speed_data->variables_[i].active);
ui->doubleSpinBox_high_4->setValue(speed_data->variables_[i].normal_voltage_high);
ui->doubleSpinBox_low_4->setValue(speed_data->variables_[i].normal_voltage_low);
ui->full_scale_range_4->setValue(speed_data->variables_[i].speed_peek);
ui->default_value_4->setValue(speed_data->variables_[i].default_speed);
if (speed_data->variables_[i].automatic_threshold) {
ui->radioButton_automatic_threshold_4->setChecked(true);
ui->doubleSpinBox_threshold_4->setEnabled(false);
ui->doubleSpinBox_hysteresis_4->setEnabled(false);
} else {
ui->radioButton_manual_threshold_4->setChecked(true);
ui->doubleSpinBox_threshold_4->setEnabled(true);
ui->doubleSpinBox_hysteresis_4->setEnabled(true);
}
ui->doubleSpinBox_threshold_4->setValue(speed_data->variables_[i].threshold);
ui->doubleSpinBox_hysteresis_4->setValue(speed_data->variables_[i].hysteresis);
ui->spinBox_events_per_revolution_4->setValue(speed_data->variables_[i].events_per_revolution);
ui->comboBox_record_output_4->setCurrentIndex(speed_data->variables_[i].record_output);
ui->checkBox_two_ma_clamp_4->setChecked(speed_data->variables_[i].two_ma_clamp);
if (speed_data->variables_[i].alert_latching) {
ui->radioButton_alert_latching_4->setCheckable(true);
} else {
ui->radioButton_alert_latching_4->setCheckable(false);
}
if (speed_data->variables_[i].overspeed_latching) {
ui->radioButton_overspeed_latching_4->setCheckable(true);
} else {
ui->radioButton_overspeed_latching_4->setCheckable(false);
}
// -alarm
ui->lineEdit_danger_high_level_4->setText(QString::number(speed_data->danger_high[i].level));
ui->lineEdit_danger_high_hysteresis_4->setText(QString::number(speed_data->danger_high[i].hysteresis));
ui->lineEdit_danger_high_delay_4->setText(QString::number(speed_data->danger_high[i].delay));
ui->checkBox_danger_high_enable_4->setChecked(speed_data->danger_high[i].enable);
ui->checkBox_danger_high_latch_4->setChecked(speed_data->danger_high[i].latch);
ui->lineEdit_alert_high_level_4->setText(QString::number(speed_data->alert_high[i].level));
ui->lineEdit_alert_high_hysteresis_4->setText(QString::number(speed_data->alert_high[i].hysteresis));
ui->lineEdit_alert_high_delay_4->setText(QString::number(speed_data->alert_high[i].delay));
ui->checkBox_alert_high_enable_4->setChecked(speed_data->alert_high[i].enable);
ui->checkBox_alert_high_latch_4->setChecked(speed_data->alert_high[i].latch);
// ui->lineEdit_danger_low_level_4->setText(QString::number(speed_data->danger_low[i].level));
// ui->lineEdit_danger_low_hysteresis_4->setText(QString::number(speed_data->danger_low[i].hysteresis));
// ui->lineEdit_danger_low_delay_4->setText(QString::number(speed_data->danger_low[i].delay));
// ui->checkBox_danger_low_enable_4->setChecked(speed_data->danger_low[i].enable);
// ui->checkBox_danger_low_latch_4->setChecked(speed_data->danger_low[i].latch);
// ui->lineEdit_alert_low_level_4->setText(QString::number(speed_data->alert_low[i].level));
// ui->lineEdit_alert_low_hysteresis_4->setText(QString::number(speed_data->alert_low[i].hysteresis));
// ui->lineEdit_alert_low_delay_4->setText(QString::number(speed_data->alert_low[i].delay));
// ui->checkBox_alert_low_enable_4->setChecked(speed_data->alert_low[i].enable);
// ui->checkBox_alert_low_latch_4->setChecked(speed_data->alert_low[i].latch);
}
}
}
void Tachometer::on_pushButton_confirm_clicked() {
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
if (base_ptr == nullptr) {
qCritical() << " should not be here";
return;
}
std::shared_ptr<TachometerData> speed_data = std::dynamic_pointer_cast<TachometerData>(base_ptr);
UpdateData(speed_data);
this->close();
}
void Tachometer::on_pushButton_cancel_clicked() {
this->close();
}
void Tachometer::on_radioButton_automatic_threshold_1_clicked()
{
}