From bf07f1cc1510bcf24996e422171ab5dcb9719f6c Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Fri, 20 May 2022 13:40:01 +0800 Subject: [PATCH] update: Repetitive mode can works with 0.1 interval --- DSView/pv/dialogs/interval.cpp | 37 ++++++++++++++++++++++++++-------- DSView/pv/dialogs/interval.h | 9 +++++++-- DSView/pv/sigsession.cpp | 8 ++++---- DSView/pv/sigsession.h | 6 +++--- 4 files changed, 43 insertions(+), 17 deletions(-) diff --git a/DSView/pv/dialogs/interval.cpp b/DSView/pv/dialogs/interval.cpp index 1304bdd5..ee53ec3e 100755 --- a/DSView/pv/dialogs/interval.cpp +++ b/DSView/pv/dialogs/interval.cpp @@ -35,17 +35,19 @@ Interval::Interval(SigSession *session, QWidget *parent) : _interval_label = NULL; _interval_spinBox = NULL; _interval_slider = NULL; - + _bSetting = false; setMinimumWidth(300); _interval_label = new QLabel(tr("Interval(s): "), this); - _interval_spinBox = new QSpinBox(this); - _interval_spinBox->setRange(1, 10); + _interval_spinBox = new QDoubleSpinBox(this); + _interval_spinBox->setRange(0.1, 10); + _interval_spinBox->setDecimals(1); _interval_spinBox->setButtonSymbols(QAbstractSpinBox::NoButtons); _interval_slider = new QSlider(Qt::Horizontal, this); - _interval_slider->setRange(1, 10); + _interval_slider->setRange(0, 10); - _interval_slider->setValue(_session->get_repeat_intvl()); + _interval_slider->setValue((int)_session->get_repeat_intvl()); + _interval_spinBox->setValue(_session->get_repeat_intvl()); QGridLayout *glayout = new QGridLayout(this); glayout->addWidget(_interval_label, 0, 0); @@ -57,14 +59,14 @@ Interval::Interval(SigSession *session, QWidget *parent) : setTitle(tr("Repetitive Interval")); connect(&_button_box, SIGNAL(accepted()), this, SLOT(accept())); - connect(_interval_slider, SIGNAL(valueChanged(int)), _interval_spinBox, SLOT(setValue(int))); - connect(_interval_spinBox, SIGNAL(valueChanged(int)), _interval_slider, SLOT(setValue(int))); + connect(_interval_slider, SIGNAL(valueChanged(int)), this, SLOT(on_slider_changed(int))); + connect(_interval_spinBox, SIGNAL(valueChanged(double)), this, SLOT(on_inputbox_changed(double))); } void Interval::accept() { using namespace Qt; - _session->set_repeat_intvl(_interval_slider->value()); + _session->set_repeat_intvl(_interval_spinBox->value()); QDialog::accept(); } @@ -75,6 +77,25 @@ void Interval::reject() QDialog::reject(); } +void Interval::on_slider_changed(int value) +{ + if (!_bSetting){ + _bSetting = true; + _interval_spinBox->setValue((double)value); + _bSetting = false; + } + +} + +void Interval::on_inputbox_changed(double value) +{ + if (!_bSetting){ + _bSetting = true; + _interval_slider->setValue((int)value); + _bSetting = false; + } + +} } // namespace dialogs } // namespace pv diff --git a/DSView/pv/dialogs/interval.h b/DSView/pv/dialogs/interval.h index 9e3c0c40..421b9d2a 100755 --- a/DSView/pv/dialogs/interval.h +++ b/DSView/pv/dialogs/interval.h @@ -24,7 +24,7 @@ #define DSVIEW_PV_INTERVAL_H #include -#include +#include #include #include @@ -46,14 +46,19 @@ protected: void accept(); void reject(); +private Q_SLOTS: + void on_slider_changed(int value); + void on_inputbox_changed(double value); + private: SigSession *_session; QLabel *_interval_label; - QSpinBox *_interval_spinBox; + QDoubleSpinBox *_interval_spinBox; QSlider *_interval_slider; QDialogButtonBox _button_box; + bool _bSetting; }; } // namespace dialogs diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index 416bd570..35e11b30 100755 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -1632,12 +1632,12 @@ void SigSession::set_run_mode(run_mode mode) _run_mode = mode; } -int SigSession::get_repeat_intvl() +double SigSession::get_repeat_intvl() { return _repeat_intvl; } -void SigSession::set_repeat_intvl(int interval) +void SigSession::set_repeat_intvl(double interval) { _repeat_intvl = interval; } @@ -1665,7 +1665,7 @@ bool SigSession::repeat_check() if (_dev_inst->dev_inst()->mode == LOGIC) { _repeat_hold_prg = 100; _callback->repeat_hold(_repeat_hold_prg); - _out_timer.TimeOut(_repeat_intvl*1000/RepeatHoldDiv, std::bind(&SigSession::repeat_update, this)); + _out_timer.TimeOut(_repeat_intvl * 1000 / RepeatHoldDiv, std::bind(&SigSession::repeat_update, this)); return true; } else { return false; @@ -1677,7 +1677,7 @@ void SigSession::repeat_update() if (isRepeating()) { _repeat_hold_prg -= 100/RepeatHoldDiv; if (_repeat_hold_prg != 0){ - _out_timer.TimeOut(_repeat_intvl*1000/RepeatHoldDiv, std::bind(&SigSession::repeat_update, this)); + _out_timer.TimeOut(_repeat_intvl * 1000 / RepeatHoldDiv, std::bind(&SigSession::repeat_update, this)); } _callback->repeat_hold(_repeat_hold_prg); if (_repeat_hold_prg == 0) diff --git a/DSView/pv/sigsession.h b/DSView/pv/sigsession.h index b3d88a17..73b0d6e6 100755 --- a/DSView/pv/sigsession.h +++ b/DSView/pv/sigsession.h @@ -210,8 +210,8 @@ public: uint64_t get_error_pattern(); run_mode get_run_mode(); void set_run_mode(run_mode mode); - int get_repeat_intvl(); - void set_repeat_intvl(int interval); + double get_repeat_intvl(); + void set_repeat_intvl(double interval); bool isRepeating(); bool repeat_check(); @@ -400,7 +400,7 @@ private: uint64_t _error_pattern; run_mode _run_mode; - int _repeat_intvl; + double _repeat_intvl; bool _repeating; int _repeat_hold_prg;