289 lines
18 KiB
C++
289 lines
18 KiB
C++
|
|
#include "high_speed_current.h"
|
||
|
|
#include "ui_high_speed_current.h"
|
||
|
|
#include "config_mgr.h"
|
||
|
|
#include <QMessageBox>
|
||
|
|
|
||
|
|
HighSpeedCurrent::HighSpeedCurrent(int slot_no_,CardType cardtype,QWidget *parent)
|
||
|
|
: QWidget(parent)
|
||
|
|
, ui(new Ui::HighSpeedCurrent)
|
||
|
|
{
|
||
|
|
ui->setupUi(this);
|
||
|
|
slot_no = slot_no_;
|
||
|
|
card_type = cardtype;
|
||
|
|
QString slot = QString("%1").arg(slot_no);
|
||
|
|
ui->label_slot->setText(slot);
|
||
|
|
Init();
|
||
|
|
}
|
||
|
|
|
||
|
|
HighSpeedCurrent::~HighSpeedCurrent()
|
||
|
|
{
|
||
|
|
delete ui;
|
||
|
|
}
|
||
|
|
|
||
|
|
void HighSpeedCurrent::UpdateData(std::shared_ptr<HighSpeedCurrentData> ¤t_data){
|
||
|
|
|
||
|
|
current_data->card_type_ = kCardHighSpeedCurrent;
|
||
|
|
current_data->slot_ = slot_no;
|
||
|
|
current_data->version_ = 1;
|
||
|
|
for (int i = 0; i < CHANNEL_COUNT_SPEED; i++){
|
||
|
|
if (i + 1 == 1) {
|
||
|
|
current_data->variables_[i].active = ui->checkBox_chan_1->isChecked();
|
||
|
|
current_data->variables_[i].engineering_unit = ui->lineEdit_engineeringUnit->text();
|
||
|
|
current_data->variables_[i].fullScalePosition = ui->lineEdit_fullScalePosition->text().toFloat();
|
||
|
|
current_data->variables_[i].xfullScalePosition = ui->lineEdit_xfullScalePosition->text().toFloat();
|
||
|
|
current_data->variables_[i].zeroScalePosition = ui->lineEdit_zeroScalePosition->text().toFloat();
|
||
|
|
current_data->variables_[i].xzeroScalePosition = ui->lineEdit_xzeroScalePosition->text().toFloat();
|
||
|
|
current_data->variables_[i].rectifier_funtion = ui->comboBox_rectifier_funtion->currentIndex();
|
||
|
|
// -alarm
|
||
|
|
current_data->danger_high[i].level = ui->lineEdit_danger_high_level->text().toDouble();
|
||
|
|
current_data->danger_high[i].hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble();
|
||
|
|
current_data->danger_high[i].delay = ui->lineEdit_danger_high_delay->text().toDouble();
|
||
|
|
current_data->danger_high[i].enable = ui->checkBox_danger_high_enable->isChecked();
|
||
|
|
current_data->danger_high[i].latch = ui->checkBox_danger_high_latch->isChecked();
|
||
|
|
current_data->alert_high[i].level = ui->lineEdit_alert_high_level->text().toDouble();
|
||
|
|
current_data->alert_high[i].hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble();
|
||
|
|
current_data->alert_high[i].delay = ui->lineEdit_alert_high_delay->text().toDouble();
|
||
|
|
current_data->alert_high[i].enable = ui->checkBox_alert_high_enable->isChecked();
|
||
|
|
current_data->alert_high[i].latch = ui->checkBox_alert_high_latch->isChecked();
|
||
|
|
|
||
|
|
}else if(i + 1 == 2){
|
||
|
|
current_data->variables_[i].active = ui->checkBox_chan_2->isChecked();
|
||
|
|
current_data->variables_[i].engineering_unit = ui->lineEdit_engineeringUnit_2->text();
|
||
|
|
current_data->variables_[i].fullScalePosition = ui->lineEdit_fullScalePosition_2->text().toFloat();
|
||
|
|
current_data->variables_[i].xfullScalePosition = ui->lineEdit_xfullScalePosition_2->text().toFloat();
|
||
|
|
current_data->variables_[i].zeroScalePosition = ui->lineEdit_zeroScalePosition_2->text().toFloat();
|
||
|
|
current_data->variables_[i].xzeroScalePosition = ui->lineEdit_xzeroScalePosition_2->text().toFloat();
|
||
|
|
current_data->variables_[i].rectifier_funtion = ui->comboBox_rectifier_funtion_2->currentIndex();
|
||
|
|
// -alarm
|
||
|
|
current_data->danger_high[i].level = ui->lineEdit_danger_high_level_2->text().toDouble();
|
||
|
|
current_data->danger_high[i].hysteresis = ui->lineEdit_danger_high_hysteresis_2->text().toDouble();
|
||
|
|
current_data->danger_high[i].delay = ui->lineEdit_danger_high_delay_2->text().toDouble();
|
||
|
|
current_data->danger_high[i].enable = ui->checkBox_danger_high_enable_2->isChecked();
|
||
|
|
current_data->danger_high[i].latch = ui->checkBox_danger_high_latch_2->isChecked();
|
||
|
|
current_data->alert_high[i].level = ui->lineEdit_alert_high_level_2->text().toDouble();
|
||
|
|
current_data->alert_high[i].hysteresis = ui->lineEdit_alert_high_hysteresis_2->text().toDouble();
|
||
|
|
current_data->alert_high[i].delay = ui->lineEdit_alert_high_delay_2->text().toDouble();
|
||
|
|
current_data->alert_high[i].enable = ui->checkBox_alert_high_enable_2->isChecked();
|
||
|
|
current_data->alert_high[i].latch = ui->checkBox_alert_high_latch_2->isChecked();
|
||
|
|
}else if(i + 1 == 3){
|
||
|
|
current_data->variables_[i].active = ui->checkBox_chan_3->isChecked();
|
||
|
|
current_data->variables_[i].engineering_unit = ui->lineEdit_engineeringUnit_3->text();
|
||
|
|
current_data->variables_[i].fullScalePosition = ui->lineEdit_fullScalePosition_3->text().toFloat();
|
||
|
|
current_data->variables_[i].xfullScalePosition = ui->lineEdit_xfullScalePosition_3->text().toFloat();
|
||
|
|
current_data->variables_[i].zeroScalePosition = ui->lineEdit_zeroScalePosition_3->text().toFloat();
|
||
|
|
current_data->variables_[i].xzeroScalePosition = ui->lineEdit_xzeroScalePosition_3->text().toFloat();
|
||
|
|
current_data->variables_[i].rectifier_funtion = ui->comboBox_rectifier_funtion_3->currentIndex();
|
||
|
|
// -alarm
|
||
|
|
current_data->danger_high[i].level = ui->lineEdit_danger_high_level_3->text().toDouble();
|
||
|
|
current_data->danger_high[i].hysteresis = ui->lineEdit_danger_high_hysteresis_3->text().toDouble();
|
||
|
|
current_data->danger_high[i].delay = ui->lineEdit_danger_high_delay_3->text().toDouble();
|
||
|
|
current_data->danger_high[i].enable = ui->checkBox_danger_high_enable_3->isChecked();
|
||
|
|
current_data->danger_high[i].latch = ui->checkBox_danger_high_latch_3->isChecked();
|
||
|
|
current_data->alert_high[i].level = ui->lineEdit_alert_high_level_3->text().toDouble();
|
||
|
|
current_data->alert_high[i].hysteresis = ui->lineEdit_alert_high_hysteresis_3->text().toDouble();
|
||
|
|
current_data->alert_high[i].delay = ui->lineEdit_alert_high_delay_3->text().toDouble();
|
||
|
|
current_data->alert_high[i].enable = ui->checkBox_alert_high_enable_3->isChecked();
|
||
|
|
current_data->alert_high[i].latch = ui->checkBox_alert_high_latch_3->isChecked();
|
||
|
|
}else if(i + 1 == 4){
|
||
|
|
current_data->variables_[i].active = ui->checkBox_chan_4->isChecked();
|
||
|
|
current_data->variables_[i].engineering_unit = ui->lineEdit_engineeringUnit_4->text();
|
||
|
|
current_data->variables_[i].fullScalePosition = ui->lineEdit_fullScalePosition_4->text().toFloat();
|
||
|
|
current_data->variables_[i].xfullScalePosition = ui->lineEdit_xfullScalePosition_4->text().toFloat();
|
||
|
|
current_data->variables_[i].zeroScalePosition = ui->lineEdit_zeroScalePosition_4->text().toFloat();
|
||
|
|
current_data->variables_[i].xzeroScalePosition = ui->lineEdit_xzeroScalePosition_4->text().toFloat();
|
||
|
|
current_data->variables_[i].rectifier_funtion = ui->comboBox_rectifier_funtion_4->currentIndex();
|
||
|
|
// -alarm
|
||
|
|
current_data->danger_high[i].level = ui->lineEdit_danger_high_level_4->text().toDouble();
|
||
|
|
current_data->danger_high[i].hysteresis = ui->lineEdit_danger_high_hysteresis_4->text().toDouble();
|
||
|
|
current_data->danger_high[i].delay = ui->lineEdit_danger_high_delay_4->text().toDouble();
|
||
|
|
current_data->danger_high[i].enable = ui->checkBox_danger_high_enable_4->isChecked();
|
||
|
|
current_data->danger_high[i].latch = ui->checkBox_danger_high_latch_4->isChecked();
|
||
|
|
current_data->alert_high[i].level = ui->lineEdit_alert_high_level_4->text().toDouble();
|
||
|
|
current_data->alert_high[i].hysteresis = ui->lineEdit_alert_high_hysteresis_4->text().toDouble();
|
||
|
|
current_data->alert_high[i].delay = ui->lineEdit_alert_high_delay_4->text().toDouble();
|
||
|
|
current_data->alert_high[i].enable = ui->checkBox_alert_high_enable_4->isChecked();
|
||
|
|
current_data->alert_high[i].latch = ui->checkBox_alert_high_latch_4->isChecked();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
void HighSpeedCurrent::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<HighSpeedCurrentData> current_data = std::make_shared<HighSpeedCurrentData>();
|
||
|
|
current_data->card_type_ = card_type;
|
||
|
|
current_data->slot_ = slot_no;
|
||
|
|
ConfigMgr::Instance()->AddCard(current_data);
|
||
|
|
UpdateData(current_data);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
std::shared_ptr<HighSpeedCurrentData> current_data = std::dynamic_pointer_cast<HighSpeedCurrentData>(base_ptr);
|
||
|
|
for (int i = 0; i < CHANNEL_COUNT_SPEED; i++) {
|
||
|
|
if (i + 1 == 1) {
|
||
|
|
ui->checkBox_chan_1->setChecked(current_data->variables_[i].active);
|
||
|
|
ui->lineEdit_engineeringUnit->setText(current_data->variables_[i].engineering_unit);
|
||
|
|
ui->lineEdit_fullScalePosition->setText(QString::number(current_data->variables_[i].fullScalePosition));
|
||
|
|
ui->lineEdit_xfullScalePosition->setText(QString::number(current_data->variables_[i].xfullScalePosition));
|
||
|
|
ui->lineEdit_zeroScalePosition->setText(QString::number(current_data->variables_[i].zeroScalePosition));
|
||
|
|
ui->lineEdit_xzeroScalePosition->setText(QString::number(current_data->variables_[i].xzeroScalePosition));
|
||
|
|
ui->comboBox_rectifier_funtion->setCurrentIndex(current_data->variables_[i].rectifier_funtion);
|
||
|
|
// -alarm
|
||
|
|
ui->lineEdit_danger_high_level->setText(QString::number(current_data->danger_high[i].level));
|
||
|
|
ui->lineEdit_danger_high_hysteresis->setText(QString::number(current_data->danger_high[i].hysteresis));
|
||
|
|
ui->lineEdit_danger_high_delay->setText(QString::number(current_data->danger_high[i].delay));
|
||
|
|
ui->checkBox_danger_high_enable->setChecked(current_data->danger_high[i].enable);
|
||
|
|
ui->checkBox_danger_high_latch->setChecked(current_data->danger_high[i].latch);
|
||
|
|
|
||
|
|
ui->lineEdit_alert_high_level->setText(QString::number(current_data->alert_high[i].level));
|
||
|
|
ui->lineEdit_alert_high_hysteresis->setText(QString::number(current_data->alert_high[i].hysteresis));
|
||
|
|
ui->lineEdit_alert_high_delay->setText(QString::number(current_data->alert_high[i].delay));
|
||
|
|
ui->checkBox_alert_high_enable->setChecked(current_data->alert_high[i].enable);
|
||
|
|
ui->checkBox_alert_high_latch->setChecked(current_data->alert_high[i].latch);
|
||
|
|
}else if(i + 1 == 2){
|
||
|
|
ui->checkBox_chan_2->setChecked(current_data->variables_[i].active);
|
||
|
|
ui->lineEdit_engineeringUnit_2->setText(current_data->variables_[i].engineering_unit);
|
||
|
|
ui->lineEdit_fullScalePosition_2->setText(QString::number(current_data->variables_[i].fullScalePosition));
|
||
|
|
ui->lineEdit_xfullScalePosition_2->setText(QString::number(current_data->variables_[i].xfullScalePosition));
|
||
|
|
ui->lineEdit_zeroScalePosition_2->setText(QString::number(current_data->variables_[i].zeroScalePosition));
|
||
|
|
ui->lineEdit_xzeroScalePosition_2->setText(QString::number(current_data->variables_[i].xzeroScalePosition));
|
||
|
|
ui->comboBox_rectifier_funtion_2->setCurrentIndex(current_data->variables_[i].rectifier_funtion);
|
||
|
|
// -alarm
|
||
|
|
ui->lineEdit_danger_high_level_2->setText(QString::number(current_data->danger_high[i].level));
|
||
|
|
ui->lineEdit_danger_high_hysteresis_2->setText(QString::number(current_data->danger_high[i].hysteresis));
|
||
|
|
ui->lineEdit_danger_high_delay_2->setText(QString::number(current_data->danger_high[i].delay));
|
||
|
|
ui->checkBox_danger_high_enable_2->setChecked(current_data->danger_high[i].enable);
|
||
|
|
ui->checkBox_danger_high_latch_2->setChecked(current_data->danger_high[i].latch);
|
||
|
|
|
||
|
|
ui->lineEdit_alert_high_level_2->setText(QString::number(current_data->alert_high[i].level));
|
||
|
|
ui->lineEdit_alert_high_hysteresis_2->setText(QString::number(current_data->alert_high[i].hysteresis));
|
||
|
|
ui->lineEdit_alert_high_delay_2->setText(QString::number(current_data->alert_high[i].delay));
|
||
|
|
ui->checkBox_alert_high_enable_2->setChecked(current_data->alert_high[i].enable);
|
||
|
|
ui->checkBox_alert_high_latch_2->setChecked(current_data->alert_high[i].latch);
|
||
|
|
}else if(i + 1 == 3){
|
||
|
|
ui->checkBox_chan_3->setChecked(current_data->variables_[i].active);
|
||
|
|
ui->lineEdit_engineeringUnit_3->setText(current_data->variables_[i].engineering_unit);
|
||
|
|
ui->lineEdit_fullScalePosition_3->setText(QString::number(current_data->variables_[i].fullScalePosition));
|
||
|
|
ui->lineEdit_xfullScalePosition_3->setText(QString::number(current_data->variables_[i].xfullScalePosition));
|
||
|
|
ui->lineEdit_zeroScalePosition_3->setText(QString::number(current_data->variables_[i].zeroScalePosition));
|
||
|
|
ui->lineEdit_xzeroScalePosition_3->setText(QString::number(current_data->variables_[i].xzeroScalePosition));
|
||
|
|
ui->comboBox_rectifier_funtion_3->setCurrentIndex(current_data->variables_[i].rectifier_funtion);
|
||
|
|
// -alarm
|
||
|
|
ui->lineEdit_danger_high_level_3->setText(QString::number(current_data->danger_high[i].level));
|
||
|
|
ui->lineEdit_danger_high_hysteresis_3->setText(QString::number(current_data->danger_high[i].hysteresis));
|
||
|
|
ui->lineEdit_danger_high_delay_3->setText(QString::number(current_data->danger_high[i].delay));
|
||
|
|
ui->checkBox_danger_high_enable_3->setChecked(current_data->danger_high[i].enable);
|
||
|
|
ui->checkBox_danger_high_latch_3->setChecked(current_data->danger_high[i].latch);
|
||
|
|
|
||
|
|
ui->lineEdit_alert_high_level_3->setText(QString::number(current_data->alert_high[i].level));
|
||
|
|
ui->lineEdit_alert_high_hysteresis_3->setText(QString::number(current_data->alert_high[i].hysteresis));
|
||
|
|
ui->lineEdit_alert_high_delay_3->setText(QString::number(current_data->alert_high[i].delay));
|
||
|
|
ui->checkBox_alert_high_enable_3->setChecked(current_data->alert_high[i].enable);
|
||
|
|
ui->checkBox_alert_high_latch_3->setChecked(current_data->alert_high[i].latch);
|
||
|
|
}else if(i + 1 == 4){
|
||
|
|
ui->checkBox_chan_4->setChecked(current_data->variables_[i].active);
|
||
|
|
ui->lineEdit_engineeringUnit_4->setText(current_data->variables_[i].engineering_unit);
|
||
|
|
ui->lineEdit_fullScalePosition_4->setText(QString::number(current_data->variables_[i].fullScalePosition));
|
||
|
|
ui->lineEdit_xfullScalePosition_4->setText(QString::number(current_data->variables_[i].xfullScalePosition));
|
||
|
|
ui->lineEdit_zeroScalePosition_4->setText(QString::number(current_data->variables_[i].zeroScalePosition));
|
||
|
|
ui->lineEdit_xzeroScalePosition_4->setText(QString::number(current_data->variables_[i].xzeroScalePosition));
|
||
|
|
ui->comboBox_rectifier_funtion_4->setCurrentIndex(current_data->variables_[i].rectifier_funtion);
|
||
|
|
// -alarm
|
||
|
|
ui->lineEdit_danger_high_level_4->setText(QString::number(current_data->danger_high[i].level));
|
||
|
|
ui->lineEdit_danger_high_hysteresis_4->setText(QString::number(current_data->danger_high[i].hysteresis));
|
||
|
|
ui->lineEdit_danger_high_delay_4->setText(QString::number(current_data->danger_high[i].delay));
|
||
|
|
ui->checkBox_danger_high_enable_4->setChecked(current_data->danger_high[i].enable);
|
||
|
|
ui->checkBox_danger_high_latch_4->setChecked(current_data->danger_high[i].latch);
|
||
|
|
|
||
|
|
ui->lineEdit_alert_high_level_4->setText(QString::number(current_data->alert_high[i].level));
|
||
|
|
ui->lineEdit_alert_high_hysteresis_4->setText(QString::number(current_data->alert_high[i].hysteresis));
|
||
|
|
ui->lineEdit_alert_high_delay_4->setText(QString::number(current_data->alert_high[i].delay));
|
||
|
|
ui->checkBox_alert_high_enable_4->setChecked(current_data->alert_high[i].enable);
|
||
|
|
ui->checkBox_alert_high_latch_4->setChecked(current_data->alert_high[i].latch);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
ui->comboBox_relative_number->setCurrentIndex(base_ptr->relative_number);
|
||
|
|
ui->comboBox_group->setCurrentIndex(base_ptr->group - 1);
|
||
|
|
}
|
||
|
|
void HighSpeedCurrent::on_lineEdit_engineeringUnit_editingFinished()
|
||
|
|
{
|
||
|
|
QString str = ui->lineEdit_engineeringUnit->text();
|
||
|
|
ui->label_unit1->setText(str);
|
||
|
|
ui->label_unit2->setText(str);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void HighSpeedCurrent::on_lineEdit_engineeringUnit_2_editingFinished()
|
||
|
|
{
|
||
|
|
QString str = ui->lineEdit_engineeringUnit_2->text();
|
||
|
|
ui->label_unit1_2->setText(str);
|
||
|
|
ui->label_unit2_2->setText(str);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void HighSpeedCurrent::on_lineEdit_engineeringUnit_3_editingFinished()
|
||
|
|
{
|
||
|
|
QString str = ui->lineEdit_engineeringUnit_3->text();
|
||
|
|
ui->label_unit1_3->setText(str);
|
||
|
|
ui->label_unit2_3->setText(str);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void HighSpeedCurrent::on_lineEdit_engineeringUnit_4_editingFinished()
|
||
|
|
{
|
||
|
|
QString str = ui->lineEdit_engineeringUnit_4->text();
|
||
|
|
ui->label_unit1_4->setText(str);
|
||
|
|
ui->label_unit2_4->setText(str);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void HighSpeedCurrent::on_pushButton_confirm_clicked()
|
||
|
|
{
|
||
|
|
if(ui->lineEdit_fullScalePosition->text() == "" ||
|
||
|
|
ui->lineEdit_xfullScalePosition->text() == "" ||
|
||
|
|
ui->lineEdit_zeroScalePosition->text() == "" ||
|
||
|
|
ui->lineEdit_xzeroScalePosition->text() == ""){
|
||
|
|
QMessageBox::information(this, QStringLiteral("提示"), "请填写测量上下限数据!");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||
|
|
if (base_ptr == nullptr) {
|
||
|
|
qCritical() << " should not be here";
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
for (int var = 1; var < SLOT_NUM; var ++) {
|
||
|
|
if(ui->comboBox_relative_number->currentIndex() != 0){
|
||
|
|
std::shared_ptr<CardBase> slot_base_ptr = ConfigMgr::Instance()->GetSlotPtr(var);
|
||
|
|
if(slot_base_ptr == nullptr || slot_base_ptr->card_type_ != kCardHighSpeedCurrent)
|
||
|
|
continue;
|
||
|
|
if(var == slot_no)
|
||
|
|
continue;
|
||
|
|
qDebug() << "relative_number" << var << slot_base_ptr->relative_number;
|
||
|
|
if(slot_base_ptr->relative_number == ui->comboBox_relative_number->currentIndex() &&
|
||
|
|
slot_base_ptr->card_type_ != kCardHighSpeedCurrent){
|
||
|
|
QMessageBox::information(this, QStringLiteral("提示"), "板卡相对编号重复!");
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
base_ptr->relative_number = ui->comboBox_relative_number->currentIndex();
|
||
|
|
base_ptr->group = ui->comboBox_group->currentIndex() + 1;
|
||
|
|
|
||
|
|
std::shared_ptr<HighSpeedCurrentData> current_data = std::dynamic_pointer_cast<HighSpeedCurrentData>(base_ptr);
|
||
|
|
UpdateData(current_data);
|
||
|
|
this->close();
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void HighSpeedCurrent::on_pushButton_cancel_clicked()
|
||
|
|
{
|
||
|
|
this->close();
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
void HighSpeedCurrent::on_pushButton_copy_channel_clicked()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
|