update: Repetitive mode can works with 0.1 interval

This commit is contained in:
dreamsourcelabTAI 2022-05-20 13:40:01 +08:00
parent 253c35bee4
commit bf07f1cc15
4 changed files with 43 additions and 17 deletions

View File

@ -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

View File

@ -24,7 +24,7 @@
#define DSVIEW_PV_INTERVAL_H
#include <QLabel>
#include <QSpinBox>
#include <QDoubleSpinBox>
#include <QSlider>
#include <QDialogButtonBox>
@ -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

View File

@ -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)

View File

@ -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;