2
0
forked from Ivasoft/DSView

Control real-time refresh timer interval

This commit is contained in:
dreamsourcelabTAI
2022-12-16 19:46:28 +08:00
parent 747c750d19
commit 2a5ea67887
11 changed files with 107 additions and 35 deletions

View File

@@ -532,6 +532,9 @@ bool LogicSnapshot::get_display_edges(std::vector<std::pair<bool, bool> > &edges
if (_ring_sample_count == 0)
return false;
if (_sample_count > _ring_sample_count)
dsv_info("_sample_count > _ring_sample_count");
assert(end < _ring_sample_count);
assert(start <= end);
assert(min_length > 0);

View File

@@ -75,6 +75,12 @@ uint64_t Snapshot::get_sample_count()
std::lock_guard<std::mutex> lock(_mutex);
return _sample_count;
}
uint64_t Snapshot::get_ring_sample_count()
{
std::lock_guard<std::mutex> lock(_mutex);
return _ring_sample_count;
}
uint64_t Snapshot::get_ring_start()
{

View File

@@ -40,6 +40,7 @@ public:
virtual void init() = 0;
uint64_t get_sample_count();
uint64_t get_ring_sample_count();
uint64_t get_ring_start();
uint64_t get_ring_end();

View File

@@ -85,6 +85,8 @@ namespace pv
_data_lock = false;
_data_updated = false;
_opt_mode = OPT_SINGLE;
_rt_refresh_time_id = 0;
_rt_ck_refresh_time_id = 0;
this->add_msg_listener(this);
@@ -113,6 +115,7 @@ namespace pv
_feed_timer.SetCallback(std::bind(&SigSession::feed_timeout, this));
_repeat_timer.SetCallback(std::bind(&SigSession::repeat_capture_wait_timeout, this));
_repeat_wait_prog_timer.SetCallback(std::bind(&SigSession::repeat_wait_prog_timeout, this));
_refresh_rt_timer.SetCallback(std::bind(&SigSession::realtime_refresh_timeout, this));
}
SigSession::SigSession(SigSession &o)
@@ -374,6 +377,8 @@ namespace pv
_trigger_flag = false;
_trigger_ch = 0;
_hw_replied = false;
_rt_refresh_time_id = 0;
_rt_ck_refresh_time_id = 0;
int work_mode = _device_agent.get_work_mode();
if (work_mode == DSO || work_mode == ANALOG)
@@ -472,6 +477,10 @@ namespace pv
_capture_time_id++;
_is_working = true;
_callback->trigger_message(DSV_MSG_START_COLLECT_WORK);
if (is_realtime_mode()){
_refresh_rt_timer.Start(1000 / 30);
}
return true;
}
@@ -528,6 +537,7 @@ namespace pv
_is_working = false;
_repeat_timer.Stop();
_repeat_wait_prog_timer.Stop();
_refresh_rt_timer.Stop();
exit_capture();
return;
}
@@ -548,6 +558,7 @@ namespace pv
_is_working = false;
_repeat_timer.Stop();
_repeat_wait_prog_timer.Stop();
_refresh_rt_timer.Stop();
if (_repeat_hold_prg != 0 && is_repeat_mode()){
_repeat_hold_prg = 0;
@@ -635,7 +646,6 @@ namespace pv
if (_data_updated)
{
data_updated();
_data_updated = false;
_noData_cnt = 0;
data_auto_unlock();
@@ -2001,4 +2011,20 @@ namespace pv
return false;
}
void SigSession::realtime_refresh_timeout()
{
_rt_refresh_time_id++;
}
bool SigSession::have_new_realtime_refresh(bool keep)
{
if (_rt_ck_refresh_time_id != _rt_refresh_time_id){
if (!keep){
_rt_ck_refresh_time_id = _rt_refresh_time_id;
}
return true;
}
return false;
}
} // namespace pv

View File

@@ -367,6 +367,7 @@ public:
void add_msg_listener(IMessageListener *ln);
void broadcast_msg(int msg);
bool switch_work_mode(int mode);
bool have_new_realtime_refresh(bool keep);
private:
void set_cur_samplelimits(uint64_t samplelimits);
@@ -441,6 +442,7 @@ private:
void repeat_capture_wait_timeout();
void repeat_wait_prog_timeout();
void realtime_refresh_timeout();
private:
mutable std::mutex _sampling_mutex;
@@ -470,6 +472,7 @@ private:
DsTimer _out_timer;
DsTimer _repeat_timer;
DsTimer _repeat_wait_prog_timer;
DsTimer _refresh_rt_timer;
int _noData_cnt;
bool _data_lock;
bool _data_updated;
@@ -499,6 +502,8 @@ private:
int _device_status;
int _capture_time_id;
int _confirm_store_time_id;
uint64_t _rt_refresh_time_id;
uint64_t _rt_ck_refresh_time_id;
COLLECT_OPT_MODE _opt_mode;

View File

@@ -238,14 +238,15 @@ namespace pv
{
QString iconPath = GetIconPath();
_configure_button.setIcon(QIcon(iconPath + "/params.svg"));
QString icon1 = _session->is_repeat_mode() ? "moder.svg" : "modes.svg";
_mode_button.setIcon(QIcon(iconPath + "/" + icon1));
QString icon2 = _session->is_working() ? "stop.svg" : "start.svg";
_run_stop_button.setIcon(QIcon(iconPath + "/" + icon2));
_instant_button.setIcon(QIcon(iconPath + "/single.svg"));
_action_single->setIcon(QIcon(iconPath + "/oneloop.svg"));
_action_repeat->setIcon(QIcon(iconPath + "/repeat.svg"));
_action_realtime->setIcon(QIcon(iconPath + "/update.svg"));
update_mode_icon();
}
}
@@ -1031,8 +1032,7 @@ namespace pv
else
{
QString icon = _session->is_repeat_mode() ? "/moder.svg" : "/modes.svg";
_mode_button.setIcon(QIcon(iconPath + icon));
update_mode_icon();
_mode_action->setVisible(true);
}
_run_stop_action->setVisible(true);
@@ -1062,13 +1062,11 @@ namespace pv
QAction *act = qobject_cast<QAction *>(sender());
if (act == _action_single)
{
_mode_button.setIcon(QIcon(iconPath + "/modes.svg"));
{
_session->set_operation_mode(OPT_SINGLE);
}
else if (act == _action_repeat)
{
_mode_button.setIcon(QIcon(iconPath + "/moder.svg"));
{
pv::dialogs::Interval interval_dlg(this);
interval_dlg.set_interval(_session->get_repeat_intvl());
@@ -1081,10 +1079,11 @@ namespace pv
}
}
else if (act == _action_realtime)
{
_mode_button.setIcon(QIcon(iconPath + "/update.svg"));
{
_session->set_operation_mode(OPT_REALTIME);
}
update_mode_icon();
}
void SamplingBar::update_device_list()
@@ -1181,14 +1180,14 @@ namespace pv
_instant_button.setIcon(!bEnable ? QIcon(iconPath + "/stop.svg") : QIcon(iconPath + "/single.svg"));
else
_run_stop_button.setIcon(!bEnable ? QIcon(iconPath + "/stop.svg") : QIcon(iconPath + "/start.svg"));
_mode_button.setIcon(_session->is_repeat_mode() == false ? QIcon(iconPath + "/modes.svg") : QIcon(iconPath + "/moder.svg"));
retranslateUi();
if (bEnable){
_is_run_as_instant = false;
}
}
update_mode_icon();
}
ds_device_handle SamplingBar::get_next_device_handle()
@@ -1198,5 +1197,17 @@ namespace pv
return h;
}
void SamplingBar::update_mode_icon()
{
QString iconPath = GetIconPath();
if (_session->is_repeat_mode())
_mode_button.setIcon(QIcon(iconPath + "/moder.svg"));
else if (_session->is_realtime_mode())
_mode_button.setIcon(QIcon(iconPath + "/update.svg"));
else
_mode_button.setIcon(QIcon(iconPath + "/modes.svg"));
}
} // namespace toolbars
} // namespace pv

View File

@@ -103,6 +103,7 @@ namespace pv
void commit_settings();
void setting_adj();
void enable_toggle(bool enable);
void update_mode_icon();
private slots:
void on_mode();

View File

@@ -145,7 +145,7 @@ void LogicSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QColo
if (!snapshot->has_data(_probe->index))
return;
const int64_t last_sample = snapshot->get_sample_count() - 1;
const int64_t last_sample = snapshot->get_ring_sample_count() - 1;
const double samples_per_pixel = samplerate * scale;
uint16_t width = right - left;

View File

@@ -1332,7 +1332,7 @@ void View::set_receive_len(uint64_t len)
if (_time_viewport)
_time_viewport->set_receive_len(len);
if (_fft_viewport)
if (_fft_viewport && _session->get_device()->get_work_mode() == DSO)
_fft_viewport->set_receive_len(len);
}

View File

@@ -138,11 +138,19 @@ bool Viewport::event(QEvent *event)
}
void Viewport::paintEvent(QPaintEvent *event)
{
(void)event;
{
(void)event;
doPaint(true);
}
void Viewport::doPaint(bool bForce)
{
using pv::view::Signal;
// if (_view.session().is_stopped_status())
// dsv_info("paint");
QStyleOption o;
o.initFrom(this);
QPainter p(this);
@@ -153,7 +161,7 @@ void Viewport::paintEvent(QPaintEvent *event)
QColor back(QWidget::palette().color(QWidget::backgroundRole()));
fore.setAlpha(View::ForeAlpha);
_view.set_back(false);
std::vector<Trace*> traces;
_view.get_traces(_type, traces);
@@ -166,11 +174,15 @@ void Viewport::paintEvent(QPaintEvent *event)
if (_view.session().get_device()->get_work_mode() == LOGIC ||
_view.session().is_instant())
{
if (_view.session().is_stopped_status()
|| _view.session().is_realtime_mode())
if (_view.session().is_stopped_status())
{
paintSignals(p, fore, back);
}
else if (_view.session().is_realtime_mode())
{
if (_view.session().have_new_realtime_refresh(false) || bForce)
paintSignals(p, fore, back);
}
else if (_view.session().is_running_status()){
if (_view.session().is_repeat_mode() && !_transfer_started) {
_view.set_capture_status();
@@ -735,20 +747,21 @@ void Viewport::mouseMoveEvent(QMouseEvent *event)
_mouse_point = event->pos();
measure();
update();
}
void Viewport::mouseReleaseEvent(QMouseEvent *event)
{
assert(event);
assert(event);
bool quickScroll = AppConfig::Instance()._appOptions.quickScroll;
bool isMaxWindow = AppControl::Instance()->TopWindowIsMaximized();
bool quickScroll = AppConfig::Instance()._appOptions.quickScroll;
bool isMaxWindow = AppControl::Instance()->TopWindowIsMaximized();
if (_type != TIME_VIEW){
update();
return;
}
if (_type != TIME_VIEW){
update();
return;
}
if ((_action_type == NO_ACTION) && (event->button() == Qt::LeftButton))
{
@@ -1000,6 +1013,7 @@ void Viewport::mouseDoubleClickEvent(QMouseEvent *event)
_view.add_cursor(view::Ruler::CursorColor[_view.get_cursorList().size() % 8], index);
_view.show_cursors(true);
}
update();
}
else if (_view.session().get_device()->get_work_mode() == DSO
@@ -1189,6 +1203,12 @@ void Viewport::set_receive_len(quint64 length)
else
_sample_received += length;
}
if (_view.session().is_realtime_mode() && _view.session().have_new_realtime_refresh(true) == false){
return;
}
// Received new data, and refresh the view.
update();
}
@@ -1714,7 +1734,7 @@ void Viewport::show_wait_trigger()
}
void Viewport::unshow_wait_trigger()
{
{
_waiting_trig = 0;
update();
}

View File

@@ -100,12 +100,16 @@ public:
void clear_dso_xm();
void set_need_update(bool update);
bool get_dso_trig_moved();
void set_receive_len(quint64 length);
void unshow_wait_trigger();
void show_wait_trigger();
protected:
bool event(QEvent *event) override;
void paintEvent(QPaintEvent *event) override;
private:
void doPaint(bool bForce);
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
@@ -129,11 +133,6 @@ private slots:
void add_cursor_x();
void add_cursor_y();
public slots:
void show_wait_trigger();
void unshow_wait_trigger();
void set_receive_len(quint64 length);
signals:
void measure_updated();
void prgRate(int progress);