Commit f9f0507a authored by DreamSourceLab's avatar DreamSourceLab

improve synchronism between between data acquisition and wave display

parent 85c2ef62
......@@ -39,6 +39,8 @@ DSView/DSView
DSView/install_manifest.txt
DSView/qrc_DSView.cpp
DSView/qrc_style.cpp
DSView/qrc_breeze.cpp
DSView/qrc_language.cpp
moc_*.cpp
moc_*.cpp_parameters
......
......@@ -195,6 +195,7 @@ void DsoSnapshot::enable_envelope(bool enable)
const uint8_t *DsoSnapshot::get_samples(
int64_t start_sample, int64_t end_sample, uint16_t index) const
{
boost::lock_guard<boost::recursive_mutex> lock(_mutex);
(void)end_sample;
assert(start_sample >= 0);
......
......@@ -109,10 +109,13 @@ void MathStack::free_envelop()
void MathStack::clear()
{
boost::lock_guard<boost::recursive_mutex> lock(_mutex);
}
void MathStack::init()
{
boost::lock_guard<boost::recursive_mutex> lock(_mutex);
_sample_num = 0;
_envelope_done = false;
}
......@@ -312,6 +315,8 @@ void MathStack::get_math_envelope_section(EnvelopeSection &s,
void MathStack::calc_math()
{
boost::lock_guard<boost::recursive_mutex> lock(_mutex);
_math_state = Running;
const boost::shared_ptr<pv::data::Dso> data = _dsoSig1->dso_data();
......
......@@ -25,6 +25,7 @@
#define DSVIEW_PV_DATA_SIGNALDATA_H
#include <stdint.h>
#include <boost/thread.hpp>
namespace pv {
namespace data {
......@@ -43,6 +44,8 @@ public:
virtual void init() = 0;
protected:
mutable boost::recursive_mutex _mutex;
double _samplerate;
};
......
......@@ -105,7 +105,7 @@ SigSession::SigSession(DeviceManager &device_manager) :
_hot_detach = false;
_group_cnt = 0;
register_hotplug_callback();
_view_timer.stop();
_feed_timer.stop();
_noData_cnt = 0;
_data_lock = false;
_data_updated = false;
......@@ -129,7 +129,7 @@ SigSession::SigSession(DeviceManager &device_manager) :
_group_data.reset(new data::Group());
_group_cnt = 0;
connect(&_view_timer, SIGNAL(timeout()), this, SLOT(check_update()));
connect(&_feed_timer, SIGNAL(timeout()), this, SLOT(data_unlock()));
}
SigSession::~SigSession()
......@@ -354,9 +354,10 @@ void SigSession::capture_init()
_trigger_flag = false;
_hw_replied = false;
if (_dev_inst->dev_inst()->mode != LOGIC)
_view_timer.start(ViewTime);
_feed_timer.start(FeedInterval);
else
_view_timer.stop();
_feed_timer.stop();
_noData_cnt = 0;
data_unlock();
......@@ -587,7 +588,9 @@ void SigSession::sample_thread_proc(boost::shared_ptr<device::DevInst> dev_inst,
void SigSession::check_update()
{
data_unlock();
boost::lock_guard<boost::mutex> lock(_data_mutex);
//data_unlock(); unlock after wave rendering
if (_capture_state != Running)
return;
......@@ -597,7 +600,7 @@ void SigSession::check_update()
_noData_cnt = 0;
data_auto_unlock();
} else {
if (++_noData_cnt >= (WaitShowTime/ViewTime))
if (++_noData_cnt >= (WaitShowTime/FeedInterval))
nodata_timeout();
}
}
......@@ -1070,7 +1073,7 @@ void SigSession::feed_in_dso(const sr_datafeed_dso &dso)
_trigger_flag = dso.trig_flag;
receive_data(dso.num_samples);
//data_updated();
if (!_instant)
data_lock();
_data_updated = true;
......
......@@ -102,7 +102,7 @@ private:
static const int RepeatHoldDiv = 20;
public:
static const int ViewTime = 50;
static const int FeedInterval = 50;
static const int WaitShowTime = 500;
public:
......@@ -337,7 +337,7 @@ private:
bool _hot_attach;
bool _hot_detach;
QTimer _view_timer;
QTimer _feed_timer;
int _noData_cnt;
bool _data_lock;
bool _data_updated;
......@@ -413,6 +413,7 @@ public slots:
void reload();
void refresh(int holdtime);
void stop_capture();
void check_update();
// repeat
void set_repeating(bool repeat);
void set_map_zoom(int index);
......@@ -422,7 +423,6 @@ public slots:
private slots:
void data_lock();
void data_unlock();
void check_update();
void nodata_timeout();
void repeat_update();
......
......@@ -141,6 +141,7 @@ void Viewport::paintEvent(QPaintEvent *event)
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &o, &p, this);
_view.session().check_update();
QColor fore(QWidget::palette().color(QWidget::foregroundRole()));
QColor back(QWidget::palette().color(QWidget::backgroundRole()));
fore.setAlpha(View::ForeAlpha);
......@@ -328,7 +329,7 @@ void Viewport::paintSignals(QPainter &p, QColor fore, QColor back)
} else if (_waiting_trig > 0) {
type_str = "Waiting Trig";
for (int i = 1; i < _waiting_trig; i++)
if (i % (WaitLoopTime / SigSession::ViewTime) == 0)
if (i % (WaitLoopTime / SigSession::FeedInterval) == 0)
type_str += ".";
} else {
type_str = "Trig'd";
......@@ -1613,7 +1614,7 @@ void Viewport::set_need_update(bool update)
void Viewport::show_wait_trigger()
{
_waiting_trig %= (WaitLoopTime / SigSession::ViewTime) * 4;
_waiting_trig %= (WaitLoopTime / SigSession::FeedInterval) * 4;
_waiting_trig++;
update();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment