diff --git a/TSI_Config.pro b/TSI_Config.pro index bb7c02a..ca9dfcb 100644 --- a/TSI_Config.pro +++ b/TSI_Config.pro @@ -15,19 +15,21 @@ SOURCES += \ common.cpp \ config_mgr.cpp \ connect.cpp \ + dc_output_channel.cpp \ + dc_outputs.cpp \ ethconfig.cpp \ keyphase.cpp \ keyphase_data.cpp \ macconfig.cpp \ main.cpp \ mainwindow.cpp \ + mqtt_config.cpp \ pointname.cpp \ pressure_pulsation.cpp \ radial_vibration.cpp \ rangeslider.cpp \ relaysetting.cpp \ seismic_monitor.cpp \ - setpoint.cpp \ setpoint_tachometer.cpp \ singlerelay.cpp \ singlerelay_data.cpp \ @@ -48,19 +50,21 @@ HEADERS += \ config_mgr.h \ connect.h \ data_config.h \ + dc_output_channel.h \ + dc_outputs.h \ displacement_ds.h \ ethconfig.h \ keyphase.h \ keyphase_data.h \ macconfig.h \ mainwindow.h \ + mqtt_config.h \ pointname.h \ pressure_pulsation.h \ radial_vibration.h \ rangeslider.h \ relaysetting.h \ seismic_monitor.h \ - setpoint.h \ setpoint_tachometer.h \ singlerelay.h \ singlerelay_data.h \ @@ -77,16 +81,18 @@ HEADERS += \ FORMS += \ acceleration.ui \ connect.ui \ + dc_output_channel.ui \ + dc_outputs.ui \ ethconfig.ui \ keyphase.ui \ macconfig.ui \ mainwindow.ui \ + mqtt_config.ui \ pointname.ui \ pressure_pulsation.ui \ radial_vibration.ui \ relaysetting.ui \ seismic_monitor.ui \ - setpoint.ui \ setpoint_tachometer.ui \ singlerelay.ui \ tachometer.ui \ diff --git a/acceleration.cpp b/acceleration.cpp index db4d62b..77b6e77 100644 --- a/acceleration.cpp +++ b/acceleration.cpp @@ -5,7 +5,7 @@ #include #include #include - +#include #include "data_config.h" #include "vibrationdata.h" #include "config_mgr.h" @@ -32,136 +32,6 @@ Acceleration::~Acceleration() { delete ui; } -void Acceleration::on_checkBox_rms_toggled(bool checked) { - // TODO: 自定义的回调 - if (checked) { - if (ui->checkBox_integrate->isChecked()) { - QStringList items = {"0-25 mm/s rms", "0-50 mm/s rms", "自定义"}; - ui->comboBox_direct_value_range->clear(); - ui->comboBox_direct_value_range->addItems(items); - ui->comboBox_direct_value_range->setCurrentIndex(0); - ui->comboBox_1x_value_range->clear(); - ui->comboBox_1x_value_range->addItems(items); - ui->comboBox_1x_value_range->setCurrentIndex(0); - ui->comboBox_2x_value_range->clear(); - ui->comboBox_2x_value_range->addItems(items); - ui->comboBox_2x_value_range->setCurrentIndex(0); - } else { - QStringList items = {"0-20 m/s^2 rms", "0-50 m/s^2 rms", "0-100 m/s^2 rms", "0-200 m/s^2 rms", "自定义"}; - ui->comboBox_direct_value_range->clear(); - ui->comboBox_direct_value_range->addItems(items); - ui->comboBox_direct_value_range->setCurrentIndex(0); - ui->comboBox_1x_value_range->clear(); - ui->comboBox_1x_value_range->addItems(items); - ui->comboBox_1x_value_range->setCurrentIndex(0); - ui->comboBox_2x_value_range->clear(); - ui->comboBox_2x_value_range->addItems(items); - ui->comboBox_2x_value_range->setCurrentIndex(0); - } - return; - } - if (ui->checkBox_integrate->isChecked()) { - QStringList items = {"0-25 mm/s pk", "0-50 mm/s pk", "0-100 mm/s pk", "自定义"}; - ui->comboBox_direct_value_range->clear(); - ui->comboBox_direct_value_range->addItems(items); - ui->comboBox_direct_value_range->setCurrentIndex(0); - ui->comboBox_1x_value_range->clear(); - ui->comboBox_1x_value_range->addItems(items); - ui->comboBox_1x_value_range->setCurrentIndex(0); - ui->comboBox_2x_value_range->clear(); - ui->comboBox_2x_value_range->addItems(items); - ui->comboBox_2x_value_range->setCurrentIndex(0); - } else { - QStringList items = {"0-20 m/s^2 pk", "0-50 m/s^2 pk", "0-100 m/s^2 pk", "0-200 m/s^2 pk", "0-250 m/s^2 pk", "0-400 m/s^2 pk", "自定义"}; - ui->comboBox_direct_value_range->clear(); - ui->comboBox_direct_value_range->addItems(items); - ui->comboBox_direct_value_range->setCurrentIndex(0); - ui->comboBox_1x_value_range->clear(); - ui->comboBox_1x_value_range->addItems(items); - ui->comboBox_1x_value_range->setCurrentIndex(0); - ui->comboBox_2x_value_range->clear(); - ui->comboBox_2x_value_range->addItems(items); - ui->comboBox_2x_value_range->setCurrentIndex(0); - } -} - -void Acceleration::on_checkBox_integrate_toggled(bool checked) { - // TODO: 自定义的回调 - if (checked) { - if (ui->checkBox_rms->isChecked()) { - QStringList items = {"0-25 mm/s rms", "0-50 mm/s rms", "自定义"}; - ui->comboBox_direct_value_range->clear(); - ui->comboBox_direct_value_range->addItems(items); - ui->comboBox_direct_value_range->setCurrentIndex(0); - ui->comboBox_1x_value_range->clear(); - ui->comboBox_1x_value_range->addItems(items); - ui->comboBox_1x_value_range->setCurrentIndex(0); - ui->comboBox_2x_value_range->clear(); - ui->comboBox_2x_value_range->addItems(items); - ui->comboBox_2x_value_range->setCurrentIndex(0); - } else { - QStringList items = {"0-25 mm/s pk", "0-50 mm/s pk", "0-100 mm/s pk", "自定义"}; - ui->comboBox_direct_value_range->clear(); - ui->comboBox_direct_value_range->addItems(items); - ui->comboBox_direct_value_range->setCurrentIndex(0); - ui->comboBox_1x_value_range->clear(); - ui->comboBox_1x_value_range->addItems(items); - ui->comboBox_1x_value_range->setCurrentIndex(0); - ui->comboBox_2x_value_range->clear(); - ui->comboBox_2x_value_range->addItems(items); - ui->comboBox_2x_value_range->setCurrentIndex(0); - } - return; - } - if (ui->checkBox_rms->isChecked()) { - QStringList items = {"0-20 m/s^2 rms", "0-50 m/s^2 rms", "0-100 m/s^2 rms", "0-200 m/s^2 rms", "自定义"}; - ui->comboBox_direct_value_range->clear(); - ui->comboBox_direct_value_range->addItems(items); - ui->comboBox_direct_value_range->setCurrentIndex(0); - ui->comboBox_1x_value_range->clear(); - ui->comboBox_1x_value_range->addItems(items); - ui->comboBox_1x_value_range->setCurrentIndex(0); - ui->comboBox_2x_value_range->clear(); - ui->comboBox_2x_value_range->addItems(items); - ui->comboBox_2x_value_range->setCurrentIndex(0); - } else { - QStringList items = {"0-20 m/s^2 pk", "0-50 m/s^2 pk", "0-100 m/s^2 pk", "0-200 m/s^2 pk", "0-250 m/s^2 pk", "0-400 m/s^2 pk", "自定义"}; - ui->comboBox_direct_value_range->clear(); - ui->comboBox_direct_value_range->addItems(items); - ui->comboBox_direct_value_range->setCurrentIndex(0); - ui->comboBox_1x_value_range->clear(); - ui->comboBox_1x_value_range->addItems(items); - ui->comboBox_1x_value_range->setCurrentIndex(0); - ui->comboBox_2x_value_range->clear(); - ui->comboBox_2x_value_range->addItems(items); - ui->comboBox_2x_value_range->setCurrentIndex(0); - } -} - -void Acceleration::on_checkBox_1x_ampl_toggled(bool checked) { - if (checked) { - ui->comboBox_1x_value_range->setEnabled(true); - ui->doubleSpinBox_1x_ampl_clamp->setEnabled(true); - ui->doubleSpinBox_1x_phase_lag_clamp->setEnabled(true); - return; - } - ui->comboBox_1x_value_range->setEnabled(false); - ui->doubleSpinBox_1x_ampl_clamp->setEnabled(false); - ui->doubleSpinBox_1x_phase_lag_clamp->setEnabled(false); -} - -void Acceleration::on_checkBox_2x_ampl_toggled(bool checked) { - if (checked) { - ui->comboBox_2x_value_range->setEnabled(true); - ui->doubleSpinBox_2x_ampl_clamp->setEnabled(true); - ui->doubleSpinBox_2x_phase_lag_clamp->setEnabled(true); - return; - } - ui->comboBox_2x_value_range->setEnabled(false); - ui->doubleSpinBox_2x_ampl_clamp->setEnabled(false); - ui->doubleSpinBox_2x_phase_lag_clamp->setEnabled(false); -} - void Acceleration::Init() { std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); if (base_ptr == nullptr) { @@ -188,32 +58,71 @@ void Acceleration::Init() { 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->checkBox_1x_ampl->setChecked(variable_ptr->x1_.checked); - ui->comboBox_1x_value_range->setCurrentIndex(variable_ptr->x1_.full_scale_range); - ui->doubleSpinBox_1x_ampl_clamp->setValue(variable_ptr->x1_.clamp_value); - ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variable_ptr->x1_.phase_lag); - ui->checkBox_2x_ampl->setChecked(variable_ptr->x2_.checked); - ui->comboBox_2x_value_range->setCurrentIndex(variable_ptr->x2_.full_scale_range); - ui->doubleSpinBox_2x_ampl_clamp->setValue(variable_ptr->x2_.clamp_value); - ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variable_ptr->x2_.phase_lag); - 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_rms->setChecked(variable_ptr->rms_active_); - ui->checkBox_integrate->setChecked(variable_ptr->integrate_active_); - ui->checkBox_alert_latching->setChecked(variable_ptr->alert_latching_); - ui->checkBox_danger_latching->setChecked(variable_ptr->danger_latching_); - ui->checkBox_timed_ok->setChecked(variable_ptr->timed_ok_); - 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_trip_multiply->setValue(variable_ptr->recorder_out_.trip_multiply); - ui->comboBox_comparision->setCurrentIndex(variable_ptr->recorder_out_.comparision); - ui->spinBox_comparision_percentage->setValue(variable_ptr->recorder_out_.percentage); + + // processed output + // -general + if(variable_ptr->general.output_used) + ui->comboBox_output_used->setCurrentIndex(0); + else + ui->comboBox_output_used->setCurrentIndex(1); + ui->comboBox_engineering_unit->setCurrentIndex(variable_ptr->general.engineering_unit); + ui->comboBox_rectifier_funtion->setCurrentIndex(variable_ptr->general.rectifier_function); + // -alarm + ui->lineEdit_danger_high_level->setText(QString::number(variable_ptr->danger_high.level)); + ui->lineEdit_danger_high_hysteresis->setText(QString::number(variable_ptr->danger_high.hysteresis)); + ui->lineEdit_danger_high_delay->setText(QString::number(variable_ptr->danger_high.delay)); + ui->checkBox_danger_high_enable->setChecked(variable_ptr->danger_high.enable); + ui->checkBox_danger_high_latch->setChecked(variable_ptr->danger_high.latch); + + ui->lineEdit_alert_high_level->setText(QString::number(variable_ptr->alert_high.level)); + ui->lineEdit_alert_high_hysteresis->setText(QString::number(variable_ptr->alert_high.hysteresis)); + ui->lineEdit_alert_high_delay->setText(QString::number(variable_ptr->alert_high.delay)); + ui->checkBox_alert_high_enable->setChecked(variable_ptr->alert_high.enable); + ui->checkBox_alert_high_latch->setChecked(variable_ptr->alert_high.latch); + + ui->lineEdit_danger_low_level->setText(QString::number(variable_ptr->danger_low.level)); + ui->lineEdit_danger_low_hysteresis->setText(QString::number(variable_ptr->danger_low.hysteresis)); + ui->lineEdit_danger_low_delay->setText(QString::number(variable_ptr->danger_low.delay)); + ui->checkBox_danger_low_enable->setChecked(variable_ptr->danger_low.enable); + ui->checkBox_danger_low_latch->setChecked(variable_ptr->danger_low.latch); + + ui->lineEdit_alert_low_level->setText(QString::number(variable_ptr->alert_low.level)); + ui->lineEdit_alert_low_hysteresis->setText(QString::number(variable_ptr->alert_low.hysteresis)); + ui->lineEdit_alert_low_delay->setText(QString::number(variable_ptr->alert_low.delay)); + ui->checkBox_alert_low_enable->setChecked(variable_ptr->alert_low.enable); + ui->checkBox_alert_low_latch->setChecked(variable_ptr->alert_low.latch); + + // + ui->checkBox_enable->setChecked(variable_ptr->freband_output[0].enable); + ui->lineEdit_start->setText(QString::number(variable_ptr->freband_output[0].start)); + ui->lineEdit_end->setText(QString::number(variable_ptr->freband_output[0].end)); + ui->checkBox_enable_2->setChecked(variable_ptr->freband_output[1].enable); + ui->lineEdit_start_2->setText(QString::number(variable_ptr->freband_output[1].start)); + ui->lineEdit_end_2->setText(QString::number(variable_ptr->freband_output[1].end)); + ui->checkBox_enable_3->setChecked(variable_ptr->freband_output[2].enable); + ui->lineEdit_start_3->setText(QString::number(variable_ptr->freband_output[2].start)); + ui->lineEdit_end_3->setText(QString::number(variable_ptr->freband_output[2].end)); + ui->checkBox_enable_4->setChecked(variable_ptr->freband_output[3].enable); + ui->lineEdit_start_4->setText(QString::number(variable_ptr->freband_output[3].start)); + ui->lineEdit_end_4->setText(QString::number(variable_ptr->freband_output[3].end)); + ui->checkBox_enable_5->setChecked(variable_ptr->freband_output[4].enable); + ui->lineEdit_start_5->setText(QString::number(variable_ptr->freband_output[4].start)); + ui->lineEdit_end_5->setText(QString::number(variable_ptr->freband_output[4].end)); + ui->checkBox_enable_6->setChecked(variable_ptr->freband_output[5].enable); + ui->lineEdit_start_6->setText(QString::number(variable_ptr->freband_output[5].start)); + ui->lineEdit_end_6->setText(QString::number(variable_ptr->freband_output[5].end)); + ui->checkBox_enable_7->setChecked(variable_ptr->freband_output[6].enable); + ui->lineEdit_start_7->setText(QString::number(variable_ptr->freband_output[6].start)); + ui->lineEdit_end_7->setText(QString::number(variable_ptr->freband_output[6].end)); + ui->checkBox_enable_8->setChecked(variable_ptr->freband_output[7].enable); + ui->lineEdit_start_8->setText(QString::number(variable_ptr->freband_output[7].start)); + ui->lineEdit_end_8->setText(QString::number(variable_ptr->freband_output[7].end)); + ui->checkBox_enable_9->setChecked(variable_ptr->freband_output[8].enable); + ui->lineEdit_start_9->setText(QString::number(variable_ptr->freband_output[8].start)); + ui->lineEdit_end_9->setText(QString::number(variable_ptr->freband_output[8].end)); + ui->checkBox_enable_10->setChecked(variable_ptr->freband_output[9].enable); + ui->lineEdit_start_10->setText(QString::number(variable_ptr->freband_output[9].start)); + ui->lineEdit_end_10->setText(QString::number(variable_ptr->freband_output[9].end)); } void Acceleration::on_pushButton_confirm_clicked() { @@ -222,9 +131,16 @@ void Acceleration::on_pushButton_confirm_clicked() { qCritical() << "[Acceleration::Init] should not be here"; return; } + if(ui->lineEdit_alert_high_level->text().toFloat() > ui->lineEdit_danger_high_level->text().toDouble()){ + QMessageBox::warning(this, QStringLiteral("警告"), "危险 + 高 必须大于 警报 + 高"); + return; + } std::shared_ptr ptr = std::dynamic_pointer_cast(base_ptr); + ptr->base_config_[channel - 1].channel_type = kVibAcc; std::shared_ptr variable_base = ptr->GetChannelPtr(channel); - if (variable_base == nullptr || variable_base->type_ != kVibAcc) { + std::shared_ptr variable = std::dynamic_pointer_cast(variable_base); + + if (variable_base == nullptr || variable_base->type_ != kVibAcc || variable == nullptr) { if (variable_base == nullptr) { qDebug() << "no channel ptr"; } else { @@ -243,37 +159,71 @@ void Acceleration::on_pushButton_confirm_clicked() { 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->x1_.checked = ui->checkBox_1x_ampl->isChecked(); - variable->x1_.full_scale_range = ui->comboBox_1x_value_range->currentIndex(); - variable->x1_.clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value(); - variable->x1_.custom = 0; // TODO: - variable->x1_.phase_lag = ui->doubleSpinBox_1x_phase_lag_clamp->value(); - variable->x2_.checked = ui->checkBox_2x_ampl->isChecked(); - variable->x2_.full_scale_range = ui->comboBox_2x_value_range->currentIndex(); - variable->x2_.clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value(); - variable->x2_.custom = 0; // TODO: - variable->x2_.phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value(); - variable->recorder_out_.recorder_output = ui->comboBox_recorder_output->currentIndex(); - variable->recorder_out_.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked(); - variable->recorder_out_.trip_multiply = ui->doubleSpinBox_trip_multiply->value(); - variable->recorder_out_.comparision = ui->comboBox_comparision->currentIndex(); - variable->recorder_out_.percentage = ui->spinBox_comparision_percentage->value(); - variable->delay_.alert = ui->spinBox_alert->value(); - variable->delay_.danger = ui->doubleSpinBox_danger->value(); - variable->delay_.active_100ms = ui->checkBox_100ms->isChecked(); - variable->rms_active_ = ui->checkBox_rms->isChecked(); - variable->integrate_active_ = ui->checkBox_integrate->isChecked(); - variable->alert_latching_ = ui->checkBox_alert_latching->isChecked(); - variable->danger_latching_ = ui->checkBox_danger_latching->isChecked(); - variable->timed_ok_ = ui->checkBox_timed_ok->isChecked(); + // processed output + // -general + if(ui->comboBox_output_used->currentIndex() == 0) + variable->general.output_used = true; + else + variable->general.output_used = false; + variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); + variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); + // -alarm + variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble(); + variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble(); + variable->danger_high.delay = ui->lineEdit_danger_high_delay->text().toDouble(); + variable->danger_high.enable = ui->checkBox_danger_high_enable->isChecked(); + variable->danger_high.latch = ui->checkBox_danger_high_latch->isChecked(); + variable->alert_high.level = ui->lineEdit_alert_high_level->text().toDouble(); + variable->alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble(); + variable->alert_high.delay = ui->lineEdit_alert_high_delay->text().toDouble(); + variable->alert_high.enable = ui->checkBox_alert_high_enable->isChecked(); + variable->alert_high.latch = ui->checkBox_alert_high_latch->isChecked(); + variable->danger_low.level = ui->lineEdit_danger_low_level->text().toDouble(); + variable->danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis->text().toDouble(); + variable->danger_low.delay = ui->lineEdit_danger_low_delay->text().toDouble(); + variable->danger_low.enable = ui->checkBox_danger_low_enable->isChecked(); + variable->danger_low.latch = ui->checkBox_danger_low_latch->isChecked(); + variable->alert_low.level = ui->lineEdit_alert_low_level->text().toDouble(); + variable->alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis->text().toDouble(); + variable->alert_low.delay = ui->lineEdit_alert_low_delay->text().toDouble(); + variable->alert_low.enable = ui->checkBox_alert_low_enable->isChecked(); + variable->alert_low.latch = ui->checkBox_alert_low_latch->isChecked(); + // -freband output + variable->freband_output[0].enable = ui->checkBox_enable->isChecked(); + variable->freband_output[0].start = ui->lineEdit_start->text().toDouble(); + variable->freband_output[0].end = ui->lineEdit_end->text().toDouble(); + variable->freband_output[1].enable = ui->checkBox_enable_2->isChecked(); + variable->freband_output[1].start = ui->lineEdit_start_2->text().toDouble(); + variable->freband_output[1].end = ui->lineEdit_end_2->text().toDouble(); + variable->freband_output[2].enable = ui->checkBox_enable_3->isChecked(); + variable->freband_output[2].start = ui->lineEdit_start_3->text().toDouble(); + variable->freband_output[2].end = ui->lineEdit_end_3->text().toDouble(); + variable->freband_output[3].enable = ui->checkBox_enable_4->isChecked(); + variable->freband_output[3].start = ui->lineEdit_start_4->text().toDouble(); + variable->freband_output[3].end = ui->lineEdit_end_4->text().toDouble(); + variable->freband_output[4].enable = ui->checkBox_enable_5->isChecked(); + variable->freband_output[4].start = ui->lineEdit_start_5->text().toDouble(); + variable->freband_output[4].end = ui->lineEdit_end_5->text().toDouble(); + variable->freband_output[5].enable = ui->checkBox_enable_6->isChecked(); + variable->freband_output[5].start = ui->lineEdit_start_6->text().toDouble(); + variable->freband_output[5].end = ui->lineEdit_end_6->text().toDouble(); + variable->freband_output[6].enable = ui->checkBox_enable_7->isChecked(); + variable->freband_output[6].start = ui->lineEdit_start_7->text().toDouble(); + variable->freband_output[6].end = ui->lineEdit_end_7->text().toDouble(); + variable->freband_output[7].enable = ui->checkBox_enable_8->isChecked(); + variable->freband_output[7].start = ui->lineEdit_start_8->text().toDouble(); + variable->freband_output[7].end = ui->lineEdit_end_8->text().toDouble(); + variable->freband_output[8].enable = ui->checkBox_enable_9->isChecked(); + variable->freband_output[8].start = ui->lineEdit_start_9->text().toDouble(); + variable->freband_output[8].end = ui->lineEdit_end_9->text().toDouble(); + variable->freband_output[9].enable = ui->checkBox_enable_10->isChecked(); + variable->freband_output[9].start = ui->lineEdit_start_10->text().toDouble(); + variable->freband_output[9].end = ui->lineEdit_end_10->text().toDouble(); 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(); @@ -283,32 +233,66 @@ void Acceleration::on_pushButton_confirm_clicked() { 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->x1_.checked = ui->checkBox_1x_ampl->isChecked(); - variable->x1_.full_scale_range = ui->comboBox_1x_value_range->currentIndex(); - variable->x1_.clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value(); - variable->x1_.custom = 0; // TODO: - variable->x1_.phase_lag = ui->doubleSpinBox_1x_phase_lag_clamp->value(); - variable->x2_.checked = ui->checkBox_2x_ampl->isChecked(); - variable->x2_.full_scale_range = ui->comboBox_2x_value_range->currentIndex(); - variable->x2_.clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value(); - variable->x2_.custom = 0; // TODO: - variable->x2_.phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value(); - variable->recorder_out_.recorder_output = ui->comboBox_recorder_output->currentIndex(); - variable->recorder_out_.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked(); - variable->recorder_out_.trip_multiply = ui->doubleSpinBox_trip_multiply->value(); - variable->recorder_out_.comparision = ui->comboBox_comparision->currentIndex(); - variable->recorder_out_.percentage = ui->spinBox_comparision_percentage->value(); - variable->delay_.alert = ui->spinBox_alert->value(); - variable->delay_.danger = ui->doubleSpinBox_danger->value(); - variable->delay_.active_100ms = ui->checkBox_100ms->isChecked(); - variable->rms_active_ = ui->checkBox_rms->isChecked(); - variable->integrate_active_ = ui->checkBox_integrate->isChecked(); - variable->alert_latching_ = ui->checkBox_alert_latching->isChecked(); - variable->danger_latching_ = ui->checkBox_danger_latching->isChecked(); - variable->timed_ok_ = ui->checkBox_timed_ok->isChecked(); + // processed output + // -general + if(ui->comboBox_output_used->currentIndex() == 0) + variable->general.output_used = true; + else + variable->general.output_used = false; + variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); + variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); + // -alarm + variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble(); + variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble(); + variable->danger_high.delay = ui->lineEdit_danger_high_delay->text().toDouble(); + variable->danger_high.enable = ui->checkBox_danger_high_enable->isChecked(); + variable->danger_high.latch = ui->checkBox_danger_high_latch->isChecked(); + variable->alert_high.level = ui->lineEdit_alert_high_level->text().toDouble(); + variable->alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble(); + variable->alert_high.delay = ui->lineEdit_alert_high_delay->text().toDouble(); + variable->alert_high.enable = ui->checkBox_alert_high_enable->isChecked(); + variable->alert_high.latch = ui->checkBox_alert_high_latch->isChecked(); + variable->danger_low.level = ui->lineEdit_danger_low_level->text().toDouble(); + variable->danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis->text().toDouble(); + variable->danger_low.delay = ui->lineEdit_danger_low_delay->text().toDouble(); + variable->danger_low.enable = ui->checkBox_danger_low_enable->isChecked(); + variable->danger_low.latch = ui->checkBox_danger_low_latch->isChecked(); + variable->alert_low.level = ui->lineEdit_alert_low_level->text().toDouble(); + variable->alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis->text().toDouble(); + variable->alert_low.delay = ui->lineEdit_alert_low_delay->text().toDouble(); + variable->alert_low.enable = ui->checkBox_alert_low_enable->isChecked(); + variable->alert_low.latch = ui->checkBox_alert_low_latch->isChecked(); + // -freband output + variable->freband_output[0].enable = ui->checkBox_enable->isChecked(); + variable->freband_output[0].start = ui->lineEdit_start->text().toDouble(); + variable->freband_output[0].end = ui->lineEdit_end->text().toDouble(); + variable->freband_output[1].enable = ui->checkBox_enable_2->isChecked(); + variable->freband_output[1].start = ui->lineEdit_start_2->text().toDouble(); + variable->freband_output[1].end = ui->lineEdit_end_2->text().toDouble(); + variable->freband_output[2].enable = ui->checkBox_enable_3->isChecked(); + variable->freband_output[2].start = ui->lineEdit_start_3->text().toDouble(); + variable->freband_output[2].end = ui->lineEdit_end_3->text().toDouble(); + variable->freband_output[3].enable = ui->checkBox_enable_4->isChecked(); + variable->freband_output[3].start = ui->lineEdit_start_4->text().toDouble(); + variable->freband_output[3].end = ui->lineEdit_end_4->text().toDouble(); + variable->freband_output[4].enable = ui->checkBox_enable_5->isChecked(); + variable->freband_output[4].start = ui->lineEdit_start_5->text().toDouble(); + variable->freband_output[4].end = ui->lineEdit_end_5->text().toDouble(); + variable->freband_output[5].enable = ui->checkBox_enable_6->isChecked(); + variable->freband_output[5].start = ui->lineEdit_start_6->text().toDouble(); + variable->freband_output[5].end = ui->lineEdit_end_6->text().toDouble(); + variable->freband_output[6].enable = ui->checkBox_enable_7->isChecked(); + variable->freband_output[6].start = ui->lineEdit_start_7->text().toDouble(); + variable->freband_output[6].end = ui->lineEdit_end_7->text().toDouble(); + variable->freband_output[7].enable = ui->checkBox_enable_8->isChecked(); + variable->freband_output[7].start = ui->lineEdit_start_8->text().toDouble(); + variable->freband_output[7].end = ui->lineEdit_end_8->text().toDouble(); + variable->freband_output[8].enable = ui->checkBox_enable_9->isChecked(); + variable->freband_output[8].start = ui->lineEdit_start_9->text().toDouble(); + variable->freband_output[8].end = ui->lineEdit_end_9->text().toDouble(); + variable->freband_output[9].enable = ui->checkBox_enable_10->isChecked(); + variable->freband_output[9].start = ui->lineEdit_start_10->text().toDouble(); + variable->freband_output[9].end = ui->lineEdit_end_10->text().toDouble(); this->close(); } @@ -319,3 +303,17 @@ void Acceleration::on_pushButton_cancel_clicked() { this->close(); } + +void Acceleration::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 Acceleration::on_lineEdit_danger_high_level_editingFinished() +{ + +} + diff --git a/acceleration.h b/acceleration.h index 21ce04c..1be0827 100644 --- a/acceleration.h +++ b/acceleration.h @@ -23,12 +23,12 @@ class Acceleration : public QWidget { void on_pushButton_set_default_clicked(); void on_pushButton_cancel_clicked(); - void on_checkBox_1x_ampl_toggled(bool checked); - void on_checkBox_2x_ampl_toggled(bool checked); - void on_checkBox_rms_toggled(bool checked); - void on_checkBox_integrate_toggled(bool checked); - private: + void on_lineEdit_alert_high_level_editingFinished(); + + void on_lineEdit_danger_high_level_editingFinished(); + +private: Ui::Acceleration *ui; void Init(); diff --git a/acceleration.ui b/acceleration.ui index e0dbe0e..b2e24e1 100644 --- a/acceleration.ui +++ b/acceleration.ui @@ -11,7 +11,7 @@ - 加速度配置 + 处理后输出 @@ -107,11 +107,11 @@ - 1 + 0 - 滤波配置 + 滤波 @@ -378,714 +378,8 @@ - 特征值和警报配置 + 处理后输出 - - - - 20 - 10 - 431 - 351 - - - - 特征值 - - - - - 20 - 50 - 54 - 12 - - - - 直接值 - - - - - - 10 - 80 - 81 - 16 - - - - 偏置电压 - - - - - - 20 - 110 - 81 - 16 - - - - 1倍频幅值 - - - - - - 20 - 180 - 81 - 16 - - - - 2倍频幅值 - - - - - - 141 - 31 - 48 - 16 - - - - 取值范围 - - - - - - 269 - 31 - 48 - 16 - - - - 默认值 - - - - - - 130 - 50 - 111 - 22 - - - - - 16777215 - 16777215 - - - - - 0-20 m/s^2 pk - - - - - 0-50 m/s^2 pk - - - - - 0-100 m/s^2 pk - - - - - 0-200 m/s^2 pk - - - - - 0-250 m/s^2 pk - - - - - 0-400 m/s^2 pk - - - - - 自定义 - - - - - - - 260 - 50 - 62 - 22 - - - - - 80 - 16777215 - - - - - - - 130 - 80 - 54 - 12 - - - - -24 - - - - - - 260 - 80 - 62 - 22 - - - - 1 - - - - - false - - - - 130 - 110 - 111 - 22 - - - - - 0-20 m/s^2 pk - - - - - 0-50 m/s^2 pk - - - - - 0-100 m/s^2 pk - - - - - 0-200 m/s^2 pk - - - - - 0-250 m/s^2 pk - - - - - 0-400 m/s^2 pk - - - - - 自定义 - - - - - - false - - - - 260 - 110 - 62 - 22 - - - - - - - 20 - 150 - 91 - 16 - - - - 1倍频相位 - - - - - - 20 - 210 - 91 - 16 - - - - 2倍频相位 - - - - - false - - - - 260 - 150 - 62 - 22 - - - - 0 - - - 100.000000000000000 - - - - - false - - - - 260 - 180 - 62 - 22 - - - - - - false - - - - 260 - 210 - 62 - 22 - - - - 0 - - - - - false - - - - 130 - 180 - 111 - 22 - - - - - 0-20 m/s^2 pk - - - - - 0-50 m/s^2 pk - - - - - 0-100 m/s^2 pk - - - - - 0-200 m/s^2 pk - - - - - 0-250 m/s^2 pk - - - - - 0-400 m/s^2 pk - - - - - 自定义 - - - - - - - 20 - 250 - 71 - 16 - - - - 有效值 - - - - - - 130 - 250 - 61 - 16 - - - - 积分 - - - - - - 200 - 240 - 221 - 101 - - - - 延时 - - - - - 20 - 20 - 54 - 12 - - - - 告警 - - - - - - 20 - 50 - 54 - 12 - - - - 危险 - - - - - - 60 - 50 - 61 - 21 - - - - 1 - - - 1.000000000000000 - - - - - - 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 - - - - - - - 190 - 80 - 53 - 15 - - - - Vdc - - - - - - - 460 - 20 - 131 - 16 - - - - 告警锁定 - - - - - - 460 - 40 - 131 - 16 - - - - 危险锁定 - - - - - - 460 - 170 - 121 - 16 - - - - 倍增 - - - - - - 460 - 190 - 62 - 16 - - - - 1.000000000000000 - - - - - - 460 - 210 - 141 - 16 - - - - 1.00 - 3.00 (步进0.25) - - - - - - 460 - 90 - 54 - 12 - - - - 记录输出 - - - - - - 460 - 110 - 141 - 22 - - - - - - - - - - 直接幅值 - - - - - 1倍频幅值 - - - - - 2倍频幅值 - - - - - - - 460 - 140 - 91 - 16 - - - - 2 mA 默认值 - - - - - - 460 - 60 - 181 - 16 - - - - Timed OK channel Defeat - - - - - - 460 - 250 - 121 - 16 - - - - 比较 - - - - - false - - - - 460 - 310 - 61 - 22 - - - - - - false - - - - 460 - 270 - 141 - 22 - - - - - - - - - - 直接幅值 - - - - - 1倍频幅值 - - - - - 2倍频幅值 - - - @@ -1099,6 +393,995 @@ % + + + + 10 + 40 + 621 + 321 + + + + 0 + + + + 常规 + + + + + 200 + 150 + 71 + 16 + + + + 整流器 + + + + + + 200 + 50 + 81 + 16 + + + + 输出使用 + + + + + + 10 + 90 + 150 + 25 + + + + + 150 + 25 + + + + + 150 + 25 + + + + + g + + + + + m/s**2 + + + + + mm/s + + + + + inch/s + + + + + um + + + + + mm + + + + + + + 200 + 100 + 81 + 16 + + + + 工程单位 + + + + + + 10 + 40 + 150 + 25 + + + + + 150 + 25 + + + + + 150 + 25 + + + + + + + + + + + + + + + + + 10 + 140 + 150 + 25 + + + + + 150 + 25 + + + + + 150 + 25 + + + + + True Peak + + + + + True Peak-To-Peak + + + + + RMS Scaled Peak + + + + + RMS Scaled Peak-To-Peak + + + + + AVG + + + + + RMS Scaled AVG + + + + + RMS + + + + + + + 警报 + + + + + 10 + 60 + 71 + 16 + + + + 危险 + 高 + + + + + + 10 + 100 + 71 + 16 + + + + 警报 + 高 + + + + + + 10 + 140 + 71 + 16 + + + + 警报 + 低 + + + + + + 10 + 180 + 71 + 16 + + + + 危险 + 低 + + + + + + 90 + 30 + 41 + 31 + + + + 等级 + + + + + + 170 + 30 + 41 + 31 + + + + 回差 + + + + + + 230 + 30 + 41 + 31 + + + + 延时 + + + + + + 280 + 40 + 41 + 16 + + + + 使能 + + + + + + 340 + 40 + 41 + 16 + + + + 锁存 + + + + + + 80 + 60 + 51 + 20 + + + + + + + 150 + 60 + 51 + 20 + + + + + + + 220 + 60 + 51 + 20 + + + + + + + 220 + 100 + 51 + 20 + + + + + + + 80 + 100 + 51 + 20 + + + + + + + 150 + 100 + 51 + 20 + + + + + + false + + + + 220 + 140 + 51 + 20 + + + + + + false + + + + 150 + 180 + 51 + 20 + + + + + + false + + + + 80 + 140 + 51 + 20 + + + + + + false + + + + 220 + 180 + 51 + 20 + + + + + + false + + + + 80 + 180 + 51 + 20 + + + + + + false + + + + 150 + 140 + 51 + 20 + + + + + + + 290 + 60 + 16 + 16 + + + + + + + + + + 290 + 100 + 16 + 16 + + + + + + + + + false + + + + 290 + 140 + 16 + 16 + + + + + + + + + false + + + + 290 + 180 + 16 + 16 + + + + + + + + + + 350 + 100 + 16 + 16 + + + + + + + + + false + + + + 350 + 180 + 16 + 16 + + + + + + + + + + 350 + 60 + 16 + 16 + + + + + + + + + false + + + + 350 + 140 + 16 + 16 + + + + + + + + + + + + 分频段选择 + + + + + 50 + 90 + 71 + 16 + + + + 使能 + + + + + + 170 + 50 + 91 + 16 + + + + 频率开始(Hz) + + + + + + 320 + 50 + 91 + 16 + + + + 频率结束(Hz) + + + + + + 150 + 90 + 113 + 20 + + + + + + + 300 + 90 + 113 + 20 + + + + + + + 150 + 120 + 113 + 20 + + + + + + + 50 + 120 + 71 + 16 + + + + 使能 + + + + + + 300 + 120 + 113 + 20 + + + + + + + 50 + 150 + 71 + 16 + + + + 使能 + + + + + + 300 + 150 + 113 + 20 + + + + + + + 150 + 150 + 113 + 20 + + + + + + + 50 + 180 + 71 + 16 + + + + 使能 + + + + + + 300 + 180 + 113 + 20 + + + + + + + 150 + 180 + 113 + 20 + + + + + + false + + + + 50 + 210 + 71 + 16 + + + + 使能 + + + + + false + + + + 300 + 210 + 113 + 20 + + + + + + false + + + + 150 + 210 + 113 + 20 + + + + + + false + + + + 50 + 240 + 71 + 16 + + + + 使能 + + + + + false + + + + 300 + 240 + 113 + 20 + + + + + + false + + + + 150 + 240 + 113 + 20 + + + + + + false + + + + 50 + 270 + 71 + 16 + + + + 使能 + + + + + false + + + + 300 + 270 + 113 + 20 + + + + + + false + + + + 150 + 270 + 113 + 20 + + + + + + false + + + + 50 + 300 + 71 + 16 + + + + 使能 + + + + + false + + + + 300 + 300 + 113 + 20 + + + + + + false + + + + 150 + 300 + 113 + 20 + + + + + + false + + + + 50 + 330 + 71 + 16 + + + + 使能 + + + + + false + + + + 300 + 330 + 113 + 20 + + + + + + false + + + + 150 + 330 + 113 + 20 + + + + + + false + + + + 50 + 360 + 71 + 16 + + + + 使能 + + + + + false + + + + 300 + 360 + 113 + 20 + + + + + + false + + + + 150 + 360 + 113 + 20 + + + diff --git a/cardbase.h b/cardbase.h index 8523d52..fdf2398 100644 --- a/cardbase.h +++ b/cardbase.h @@ -24,12 +24,19 @@ class VariableBase { int id_; VibChannelType type_; Filter filter_[3]; - DirectImpl direct_; - GapRange gap_range; - XImpl x1_; - XImpl x2_; - RecorderOut recorder_out_; - Delay delay_; + General general; + AlarmDangerHigh danger_high; + AlarmAlertHigh alert_high; + AlarmDangerLow danger_low; + AlarmAlertLow alert_low; + + General gap_general; + AlarmDangerHigh gap_danger_high; + AlarmAlertHigh gap_alert_high; + AlarmDangerLow gap_danger_low; + AlarmAlertLow gap_alert_low; + + FrequencybandOutput freband_output[10]; }; // 位移 diff --git a/config_mgr.cpp b/config_mgr.cpp index e68e418..27a309d 100644 --- a/config_mgr.cpp +++ b/config_mgr.cpp @@ -47,6 +47,7 @@ void ConfigMgr::Save(QString & file_path) { card_type_[i] != kCardRelayTMRPrimary && card_type_[i] != kCardRelaySingleNOK && card_type_[i] != kCardRelayTMRBackup) { + QJsonObject dc_output; for (int cid = 0; cid < CHANNEL_COUNT; ++cid) { QJsonObject channel_item; if (card_type_[i] == kCardVibSingle || @@ -58,52 +59,50 @@ void ConfigMgr::Save(QString & file_path) { std::shared_ptr ptr = std::dynamic_pointer_cast(base_ptr); channel_item["standby"] = ptr->base_config_[cid].standby; channel_item["active"] = ptr->base_config_[cid].active; - channel_item["rack_type"] = 0; // TODO: +// channel_item["rack_type"] = 0; // TODO: channel_item["channel_type"] = ptr->base_config_[cid].channel_type; - channel_item["transducer_id"] = ptr->base_config_[cid].transducer_id; - channel_item["scale_factor"] = ptr->base_config_[cid].scale_factor; - channel_item["sampling_rate"] = ptr->base_config_[cid].sampling_rate; +// channel_item["transducer_id"] = ptr->base_config_[cid].transducer_id; +// channel_item["scale_factor"] = ptr->base_config_[cid].scale_factor; +// channel_item["sampling_rate"] = ptr->base_config_[cid].sampling_rate; channel_item["power"] = ptr->base_config_[cid].power; channel_item["point_name"] = ptr->base_config_[cid].point_name; channel_item["chan_id"] = ptr->base_config_[cid].chan_id; + channel_item["sensitivity_unit"] = ptr->base_config_[cid].sensitivity_unit; + channel_item["signal_sensitivity"] = ptr->base_config_[cid].signal_sensitivity; + QJsonArray voltage_range; voltage_range.append(ptr->base_config_[cid].normal_voltage_low); voltage_range.append(ptr->base_config_[cid].normal_voltage_high); channel_item["normal_voltage_range"] = voltage_range; - QJsonObject setpoint_data; + // output channel + QJsonObject dc_output_item; + if(ptr->dc_output[cid].output_channel != -1){ + dc_output_item["output_channel"] = ptr->dc_output[cid].output_channel; + dc_output_item["minmum"] = ptr->dc_output[cid].minmum; + dc_output_item["maxmum"] = ptr->dc_output[cid].maxmum; + dc_output[QString::number(cid + 1)] = dc_output_item; + } if(ptr->base_config_[cid].channel_type == kVibRadial || ptr->base_config_[cid].channel_type == kVibThrust || ptr->base_config_[cid].channel_type == kVibAcc || ptr->base_config_[cid].channel_type == kVibVelocity ){ if(ptr->base_config_[cid].channel_type != kVibThrust){ - setpoint_data["1x_ampl_upper"] = qRound(ptr->alert_danger[cid].x1_ampl_upper * 10)/10.0; - setpoint_data["1x_ampl_lower"] = qRound(ptr->alert_danger[cid].x1_ampl_lower * 10)/10.0; - setpoint_data["1x_ampl_enable"] = ptr->alert_danger[cid].x1_ampl_enable; - setpoint_data["2x_ampl_upper"] = qRound(ptr->alert_danger[cid].x2_ampl_upper * 10)/10.0; - setpoint_data["2x_ampl_lower"] = qRound(ptr->alert_danger[cid].x2_ampl_lower * 10)/10.0; - setpoint_data["2x_ampl_enable"] = ptr->alert_danger[cid].x2_ampl_enable; channel_item["keyphase"] = ptr->base_config_[cid].keyphase; channel_item["keyphase_slot"] = ptr->base_config_[cid].keyphase_slot; channel_item["keyphase_ch"] = ptr->base_config_[cid].keyphase_ch; - } - setpoint_data["direct_upper"] = qRound(ptr->alert_danger[cid].direct_upper * 10)/10.0; - setpoint_data["direct_enable"] = ptr->alert_danger[cid].direct_enable; - setpoint_data["danger_param"] = ptr->alert_danger[cid].danger_param; - setpoint_data["danger_upper"] = qRound(ptr->alert_danger[cid].danger_upper * 10)/10.0; - setpoint_data["danger_enable"] = ptr->alert_danger[cid].danger_enable; - + } } - if(ptr->base_config_[cid].channel_type == kVibPressurePulsation){ - setpoint_data["low_upper"] = qRound(ptr->alert_danger_press[cid].low_upper * 10)/10.0; - setpoint_data["low_enable"] = ptr->alert_danger_press[cid].low_enable; - setpoint_data["mid1_upper"] = qRound(ptr->alert_danger_press[cid].mid1_upper * 10)/10.0; - setpoint_data["mid1_enable"] = ptr->alert_danger_press[cid].mid1_enable; - setpoint_data["mid2_upper"] = qRound(ptr->alert_danger_press[cid].mid2_upper * 10)/10.0; - setpoint_data["mid2_enable"] = ptr->alert_danger_press[cid].mid2_enable; - setpoint_data["danger_param"] = ptr->alert_danger_press[cid].danger_param; - setpoint_data["danger_upper"] = qRound(ptr->alert_danger_press[cid].danger_upper * 10)/10.0; - setpoint_data["danger_enable"] = ptr->alert_danger_press[cid].danger_enable; - } - channel_item["setpoint"] = setpoint_data; +// if(ptr->base_config_[cid].channel_type == kVibPressurePulsation){ +// setpoint_data["low_upper"] = qRound(ptr->alert_danger_press[cid].low_upper * 10)/10.0; +// setpoint_data["low_enable"] = ptr->alert_danger_press[cid].low_enable; +// setpoint_data["mid1_upper"] = qRound(ptr->alert_danger_press[cid].mid1_upper * 10)/10.0; +// setpoint_data["mid1_enable"] = ptr->alert_danger_press[cid].mid1_enable; +// setpoint_data["mid2_upper"] = qRound(ptr->alert_danger_press[cid].mid2_upper * 10)/10.0; +// setpoint_data["mid2_enable"] = ptr->alert_danger_press[cid].mid2_enable; +// setpoint_data["danger_param"] = ptr->alert_danger_press[cid].danger_param; +// setpoint_data["danger_upper"] = qRound(ptr->alert_danger_press[cid].danger_upper * 10)/10.0; +// setpoint_data["danger_enable"] = ptr->alert_danger_press[cid].danger_enable; +// } +// channel_item["setpoint"] = setpoint_data; // variables QJsonObject variables; std::shared_ptr base_channel_ptr = ptr->GetChannelPtr(cid + 1); @@ -133,41 +132,66 @@ void ConfigMgr::Save(QString & file_path) { band_pass["checked"] = radial_ptr->filter_[2].checked; filter.append(band_pass); variables["filter"] = filter; - QJsonObject direct; - QJsonObject x1; - QJsonObject x2; - QJsonObject recorder_out; - QJsonObject delay; - QJsonArray latching; - direct["full_scale_range"] = radial_ptr->direct_.full_scale_range; - direct["clamp_value"] = radial_ptr->direct_.clamp_value; - direct["custom"] = radial_ptr->direct_.custom; - variables["direct"] = direct; - x1["checked"] = radial_ptr->x1_.checked; - x1["full_scale_range"] = radial_ptr->x1_.full_scale_range; - x1["clamp_value"] = radial_ptr->x1_.clamp_value; - x1["custom"] = radial_ptr->x1_.custom; - x1["phase_lag"] = radial_ptr->x1_.phase_lag; - variables["x1"] = x1; - x2["checked"] = radial_ptr->x2_.checked; - x2["full_scale_range"] = radial_ptr->x2_.full_scale_range; - x2["clamp_value"] = radial_ptr->x2_.clamp_value; - x2["custom"] = radial_ptr->x2_.custom; - x2["phase_lag"] = radial_ptr->x2_.phase_lag; - variables["x2"] = x2; - recorder_out["recorder_output"] = radial_ptr->recorder_out_.recorder_output; - recorder_out["two_ma_clamp"] = radial_ptr->recorder_out_.two_ma_clamp; - recorder_out["trip_multiply"] = radial_ptr->recorder_out_.trip_multiply; - recorder_out["comparision"] = radial_ptr->recorder_out_.comparision; - recorder_out["percentage"] = radial_ptr->recorder_out_.percentage; - variables["recorder_out"] = recorder_out; - delay["alert"] = radial_ptr->delay_.alert; - delay["danger"] = radial_ptr->delay_.danger; - delay["active_100ms"] = radial_ptr->delay_.active_100ms; - variables["delay"] = delay; - latching.append(radial_ptr->alert_latching_); - latching.append(radial_ptr->danger_latching_); - variables["latching"] = latching; + // measurement + QJsonObject measurement,general,alarm; + general["output_used"] = radial_ptr->general.output_used; + general["engieneering_unit"] = radial_ptr->general.engineering_unit; + general["rectifier_function"] = radial_ptr->general.rectifier_function; + + alarm["danger_high_level"] = radial_ptr->danger_high.level; + alarm["danger_high_hysteresis"] = radial_ptr->danger_high.hysteresis; + alarm["danger_high_delay"] = radial_ptr->danger_high.delay; + alarm["danger_high_enable"] = radial_ptr->danger_high.enable; + alarm["danger_high_latch"] = radial_ptr->danger_high.latch; + alarm["alert_high_level"] = radial_ptr->alert_high.level; + alarm["alert_high_hysteresis"] = radial_ptr->alert_high.hysteresis; + alarm["alert_high_delay"] = radial_ptr->alert_high.delay; + alarm["alert_high_enable"] = radial_ptr->alert_high.enable; + alarm["alert_high_latch"] = radial_ptr->alert_high.latch; +// alarm["danger_low_level"] = radial_ptr->danger_low.level; +// alarm["danger_low_hysteresis"] = radial_ptr->danger_low.hysteresis; +// alarm["danger_low_delay"] = radial_ptr->danger_low.delay; +// alarm["danger_low_enable"] = radial_ptr->danger_low.enable; +// alarm["danger_low_latch"] = radial_ptr->danger_low.latch; +// alarm["alert_low_level"] = radial_ptr->alert_low.level; +// alarm["alert_low_hysteresis"] = radial_ptr->alert_low.hysteresis; +// alarm["alert_low_delay"] = radial_ptr->alert_low.delay; +// alarm["alert_low_enable"] = radial_ptr->alert_low.enable; +// alarm["alert_low_latch"] = radial_ptr->alert_low.latch; + measurement["general"] = general; + measurement["alarm"] = alarm; + variables["measurement"] = measurement; + // gap + QJsonObject gap,gap_general,gap_alarm; + gap_general["output_used"] = radial_ptr->gap_general.output_used; + gap_general["engieneering_unit"] = radial_ptr->gap_general.engineering_unit; + gap_general["rectifier_function"] = radial_ptr->gap_general.rectifier_function; + + gap_alarm["danger_high_level"] = radial_ptr->gap_danger_high.level; + gap_alarm["danger_high_hysteresis"] = radial_ptr->gap_danger_high.hysteresis; + gap_alarm["danger_high_delay"] = radial_ptr->gap_danger_high.delay; + gap_alarm["danger_high_enable"] = radial_ptr->gap_danger_high.enable; + gap_alarm["danger_high_latch"] = radial_ptr->gap_danger_high.latch; + gap_alarm["alert_high_level"] = radial_ptr->gap_alert_high.level; + gap_alarm["alert_high_hysteresis"] = radial_ptr->gap_alert_high.hysteresis; + gap_alarm["alert_high_delay"] = radial_ptr->gap_alert_high.delay; + gap_alarm["alert_high_enable"] = radial_ptr->gap_alert_high.enable; + gap_alarm["alert_high_latch"] = radial_ptr->gap_alert_high.latch; +// gap_alarm["danger_low_level"] = radial_ptr->gap_danger_low.level; +// gap_alarm["danger_low_hysteresis"] = radial_ptr->gap_danger_low.hysteresis; +// gap_alarm["danger_low_delay"] = radial_ptr->gap_danger_low.delay; +// gap_alarm["danger_low_enable"] = radial_ptr->gap_danger_low.enable; +// gap_alarm["danger_low_latch"] = radial_ptr->gap_danger_low.latch; +// gap_alarm["alert_low_level"] = radial_ptr->gap_alert_low.level; +// gap_alarm["alert_low_hysteresis"] = radial_ptr->gap_alert_low.hysteresis; +// gap_alarm["alert_low_delay"] = radial_ptr->gap_alert_low.delay; +// gap_alarm["alert_low_enable"] = radial_ptr->gap_alert_low.enable; +// gap_alarm["alert_low_latch"] = radial_ptr->gap_alert_low.latch; + gap["general"] = gap_general; + gap["alarm"] = gap_alarm; + variables["gap"] = gap; + + }else if(ptr->base_config_[cid].channel_type == kVibThrust){ std::shared_ptr thrust_ptr = std::dynamic_pointer_cast(base_channel_ptr); if(thrust_ptr == nullptr){ @@ -191,33 +215,37 @@ void ConfigMgr::Save(QString & file_path) { band_pass["checked"] = thrust_ptr->filter_[2].checked; filter.append(band_pass); variables["filter"] = filter; - QJsonObject direct,gap; - QJsonObject recorder_out; - QJsonObject delay; - QJsonArray latching; - direct["full_scale_range"] = thrust_ptr->direct_.full_scale_range; - direct["clamp_value"] = thrust_ptr->direct_.clamp_value; - direct["custom"] = thrust_ptr->direct_.custom; - variables["direct"] = direct; - gap["full_scale_range"] = thrust_ptr->gap_range.full_scale_range; - gap["custom"] = thrust_ptr->gap_range.custom; + // gap + QJsonObject gap,gap_general,gap_alarm; + gap_general["output_used"] = thrust_ptr->gap_general.output_used; + gap_general["engieneering_unit"] = thrust_ptr->gap_general.engineering_unit; + + gap_alarm["danger_high_level"] = thrust_ptr->gap_danger_high.level; + gap_alarm["danger_high_hysteresis"] = thrust_ptr->gap_danger_high.hysteresis; + gap_alarm["danger_high_delay"] = thrust_ptr->gap_danger_high.delay; + gap_alarm["danger_high_enable"] = thrust_ptr->gap_danger_high.enable; + gap_alarm["danger_high_latch"] = thrust_ptr->gap_danger_high.latch; + gap_alarm["alert_high_level"] = thrust_ptr->gap_alert_high.level; + gap_alarm["alert_high_hysteresis"] = thrust_ptr->gap_alert_high.hysteresis; + gap_alarm["alert_high_delay"] = thrust_ptr->gap_alert_high.delay; + gap_alarm["alert_high_enable"] = thrust_ptr->gap_alert_high.enable; + gap_alarm["alert_high_latch"] = thrust_ptr->gap_alert_high.latch; + gap_alarm["danger_low_level"] = thrust_ptr->gap_danger_low.level; + gap_alarm["danger_low_hysteresis"] = thrust_ptr->gap_danger_low.hysteresis; + gap_alarm["danger_low_delay"] = thrust_ptr->gap_danger_low.delay; + gap_alarm["danger_low_enable"] = thrust_ptr->gap_danger_low.enable; + gap_alarm["danger_low_latch"] = thrust_ptr->gap_danger_low.latch; + gap_alarm["alert_low_level"] = thrust_ptr->gap_alert_low.level; + gap_alarm["alert_low_hysteresis"] = thrust_ptr->gap_alert_low.hysteresis; + gap_alarm["alert_low_delay"] = thrust_ptr->gap_alert_low.delay; + gap_alarm["alert_low_enable"] = thrust_ptr->gap_alert_low.enable; + gap_alarm["alert_low_latch"] = thrust_ptr->gap_alert_low.latch; + gap["general"] = gap_general; + gap["alarm"] = gap_alarm; variables["gap"] = gap; - recorder_out["recorder_output"] = thrust_ptr->recorder_out_.recorder_output; - recorder_out["two_ma_clamp"] = thrust_ptr->recorder_out_.two_ma_clamp; - recorder_out["trip_multiply"] = thrust_ptr->recorder_out_.trip_multiply; - recorder_out["comparision"] = thrust_ptr->recorder_out_.comparision; - recorder_out["percentage"] = thrust_ptr->recorder_out_.percentage; - variables["recorder_out"] = recorder_out; - delay["alert"] = thrust_ptr->delay_.alert; - delay["danger"] = thrust_ptr->delay_.danger; - delay["active_100ms"] = thrust_ptr->delay_.active_100ms; - variables["delay"] = delay; - latching.append(thrust_ptr->alert_latching_); - latching.append(thrust_ptr->danger_latching_); - latching.append(thrust_ptr->timed_ok_); - variables["zero_position"] = thrust_ptr->zero_position.value; variables["negation"] = thrust_ptr->zero_position.negation; - variables["latching"] = latching; + variables["zero_position"] = thrust_ptr->zero_position.value; + }else if(ptr->base_config_[cid].channel_type == kVibPressurePulsation){ std::shared_ptr pressure_ptr = std::dynamic_pointer_cast(base_channel_ptr); if(pressure_ptr == nullptr){ @@ -253,8 +281,21 @@ void ConfigMgr::Save(QString & file_path) { scaling["scale_max"] = pressure_ptr->scale_max; variables["sampling"] = sampling; variables["scaling"] = scaling; + QJsonObject general; + general["engieneering_unit"] = pressure_ptr->general.engineering_unit; + variables["general"] = general; + QJsonObject freband_output,number; + for (int var = 0; var < 10; ++var) { + if(pressure_ptr->freband_output[var].start != 0 || pressure_ptr->freband_output[var].end != 0){ + freband_output["enable"] = pressure_ptr->freband_output[var].enable; + freband_output["start"] = pressure_ptr->freband_output[var].start; + freband_output["end"] = pressure_ptr->freband_output[var].end; + number[QString::number(var + 1)] = freband_output; + } + } + variables["freband_output"] = number; - } else { + } else if(ptr->base_config_[cid].channel_type == kVibAcc){ std::shared_ptr av_ptr = std::dynamic_pointer_cast(base_channel_ptr); if(av_ptr == nullptr){ continue; @@ -277,46 +318,98 @@ void ConfigMgr::Save(QString & file_path) { band_pass["checked"] = av_ptr->filter_[2].checked; filter.append(band_pass); variables["filter"] = filter; - QJsonObject direct; - QJsonObject x1; - QJsonObject x2; - QJsonObject recorder_out; - QJsonObject delay; - QJsonArray latching; - direct["full_scale_range"] = av_ptr->direct_.full_scale_range; - direct["clamp_value"] = av_ptr->direct_.clamp_value; - direct["custom"] = av_ptr->direct_.custom; - variables["direct"] = direct; - x1["checked"] = av_ptr->x1_.checked; - x1["full_scale_range"] = av_ptr->x1_.full_scale_range; - x1["clamp_value"] = av_ptr->x1_.clamp_value; - x1["custom"] = av_ptr->x1_.custom; - x1["phase_lag"] = av_ptr->x1_.phase_lag; - variables["x1"] = x1; - x2["checked"] = av_ptr->x2_.checked; - x2["full_scale_range"] = av_ptr->x2_.full_scale_range; - x2["clamp_value"] = av_ptr->x2_.clamp_value; - x2["custom"] = av_ptr->x2_.custom; - x2["phase_lag"] = av_ptr->x2_.phase_lag; - variables["x2"] = x2; - QJsonObject rms_integrate; - rms_integrate["rms_active"] = av_ptr->rms_active_; - rms_integrate["integrate_active"] = av_ptr->integrate_active_; - variables["rms_integrate"] = rms_integrate; - recorder_out["recorder_output"] = av_ptr->recorder_out_.recorder_output; - recorder_out["two_ma_clamp"] = av_ptr->recorder_out_.two_ma_clamp; - recorder_out["trip_multiply"] = av_ptr->recorder_out_.trip_multiply; - recorder_out["comparision"] = av_ptr->recorder_out_.comparision; - recorder_out["percentage"] = av_ptr->recorder_out_.percentage; - variables["recorder_out"] = recorder_out; - delay["alert"] = av_ptr->delay_.alert; - delay["danger"] = av_ptr->delay_.danger; - delay["active_100ms"] = av_ptr->delay_.active_100ms; - variables["delay"] = delay; - latching.append(av_ptr->alert_latching_); - latching.append(av_ptr->danger_latching_); - latching.append(av_ptr->timed_ok_); - variables["latching"] = latching; + // processed output + QJsonObject processed_output,general,alarm; + general["output_used"] = av_ptr->general.output_used; + general["engieneering_unit"] = av_ptr->general.engineering_unit; + general["rectifier_function"] = av_ptr->general.rectifier_function; + + alarm["danger_high_level"] = av_ptr->danger_high.level; + alarm["danger_high_hysteresis"] = av_ptr->danger_high.hysteresis; + alarm["danger_high_delay"] = av_ptr->danger_high.delay; + alarm["danger_high_enable"] = av_ptr->danger_high.enable; + alarm["danger_high_latch"] = av_ptr->danger_high.latch; + alarm["alert_high_level"] = av_ptr->alert_high.level; + alarm["alert_high_hysteresis"] = av_ptr->alert_high.hysteresis; + alarm["alert_high_delay"] = av_ptr->alert_high.delay; + alarm["alert_high_enable"] = av_ptr->alert_high.enable; + alarm["alert_high_latch"] = av_ptr->alert_high.latch; +// alarm["danger_low_level"] = av_ptr->danger_low.level; +// alarm["danger_low_hysteresis"] = av_ptr->danger_low.hysteresis; +// alarm["danger_low_delay"] = av_ptr->danger_low.delay; +// alarm["danger_low_enable"] = av_ptr->danger_low.enable; +// alarm["danger_low_latch"] = av_ptr->danger_low.latch; +// alarm["alert_low_level"] = av_ptr->alert_low.level; +// alarm["alert_low_hysteresis"] = av_ptr->alert_low.hysteresis; +// alarm["alert_low_delay"] = av_ptr->alert_low.delay; +// alarm["alert_low_enable"] = av_ptr->alert_low.enable; +// alarm["alert_low_latch"] = av_ptr->alert_low.latch; + processed_output["general"] = general; + processed_output["alarm"] = alarm; + variables["processed_output"] = processed_output; + QJsonObject freband_output,number; + for (int var = 0; var < 10; ++var) { + if(av_ptr->freband_output[var].start != 0 || av_ptr->freband_output[var].end != 0){ + freband_output["enable"] = av_ptr->freband_output[var].enable; + freband_output["start"] = av_ptr->freband_output[var].start; + freband_output["end"] = av_ptr->freband_output[var].end; + number[QString::number(var + 1)] = freband_output; + } + } + variables["freband_output"] = number; + + }else if(ptr->base_config_[cid].channel_type == kVibVelocity){ + std::shared_ptr vel_ptr = std::dynamic_pointer_cast(base_channel_ptr); + if(vel_ptr == nullptr){ + continue; + } + // filter + QJsonArray filter; + QJsonObject low_pass; + low_pass["low"] = vel_ptr->filter_[0].low; + low_pass["high"] = vel_ptr->filter_[0].high; + low_pass["checked"] = vel_ptr->filter_[0].checked; + filter.append(low_pass); + QJsonObject high_pass; + high_pass["low"] = vel_ptr->filter_[1].low; + high_pass["high"] = vel_ptr->filter_[1].high; + high_pass["checked"] = vel_ptr->filter_[1].checked; + filter.append(high_pass); + QJsonObject band_pass; + band_pass["low"] = vel_ptr->filter_[2].low; + band_pass["high"] = vel_ptr->filter_[2].high; + band_pass["checked"] = vel_ptr->filter_[2].checked; + filter.append(band_pass); + variables["filter"] = filter; + // processed output + QJsonObject processed_output,general,alarm; + general["output_used"] = vel_ptr->general.output_used; + general["engieneering_unit"] = vel_ptr->general.engineering_unit; + general["rectifier_function"] = vel_ptr->general.rectifier_function; + + alarm["danger_high_level"] = vel_ptr->danger_high.level; + alarm["danger_high_hysteresis"] = vel_ptr->danger_high.hysteresis; + alarm["danger_high_delay"] = vel_ptr->danger_high.delay; + alarm["danger_high_enable"] = vel_ptr->danger_high.enable; + alarm["danger_high_latch"] = vel_ptr->danger_high.latch; + alarm["alert_high_level"] = vel_ptr->alert_high.level; + alarm["alert_high_hysteresis"] = vel_ptr->alert_high.hysteresis; + alarm["alert_high_delay"] = vel_ptr->alert_high.delay; + alarm["alert_high_enable"] = vel_ptr->alert_high.enable; + alarm["alert_high_latch"] = vel_ptr->alert_high.latch; +// alarm["danger_low_level"] = vel_ptr->danger_low.level; +// alarm["danger_low_hysteresis"] = vel_ptr->danger_low.hysteresis; +// alarm["danger_low_delay"] = vel_ptr->danger_low.delay; +// alarm["danger_low_enable"] = vel_ptr->danger_low.enable; +// alarm["danger_low_latch"] = vel_ptr->danger_low.latch; +// alarm["alert_low_level"] = vel_ptr->alert_low.level; +// alarm["alert_low_hysteresis"] = vel_ptr->alert_low.hysteresis; +// alarm["alert_low_delay"] = vel_ptr->alert_low.delay; +// alarm["alert_low_enable"] = vel_ptr->alert_low.enable; +// alarm["alert_low_latch"] = vel_ptr->alert_low.latch; + processed_output["general"] = general; + processed_output["alarm"] = alarm; + variables["processed_output"] = processed_output; } channel_item["variable"] = variables; } else if (card_type_[i] == kCardSpeedSingle || card_type_[i] == kCardSpeedTMRPrimary) { @@ -367,6 +460,7 @@ void ConfigMgr::Save(QString & file_path) { channel_item.insert("automatic_threshold",ptr->variables_[cid].automatic_threshold); } slot_item[QString::number(cid + 1)] = channel_item; + slot_item["dc_output"] = dc_output; } slot_item["version"] = 1; }else{ @@ -451,6 +545,20 @@ void ConfigMgr::Load(QString filename) { vib_data->version_ = temp_obj["version"].toInt(); vib_data->card_type_ = static_cast(card_type_[i]); vib_data->slot_ = slot; + // dc_output + QJsonObject dc_output_obj = temp_obj["dc_output"].toObject(); + if(!dc_output_obj.isEmpty()){ + QJsonObject output_obj; + for (int var = 0; var < CHANNEL_COUNT; ++var) { + output_obj = dc_output_obj[QString::number(var + 1)].toObject(); + if(output_obj.isEmpty()) + continue; + vib_data->dc_output[var].output_channel = output_obj["output_channel"].toInt(); + vib_data->dc_output[var].minmum = output_obj["minmum"].toDouble(); + vib_data->dc_output[var].maxmum = output_obj["maxmum"].toDouble(); + } + + } for (int j = 0; j < CHANNEL_COUNT; ++j) { std::shared_ptr base_channel_ptr = vib_data->GetChannelPtr(j + 1); channel = temp_obj[QString::number(j + 1)].toObject(); @@ -459,49 +567,43 @@ void ConfigMgr::Load(QString filename) { // base info vib_data->base_config_[j].standby = channel["standby"].toBool(); vib_data->base_config_[j].active = channel["active"].toBool(); - vib_data->base_config_[j].rack_type = channel["rack_type"].toInt(); +// vib_data->base_config_[j].rack_type = channel["rack_type"].toInt(); // vib_data->base_config_[j].tmr_group = channel["tmr_group"].toString(); vib_data->base_config_[j].channel_type = channel["channel_type"].toInt(); vib_data->base_config_[j].transducer_id = channel["transducer_id"].toInt(); - vib_data->base_config_[j].scale_factor = channel["scale_factor"].toDouble(); - vib_data->base_config_[j].sampling_rate = channel["sampling_rate"].toInt(); +// vib_data->base_config_[j].scale_factor = channel["scale_factor"].toDouble(); +// vib_data->base_config_[j].sampling_rate = channel["sampling_rate"].toInt(); QJsonArray voltage_range_array = channel["normal_voltage_range"].toArray(); vib_data->base_config_[j].normal_voltage_low = voltage_range_array[0].toDouble(); vib_data->base_config_[j].normal_voltage_high = voltage_range_array[1].toDouble(); vib_data->base_config_[j].power = channel["power"].toBool(); vib_data->base_config_[j].point_name = channel["point_name"].toString(); vib_data->base_config_[j].chan_id = channel["chan_id"].toString(); - + vib_data->base_config_[j].sensitivity_unit = channel["sensitivity_unit"].toInt(); + vib_data->base_config_[j].signal_sensitivity = channel["signal_sensitivity"].toDouble(); + vib_data->base_config_[j].keyphase = channel["keyphase"].toBool(); + vib_data->base_config_[j].keyphase_slot = channel["keyphase_slot"].toInt(); + vib_data->base_config_[j].keyphase_ch = channel["keyphase_ch"].toInt(); //setpoint QJsonObject setpoint_data = channel["setpoint"].toObject(); if(vib_data->base_config_[j].channel_type == kVibRadial || vib_data->base_config_[j].channel_type == kVibThrust || vib_data->base_config_[j].channel_type == kVibAcc ||vib_data->base_config_[j].channel_type == kVibVelocity ){ - vib_data->alert_danger[j].direct_upper = setpoint_data["direct_upper"].toDouble(); - vib_data->alert_danger[j].direct_enable = setpoint_data["direct_enable"].toBool(); - vib_data->alert_danger[j].x1_ampl_upper = setpoint_data["1x_ampl_upper"].toDouble(); - vib_data->alert_danger[j].x1_ampl_lower = setpoint_data["1x_ampl_lower"].toDouble(); - vib_data->alert_danger[j].x1_ampl_enable = setpoint_data["1x_ampl_enable"].toBool(); - vib_data->alert_danger[j].x2_ampl_upper = setpoint_data["2x_ampl_upper"].toDouble(); - vib_data->alert_danger[j].x2_ampl_lower = setpoint_data["2x_ampl_lower"].toDouble(); - vib_data->alert_danger[j].x2_ampl_enable = setpoint_data["2x_ampl_enable"].toBool(); - vib_data->alert_danger[j].danger_param = setpoint_data["danger_param"].toInt(); - vib_data->alert_danger[j].danger_upper = setpoint_data["danger_upper"].toDouble(); - vib_data->alert_danger[j].danger_enable = setpoint_data["danger_enable"].toBool(); vib_data->base_config_[j].keyphase = channel["keyphase"].toBool(); vib_data->base_config_[j].keyphase_slot = channel["keyphase_slot"].toInt(); vib_data->base_config_[j].keyphase_ch = channel["keyphase_ch"].toInt(); } - if(vib_data->base_config_[j].channel_type == kVibPressurePulsation){ - vib_data->alert_danger_press[j].low_upper = setpoint_data["low_upper"].toDouble(); - vib_data->alert_danger_press[j].low_enable = setpoint_data["low_enable"].toBool(); - vib_data->alert_danger_press[j].mid1_upper = setpoint_data["mid1_upper"].toDouble(); - vib_data->alert_danger_press[j].mid1_enable = setpoint_data["mid1_enable"].toBool(); - vib_data->alert_danger_press[j].mid2_upper = setpoint_data["mid2_upper"].toDouble(); - vib_data->alert_danger_press[j].mid2_enable = setpoint_data["mid2_enable"].toBool(); - vib_data->alert_danger_press[j].danger_param = setpoint_data["danger_param"].toInt(); - vib_data->alert_danger_press[j].danger_upper = setpoint_data["danger_upper"].toDouble(); - vib_data->alert_danger_press[j].danger_enable = setpoint_data["danger_enable"].toBool(); - } + +// if(vib_data->base_config_[j].channel_type == kVibPressurePulsation){ +// vib_data->alert_danger_press[j].low_upper = setpoint_data["low_upper"].toDouble(); +// vib_data->alert_danger_press[j].low_enable = setpoint_data["low_enable"].toBool(); +// vib_data->alert_danger_press[j].mid1_upper = setpoint_data["mid1_upper"].toDouble(); +// vib_data->alert_danger_press[j].mid1_enable = setpoint_data["mid1_enable"].toBool(); +// vib_data->alert_danger_press[j].mid2_upper = setpoint_data["mid2_upper"].toDouble(); +// vib_data->alert_danger_press[j].mid2_enable = setpoint_data["mid2_enable"].toBool(); +// vib_data->alert_danger_press[j].danger_param = setpoint_data["danger_param"].toInt(); +// vib_data->alert_danger_press[j].danger_upper = setpoint_data["danger_upper"].toDouble(); +// vib_data->alert_danger_press[j].danger_enable = setpoint_data["danger_enable"].toBool(); +// } // variables QJsonObject tmp_variable = channel["variable"].toObject(); switch (vib_data->base_config_[j].channel_type) { @@ -516,35 +618,61 @@ void ConfigMgr::Load(QString filename) { variable->filter_[k].checked = filter_ele["checked"].toBool(); } variable->id_ = j + 1; - QJsonObject direct = tmp_variable["direct"].toObject(); - variable->direct_.full_scale_range = direct["full_scale_range"].toInt(); - variable->direct_.clamp_value = direct["clamp_value"].toDouble(); - variable->direct_.custom = direct["custom"].toDouble(); - QJsonObject x1 = tmp_variable["x1"].toObject(); - variable->x1_.checked = x1["checked"].toBool(); - variable->x1_.full_scale_range = x1["full_scale_range"].toInt(); - variable->x1_.clamp_value = x1["clamp_value"].toDouble(); - variable->x1_.custom = x1["custom"].toDouble(); - variable->x1_.phase_lag = x1["phase_lag"].toInt(); - QJsonObject x2 = tmp_variable["x2"].toObject(); - variable->x2_.checked = x2["checked"].toBool(); - variable->x2_.full_scale_range = x2["full_scale_range"].toInt(); - variable->x2_.clamp_value = x2["clamp_value"].toDouble(); - variable->x2_.custom = x2["custom"].toDouble(); - variable->x2_.phase_lag = x2["phase_lag"].toInt(); - QJsonObject recorder_out = tmp_variable["recorder_out"].toObject(); - variable->recorder_out_.recorder_output = recorder_out["recorder_output"].toInt(); - variable->recorder_out_.two_ma_clamp = recorder_out["two_ma_clamp"].toBool(); - variable->recorder_out_.trip_multiply = recorder_out["trip_multiply"].toDouble(); - variable->recorder_out_.comparision = recorder_out["comparision"].toInt(); - variable->recorder_out_.percentage = recorder_out["percentage"].toInt(); - QJsonObject delay = tmp_variable["delay"].toObject(); - variable->delay_.alert = delay["alert"].toInt(); - variable->delay_.danger = delay["danger"].toDouble(); - variable->delay_.active_100ms = delay["active_100ms"].toBool(); - QJsonObject latching = tmp_variable["latching"].toObject(); - variable->alert_latching_ = latching["alert"].toBool(); - variable->danger_latching_ = latching["danger"].toBool(); + QJsonObject measurement, gap,m_general,m_alarm,g_general,g_alarm; + measurement = tmp_variable["measurement"].toObject(); + gap = tmp_variable["gap"].toObject(); + m_general = measurement["general"].toObject(); + m_alarm = measurement["alarm"].toObject(); + g_general = gap["general"].toObject(); + g_alarm = gap["alarm"].toObject(); + variable->general.output_used = m_general["output_used"].toBool(); + variable->general.engineering_unit = m_general["engieneering_unit"].toInt(); + variable->general.rectifier_function = m_general["rectifier_function"].toInt(); + variable->danger_high.level = m_alarm["danger_high_level"].toDouble(); + variable->danger_high.hysteresis = m_alarm["danger_high_hysteresis"].toDouble(); + variable->danger_high.delay = m_alarm["danger_high_delay"].toInt(); + variable->danger_high.enable = m_alarm["danger_high_enable"].toBool(); + variable->danger_high.latch = m_alarm["danger_high_latch"].toBool(); + variable->alert_high.level = m_alarm["alert_high_level"].toDouble(); + variable->alert_high.hysteresis = m_alarm["alert_high_hysteresis"].toDouble(); + variable->alert_high.delay = m_alarm["alert_high_delay"].toInt(); + variable->alert_high.enable = m_alarm["alert_high_enable"].toBool(); + variable->alert_high.latch = m_alarm["alert_high_latch"].toBool(); +// variable->danger_low.level = m_alarm["danger_low_level"].toDouble(); +// variable->danger_low.hysteresis = m_alarm["danger_low_hysteresis"].toDouble(); +// variable->danger_low.delay = m_alarm["danger_low_delay"].toInt(); +// variable->danger_low.enable = m_alarm["danger_low_enable"].toBool(); +// variable->danger_low.latch = m_alarm["danger_low_latch"].toBool(); +// variable->alert_low.level = m_alarm["alert_low_level"].toDouble(); +// variable->alert_low.hysteresis = m_alarm["alert_low_hysteresis"].toDouble(); +// variable->alert_low.delay = m_alarm["alert_low_delay"].toInt(); +// variable->alert_low.enable = m_alarm["alert_low_enable"].toBool(); +// variable->alert_low.latch = m_alarm["alert_low_latch"].toBool(); + + variable->gap_general.output_used = g_general["output_used"].toBool(); + variable->gap_general.engineering_unit = g_general["engieneering_unit"].toInt(); + variable->gap_general.rectifier_function = g_general["rectifier_function"].toInt(); + variable->gap_danger_high.level = g_alarm["danger_high_level"].toDouble(); + variable->gap_danger_high.hysteresis = g_alarm["danger_high_hysteresis"].toDouble(); + variable->gap_danger_high.delay = g_alarm["danger_high_delay"].toInt(); + variable->gap_danger_high.enable = g_alarm["danger_high_enable"].toBool(); + variable->gap_danger_high.latch = g_alarm["danger_high_latch"].toBool(); + variable->gap_alert_high.level = g_alarm["alert_high_level"].toDouble(); + variable->gap_alert_high.hysteresis = g_alarm["alert_high_hysteresis"].toDouble(); + variable->gap_alert_high.delay = g_alarm["alert_high_delay"].toInt(); + variable->gap_alert_high.enable = g_alarm["alert_high_enable"].toBool(); + variable->gap_alert_high.latch = g_alarm["alert_high_latch"].toBool(); +// variable->gap_danger_low.level = g_alarm["danger_low_level"].toDouble(); +// variable->gap_danger_low.hysteresis = g_alarm["danger_low_hysteresis"].toDouble(); +// variable->gap_danger_low.delay = g_alarm["danger_low_delay"].toInt(); +// variable->gap_danger_low.enable = g_alarm["danger_low_enable"].toBool(); +// variable->gap_danger_low.latch = g_alarm["danger_low_latch"].toBool(); +// variable->gap_alert_low.level = g_alarm["alert_low_level"].toDouble(); +// variable->gap_alert_low.hysteresis = g_alarm["alert_low_hysteresis"].toDouble(); +// variable->gap_alert_low.delay = g_alarm["alert_low_delay"].toInt(); +// variable->gap_alert_low.enable = g_alarm["alert_low_enable"].toBool(); +// variable->gap_alert_low.latch = g_alarm["alert_low_latch"].toBool(); + vib_data->variables_.push_back(variable); break; } @@ -559,26 +687,32 @@ void ConfigMgr::Load(QString filename) { variable->filter_[k].checked = filter_ele["checked"].toBool(); } variable->id_ = j + 1; - QJsonObject direct = tmp_variable["direct"].toObject(); - variable->direct_.full_scale_range = direct["full_scale_range"].toInt(); - variable->direct_.clamp_value = direct["clamp_value"].toDouble(); - variable->direct_.custom = direct["custom"].toDouble(); - - QJsonObject gap = tmp_variable["gap"].toObject(); - variable->gap_range.full_scale_range = direct["full_scale_range"].toInt(); - variable->gap_range.custom = direct["custom"].toDouble(); - - QJsonObject recorder_out = tmp_variable["recorder_out"].toObject(); - variable->recorder_out_.recorder_output = recorder_out["recorder_output"].toInt(); - variable->recorder_out_.two_ma_clamp = recorder_out["two_ma_clamp"].toBool(); - QJsonObject delay = tmp_variable["delay"].toObject(); - variable->delay_.alert = delay["alert"].toInt(); - variable->delay_.danger = delay["danger"].toDouble(); - variable->delay_.active_100ms = delay["active_100ms"].toBool(); - QJsonObject latching = tmp_variable["latching"].toObject(); - variable->alert_latching_ = latching["alert"].toBool(); - variable->danger_latching_ = latching["danger"].toBool(); - variable->timed_ok_ = latching["timed_ok"].toBool(); + QJsonObject gap,g_general,g_alarm; + gap = tmp_variable["gap"].toObject(); + g_general = gap["general"].toObject(); + g_alarm = gap["alarm"].toObject(); + variable->gap_general.output_used = g_general["output_used"].toBool(); + variable->gap_general.engineering_unit = g_general["engieneering_unit"].toInt(); + variable->gap_danger_high.level = g_alarm["danger_high_level"].toDouble(); + variable->gap_danger_high.hysteresis = g_alarm["danger_high_hysteresis"].toDouble(); + variable->gap_danger_high.delay = g_alarm["danger_high_delay"].toInt(); + variable->gap_danger_high.enable = g_alarm["danger_high_enable"].toBool(); + variable->gap_danger_high.latch = g_alarm["danger_high_latch"].toBool(); + variable->gap_alert_high.level = g_alarm["alert_high_level"].toDouble(); + variable->gap_alert_high.hysteresis = g_alarm["alert_high_hysteresis"].toDouble(); + variable->gap_alert_high.delay = g_alarm["alert_high_delay"].toInt(); + variable->gap_alert_high.enable = g_alarm["alert_high_enable"].toBool(); + variable->gap_alert_high.latch = g_alarm["alert_high_latch"].toBool(); + variable->gap_danger_low.level = g_alarm["danger_low_level"].toDouble(); + variable->gap_danger_low.hysteresis = g_alarm["danger_low_hysteresis"].toDouble(); + variable->gap_danger_low.delay = g_alarm["danger_low_delay"].toInt(); + variable->gap_danger_low.enable = g_alarm["danger_low_enable"].toBool(); + variable->gap_danger_low.latch = g_alarm["danger_low_latch"].toBool(); + variable->gap_alert_low.level = g_alarm["alert_low_level"].toDouble(); + variable->gap_alert_low.hysteresis = g_alarm["alert_low_hysteresis"].toDouble(); + variable->gap_alert_low.delay = g_alarm["alert_low_delay"].toInt(); + variable->gap_alert_low.enable = g_alarm["alert_low_enable"].toBool(); + variable->gap_alert_low.latch = g_alarm["alert_low_latch"].toBool(); variable->zero_position.value = tmp_variable["zero_position"].toDouble(); variable->zero_position.negation = tmp_variable["negation"].toBool(); vib_data->variables_.push_back(variable); @@ -595,21 +729,89 @@ void ConfigMgr::Load(QString filename) { variable->filter_[k].checked = filter_ele["checked"].toBool(); } variable->id_ = j + 1; - QJsonObject sampling,scaling; - sampling = tmp_variable["sampling"].toObject(); - scaling = tmp_variable["scaling"].toObject(); - variable->fixed = sampling["fixed"].toBool(); - variable->sample_rate = sampling["sample_rate"].toInt(); - variable->bandwidth = sampling["band_width"].toInt(); - variable->fft_points = sampling["fft_points"].toInt(); - variable->measuring_min = scaling["measuring_min"].toInt(); - variable->measuring_max = scaling["measuring_max"].toInt(); - variable->scale_min = scaling["scale_min"].toInt(); - variable->scale_max = scaling["scale_max"].toInt(); + QJsonObject processed_output, general, alarm; + processed_output = tmp_variable["processed_output"].toObject(); + general = processed_output["general"].toObject(); + alarm = processed_output["alarm"].toObject(); + variable->general.output_used = general["output_used"].toBool(); + variable->general.engineering_unit = general["engieneering_unit"].toInt(); + variable->general.rectifier_function = general["rectifier_function"].toInt(); + variable->danger_high.level = alarm["danger_high_level"].toDouble(); + variable->danger_high.hysteresis = alarm["danger_high_hysteresis"].toDouble(); + variable->danger_high.delay = alarm["danger_high_delay"].toInt(); + variable->danger_high.enable = alarm["danger_high_enable"].toBool(); + variable->danger_high.latch = alarm["danger_high_latch"].toBool(); + variable->alert_high.level = alarm["alert_high_level"].toDouble(); + variable->alert_high.hysteresis = alarm["alert_high_hysteresis"].toDouble(); + variable->alert_high.delay = alarm["alert_high_delay"].toInt(); + variable->alert_high.enable = alarm["alert_high_enable"].toBool(); + variable->alert_high.latch = alarm["alert_high_latch"].toBool(); +// variable->danger_low.level = alarm["danger_low_level"].toDouble(); +// variable->danger_low.hysteresis = alarm["danger_low_hysteresis"].toDouble(); +// variable->danger_low.delay = alarm["danger_low_delay"].toInt(); +// variable->danger_low.enable = alarm["danger_low_enable"].toBool(); +// variable->danger_low.latch = alarm["danger_low_latch"].toBool(); +// variable->alert_low.level = alarm["alert_low_level"].toDouble(); +// variable->alert_low.hysteresis = alarm["alert_low_hysteresis"].toDouble(); +// variable->alert_low.delay = alarm["alert_low_delay"].toInt(); +// variable->alert_low.enable = alarm["alert_low_enable"].toBool(); +// variable->alert_low.latch = alarm["alert_low_latch"].toBool(); + QJsonObject freband_output_obj = tmp_variable["freband_output"].toObject(); + QJsonObject number_obj; + for (int k = 0; k < 10; ++k) { + number_obj = freband_output_obj[QString::number(k + 1)].toObject(); + if(number_obj.isEmpty()) + continue; + FrequencybandOutput output; + output.enable = number_obj["enable"].toBool(); + output.start = number_obj["start"].toInt(); + output.end = number_obj["end"].toInt(); + variable->freband_output[k] = output; + } + vib_data->variables_.push_back(variable); + break; + } + case kVibVelocity:{ + std::shared_ptr variable = std::make_shared(); + // filter + QJsonArray filter_array = tmp_variable["filter"].toArray(); + for (int k = 0; k < filter_array.size(); k++) { + QJsonObject filter_ele = filter_array[k].toObject(); + variable->filter_[k].low = filter_ele["low"].toInt(); + variable->filter_[k].high = filter_ele["high"].toInt(); + variable->filter_[k].checked = filter_ele["checked"].toBool(); + } + variable->id_ = j + 1; + QJsonObject processed_output, general, alarm; + processed_output = tmp_variable["processed_output"].toObject(); + general = processed_output["general"].toObject(); + alarm = processed_output["alarm"].toObject(); + variable->general.output_used = general["output_used"].toBool(); + variable->general.engineering_unit = general["engieneering_unit"].toInt(); + variable->general.rectifier_function = general["rectifier_function"].toInt(); + variable->danger_high.level = alarm["danger_high_level"].toDouble(); + variable->danger_high.hysteresis = alarm["danger_high_hysteresis"].toDouble(); + variable->danger_high.delay = alarm["danger_high_delay"].toInt(); + variable->danger_high.enable = alarm["danger_high_enable"].toBool(); + variable->danger_high.latch = alarm["danger_high_latch"].toBool(); + variable->alert_high.level = alarm["alert_high_level"].toDouble(); + variable->alert_high.hysteresis = alarm["alert_high_hysteresis"].toDouble(); + variable->alert_high.delay = alarm["alert_high_delay"].toInt(); + variable->alert_high.enable = alarm["alert_high_enable"].toBool(); + variable->alert_high.latch = alarm["alert_high_latch"].toBool(); +// variable->danger_low.level = alarm["danger_low_level"].toDouble(); +// variable->danger_low.hysteresis = alarm["danger_low_hysteresis"].toDouble(); +// variable->danger_low.delay = alarm["danger_low_delay"].toInt(); +// variable->danger_low.enable = alarm["danger_low_enable"].toBool(); +// variable->danger_low.latch = alarm["danger_low_latch"].toBool(); +// variable->alert_low.level = alarm["alert_low_level"].toDouble(); +// variable->alert_low.hysteresis = alarm["alert_low_hysteresis"].toDouble(); +// variable->alert_low.delay = alarm["alert_low_delay"].toInt(); +// variable->alert_low.enable = alarm["alert_low_enable"].toBool(); +// variable->alert_low.latch = alarm["alert_low_latch"].toBool(); vib_data->variables_.push_back(variable); break; } - case kVibVelocity: case kVibAcc: { std::shared_ptr variable = std::make_shared(); // filter @@ -621,39 +823,45 @@ void ConfigMgr::Load(QString filename) { variable->filter_[k].checked = filter_ele["checked"].toBool(); } variable->id_ = j + 1; - QJsonObject direct = tmp_variable["direct"].toObject(); - variable->direct_.full_scale_range = direct["full_scale_range"].toInt(); - variable->direct_.clamp_value = direct["clamp_value"].toDouble(); - variable->direct_.custom = direct["custom"].toDouble(); - QJsonObject x1 = tmp_variable["x1"].toObject(); - variable->x1_.checked = x1["checked"].toBool(); - variable->x1_.full_scale_range = x1["full_scale_range"].toInt(); - variable->x1_.clamp_value = x1["clamp_value"].toDouble(); - variable->x1_.custom = x1["custom"].toDouble(); - variable->x1_.phase_lag = x1["phase_lag"].toInt(); - QJsonObject x2 = tmp_variable["x2"].toObject(); - variable->x2_.checked = x2["checked"].toBool(); - variable->x2_.full_scale_range = x2["full_scale_range"].toInt(); - variable->x2_.clamp_value = x2["clamp_value"].toDouble(); - variable->x2_.custom = x2["custom"].toDouble(); - variable->x2_.phase_lag = x2["phase_lag"].toInt(); - QJsonObject rms_integrate = tmp_variable["rms_integrate"].toObject(); - variable->rms_active_ = rms_integrate["rms_active"].toBool(); - variable->integrate_active_ = rms_integrate["integrate_active"].toBool(); - QJsonObject recorder_out = tmp_variable["recorder_out"].toObject(); - variable->recorder_out_.recorder_output = recorder_out["recorder_output"].toInt(); - variable->recorder_out_.two_ma_clamp = recorder_out["two_ma_clamp"].toBool(); - variable->recorder_out_.trip_multiply = recorder_out["trip_multiply"].toDouble(); - variable->recorder_out_.comparision = recorder_out["comparision"].toInt(); - variable->recorder_out_.percentage = recorder_out["percentage"].toInt(); - QJsonObject delay = tmp_variable["delay"].toObject(); - variable->delay_.alert = delay["alert"].toInt(); - variable->delay_.danger = delay["danger"].toDouble(); - variable->delay_.active_100ms = delay["active_100ms"].toBool(); - QJsonObject latching = tmp_variable["latching"].toObject(); - variable->alert_latching_ = latching["alert"].toBool(); - variable->danger_latching_ = latching["danger"].toBool(); - variable->timed_ok_ = latching["timed_ok"].toBool(); + QJsonObject processed_output, general, alarm; + processed_output = tmp_variable["processed_output"].toObject(); + general = processed_output["general"].toObject(); + alarm = processed_output["alarm"].toObject(); + variable->general.output_used = general["output_used"].toBool(); + variable->general.engineering_unit = general["engieneering_unit"].toInt(); + variable->general.rectifier_function = general["rectifier_function"].toInt(); + variable->danger_high.level = alarm["danger_high_level"].toDouble(); + variable->danger_high.hysteresis = alarm["danger_high_hysteresis"].toDouble(); + variable->danger_high.delay = alarm["danger_high_delay"].toInt(); + variable->danger_high.enable = alarm["danger_high_enable"].toBool(); + variable->danger_high.latch = alarm["danger_high_latch"].toBool(); + variable->alert_high.level = alarm["alert_high_level"].toDouble(); + variable->alert_high.hysteresis = alarm["alert_high_hysteresis"].toDouble(); + variable->alert_high.delay = alarm["alert_high_delay"].toInt(); + variable->alert_high.enable = alarm["alert_high_enable"].toBool(); + variable->alert_high.latch = alarm["alert_high_latch"].toBool(); +// variable->danger_low.level = alarm["danger_low_level"].toDouble(); +// variable->danger_low.hysteresis = alarm["danger_low_hysteresis"].toDouble(); +// variable->danger_low.delay = alarm["danger_low_delay"].toInt(); +// variable->danger_low.enable = alarm["danger_low_enable"].toBool(); +// variable->danger_low.latch = alarm["danger_low_latch"].toBool(); +// variable->alert_low.level = alarm["alert_low_level"].toDouble(); +// variable->alert_low.hysteresis = alarm["alert_low_hysteresis"].toDouble(); +// variable->alert_low.delay = alarm["alert_low_delay"].toInt(); +// variable->alert_low.enable = alarm["alert_low_enable"].toBool(); +// variable->alert_low.latch = alarm["alert_low_latch"].toBool(); + QJsonObject freband_output_obj = tmp_variable["freband_output"].toObject(); + QJsonObject number_obj; + for (int k = 0; k < 10; ++k) { + number_obj = freband_output_obj[QString::number(k + 1)].toObject(); + if(number_obj.isEmpty()) + continue; + FrequencybandOutput output; + output.enable = number_obj["enable"].toBool(); + output.start = number_obj["start"].toInt(); + output.end = number_obj["end"].toInt(); + variable->freband_output[k] = output; + } vib_data->variables_.push_back(variable); break; } @@ -703,8 +911,10 @@ void ConfigMgr::Load(QString filename) { channel = temp_obj[QString::number(j + 1)].toObject(); keyphase_data->variables_[j].active = channel["active"].toBool(); QJsonArray voltage_range_array = channel["normal_voltage_range"].toArray(); - keyphase_data->variables_[j].normal_voltage_high = voltage_range_array[1].toDouble(); - keyphase_data->variables_[j].normal_voltage_low = voltage_range_array[0].toDouble(); + if(voltage_range_array.size() > 0){ + keyphase_data->variables_[j].normal_voltage_high = voltage_range_array[1].toDouble(); + keyphase_data->variables_[j].normal_voltage_low = voltage_range_array[0].toDouble(); + } keyphase_data->variables_[j].threshold = channel["threshold"].toDouble(); keyphase_data->variables_[j].hysteresis = channel["hysteresis"].toDouble(); keyphase_data->variables_[j].events_per_revolution = channel["events_per_revolution"].toInt(); diff --git a/connect.cpp b/connect.cpp index 147c518..ef9c702 100644 --- a/connect.cpp +++ b/connect.cpp @@ -14,6 +14,7 @@ Connect::Connect(QWidget *parent) : QRegularExpression ipRegex(R"(^(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$)"); QRegularExpressionValidator *ipValidator = new QRegularExpressionValidator(ipRegex, this); ui->lineEdit_IP->setValidator(ipValidator); + ui->lineEdit_IP->setText(g_strServerIp); } Connect::~Connect() diff --git a/data_config.h b/data_config.h index d8ecaef..2aa5d38 100644 --- a/data_config.h +++ b/data_config.h @@ -8,12 +8,19 @@ typedef unsigned char uint8_t; typedef unsigned short uint16_t; -extern QString g_strServerIp; // 服务端IP -extern QString g_version; - #define SLOT_NUM 15 #define CHANNEL_COUNT 4 #define RELAY_COUNT 16 + +typedef struct { + bool used[4]; // 是否已配置 + int channel; +}ChannelUsed; + +extern QString g_strServerIp; // 服务端IP +extern QString g_version; +extern ChannelUsed ch_used[SLOT_NUM][22]; + struct ExprNode { QString value; QList children; @@ -54,6 +61,118 @@ typedef enum { kVibThrust = 3, //轴向位移 kVibPressurePulsation = 4 //动态压力脉动 } VibChannelType; +enum TotalCalcValueType { + // 转速 + kSpeedRpm = 0, + + // 轴向位移 + kThrustGap = 2, + + // 径向位移 + kRadialPk = 4, + kRadialPk2Pk = 5, + kRadialRmsScaledPeak = 6, + kRadialRmsScaledPk2Pk = 7, + + // 速度 + kVelPeak = 11, + kVelRmsScaledPeak = 12, + kVelRms = 13, + + kVelDisPeak = 17, + kVelDisPk2Pk = 18, + kVelDisRmsScaledPeak = 19, + kVelDisRmsScaledPk2Pk = 20, + + // 加速度 + kAccPeak = 21, + kAccRmsScaledPeak = 22, + kAccRms = 23, + + kAccVelPeak = 26, + kAccVelRmsScaledPeak = 27, + kAccVelRms = 28, + + kAccDisPeak = 31, + kAccDisPk2Pk = 32, + kAccDisRmsScaledPeak = 33, + kAccDisRmsScaledPk2Pk = 34, + + // 压力脉动 + kPressPulsationPeak = 41, + kPressPulsationRmsScaledPeak = 42, + kPressPulsationRms = 43, + + // kTriggerPressurePulsationLow = 11, // [10, 40] + // kTriggerPressurePulsationMID1 = 12, // (40, 120] + // kTriggerPressurePulsationMID2 = 13, // (120, 190] + // kTriggerPressurePulsationHIGH1 = 14, // (190, 290] + // kTriggerPressurePulsationHIGH2 = 15, // (290, 500] + // kTriggerPressurePulsationHH1 = 16, // (500, 2000] + // kTriggerPressurePulsationHH2 = 17, // (2000, 3200] + // kTriggerPressurePulsationHH3 = 18, // (3200, 4200] + // kTriggerPressurePulsationHH4 = 19, // (4200, 4600] + // kTriggerPressurePulsationOA = 20, // [5, 500] + + // 复合运算 + kSmax = 81, // 径向位移运算 + kDifferentialHousingExpansion = 82, // 差胀,针对轴向位移,做减法 + kRelativeShaftTaper = 83, // 径向位移,根据公式进行计算 + kRelativeShaftCollar = 84, // 径向位移,根据公式进行计算 + kDualMathematicalFunction = 85, // 公式计算 + + kDCValue = 100, +}; +typedef enum{ + kTruePeak = 0, + kTruePeakToPeak = 1, + kRMSScalePeak = 2, + kRMSScalePeakToPeak = 3, + kAVG = 4, + kRMSScaleAVG = 5, + kRMS = 6 +} RectifierFuntion; + +typedef enum{ + kUnit1 = 0, // g + kUnit2 = 1, // m/s**2 + kUnit3 = 2, // mm/s + kUnit4 = 3, // inch/s + kUnit5 = 4, // um + kUnit6 = 5, // mm + kUnit7 = 6, // mils + kUnit8 = 7, // inch/s**2 + kUnit9 = 9, // mbar + kUnit10 = 10, // bar + kUnit11 = 11, // psi + kUnit12 = 12, // pa + kUnit13 = 13 // user defined +} EngineeringUnit; + +typedef enum{ + kCh1Output1 = 0, // 通道1 输出1 + kCh2Output2 = 1, // 通道2 输出1 + kCh3Output3 = 2, // 通道3 输出1 + kCh4Output4 = 3, // 通道4 输出1 + kCh1Ch2 = 4, // 通道1 & 通道2 + kCh3Ch4 = 5, // 通道3 & 通道4 + kCh1FreBand1 = 6, // 通道1 分频段1 + kCh1FreBand2 = 7, // 通道1 分频段2 + kCh1FreBand3 = 8, // 通道1 分频段3 + kCh1FreBand4 = 9, // 通道1 分频段4 + kCh2FreBand1 = 10, // 通道2 分频段1 + kCh2FreBand2 = 11, // 通道2 分频段2 + kCh2FreBand3 = 12, // 通道2 分频段3 + kCh2FreBand4 = 13, // 通道2 分频段4 + kCh3FreBand1 = 14, // 通道3 分频段1 + kCh3FreBand2 = 15, // 通道3 分频段2 + kCh3FreBand3 = 16, // 通道3 分频段3 + kCh3FreBand4 = 17, // 通道3 分频段4 + kCh4FreBand1 = 18, // 通道4 分频段1 + kCh4FreBand2 = 19, // 通道4 分频段2 + kCh4FreBand3 = 20, // 通道4 分频段3 + kCh4FreBand4 = 21 // 通道4 分频段4 +} DCOutputChannel; typedef struct SlotConfig_{ int slot; @@ -89,10 +208,15 @@ enum CMTCommand { kRebootCard = 21, // 重启板卡 kGetCardDcValue = 22, // 获取子板平均值 kGetRelayStatus = 23, // 获取继电器状态 - KConfigProgress = 25, - kTimingCmd = 26, - kGetTimeInfo = 27, - kGetLogInfo = 28 + kGetKeyphaseInfo = 24, // 获取键相信息 + kConfigProgress = 25, // 配置进度 + kTimingCmd = 26, // 校时 + kGetTimeInfo = 27, // 获取时间信息 + kGetLogInfo = 28, // 获取子板日志信息 + kCleanSubCardCfg = 29, // 清理子板配置 + kCleanSubCardLatch = 30, // 清理子板特定通道的Latch状态 + kConfigMQTTBrokerInfo = 31, // 配置与获取MQTT broker信息 + kConfigDeviceID = 32, // 配置设备编号,编号范围为1~99 }; enum RS485Baudrate { kBaudrate2400 = 0, @@ -117,7 +241,7 @@ typedef enum { kVibRackTMR = 1 // 三冗余 } VibRackType; -typedef struct { +typedef struct SeismicMonitor_{ int id; QString point_name; QString chan_id; @@ -135,6 +259,15 @@ typedef struct { bool keyphase; int keyphase_slot; int keyphase_ch; + int sensitivity_unit; + float signal_sensitivity; + SeismicMonitor_(){ + standby = false; + active = false; + normal_voltage_high = 20; + normal_voltage_low = -20; + signal_sensitivity = 8; + } } SeismicMonitor; typedef enum { @@ -149,6 +282,44 @@ typedef struct { bool checked; } Filter; +typedef struct{ + bool output_used; + int engineering_unit; + int rectifier_function; +}General; + +typedef struct{ + float level; + float hysteresis; + float delay; + bool enable; + bool latch; +}AlarmDangerHigh,AlarmAlertHigh,AlarmDangerLow,AlarmAlertLow ; + +typedef struct FrequencybandOutput_{ + bool enable; + int start; + int end; + FrequencybandOutput_() + { + enable = false; + start = 0; + end = 0; + } +}FrequencybandOutput ; + +typedef struct DCOutput_{ + int output_channel; + float minmum; + float maxmum; + DCOutput_(){ + output_channel = -1; + minmum = 0; + maxmum = 0; + } +} DCOutput; + + //typedef struct { // Filter filter[3]; // 0: kFilterTypeLowPass, 1: kFilterTypeHighPass, 2: kFilterTypeBandPass //} AllFilter; @@ -587,6 +758,51 @@ typedef struct { uint32_t ts; // 时间戳 } GetTimeInfoRsp; +typedef struct { + uint8_t head[3]; // 固定值:0xAA55AA + uint8_t cmd; // kConfigMQTTBrokerInfo + uint8_t version; // 版本号,默认为1 + uint8_t sub_cmd; // 0: get, 1: set + char ip[16]; // mqtt broker地址 + uint16_t port; +} MQTTBrokerConfigInfoReq; + +typedef struct { + uint8_t head[3]; // 固定值:0xAA55AA + uint8_t cmd; // kConfigMQTTBrokerInfo + uint8_t version; // 版本号,默认为1 + uint8_t code; // success:0, failure: others + uint8_t sub_cmd; // 0: get, 1: set + char ip[16]; // mqtt broker地址 + uint16_t port; +} MQTTBrokerConfigInfoRsp; + +// 子命令无响应,可观察灯板变化 +typedef struct { + uint8_t head[3]; // 固定值:0xAA55AA + uint8_t cmd; // kCleanSubCardLatch + uint8_t version; // 版本号,默认为1 + uint8_t card_id; // 子板编号,1-15 + uint8_t sid; // 通道编号,1-4 +} CleanLatchStatusReq; + +typedef struct { + uint8_t head[3]; // 固定值:0xAA55AA + uint8_t cmd; // kConfigDeviceID + uint8_t version; // 版本号,默认为1 + uint8_t sub_cmd; // 0: get, 1: set + uint8_t device_id; // 设备编号 0~99 +} DeviceIDConfigReq; + +typedef struct { + uint8_t head[3]; // 固定值:0xAA55AA + uint8_t cmd; // kConfigDeviceID + uint8_t version; // 版本号,默认为1 + uint8_t code; // success:0, failure: others + uint8_t sub_cmd; // 0: get, 1: set + uint8_t device_id; // 设备编号 +} DeviceIDConfigRsp; + struct BaseHeader { uint8_t head[3]; // 固定 0xAA 0x55 0xAA uint8_t cmd; diff --git a/dc_output_channel.cpp b/dc_output_channel.cpp new file mode 100644 index 0000000..05529b1 --- /dev/null +++ b/dc_output_channel.cpp @@ -0,0 +1,79 @@ +#include "dc_output_channel.h" +#include "ui_dc_output_channel.h" +#include +#include "data_config.h" +#include + + +DC_Output_Channel::DC_Output_Channel(int slot_no_,QString unit_str_,int current_index_,QWidget *parent) : + QWidget(parent), + ui(new Ui::DC_Output_Channel) +{ + ui->setupUi(this); + unit_str = unit_str_; + current_index = current_index_; + slot_no = slot_no_; + ui->label_min_unit->setText(unit_str); + ui->label_max_unit->setText(unit_str); + radiobtn[0] = ui->radioButton; + radiobtn[1] = ui->radioButton_2; + radiobtn[2] = ui->radioButton_3; + radiobtn[3] = ui->radioButton_4; + radiobtn[4] = ui->radioButton_5; + int not_used = 0; + for (int i = 0; i < 22; i++) { + for (int j = 0; j < 4; j++){ + if(ch_used[slot_no][i].used[j] && current_index == i){ + radiobtn[j]->setEnabled(true); + radiobtn[j]->setChecked(true); + first_used = j; + }else if(ch_used[slot_no][i].used[j] && current_index != i){ + radiobtn[j]->setEnabled(false); + }else if(!ch_used[slot_no][i].used[j] && current_index == i){ + not_used ++; + } + } + } + if(not_used == 4){ + ui->radioButton_5->setChecked(true); + } +} + +DC_Output_Channel::~DC_Output_Channel() +{ + delete ui; +} + +void DC_Output_Channel::on_pushButton_confirm_clicked() +{ + int channel = 0; + if(!ui->radioButton_5->isChecked() && ((ui->lineEdit_minmum->text().toFloat() >= ui->lineEdit_maxmum->text().toFloat()) || + (ui->lineEdit_minmum->text().toFloat() == 0 && ui->lineEdit_maxmum->text().toFloat() == 0))){ + QMessageBox::information(this, QStringLiteral("提示"), "请填写正确的最小值和最大值"); + return; + } + if(ui->radioButton->isChecked()){ + channel = 1; + }else if(ui->radioButton_2->isChecked()){ + channel = 2; + }else if(ui->radioButton_3->isChecked()){ + channel = 3; + }else if(ui->radioButton_4->isChecked()){ + channel = 4; + }else if(ui->radioButton_5->isChecked()){ + ch_used[slot_no][current_index].used[first_used] = false; + channel = 5; + }else { + QMessageBox::information(this, QStringLiteral("提示"), "请选择正确的通道"); + return; + } + emit output_channel_data_sg(channel,ui->lineEdit_minmum->text().toFloat(),ui->lineEdit_maxmum->text().toFloat(),first_used); + this->close(); +} + + +void DC_Output_Channel::on_pushButton_cancel_clicked() +{ + this->close(); +} + diff --git a/dc_output_channel.h b/dc_output_channel.h new file mode 100644 index 0000000..91cbb9c --- /dev/null +++ b/dc_output_channel.h @@ -0,0 +1,34 @@ +#ifndef DC_OUTPUT_CHANNEL_H +#define DC_OUTPUT_CHANNEL_H + +#include +#include + +namespace Ui { +class DC_Output_Channel; +} + +class DC_Output_Channel : public QWidget +{ + Q_OBJECT + +public: + explicit DC_Output_Channel(int slot_no_,QString unit_str_,int current_index_,QWidget *parent = nullptr); + ~DC_Output_Channel(); +signals: + void output_channel_data_sg(int channel,float minmun,float maxmum,int not_used); +private slots: + void on_pushButton_confirm_clicked(); + + void on_pushButton_cancel_clicked(); + +private: + Ui::DC_Output_Channel *ui; + QString unit_str; + int current_index; + int first_used; + int slot_no; + QRadioButton *radiobtn[5]; +}; + +#endif // DC_OUTPUT_CHANNEL_H diff --git a/dc_output_channel.ui b/dc_output_channel.ui new file mode 100644 index 0000000..cc9b19a --- /dev/null +++ b/dc_output_channel.ui @@ -0,0 +1,225 @@ + + + DC_Output_Channel + + + + 0 + 0 + 527 + 416 + + + + 输出通道 + + + + + 30 + 50 + 391 + 181 + + + + 4 - 20 mA 输出 + + + + + 40 + 30 + 89 + 16 + + + + 通道1 + + + buttonGroup + + + + + + 40 + 60 + 89 + 16 + + + + 通道2 + + + buttonGroup + + + + + + 40 + 90 + 89 + 16 + + + + 通道3 + + + buttonGroup + + + + + + 40 + 120 + 89 + 16 + + + + 通道4 + + + buttonGroup + + + + + + 40 + 150 + 89 + 16 + + + + 不使用 + + + buttonGroup + + + + + + + 50 + 260 + 113 + 25 + + + + + 0 + 25 + + + + + + + 50 + 300 + 113 + 25 + + + + + 0 + 25 + + + + + + + 190 + 270 + 54 + 12 + + + + - - + + + + + + 190 + 310 + 54 + 12 + + + + - - + + + + + + 280 + 270 + 54 + 12 + + + + 最小值 + + + + + + 280 + 310 + 54 + 12 + + + + 最大值 + + + + + + 90 + 360 + 75 + 23 + + + + 确认 + + + + + + 240 + 360 + 75 + 23 + + + + 取消 + + + + + + + + + diff --git a/dc_outputs.cpp b/dc_outputs.cpp new file mode 100644 index 0000000..3260afa --- /dev/null +++ b/dc_outputs.cpp @@ -0,0 +1,422 @@ +#include "dc_outputs.h" +#include "ui_dc_outputs.h" +#include +#include "dc_output_channel.h" +#include +#include "config_mgr.h" +#include "data_config.h" +#include "vibrationdata.h" + +ChannelUsed ch_used[SLOT_NUM][22]; + +DC_Outputs::DC_Outputs(int slot_no_,int cardtype,QWidget *parent) : + QWidget(parent), + ui(new Ui::DC_Outputs) +{ + ui->setupUi(this); + ui->comboBox_ch_output->setView(new QListView()); + slot_no = slot_no_; + car_type = static_cast(cardtype); + unit = ""; + current_index = ui->comboBox_ch_output->currentIndex(); + label_ch1[0] = ui->label_ch_1; + label_ch1[1] = ui->label_ch_1_min; + label_ch1[2] = ui->label_ch_1_min_unit; + label_ch1[3] = ui->label_ch_1_max; + label_ch1[4] = ui->label_ch_1_max_unit; + + label_ch2[0] = ui->label_ch_2; + label_ch2[1] = ui->label_ch_2_min; + label_ch2[2] = ui->label_ch_2_min_unit; + label_ch2[3] = ui->label_ch_2_max; + label_ch2[4] = ui->label_ch_2_max_unit; + + label_ch3[0] = ui->label_ch_3; + label_ch3[1] = ui->label_ch_3_min; + label_ch3[2] = ui->label_ch_3_min_unit; + label_ch3[3] = ui->label_ch_3_max; + label_ch3[4] = ui->label_ch_3_max_unit; + + label_ch4[0] = ui->label_ch_4; + label_ch4[1] = ui->label_ch_4_min; + label_ch4[2] = ui->label_ch_4_min_unit; + label_ch4[3] = ui->label_ch_4_max; + label_ch4[4] = ui->label_ch_4_max_unit; + + Init(); +} + +DC_Outputs::~DC_Outputs() +{ + delete ui; +} + +void DC_Outputs::Init(){ + std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); + if (base_ptr == nullptr) { + qCritical() << "[DC_Outputs::Init] should not be here"; + return; + } + vib_dc_output_ptr = std::dynamic_pointer_cast(base_ptr); + QString unit_str = ""; + + if(vib_dc_output_ptr->dc_output[0].output_channel != -1){ + unit_str = GetUnit(vib_dc_output_ptr->dc_output[0].output_channel); + ui->label_ch_1->setText(ui->comboBox_ch_output->itemText(vib_dc_output_ptr->dc_output[0].output_channel)); + ui->label_ch_1_min->setText(QString::number(vib_dc_output_ptr->dc_output[0].minmum)); + ui->label_ch_1_max->setText(QString::number(vib_dc_output_ptr->dc_output[0].maxmum)); + ui->label_ch_1_min_unit->setText(unit_str); + ui->label_ch_1_max_unit->setText(unit_str); + ch_used[slot_no][vib_dc_output_ptr->dc_output[0].output_channel].used[0] = true; + } + if(vib_dc_output_ptr->dc_output[1].output_channel != -1){ + unit_str = GetUnit(vib_dc_output_ptr->dc_output[1].output_channel); + ui->label_ch_2->setText(ui->comboBox_ch_output->itemText(vib_dc_output_ptr->dc_output[1].output_channel)); + ui->label_ch_2_min->setText(QString::number(vib_dc_output_ptr->dc_output[1].minmum)); + ui->label_ch_2_max->setText(QString::number(vib_dc_output_ptr->dc_output[1].maxmum)); + ui->label_ch_2_min_unit->setText(unit_str); + ui->label_ch_2_max_unit->setText(unit_str); + ch_used[slot_no][vib_dc_output_ptr->dc_output[1].output_channel].used[1] = true; + } + if(vib_dc_output_ptr->dc_output[2].output_channel != -1){ + unit_str = GetUnit(vib_dc_output_ptr->dc_output[2].output_channel); + ui->label_ch_3->setText(ui->comboBox_ch_output->itemText(vib_dc_output_ptr->dc_output[2].output_channel)); + ui->label_ch_3_min->setText(QString::number(vib_dc_output_ptr->dc_output[2].minmum)); + ui->label_ch_3_max->setText(QString::number(vib_dc_output_ptr->dc_output[2].maxmum)); + ui->label_ch_3_min_unit->setText(unit_str); + ui->label_ch_3_max_unit->setText(unit_str); + ch_used[slot_no][vib_dc_output_ptr->dc_output[2].output_channel].used[2] = true; + } + if(vib_dc_output_ptr->dc_output[3].output_channel != -1){ + unit_str = GetUnit(vib_dc_output_ptr->dc_output[3].output_channel); + ui->label_ch_4->setText(ui->comboBox_ch_output->itemText(vib_dc_output_ptr->dc_output[3].output_channel)); + ui->label_ch_4_min->setText(QString::number(vib_dc_output_ptr->dc_output[3].minmum)); + ui->label_ch_4_max->setText(QString::number(vib_dc_output_ptr->dc_output[3].maxmum)); + ui->label_ch_4_min_unit->setText(unit_str); + ui->label_ch_4_max_unit->setText(unit_str); + ch_used[slot_no][vib_dc_output_ptr->dc_output[3].output_channel].used[3] = true; + } + + +} + +QString DC_Outputs::GetUnit(int com_index){ + int unit_num = -1,channel_num = 0; + QString unit_str = ""; + channel_num = com_index; + if(com_index > 5 && com_index < 9){ + channel_num = 0; + } + if(com_index > 9 && com_index < 13){ + channel_num = 1; + } + if(com_index > 13 && com_index < 17){ + channel_num = 2; + } + if(com_index > 17 && com_index < 21){ + channel_num = 3; + } + if(com_index == 4) { + channel_num = 0; + }else if(com_index == 5){ + channel_num = 2; + } + std::shared_ptr variable_base = vib_dc_output_ptr->GetChannelPtr(channel_num + 1); + if (vib_dc_output_ptr->base_config_[channel_num].channel_type == kVibRadial) { + std::shared_ptr variable_ptr = std::dynamic_pointer_cast(variable_base); + unit_num = variable_ptr->general.engineering_unit; + qDebug() << "unit_num1" << unit_num ; + } + if (vib_dc_output_ptr->base_config_[channel_num].channel_type == kVibAcc) { + std::shared_ptr variable_ptr = std::dynamic_pointer_cast(variable_base); + unit_num = variable_ptr->general.engineering_unit; + qDebug() << "unit_num2" << unit_num ; + } + if (vib_dc_output_ptr->base_config_[channel_num].channel_type == kVibVelocity) { + std::shared_ptr variable_ptr = std::dynamic_pointer_cast(variable_base); + unit_num = variable_ptr->general.engineering_unit; + qDebug() << "unit_num3" << unit_num ; + } + if (vib_dc_output_ptr->base_config_[channel_num].channel_type == kVibThrust) { + std::shared_ptr variable_ptr = std::dynamic_pointer_cast(variable_base); + unit_num = variable_ptr->general.engineering_unit; + qDebug() << "unit_num4" << unit_num ; + } + if (vib_dc_output_ptr->base_config_[channel_num].channel_type == kVibPressurePulsation) { + std::shared_ptr variable_ptr = std::dynamic_pointer_cast(variable_base); + unit_num = variable_ptr->general.engineering_unit; + qDebug() << "unit_num5" << unit_num ; + } + switch (unit_num) { + case kUnit1:{ + unit_str = "g"; + break; + } + case kUnit2:{ + unit_str = "m/s**2"; + break; + } + case kUnit3:{ + unit_str = "mm/s"; + break; + } + case kUnit4:{ + unit_str = "inch/s"; + break; + } + case kUnit5:{ + unit_str = "um"; + break; + } + case kUnit6:{ + unit_str = "mm"; + break; + } + case kUnit7:{ + unit_str = "mils"; + break; + } + case kUnit8:{ + unit_str = "inch/s**2"; + break; + } + case kUnit9:{ + unit_str = "mbar"; + break; + } + case kUnit10:{ + unit_str = "bar"; + break; + } + case kUnit11:{ + unit_str = "psi"; + break; + } + case kUnit12:{ + unit_str = "pa"; + break; + } + } + return unit_str; +} +void DC_Outputs::on_comboBox_ch_output_activated(int index) +{ + current_index = index; + QString unit_str = GetUnit(current_index); + DC_Output_Channel *dc_output_channel = new DC_Output_Channel(slot_no,unit_str,current_index); + dc_output_channel->setWindowModality(Qt::ApplicationModal); + connect(dc_output_channel,SIGNAL(output_channel_data_sg(int,float,float,int)),this,SLOT(output_channel_data(int,float,float,int))); + dc_output_channel->show(); +} + +void DC_Outputs::output_channel_data(int channel,float minmun,float maxmum,int not_used){ + qDebug() << channel << minmun << maxmum ; + QString unit_str = GetUnit(current_index); + for (int i = 0; i < CHANNEL_COUNT; i++) { + if(ch_used[slot_no][current_index].used[i] && i != (channel - 1)){ + if(i == 0){ + label_ch1[0]->setText("未使用"); + label_ch1[1]->setText("-----"); + label_ch1[2]->setText("-----"); + label_ch1[3]->setText("-----"); + label_ch1[4]->setText("-----"); + ch_used[slot_no][ui->comboBox_ch_output->currentIndex()].used[0] = false; + vib_dc_output_ptr->dc_output[0].output_channel = -1; + }else if(i == 1){ + label_ch2[0]->setText("未使用"); + label_ch2[1]->setText("-----"); + label_ch2[2]->setText("-----"); + label_ch2[3]->setText("-----"); + label_ch2[4]->setText("-----"); + ch_used[slot_no][current_index].used[1] = false; + vib_dc_output_ptr->dc_output[1].output_channel = -1; + }else if(i == 2){ + label_ch3[0]->setText("未使用"); + label_ch3[1]->setText("-----"); + label_ch3[2]->setText("-----"); + label_ch3[3]->setText("-----"); + label_ch3[4]->setText("-----"); + ch_used[slot_no][current_index].used[2] = false; + vib_dc_output_ptr->dc_output[2].output_channel = -1; + }else if(i == 3){ + label_ch4[0]->setText("未使用"); + label_ch4[1]->setText("-----"); + label_ch4[2]->setText("-----"); + label_ch4[3]->setText("-----"); + label_ch4[4]->setText("-----"); + ch_used[slot_no][current_index].used[3] = false; + vib_dc_output_ptr->dc_output[3].output_channel = -1; + } + } + } + if(channel == 1){ + ui->label_ch_1->setText(ui->comboBox_ch_output->currentText()); + ui->label_ch_1_min->setText(QString::number(minmun)); + ui->label_ch_1_max->setText(QString::number(maxmum)); + ui->label_ch_1_min_unit->setText(unit_str); + ui->label_ch_1_max_unit->setText(unit_str); + ch_used[slot_no][ui->comboBox_ch_output->currentIndex()].used[0] = true; + vib_dc_output_ptr->dc_output[0].output_channel = current_index; + vib_dc_output_ptr->dc_output[0].minmum = ui->label_ch_1_min->text().toFloat(); + vib_dc_output_ptr->dc_output[0].maxmum = ui->label_ch_1_max->text().toFloat(); + }else if(channel == 2){ + ui->label_ch_2->setText(ui->comboBox_ch_output->currentText()); + ui->label_ch_2_min->setText(QString::number(minmun)); + ui->label_ch_2_max->setText(QString::number(maxmum)); + ui->label_ch_2_min_unit->setText(unit_str); + ui->label_ch_2_max_unit->setText(unit_str); + ch_used[slot_no][ui->comboBox_ch_output->currentIndex()].used[1] = true; + vib_dc_output_ptr->dc_output[1].output_channel = current_index; + vib_dc_output_ptr->dc_output[1].minmum = ui->label_ch_2_min->text().toFloat(); + vib_dc_output_ptr->dc_output[1].maxmum = ui->label_ch_2_max->text().toFloat(); + }else if(channel == 3){ + ui->label_ch_3->setText(ui->comboBox_ch_output->currentText()); + ui->label_ch_3_min->setText(QString::number(minmun)); + ui->label_ch_3_max->setText(QString::number(maxmum)); + ui->label_ch_3_min_unit->setText(unit_str); + ui->label_ch_3_max_unit->setText(unit_str); + ch_used[slot_no][ui->comboBox_ch_output->currentIndex()].used[2] = true; + vib_dc_output_ptr->dc_output[2].output_channel = current_index; + vib_dc_output_ptr->dc_output[2].minmum = ui->label_ch_3_min->text().toFloat(); + vib_dc_output_ptr->dc_output[2].maxmum = ui->label_ch_3_max->text().toFloat(); + }else if(channel == 4){ + ui->label_ch_4->setText(ui->comboBox_ch_output->currentText()); + ui->label_ch_4_min->setText(QString::number(minmun)); + ui->label_ch_4_max->setText(QString::number(maxmum)); + ui->label_ch_4_min_unit->setText(unit_str); + ui->label_ch_4_max_unit->setText(unit_str); + ch_used[slot_no][ui->comboBox_ch_output->currentIndex()].used[3] = true; + vib_dc_output_ptr->dc_output[3].output_channel = current_index; + vib_dc_output_ptr->dc_output[3].minmum = ui->label_ch_4_min->text().toFloat(); + vib_dc_output_ptr->dc_output[3].maxmum = ui->label_ch_4_max->text().toFloat(); + }else if(channel == 5){ + if(not_used == 0){ + label_ch1[0]->setText("未使用"); + label_ch1[1]->setText("-----"); + label_ch1[2]->setText("-----"); + label_ch1[3]->setText("-----"); + label_ch1[4]->setText("-----"); + ch_used[slot_no][ui->comboBox_ch_output->currentIndex()].used[0] = false; + vib_dc_output_ptr->dc_output[0].output_channel = -1; + }else if(not_used == 1){ + label_ch2[0]->setText("未使用"); + label_ch2[1]->setText("-----"); + label_ch2[2]->setText("-----"); + label_ch2[3]->setText("-----"); + label_ch2[4]->setText("-----"); + ch_used[slot_no][ui->comboBox_ch_output->currentIndex()].used[1] = false; + vib_dc_output_ptr->dc_output[1].output_channel = -1; + }else if(not_used == 2){ + label_ch3[0]->setText("未使用"); + label_ch3[1]->setText("-----"); + label_ch3[2]->setText("-----"); + label_ch3[3]->setText("-----"); + label_ch3[4]->setText("-----"); + ch_used[slot_no][ui->comboBox_ch_output->currentIndex()].used[2] = false; + vib_dc_output_ptr->dc_output[2].output_channel = -1; + }else if(not_used == 3){ + label_ch4[0]->setText("未使用"); + label_ch4[1]->setText("-----"); + label_ch4[2]->setText("-----"); + label_ch4[3]->setText("-----"); + label_ch4[4]->setText("-----"); + ch_used[slot_no][ui->comboBox_ch_output->currentIndex()].used[3] = false; + vib_dc_output_ptr->dc_output[3].output_channel = -1; + } + } +} + +void DC_Outputs::on_pushButton_confirm_clicked() +{ + +// if(ui->label_ch_1->text() != "未使用" && current_index){ +// vib_dc_output_ptr->dc_output[0].output_channel = current_index; +// vib_dc_output_ptr->dc_output[0].dc_output_channel = 1; +// vib_dc_output_ptr->dc_output[0].minmum = ui->label_ch_1_min->text().toFloat(); +// vib_dc_output_ptr->dc_output[0].maxmum = ui->label_ch_1_max->text().toFloat(); +// } +// if(ui->label_ch_2->text() != "未使用"){ +// vib_dc_output_ptr->dc_output[1].output_channel = current_index; +// vib_dc_output_ptr->dc_output[1].dc_output_channel = 2; +// vib_dc_output_ptr->dc_output[1].minmum = ui->label_ch_2_min->text().toFloat(); +// vib_dc_output_ptr->dc_output[1].maxmum = ui->label_ch_2_max->text().toFloat(); +// } +// if(ui->label_ch_3->text() != "未使用"){ +// vib_dc_output_ptr->dc_output[2].output_channel = current_index; +// vib_dc_output_ptr->dc_output[2].dc_output_channel = 3; +// vib_dc_output_ptr->dc_output[2].minmum = ui->label_ch_3_min->text().toFloat(); +// vib_dc_output_ptr->dc_output[2].maxmum = ui->label_ch_3_max->text().toFloat(); +// } +// if(ui->label_ch_4->text() != "未使用"){ +// vib_dc_output_ptr->dc_output[3].output_channel = current_index; +// vib_dc_output_ptr->dc_output[3].dc_output_channel = 4; +// vib_dc_output_ptr->dc_output[3].minmum = ui->label_ch_4_min->text().toFloat(); +// vib_dc_output_ptr->dc_output[3].maxmum = ui->label_ch_4_max->text().toFloat(); +// } + + this->close(); +} + + +void DC_Outputs::on_pushButton_cancel_clicked() +{ + this->close(); +} + + +void DC_Outputs::on_comboBox_ch_output_currentIndexChanged(int index) +{ + qDebug() << "on_comboBox_ch_output_currentIndexChanged" ; +// if(ui->label_ch_1->text() != "未使用"){ +// vib_dc_output_ptr->dc_output[0].output_channel = current_index; +// vib_dc_output_ptr->dc_output[0].dc_output_channel = 1; +// vib_dc_output_ptr->dc_output[0].minmum = ui->label_ch_1_min->text().toFloat(); +// vib_dc_output_ptr->dc_output[0].maxmum = ui->label_ch_1_max->text().toFloat(); +// } +// if(ui->label_ch_2->text() != "未使用"){ +// vib_dc_output_ptr->dc_output[1].output_channel = current_index; +// vib_dc_output_ptr->dc_output[1].dc_output_channel = 2; +// vib_dc_output_ptr->dc_output[1].minmum = ui->label_ch_2_min->text().toFloat(); +// vib_dc_output_ptr->dc_output[1].maxmum = ui->label_ch_2_max->text().toFloat(); +// } +// if(ui->label_ch_3->text() != "未使用"){ +// vib_dc_output_ptr->dc_output[2].output_channel = current_index; +// vib_dc_output_ptr->dc_output[2].dc_output_channel = 3; +// vib_dc_output_ptr->dc_output[2].minmum = ui->label_ch_3_min->text().toFloat(); +// vib_dc_output_ptr->dc_output[2].maxmum = ui->label_ch_3_max->text().toFloat(); +// } +// if(ui->label_ch_4->text() != "未使用"){ +// vib_dc_output_ptr->dc_output[3].output_channel = current_index; +// vib_dc_output_ptr->dc_output[3].dc_output_channel = 4; +// vib_dc_output_ptr->dc_output[3].minmum = ui->label_ch_4_min->text().toFloat(); +// vib_dc_output_ptr->dc_output[3].maxmum = ui->label_ch_4_max->text().toFloat(); +// } + +// current_index = index; +// QString unit_str = GetUnit(); +// if(vib_dc_output_ptr->dc_output[0].dc_output_channel == 1 && current_index == vib_dc_output_ptr->dc_output[0].output_channel){ +// ui->label_ch_1->setText(ui->comboBox_ch_output->itemText(vib_dc_output_ptr->dc_output[0].output_channel)); +// ui->label_ch_1_min->setText(QString::number(vib_dc_output_ptr->dc_output[0].minmum)); +// ui->label_ch_1_max->setText(QString::number(vib_dc_output_ptr->dc_output[0].maxmum)); +// ch_used[slot_no][current_index].used[0] = true; +// } +// if(vib_dc_output_ptr->dc_output[1].dc_output_channel == 2 && current_index == vib_dc_output_ptr->dc_output[1].output_channel){ +// ui->label_ch_2->setText(ui->comboBox_ch_output->itemText(vib_dc_output_ptr->dc_output[1].output_channel)); +// ui->label_ch_2_min->setText(QString::number(vib_dc_output_ptr->dc_output[1].minmum)); +// ui->label_ch_2_max->setText(QString::number(vib_dc_output_ptr->dc_output[1].maxmum)); +// ch_used[slot_no][current_index].used[1] = true; +// } +// if(vib_dc_output_ptr->dc_output[2].dc_output_channel == 3 && current_index == vib_dc_output_ptr->dc_output[2].output_channel){ +// ui->label_ch_3->setText(ui->comboBox_ch_output->itemText(vib_dc_output_ptr->dc_output[2].output_channel)); +// ui->label_ch_3_min->setText(QString::number(vib_dc_output_ptr->dc_output[2].minmum)); +// ui->label_ch_3_max->setText(QString::number(vib_dc_output_ptr->dc_output[2].maxmum)); +// ch_used[slot_no][current_index].used[2] = true; +// } +// if(vib_dc_output_ptr->dc_output[3].dc_output_channel == 4 && current_index == vib_dc_output_ptr->dc_output[3].output_channel){ +// ui->label_ch_4->setText(ui->comboBox_ch_output->itemText(vib_dc_output_ptr->dc_output[3].output_channel)); +// ui->label_ch_4_min->setText(QString::number(vib_dc_output_ptr->dc_output[3].minmum)); +// ui->label_ch_4_max->setText(QString::number(vib_dc_output_ptr->dc_output[3].maxmum)); +// ch_used[slot_no][current_index].used[3] = true; +// } +} + diff --git a/dc_outputs.h b/dc_outputs.h new file mode 100644 index 0000000..e502964 --- /dev/null +++ b/dc_outputs.h @@ -0,0 +1,45 @@ +#ifndef DC_OUTPUTS_H +#define DC_OUTPUTS_H + +#include +#include "data_config.h" +#include "vibrationdata.h" + +namespace Ui { +class DC_Outputs; +} + +class DC_Outputs : public QWidget +{ + Q_OBJECT + +public: + explicit DC_Outputs(int slot_no_,int cardtype,QWidget *parent = nullptr); + ~DC_Outputs(); + int slot_no; + CardType car_type; +private slots: + void on_comboBox_ch_output_activated(int index); + + void on_pushButton_confirm_clicked(); + + void on_pushButton_cancel_clicked(); + + void output_channel_data(int channel,float minmun,float maxmum,int not_used); + + void on_comboBox_ch_output_currentIndexChanged(int index); + +private: + Ui::DC_Outputs *ui; + std::shared_ptr vib_dc_output_ptr = nullptr; + void Init(); + QString GetUnit(int com_index); + QLabel *label_ch1[5]; + QLabel *label_ch2[5]; + QLabel *label_ch3[5]; + QLabel *label_ch4[5]; + int current_index; + QString unit; +}; + +#endif // DC_OUTPUTS_H diff --git a/dc_outputs.ui b/dc_outputs.ui new file mode 100644 index 0000000..f951cf4 --- /dev/null +++ b/dc_outputs.ui @@ -0,0 +1,528 @@ + + + DC_Outputs + + + + 0 + 0 + 727 + 450 + + + + 直流输出 + + + + + 60 + 40 + 150 + 25 + + + + + 150 + 25 + + + + + 150 + 25 + + + + + 通道1 输出1 + + + + + 通道2 输出1 + + + + + 通道3 输出1 + + + + + 通道4 输出1 + + + + + 通道1 & 通道2 + + + + + 通道3 & 通道4 + + + + + 通道1 分频段1 + + + + + 通道1 分频段2 + + + + + 通道1 分频段3 + + + + + 通道1 分频段4 + + + + + 通道2 分频段1 + + + + + 通道2 分频段2 + + + + + 通道2 分频段3 + + + + + 通道2 分频段4 + + + + + 通道3 分频段1 + + + + + 通道3 分频段2 + + + + + 通道3 分频段3 + + + + + 通道3 分频段4 + + + + + 通道4 分频段1 + + + + + 通道4 分频段2 + + + + + 通道4 分频段3 + + + + + 通道4 分频段4 + + + + + + + 50 + 160 + 54 + 12 + + + + 1 + + + + + + 50 + 200 + 54 + 12 + + + + 2 + + + + + + 50 + 240 + 54 + 12 + + + + 3 + + + + + + 50 + 280 + 54 + 12 + + + + 4 + + + + + + 140 + 110 + 101 + 16 + + + + IOC 直流 输出 + + + + + + 310 + 110 + 41 + 16 + + + + 最小值 + + + + + + 440 + 110 + 41 + 16 + + + + 最大值 + + + + + + 160 + 160 + 81 + 16 + + + + 未使用 + + + + + + 160 + 200 + 81 + 16 + + + + 未使用 + + + + + + 160 + 240 + 81 + 16 + + + + 未使用 + + + + + + 160 + 280 + 81 + 16 + + + + 未使用 + + + + + + 300 + 160 + 41 + 16 + + + + ----- + + + + + + 300 + 200 + 31 + 16 + + + + ----- + + + + + + 420 + 160 + 31 + 16 + + + + ----- + + + + + + 420 + 200 + 31 + 16 + + + + ----- + + + + + + 300 + 240 + 31 + 16 + + + + ----- + + + + + + 300 + 280 + 31 + 16 + + + + ----- + + + + + + 420 + 240 + 31 + 16 + + + + ----- + + + + + + 420 + 280 + 31 + 16 + + + + ----- + + + + + + 160 + 380 + 75 + 23 + + + + 确认 + + + + + + 340 + 380 + 75 + 23 + + + + 取消 + + + + + + 340 + 160 + 41 + 16 + + + + ----- + + + + + + 460 + 160 + 41 + 16 + + + + ----- + + + + + + 340 + 200 + 41 + 16 + + + + ----- + + + + + + 460 + 200 + 41 + 16 + + + + ----- + + + + + + 340 + 240 + 41 + 16 + + + + ----- + + + + + + 460 + 240 + 41 + 16 + + + + ----- + + + + + + 340 + 280 + 41 + 16 + + + + ----- + + + + + + 460 + 280 + 31 + 16 + + + + ----- + + + + + + diff --git a/keyphase.ui b/keyphase.ui index ca886fd..eb688b7 100644 --- a/keyphase.ui +++ b/keyphase.ui @@ -6,8 +6,8 @@ 0 0 - 660 - 580 + 691 + 598 @@ -76,7 +76,7 @@ - 300 + 326 310 41 16 @@ -89,7 +89,7 @@ - 296 + 322 250 51 32 @@ -104,7 +104,7 @@ 10 60 - 281 + 301 451 @@ -550,7 +550,7 @@ 10 40 - 251 + 281 71 @@ -717,7 +717,7 @@ 10 130 - 251 + 281 181 @@ -809,7 +809,7 @@ 140 90 - 111 + 131 16 @@ -822,7 +822,7 @@ 140 130 - 101 + 131 16 @@ -897,7 +897,7 @@ - 294 + 320 360 51 32 @@ -926,9 +926,9 @@ - 350 + 380 60 - 281 + 301 451 @@ -1374,7 +1374,7 @@ 10 40 - 251 + 281 71 @@ -1538,7 +1538,7 @@ 10 130 - 251 + 281 181 @@ -1630,7 +1630,7 @@ 140 90 - 111 + 131 16 @@ -1643,7 +1643,7 @@ 140 130 - 101 + 121 16 diff --git a/mainwindow.cpp b/mainwindow.cpp index 0820363..c61d847 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -5,12 +5,11 @@ #include #include #include - +#include #include "keyphase.h" #include "singlerelay.h" #include "tachometer.h" #include "seismic_monitor.h" -#include "setpoint.h" #include #include #include @@ -27,6 +26,9 @@ #include "ethconfig.h" #include "macconfig.h" #include +#include "dc_outputs.h" +#include "mqtt_config.h" +#include QString g_strServerIp; QString g_version; @@ -35,9 +37,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); -// QMenuBar *menuBar = this->menuBar(); -// this->setMenuBar(menuBar); //添加到对象树 -// menuBar->addMenu(ui->menu_start); g_version = "1.1"; current_slot = -1; tsi_config_file = ""; @@ -101,6 +100,9 @@ MainWindow::MainWindow(QWidget *parent) QObject::connect(ui->action_eth, &QAction::triggered, this, &MainWindow::onEthConfig); QObject::connect(ui->action_mac, &QAction::triggered, this, &MainWindow::onMACConfig); QObject::connect(ui->action_time, &QAction::triggered, this, &MainWindow::onSetTime); + QObject::connect(ui->action_mqtt, &QAction::triggered, this, &MainWindow::onMqttConfig); + QObject::connect(ui->action_deviveID, &QAction::triggered, this, &MainWindow::onConfigDeviceID); + QObject::connect(ui->action_get_deviceID, &QAction::triggered, this, &MainWindow::onGetDeviceID); QSettings settingsread(QCoreApplication::applicationDirPath() + "\\config\\config.ini", QSettings::IniFormat); g_strServerIp = settingsread.value("Server/IP").toString(); @@ -476,9 +478,12 @@ void MainWindow::OnButtonGroup(QAbstractButton *slot_btn) { case kCardVibSingle:{ QString object_name = slot_btn->objectName(); int button_id = object_name.right(object_name.length() - 15).toInt(); - Setpoint *setpoint = new Setpoint(button_id,ConfigMgr::Instance()->card_type_[button_id - 1]); - setpoint->setWindowModality(Qt::ApplicationModal); - setpoint->show(); + DC_Outputs *dc_output = new DC_Outputs(button_id,ConfigMgr::Instance()->card_type_[button_id - 1]); + dc_output->setWindowModality(Qt::ApplicationModal); + dc_output->show(); + // Setpoint *setpoint = new Setpoint(button_id,ConfigMgr::Instance()->card_type_[button_id - 1]); + // setpoint->setWindowModality(Qt::ApplicationModal); + // setpoint->show(); break; } case kCardSpeedSingle:{ @@ -566,12 +571,28 @@ uint8_t calculate_crc(const QByteArray &data) { } void MainWindow::on_pushButton_save_clicked() { - QString filepath = QFileDialog::getExistingDirectory(this, tr("选择文件夹"), tr("")); - if(filepath == "") - return; - QString file_name = filepath + "\\tsi_config_file.json"; - ConfigMgr::Instance()->Save(file_name); - tsi_config_file = file_name; + QString file_name = ""; + if(tsi_config_file == ""){ + QString strTips =QString("请输入保存的文件名称"); + bool ok = false; + QString defaultInput = "tsi_config_file"; + file_name = QInputDialog::getText(this, tr("输入名称对话框"), strTips, QLineEdit::Normal, defaultInput, &ok); + if(!ok) return; + + if( file_name == ""){ + QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("请输入正确的文件名称!")); + return ; + } + QString filepath = QFileDialog::getExistingDirectory(this, tr("选择文件夹"), tr("")); + if(filepath == "") + return; + file_name = filepath + "\\"+file_name +".json"; + ConfigMgr::Instance()->Save(file_name); + tsi_config_file = file_name; + }else { + ConfigMgr::Instance()->Save(tsi_config_file); + } + return; } @@ -593,7 +614,7 @@ void MainWindow::on_pushButton_open_clicked() { return; } QList buttonList = btnGroup_slot->buttons(); - for (int i = 0; i < buttonList.count(); i++) { + for (int i = 1; i < buttonList.count(); i++) { buttonList[i]->setText(""); } for (int i = 0; i < SLOT_NUM; i++) { @@ -848,7 +869,7 @@ void MainWindow::readData(const QByteArray &data) { }else if(upload_config_rsp.code == 1){ statusBar()->showMessage("上传失败!", 2000); } - }else if(cmd == KConfigProgress){ + }else if(cmd == kConfigProgress){ ConfigSubCardProgress config_sub_card_progress; memcpy(&config_sub_card_progress, data.data(), sizeof(ConfigSubCardProgress)); QString status ; @@ -862,6 +883,18 @@ void MainWindow::readData(const QByteArray &data) { map_slot_config[config_sub_card_progress.subcard_id].slot_label->setStyleSheet("QLabel { color :#FF0000; font: bold 16px}"); statusBar()->showMessage(status, 2000); } + }else if(cmd == kConfigDeviceID){ + DeviceIDConfigRsp device_config_rsp; + memcpy(&device_config_rsp, data.data(), sizeof(DeviceIDConfigRsp)); + if(device_config_rsp.code == 0){ + statusBar()->showMessage("配置成功!", 2000); + }else if(device_config_rsp.code == 1){ + statusBar()->showMessage("配置失败!", 2000); + } + if(device_config_rsp.sub_cmd == 0){ + QString str = QString("设备ID: %1").arg(device_config_rsp.device_id); + QMessageBox::information(this, QStringLiteral("提示"), str); + } } } @@ -893,6 +926,36 @@ void MainWindow::onMACConfig(){ mac_config->setWindowModality(Qt::ApplicationModal); mac_config->show(); } +void MainWindow::onMqttConfig(){ + MqttConfig *mqtt_config = new MqttConfig(); + mqtt_config->setWindowModality(Qt::ApplicationModal); + mqtt_config->show(); +} +void MainWindow::onGetDeviceID(){ + DeviceIDConfigReq config_device_id = { {0xAA, 0x55, 0xAA}, kConfigDeviceID, 1,0,{}}; + int length = sizeof(DeviceIDConfigReq); + qint64 bytesWritten = m_tcpClient->sendData((char*)&config_device_id, length); + m_tcpClient->waitForRead(); + qDebug() << "bytesWritten: " << bytesWritten; +} +void MainWindow::onConfigDeviceID(){ + QString strTips =QString("请输入0到99之间的数值"); + + bool ok = false; + int value = QInputDialog::getInt(this, tr("输入整数对话框"), strTips, 0, 0, 99, 1, &ok); + if(!ok) return; + + if(value < 1){ + QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("请输入正确的数字!")); + return ; + } + DeviceIDConfigReq config_device_id = { {0xAA, 0x55, 0xAA}, kConfigDeviceID, 1,1,{}}; + config_device_id.device_id = value; + int length = sizeof(DeviceIDConfigReq); + qint64 bytesWritten = m_tcpClient->sendData((char*)&config_device_id, length); + m_tcpClient->waitForRead(); + qDebug() << "bytesWritten: " << bytesWritten; +} void MainWindow::onSetTime(){ SetTimingReq set_time_req = { {0xAA, 0x55, 0xAA}, kTimingCmd, 1,0 }; int length = sizeof(SetTimingReq); diff --git a/mainwindow.h b/mainwindow.h index 0b104f6..bb8c80e 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -76,6 +76,9 @@ private slots: void onEthConfig(); void onMACConfig(); void onSetTime(); + void onMqttConfig(); + void onConfigDeviceID(); + void onGetDeviceID(); void onMenuActionTriggered(); void on_pushButton_slot_clicked(); diff --git a/mainwindow.ui b/mainwindow.ui index c2fe78a..8f2ed9a 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -254,7 +254,7 @@ - 触发配置 + 直流输出 true @@ -724,7 +724,7 @@ - 电源板 + Qt::AlignCenter @@ -1087,6 +1087,9 @@ + + + @@ -1138,6 +1141,21 @@ MAC配置 + + + MQTT配置 + + + + + 设备ID配置 + + + + + 获取设备ID + + diff --git a/mqtt_config.cpp b/mqtt_config.cpp new file mode 100644 index 0000000..030262e --- /dev/null +++ b/mqtt_config.cpp @@ -0,0 +1,53 @@ +#include "mqtt_config.h" +#include "ui_mqtt_config.h" +#include +MqttConfig::MqttConfig(QWidget *parent) : + QWidget(parent), + ui(new Ui::MqttConfig) +{ + ui->setupUi(this); + QString exp = "\\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.)" + "{3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"; + QRegExp rege(exp); + QValidator *Validator = new QRegExpValidator(rege); + ui->lineEdit_ip->setValidator(Validator); + m_tcpClient = MyTcpClient::instance(); + connect(m_tcpClient, SIGNAL(dataReceived(const QByteArray &)), this, SLOT(readData(const QByteArray &))); + +} + +MqttConfig::~MqttConfig() +{ + delete ui; +} +void MqttConfig::readData(const QByteArray &data) { + qDebug() << "Received from server:" << data; + uint8_t cmd = data[3]; + if (cmd == kConfigMQTTBrokerInfo) { + MQTTBrokerConfigInfoRsp mqtt_config_rsp; + memcpy(&mqtt_config_rsp, data.data(), sizeof(MQTTBrokerConfigInfoRsp)); + qDebug() << "mqtt_config_rsp code" << mqtt_config_rsp.code ; + } +} +void MqttConfig::on_pushButton_confirm_clicked() +{ + MQTTBrokerConfigInfoReq mqtt_config = { {0xAA, 0x55, 0xAA}, kConfigMQTTBrokerInfo, 1,1,{} }; + memcpy(mqtt_config.ip,ui->lineEdit_ip->text().toStdString().c_str(),sizeof(mqtt_config.ip)); + mqtt_config.port = ui->lineEdit_port->text().toInt(); + char send_buf[100] ={0}; + memcpy(send_buf, (char*)&mqtt_config, sizeof(MQTTBrokerConfigInfoReq)); + + int length = sizeof(MQTTBrokerConfigInfoReq); + qint64 bytesWritten = m_tcpClient->sendData(send_buf, length); + m_tcpClient->waitForRead(); + qDebug() << "bytesWritten: " << bytesWritten; + + this->close(); +} + + +void MqttConfig::on_pushButton_cancel_clicked() +{ + this->close(); +} + diff --git a/mqtt_config.h b/mqtt_config.h new file mode 100644 index 0000000..45e95db --- /dev/null +++ b/mqtt_config.h @@ -0,0 +1,28 @@ +#ifndef MQTT_CONFIG_H +#define MQTT_CONFIG_H + +#include +#include "MyTcpClient.h" +namespace Ui { +class MqttConfig; +} + +class MqttConfig : public QWidget +{ + Q_OBJECT + +public: + explicit MqttConfig(QWidget *parent = nullptr); + ~MqttConfig(); + +private slots: + void on_pushButton_confirm_clicked(); + + void on_pushButton_cancel_clicked(); + void readData(const QByteArray&); +private: + Ui::MqttConfig *ui; + MyTcpClient* m_tcpClient; +}; + +#endif // MQTT_CONFIG_H diff --git a/mqtt_config.ui b/mqtt_config.ui new file mode 100644 index 0000000..f8c039c --- /dev/null +++ b/mqtt_config.ui @@ -0,0 +1,116 @@ + + + MqttConfig + + + + 0 + 0 + 412 + 314 + + + + MQTT 配置 + + + + + 140 + 30 + 111 + 16 + + + + MQTT 服务器配置 + + + + + + 60 + 90 + 54 + 12 + + + + IP: + + + + + + 130 + 80 + 151 + 25 + + + + + 0 + 25 + + + + + + + 60 + 130 + 54 + 12 + + + + 端口: + + + + + + 130 + 120 + 151 + 25 + + + + + 0 + 25 + + + + + + + 90 + 230 + 75 + 23 + + + + 确定 + + + + + + 210 + 230 + 75 + 23 + + + + 取消 + + + + + + diff --git a/pressure_pulsation.cpp b/pressure_pulsation.cpp index 7f685a1..7d023db 100644 --- a/pressure_pulsation.cpp +++ b/pressure_pulsation.cpp @@ -4,7 +4,7 @@ #include #include #include - +#include #include "data_config.h" #include "vibrationdata.h" #include "config_mgr.h" @@ -58,14 +58,71 @@ void PressurePulsation::Init() { 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->radioButton_fixed->setChecked(variable_ptr->fixed); - ui->lineEdit_sample_rate->setText(QString::number(variable_ptr->sample_rate)); - ui->lineEdit_bandwidth->setText(QString::number(variable_ptr->bandwidth)); - ui->comboBox_fft_points->setCurrentText(QString::number(variable_ptr->fft_points)); - ui->lineEdit_measuring_value_min->setText(QString::number(variable_ptr->measuring_min)); - ui->lineEdit_measuring_value_max->setText(QString::number(variable_ptr->measuring_max)); - ui->lineEdit_scale_value_min->setText(QString::number(variable_ptr->scale_min)); - ui->lineEdit_scale_value_max->setText(QString::number(variable_ptr->scale_max)); + // processed output + // -general + if(variable_ptr->general.output_used) + ui->comboBox_output_used->setCurrentIndex(0); + else + ui->comboBox_output_used->setCurrentIndex(1); + ui->comboBox_engineering_unit->setCurrentIndex(variable_ptr->general.engineering_unit); + ui->comboBox_rectifier_funtion->setCurrentIndex(variable_ptr->general.rectifier_function); + // -alarm + ui->lineEdit_danger_high_level->setText(QString::number(variable_ptr->danger_high.level)); + ui->lineEdit_danger_high_hysteresis->setText(QString::number(variable_ptr->danger_high.hysteresis)); + ui->lineEdit_danger_high_delay->setText(QString::number(variable_ptr->danger_high.delay)); + ui->checkBox_danger_high_enable->setChecked(variable_ptr->danger_high.enable); + ui->checkBox_danger_high_latch->setChecked(variable_ptr->danger_high.latch); + + ui->lineEdit_alert_high_level->setText(QString::number(variable_ptr->alert_high.level)); + ui->lineEdit_alert_high_hysteresis->setText(QString::number(variable_ptr->alert_high.hysteresis)); + ui->lineEdit_alert_high_delay->setText(QString::number(variable_ptr->alert_high.delay)); + ui->checkBox_alert_high_enable->setChecked(variable_ptr->alert_high.enable); + ui->checkBox_alert_high_latch->setChecked(variable_ptr->alert_high.latch); + + ui->lineEdit_danger_low_level->setText(QString::number(variable_ptr->danger_low.level)); + ui->lineEdit_danger_low_hysteresis->setText(QString::number(variable_ptr->danger_low.hysteresis)); + ui->lineEdit_danger_low_delay->setText(QString::number(variable_ptr->danger_low.delay)); + ui->checkBox_danger_low_enable->setChecked(variable_ptr->danger_low.enable); + ui->checkBox_danger_low_latch->setChecked(variable_ptr->danger_low.latch); + + ui->lineEdit_alert_low_level->setText(QString::number(variable_ptr->alert_low.level)); + ui->lineEdit_alert_low_hysteresis->setText(QString::number(variable_ptr->alert_low.hysteresis)); + ui->lineEdit_alert_low_delay->setText(QString::number(variable_ptr->alert_low.delay)); + ui->checkBox_alert_low_enable->setChecked(variable_ptr->alert_low.enable); + ui->checkBox_alert_low_latch->setChecked(variable_ptr->alert_low.latch); + + // + ui->checkBox_enable->setChecked(variable_ptr->freband_output[0].enable); + ui->lineEdit_start->setText(QString::number(variable_ptr->freband_output[0].start)); + ui->lineEdit_end->setText(QString::number(variable_ptr->freband_output[0].end)); + ui->checkBox_enable_2->setChecked(variable_ptr->freband_output[1].enable); + ui->lineEdit_start_2->setText(QString::number(variable_ptr->freband_output[1].start)); + ui->lineEdit_end_2->setText(QString::number(variable_ptr->freband_output[1].end)); + ui->checkBox_enable_3->setChecked(variable_ptr->freband_output[2].enable); + ui->lineEdit_start_3->setText(QString::number(variable_ptr->freband_output[2].start)); + ui->lineEdit_end_3->setText(QString::number(variable_ptr->freband_output[2].end)); + ui->checkBox_enable_4->setChecked(variable_ptr->freband_output[3].enable); + ui->lineEdit_start_4->setText(QString::number(variable_ptr->freband_output[3].start)); + ui->lineEdit_end_4->setText(QString::number(variable_ptr->freband_output[3].end)); + ui->checkBox_enable_5->setChecked(variable_ptr->freband_output[4].enable); + ui->lineEdit_start_5->setText(QString::number(variable_ptr->freband_output[4].start)); + ui->lineEdit_end_5->setText(QString::number(variable_ptr->freband_output[4].end)); + ui->checkBox_enable_6->setChecked(variable_ptr->freband_output[5].enable); + ui->lineEdit_start_6->setText(QString::number(variable_ptr->freband_output[5].start)); + ui->lineEdit_end_6->setText(QString::number(variable_ptr->freband_output[5].end)); + ui->checkBox_enable_7->setChecked(variable_ptr->freband_output[6].enable); + ui->lineEdit_start_7->setText(QString::number(variable_ptr->freband_output[6].start)); + ui->lineEdit_end_7->setText(QString::number(variable_ptr->freband_output[6].end)); + ui->checkBox_enable_8->setChecked(variable_ptr->freband_output[7].enable); + ui->lineEdit_start_8->setText(QString::number(variable_ptr->freband_output[7].start)); + ui->lineEdit_end_8->setText(QString::number(variable_ptr->freband_output[7].end)); + ui->checkBox_enable_9->setChecked(variable_ptr->freband_output[8].enable); + ui->lineEdit_start_9->setText(QString::number(variable_ptr->freband_output[8].start)); + ui->lineEdit_end_9->setText(QString::number(variable_ptr->freband_output[8].end)); + ui->checkBox_enable_10->setChecked(variable_ptr->freband_output[9].enable); + ui->lineEdit_start_10->setText(QString::number(variable_ptr->freband_output[9].start)); + ui->lineEdit_end_10->setText(QString::number(variable_ptr->freband_output[9].end)); + } void PressurePulsation::on_pushButton_confirm_clicked() { @@ -74,9 +131,17 @@ void PressurePulsation::on_pushButton_confirm_clicked() qCritical() << "[Radial::Init] should not be here"; return; } + if(ui->lineEdit_alert_high_level->text().toFloat() > ui->lineEdit_danger_high_level->text().toDouble()){ + QMessageBox::warning(this, QStringLiteral("警告"), "危险 + 高 必须大于 警报 + 高"); + return; + } std::shared_ptr ptr = std::dynamic_pointer_cast(base_ptr); + ptr->base_config_[channel - 1].channel_type = kVibPressurePulsation; + std::shared_ptr variable_base = ptr->GetChannelPtr(channel); - if (variable_base == nullptr || variable_base->type_ != kVibThrust) { + std::shared_ptr variable = std::dynamic_pointer_cast(variable_base); + + if (variable_base == nullptr || variable_base->type_ != kVibThrust || variable == nullptr) { if (variable_base == nullptr) { qDebug() << "no channel ptr"; } else { @@ -95,20 +160,71 @@ void PressurePulsation::on_pushButton_confirm_clicked() variable->filter_[2].checked = ui->checkBox_band_pass->checkState(); variable->filter_[2].low = ui->spinBox_band_pass_low->value(); variable->filter_[2].high = ui->spinBox_band_pass_high->value(); - variable->fixed = ui->radioButton_fixed->isChecked(); - variable->sample_rate = ui->lineEdit_sample_rate->text().toUInt(); - variable->bandwidth = ui->lineEdit_bandwidth->text().toInt(); - variable->fft_points = ui->comboBox_fft_points->currentText().toInt(); - variable->measuring_min = ui->lineEdit_measuring_value_min->text().toInt(); - variable->measuring_max = ui->lineEdit_measuring_value_max->text().toInt(); - variable->scale_min = ui->lineEdit_scale_value_min->text().toInt(); - variable->scale_max = ui->lineEdit_scale_value_max->text().toInt(); + // processed output + // -general + if(ui->comboBox_output_used->currentIndex() == 0) + variable->general.output_used = true; + else + variable->general.output_used = false; + variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); + variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); + // -alarm + variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble(); + variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble(); + variable->danger_high.delay = ui->lineEdit_danger_high_delay->text().toDouble(); + variable->danger_high.enable = ui->checkBox_danger_high_enable->isChecked(); + variable->danger_high.latch = ui->checkBox_danger_high_latch->isChecked(); + variable->alert_high.level = ui->lineEdit_alert_high_level->text().toDouble(); + variable->alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble(); + variable->alert_high.delay = ui->lineEdit_alert_high_delay->text().toDouble(); + variable->alert_high.enable = ui->checkBox_alert_high_enable->isChecked(); + variable->alert_high.latch = ui->checkBox_alert_high_latch->isChecked(); + variable->danger_low.level = ui->lineEdit_danger_low_level->text().toDouble(); + variable->danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis->text().toDouble(); + variable->danger_low.delay = ui->lineEdit_danger_low_delay->text().toDouble(); + variable->danger_low.enable = ui->checkBox_danger_low_enable->isChecked(); + variable->danger_low.latch = ui->checkBox_danger_low_latch->isChecked(); + variable->alert_low.level = ui->lineEdit_alert_low_level->text().toDouble(); + variable->alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis->text().toDouble(); + variable->alert_low.delay = ui->lineEdit_alert_low_delay->text().toDouble(); + variable->alert_low.enable = ui->checkBox_alert_low_enable->isChecked(); + variable->alert_low.latch = ui->checkBox_alert_low_latch->isChecked(); + // -freband output + variable->freband_output[0].enable = ui->checkBox_enable->isChecked(); + variable->freband_output[0].start = ui->lineEdit_start->text().toDouble(); + variable->freband_output[0].end = ui->lineEdit_end->text().toDouble(); + variable->freband_output[1].enable = ui->checkBox_enable_2->isChecked(); + variable->freband_output[1].start = ui->lineEdit_start_2->text().toDouble(); + variable->freband_output[1].end = ui->lineEdit_end_2->text().toDouble(); + variable->freband_output[2].enable = ui->checkBox_enable_3->isChecked(); + variable->freband_output[2].start = ui->lineEdit_start_3->text().toDouble(); + variable->freband_output[2].end = ui->lineEdit_end_3->text().toDouble(); + variable->freband_output[3].enable = ui->checkBox_enable_4->isChecked(); + variable->freband_output[3].start = ui->lineEdit_start_4->text().toDouble(); + variable->freband_output[3].end = ui->lineEdit_end_4->text().toDouble(); + variable->freband_output[4].enable = ui->checkBox_enable_5->isChecked(); + variable->freband_output[4].start = ui->lineEdit_start_5->text().toDouble(); + variable->freband_output[4].end = ui->lineEdit_end_5->text().toDouble(); + variable->freband_output[5].enable = ui->checkBox_enable_6->isChecked(); + variable->freband_output[5].start = ui->lineEdit_start_6->text().toDouble(); + variable->freband_output[5].end = ui->lineEdit_end_6->text().toDouble(); + variable->freband_output[6].enable = ui->checkBox_enable_7->isChecked(); + variable->freband_output[6].start = ui->lineEdit_start_7->text().toDouble(); + variable->freband_output[6].end = ui->lineEdit_end_7->text().toDouble(); + variable->freband_output[7].enable = ui->checkBox_enable_8->isChecked(); + variable->freband_output[7].start = ui->lineEdit_start_8->text().toDouble(); + variable->freband_output[7].end = ui->lineEdit_end_8->text().toDouble(); + variable->freband_output[8].enable = ui->checkBox_enable_9->isChecked(); + variable->freband_output[8].start = ui->lineEdit_start_9->text().toDouble(); + variable->freband_output[8].end = ui->lineEdit_end_9->text().toDouble(); + variable->freband_output[9].enable = ui->checkBox_enable_10->isChecked(); + variable->freband_output[9].start = ui->lineEdit_start_10->text().toDouble(); + variable->freband_output[9].end = ui->lineEdit_end_10->text().toDouble(); 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->checkState(); variable->filter_[0].low = ui->spinBox_low_pass_low->value(); variable->filter_[0].high = ui->spinBox_low_pass_high->value(); @@ -118,14 +234,66 @@ void PressurePulsation::on_pushButton_confirm_clicked() variable->filter_[2].checked = ui->checkBox_band_pass->checkState(); variable->filter_[2].low = ui->spinBox_band_pass_low->value(); variable->filter_[2].high = ui->spinBox_band_pass_high->value(); - variable->fixed = ui->radioButton_fixed->isChecked(); - variable->sample_rate = ui->lineEdit_sample_rate->text().toUInt(); - variable->bandwidth = ui->lineEdit_bandwidth->text().toInt(); - variable->fft_points = ui->comboBox_fft_points->currentText().toInt(); - variable->measuring_min = ui->lineEdit_measuring_value_min->text().toInt(); - variable->measuring_max = ui->lineEdit_measuring_value_max->text().toInt(); - variable->scale_min = ui->lineEdit_scale_value_min->text().toInt(); - variable->scale_max = ui->lineEdit_scale_value_max->text().toInt(); + // processed output + // -general + if(ui->comboBox_output_used->currentIndex() == 0) + variable->general.output_used = true; + else + variable->general.output_used = false; + variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); + variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); + // -alarm + variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble(); + variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble(); + variable->danger_high.delay = ui->lineEdit_danger_high_delay->text().toDouble(); + variable->danger_high.enable = ui->checkBox_danger_high_enable->isChecked(); + variable->danger_high.latch = ui->checkBox_danger_high_latch->isChecked(); + variable->alert_high.level = ui->lineEdit_alert_high_level->text().toDouble(); + variable->alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble(); + variable->alert_high.delay = ui->lineEdit_alert_high_delay->text().toDouble(); + variable->alert_high.enable = ui->checkBox_alert_high_enable->isChecked(); + variable->alert_high.latch = ui->checkBox_alert_high_latch->isChecked(); + variable->danger_low.level = ui->lineEdit_danger_low_level->text().toDouble(); + variable->danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis->text().toDouble(); + variable->danger_low.delay = ui->lineEdit_danger_low_delay->text().toDouble(); + variable->danger_low.enable = ui->checkBox_danger_low_enable->isChecked(); + variable->danger_low.latch = ui->checkBox_danger_low_latch->isChecked(); + variable->alert_low.level = ui->lineEdit_alert_low_level->text().toDouble(); + variable->alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis->text().toDouble(); + variable->alert_low.delay = ui->lineEdit_alert_low_delay->text().toDouble(); + variable->alert_low.enable = ui->checkBox_alert_low_enable->isChecked(); + variable->alert_low.latch = ui->checkBox_alert_low_latch->isChecked(); + // -freband output + variable->freband_output[0].enable = ui->checkBox_enable->isChecked(); + variable->freband_output[0].start = ui->lineEdit_start->text().toDouble(); + variable->freband_output[0].end = ui->lineEdit_end->text().toDouble(); + variable->freband_output[1].enable = ui->checkBox_enable_2->isChecked(); + variable->freband_output[1].start = ui->lineEdit_start_2->text().toDouble(); + variable->freband_output[1].end = ui->lineEdit_end_2->text().toDouble(); + variable->freband_output[2].enable = ui->checkBox_enable_3->isChecked(); + variable->freband_output[2].start = ui->lineEdit_start_3->text().toDouble(); + variable->freband_output[2].end = ui->lineEdit_end_3->text().toDouble(); + variable->freband_output[3].enable = ui->checkBox_enable_4->isChecked(); + variable->freband_output[3].start = ui->lineEdit_start_4->text().toDouble(); + variable->freband_output[3].end = ui->lineEdit_end_4->text().toDouble(); + variable->freband_output[4].enable = ui->checkBox_enable_5->isChecked(); + variable->freband_output[4].start = ui->lineEdit_start_5->text().toDouble(); + variable->freband_output[4].end = ui->lineEdit_end_5->text().toDouble(); + variable->freband_output[5].enable = ui->checkBox_enable_6->isChecked(); + variable->freband_output[5].start = ui->lineEdit_start_6->text().toDouble(); + variable->freband_output[5].end = ui->lineEdit_end_6->text().toDouble(); + variable->freband_output[6].enable = ui->checkBox_enable_7->isChecked(); + variable->freband_output[6].start = ui->lineEdit_start_7->text().toDouble(); + variable->freband_output[6].end = ui->lineEdit_end_7->text().toDouble(); + variable->freband_output[7].enable = ui->checkBox_enable_8->isChecked(); + variable->freband_output[7].start = ui->lineEdit_start_8->text().toDouble(); + variable->freband_output[7].end = ui->lineEdit_end_8->text().toDouble(); + variable->freband_output[8].enable = ui->checkBox_enable_9->isChecked(); + variable->freband_output[8].start = ui->lineEdit_start_9->text().toDouble(); + variable->freband_output[8].end = ui->lineEdit_end_9->text().toDouble(); + variable->freband_output[9].enable = ui->checkBox_enable_10->isChecked(); + variable->freband_output[9].start = ui->lineEdit_start_10->text().toDouble(); + variable->freband_output[9].end = ui->lineEdit_end_10->text().toDouble(); this->close(); } @@ -136,3 +304,11 @@ void PressurePulsation::on_pushButton_cancel_clicked() this->close(); } + +void PressurePulsation::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()); + } +} + diff --git a/pressure_pulsation.h b/pressure_pulsation.h index 8bdbcaa..76b4316 100644 --- a/pressure_pulsation.h +++ b/pressure_pulsation.h @@ -22,6 +22,8 @@ private slots: void on_pushButton_cancel_clicked(); + void on_lineEdit_alert_high_level_editingFinished(); + private: Ui::PressurePulsation *ui; void Init(); diff --git a/pressure_pulsation.ui b/pressure_pulsation.ui index c196bd0..3dcbea9 100644 --- a/pressure_pulsation.ui +++ b/pressure_pulsation.ui @@ -7,11 +7,11 @@ 0 0 701 - 519 + 572 - Form + 压力脉动 @@ -76,7 +76,7 @@ 30 - 450 + 500 632 37 @@ -161,617 +161,1257 @@ - 20 - 60 - 651 - 381 + 10 + 50 + 667 + 434 1 - + - 传感器和滤波配置 + 滤波 - + + + + + 滤波 + + + + + + + + + + 高通: + + + + + + + + 60 + 0 + + + + + 60 + 16777215 + + + + 3 + + + 3000 + + + + + + + - + + + + + + + + 60 + 0 + + + + + 60 + 16777215 + + + + 3 + + + 3000 + + + 3000 + + + + + + + + 60 + 0 + + + + 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 + + + + + + + + + + + + Qt::Vertical + + + + 20 + 248 + + + + + + + + + + + + 处理后输出 + + + + + 530 + 320 + 54 + 12 + + + + % + + + 10 - 30 - 353 - 116 + 40 + 621 + 321 - - 滤波 + + 0 - - - - - - - 高通: - - - - - - - - 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 - - - - - - - + + + 常规 + + + + + 220 + 150 + 54 + 12 + + + + 整流器 + + + + + + 10 + 140 + 150 + 25 + + + + + 150 + 25 + + + + + 150 + 25 + + + + + RMS + + + + + + + 220 + 50 + 54 + 12 + + + + 输出使用 + + + + + + 10 + 90 + 150 + 25 + + + + + 150 + 25 + + + + + 150 + 25 + + + + + g + + + + + m/s**2 + + + + + mm/s + + + + + inch/s + + + + + um + + + + + mm + + + + + + + 220 + 100 + 54 + 12 + + + + 工程单位 + + + + + + 10 + 40 + 150 + 25 + + + + + 150 + 25 + + + + + 150 + 25 + + + + + + + + + + + + + + + + + 警报 + + + + + 10 + 60 + 71 + 16 + + + + 危险 + 高 + + + + + + 10 + 100 + 71 + 16 + + + + 警报 + 高 + + + + + + 10 + 140 + 71 + 16 + + + + 警报 + 低 + + + + + + 10 + 180 + 71 + 16 + + + + 危险 + 低 + + + + + + 90 + 30 + 31 + 31 + + + + 等级 + + + + + + 170 + 30 + 31 + 31 + + + + 回差 + + + + + + 230 + 30 + 31 + 31 + + + + 延时 + + + + + + 280 + 40 + 41 + 16 + + + + 使能 + + + + + + 340 + 40 + 41 + 16 + + + + 锁存 + + + + + + 80 + 60 + 51 + 20 + + + + + + + 150 + 60 + 51 + 20 + + + + + + + 220 + 60 + 51 + 20 + + + + + + + 220 + 100 + 51 + 20 + + + + + + + 80 + 100 + 51 + 20 + + + + + + + 150 + 100 + 51 + 20 + + + + + + false + + + + 220 + 140 + 51 + 20 + + + + + + false + + + + 150 + 180 + 51 + 20 + + + + + + false + + + + 80 + 140 + 51 + 20 + + + + + + false + + + + 220 + 180 + 51 + 20 + + + + + + false + + + + 80 + 180 + 51 + 20 + + + + + + false + + + + 150 + 140 + 51 + 20 + + + + + + + 290 + 60 + 16 + 16 + + + + + + + + + + 290 + 100 + 16 + 16 + + + + + + + + + false + + + + 290 + 140 + 16 + 16 + + + + + + + + + false + + + + 290 + 180 + 16 + 16 + + + + + + + + + + 350 + 100 + 16 + 16 + + + + + + + + + false + + + + 350 + 180 + 16 + 16 + + + + + + + + + + 350 + 60 + 16 + 16 + + + + + + + + + false + + + + 350 + 140 + 16 + 16 + + + + + + + - + - 特征值和警报配置 + 分频段选择 - + - 10 - 10 - 471 - 191 + 50 + 90 + 71 + 16 - - 采样频率 + + 使能 - - - - 20 - 30 - 397 - 24 - - - - - - - 固定 - - - - - - - - - 采样率: - - - - - - - - 100 - 20 - - - - - - - - Hz - - - - - - - - - - - 带宽: - - - - - - - - 100 - 20 - - - - - - - - Hz - - - - - - - - - - - 20 - 70 - 118 - 22 - - - - - - - FFT 点数: - - - - - - - - 8192 - - - - - - - - - - 20 - 100 - 122 - 14 - - - - - - - 频率范围: - - - - - - - 5000 Hz - - - - - - - - - 20 - 130 - 92 - 14 - - - - - - - 线数: - - - - - - - 1250 Hz - - - - - - - - - 20 - 160 - 104 - 14 - - - - - - - 频率分辨率: - - - - - - - 4 Hz - - - - - - + - 10 - 219 - 471 - 121 + 170 + 50 + 91 + 16 - - 测量 + + 频率开始(Hz) + + + + + + 320 + 50 + 91 + 16 + + + + 频率结束(Hz) + + + + + + 150 + 90 + 113 + 20 + + + + + + + 300 + 90 + 113 + 20 + + + + + + + 150 + 120 + 113 + 20 + + + + + + + 50 + 120 + 71 + 16 + + + + 使能 + + + + + + 300 + 120 + 113 + 20 + + + + + + + 50 + 150 + 71 + 16 + + + + 使能 + + + + + + 300 + 150 + 113 + 20 + + + + + + + 150 + 150 + 113 + 20 + + + + + + + 50 + 180 + 71 + 16 + + + + 使能 + + + + + + 300 + 180 + 113 + 20 + + + + + + + 150 + 180 + 113 + 20 + + + + + + false + + + + 50 + 210 + 71 + 16 + + + + 使能 + + + + + false + + + + 300 + 210 + 113 + 20 + + + + + + false + + + + 150 + 210 + 113 + 20 + + + + + + false + + + + 50 + 240 + 71 + 16 + + + + 使能 + + + + + false + + + + 300 + 240 + 113 + 20 + + + + + + false + + + + 150 + 240 + 113 + 20 + + + + + + false + + + + 50 + 270 + 71 + 16 + + + + 使能 + + + + + false + + + + 300 + 270 + 113 + 20 + + + + + + false + + + + 150 + 270 + 113 + 20 + + + + + + false + + + + 50 + 300 + 71 + 16 + + + + 使能 + + + + + false + + + + 300 + 300 + 113 + 20 + + + + + + false + + + + 150 + 300 + 113 + 20 + + + + + + false + + + + 50 + 330 + 71 + 16 + + + + 使能 + + + + + false + + + + 300 + 330 + 113 + 20 + + + + + + false + + + + 150 + 330 + 113 + 20 + + + + + + false + + + + 50 + 360 + 71 + 16 + + + + 使能 + + + + + false + + + + 300 + 360 + 113 + 20 + + + + + + false + + + + 150 + 360 + 113 + 20 + - - - - 20 - 40 - 54 - 12 - - - - 最小: - - - - - - 20 - 80 - 54 - 12 - - - - 最大: - - - - - - 90 - 20 - 54 - 12 - - - - 测量值 - - - - - - 230 - 20 - 54 - 12 - - - - 对应值 - - - - - - 70 - 40 - 81 - 20 - - - - - - - 210 - 40 - 81 - 20 - - - - - - - 70 - 80 - 81 - 20 - - - - - - - 210 - 80 - 81 - 20 - - - - - - - 310 - 40 - 54 - 12 - - - - mbar - - - - - - 310 - 80 - 54 - 12 - - - - mbar - - - - - - 160 - 40 - 31 - 16 - - - - mV - - - - - - 160 - 80 - 31 - 16 - - - - mV - - diff --git a/radial_vibration.cpp b/radial_vibration.cpp index e82e43d..3159970 100644 --- a/radial_vibration.cpp +++ b/radial_vibration.cpp @@ -5,7 +5,7 @@ #include #include #include - +#include #include "data_config.h" #include "vibrationdata.h" #include "config_mgr.h" @@ -37,27 +37,11 @@ void Radial::on_pushButton_cancel_clicked() { } void Radial::on_checkBox_1x_ampl_toggled(bool checked) { - if (checked) { - ui->comboBox_1x_value_range->setEnabled(true); - ui->doubleSpinBox_1x_ampl_clamp->setEnabled(true); - ui->doubleSpinBox_1x_phase_lag_clamp->setEnabled(true); - return; - } - ui->comboBox_1x_value_range->setEnabled(false); - ui->doubleSpinBox_1x_ampl_clamp->setEnabled(false); - ui->doubleSpinBox_1x_phase_lag_clamp->setEnabled(false); + } void Radial::on_checkBox_2x_ampl_toggled(bool checked) { - if (checked) { - ui->comboBox_2x_value_range->setEnabled(true); - ui->doubleSpinBox_2x_ampl_clamp->setEnabled(true); - ui->doubleSpinBox_2x_phase_lag_clamp->setEnabled(true); - return; - } - ui->comboBox_2x_value_range->setEnabled(false); - ui->doubleSpinBox_2x_ampl_clamp->setEnabled(false); - ui->doubleSpinBox_2x_phase_lag_clamp->setEnabled(false); + } void Radial::Init() { @@ -86,29 +70,71 @@ void Radial::Init() { 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->checkBox_1x_ampl->setChecked(variable_ptr->x1_.checked); - ui->comboBox_1x_value_range->setCurrentIndex(variable_ptr->x1_.full_scale_range); - ui->doubleSpinBox_1x_ampl_clamp->setValue(variable_ptr->x1_.clamp_value); - ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variable_ptr->x1_.phase_lag); - ui->checkBox_2x_ampl->setChecked(variable_ptr->x2_.checked); - ui->comboBox_2x_value_range->setCurrentIndex(variable_ptr->x2_.full_scale_range); - ui->doubleSpinBox_2x_ampl_clamp->setValue(variable_ptr->x2_.clamp_value); - ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variable_ptr->x2_.phase_lag); - 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_trip_multiply->setValue(variable_ptr->recorder_out_.trip_multiply); - ui->comboBox_comparision->setCurrentIndex(variable_ptr->recorder_out_.comparision); - ui->spinBox_comparision_percentage->setValue(variable_ptr->recorder_out_.percentage); + // processed output + // -general + if(variable_ptr->general.output_used) + ui->comboBox_output_used->setCurrentIndex(0); + else + ui->comboBox_output_used->setCurrentIndex(1); + ui->comboBox_engineering_unit->setCurrentIndex(variable_ptr->general.engineering_unit); + ui->comboBox_rectifier_funtion->setCurrentIndex(variable_ptr->general.rectifier_function); + // -alarm + ui->lineEdit_danger_high_level->setText(QString::number(variable_ptr->danger_high.level)); + ui->lineEdit_danger_high_hysteresis->setText(QString::number(variable_ptr->danger_high.hysteresis)); + ui->lineEdit_danger_high_delay->setText(QString::number(variable_ptr->danger_high.delay)); + ui->checkBox_danger_high_enable->setChecked(variable_ptr->danger_high.enable); + ui->checkBox_danger_high_latch->setChecked(variable_ptr->danger_high.latch); + + ui->lineEdit_alert_high_level->setText(QString::number(variable_ptr->alert_high.level)); + ui->lineEdit_alert_high_hysteresis->setText(QString::number(variable_ptr->alert_high.hysteresis)); + ui->lineEdit_alert_high_delay->setText(QString::number(variable_ptr->alert_high.delay)); + ui->checkBox_alert_high_enable->setChecked(variable_ptr->alert_high.enable); + ui->checkBox_alert_high_latch->setChecked(variable_ptr->alert_high.latch); + + ui->lineEdit_danger_low_level->setText(QString::number(variable_ptr->danger_low.level)); + ui->lineEdit_danger_low_hysteresis->setText(QString::number(variable_ptr->danger_low.hysteresis)); + ui->lineEdit_danger_low_delay->setText(QString::number(variable_ptr->danger_low.delay)); + ui->checkBox_danger_low_enable->setChecked(variable_ptr->danger_low.enable); + ui->checkBox_danger_low_latch->setChecked(variable_ptr->danger_low.latch); + + ui->lineEdit_alert_low_level->setText(QString::number(variable_ptr->alert_low.level)); + ui->lineEdit_alert_low_hysteresis->setText(QString::number(variable_ptr->alert_low.hysteresis)); + ui->lineEdit_alert_low_delay->setText(QString::number(variable_ptr->alert_low.delay)); + ui->checkBox_alert_low_enable->setChecked(variable_ptr->alert_low.enable); + ui->checkBox_alert_low_latch->setChecked(variable_ptr->alert_low.latch); + + // Gap + // -general + if(variable_ptr->gap_general.output_used) + ui->comboBox_output_used_2->setCurrentIndex(0); + else + ui->comboBox_output_used_2->setCurrentIndex(1); + ui->comboBox_engineering_unit_2->setCurrentIndex(variable_ptr->general.engineering_unit); + ui->comboBox_rectifier_funtion_2->setCurrentIndex(variable_ptr->general.rectifier_function); + // -alarm + ui->lineEdit_danger_high_level_2->setText(QString::number(variable_ptr->gap_danger_high.level)); + ui->lineEdit_danger_high_hysteresis_2->setText(QString::number(variable_ptr->gap_danger_high.hysteresis)); + ui->lineEdit_danger_high_delay_2->setText(QString::number(variable_ptr->gap_danger_high.delay)); + ui->checkBox_danger_high_enable_2->setChecked(variable_ptr->gap_danger_high.enable); + ui->checkBox_danger_high_latch_2->setChecked(variable_ptr->gap_danger_high.latch); + + ui->lineEdit_alert_high_level_2->setText(QString::number(variable_ptr->gap_alert_high.level)); + ui->lineEdit_alert_high_hysteresis_2->setText(QString::number(variable_ptr->gap_alert_high.hysteresis)); + ui->lineEdit_alert_high_delay_2->setText(QString::number(variable_ptr->gap_alert_high.delay)); + ui->checkBox_alert_high_enable_2->setChecked(variable_ptr->gap_alert_high.enable); + ui->checkBox_alert_high_latch_2->setChecked(variable_ptr->gap_alert_high.latch); + + ui->lineEdit_danger_low_level_2->setText(QString::number(variable_ptr->gap_danger_low.level)); + ui->lineEdit_danger_low_hysteresis_2->setText(QString::number(variable_ptr->gap_danger_low.hysteresis)); + ui->lineEdit_danger_low_delay_2->setText(QString::number(variable_ptr->gap_danger_low.delay)); + ui->checkBox_danger_low_enable_2->setChecked(variable_ptr->gap_danger_low.enable); + ui->checkBox_danger_low_latch_2->setChecked(variable_ptr->gap_danger_low.latch); + + ui->lineEdit_alert_low_level_2->setText(QString::number(variable_ptr->gap_alert_low.level)); + ui->lineEdit_alert_low_hysteresis_2->setText(QString::number(variable_ptr->gap_alert_low.hysteresis)); + ui->lineEdit_alert_low_delay_2->setText(QString::number(variable_ptr->gap_alert_low.delay)); + ui->checkBox_alert_low_enable_2->setChecked(variable_ptr->gap_alert_low.enable); + ui->checkBox_alert_low_latch_2->setChecked(variable_ptr->gap_alert_low.latch); } void Radial::on_pushButton_confirm_clicked() { @@ -117,9 +143,17 @@ void Radial::on_pushButton_confirm_clicked() { qCritical() << "[Radial::Init] should not be here"; return; } + if(ui->lineEdit_alert_high_level->text().toFloat() > ui->lineEdit_danger_high_level->text().toDouble()){ + QMessageBox::warning(this, QStringLiteral("警告"), "危险 + 高 必须大于 警报 + 高"); + return; + } std::shared_ptr ptr = std::dynamic_pointer_cast(base_ptr); + ptr->base_config_[channel - 1].channel_type = kVibRadial; + std::shared_ptr variable_base = ptr->GetChannelPtr(channel); - if (variable_base == nullptr || variable_base->type_ != kVibRadial) { + std::shared_ptr variable = std::dynamic_pointer_cast(variable_base); + + if (variable_base == nullptr || variable_base->type_ != kVibRadial || variable == nullptr) { if (variable_base == nullptr) { qDebug() << "no channel ptr"; } else { @@ -138,34 +172,69 @@ void Radial::on_pushButton_confirm_clicked() { 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->x1_.checked = ui->checkBox_1x_ampl->isChecked(); - variable->x1_.full_scale_range = ui->comboBox_1x_value_range->currentIndex(); - variable->x1_.clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value(); - variable->x1_.custom = 0; // TODO: - variable->x1_.phase_lag = ui->doubleSpinBox_1x_phase_lag_clamp->value(); - variable->x2_.checked = ui->checkBox_2x_ampl->isChecked(); - variable->x2_.full_scale_range = ui->comboBox_2x_value_range->currentIndex(); - variable->x2_.clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value(); - variable->x2_.custom = 0; // TODO: - variable->x2_.phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value(); - variable->recorder_out_.recorder_output = ui->comboBox_recorder_output->currentIndex(); - variable->recorder_out_.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked(); - variable->recorder_out_.trip_multiply = ui->doubleSpinBox_trip_multiply->value(); - variable->recorder_out_.comparision = ui->comboBox_comparision->currentIndex(); - variable->recorder_out_.percentage = ui->spinBox_comparision_percentage->value(); - 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(); + // processed output + // -general + if(ui->comboBox_output_used->currentIndex() == 0) + variable->general.output_used = true; + else + variable->general.output_used = false; + variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); + variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); + // -alarm + variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble(); + variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble(); + variable->danger_high.delay = ui->lineEdit_danger_high_delay->text().toDouble(); + variable->danger_high.enable = ui->checkBox_danger_high_enable->isChecked(); + variable->danger_high.latch = ui->checkBox_danger_high_latch->isChecked(); + variable->alert_high.level = ui->lineEdit_alert_high_level->text().toDouble(); + variable->alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble(); + variable->alert_high.delay = ui->lineEdit_alert_high_delay->text().toDouble(); + variable->alert_high.enable = ui->checkBox_alert_high_enable->isChecked(); + variable->alert_high.latch = ui->checkBox_alert_high_latch->isChecked(); +// variable->danger_low.level = ui->lineEdit_danger_low_level->text().toDouble(); +// variable->danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis->text().toDouble(); +// variable->danger_low.delay = ui->lineEdit_danger_low_delay->text().toDouble(); +// variable->danger_low.enable = ui->checkBox_danger_low_enable->isChecked(); +// variable->danger_low.latch = ui->checkBox_danger_low_latch->isChecked(); +// variable->alert_low.level = ui->lineEdit_alert_low_level->text().toDouble(); +// variable->alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis->text().toDouble(); +// variable->alert_low.delay = ui->lineEdit_alert_low_delay->text().toDouble(); +// variable->alert_low.enable = ui->checkBox_alert_low_enable->isChecked(); +// variable->alert_low.latch = ui->checkBox_alert_low_latch->isChecked(); + // Gap + // -general + if(ui->comboBox_output_used_2->currentIndex() == 0) + variable->gap_general.output_used = true; + else + variable->gap_general.output_used = false; + variable->gap_general.engineering_unit = ui->comboBox_engineering_unit_2->currentIndex(); + variable->gap_general.rectifier_function = ui->comboBox_rectifier_funtion_2->currentIndex(); + // -alarm + variable->gap_danger_high.level = ui->lineEdit_danger_high_level_2->text().toDouble(); + variable->gap_danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis_2->text().toDouble(); + variable->gap_danger_high.delay = ui->lineEdit_danger_high_delay_2->text().toDouble(); + variable->gap_danger_high.enable = ui->checkBox_danger_high_enable_2->isChecked(); + variable->gap_danger_high.latch = ui->checkBox_danger_high_latch_2->isChecked(); + variable->gap_alert_high.level = ui->lineEdit_alert_high_level_2->text().toDouble(); + variable->gap_alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis_2->text().toDouble(); + variable->gap_alert_high.delay = ui->lineEdit_alert_high_delay_2->text().toDouble(); + variable->gap_alert_high.enable = ui->checkBox_alert_high_enable_2->isChecked(); + variable->gap_alert_high.latch = ui->checkBox_alert_high_latch_2->isChecked(); +// variable->gap_danger_low.level = ui->lineEdit_danger_low_level_2->text().toDouble(); +// variable->gap_danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis_2->text().toDouble(); +// variable->gap_danger_low.delay = ui->lineEdit_danger_low_delay_2->text().toDouble(); +// variable->gap_danger_low.enable = ui->checkBox_danger_low_enable_2->isChecked(); +// variable->gap_danger_low.latch = ui->checkBox_danger_low_latch_2->isChecked(); +// variable->gap_alert_low.level = ui->lineEdit_alert_low_level_2->text().toDouble(); +// variable->gap_alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis_2->text().toDouble(); +// variable->gap_alert_low.delay = ui->lineEdit_alert_low_delay_2->text().toDouble(); +// variable->gap_alert_low.enable = ui->checkBox_alert_low_enable_2->isChecked(); +// variable->gap_alert_low.latch = ui->checkBox_alert_low_latch_2->isChecked(); + // add to ptr 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(); @@ -175,29 +244,64 @@ void Radial::on_pushButton_confirm_clicked() { 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->x1_.checked = ui->checkBox_1x_ampl->isChecked(); - variable->x1_.full_scale_range = ui->comboBox_1x_value_range->currentIndex(); - variable->x1_.clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value(); - variable->x1_.custom = 0; // TODO: - variable->x1_.phase_lag = ui->doubleSpinBox_1x_phase_lag_clamp->value(); - variable->x2_.checked = ui->checkBox_2x_ampl->isChecked(); - variable->x2_.full_scale_range = ui->comboBox_2x_value_range->currentIndex(); - variable->x2_.clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value(); - variable->x2_.custom = 0; // TODO: - variable->x2_.phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value(); - variable->recorder_out_.recorder_output = ui->comboBox_recorder_output->currentIndex(); - variable->recorder_out_.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked(); - variable->recorder_out_.trip_multiply = ui->doubleSpinBox_trip_multiply->value(); - variable->recorder_out_.comparision = ui->comboBox_comparision->currentIndex(); - variable->recorder_out_.percentage = ui->spinBox_comparision_percentage->value(); - 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(); + // processed output + // -general + if(ui->comboBox_output_used->currentIndex() == 0) + variable->general.output_used = true; + else + variable->general.output_used = false; + variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); + variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); + // -alarm + variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble(); + variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble(); + variable->danger_high.delay = ui->lineEdit_danger_high_delay->text().toDouble(); + variable->danger_high.enable = ui->checkBox_danger_high_enable->isChecked(); + variable->danger_high.latch = ui->checkBox_danger_high_latch->isChecked(); + variable->alert_high.level = ui->lineEdit_alert_high_level->text().toDouble(); + variable->alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble(); + variable->alert_high.delay = ui->lineEdit_alert_high_delay->text().toDouble(); + variable->alert_high.enable = ui->checkBox_alert_high_enable->isChecked(); + variable->alert_high.latch = ui->checkBox_alert_high_latch->isChecked(); +// variable->danger_low.level = ui->lineEdit_danger_low_level->text().toDouble(); +// variable->danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis->text().toDouble(); +// variable->danger_low.delay = ui->lineEdit_danger_low_delay->text().toDouble(); +// variable->danger_low.enable = ui->checkBox_danger_low_enable->isChecked(); +// variable->danger_low.latch = ui->checkBox_danger_low_latch->isChecked(); +// variable->alert_low.level = ui->lineEdit_alert_low_level->text().toDouble(); +// variable->alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis->text().toDouble(); +// variable->alert_low.delay = ui->lineEdit_alert_low_delay->text().toDouble(); +// variable->alert_low.enable = ui->checkBox_alert_low_enable->isChecked(); +// variable->alert_low.latch = ui->checkBox_alert_low_latch->isChecked(); + // Gap + // -general + if(ui->comboBox_output_used_2->currentIndex() == 0) + variable->gap_general.output_used = true; + else + variable->gap_general.output_used = false; + variable->gap_general.engineering_unit = ui->comboBox_engineering_unit_2->currentIndex(); + variable->gap_general.rectifier_function = ui->comboBox_rectifier_funtion_2->currentIndex(); + // -alarm + variable->gap_danger_high.level = ui->lineEdit_danger_high_level_2->text().toDouble(); + variable->gap_danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis_2->text().toDouble(); + variable->gap_danger_high.delay = ui->lineEdit_danger_high_delay_2->text().toDouble(); + variable->gap_danger_high.enable = ui->checkBox_danger_high_enable_2->isChecked(); + variable->gap_danger_high.latch = ui->checkBox_danger_high_latch_2->isChecked(); + variable->gap_alert_high.level = ui->lineEdit_alert_high_level_2->text().toDouble(); + variable->gap_alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis_2->text().toDouble(); + variable->gap_alert_high.delay = ui->lineEdit_alert_high_delay_2->text().toDouble(); + variable->gap_alert_high.enable = ui->checkBox_alert_high_enable_2->isChecked(); + variable->gap_alert_high.latch = ui->checkBox_alert_high_latch_2->isChecked(); +// variable->gap_danger_low.level = ui->lineEdit_danger_low_level_2->text().toDouble(); +// variable->gap_danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis_2->text().toDouble(); +// variable->gap_danger_low.delay = ui->lineEdit_danger_low_delay_2->text().toDouble(); +// variable->gap_danger_low.enable = ui->checkBox_danger_low_enable_2->isChecked(); +// variable->gap_danger_low.latch = ui->checkBox_danger_low_latch_2->isChecked(); +// variable->gap_alert_low.level = ui->lineEdit_alert_low_level_2->text().toDouble(); +// variable->gap_alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis_2->text().toDouble(); +// variable->gap_alert_low.delay = ui->lineEdit_alert_low_delay_2->text().toDouble(); +// variable->gap_alert_low.enable = ui->checkBox_alert_low_enable_2->isChecked(); +// variable->gap_alert_low.latch = ui->checkBox_alert_low_latch_2->isChecked(); this->close(); } @@ -205,3 +309,11 @@ void Radial::on_pushButton_confirm_clicked() { void Radial::on_pushButton_set_default_clicked() { } + +void Radial::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()); + } +} + diff --git a/radial_vibration.h b/radial_vibration.h index 2a94031..37b0f8a 100644 --- a/radial_vibration.h +++ b/radial_vibration.h @@ -22,7 +22,9 @@ class Radial : public QWidget { void on_checkBox_1x_ampl_toggled(bool checked); void on_checkBox_2x_ampl_toggled(bool checked); - private: + void on_lineEdit_alert_high_level_editingFinished(); + +private: Ui::Radial_vibration *ui; void Init(); diff --git a/radial_vibration.ui b/radial_vibration.ui index ce15039..54d8bc4 100644 --- a/radial_vibration.ui +++ b/radial_vibration.ui @@ -23,11 +23,11 @@ - 1 + 2 - 传感器和滤波配置 + 滤波 @@ -275,657 +275,8 @@ - 特征值和警报配置 + 测量 - - - - 20 - 10 - 411 - 411 - - - - 特征值 - - - - - 20 - 50 - 54 - 12 - - - - 直接值 - - - - - - 20 - 80 - 81 - 16 - - - - 间隙 - - - - - - 20 - 110 - 81 - 16 - - - - 1倍频幅值 - - - - - - 20 - 180 - 81 - 16 - - - - 2倍频幅值 - - - - - - 141 - 31 - 48 - 16 - - - - 取值范围 - - - - - - 260 - 31 - 61 - 16 - - - - 默认值 - - - - - - 130 - 50 - 111 - 22 - - - - 4 - - - - 0-100 um - - - - - 0-150 um - - - - - 0-200 um - - - - - 0-400 um - - - - - 0-500 um - - - - - 自定义 - - - - - - - 260 - 50 - 62 - 22 - - - - 0 - - - 1000.000000000000000 - - - - - - 260 - 80 - 62 - 22 - - - - 1 - - - - - false - - - - 130 - 110 - 111 - 22 - - - - 4 - - - - 0-100 um - - - - - 0-150 um - - - - - 0-200 um - - - - - 0-400 um - - - - - 0-500 um - - - - - 自定义 - - - - - - false - - - - 260 - 110 - 62 - 22 - - - - 0 - - - 1000.000000000000000 - - - - - - 20 - 150 - 91 - 16 - - - - 1倍频相位 - - - - - - 20 - 210 - 91 - 16 - - - - 2倍频相位 - - - - - false - - - - 260 - 150 - 62 - 22 - - - - 0 - - - 360.000000000000000 - - - - - false - - - - 260 - 180 - 62 - 22 - - - - 0 - - - - - false - - - - 260 - 210 - 62 - 22 - - - - 0 - - - 360.000000000000000 - - - - - false - - - - 130 - 180 - 111 - 22 - - - - 4 - - - - 0-100 um - - - - - 0-150 um - - - - - 0-200 um - - - - - 0-400 um - - - - - 0-500 um - - - - - 自定义 - - - - - - - 130 - 80 - 111 - 22 - - - - 0 - - - - -24 Vdc - - - - - 0-100 um - - - - - 0-150 um - - - - - 0-200 um - - - - - 0-400 um - - - - - 0-500 um - - - - - 自定义 - - - - - - - 10 - 300 - 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 - 220 - 121 - 16 - - - - 倍增 - - - - - - 460 - 240 - 62 - 16 - - - - 1.000000000000000 - - - - - - 460 - 260 - 141 - 16 - - - - 1.00 - 3.00 (步进0.25) - - - - - - 460 - 130 - 54 - 12 - - - - 记录输出 - - - - - - 460 - 150 - 141 - 22 - - - - - - - - - - 直接幅值 - - - - - 1倍频幅值 - - - - - 2倍频幅值 - - - - - - - 460 - 180 - 91 - 16 - - - - 2 mA 默认值 - - - true - - - - - - 460 - 290 - 121 - 16 - - - - 比较 - - @@ -939,51 +290,1153 @@ % - - - false - + - 460 - 310 - 141 - 22 + 20 + 50 + 621 + 321 - - - - - - - - 直接幅值 - - - - - 1倍频幅值 - - - - - 2倍频幅值 - - + + 0 + + + + 常规 + + + + + 210 + 150 + 54 + 12 + + + + 整流器 + + + + + + 210 + 50 + 54 + 12 + + + + 输出使用 + + + + + + 210 + 100 + 54 + 12 + + + + 工程单位 + + + + + + 10 + 40 + 150 + 25 + + + + + 150 + 25 + + + + + 150 + 25 + + + + + + + + + + + + + + + + + 10 + 90 + 150 + 25 + + + + + 150 + 25 + + + + + 150 + 25 + + + + + g + + + + + m/s**2 + + + + + mm/s + + + + + inch/s + + + + + um + + + + + mm + + + + + mils + + + + + inch/s**2 + + + + + + + 10 + 140 + 150 + 25 + + + + + 150 + 25 + + + + + 150 + 25 + + + + + True Peak + + + + + True Peak-To-Peak + + + + + RMS Scaled Peak + + + + + RMS Scaled Peak-To-Peak + + + + + AVG + + + + + RMS Scaled AVG + + + + + RMS + + + + + + + 警报 + + + + + 10 + 60 + 71 + 16 + + + + 危险 + 高 + + + + + + 10 + 100 + 71 + 16 + + + + 警报 + 高 + + + + + + 10 + 140 + 71 + 16 + + + + 警报 + 低 + + + + + + 10 + 180 + 71 + 16 + + + + 危险 + 低 + + + + + + 90 + 30 + 41 + 31 + + + + 等级 + + + + + + 160 + 30 + 41 + 31 + + + + 回差 + + + + + + 230 + 30 + 41 + 31 + + + + 延时 + + + + + + 280 + 40 + 51 + 16 + + + + 使能 + + + + + + 340 + 40 + 41 + 16 + + + + 锁存 + + + + + + 80 + 60 + 51 + 20 + + + + + + + 150 + 60 + 51 + 20 + + + + + + + 220 + 60 + 51 + 20 + + + + + + + 220 + 100 + 51 + 20 + + + + + + + 80 + 100 + 51 + 20 + + + + + + + 150 + 100 + 51 + 20 + + + + + + false + + + + 220 + 140 + 51 + 20 + + + + + + false + + + + 150 + 180 + 51 + 20 + + + + + + false + + + + 80 + 140 + 51 + 20 + + + + + + false + + + + 220 + 180 + 51 + 20 + + + + + + false + + + + 80 + 180 + 51 + 20 + + + + + + false + + + + 150 + 140 + 51 + 20 + + + + + + + 290 + 60 + 16 + 16 + + + + + + + + + + 290 + 100 + 16 + 16 + + + + + + + + + false + + + + 290 + 140 + 16 + 16 + + + + + + + + + false + + + + 290 + 180 + 16 + 16 + + + + + + + + + + 350 + 100 + 16 + 16 + + + + + + + + + false + + + + 350 + 180 + 16 + 16 + + + + + + + + + + 350 + 60 + 16 + 16 + + + + + + + + + false + + + + 350 + 140 + 16 + 16 + + + + + + + - - - false - + + + + 间隙 + + - 460 - 350 - 61 - 22 + 20 + 40 + 621 + 321 + + 0 + + + + 常规 + + + + + 210 + 150 + 91 + 16 + + + + 整流器 + + + + + + 210 + 50 + 71 + 16 + + + + 输出使用 + + + + + + 210 + 100 + 91 + 16 + + + + 工程单位 + + + + + + 10 + 40 + 150 + 25 + + + + + 150 + 25 + + + + + 150 + 25 + + + + + + + + + + + + + + + + + 10 + 90 + 150 + 25 + + + + + 150 + 25 + + + + + 150 + 25 + + + + + g + + + + + m/s**2 + + + + + mm/s + + + + + inch/s + + + + + um + + + + + mm + + + + + mils + + + + + inch/s**2 + + + + + + + + + + + + 10 + 140 + 150 + 25 + + + + + 150 + 25 + + + + + 150 + 25 + + + + + AVG + + + + + + + 警报 + + + + + 10 + 60 + 71 + 16 + + + + 危险 + 高 + + + + + + 10 + 100 + 71 + 16 + + + + 警报 + 高 + + + + + + 10 + 140 + 71 + 16 + + + + 警报 + 低 + + + + + + 10 + 180 + 71 + 16 + + + + 危险 + 低 + + + + + + 90 + 30 + 41 + 31 + + + + 等级 + + + + + + 160 + 30 + 41 + 31 + + + + 回差 + + + + + + 230 + 30 + 41 + 31 + + + + 延时 + + + + + + 280 + 40 + 51 + 16 + + + + 使能 + + + + + + 340 + 40 + 51 + 16 + + + + 锁存 + + + + + + 80 + 60 + 51 + 20 + + + + + + + 150 + 60 + 51 + 20 + + + + + + + 220 + 60 + 51 + 20 + + + + + + + 220 + 100 + 51 + 20 + + + + + + + 80 + 100 + 51 + 20 + + + + + + + 150 + 100 + 51 + 20 + + + + + + false + + + + 220 + 140 + 51 + 20 + + + + + + false + + + + 150 + 180 + 51 + 20 + + + + + + false + + + + 80 + 140 + 51 + 20 + + + + + + false + + + + 220 + 180 + 51 + 20 + + + + + + false + + + + 80 + 180 + 51 + 20 + + + + + + false + + + + 150 + 140 + 51 + 20 + + + + + + + 290 + 60 + 16 + 16 + + + + + + + + + + 290 + 100 + 16 + 16 + + + + + + + + + false + + + + 290 + 140 + 16 + 16 + + + + + + + + + false + + + + 290 + 180 + 16 + 16 + + + + + + + + + + 350 + 100 + 16 + 16 + + + + + + + + + false + + + + 350 + 180 + 16 + 16 + + + + + + + + + + 350 + 60 + 16 + 16 + + + + + + + + + false + + + + 350 + 140 + 16 + 16 + + + + + + + @@ -992,7 +1445,7 @@ 21 10 - 105 + 141 17 diff --git a/seismic_monitor.cpp b/seismic_monitor.cpp index 68302e8..92e657a 100644 --- a/seismic_monitor.cpp +++ b/seismic_monitor.cpp @@ -25,18 +25,13 @@ Seismic_monitor::Seismic_monitor(int slot,int cardtype, QWidget *parent) : ui->comboBox_chan_type_2->setView(new QListView()); ui->comboBox_chan_type_3->setView(new QListView()); ui->comboBox_chan_type_4->setView(new QListView()); - ui->comboBox_transducer_name_1->setView(new QListView()); - ui->comboBox_transducer_name_2->setView(new QListView()); - ui->comboBox_transducer_name_3->setView(new QListView()); - ui->comboBox_transducer_name_4->setView(new QListView()); - ui->comboBox_sample_rate_1->setView(new QListView()); - ui->comboBox_sample_rate_2->setView(new QListView()); - ui->comboBox_sample_rate_3->setView(new QListView()); - ui->comboBox_sample_rate_4->setView(new QListView()); + slot_no = slot; car_type = static_cast(cardtype); QString slot_no_ = QString("%1").arg(slot_no); ui->label_slot_no->setText(slot_no_); + ui->checkBox_standby_1->hide(); + ui->checkBox_standby_2->hide(); Init(); } @@ -69,41 +64,57 @@ void Seismic_monitor::Init() { qDebug() << vib_data->base_config_[i].channel_type ; ui->comboBox_chan_type_1->setCurrentIndex(vib_data->base_config_[i].channel_type); ui->checkBox_standby_1->setChecked(vib_data->base_config_[i].standby); - ui->comboBox_transducer_name_1->setCurrentIndex(vib_data->base_config_[i].transducer_id); - ui->doubleSpinBox_scale_factor_1->setValue(vib_data->base_config_[i].scale_factor); + ui->comboBox_sensitivity_unit_1->setCurrentIndex(vib_data->base_config_[i].sensitivity_unit); + ui->lineEdit_signal_sensitivity_1->setText(QString::number(vib_data->base_config_[i].signal_sensitivity)); + ui->checkBox_enable_1->setChecked(vib_data->base_config_[i].active); ui->doubleSpinBox_low_1->setValue(vib_data->base_config_[i].normal_voltage_low); ui->doubleSpinBox_high_1->setValue(vib_data->base_config_[i].normal_voltage_high); - ui->comboBox_sample_rate_1->setCurrentIndex(vib_data->base_config_[i].sampling_rate); - ui->checkBox_power_1->setChecked(vib_data->base_config_[i].power); + + ui->checkBox_keyphase->setChecked(vib_data->base_config_[i].keyphase); + ui->comboBox_keyphase_ch->setCurrentText(QString::number(vib_data->base_config_[i].keyphase_ch)); + ui->comboBox_keyphase_slot->setCurrentText(QString::number(vib_data->base_config_[i].keyphase_slot)); + } else if (i + 1 == 2) { ui->comboBox_chan_type_2->setCurrentIndex(vib_data->base_config_[i].channel_type); - ui->comboBox_transducer_name_2->setCurrentIndex(vib_data->base_config_[i].transducer_id); - ui->doubleSpinBox_scale_factor_2->setValue(vib_data->base_config_[i].scale_factor); + ui->comboBox_sensitivity_unit_2->setCurrentIndex(vib_data->base_config_[i].sensitivity_unit); + ui->lineEdit_signal_sensitivity_2->setText(QString::number(vib_data->base_config_[i].signal_sensitivity)); + ui->checkBox_enable_2->setChecked(vib_data->base_config_[i].active); ui->doubleSpinBox_low_2->setValue(vib_data->base_config_[i].normal_voltage_low); ui->doubleSpinBox_high_2->setValue(vib_data->base_config_[i].normal_voltage_high); - ui->comboBox_sample_rate_2->setCurrentIndex(vib_data->base_config_[i].sampling_rate); - ui->checkBox_power_2->setChecked(vib_data->base_config_[i].power); + + ui->checkBox_keyphase_2->setChecked(vib_data->base_config_[i].keyphase); + ui->comboBox_keyphase_ch_2->setCurrentText(QString::number(vib_data->base_config_[i].keyphase_ch)); + ui->comboBox_keyphase_slot_2->setCurrentText(QString::number(vib_data->base_config_[i].keyphase_slot)); + } else if (i + 1 == 3) { ui->checkBox_standby_2->setChecked(vib_data->base_config_[i].standby); ui->comboBox_chan_type_3->setCurrentIndex(vib_data->base_config_[i].channel_type); - ui->comboBox_transducer_name_3->setCurrentIndex(vib_data->base_config_[i].transducer_id); - ui->doubleSpinBox_scale_factor_3->setValue(vib_data->base_config_[i].scale_factor); + ui->comboBox_sensitivity_unit_3->setCurrentIndex(vib_data->base_config_[i].sensitivity_unit); + ui->lineEdit_signal_sensitivity_3->setText(QString::number(vib_data->base_config_[i].signal_sensitivity)); + + ui->checkBox_keyphase_3->setChecked(vib_data->base_config_[i].keyphase); + ui->comboBox_keyphase_ch_3->setCurrentText(QString::number(vib_data->base_config_[i].keyphase_ch)); + ui->comboBox_keyphase_slot_3->setCurrentText(QString::number(vib_data->base_config_[i].keyphase_slot)); + ui->checkBox_enable_3->setChecked(vib_data->base_config_[i].active); ui->doubleSpinBox_low_3->setValue(vib_data->base_config_[i].normal_voltage_low); ui->doubleSpinBox_high_3->setValue(vib_data->base_config_[i].normal_voltage_high); - ui->comboBox_sample_rate_3->setCurrentIndex(vib_data->base_config_[i].sampling_rate); - ui->checkBox_power_3->setChecked(vib_data->base_config_[i].power); + } else if (i + 1 == 4) { ui->comboBox_chan_type_4->setCurrentIndex(vib_data->base_config_[i].channel_type); - ui->comboBox_transducer_name_4->setCurrentIndex(vib_data->base_config_[i].transducer_id); - ui->doubleSpinBox_scale_factor_4->setValue(vib_data->base_config_[i].scale_factor); + ui->comboBox_sensitivity_unit_4->setCurrentIndex(vib_data->base_config_[i].sensitivity_unit); + ui->lineEdit_signal_sensitivity_4->setText(QString::number(vib_data->base_config_[i].signal_sensitivity)); + + ui->checkBox_keyphase_4->setChecked(vib_data->base_config_[i].keyphase); + ui->comboBox_keyphase_ch_4->setCurrentText(QString::number(vib_data->base_config_[i].keyphase_ch)); + ui->comboBox_keyphase_slot_4->setCurrentText(QString::number(vib_data->base_config_[i].keyphase_slot)); + ui->checkBox_enable_4->setChecked(vib_data->base_config_[i].active); ui->doubleSpinBox_low_4->setValue(vib_data->base_config_[i].normal_voltage_low); ui->doubleSpinBox_high_4->setValue(vib_data->base_config_[i].normal_voltage_high); - ui->comboBox_sample_rate_4->setCurrentIndex(vib_data->base_config_[i].sampling_rate); - ui->checkBox_power_4->setChecked(vib_data->base_config_[i].power); + } } } @@ -115,12 +126,11 @@ void Seismic_monitor::UpdateData(std::shared_ptr vib_data) { vib_data->base_config_[var].active = ui->checkBox_enable_1->isChecked(); vib_data->base_config_[var].rack_type = 0; vib_data->base_config_[var].channel_type = ui->comboBox_chan_type_1->currentIndex(); - vib_data->base_config_[var].transducer_id = ui->comboBox_transducer_name_1->currentIndex(); - vib_data->base_config_[var].scale_factor = ui->doubleSpinBox_scale_factor_1->value(); - vib_data->base_config_[var].sampling_rate = ui->comboBox_sample_rate_1->currentIndex(); + vib_data->base_config_[var].sensitivity_unit = ui->comboBox_sensitivity_unit_1->currentIndex(); + vib_data->base_config_[var].signal_sensitivity = ui->lineEdit_signal_sensitivity_1->text().toFloat(); + vib_data->base_config_[var].normal_voltage_low = ui->doubleSpinBox_low_1->value(); vib_data->base_config_[var].normal_voltage_high = ui->doubleSpinBox_high_1->value(); - vib_data->base_config_[var].power = ui->checkBox_power_1->isChecked(); vib_data->base_config_[var].chan_id = QString("S%1C%2").arg(QString::number(slot_no, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); vib_data->base_config_[var].keyphase = ui->checkBox_keyphase->isChecked(); vib_data->base_config_[var].keyphase_slot = ui->comboBox_keyphase_slot->currentText().toInt(); @@ -130,12 +140,11 @@ void Seismic_monitor::UpdateData(std::shared_ptr vib_data) { vib_data->base_config_[var].active = ui->checkBox_enable_2->isChecked(); vib_data->base_config_[var].rack_type = 0; vib_data->base_config_[var].channel_type = ui->comboBox_chan_type_2->currentIndex(); - vib_data->base_config_[var].transducer_id = ui->comboBox_transducer_name_2->currentIndex(); - vib_data->base_config_[var].scale_factor = ui->doubleSpinBox_scale_factor_2->value(); - vib_data->base_config_[var].sampling_rate = ui->comboBox_sample_rate_2->currentIndex(); + vib_data->base_config_[var].sensitivity_unit = ui->comboBox_sensitivity_unit_2->currentIndex(); + vib_data->base_config_[var].signal_sensitivity = ui->lineEdit_signal_sensitivity_2->text().toFloat(); vib_data->base_config_[var].normal_voltage_low = ui->doubleSpinBox_low_2->value(); vib_data->base_config_[var].normal_voltage_high = ui->doubleSpinBox_high_2->value(); - vib_data->base_config_[var].power = ui->checkBox_power_2->isChecked(); + vib_data->base_config_[var].chan_id = QString("S%1C%2").arg(QString::number(slot_no, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); vib_data->base_config_[var].keyphase = ui->checkBox_keyphase_2->isChecked(); vib_data->base_config_[var].keyphase_slot = ui->comboBox_keyphase_slot_2->currentText().toInt(); @@ -145,12 +154,12 @@ void Seismic_monitor::UpdateData(std::shared_ptr vib_data) { vib_data->base_config_[var].active = ui->checkBox_enable_3->isChecked(); vib_data->base_config_[var].rack_type = 0; vib_data->base_config_[var].channel_type = ui->comboBox_chan_type_3->currentIndex(); - vib_data->base_config_[var].transducer_id = ui->comboBox_transducer_name_3->currentIndex(); - vib_data->base_config_[var].scale_factor = ui->doubleSpinBox_scale_factor_3->value(); - vib_data->base_config_[var].sampling_rate = ui->comboBox_sample_rate_3->currentIndex(); + vib_data->base_config_[var].sensitivity_unit = ui->comboBox_sensitivity_unit_3->currentIndex(); + vib_data->base_config_[var].signal_sensitivity = ui->lineEdit_signal_sensitivity_3->text().toFloat(); + vib_data->base_config_[var].normal_voltage_low = ui->doubleSpinBox_low_3->value(); vib_data->base_config_[var].normal_voltage_high = ui->doubleSpinBox_high_3->value(); - vib_data->base_config_[var].power = ui->checkBox_power_3->isChecked(); + vib_data->base_config_[var].chan_id = QString("S%1C%2").arg(QString::number(slot_no, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); vib_data->base_config_[var].keyphase = ui->checkBox_keyphase_3->isChecked(); vib_data->base_config_[var].keyphase_slot = ui->comboBox_keyphase_slot_3->currentText().toInt(); @@ -160,12 +169,10 @@ void Seismic_monitor::UpdateData(std::shared_ptr vib_data) { vib_data->base_config_[var].active = ui->checkBox_enable_4->isChecked(); vib_data->base_config_[var].rack_type = 0; vib_data->base_config_[var].channel_type = ui->comboBox_chan_type_4->currentIndex(); - vib_data->base_config_[var].transducer_id = ui->comboBox_transducer_name_4->currentIndex(); - vib_data->base_config_[var].scale_factor = ui->doubleSpinBox_scale_factor_4->value(); - vib_data->base_config_[var].sampling_rate = ui->comboBox_sample_rate_4->currentIndex(); + vib_data->base_config_[var].sensitivity_unit = ui->comboBox_sensitivity_unit_4->currentIndex(); + vib_data->base_config_[var].signal_sensitivity = ui->lineEdit_signal_sensitivity_4->text().toFloat(); vib_data->base_config_[var].normal_voltage_low = ui->doubleSpinBox_low_4->value(); vib_data->base_config_[var].normal_voltage_high = ui->doubleSpinBox_high_4->value(); - vib_data->base_config_[var].power = ui->checkBox_power_4->isChecked(); vib_data->base_config_[var].chan_id = QString("S%1C%2").arg(QString::number(slot_no, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); vib_data->base_config_[var].keyphase = ui->checkBox_keyphase_4->isChecked(); vib_data->base_config_[var].keyphase_slot = ui->comboBox_keyphase_slot_4->currentText().toInt(); @@ -183,24 +190,29 @@ void Seismic_monitor::on_pushButton_confirm_clicked() { // UpdateData(vib_data); return; } - - if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot->currentText().toInt()] != kCardKeyphaseSingle && ui->checkBox_keyphase->isChecked()) { + if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot->currentIndex()] != kCardKeyphaseSingle && ui->checkBox_keyphase->isChecked()) { QMessageBox::information(this, QStringLiteral("提示"), "第一通道键相槽位选择错误!"); return; } - if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot_2->currentText().toInt()] != kCardKeyphaseSingle && ui->checkBox_keyphase_2->isChecked()) { + if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot_2->currentIndex()] != kCardKeyphaseSingle && ui->checkBox_keyphase_2->isChecked()) { QMessageBox::information(this, QStringLiteral("提示"), "第二通道键相槽位选择错误!"); return; } - if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot_3->currentText().toInt()] != kCardKeyphaseSingle && ui->checkBox_keyphase_3->isChecked()) { + if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot_3->currentIndex()] != kCardKeyphaseSingle && ui->checkBox_keyphase_3->isChecked()) { QMessageBox::information(this, QStringLiteral("提示"), "第三通道键相槽位选择错误!"); return; } - if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot_4->currentText().toInt()] != kCardKeyphaseSingle && ui->checkBox_keyphase_4->isChecked()) { + if (ConfigMgr::Instance()->card_type_[ui->comboBox_keyphase_slot_4->currentIndex()] != kCardKeyphaseSingle && ui->checkBox_keyphase_4->isChecked()) { QMessageBox::information(this, QStringLiteral("提示"), "第四通道键相槽位选择错误!"); return; } - + if(ui->lineEdit_signal_sensitivity_1->text() == "0" || + ui->lineEdit_signal_sensitivity_2->text() == "0" || + ui->lineEdit_signal_sensitivity_3->text() == "0" || + ui->lineEdit_signal_sensitivity_4->text() == "0"){ + QMessageBox::information(this, QStringLiteral("提示"), "传感器灵敏度填写错误!"); + return; + } std::shared_ptr vib_data = std::dynamic_pointer_cast(base_ptr); UpdateData(vib_data); @@ -313,19 +325,19 @@ void Seismic_monitor::on_pushButton_config_4_clicked() { void Seismic_monitor::on_comboBox_chan_type_1_currentTextChanged(const QString &arg1) { switch (ui->comboBox_chan_type_1->currentIndex()) { case kVibRadial: - ui->label_unit_1->setText("mV / mm"); + EnableKeyphase(); break; case kVibAcc: - ui->label_unit_1->setText("mV / m/s^2"); + EnableKeyphase(); break; case kVibVelocity: - ui->label_unit_1->setText("mV / mm/s"); + EnableKeyphase(); break; case kVibThrust: - ui->label_unit_1->setText("mV / mil"); + DisableKeyphase(); break; case kVibPressurePulsation: @@ -337,19 +349,15 @@ void Seismic_monitor::on_comboBox_chan_type_1_currentTextChanged(const QString & void Seismic_monitor::on_comboBox_chan_type_2_currentTextChanged(const QString &arg1) { switch (ui->comboBox_chan_type_2->currentIndex()) { case kVibRadial: - ui->label_unit_2->setText("mV / mm"); EnableKeyphase(); break; case kVibAcc: - ui->label_unit_2->setText("mV / m/s^2"); EnableKeyphase2(); break; case kVibVelocity: - ui->label_unit_2->setText("mV / mm/s"); EnableKeyphase2(); break; case kVibThrust: - ui->label_unit_2->setText("mV / mil"); DisableKeyphase2(); break; case kVibPressurePulsation: @@ -361,19 +369,15 @@ void Seismic_monitor::on_comboBox_chan_type_2_currentTextChanged(const QString & void Seismic_monitor::on_comboBox_chan_type_3_currentTextChanged(const QString &arg1) { switch (ui->comboBox_chan_type_3->currentIndex()) { case kVibRadial: - ui->label_unit_3->setText("mV / mm"); EnableKeyphase(); break; case kVibAcc: - ui->label_unit_3->setText("mV / m/s^2"); EnableKeyphase3(); break; case kVibVelocity: - ui->label_unit_3->setText("mV / mm/s"); EnableKeyphase3(); break; case kVibThrust: - ui->label_unit_3->setText("mV / mil"); DisableKeyphase3(); break; case kVibPressurePulsation: @@ -385,19 +389,15 @@ void Seismic_monitor::on_comboBox_chan_type_3_currentTextChanged(const QString & void Seismic_monitor::on_comboBox_chan_type_4_currentTextChanged(const QString &arg1) { switch (ui->comboBox_chan_type_4->currentIndex()) { case kVibRadial: - ui->label_unit_4->setText("mV / mm"); EnableKeyphase4(); break; case kVibAcc: - ui->label_unit_4->setText("mV / m/s^2"); EnableKeyphase4(); break; case kVibVelocity: - ui->label_unit_4->setText("mV / mm/s"); EnableKeyphase4(); break; case kVibThrust: - ui->label_unit_4->setText("mV / mil"); DisableKeyphase4(); break; case kVibPressurePulsation: @@ -411,35 +411,19 @@ void Seismic_monitor::on_pushButton_cancel_clicked() { } void Seismic_monitor::on_comboBox_transducer_name_1_currentTextChanged(const QString &arg1) { - for (int var = 0; var < vec_transducer.size(); ++var) { - if (ui->comboBox_transducer_name_1->currentText() == vec_transducer[var].transducer_name) { - ui->doubleSpinBox_scale_factor_1->setValue(vec_transducer[var].scale_factor); - } - } + } void Seismic_monitor::on_comboBox_transducer_name_2_currentTextChanged(const QString &arg1) { - for (int var = 0; var < vec_transducer.size(); ++var) { - if (ui->comboBox_transducer_name_2->currentText() == vec_transducer[var].transducer_name) { - ui->doubleSpinBox_scale_factor_2->setValue(vec_transducer[var].scale_factor); - } - } + } void Seismic_monitor::on_comboBox_transducer_name_3_currentTextChanged(const QString &arg1) { - for (int var = 0; var < vec_transducer.size(); ++var) { - if (ui->comboBox_transducer_name_3->currentText() == vec_transducer[var].transducer_name) { - ui->doubleSpinBox_scale_factor_3->setValue(vec_transducer[var].scale_factor); - } - } + } void Seismic_monitor::on_comboBox_transducer_name_4_currentTextChanged(const QString &arg1) { - for (int var = 0; var < vec_transducer.size(); ++var) { - if (ui->comboBox_transducer_name_4->currentText() == vec_transducer[var].transducer_name) { - ui->doubleSpinBox_scale_factor_4->setValue(vec_transducer[var].scale_factor); - } - } + } void Seismic_monitor::EnableKeyphase(){ ui->checkBox_keyphase->setCheckable(true); @@ -490,3 +474,31 @@ void Seismic_monitor::DisableKeyphase4(){ ui->comboBox_keyphase_ch_4->setEnabled(false); ui->comboBox_keyphase_slot_4->setEnabled(false); } + +void Seismic_monitor::on_comboBox_sensitivity_unit_1_currentTextChanged(const QString &arg1) +{ + QString str = QString("信号灵敏度(mV/%1)").arg(arg1); + ui->label_signal_sensitivity_1->setText(str); +} + + +void Seismic_monitor::on_comboBox_sensitivity_unit_2_currentTextChanged(const QString &arg1) +{ + QString str = QString("信号灵敏度(mV/%1)").arg(arg1); + ui->label_signal_sensitivity_2->setText(str); +} + + +void Seismic_monitor::on_comboBox_sensitivity_unit_3_currentTextChanged(const QString &arg1) +{ + QString str = QString("信号灵敏度(mV/%1)").arg(arg1); + ui->label_signal_sensitivity_3->setText(str); +} + + +void Seismic_monitor::on_comboBox_sensitivity_unit_4_currentTextChanged(const QString &arg1) +{ + QString str = QString("信号灵敏度(mV/%1)").arg(arg1); + ui->label_signal_sensitivity_4->setText(str); +} + diff --git a/seismic_monitor.h b/seismic_monitor.h index b18441d..2953526 100644 --- a/seismic_monitor.h +++ b/seismic_monitor.h @@ -49,7 +49,15 @@ class Seismic_monitor : public QWidget { void on_comboBox_transducer_name_4_currentTextChanged(const QString &arg1); - private: + void on_comboBox_sensitivity_unit_1_currentTextChanged(const QString &arg1); + + void on_comboBox_sensitivity_unit_2_currentTextChanged(const QString &arg1); + + void on_comboBox_sensitivity_unit_3_currentTextChanged(const QString &arg1); + + void on_comboBox_sensitivity_unit_4_currentTextChanged(const QString &arg1); + +private: Ui::Seismic_monitor *ui; void UpdateData(std::shared_ptr vib_data); int card_type; diff --git a/seismic_monitor.ui b/seismic_monitor.ui index c67cddc..5ed3f4c 100644 --- a/seismic_monitor.ui +++ b/seismic_monitor.ui @@ -7,7 +7,7 @@ 0 0 862 - 580 + 601 @@ -178,7 +178,7 @@ - 420 + 430 203 52 75 @@ -280,7 +280,7 @@ - 200 + 220 380 120 81 @@ -324,8 +324,8 @@ 10 50 - 333 - 328 + 341 + 321 @@ -347,296 +347,298 @@ 通道1 - + - + - + + + + 120 + 0 + + + + + 120 + 16777215 + + - - - - 90 - 0 - - - - 类 型: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + 轴振传感器 + - - - - 120 - 0 - - - - - 120 - 16777215 - - - - - 径向位移 - - - - - 加速度 - - - - - 速度 - - - - - 轴向位移 - - - - - 动态压力脉动 - - - + + 加速度传感器 + - - - Qt::Horizontal - - - - 40 - 20 - - - + + 速度传感器 + - + + + 轴位移传感器 + + + + + 压力脉动传感器 + + + + + DC传感器 + + + - + + + + 90 + 0 + + + + 传感器类型 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + - - - - 90 - 0 - - - - 传感器名称: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + g + - - - - 120 - 0 - - - - - 120 - 16777215 - - - - xxx - - - - xxx - - - - - yyy - - - + + m/s^2 + - - - Qt::Horizontal - - - - 20 - 20 - - - + + mm/s + - + + + um + + + + + mm + + + + + mbar + + + + + bar + + + - - - - - - 90 - 0 - - - - 灵敏度: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 10000.000000000000000 - - - 8.000000000000000 - - - - - - - v/mm - - - - + + + + 90 + 0 + + + + 传感器灵敏度单位 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + + + 8 + + - + + + + 90 + 0 + + + + 信号灵敏度(mV/um) + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + - - - - 90 - 0 - - - - 采样率: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + + - - - - 120 - 0 - - - - - 120 - 16777215 - - - - 1 - - - - 16 k - - - - - 32 k - - - - - 64 k - - - - - 128 k - - - + + + - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + - - - - - Qt::Horizontal - - - - 90 - 20 - - - - - - - - Qt::LeftToRight - - - 是否供电 - - - false - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + + + + 90 + 0 + + + + 传感器IEPE供电 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + + + 1 + + + -100.000000000000000 + + + 20.000000000000000 + + + + + + + 电压上限(V) + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + + + 1 + + + -100.000000000000000 + + + -20.000000000000000 + + + + + + + 电压下限(V) + + @@ -777,418 +779,304 @@ - - - - - 220 - 80 - - - - 电压范围 - - - - - - - - - 80 - 0 - - - - 上限: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 120 - 0 - - - - - 120 - 16777215 - - - - 1 - - - -100.000000000000000 - - - 25.000000000000000 - - - - - - - V - - - - - - - - - - - - 80 - 0 - - - - 下限: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 120 - 0 - - - - - 120 - 16777215 - - - - 1 - - - -100.000000000000000 - - - -25.000000000000000 - - - - - - - V - - - - - - - - 通道2 - + - + - + + + + 120 + 0 + + + + + 120 + 16777215 + + - - - - 90 - 0 - - - - 类 型: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + 轴振传感器 + - - - - 120 - 0 - - - - - 120 - 16777215 - - - - - 径向位移 - - - - - 加速度 - - - - - 速度 - - - - - 轴向位移 - - - - - 动态压力脉动 - - - + + 加速度传感器 + - - - Qt::Horizontal - - - - 40 - 20 - - - + + 速度传感器 + - + + + 轴位移传感器 + + + + + 压力脉动传感器 + + + + + DC传感器 + + + - + + + + 90 + 0 + + + + 传感器类型 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + - - - - 90 - 0 - - - - 传感器名称: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + g + - - - - 120 - 0 - - - - - 120 - 16777215 - - - - - xxx - - - - - yyy - - - + + m/s^2 + - - - Qt::Horizontal - - - - 20 - 20 - - - + + mm/s + - + + + um + + + + + mm + + + + + mbar + + + + + bar + + + - - - - - - 90 - 0 - - - - 灵敏度: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 10000.000000000000000 - - - 8.000000000000000 - - - - - - - v/mm - - - - + + + + 90 + 0 + + + + 传感器灵敏度单位 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + + + 8 + + - + + + + 90 + 0 + + + + 信号灵敏度(mV/um) + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + - - - - 90 - 0 - - - - 采样率: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + + - - - - 120 - 0 - - - - - 120 - 16777215 - - - - 1 - - - - 16 k - - - - - 32 k - - - - - 64 k - - - - - 128 k - - - + + + - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + - - - - - Qt::Horizontal - - - - 90 - 20 - - - - - - - - Qt::LeftToRight - - - 是否供电 - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + + + + 90 + 0 + + + + 传感器IEPE供电 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + + + 1 + + + -100.000000000000000 + + + 20.000000000000000 + + + + + + + 电压上限(V) + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + + + 1 + + + -100.000000000000000 + + + -20.000000000000000 + + + + + + + 电压下限(V) + + @@ -1329,139 +1217,78 @@ - - - - - 220 - 80 - - - - 电压范围 - - - - - - - - - 80 - 0 - - - - - 80 - 16777215 - - - - 上限: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 120 - 0 - - - - - 120 - 16777215 - - - - 1 - - - -100.000000000000000 - - - 25.000000000000000 - - - - - - - V - - - - - - - - - - - - 80 - 0 - - - - - 80 - 16777215 - - - - 下限: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 120 - 0 - - - - - 120 - 16777215 - - - - 1 - - - -100.000000000000000 - - - -25.000000000000000 - - - - - - - V - - - - - - - - + + + 通道1-通道2 + + + + + 20 + 50 + 180 + 22 + + + + + 180 + 0 + + + + + 120 + 16777215 + + + + + No Processing + + + + + (SMAX) Smax + + + + + (DHE) Differential Housing Expansion + + + + + (RST) Relative Shaft Expansion (Shaft taper) + + + + + (RSC) Relative Shaft Expansion (Shaft collar) + + + + + (DMF) Dual Mathematical Function + + + + + + + 220 + 60 + 54 + 12 + + + + 函数 + + + @@ -1479,7 +1306,7 @@ - 140 + 150 390 52 75 @@ -1631,8 +1458,8 @@ 10 50 - 333 - 328 + 331 + 321 @@ -1654,290 +1481,298 @@ 通道3 - + - + - + + + + 120 + 0 + + + + + 120 + 16777215 + + - - - - 90 - 0 - - - - 类 型: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + 轴振传感器 + - - - - 120 - 0 - - - - - 120 - 16777215 - - - - - 径向位移 - - - - - 加速度 - - - - - 速度 - - - - - 轴向位移 - - - - - 动态压力脉动 - - - + + 加速度传感器 + - - - Qt::Horizontal - - - - 40 - 20 - - - + + 速度传感器 + - + + + 轴位移传感器 + + + + + 压力脉动传感器 + + + + + DC传感器 + + + - + + + + 90 + 0 + + + + 传感器类型 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + - - - - 90 - 0 - - - - 传感器名称: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + g + - - - - 120 - 0 - - - - - 120 - 16777215 - - - - - xxx - - - - - yyy - - - + + m/s^2 + - - - Qt::Horizontal - - - - 20 - 20 - - - + + mm/s + - + + + um + + + + + mm + + + + + mbar + + + + + bar + + + - - - - - - 90 - 0 - - - - 灵敏度: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 10000.000000000000000 - - - 8.000000000000000 - - - - - - - v/mm - - - - + + + + 90 + 0 + + + + 传感器灵敏度单位 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + + + 8 + + - + + + + 90 + 0 + + + + 信号灵敏度(mV/um) + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + - - - - 90 - 0 - - - - 采样率: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + + - - - - 120 - 0 - - - - - 120 - 16777215 - - - - 1 - - - - 16 k - - - - - 32 k - - - - - 64 k - - - - - 128 k - - - + + + - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + - - - - - Qt::Horizontal - - - - 90 - 20 - - - - - - - - Qt::LeftToRight - - - 是否供电 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + + + + 90 + 0 + + + + 传感器IEPE供电 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + + + 1 + + + -100.000000000000000 + + + 20.000000000000000 + + + + + + + 电压上限(V) + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + + + 1 + + + -100.000000000000000 + + + -20.000000000000000 + + + + + + + 电压下限(V) + + @@ -2078,415 +1913,304 @@ - - - - - 220 - 80 - - - - 电压范围 - - - - - - - - - 80 - 0 - - - - 上限: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 120 - 0 - - - - - 120 - 16777215 - - - - 1 - - - -100.000000000000000 - - - 25.000000000000000 - - - - - - - V - - - - - - - - - - - - 80 - 0 - - - - 下限: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 120 - 0 - - - - - 120 - 16777215 - - - - 1 - - - -100.000000000000000 - - - -25.000000000000000 - - - - - - - V - - - - - - - - 通道4 - + - + - + + + + 120 + 0 + + + + + 120 + 16777215 + + - - - - 90 - 0 - - - - 类 型: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + 轴振传感器 + - - - - 120 - 0 - - - - - 120 - 16777215 - - - - - 径向位移 - - - - - 加速度 - - - - - 速度 - - - - - 轴向位移 - - - - - 动态压力脉动 - - - + + 加速度传感器 + - - - Qt::Horizontal - - - - 40 - 20 - - - + + 速度传感器 + - + + + 轴位移传感器 + + + + + 压力脉动传感器 + + + + + DC传感器 + + + - + + + + 90 + 0 + + + + 传感器类型 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + - - - - 90 - 0 - - - - 传感器名称: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + g + - - - - 120 - 0 - - - - - 120 - 16777215 - - - - - xxx - - - - - yyy - - - + + m/s^2 + - - - Qt::Horizontal - - - - 20 - 20 - - - + + mm/s + - + + + um + + + + + mm + + + + + mbar + + + + + bar + + + - - - - - - 90 - 0 - - - - 灵敏度: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 10000.000000000000000 - - - 8.000000000000000 - - - - - - - v/mm - - - - + + + + 90 + 0 + + + + 传感器灵敏度单位 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + + + 8 + + - + + + + 90 + 0 + + + + 信号灵敏度(mV/um) + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + - - - - 90 - 0 - - - - 采样率: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + + - - - - 120 - 0 - - - - - 120 - 16777215 - - - - 1 - - - - 16 k - - - - - 32 k - - - - - 64 k - - - - - 128 k - - - + + + - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + - - - - - Qt::Horizontal - - - - 90 - 20 - - - - - - - - Qt::LeftToRight - - - 是否供电 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + + + + 90 + 0 + + + + 传感器IEPE供电 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + + + 1 + + + -100.000000000000000 + + + 20.000000000000000 + + + + + + + 电压上限(V) + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + + + 1 + + + -100.000000000000000 + + + -20.000000000000000 + + + + + + + 电压下限(V) + + @@ -2627,127 +2351,78 @@ - - - - - 220 - 80 - - - - 电压范围 - - - - - - - - - 80 - 0 - - - - 上限: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 120 - 0 - - - - - 120 - 16777215 - - - - 1 - - - -100.000000000000000 - - - 25.000000000000000 - - - - - - - V - - - - - - - - - - - - 80 - 0 - - - - 下限: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 120 - 0 - - - - - 120 - 16777215 - - - - 1 - - - -100.000000000000000 - - - -25.000000000000000 - - - - - - - V - - - - - - - - + + + 通道3-通道4 + + + + + 20 + 50 + 180 + 22 + + + + + 180 + 0 + + + + + 120 + 16777215 + + + + + No Processing + + + + + (SMAX) Smax + + + + + (DHE) Differential Housing Expansion + + + + + (RST) Relative Shaft Expansion (Shaft taper) + + + + + (RSC) Relative Shaft Expansion (Shaft collar) + + + + + (DMF) Dual Mathematical Function + + + + + + + 220 + 60 + 54 + 12 + + + + 函数 + + + diff --git a/setpoint.cpp b/setpoint.cpp deleted file mode 100644 index a9cdd04..0000000 --- a/setpoint.cpp +++ /dev/null @@ -1,482 +0,0 @@ -#include "setpoint.h" -#include "ui_setpoint.h" -#include "config_mgr.h" -#include -#include "displacement_ds.h" -#include "acceleration_ds.h" -#include "velocity_ds.h" -#include -#include - -Setpoint::Setpoint(int slot_no_,int cardtype,QWidget *parent) : - QWidget(parent), - ui(new Ui::Setpoint) -{ - ui->setupUi(this); - slot_no = slot_no_; - car_type = static_cast(cardtype); - ui->label_slot->setText(QString::number(slot_no)); - ui->comboBox_chan->setView(new QListView()); - ui->comboBox_danger->setView(new QListView()); - Init(); - connect(ui->comboBox_chan, QOverload::of(&QComboBox::currentIndexChanged), - this, &Setpoint::onComboBoxIndexChanged); - current_index = ui->comboBox_chan->currentIndex(); -} - -Setpoint::~Setpoint() -{ - if(slider_1st != nullptr) - delete slider_1st; - if(slider_2nd != nullptr) - delete slider_2nd; - if(slider_3rd != nullptr) - delete slider_3rd; - if(slider_danger != nullptr) - delete slider_danger; - delete ui; -} -void Setpoint::Init(){ - - QVBoxLayout *layout_direct = new QVBoxLayout(ui->widget_direct); - slider_1st = new RangeSlider; - layout_direct->addWidget(slider_1st); - - QVBoxLayout *layout_1x_ampl = new QVBoxLayout(ui->widget_1x_ampl); - slider_2nd = new RangeSlider; - layout_1x_ampl->addWidget(slider_2nd); - - QVBoxLayout *layout_2x_ampl = new QVBoxLayout(ui->widget_2x_ampl); - slider_3rd = new RangeSlider; - layout_2x_ampl->addWidget(slider_3rd); - - QVBoxLayout *layout_danger = new QVBoxLayout(ui->widget_danger); - slider_danger = new RangeSlider(1); - layout_danger->addWidget(slider_danger); - - std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); - - switch (car_type) { - case kCardVibSingle:{ - update(); - }break; - } - QObject::connect(ui->lineEdit_1st_upper, &QLineEdit::editingFinished, [&]() { - slider_1st->setUpperValue(ui->lineEdit_1st_upper->text().toFloat()); - }); - QObject::connect(slider_1st, &RangeSlider::rangeChanged, [&](float low,float high) { - ui->lineEdit_1st_upper->setText(QString::number(high)); - }); - - QObject::connect(slider_2nd, &RangeSlider::rangeChanged, [&](float low, float high) { - ui->lineEdit_2nd_upper->setText(QString::number(high)); - ui->lineEdit_2nd_lower->setText(QString::number(low)); - }); - QObject::connect(ui->lineEdit_2nd_upper, &QLineEdit::editingFinished, [&]() { - slider_2nd->setUpperValue(ui->lineEdit_2nd_upper->text().toFloat()); - }); - QObject::connect(ui->lineEdit_2nd_lower, &QLineEdit::editingFinished, [&]() { - slider_2nd->setLowerValue(ui->lineEdit_2nd_lower->text().toFloat()); - }); - - QObject::connect(slider_3rd, &RangeSlider::rangeChanged, [&](float low, float high) { - ui->lineEdit_3rd_upper->setText(QString::number(high)); - ui->lineEdit_3rd_lower->setText(QString::number(low)); - }); - QObject::connect(ui->lineEdit_3rd_upper, &QLineEdit::editingFinished, [&]() { - slider_2nd->setUpperValue(ui->lineEdit_3rd_upper->text().toFloat()); - }); - QObject::connect(ui->lineEdit_3rd_lower, &QLineEdit::editingFinished, [&]() { - slider_2nd->setLowerValue(ui->lineEdit_3rd_lower->text().toFloat()); - }); - - QObject::connect(slider_danger, &RangeSlider::rangeChanged, [&](float low,float high) { - ui->lineEdit_danger_upper->setText(QString::number(high)); - }); - QObject::connect(ui->lineEdit_danger_upper, &QLineEdit::editingFinished, [&]() { - slider_danger->setUpperValue(ui->lineEdit_danger_upper->text().toFloat()); - }); -} - -void Setpoint::on_pushButton_confirm_clicked() -{ - - std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); - std::shared_ptr setpoint_data = std::dynamic_pointer_cast(base_ptr); - if(setpoint_data->base_config_[current_index].channel_type == kVibPressurePulsation){ - setpoint_data->alert_danger_press[current_index].low_upper = ui->lineEdit_1st_upper->text().toFloat(); - setpoint_data->alert_danger_press[current_index].low_enable = ui->checkBox_1st->checkState(); - setpoint_data->alert_danger_press[current_index].mid1_upper = ui->lineEdit_2nd_upper->text().toFloat(); - setpoint_data->alert_danger_press[current_index].mid1_enable = ui->checkBox_2nd->checkState(); - setpoint_data->alert_danger_press[current_index].mid2_upper = ui->lineEdit_3rd_upper->text().toFloat(); - setpoint_data->alert_danger_press[current_index].mid2_enable = ui->checkBox_3rd->checkState(); - setpoint_data->alert_danger_press[current_index].danger_param = ui->comboBox_danger->currentIndex(); - setpoint_data->alert_danger_press[current_index].danger_upper = ui->lineEdit_danger_upper->text().toFloat(); - setpoint_data->alert_danger_press[current_index].danger_enable = ui->checkBox_danger->checkState(); - }else{ - setpoint_data->alert_danger[current_index].direct_upper = ui->lineEdit_1st_upper->text().toFloat(); - setpoint_data->alert_danger[current_index].direct_enable = ui->checkBox_1st->checkState(); - setpoint_data->alert_danger[current_index].x1_ampl_upper = ui->lineEdit_2nd_upper->text().toFloat(); - setpoint_data->alert_danger[current_index].x1_ampl_lower = ui->lineEdit_2nd_lower->text().toFloat(); - setpoint_data->alert_danger[current_index].x1_ampl_enable = ui->checkBox_2nd->checkState(); - setpoint_data->alert_danger[current_index].x2_ampl_upper = ui->lineEdit_3rd_upper->text().toFloat(); - setpoint_data->alert_danger[current_index].x2_ampl_lower = ui->lineEdit_3rd_lower->text().toFloat(); - setpoint_data->alert_danger[current_index].x2_ampl_enable = ui->checkBox_3rd->checkState(); - setpoint_data->alert_danger[current_index].danger_param = ui->comboBox_danger->currentIndex(); - setpoint_data->alert_danger[current_index].danger_upper = ui->lineEdit_danger_upper->text().toFloat(); - setpoint_data->alert_danger[current_index].danger_enable = ui->checkBox_danger->checkState(); - } - this->close(); -} - - -void Setpoint::on_pushButton_cancel_clicked() -{ - this->close(); -} - - -void Setpoint::on_pushButton_set_default_clicked() -{ - -} -void Setpoint::onComboBoxIndexChanged(int index){ - - std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); - std::shared_ptr setpoint_data = std::dynamic_pointer_cast(base_ptr); - if(setpoint_data->base_config_[current_index].channel_type == kVibPressurePulsation){ - setpoint_data->alert_danger_press[current_index].low_upper = ui->lineEdit_1st_upper->text().toFloat(); - setpoint_data->alert_danger_press[current_index].low_enable = ui->checkBox_1st->checkState(); - setpoint_data->alert_danger_press[current_index].mid1_upper = ui->lineEdit_2nd_upper->text().toFloat(); - setpoint_data->alert_danger_press[current_index].mid1_enable = ui->checkBox_2nd->checkState(); - setpoint_data->alert_danger_press[current_index].mid2_upper = ui->lineEdit_3rd_upper->text().toFloat(); - setpoint_data->alert_danger_press[current_index].mid2_enable = ui->checkBox_3rd->checkState(); - setpoint_data->alert_danger_press[current_index].danger_param = ui->comboBox_danger->currentIndex(); - setpoint_data->alert_danger_press[current_index].danger_upper = ui->lineEdit_danger_upper->text().toFloat(); - setpoint_data->alert_danger_press[current_index].danger_enable = ui->checkBox_danger->checkState(); - }else{ - setpoint_data->alert_danger[current_index].direct_upper = ui->lineEdit_1st_upper->text().toFloat(); - setpoint_data->alert_danger[current_index].direct_enable = ui->checkBox_1st->checkState(); - setpoint_data->alert_danger[current_index].x1_ampl_upper = ui->lineEdit_2nd_upper->text().toFloat(); - setpoint_data->alert_danger[current_index].x1_ampl_lower = ui->lineEdit_2nd_lower->text().toFloat(); - setpoint_data->alert_danger[current_index].x1_ampl_enable = ui->checkBox_2nd->checkState(); - setpoint_data->alert_danger[current_index].x2_ampl_upper = ui->lineEdit_3rd_upper->text().toFloat(); - setpoint_data->alert_danger[current_index].x2_ampl_lower = ui->lineEdit_3rd_lower->text().toFloat(); - setpoint_data->alert_danger[current_index].x2_ampl_enable = ui->checkBox_3rd->checkState(); - setpoint_data->alert_danger[current_index].danger_param = ui->comboBox_danger->currentIndex(); - setpoint_data->alert_danger[current_index].danger_upper = ui->lineEdit_danger_upper->text().toFloat(); - setpoint_data->alert_danger[current_index].danger_enable = ui->checkBox_danger->checkState(); - } - current_index = index; - update(); - -} -void Setpoint::update() -{ - int chan = ui->comboBox_chan->currentIndex(); - std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); - std::shared_ptr setpoint_data = std::dynamic_pointer_cast(base_ptr); - std::vector> variable_ = setpoint_data->variables_; - if(variable_.size() <= 0 ) - { - QMessageBox::information(this, QStringLiteral("提示"), "请先配置完通道参数!"); - return; - } - if(!variable_[chan]->x1_.checked){ - ui->checkBox_1st->setEnabled(false); - ui->lineEdit_2nd_lower->setEnabled(false); - ui->lineEdit_2nd_upper->setEnabled(false); - } - if(!variable_[chan]->x2_.checked){ - ui->checkBox_2nd->setEnabled(false); - ui->lineEdit_3rd_upper->setEnabled(false); - ui->lineEdit_3rd_lower->setEnabled(false); - } - if(setpoint_data->base_config_[chan].channel_type == kVibRadial){ - EnableNormal(); - ShowSlider(); - if(variable_[chan]->direct_.full_scale_range == 0){ - slider_1st->setRange(0,100); - slider_danger->setRange(0,100); - }else if(variable_[chan]->direct_.full_scale_range == 1){ - slider_1st->setRange(0,150); - slider_danger->setRange(0,150); - }else if(variable_[chan]->direct_.full_scale_range == 2){ - slider_1st->setRange(0,200); - slider_danger->setRange(0,200); - }else if(variable_[chan]->direct_.full_scale_range == 3){ - slider_1st->setRange(0,400); - slider_danger->setRange(0,400); - }else if(variable_[chan]->direct_.full_scale_range == 4){ - slider_1st->setRange(0,500); - slider_danger->setRange(0,500); - } - ui->label_unit_1st->setText("um"); - ui->label_danger->setText("um"); - - } - if(setpoint_data->base_config_[chan].channel_type == kVibThrust){ - EnableNormal(); - ui->label_2nd->hide(); - ui->label_unit_2nd->hide(); - ui->lineEdit_2nd_upper->hide(); - ui->widget_1x_ampl->hide(); - ui->lineEdit_2nd_lower->hide(); - ui->checkBox_2nd->hide(); - ui->label_3rd->hide(); - ui->label_unit_3rd->hide(); - ui->lineEdit_3rd_upper->hide(); - ui->widget_2x_ampl->hide(); - ui->lineEdit_3rd_lower->hide(); - ui->checkBox_3rd->hide(); - ui->label_unit_1st->setText("mil"); - ui->label_danger->setText("mil"); - if(variable_[chan]->direct_.full_scale_range == 0){ - slider_1st->setRange(-25,25); - slider_danger->setRange(-25,25); - }else if(variable_[chan]->direct_.full_scale_range == 1){ - slider_1st->setRange(-30,30); - slider_danger->setRange(-30,30); - }else if(variable_[chan]->direct_.full_scale_range == 2){ - slider_1st->setRange(-40,40); - slider_danger->setRange(-40,40); - }else if(variable_[chan]->direct_.full_scale_range == 3){ - ui->label_unit_1st->setText("mm"); - ui->label_danger->setText("mm"); - slider_1st->setRange(-0.5,0.5); - slider_danger->setRange(-0.5,0.5); - }else if(variable_[chan]->direct_.full_scale_range == 4){ - ui->label_unit_1st->setText("mm"); - ui->label_danger->setText("mm"); - slider_1st->setRange(-1,1); - slider_danger->setRange(-1,1); - } - } - if(setpoint_data->base_config_[chan].channel_type == kVibAcc){ - EnableNormal(); - ShowSlider(); - std::shared_ptr base_channel_ptr = setpoint_data->GetChannelPtr(chan + 1); - std::shared_ptr av_ptr = std::dynamic_pointer_cast(base_channel_ptr); - if(variable_[chan]->direct_.full_scale_range == 0){ - slider_1st->setRange(0,20); - slider_danger->setRange(0,20); - }else if(variable_[chan]->direct_.full_scale_range == 1){ - slider_1st->setRange(0,50); - slider_danger->setRange(0,50); - }else if(variable_[chan]->direct_.full_scale_range == 2){ - slider_1st->setRange(0,100); - slider_danger->setRange(0,100); - }else if(variable_[chan]->direct_.full_scale_range == 3){ - slider_1st->setRange(0,200); - slider_danger->setRange(0,200); - }else if(variable_[chan]->direct_.full_scale_range == 4){ - slider_1st->setRange(0,250); - slider_danger->setRange(0,250); - }else if(variable_[chan]->direct_.full_scale_range == 5){ - slider_1st->setRange(0,400); - slider_danger->setRange(0,400); - } - ui->label_unit_1st->setText("m/s^2 pk"); - ui->label_danger->setText("m/s^2 pk"); - - if(av_ptr->rms_active_){ - if(variable_[chan]->direct_.full_scale_range == 0){ - slider_1st->setRange(0,20); - slider_danger->setRange(0,20); - }else if(variable_[chan]->direct_.full_scale_range == 1){ - slider_1st->setRange(0,50); - slider_danger->setRange(0,50); - }else if(variable_[chan]->direct_.full_scale_range == 2){ - slider_1st->setRange(0,100); - slider_danger->setRange(0,100); - }else if(variable_[chan]->direct_.full_scale_range == 3){ - slider_1st->setRange(0,200); - slider_danger->setRange(0,200); - } - ui->label_unit_1st->setText("m/s^2 rms"); - ui->label_danger->setText("m/s^2 rms"); - } - - if(av_ptr->integrate_active_){ - if(variable_[chan]->direct_.full_scale_range == 0){ - slider_1st->setRange(0,25); - slider_danger->setRange(0,25); - }else if(variable_[chan]->direct_.full_scale_range == 1){ - slider_1st->setRange(0,50); - slider_danger->setRange(0,50); - }else if(variable_[chan]->direct_.full_scale_range == 2){ - slider_1st->setRange(0,100); - slider_danger->setRange(0,100); - } - ui->label_unit_1st->setText("mm/s pk"); - ui->label_danger->setText("mm/s pk"); - } - - if(av_ptr->rms_active_ && av_ptr->integrate_active_){ - if(variable_[chan]->direct_.full_scale_range == 0){ - slider_1st->setRange(0,25); - slider_danger->setRange(0,25); - }else if(variable_[chan]->direct_.full_scale_range == 1){ - slider_1st->setRange(0,50); - slider_danger->setRange(0,50); - } - ui->label_unit_1st->setText("mm/s rms"); - ui->label_danger->setText("mm/s rms"); - } - - } - if(setpoint_data->base_config_[chan].channel_type == kVibVelocity){ - EnableNormal(); - ShowSlider(); - std::shared_ptr base_channel_ptr = setpoint_data->GetChannelPtr(chan + 1); - std::shared_ptr av_ptr = std::dynamic_pointer_cast(base_channel_ptr); - - if(variable_[chan]->direct_.full_scale_range == 0){ - slider_1st->setRange(0,10); - slider_danger->setRange(0,10); - }else if(variable_[chan]->direct_.full_scale_range == 1){ - slider_1st->setRange(0,20); - slider_danger->setRange(0,20); - }else if(variable_[chan]->direct_.full_scale_range == 2){ - slider_1st->setRange(0,50); - slider_danger->setRange(0,50); - } - ui->label_unit_1st->setText("mm/s pk"); - ui->label_danger->setText("mm/s pk"); - - if(av_ptr->rms_active_){ - if(variable_[chan]->direct_.full_scale_range == 0){ - slider_1st->setRange(0,10); - slider_danger->setRange(0,10); - }else if(variable_[chan]->direct_.full_scale_range == 1){ - slider_1st->setRange(0,20); - slider_danger->setRange(0,20); - }else if(variable_[chan]->direct_.full_scale_range == 2){ - slider_1st->setRange(0,50); - slider_danger->setRange(0,50); - } - ui->label_unit_1st->setText("mm/s rms"); - ui->label_danger->setText("mm/s rms"); - } - - if(av_ptr->integrate_active_){ - if(variable_[chan]->direct_.full_scale_range == 0){ - slider_1st->setRange(0,100); - slider_danger->setRange(0,100); - }else if(variable_[chan]->direct_.full_scale_range == 1){ - slider_1st->setRange(0,200); - slider_danger->setRange(0,200); - }else if(variable_[chan]->direct_.full_scale_range == 2){ - slider_1st->setRange(0,500); - slider_danger->setRange(0,500); - } - ui->label_unit_1st->setText("um pp"); - ui->label_danger->setText("um pp"); - } - } - if(setpoint_data->base_config_[chan].channel_type == kVibPressurePulsation){ - ShowSlider(); - ui->label_1st->setText("低频段"); - ui->label_2nd->setText("中1频段"); - ui->label_3rd->setText("中2频段"); - ui->comboBox_danger->clear(); - ui->comboBox_danger->addItem("全频段"); - ui->checkBox_1st->setEnabled(true); - ui->checkBox_2nd->setEnabled(true); - ui->checkBox_3rd->setEnabled(true); - ui->lineEdit_2nd_lower->hide(); - ui->lineEdit_2nd_upper->setEnabled(true); - ui->lineEdit_3rd_lower->hide(); - ui->lineEdit_3rd_upper->setEnabled(true); - ui->label_unit_1st->setText("kPa"); - ui->label_unit_2nd->setText("kPa"); - ui->label_unit_3rd->setText("kPa"); - ui->label_danger->setText("kPa"); - slider_1st->setRange(0,10); - slider_2nd->setRange(0,10); - slider_3rd->setRange(0,10); - slider_danger->setRange(0,40); - ui->lineEdit_1st_upper->setText(QString::number(setpoint_data->alert_danger_press[chan].low_upper)); - ui->checkBox_1st->setChecked(setpoint_data->alert_danger_press[chan].low_enable); - if(setpoint_data->alert_danger_press[chan].low_upper > 0){ - slider_1st->m_upper = setpoint_data->alert_danger_press[chan].low_upper; - slider_1st->m_lower = 0; - } - - ui->lineEdit_2nd_upper->setText(QString::number(setpoint_data->alert_danger_press[chan].mid1_upper)); - ui->checkBox_2nd->setChecked(setpoint_data->alert_danger_press[chan].mid1_enable); - if(setpoint_data->alert_danger_press[chan].mid1_upper > 0){ - slider_2nd->m_upper = setpoint_data->alert_danger_press[chan].mid1_upper; - slider_2nd->m_lower = 0; - } - ui->lineEdit_3rd_upper->setText(QString::number(setpoint_data->alert_danger_press[chan].mid2_upper)); - ui->checkBox_3rd->setChecked(setpoint_data->alert_danger_press[chan].mid2_enable); - if(setpoint_data->alert_danger_press[chan].mid2_upper > 0){ - slider_3rd->m_upper = setpoint_data->alert_danger_press[chan].mid2_upper; - slider_3rd->m_lower = 0; - } - ui->lineEdit_danger_upper->setText(QString::number(setpoint_data->alert_danger_press[chan].danger_upper)); - ui->checkBox_danger->setChecked(setpoint_data->alert_danger_press[chan].danger_enable); - if(setpoint_data->alert_danger_press[chan].danger_upper > 0){ - slider_danger->m_upper = setpoint_data->alert_danger_press[chan].danger_upper; - slider_danger->m_lower = 0; - } - }else{ - ui->lineEdit_1st_upper->setText(QString::number(setpoint_data->alert_danger[chan].direct_upper)); - ui->checkBox_1st->setChecked(setpoint_data->alert_danger[chan].direct_enable); - if(setpoint_data->alert_danger[chan].direct_upper > 0){ - slider_1st->m_upper = setpoint_data->alert_danger[chan].direct_upper; - slider_1st->m_lower = 0; - } - ui->lineEdit_2nd_upper->setText(QString::number(setpoint_data->alert_danger[chan].x1_ampl_upper)); - ui->lineEdit_2nd_lower->setText(QString::number(setpoint_data->alert_danger[chan].x1_ampl_lower)); - ui->checkBox_2nd->setChecked(setpoint_data->alert_danger[chan].x1_ampl_enable); - if(setpoint_data->alert_danger[chan].x1_ampl_upper > 0 && setpoint_data->alert_danger[chan].x1_ampl_lower > 0){ - slider_2nd->m_upper = setpoint_data->alert_danger[chan].x1_ampl_upper; - slider_2nd->m_lower = setpoint_data->alert_danger[chan].x1_ampl_lower; - } - ui->lineEdit_3rd_upper->setText(QString::number(setpoint_data->alert_danger[chan].x2_ampl_upper)); - ui->lineEdit_3rd_lower->setText(QString::number(setpoint_data->alert_danger[chan].x2_ampl_lower)); - ui->checkBox_3rd->setChecked(setpoint_data->alert_danger[chan].x2_ampl_enable); - if(setpoint_data->alert_danger[chan].x2_ampl_upper > 0 && setpoint_data->alert_danger[chan].x2_ampl_lower > 0){ - slider_3rd->m_upper = setpoint_data->alert_danger[chan].x2_ampl_upper; - slider_3rd->m_lower = setpoint_data->alert_danger[chan].x2_ampl_lower; - } - ui->lineEdit_danger_upper->setText(QString::number(setpoint_data->alert_danger[chan].danger_upper)); - ui->checkBox_danger->setChecked(setpoint_data->alert_danger[chan].danger_enable); - if(setpoint_data->alert_danger[chan].danger_upper > 0){ - slider_danger->m_upper = setpoint_data->alert_danger[chan].danger_upper; - slider_danger->m_lower = 0; - } - } -} - - -void Setpoint::EnableNormal(){ - ui->label_1st->setText("直接值"); - ui->label_2nd->setText("1倍频幅值"); - ui->label_3rd->setText("2倍频幅值"); - ui->comboBox_danger->clear(); - QStringList items = {"直接值", "1倍频幅值", "2倍频幅值"}; - ui->comboBox_danger->addItems(items); - ui->checkBox_2nd->setChecked(false); - ui->checkBox_3rd->setChecked(false); - ui->label_unit_2nd->setText("- -"); - ui->label_unit_3rd->setText("- -"); -} - -void Setpoint::ShowSlider(){ - ui->label_2nd->show(); - ui->label_unit_2nd->show(); - ui->lineEdit_2nd_upper->show(); - ui->widget_1x_ampl->show(); - ui->lineEdit_2nd_lower->show(); - ui->checkBox_1st->show(); - - ui->label_3rd->show(); - ui->label_unit_3rd->show(); - ui->lineEdit_3rd_upper->show(); - ui->widget_2x_ampl->show(); - ui->lineEdit_3rd_lower->show(); - ui->checkBox_2nd->show(); -} diff --git a/setpoint.h b/setpoint.h deleted file mode 100644 index b83af7d..0000000 --- a/setpoint.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef SETPOINT_H -#define SETPOINT_H - -#include -#include "data_config.h" -#include "rangeslider.h" -#include "vibrationdata.h" - -namespace Ui { -class Setpoint; -} - -class Setpoint : public QWidget -{ - Q_OBJECT - -public: - explicit Setpoint(int slot_no_,int cardtype,QWidget *parent = nullptr); - ~Setpoint(); - int slot_no; - CardType car_type; -private slots: - void on_pushButton_confirm_clicked(); - - void on_pushButton_cancel_clicked(); - - void on_pushButton_set_default_clicked(); - - void onComboBoxIndexChanged(int index); - -private: - Ui::Setpoint *ui; - RangeSlider *slider_1st; - RangeSlider *slider_2nd; - RangeSlider *slider_3rd; - RangeSlider *slider_danger; - int current_index; - void Init(); - void update(); - void EnbalePressurePulsation(); - void EnableNormal(); - void ShowSlider(); -}; - -#endif // SETPOINT_H diff --git a/setpoint.ui b/setpoint.ui deleted file mode 100644 index 359ecac..0000000 --- a/setpoint.ui +++ /dev/null @@ -1,620 +0,0 @@ - - - Setpoint - - - - 0 - 0 - 734 - 528 - - - - 触发配置 - - - - - 540 - 10 - 161 - 451 - - - - 危险 / 警报 2 - - - - - 20 - 30 - 69 - 22 - - - - - 直接值 - - - - - 1倍频幅值 - - - - - 2倍频幅值 - - - - - - - 30 - 60 - 50 - 20 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - - - - - - Qt::AlignCenter - - - - - - 30 - 415 - 47 - 16 - - - - 启用 - - - false - - - - - - 30 - 90 - 50 - 20 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - - - - 10 - 116 - 100 - 260 - - - - - 100 - 260 - - - - - 100 - 260 - - - - - - - - 20 - 480 - 666 - 37 - - - - - - - 槽位号 - - - - - - - slot - - - - - - - - 通道 1 - - - - - 通道 2 - - - - - 通道 3 - - - - - 通道 4 - - - - - - - - - 100 - 35 - - - - 确定 - - - - - - - false - - - - 100 - 35 - - - - 设置为默认值 - - - - - - - - 100 - 35 - - - - 取消 - - - - - - - false - - - - 100 - 35 - - - - 打印 - - - - - - - false - - - - 100 - 35 - - - - 帮助 - - - - - - - - - 10 - 10 - 521 - 451 - - - - 告警 / 警报 1 - - - - - 100 - 110 - 100 - 260 - - - - - 100 - 260 - - - - - 100 - 260 - - - - - - - 121 - 41 - 54 - 16 - - - - 1倍频幅值 - - - - - - 121 - 77 - 50 - 20 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - - - - 130 - 59 - 50 - 16 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - - - - - - - - - 120 - 380 - 50 - 20 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - - - - 121 - 420 - 47 - 16 - - - - 启用 - - - - - - 221 - 420 - 47 - 16 - - - - 启用 - - - - - - 221 - 41 - 54 - 16 - - - - 2倍频幅值 - - - - - - 230 - 59 - 50 - 16 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - - - - - - - - - 221 - 77 - 50 - 20 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - - - - 200 - 110 - 100 - 260 - - - - - 100 - 260 - - - - - 100 - 260 - - - - - - - 220 - 380 - 50 - 20 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - - - - 30 - 80 - 50 - 20 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - Qt::AlignCenter - - - - - - 10 - 107 - 100 - 260 - - - - - 100 - 260 - - - - - 100 - 260 - - - - - - - 40 - 40 - 36 - 16 - - - - 直接值 - - - Qt::AlignCenter - - - - - - 25 - 60 - 50 - 20 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - - - - - - Qt::AlignCenter - - - - - - 30 - 420 - 65 - 16 - - - - 启用 - - - - - - - diff --git a/singlerelay.cpp b/singlerelay.cpp index 44d9a87..33afeab 100644 --- a/singlerelay.cpp +++ b/singlerelay.cpp @@ -112,17 +112,29 @@ void SingleRelay::Init(){ qDebug() << "i" << i; std::shared_ptr ptr = std::dynamic_pointer_cast(cardbase_ptr); for (int var = 0; var < CHANNEL_COUNT; ++var) { + std::shared_ptr variable_base = ptr->GetChannelPtr(var + 1); QString item_data,item_str; - if(ptr->alert_danger[var].direct_enable || - ptr->alert_danger[var].x1_ampl_enable || - ptr->alert_danger[var].x2_ampl_enable){ - item_str = QString("%1 (槽位 %2 通道 %3 警报)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2)); + if(variable_base->alert_high.enable){ + item_str = QString("%1 (槽位 %2 通道 %3 警报高)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2)); + item_data = QString("%1A2").arg(ptr->base_config_[var].chan_id); + } + channelNameMap[item_data] = item_str; + if(variable_base->danger_high.enable){ + item_str = QString("%1 (槽位 %2 通道 %3 危险高)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2)); item_data = QString("%1A1").arg(ptr->base_config_[var].chan_id); } channelNameMap[item_data] = item_str; - if(ptr->alert_danger[var].danger_enable){ - item_str = QString("%1 (槽位 %2 通道 %3 危险)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2)); - item_data = QString("%1A2").arg(ptr->base_config_[var].chan_id); + if(variable_base->alert_low.enable){ + item_str = QString("%1 (槽位 %2 通道 %3 警报低)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2)); + item_data = QString("%1A3").arg(ptr->base_config_[var].chan_id); + } + channelNameMap[item_data] = item_str; + if(variable_base->danger_low.enable){ + item_str = QString("%1 (槽位 %2 通道 %3 危险低)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2)); + item_data = QString("%1A4").arg(ptr->base_config_[var].chan_id); + } + if(var == 3){ + qDebug() << "alert" << variable_base->danger_high.enable<danger_high.enable; } channelNameMap[item_data] = item_str; item_str = QString("%1 (槽位 %2 通道 %3 非OK)").arg(ptr->base_config_[var].point_name).arg(ptr->base_config_[var].chan_id.mid(1,2)).arg(ptr->base_config_[var].chan_id.mid(4,2)); @@ -150,6 +162,8 @@ void SingleRelay::OnButtonGroup(QAbstractButton *slot_btn) { int button_id = object_name.right(object_name.length() - 15).toInt(); std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id); std::shared_ptr ptr = std::dynamic_pointer_cast(base_ptr); + if(ptr == nullptr) + return; QListWidgetItem *item_and = new QListWidgetItem("AND"); item_and->setData(Qt::UserRole, "*"); list_widget_available->addItem(item_and); @@ -160,24 +174,35 @@ void SingleRelay::OnButtonGroup(QAbstractButton *slot_btn) { for(int var = 0; var < CHANNEL_COUNT ; ++var){ std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(button_id); + std::shared_ptr variable_base = ptr->GetChannelPtr(var + 1); if(base_ptr->card_type_ == kCardVibSingle){ QString item_data; - if(ptr->base_config_[var].standby && (var % 2)) - continue; - if(ptr->alert_danger[var].direct_enable || - ptr->alert_danger[var].x1_ampl_enable || - ptr->alert_danger[var].x2_ampl_enable){ - QString item_str = QString("%1 (槽位 %3 通道 %4 警报)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + if(variable_base->alert_high.enable){ + QString item_str = QString("%1 (槽位 %3 通道 %4 警报高)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + QListWidgetItem *item = new QListWidgetItem(item_str); + item_data = QString("S%1C%2A2").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + item->setData(Qt::UserRole, item_data); + list_widget_available->addItem(item); + } + + if(variable_base->danger_high.enable){ + QString item_str = QString("%1 (槽位 %3 通道 %4 危险高)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); QListWidgetItem *item = new QListWidgetItem(item_str); item_data = QString("S%1C%2A1").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); item->setData(Qt::UserRole, item_data); list_widget_available->addItem(item); } - - if(ptr->alert_danger[var].danger_enable){ - QString item_str = QString("%1 (槽位 %3 通道 %4 危险)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + if(variable_base->danger_low.enable){ + QString item_str = QString("%1 (槽位 %3 通道 %4 危险低)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); QListWidgetItem *item = new QListWidgetItem(item_str); - item_data = QString("S%1C%2A2").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + item_data = QString("S%1C%2A4").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + item->setData(Qt::UserRole, item_data); + list_widget_available->addItem(item); + } + if(variable_base->alert_low.enable){ + QString item_str = QString("%1 (槽位 %3 通道 %4 警报低)").arg(ptr->base_config_[var].point_name).arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); + QListWidgetItem *item = new QListWidgetItem(item_str); + item_data = QString("S%1C%2A3").arg(QString::number(button_id, 10).rightJustified(2, '0')).arg(QString::number(var+1, 10).rightJustified(2, '0')); item->setData(Qt::UserRole, item_data); list_widget_available->addItem(item); } @@ -423,6 +448,7 @@ ExprValidationResult SingleRelay::validateLogicExpression(const QString& expr) { void SingleRelay::setExpressionToTreeView(QTreeView* treeView, const QString& expr) { int pos = 0; model_Relay->clear(); + qDebug() << "expr" << expr; ExprNode* root = parseExpression(expr, pos); QStandardItem* rootItem = buildItemTree(root); diff --git a/singlerelay.ui b/singlerelay.ui index aa8fe67..e670241 100644 --- a/singlerelay.ui +++ b/singlerelay.ui @@ -39,19 +39,6 @@ 确 定 - - - - 750 - 535 - 71 - 20 - - - - NCS6100T - - diff --git a/tmrrelayassociation.ui b/tmrrelayassociation.ui index 7f3e769..7679492 100644 --- a/tmrrelayassociation.ui +++ b/tmrrelayassociation.ui @@ -261,19 +261,6 @@ 取 消 - - - - 740 - 600 - 71 - 20 - - - - NCS6100T - - diff --git a/trust.cpp b/trust.cpp index 8d7faed..981929c 100644 --- a/trust.cpp +++ b/trust.cpp @@ -5,7 +5,7 @@ #include #include #include - +#include #include "data_config.h" #include "vibrationdata.h" #include "config_mgr.h" @@ -59,21 +59,43 @@ void Trust::Init() { 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); + + // gap + // -general + if(variable_ptr->gap_general.output_used) + ui->comboBox_output_used->setCurrentIndex(0); + else + ui->comboBox_output_used->setCurrentIndex(1); + ui->comboBox_engineering_unit->setCurrentIndex(variable_ptr->gap_general.engineering_unit); + ui->comboBox_rectifier_funtion->setCurrentIndex(variable_ptr->general.rectifier_function); + // -alarm + 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); + } void Trust::on_pushButton_confirm_clicked() { @@ -82,9 +104,25 @@ void Trust::on_pushButton_confirm_clicked() qCritical() << "[Radial::Init] should not be here"; return; } + 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; + } std::shared_ptr ptr = std::dynamic_pointer_cast(base_ptr); + ptr->base_config_[channel - 1].channel_type = kVibThrust; + std::shared_ptr variable_base = ptr->GetChannelPtr(channel); - if (variable_base == nullptr || variable_base->type_ != kVibThrust) { + std::shared_ptr variable = std::dynamic_pointer_cast(variable_base); + + if (variable_base == nullptr || variable_base->type_ != kVibThrust || variable == nullptr) { if (variable_base == nullptr) { qDebug() << "no channel ptr"; } else { @@ -103,24 +141,44 @@ void Trust::on_pushButton_confirm_clicked() 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(); + + // gap + // -general + if(ui->comboBox_output_used->currentIndex() == 0) + variable->gap_general.output_used = true; + else + variable->gap_general.output_used = false; + variable->gap_general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); + variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); + + // -alarm + 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(); 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(); @@ -130,20 +188,40 @@ void Trust::on_pushButton_confirm_clicked() 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(); + + // gap + // -general + if(ui->comboBox_output_used->currentIndex() == 0) + variable->gap_general.output_used = true; + else + variable->gap_general.output_used = false; + variable->gap_general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); + variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); + + // -alarm + 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(); this->close(); } @@ -153,3 +231,19 @@ void Trust::on_pushButton_cancel_clicked() this->close(); } + +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()); + } +} + diff --git a/trust.h b/trust.h index 8ef1319..29c4ade 100644 --- a/trust.h +++ b/trust.h @@ -22,6 +22,10 @@ private slots: void on_pushButton_cancel_clicked(); + void on_lineEdit_alert_high_level_editingFinished(); + + void on_lineEdit_danger_low_level_editingFinished(); + private: Ui::Trust *ui; void Init(); diff --git a/trust.ui b/trust.ui index 2342452..0cbdcb1 100644 --- a/trust.ui +++ b/trust.ui @@ -7,11 +7,11 @@ 0 0 691 - 505 + 525 - Form + 轴向位移 @@ -19,7 +19,7 @@ 10 60 651 - 381 + 391 @@ -27,7 +27,7 @@ - 传感器和滤波配置 + 滤波 @@ -273,431 +273,592 @@ - + - 特征值和警报配置 + 间隙 - + - 20 - 10 - 411 + 10 + 30 + 621 321 - - 特征值 + + 0 - - - - 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 - - - - - 自定义 - - - - - - - 10 - 190 - 201 - 101 - - - - 延时 - - + + + 常规 + + - 20 - 20 - 54 - 12 - - - - 告警 - - - - - - 20 + 230 50 - 54 - 12 - - - - 危险 - - - - - - 60 - 50 - 61 - 21 - - - - 1 - - - 1.000000000000000 - - - 99.900000000000006 - - - - - - 60 - 80 - 71 + 81 16 - 100 ms + 输出使用 - + - 130 - 20 - 54 - 12 - - - - 1 - 60s - - - - - - 130 - 50 - 71 + 230 + 100 + 81 16 - 1.0 - 60.0s + 工程单位 - - - - 60 - 20 - 61 - 21 - - - - 1 - - - - - - - 220 - 190 - 171 - 101 - - - - 初始位置 - - + 10 - 30 - 61 - 21 + 40 + 150 + 25 - - 2 + + + 150 + 25 + - - 1.000000000000000 + + + 150 + 25 + - - 99.900000000000006 + + + + + + + + + + + + + + + 10 + 180 + 171 + 101 + + + + 初始位置 + + + + + 10 + 30 + 61 + 21 + + + + 2 + + + -50.000000000000000 + + + 50.000000000000000 + + + + + + 80 + 30 + 91 + 16 + + + + -50 - 50 V + + + + + + 10 + 70 + 71 + 16 + + + + 取反 + + + + + + + 10 + 90 + 150 + 25 + + + + + 150 + 25 + + + + + 150 + 25 + + + + + g + + + + + m/s**2 + + + + + mm/s + + + + + inch/s + + + + + um + + + + + mm + + + + + mils + + + + + inch/s**2 + + + + + + + 230 + 150 + 81 + 16 + + + + 整流器 - + + + + 10 + 140 + 150 + 25 + + + + + 150 + 25 + + + + + 150 + 25 + + + + + AVG + + + + + + + 警报 + + + + + 10 + 60 + 71 + 16 + + + + 危险 + 高 + + + + + + 10 + 100 + 71 + 16 + + + + 警报 + 高 + + + + + + 10 + 140 + 71 + 16 + + + + 警报 + 低 + + + + + + 10 + 180 + 71 + 16 + + + + 危险 + 低 + + + + + + 90 + 30 + 31 + 31 + + + + 等级 + + + + + + 170 + 30 + 31 + 31 + + + + 回差 + + + + + + 230 + 30 + 31 + 31 + + + + 延时 + + + + + + 280 + 40 + 51 + 16 + + + + 使能 + + + + + + 340 + 40 + 51 + 16 + + + + 锁存 + + + 80 - 30 - 91 - 16 + 60 + 51 + 20 - - 0 - 13.99 V - - + - 10 - 70 - 71 + 150 + 60 + 51 + 20 + + + + + + + 220 + 60 + 51 + 20 + + + + + + + 220 + 100 + 51 + 20 + + + + + + + 80 + 100 + 51 + 20 + + + + + + + 150 + 100 + 51 + 20 + + + + + + + 220 + 140 + 51 + 20 + + + + + + + 150 + 180 + 51 + 20 + + + + + + + 80 + 140 + 51 + 20 + + + + + + + 220 + 180 + 51 + 20 + + + + + + + 80 + 180 + 51 + 20 + + + + + + + 150 + 140 + 51 + 20 + + + + + + + 290 + 60 + 16 16 - 取反 + + + + + + + 290 + 100 + 16 + 16 + + + + + + + + + + 290 + 140 + 16 + 16 + + + + + + + + + + 290 + 180 + 16 + 16 + + + + + + + + + + 350 + 100 + 16 + 16 + + + + + + + + + + 350 + 180 + 16 + 16 + + + + + + + + + + 350 + 60 + 16 + 16 + + + + + + + + + + 350 + 140 + 16 + 16 + + + + - - - - 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 - - @@ -705,7 +866,7 @@ 21 10 - 105 + 131 17 @@ -737,7 +898,7 @@ 20 - 450 + 470 632 37 diff --git a/velocity.cpp b/velocity.cpp index 45ea98b..9d58f42 100644 --- a/velocity.cpp +++ b/velocity.cpp @@ -9,6 +9,7 @@ #include "data_config.h" #include "vibrationdata.h" #include "config_mgr.h" +#include Velocity::Velocity(int slot_no_, int channel_, bool active, QWidget *parent) : QWidget(parent) @@ -32,92 +33,10 @@ Velocity::~Velocity() { delete ui; } -void Velocity::on_checkBox_rms_toggled(bool checked) { - // TODO: 自定义的回调 - if (checked) { - ui->checkBox_integrate->setEnabled(false); - QStringList items = {"0-10 mm/s rms", "0-20 mm/s rms", "0-50 mm/s rms", "自定义"}; - ui->comboBox_direct_value_range->clear(); - ui->comboBox_direct_value_range->addItems(items); - ui->comboBox_direct_value_range->setCurrentIndex(1); - ui->comboBox_1x_value_range->clear(); - ui->comboBox_1x_value_range->addItems(items); - ui->comboBox_1x_value_range->setCurrentIndex(1); - ui->comboBox_2x_value_range->clear(); - ui->comboBox_2x_value_range->addItems(items); - ui->comboBox_2x_value_range->setCurrentIndex(1); - return; - } - ui->checkBox_integrate->setEnabled(true); - ui->comboBox_direct_value_range->clear(); - QStringList items = {"0-10 mm/s pk", "0-20 mm/s pk", "0-50 mm/s pk", "自定义"}; - ui->comboBox_direct_value_range->addItems(items); - ui->comboBox_direct_value_range->setCurrentIndex(1); - ui->comboBox_1x_value_range->clear(); - ui->comboBox_1x_value_range->addItems(items); - ui->comboBox_1x_value_range->setCurrentIndex(1); - ui->comboBox_2x_value_range->clear(); - ui->comboBox_2x_value_range->addItems(items); - ui->comboBox_2x_value_range->setCurrentIndex(1); -} - -void Velocity::on_checkBox_integrate_toggled(bool checked) { - // TODO: 自定义的回调 - if (checked) { - ui->checkBox_rms->setEnabled(false); - ui->comboBox_direct_value_range->clear(); - QStringList items = {"0-100 um pp", "0-200 um pp", "0-500 um pp", "自定义"}; - ui->comboBox_direct_value_range->addItems(items); - ui->comboBox_direct_value_range->setCurrentIndex(1); - ui->comboBox_1x_value_range->clear(); - ui->comboBox_1x_value_range->addItems(items); - ui->comboBox_1x_value_range->setCurrentIndex(1); - ui->comboBox_2x_value_range->clear(); - ui->comboBox_2x_value_range->addItems(items); - ui->comboBox_2x_value_range->setCurrentIndex(1); - return; - } - ui->checkBox_rms->setEnabled(true); - ui->comboBox_direct_value_range->clear(); - QStringList items = {"0-10 mm/s pk", "0-20 mm/s pk", "0-50 mm/s pk", "自定义"}; - ui->comboBox_direct_value_range->addItems(items); - ui->comboBox_direct_value_range->setCurrentIndex(1); - ui->comboBox_1x_value_range->clear(); - ui->comboBox_1x_value_range->addItems(items); - ui->comboBox_1x_value_range->setCurrentIndex(1); - ui->comboBox_2x_value_range->clear(); - ui->comboBox_2x_value_range->addItems(items); - ui->comboBox_2x_value_range->setCurrentIndex(1); -} - void Velocity::on_pushButton_cancel_clicked() { this->close(); } -void Velocity::on_checkBox_1x_ampl_toggled(bool checked) { - if (checked) { - ui->comboBox_1x_value_range->setEnabled(true); - ui->doubleSpinBox_1x_ampl_clamp->setEnabled(true); - ui->doubleSpinBox_1x_phase_lag_clamp->setEnabled(true); - return; - } - ui->comboBox_1x_value_range->setEnabled(false); - ui->doubleSpinBox_1x_ampl_clamp->setEnabled(false); - ui->doubleSpinBox_1x_phase_lag_clamp->setEnabled(false); -} - -void Velocity::on_checkBox_2x_ampl_toggled(bool checked) { - if (checked) { - ui->comboBox_2x_value_range->setEnabled(true); - ui->doubleSpinBox_2x_ampl_clamp->setEnabled(true); - ui->doubleSpinBox_2x_phase_lag_clamp->setEnabled(true); - return; - } - ui->comboBox_2x_value_range->setEnabled(false); - ui->doubleSpinBox_2x_ampl_clamp->setEnabled(false); - ui->doubleSpinBox_2x_phase_lag_clamp->setEnabled(false); -} - void Velocity::Init() { std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); if (base_ptr == nullptr) { @@ -144,32 +63,41 @@ void Velocity::Init() { 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->checkBox_1x_ampl->setChecked(variable_ptr->x1_.checked); - ui->comboBox_1x_value_range->setCurrentIndex(variable_ptr->x1_.full_scale_range); - ui->doubleSpinBox_1x_ampl_clamp->setValue(variable_ptr->x1_.clamp_value); - ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variable_ptr->x1_.phase_lag); - ui->checkBox_2x_ampl->setChecked(variable_ptr->x2_.checked); - ui->comboBox_2x_value_range->setCurrentIndex(variable_ptr->x2_.full_scale_range); - ui->doubleSpinBox_2x_ampl_clamp->setValue(variable_ptr->x2_.clamp_value); - ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variable_ptr->x2_.phase_lag); - 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_rms->setChecked(variable_ptr->rms_active_); - ui->checkBox_integrate->setChecked(variable_ptr->integrate_active_); - ui->checkBox_alert_latching->setChecked(variable_ptr->alert_latching_); - ui->checkBox_danger_latching->setChecked(variable_ptr->danger_latching_); - ui->checkBox_timed_ok->setChecked(variable_ptr->timed_ok_); - 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_trip_multiply->setValue(variable_ptr->recorder_out_.trip_multiply); - ui->comboBox_comparision->setCurrentIndex(variable_ptr->recorder_out_.comparision); - ui->spinBox_comparision_percentage->setValue(variable_ptr->recorder_out_.percentage); + + // processed output + // -general + if(variable_ptr->general.output_used) + ui->comboBox_output_used->setCurrentIndex(0); + else + ui->comboBox_output_used->setCurrentIndex(1); + ui->comboBox_engineering_unit->setCurrentIndex(variable_ptr->general.engineering_unit); + ui->comboBox_rectifier_funtion->setCurrentIndex(variable_ptr->general.rectifier_function); + // -alarm + ui->lineEdit_danger_high_level->setText(QString::number(variable_ptr->danger_high.level)); + ui->lineEdit_danger_high_hysteresis->setText(QString::number(variable_ptr->danger_high.hysteresis)); + ui->lineEdit_danger_high_delay->setText(QString::number(variable_ptr->danger_high.delay)); + ui->checkBox_danger_high_enable->setChecked(variable_ptr->danger_high.enable); + ui->checkBox_danger_high_latch->setChecked(variable_ptr->danger_high.latch); + + ui->lineEdit_alert_high_level->setText(QString::number(variable_ptr->alert_high.level)); + ui->lineEdit_alert_high_hysteresis->setText(QString::number(variable_ptr->alert_high.hysteresis)); + ui->lineEdit_alert_high_delay->setText(QString::number(variable_ptr->alert_high.delay)); + ui->checkBox_alert_high_enable->setChecked(variable_ptr->alert_high.enable); + ui->checkBox_alert_high_latch->setChecked(variable_ptr->alert_high.latch); + + ui->lineEdit_danger_low_level->setText(QString::number(variable_ptr->danger_low.level)); + ui->lineEdit_danger_low_hysteresis->setText(QString::number(variable_ptr->danger_low.hysteresis)); + ui->lineEdit_danger_low_delay->setText(QString::number(variable_ptr->danger_low.delay)); + ui->checkBox_danger_low_enable->setChecked(variable_ptr->danger_low.enable); + ui->checkBox_danger_low_latch->setChecked(variable_ptr->danger_low.latch); + + ui->lineEdit_alert_low_level->setText(QString::number(variable_ptr->alert_low.level)); + ui->lineEdit_alert_low_hysteresis->setText(QString::number(variable_ptr->alert_low.hysteresis)); + ui->lineEdit_alert_low_delay->setText(QString::number(variable_ptr->alert_low.delay)); + ui->checkBox_alert_low_enable->setChecked(variable_ptr->alert_low.enable); + ui->checkBox_alert_low_latch->setChecked(variable_ptr->alert_low.latch); + + } void Velocity::on_pushButton_confirm_clicked() { @@ -178,9 +106,17 @@ void Velocity::on_pushButton_confirm_clicked() { qCritical() << "[Acceleration::Init] should not be here"; return; } + if(ui->lineEdit_alert_high_level->text().toFloat() > ui->lineEdit_danger_high_level->text().toDouble()){ + QMessageBox::warning(this, QStringLiteral("警告"), "危险 + 高 必须大于 警报 + 高"); + return; + } std::shared_ptr ptr = std::dynamic_pointer_cast(base_ptr); + ptr->base_config_[channel - 1].channel_type = kVibVelocity; + std::shared_ptr variable_base = ptr->GetChannelPtr(channel); - if (variable_base == nullptr || variable_base->type_ != kVibVelocity) { + std::shared_ptr variable = std::dynamic_pointer_cast(variable_base); + + if (variable_base == nullptr || variable_base->type_ != kVibVelocity || variable == nullptr) { if (variable_base == nullptr) { qDebug() << "no channel ptr"; } else { @@ -199,37 +135,39 @@ void Velocity::on_pushButton_confirm_clicked() { 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->x1_.checked = ui->checkBox_1x_ampl->isChecked(); - variable->x1_.full_scale_range = ui->comboBox_1x_value_range->currentIndex(); - variable->x1_.clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value(); - variable->x1_.custom = 0; // TODO: - variable->x1_.phase_lag = ui->doubleSpinBox_1x_phase_lag_clamp->value(); - variable->x2_.checked = ui->checkBox_2x_ampl->isChecked(); - variable->x2_.full_scale_range = ui->comboBox_2x_value_range->currentIndex(); - variable->x2_.clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value(); - variable->x2_.custom = 0; // TODO: - variable->x2_.phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value(); - variable->recorder_out_.recorder_output = ui->comboBox_recorder_output->currentIndex(); - variable->recorder_out_.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked(); - variable->recorder_out_.trip_multiply = ui->doubleSpinBox_trip_multiply->value(); - variable->recorder_out_.comparision = ui->comboBox_comparision->currentIndex(); - variable->recorder_out_.percentage = ui->spinBox_comparision_percentage->value(); - variable->delay_.alert = ui->spinBox_alert->value(); - variable->delay_.danger = ui->doubleSpinBox_danger->value(); - variable->delay_.active_100ms = ui->checkBox_100ms->isChecked(); - variable->rms_active_ = ui->checkBox_rms->isChecked(); - variable->integrate_active_ = ui->checkBox_integrate->isChecked(); - variable->alert_latching_ = ui->checkBox_alert_latching->isChecked(); - variable->danger_latching_ = ui->checkBox_danger_latching->isChecked(); - variable->timed_ok_ = ui->checkBox_timed_ok->isChecked(); + // processed output + // -general + if(ui->comboBox_output_used->currentIndex() == 0) + variable->general.output_used = true; + else + variable->general.output_used = false; + variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); + variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); + // -alarm + variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble(); + variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble(); + variable->danger_high.delay = ui->lineEdit_danger_high_delay->text().toDouble(); + variable->danger_high.enable = ui->checkBox_danger_high_enable->isChecked(); + variable->danger_high.latch = ui->checkBox_danger_high_latch->isChecked(); + variable->alert_high.level = ui->lineEdit_alert_high_level->text().toDouble(); + variable->alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble(); + variable->alert_high.delay = ui->lineEdit_alert_high_delay->text().toDouble(); + variable->alert_high.enable = ui->checkBox_alert_high_enable->isChecked(); + variable->alert_high.latch = ui->checkBox_alert_high_latch->isChecked(); + variable->danger_low.level = ui->lineEdit_danger_low_level->text().toDouble(); + variable->danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis->text().toDouble(); + variable->danger_low.delay = ui->lineEdit_danger_low_delay->text().toDouble(); + variable->danger_low.enable = ui->checkBox_danger_low_enable->isChecked(); + variable->danger_low.latch = ui->checkBox_danger_low_latch->isChecked(); + variable->alert_low.level = ui->lineEdit_alert_low_level->text().toDouble(); + variable->alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis->text().toDouble(); + variable->alert_low.delay = ui->lineEdit_alert_low_delay->text().toDouble(); + variable->alert_low.enable = ui->checkBox_alert_low_enable->isChecked(); + variable->alert_low.latch = ui->checkBox_alert_low_latch->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(); @@ -239,31 +177,42 @@ void Velocity::on_pushButton_confirm_clicked() { 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->x1_.checked = ui->checkBox_1x_ampl->isChecked(); - variable->x1_.full_scale_range = ui->comboBox_1x_value_range->currentIndex(); - variable->x1_.clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value(); - variable->x1_.custom = 0; // TODO: - variable->x1_.phase_lag = ui->doubleSpinBox_1x_phase_lag_clamp->value(); - variable->x2_.checked = ui->checkBox_2x_ampl->isChecked(); - variable->x2_.full_scale_range = ui->comboBox_2x_value_range->currentIndex(); - variable->x2_.clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value(); - variable->x2_.custom = 0; // TODO: - variable->x2_.phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value(); - variable->recorder_out_.recorder_output = ui->comboBox_recorder_output->currentIndex(); - variable->recorder_out_.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked(); - variable->recorder_out_.trip_multiply = ui->doubleSpinBox_trip_multiply->value(); - variable->recorder_out_.comparision = ui->comboBox_comparision->currentIndex(); - variable->recorder_out_.percentage = ui->spinBox_comparision_percentage->value(); - variable->delay_.alert = ui->spinBox_alert->value(); - variable->delay_.danger = ui->doubleSpinBox_danger->value(); - variable->delay_.active_100ms = ui->checkBox_100ms->isChecked(); - variable->rms_active_ = ui->checkBox_rms->isChecked(); - variable->integrate_active_ = ui->checkBox_integrate->isChecked(); - variable->alert_latching_ = ui->checkBox_alert_latching->isChecked(); - variable->danger_latching_ = ui->checkBox_danger_latching->isChecked(); - variable->timed_ok_ = ui->checkBox_timed_ok->isChecked(); + // processed output + // -general + if(ui->comboBox_output_used->currentIndex() == 0) + variable->general.output_used = true; + else + variable->general.output_used = false; + variable->general.engineering_unit = ui->comboBox_engineering_unit->currentIndex(); + variable->general.rectifier_function = ui->comboBox_rectifier_funtion->currentIndex(); + // -alarm + variable->danger_high.level = ui->lineEdit_danger_high_level->text().toDouble(); + variable->danger_high.hysteresis = ui->lineEdit_danger_high_hysteresis->text().toDouble(); + variable->danger_high.delay = ui->lineEdit_danger_high_delay->text().toDouble(); + variable->danger_high.enable = ui->checkBox_danger_high_enable->isChecked(); + variable->danger_high.latch = ui->checkBox_danger_high_latch->isChecked(); + variable->alert_high.level = ui->lineEdit_alert_high_level->text().toDouble(); + variable->alert_high.hysteresis = ui->lineEdit_alert_high_hysteresis->text().toDouble(); + variable->alert_high.delay = ui->lineEdit_alert_high_delay->text().toDouble(); + variable->alert_high.enable = ui->checkBox_alert_high_enable->isChecked(); + variable->alert_high.latch = ui->checkBox_alert_high_latch->isChecked(); + variable->danger_low.level = ui->lineEdit_danger_low_level->text().toDouble(); + variable->danger_low.hysteresis = ui->lineEdit_danger_low_hysteresis->text().toDouble(); + variable->danger_low.delay = ui->lineEdit_danger_low_delay->text().toDouble(); + variable->danger_low.enable = ui->checkBox_danger_low_enable->isChecked(); + variable->danger_low.latch = ui->checkBox_danger_low_latch->isChecked(); + variable->alert_low.level = ui->lineEdit_alert_low_level->text().toDouble(); + variable->alert_low.hysteresis = ui->lineEdit_alert_low_hysteresis->text().toDouble(); + variable->alert_low.delay = ui->lineEdit_alert_low_delay->text().toDouble(); + variable->alert_low.enable = ui->checkBox_alert_low_enable->isChecked(); + variable->alert_low.latch = ui->checkBox_alert_low_latch->isChecked(); this->close(); } + +void Velocity::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()); + } +} + diff --git a/velocity.h b/velocity.h index af40b1b..dfd530d 100644 --- a/velocity.h +++ b/velocity.h @@ -20,12 +20,10 @@ class Velocity : public QWidget { private slots: void on_pushButton_confirm_clicked(); void on_pushButton_cancel_clicked(); - void on_checkBox_1x_ampl_toggled(bool checked); - void on_checkBox_2x_ampl_toggled(bool checked); - void on_checkBox_rms_toggled(bool checked); - void on_checkBox_integrate_toggled(bool checked); - private: + void on_lineEdit_alert_high_level_editingFinished(); + +private: Ui::Velocity *ui; void Init(); diff --git a/velocity.ui b/velocity.ui index 4783dd6..f0e8a3b 100644 --- a/velocity.ui +++ b/velocity.ui @@ -27,7 +27,7 @@ - 滤波配置 + 滤波 @@ -275,684 +275,8 @@ - 特征值和警报配置 + 处理后输出 - - - - 10 - 10 - 431 - 351 - - - - 特征值 - - - - - 20 - 50 - 54 - 12 - - - - 直接值 - - - - - - 10 - 80 - 81 - 16 - - - - 偏置电压 - - - - - - 20 - 110 - 81 - 16 - - - - 1倍频幅值 - - - - - - 20 - 180 - 81 - 16 - - - - 2倍频幅值 - - - - - - 141 - 31 - 48 - 16 - - - - 取值范围 - - - - - - 269 - 31 - 48 - 16 - - - - 默认值 - - - - - - 130 - 50 - 111 - 22 - - - - 0-20 mm/s pk - - - 1 - - - - 0-10 mm/s pk - - - - - 0-20 mm/s pk - - - - - 0-50 mm/s pk - - - - - 自定义 - - - - - - - 260 - 50 - 62 - 22 - - - - 1 - - - - - - 130 - 80 - 54 - 12 - - - - -24 - - - - - - 260 - 80 - 62 - 22 - - - - 1 - - - - - false - - - - 130 - 110 - 111 - 22 - - - - 1 - - - - 0-10 mm/s pk - - - - - 0-20 mm/s pk - - - - - 0-50 mm/s pk - - - - - 自定义 - - - - - - false - - - - 260 - 110 - 62 - 22 - - - - 1 - - - - - - 20 - 150 - 91 - 16 - - - - 1倍频相位 - - - - - - 20 - 210 - 91 - 16 - - - - 2倍频相位 - - - - - false - - - - 260 - 150 - 62 - 22 - - - - 0 - - - - - false - - - - 260 - 180 - 62 - 22 - - - - 1 - - - - - false - - - - 260 - 210 - 62 - 22 - - - - 0 - - - - - false - - - - 130 - 180 - 111 - 22 - - - - 1 - - - - 0-10 mm/s pk - - - - - 0-20 mm/s pk - - - - - 0-50 mm/s pk - - - - - 自定义 - - - - - - - 20 - 250 - 71 - 16 - - - - 有效值 - - - - - - 130 - 250 - 71 - 16 - - - - 积分 - - - - - - 200 - 240 - 221 - 101 - - - - 延时 - - - - - 20 - 20 - 54 - 12 - - - - 告警 - - - - - - 20 - 50 - 54 - 12 - - - - 危险 - - - - - - 60 - 50 - 61 - 21 - - - - 1 - - - 1.000000000000000 - - - - - - 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 - - - - - - - 170 - 80 - 53 - 15 - - - - Vdc - - - - - - - 460 - 20 - 131 - 16 - - - - 告警锁定 - - - true - - - - - - 460 - 40 - 131 - 16 - - - - 危险锁定 - - - true - - - - - - 460 - 190 - 121 - 16 - - - - 倍增 - - - - - - 460 - 210 - 62 - 16 - - - - 1.000000000000000 - - - - - - 460 - 230 - 141 - 16 - - - - 1.00 - 3.00 (步进0.25) - - - - - - 460 - 110 - 54 - 12 - - - - 记录输出 - - - - - - 460 - 130 - 141 - 22 - - - - - - - - - - 直接幅值 - - - - - 1倍频幅值 - - - - - 2倍频幅值 - - - - - - - 460 - 160 - 101 - 16 - - - - 2 mA 默认值 - - - true - - - - - - 460 - 60 - 181 - 16 - - - - Timed OK channel Defeat - - - - - - 460 - 260 - 121 - 16 - - - - 比较 - - - - - false - - - - 460 - 280 - 141 - 22 - - - - - - - - - - 直接幅值 - - - - - 1倍频幅值 - - - - - 2倍频幅值 - - - - - - false - - - - 460 - 320 - 61 - 22 - - - @@ -966,6 +290,590 @@ % + + + + 20 + 30 + 621 + 321 + + + + 0 + + + + 常规 + + + + + 220 + 150 + 61 + 16 + + + + 整流器 + + + + + + 10 + 140 + 150 + 25 + + + + + 150 + 25 + + + + + 150 + 25 + + + + + True Peak + + + + + True Peak-To-Peak + + + + + RMS Scaled Peak + + + + + RMS Scaled Peak-To-Peak + + + + + AVG + + + + + RMS Scaled AVG + + + + + RMS + + + + + + + 220 + 50 + 71 + 16 + + + + 输出使用 + + + + + + 10 + 90 + 150 + 25 + + + + + 150 + 25 + + + + + 150 + 25 + + + + + g + + + + + m/s**2 + + + + + mm/s + + + + + inch/s + + + + + um + + + + + mm + + + + + mils + + + + + inch/s**2 + + + + + + + 220 + 100 + 71 + 16 + + + + 工程单位 + + + + + + 10 + 40 + 150 + 25 + + + + + 150 + 25 + + + + + 150 + 25 + + + + + + + + + + + + + + + + + 警报 + + + + + 10 + 60 + 71 + 16 + + + + 危险 + 高 + + + + + + 10 + 100 + 71 + 16 + + + + 警报 + 高 + + + + + + 10 + 140 + 71 + 16 + + + + 警报 + 低 + + + + + + 10 + 180 + 71 + 16 + + + + 危险 + 低 + + + + + + 90 + 30 + 41 + 31 + + + + 等级 + + + + + + 160 + 30 + 41 + 31 + + + + 回差 + + + + + + 230 + 30 + 51 + 31 + + + + 延时 + + + + + + 280 + 40 + 41 + 16 + + + + 使能 + + + + + + 340 + 40 + 41 + 16 + + + + 锁存 + + + + + + 80 + 60 + 51 + 20 + + + + + + + 150 + 60 + 51 + 20 + + + + + + + 220 + 60 + 51 + 20 + + + + + + + 220 + 100 + 51 + 20 + + + + + + + 80 + 100 + 51 + 20 + + + + + + + 150 + 100 + 51 + 20 + + + + + + false + + + + 220 + 140 + 51 + 20 + + + + + + false + + + + 150 + 180 + 51 + 20 + + + + + + false + + + + 80 + 140 + 51 + 20 + + + + + + false + + + + 220 + 180 + 51 + 20 + + + + + + false + + + + 80 + 180 + 51 + 20 + + + + + + false + + + + 150 + 140 + 51 + 20 + + + + + + + 290 + 60 + 16 + 16 + + + + + + + + + + 290 + 100 + 16 + 16 + + + + + + + + + false + + + + 290 + 140 + 16 + 16 + + + + + + + + + false + + + + 290 + 180 + 16 + 16 + + + + + + + + + + 350 + 100 + 16 + 16 + + + + + + + + + false + + + + 350 + 180 + 16 + 16 + + + + + + + + + + 350 + 60 + 16 + 16 + + + + + + + + + false + + + + 350 + 140 + 16 + 16 + + + + + + + + diff --git a/vibrationdata.h b/vibrationdata.h index fccb69f..f6724a6 100644 --- a/vibrationdata.h +++ b/vibrationdata.h @@ -14,6 +14,7 @@ class VibrationData : public CardBase { std::vector> variables_; VibAlertDanger alert_danger[CHANNEL_COUNT]; VibAlertDangerPress alert_danger_press[CHANNEL_COUNT]; + DCOutput dc_output[CHANNEL_COUNT]; }; #endif // VIBRATIONDATA_H