diff --git a/acceleration.cpp b/acceleration.cpp index 0939138..74561f8 100644 --- a/acceleration.cpp +++ b/acceleration.cpp @@ -168,23 +168,36 @@ void Acceleration::on_checkBox_2x_ampl_toggled(bool checked) { void Acceleration::Init() { std::shared_ptr base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no); - for (int i = 0; i < 3; i++) { - if (filter[i].checked) { - if (filter[i].type == "band_pass") { - ui->checkBox_band_pass->setChecked(filter[i].checked); - ui->spinBox_band_pass_low->setValue(filter[i].low); - ui->spinBox_band_pass_high->setValue(filter[i].high); - } else if (filter[i].type == "low_pass") { - ui->checkBox_low_pass->setChecked(filter[i].checked); - ui->spinBox_low_pass_low->setValue(filter[i].low); - ui->spinBox_low_pass_high->setValue(filter[i].high); - } else if (filter[i].type == "high_pass") { - ui->checkBox_high_pass->setChecked(filter[i].checked); - ui->spinBox_high_pass_low->setValue(filter[i].low); - ui->spinBox_high_pass_high->setValue(filter[i].high); - } - } + if (base_ptr == nullptr) { + qCritical() << "[Acceleration::Init] should not be here"; + return; } + std::shared_ptr ptr = std::dynamic_pointer_cast(base_ptr); + if (ptr->base_config_[channel - 1].channel_type != kVibAcc) { + // user change the channel type + return; + } + ui->checkBox_low_pass->setChecked(ptr->filter_[channel - 1].filter[0].checked); + ui->spinBox_low_pass_low->setValue(ptr->filter_[channel - 1].filter[0].low); + ui->spinBox_low_pass_high->setValue(ptr->filter_[channel - 1].filter[0].high); + ui->checkBox_high_pass->setChecked(ptr->filter_[channel - 1].filter[1].checked); + ui->spinBox_high_pass_low->setValue(ptr->filter_[channel - 1].filter[1].low); + ui->spinBox_high_pass_high->setValue(ptr->filter_[channel - 1].filter[1].high); + ui->checkBox_band_pass->setChecked(ptr->filter_[channel - 1].filter[2].checked); + ui->spinBox_band_pass_low->setValue(ptr->filter_[channel - 1].filter[2].low); + ui->spinBox_band_pass_high->setValue(ptr->filter_[channel - 1].filter[2].high); +// std::shared_ptr variable_base = ptr->GetChannelPtr(channel); + std::shared_ptr variable_ptr = std::dynamic_pointer_cast(ptr->GetChannelPtr(channel)); + ui->comboBox_direct_value_range->setCurrentIndex(variables[i].full_sacle_range); + ui->doubleSpinBox_direct_clamp->setValue(variables[i].clamp_value); + ui->label_bias_voltage->setText(QString::number(variables[i].bias_voltage)); + ui->doubleSpinBox_bias_volt_clamp->setValue(variables[i].clamp_value); + ui->comboBox_1x_value_range->setCurrentIndex(variables[i].full_sacle_range); + ui->doubleSpinBox_1x_ampl_clamp->setValue(variables[i].clamp_value); + ui->doubleSpinBox_1x_phase_lag_clamp->setValue(variables[i].clamp_value); + ui->comboBox_2x_value_range->setCurrentIndex(variables[i].full_sacle_range); + ui->doubleSpinBox_2x_ampl_clamp->setValue(variables[i].clamp_value); + ui->doubleSpinBox_2x_phase_lag_clamp->setValue(variables[i].clamp_value); for (int i = 0; i < 4; i++) { if (variables[i].type == "direct") { ui->comboBox_direct_value_range->setCurrentIndex(variables[i].full_sacle_range);