diff --git a/config_mgr.cpp b/config_mgr.cpp index 26d151e..d49344e 100644 --- a/config_mgr.cpp +++ b/config_mgr.cpp @@ -270,6 +270,7 @@ void ConfigMgr::Save(QString & file_path) { channel_item.insert("threshold", ptr->variables_[cid].threshold); channel_item.insert("hysteresis", ptr->variables_[cid].hysteresis); channel_item.insert("events_per_revolution", ptr->variables_[cid].events_per_revolution); + channel_item.insert("automatic_threshold",ptr->variables_[cid].automatic_threshold); } slot_item[QString::number(cid + 1)] = channel_item; } @@ -534,6 +535,7 @@ void ConfigMgr::Load(QString filename) { speed_data->variables_[j].normal_latching = channel["normal_latching"].toBool(); speed_data->variables_[j].speed_peek = channel["speed_peak"].toInt(); speed_data->variables_[j].default_speed = channel["default_speed"].toInt(); + speed_data->variables_[j].automatic_threshold = channel["automatic_threshold"].toBool(); QJsonObject setpoint_data = channel["setpoint"].toObject(); @@ -561,6 +563,7 @@ void ConfigMgr::Load(QString filename) { 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(); + keyphase_data->variables_[j].automatic_threshold = channel["automatic_threshold"].toBool(); } cards_.push_back(keyphase_data); }else if (card_type_[i] == kCardRelaySingleNOK ){ diff --git a/keyphase.cpp b/keyphase.cpp index df3ba2a..72b9366 100644 --- a/keyphase.cpp +++ b/keyphase.cpp @@ -193,3 +193,75 @@ void KeyPhase::on_pushButton_confirm_clicked() { this->close(); } + +void KeyPhase::on_radioButton_manual_threshold_1_clicked() +{ + if(ui->radioButton_manual_threshold_1->isChecked()){ + ui->doubleSpinBox_threshold_1->setEnabled(true); + ui->doubleSpinBox_hysteresis_1->setEnabled(true); + } +} + + +void KeyPhase::on_radioButton_automatic_threshold_1_clicked() +{ + if(ui->radioButton_automatic_threshold_1->isChecked()){ + ui->doubleSpinBox_threshold_1->setEnabled(false); + ui->doubleSpinBox_hysteresis_1->setEnabled(false); + } +} + + +void KeyPhase::on_radioButton_automatic_threshold_2_clicked() +{ + if(ui->radioButton_automatic_threshold_2->isChecked()){ + ui->doubleSpinBox_threshold_2->setEnabled(false); + ui->doubleSpinBox_hysteresis_2->setEnabled(false); + } +} + + +void KeyPhase::on_radioButton_manual_threshold_2_clicked() +{ + if(ui->radioButton_manual_threshold_2->isChecked()){ + ui->doubleSpinBox_threshold_2->setEnabled(true); + ui->doubleSpinBox_hysteresis_2->setEnabled(true); + } +} + + +void KeyPhase::on_radioButton_automatic_threshold_3_clicked() +{ + if(ui->radioButton_automatic_threshold_3->isChecked()){ + ui->doubleSpinBox_threshold_3->setEnabled(false); + ui->doubleSpinBox_hysteresis_3->setEnabled(false); + } +} + + +void KeyPhase::on_radioButton_manual_threshold_3_clicked() +{ + if(ui->radioButton_manual_threshold_3->isChecked()){ + ui->doubleSpinBox_threshold_3->setEnabled(true); + ui->doubleSpinBox_hysteresis_3->setEnabled(true); + } +} + + +void KeyPhase::on_radioButton_automatic_threshold_4_clicked() +{ + if(ui->radioButton_automatic_threshold_4->isChecked()){ + ui->doubleSpinBox_threshold_4->setEnabled(false); + ui->doubleSpinBox_hysteresis_4->setEnabled(false); + } +} + + +void KeyPhase::on_radioButton_manual_threshold_4_clicked() +{ + if(ui->radioButton_manual_threshold_4->isChecked()){ + ui->doubleSpinBox_threshold_4->setEnabled(true); + ui->doubleSpinBox_hysteresis_4->setEnabled(true); + } +} + diff --git a/keyphase.h b/keyphase.h index 86776b2..e2839ca 100644 --- a/keyphase.h +++ b/keyphase.h @@ -23,7 +23,23 @@ class KeyPhase : public QDialog { void on_manual_threshold_2_clicked(bool checked); void on_manual_threshold_3_clicked(bool checked); void on_manual_threshold_4_clicked(bool checked); - private: + void on_radioButton_manual_threshold_1_clicked(); + + void on_radioButton_automatic_threshold_1_clicked(); + + void on_radioButton_automatic_threshold_2_clicked(); + + void on_radioButton_manual_threshold_2_clicked(); + + void on_radioButton_automatic_threshold_3_clicked(); + + void on_radioButton_manual_threshold_3_clicked(); + + void on_radioButton_automatic_threshold_4_clicked(); + + void on_radioButton_manual_threshold_4_clicked(); + +private: Ui::KeyPhase *ui; void UpdateData(std::shared_ptr &keyphase_data); // TachometerVariables keyphase_variables[4]; diff --git a/keyphase.ui b/keyphase.ui index 6ac636e..acb246a 100644 --- a/keyphase.ui +++ b/keyphase.ui @@ -109,7 +109,7 @@ - 0 + 1 @@ -933,7 +933,7 @@ - 0 + 1 diff --git a/mainwindow.cpp b/mainwindow.cpp index 02c4b1e..934eb6d 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -482,7 +482,6 @@ void MainWindow::OnButtonGroup(QAbstractButton *slot_btn) { setpoint_tachometer->show(); break; } - } } } diff --git a/tachometer.cpp b/tachometer.cpp index cf0417b..bc9d129 100644 --- a/tachometer.cpp +++ b/tachometer.cpp @@ -174,8 +174,12 @@ void Tachometer::Init() { ui->default_value_1->setValue(speed_data->variables_[i].default_speed); if (speed_data->variables_[i].automatic_threshold) { ui->radioButton_automatic_threshold_1->setChecked(true); + ui->doubleSpinBox_threshold_1->setEnabled(false); + ui->doubleSpinBox_hysteresis_1->setEnabled(false); } else { ui->radioButton_manual_threshold_1->setChecked(true); + ui->doubleSpinBox_threshold_1->setEnabled(true); + ui->doubleSpinBox_hysteresis_1->setEnabled(true); } ui->doubleSpinBox_threshold_1->setValue(speed_data->variables_[i].threshold); ui->doubleSpinBox_hysteresis_1->setValue(speed_data->variables_[i].hysteresis); @@ -200,8 +204,12 @@ void Tachometer::Init() { ui->default_value_2->setValue(speed_data->variables_[i].default_speed); if (speed_data->variables_[i].automatic_threshold) { ui->radioButton_automatic_threshold_2->setChecked(true); + ui->doubleSpinBox_threshold_2->setEnabled(false); + ui->doubleSpinBox_hysteresis_2->setEnabled(false); } else { ui->radioButton_manual_threshold_2->setChecked(true); + ui->doubleSpinBox_threshold_2->setEnabled(true); + ui->doubleSpinBox_hysteresis_2->setEnabled(true); } ui->doubleSpinBox_threshold_2->setValue(speed_data->variables_[i].threshold); ui->doubleSpinBox_hysteresis_2->setValue(speed_data->variables_[i].hysteresis); @@ -226,8 +234,12 @@ void Tachometer::Init() { ui->default_value_3->setValue(speed_data->variables_[i].default_speed); if (speed_data->variables_[i].automatic_threshold) { ui->radioButton_automatic_threshold_3->setChecked(true); + ui->doubleSpinBox_threshold_3->setEnabled(false); + ui->doubleSpinBox_hysteresis_3->setEnabled(false); } else { ui->radioButton_manual_threshold_3->setChecked(true); + ui->doubleSpinBox_threshold_3->setEnabled(true); + ui->doubleSpinBox_hysteresis_3->setEnabled(true); } ui->doubleSpinBox_threshold_3->setValue(speed_data->variables_[i].threshold); ui->doubleSpinBox_hysteresis_3->setValue(speed_data->variables_[i].hysteresis); @@ -252,8 +264,12 @@ void Tachometer::Init() { ui->default_value_4->setValue(speed_data->variables_[i].default_speed); if (speed_data->variables_[i].automatic_threshold) { ui->radioButton_automatic_threshold_4->setChecked(true); + ui->doubleSpinBox_threshold_4->setEnabled(false); + ui->doubleSpinBox_hysteresis_4->setEnabled(false); } else { ui->radioButton_manual_threshold_4->setChecked(true); + ui->doubleSpinBox_threshold_4->setEnabled(true); + ui->doubleSpinBox_hysteresis_4->setEnabled(true); } ui->doubleSpinBox_threshold_4->setValue(speed_data->variables_[i].threshold); ui->doubleSpinBox_hysteresis_4->setValue(speed_data->variables_[i].hysteresis); @@ -288,3 +304,9 @@ void Tachometer::on_pushButton_confirm_clicked() { void Tachometer::on_pushButton_cancel_clicked() { this->close(); } + +void Tachometer::on_radioButton_automatic_threshold_1_clicked() +{ + +} + diff --git a/tachometer.h b/tachometer.h index b2b623f..c084107 100644 --- a/tachometer.h +++ b/tachometer.h @@ -24,7 +24,9 @@ class Tachometer : public QDialog { void on_manual_threshold_2_clicked(bool checked); void on_manual_threshold_3_clicked(bool checked); void on_manual_threshold_4_clicked(bool checked); - private: + void on_radioButton_automatic_threshold_1_clicked(); + +private: Ui::Tachometer *ui; void UpdateData(std::shared_ptr &speed_data); // Tachometer_Variables tachometer_variables[4];