diff --git a/acceleration.cpp b/acceleration.cpp index 74561f8..449dc41 100644 --- a/acceleration.cpp +++ b/acceleration.cpp @@ -174,7 +174,10 @@ void Acceleration::Init() { } std::shared_ptr ptr = std::dynamic_pointer_cast(base_ptr); if (ptr->base_config_[channel - 1].channel_type != kVibAcc) { - // user change the channel type + // user change the channel type, load acceleration template +// std::shared_ptr vib_data = std::make_shared(); +// ConfigMgr::Instance()->AddCard(vib_data); +// UpdateData(vib_data); return; } ui->checkBox_low_pass->setChecked(ptr->filter_[channel - 1].filter[0].checked); @@ -186,48 +189,38 @@ void Acceleration::Init() { 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); - ui->doubleSpinBox_direct_clamp->setValue(variables[i].clamp_value); - } else if (variables[i].type == "bias_volt") { - ui->label_bias_voltage->setText(QString::number(variables[i].bias_voltage)); - ui->doubleSpinBox_bias_volt_clamp->setValue(variables[i].clamp_value); - } else if (variables[i].type == "1x_ampl") { - 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); - } else if (variables[i].type == "2x_ampl") { - 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); - } + std::shared_ptr variable_base = ptr->GetChannelPtr(channel); + if (variable_base == nullptr) { + qDebug() << "no channel ptr"; + return; } - ui->spinBox_alert->setValue(delay.alert); - ui->doubleSpinBox_danger->setValue(delay.danger); - ui->checkBox_100ms->setChecked(delay.active_100ms); - ui->checkBox_rms->setChecked(alert_variables.rms_active); - ui->checkBox_integrate->setChecked(alert_variables.integrate_active); - ui->checkBox_alert_latching->setChecked(alert_variables.alert_latching); - ui->checkBox_danger_latching->setChecked(alert_variables.danger_latching); - ui->checkBox_timed_ok->setChecked(alert_variables.timed_ok); - ui->comboBox_recorder_output->setCurrentIndex(alert_variables.recorder_output); - ui->checkBox_two_ma_clamp->setChecked(alert_variables.two_ma_clamp); - ui->doubleSpinBox_trip_multiply->setValue(alert_variables.trip_multiply); - ui->comboBox_comparision->setCurrentText(alert_variables.comparision); - ui->spinBox_comparision_percentage->setValue(alert_variables.comparision_percentage); + std::shared_ptr variable_ptr = std::dynamic_pointer_cast(variable_base); + 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); } void Acceleration::on_pushButton_confirm_clicked() { @@ -328,32 +321,12 @@ void Acceleration::on_pushButton_confirm_clicked() { variables_obj.insert("slot", slot_no); variables_obj.insert("id", channel); variables_obj.insert("version", 1); -// QJsonDocument jsonDoc_filter(filter_obj); -// QString filePath = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\filter_%2.json").arg(slot_no).arg(channel); -// QFile file(filePath); -// if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { -// qDebug() << "Cannot open file for writing:" << filePath; -// return; -// } -// file.write(jsonDoc_filter.toJson()); -// file.close(); -// QJsonDocument jsonDoc_variables(variables_obj); -// filePath = QCoreApplication::applicationDirPath() + QString("\\config\\%1\\acceleration_variables_%2.json").arg(slot_no).arg(channel); -// file.setFileName(filePath); -// if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { -// qDebug() << "Cannot open file for writing:" << filePath; -// return; -// } -// file.write(jsonDoc_variables.toJson()); -// file.close(); this->close(); } - void Acceleration::on_pushButton_set_default_clicked() { } - void Acceleration::on_pushButton_cancel_clicked() { this->close(); }