添加代码

This commit is contained in:
zhangsheng 2025-04-22 10:11:18 +08:00
parent c5a57c9678
commit 9f3b468afc
7 changed files with 119 additions and 5 deletions

View File

@ -270,6 +270,7 @@ void ConfigMgr::Save(QString & file_path) {
channel_item.insert("threshold", ptr->variables_[cid].threshold); channel_item.insert("threshold", ptr->variables_[cid].threshold);
channel_item.insert("hysteresis", ptr->variables_[cid].hysteresis); channel_item.insert("hysteresis", ptr->variables_[cid].hysteresis);
channel_item.insert("events_per_revolution", ptr->variables_[cid].events_per_revolution); 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; 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].normal_latching = channel["normal_latching"].toBool();
speed_data->variables_[j].speed_peek = channel["speed_peak"].toInt(); speed_data->variables_[j].speed_peek = channel["speed_peak"].toInt();
speed_data->variables_[j].default_speed = channel["default_speed"].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(); 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].threshold = channel["threshold"].toDouble();
keyphase_data->variables_[j].hysteresis = channel["hysteresis"].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].events_per_revolution = channel["events_per_revolution"].toInt();
keyphase_data->variables_[j].automatic_threshold = channel["automatic_threshold"].toBool();
} }
cards_.push_back(keyphase_data); cards_.push_back(keyphase_data);
}else if (card_type_[i] == kCardRelaySingleNOK ){ }else if (card_type_[i] == kCardRelaySingleNOK ){

View File

@ -193,3 +193,75 @@ void KeyPhase::on_pushButton_confirm_clicked() {
this->close(); 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);
}
}

View File

@ -23,6 +23,22 @@ class KeyPhase : public QDialog {
void on_manual_threshold_2_clicked(bool checked); void on_manual_threshold_2_clicked(bool checked);
void on_manual_threshold_3_clicked(bool checked); void on_manual_threshold_3_clicked(bool checked);
void on_manual_threshold_4_clicked(bool checked); void on_manual_threshold_4_clicked(bool checked);
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: private:
Ui::KeyPhase *ui; Ui::KeyPhase *ui;
void UpdateData(std::shared_ptr<KeyphaseData> &keyphase_data); void UpdateData(std::shared_ptr<KeyphaseData> &keyphase_data);

View File

@ -109,7 +109,7 @@
</rect> </rect>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<attribute name="title"> <attribute name="title">
@ -933,7 +933,7 @@
</rect> </rect>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="tab_5"> <widget class="QWidget" name="tab_5">
<attribute name="title"> <attribute name="title">

View File

@ -482,7 +482,6 @@ void MainWindow::OnButtonGroup(QAbstractButton *slot_btn) {
setpoint_tachometer->show(); setpoint_tachometer->show();
break; break;
} }
} }
} }
} }

View File

@ -174,8 +174,12 @@ void Tachometer::Init() {
ui->default_value_1->setValue(speed_data->variables_[i].default_speed); ui->default_value_1->setValue(speed_data->variables_[i].default_speed);
if (speed_data->variables_[i].automatic_threshold) { if (speed_data->variables_[i].automatic_threshold) {
ui->radioButton_automatic_threshold_1->setChecked(true); ui->radioButton_automatic_threshold_1->setChecked(true);
ui->doubleSpinBox_threshold_1->setEnabled(false);
ui->doubleSpinBox_hysteresis_1->setEnabled(false);
} else { } else {
ui->radioButton_manual_threshold_1->setChecked(true); 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_threshold_1->setValue(speed_data->variables_[i].threshold);
ui->doubleSpinBox_hysteresis_1->setValue(speed_data->variables_[i].hysteresis); 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); ui->default_value_2->setValue(speed_data->variables_[i].default_speed);
if (speed_data->variables_[i].automatic_threshold) { if (speed_data->variables_[i].automatic_threshold) {
ui->radioButton_automatic_threshold_2->setChecked(true); ui->radioButton_automatic_threshold_2->setChecked(true);
ui->doubleSpinBox_threshold_2->setEnabled(false);
ui->doubleSpinBox_hysteresis_2->setEnabled(false);
} else { } else {
ui->radioButton_manual_threshold_2->setChecked(true); 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_threshold_2->setValue(speed_data->variables_[i].threshold);
ui->doubleSpinBox_hysteresis_2->setValue(speed_data->variables_[i].hysteresis); 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); ui->default_value_3->setValue(speed_data->variables_[i].default_speed);
if (speed_data->variables_[i].automatic_threshold) { if (speed_data->variables_[i].automatic_threshold) {
ui->radioButton_automatic_threshold_3->setChecked(true); ui->radioButton_automatic_threshold_3->setChecked(true);
ui->doubleSpinBox_threshold_3->setEnabled(false);
ui->doubleSpinBox_hysteresis_3->setEnabled(false);
} else { } else {
ui->radioButton_manual_threshold_3->setChecked(true); 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_threshold_3->setValue(speed_data->variables_[i].threshold);
ui->doubleSpinBox_hysteresis_3->setValue(speed_data->variables_[i].hysteresis); 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); ui->default_value_4->setValue(speed_data->variables_[i].default_speed);
if (speed_data->variables_[i].automatic_threshold) { if (speed_data->variables_[i].automatic_threshold) {
ui->radioButton_automatic_threshold_4->setChecked(true); ui->radioButton_automatic_threshold_4->setChecked(true);
ui->doubleSpinBox_threshold_4->setEnabled(false);
ui->doubleSpinBox_hysteresis_4->setEnabled(false);
} else { } else {
ui->radioButton_manual_threshold_4->setChecked(true); 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_threshold_4->setValue(speed_data->variables_[i].threshold);
ui->doubleSpinBox_hysteresis_4->setValue(speed_data->variables_[i].hysteresis); 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() { void Tachometer::on_pushButton_cancel_clicked() {
this->close(); this->close();
} }
void Tachometer::on_radioButton_automatic_threshold_1_clicked()
{
}

View File

@ -24,6 +24,8 @@ class Tachometer : public QDialog {
void on_manual_threshold_2_clicked(bool checked); void on_manual_threshold_2_clicked(bool checked);
void on_manual_threshold_3_clicked(bool checked); void on_manual_threshold_3_clicked(bool checked);
void on_manual_threshold_4_clicked(bool checked); void on_manual_threshold_4_clicked(bool checked);
void on_radioButton_automatic_threshold_1_clicked();
private: private:
Ui::Tachometer *ui; Ui::Tachometer *ui;
void UpdateData(std::shared_ptr<TachometerData> &speed_data); void UpdateData(std::shared_ptr<TachometerData> &speed_data);