add codes.
This commit is contained in:
parent
7575aa4aa9
commit
4c8d546c84
210
acceleration.cpp
210
acceleration.cpp
@ -174,27 +174,24 @@ void Acceleration::Init() {
|
|||||||
}
|
}
|
||||||
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||||
if (ptr->base_config_[channel - 1].channel_type != kVibAcc) {
|
if (ptr->base_config_[channel - 1].channel_type != kVibAcc) {
|
||||||
// user change the channel type, load acceleration template
|
qDebug() << " channel type changes";
|
||||||
// std::shared_ptr<VibrationData> vib_data = std::make_shared<VibrationData>();
|
|
||||||
// ConfigMgr::Instance()->AddCard(vib_data);
|
|
||||||
// UpdateData(vib_data);
|
|
||||||
return;
|
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<VariableBase> variable_base = ptr->GetChannelPtr(channel);
|
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(channel);
|
||||||
if (variable_base == nullptr) {
|
if (variable_base == nullptr) {
|
||||||
qDebug() << "no channel ptr";
|
qDebug() << "no channel ptr";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::shared_ptr<AccVelVariable> variable_ptr = std::dynamic_pointer_cast<AccVelVariable>(variable_base);
|
std::shared_ptr<AccVelVariable> variable_ptr = std::dynamic_pointer_cast<AccVelVariable>(variable_base);
|
||||||
|
ui->checkBox_low_pass->setChecked(variable_ptr->filter_[0].checked);
|
||||||
|
ui->spinBox_low_pass_low->setValue(variable_ptr->filter_[0].low);
|
||||||
|
ui->spinBox_low_pass_high->setValue(variable_ptr->filter_[0].high);
|
||||||
|
ui->checkBox_high_pass->setChecked(variable_ptr->filter_[1].checked);
|
||||||
|
ui->spinBox_high_pass_low->setValue(variable_ptr->filter_[1].low);
|
||||||
|
ui->spinBox_high_pass_high->setValue(variable_ptr->filter_[1].high);
|
||||||
|
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_direct_value_range->setCurrentIndex(variable_ptr->direct_.full_scale_range);
|
||||||
ui->doubleSpinBox_direct_clamp->setValue(variable_ptr->direct_.clamp_value);
|
ui->doubleSpinBox_direct_clamp->setValue(variable_ptr->direct_.clamp_value);
|
||||||
// ui->label_bias_voltage->setText(QString::number(variable_ptr->direct_.bias_voltage));
|
// ui->label_bias_voltage->setText(QString::number(variable_ptr->direct_.bias_voltage));
|
||||||
@ -224,103 +221,100 @@ void Acceleration::Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Acceleration::on_pushButton_confirm_clicked() {
|
void Acceleration::on_pushButton_confirm_clicked() {
|
||||||
for (int i = 0; i < 3; i++) {
|
std::shared_ptr<CardBase> base_ptr = ConfigMgr::Instance()->GetSlotPtr(slot_no);
|
||||||
if (filter[i].type == "band_pass") {
|
if (base_ptr == nullptr) {
|
||||||
filter[i].checked = ui->checkBox_band_pass->isChecked();
|
qCritical() << "[Acceleration::Init] should not be here";
|
||||||
filter[i].low = ui->spinBox_band_pass_low->value();
|
return;
|
||||||
filter[i].high = ui->spinBox_band_pass_high->value();
|
}
|
||||||
} else if (filter[i].type == "low_pass") {
|
std::shared_ptr<VibrationData> ptr = std::dynamic_pointer_cast<VibrationData>(base_ptr);
|
||||||
filter[i].checked = ui->checkBox_low_pass->isChecked();
|
std::shared_ptr<VariableBase> variable_base = ptr->GetChannelPtr(channel);
|
||||||
filter[i].low = ui->spinBox_low_pass_low->value();
|
if (variable_base->type_ != kVibAcc) {
|
||||||
filter[i].high = ui->spinBox_low_pass_high->value();
|
return;
|
||||||
} else if (filter[i].type == "high_pass") {
|
}
|
||||||
filter[i].checked = ui->checkBox_high_pass->isChecked();
|
if (variable_base == nullptr || variable_base->type_ != kVibAcc) {
|
||||||
filter[i].low = ui->spinBox_high_pass_low->value();
|
if (variable_base == nullptr) {
|
||||||
filter[i].high = ui->spinBox_high_pass_high->value();
|
qDebug() << "no channel ptr";
|
||||||
|
} else {
|
||||||
|
ptr->RemoveChannel(channel);
|
||||||
|
qDebug() << "channel type change";
|
||||||
}
|
}
|
||||||
|
std::shared_ptr<AccVelVariable> variable = std::make_shared<AccVelVariable>();
|
||||||
|
variable->id_ = channel;
|
||||||
|
variable->type_ = kVibAcc;
|
||||||
|
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();
|
||||||
|
variable->filter_[1].checked = ui->checkBox_high_pass->isChecked();
|
||||||
|
variable->filter_[1].low = ui->spinBox_high_pass_low->value();
|
||||||
|
variable->filter_[1].high = ui->spinBox_high_pass_high->value();
|
||||||
|
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();
|
||||||
|
ptr->variables_.push_back(variable);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 4; i++) {
|
std::shared_ptr<AccVelVariable> variable = std::dynamic_pointer_cast<AccVelVariable>(variable_base);
|
||||||
if (variables[i].type == "direct") {
|
variable->filter_[0].checked = ui->checkBox_low_pass->isChecked();
|
||||||
variables[i].full_sacle_range = ui->comboBox_direct_value_range->currentIndex();
|
variable->filter_[0].low = ui->spinBox_low_pass_low->value();
|
||||||
variables[i].clamp_value = ui->doubleSpinBox_direct_clamp->value();
|
variable->filter_[0].high = ui->spinBox_low_pass_high->value();
|
||||||
} else if (variables[i].type == "bias_volt") {
|
variable->filter_[1].checked = ui->checkBox_high_pass->isChecked();
|
||||||
variables[i].clamp_value = ui->doubleSpinBox_bias_volt_clamp->value();
|
variable->filter_[1].low = ui->spinBox_high_pass_low->value();
|
||||||
} else if (variables[i].type == "1x_ampl") {
|
variable->filter_[1].high = ui->spinBox_high_pass_high->value();
|
||||||
variables[i].checked = ui->checkBox_1x_ampl->isChecked();
|
variable->filter_[2].checked = ui->checkBox_band_pass->isChecked();
|
||||||
variables[i].full_sacle_range = ui->comboBox_1x_value_range->currentIndex();
|
variable->filter_[2].low = ui->spinBox_band_pass_low->value();
|
||||||
variables[i].clamp_value = ui->doubleSpinBox_1x_ampl_clamp->value();
|
variable->filter_[2].high = ui->spinBox_band_pass_high->value();
|
||||||
variables[i].clamp_value = ui->doubleSpinBox_1x_phase_lag_clamp->value();
|
variable->direct_.full_scale_range = ui->comboBox_direct_value_range->currentIndex();
|
||||||
} else if (variables[i].type == "2x_ampl") {
|
variable->direct_.clamp_value = ui->doubleSpinBox_direct_clamp->value();
|
||||||
variables[i].checked = ui->checkBox_2x_ampl->isChecked();
|
variable->direct_.custom = 0; // TODO:
|
||||||
variables[i].full_sacle_range = ui->comboBox_2x_value_range->currentIndex();
|
variable->x1_.checked = ui->checkBox_1x_ampl->isChecked();
|
||||||
variables[i].clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value();
|
variable->x1_.full_scale_range = ui->comboBox_1x_value_range->currentIndex();
|
||||||
variables[i].clamp_value = ui->doubleSpinBox_2x_phase_lag_clamp->value();
|
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();
|
||||||
delay.alert = ui->spinBox_alert->value();
|
variable->x2_.checked = ui->checkBox_2x_ampl->isChecked();
|
||||||
delay.danger = ui->doubleSpinBox_danger->value();
|
variable->x2_.full_scale_range = ui->comboBox_2x_value_range->currentIndex();
|
||||||
delay.active_100ms = ui->checkBox_100ms->isChecked();
|
variable->x2_.clamp_value = ui->doubleSpinBox_2x_ampl_clamp->value();
|
||||||
alert_variables.rms_active = ui->checkBox_rms->isChecked();
|
variable->x2_.custom = 0; // TODO:
|
||||||
alert_variables.integrate_active = ui->checkBox_integrate->isChecked();
|
variable->x2_.phase_lag = ui->doubleSpinBox_2x_phase_lag_clamp->value();
|
||||||
alert_variables.alert_latching = ui->checkBox_alert_latching->isChecked();
|
variable->recorder_out_.recorder_output = ui->comboBox_recorder_output->currentIndex();
|
||||||
alert_variables.danger_latching = ui->checkBox_danger_latching->isChecked();
|
variable->recorder_out_.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked();
|
||||||
alert_variables.timed_ok = ui->checkBox_timed_ok->isChecked();
|
variable->recorder_out_.trip_multiply = ui->doubleSpinBox_trip_multiply->value();
|
||||||
alert_variables.recorder_output = ui->comboBox_recorder_output->currentIndex();
|
variable->recorder_out_.comparision = ui->comboBox_comparision->currentIndex();
|
||||||
alert_variables.two_ma_clamp = ui->checkBox_two_ma_clamp->isChecked();
|
variable->recorder_out_.percentage = ui->spinBox_comparision_percentage->value();
|
||||||
alert_variables.trip_multiply = ui->doubleSpinBox_trip_multiply->value();
|
variable->delay_.alert = ui->spinBox_alert->value();
|
||||||
alert_variables.comparision = ui->comboBox_comparision->currentText();
|
variable->delay_.danger = ui->doubleSpinBox_danger->value();
|
||||||
alert_variables.comparision_percentage = ui->spinBox_comparision_percentage->value();
|
variable->delay_.active_100ms = ui->checkBox_100ms->isChecked();
|
||||||
QJsonObject filter_obj, variables_obj;
|
variable->rms_active_ = ui->checkBox_rms->isChecked();
|
||||||
QJsonArray filter_array;
|
variable->integrate_active_ = ui->checkBox_integrate->isChecked();
|
||||||
for (int i = 0; i < 3; i++) {
|
variable->alert_latching_ = ui->checkBox_alert_latching->isChecked();
|
||||||
QJsonObject temp_obj;
|
variable->danger_latching_ = ui->checkBox_danger_latching->isChecked();
|
||||||
temp_obj.insert("type", filter[i].type);
|
variable->timed_ok_ = ui->checkBox_timed_ok->isChecked();
|
||||||
temp_obj.insert("low", filter[i].low);
|
|
||||||
temp_obj.insert("high", filter[i].high);
|
|
||||||
temp_obj.insert("checked", filter[i].checked);
|
|
||||||
filter_array.append(temp_obj);
|
|
||||||
}
|
|
||||||
filter_obj.insert("filter", filter_array);
|
|
||||||
filter_obj.insert("slot", slot_no);
|
|
||||||
filter_obj.insert("id", channel);
|
|
||||||
filter_obj.insert("version", 1);
|
|
||||||
QJsonArray variables_array;
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
QJsonObject temp_obj;
|
|
||||||
temp_obj.insert("type", variables[i].type);
|
|
||||||
if (variables[i].type == "direct") {
|
|
||||||
temp_obj.insert("full_sacle_range", variables[i].full_sacle_range);
|
|
||||||
temp_obj.insert("clamp_value", variables[i].clamp_value);
|
|
||||||
} else if (variables[i].type == "bias_volt") {
|
|
||||||
temp_obj.insert("clamp_value", variables[i].clamp_value);
|
|
||||||
temp_obj.insert("full_sacle_range", variables[i].full_sacle_range);
|
|
||||||
} else if (variables[i].type == "1x_ampl" || variables[i].type == "2x_ampl") {
|
|
||||||
temp_obj.insert("checked", variables[i].checked);
|
|
||||||
temp_obj.insert("full_sacle_range", variables[i].full_sacle_range);
|
|
||||||
temp_obj.insert("clamp_value", variables[i].clamp_value);
|
|
||||||
temp_obj.insert("phase_lag", variables[i].phase_lag);
|
|
||||||
}
|
|
||||||
variables_array.append(temp_obj);
|
|
||||||
}
|
|
||||||
variables_obj.insert("variables", variables_array);
|
|
||||||
QJsonObject delay_obj;
|
|
||||||
delay_obj.insert("alert", delay.alert);
|
|
||||||
delay_obj.insert("danger", delay.danger);
|
|
||||||
delay_obj.insert("100ms", delay.active_100ms);
|
|
||||||
variables_obj.insert("delay", delay_obj);
|
|
||||||
variables_obj.insert("rms_active", alert_variables.rms_active);
|
|
||||||
variables_obj.insert("integrate_active", alert_variables.integrate_active);
|
|
||||||
variables_obj.insert("alert_latching", alert_variables.alert_latching);
|
|
||||||
variables_obj.insert("danger_latching", alert_variables.danger_latching);
|
|
||||||
variables_obj.insert("timed_ok", alert_variables.timed_ok);
|
|
||||||
variables_obj.insert("recorder_output", alert_variables.recorder_output);
|
|
||||||
variables_obj.insert("two_ma_clamp", alert_variables.two_ma_clamp);
|
|
||||||
variables_obj.insert("trip_multiply", alert_variables.trip_multiply);
|
|
||||||
variables_obj.insert("comparision", alert_variables.comparision);
|
|
||||||
variables_obj.insert("comparision_percentage", alert_variables.comparision_percentage);
|
|
||||||
variables_obj.insert("slot", slot_no);
|
|
||||||
variables_obj.insert("id", channel);
|
|
||||||
variables_obj.insert("version", 1);
|
|
||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ class VariableBase {
|
|||||||
|
|
||||||
int id_;
|
int id_;
|
||||||
VibChannelType type_;
|
VibChannelType type_;
|
||||||
|
Filter filter_[3];
|
||||||
DirectImpl direct_;
|
DirectImpl direct_;
|
||||||
XImpl x1_;
|
XImpl x1_;
|
||||||
XImpl x2_;
|
XImpl x2_;
|
||||||
|
@ -98,9 +98,9 @@ typedef struct {
|
|||||||
bool checked;
|
bool checked;
|
||||||
} Filter;
|
} Filter;
|
||||||
|
|
||||||
typedef struct {
|
//typedef struct {
|
||||||
Filter filter[3]; // 0: kFilterTypeLowPass, 1: kFilterTypeHighPass, 2: kFilterTypeBandPass
|
// Filter filter[3]; // 0: kFilterTypeLowPass, 1: kFilterTypeHighPass, 2: kFilterTypeBandPass
|
||||||
} AllFilter;
|
//} AllFilter;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
QString type;
|
QString type;
|
||||||
|
@ -11,3 +11,14 @@ std::shared_ptr<VariableBase> VibrationData::GetChannelPtr(int cid) {
|
|||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VibrationData::RemoveChannel(int cid) {
|
||||||
|
std::vector<std::shared_ptr<VariableBase>> tmp;
|
||||||
|
for (auto &item : variables_) {
|
||||||
|
if (item->id_ != cid) {
|
||||||
|
tmp.push_back(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
variables_.clear();
|
||||||
|
variables_ = tmp;
|
||||||
|
}
|
||||||
|
@ -22,9 +22,10 @@ class VibrationData : public CardBase {
|
|||||||
// return ch;
|
// return ch;
|
||||||
// }
|
// }
|
||||||
std::shared_ptr<VariableBase> GetChannelPtr(int cid);
|
std::shared_ptr<VariableBase> GetChannelPtr(int cid);
|
||||||
|
void RemoveChannel(int cid);
|
||||||
// private:
|
// private:
|
||||||
SeismicMonitor base_config_[CHANNEL_COUNT];
|
SeismicMonitor base_config_[CHANNEL_COUNT];
|
||||||
AllFilter filter_[CHANNEL_COUNT];
|
// AllFilter filter_[CHANNEL_COUNT];
|
||||||
std::vector<std::shared_ptr<VariableBase>> variables_;
|
std::vector<std::shared_ptr<VariableBase>> variables_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user