Commit ba34aeb9 authored by DreamSourceLab's avatar DreamSourceLab

Fix vertical scale issue after stop capturing @dso mode

parent c2384277
...@@ -116,6 +116,7 @@ SigSession::SigSession(DeviceManager &device_manager) : ...@@ -116,6 +116,7 @@ SigSession::SigSession(DeviceManager &device_manager) :
_math_trace = NULL; _math_trace = NULL;
_saving = false; _saving = false;
_dso_feed = false; _dso_feed = false;
_stop_scale = 1;
// Create snapshots & data containers // Create snapshots & data containers
_cur_logic_snapshot.reset(new data::LogicSnapshot()); _cur_logic_snapshot.reset(new data::LogicSnapshot());
...@@ -351,6 +352,7 @@ void SigSession::capture_init() ...@@ -351,6 +352,7 @@ void SigSession::capture_init()
set_cur_snap_samplerate(_dev_inst->get_sample_rate()); set_cur_snap_samplerate(_dev_inst->get_sample_rate());
set_cur_samplelimits(_dev_inst->get_sample_limit()); set_cur_samplelimits(_dev_inst->get_sample_limit());
set_stop_scale(1);
_data_updated = false; _data_updated = false;
_trigger_flag = false; _trigger_flag = false;
_trigger_ch = 0; _trigger_ch = 0;
...@@ -1781,4 +1783,31 @@ void SigSession::set_saving(bool saving) ...@@ -1781,4 +1783,31 @@ void SigSession::set_saving(bool saving)
_saving = saving; _saving = saving;
} }
void SigSession::exit_capture()
{
set_repeating(false);
bool wait_upload = false;
if (get_run_mode() != SigSession::Repetitive) {
GVariant *gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_WAIT_UPLOAD);
if (gvar != NULL) {
wait_upload = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
}
}
if (!wait_upload) {
stop_capture();
capture_state_changed(SigSession::Stopped);
}
}
float SigSession::stop_scale() const
{
return _stop_scale;
}
void SigSession::set_stop_scale(float scale)
{
_stop_scale = scale;
}
} // namespace pv } // namespace pv
...@@ -256,6 +256,10 @@ public: ...@@ -256,6 +256,10 @@ public:
uint64_t get_save_end() const; uint64_t get_save_end() const;
bool get_saving() const; bool get_saving() const;
void set_saving(bool saving); void set_saving(bool saving);
void set_stop_scale(float scale);
float stop_scale() const;
void exit_capture();
private: private:
void set_capture_state(capture_state state); void set_capture_state(capture_state state);
...@@ -367,6 +371,7 @@ private: ...@@ -367,6 +371,7 @@ private:
bool _saving; bool _saving;
bool _dso_feed; bool _dso_feed;
float _stop_scale;
signals: signals:
void capture_state_changed(int state); void capture_state_changed(int state);
......
...@@ -822,19 +822,7 @@ void SamplingBar::commit_settings() ...@@ -822,19 +822,7 @@ void SamplingBar::commit_settings()
void SamplingBar::on_run_stop() void SamplingBar::on_run_stop()
{ {
if (get_sampling() || _session.isRepeating()) { if (get_sampling() || _session.isRepeating()) {
_session.set_repeating(false); _session.exit_capture();
bool wait_upload = false;
if (_session.get_run_mode() != SigSession::Repetitive) {
GVariant *gvar = get_selected_device()->get_config(NULL, NULL, SR_CONF_WAIT_UPLOAD);
if (gvar != NULL) {
wait_upload = g_variant_get_boolean(gvar);
g_variant_unref(gvar);
}
}
if (!wait_upload) {
_session.stop_capture();
_session.capture_state_changed(SigSession::Stopped);
}
} else { } else {
enable_run_stop(false); enable_run_stop(false);
enable_instant(false); enable_instant(false);
......
...@@ -62,7 +62,6 @@ DsoSignal::DsoSignal(boost::shared_ptr<pv::device::DevInst> dev_inst, ...@@ -62,7 +62,6 @@ DsoSignal::DsoSignal(boost::shared_ptr<pv::device::DevInst> dev_inst,
Signal(dev_inst, probe), Signal(dev_inst, probe),
_data(data), _data(data),
_scale(0), _scale(0),
_stop_scale(1),
_en_lock(false), _en_lock(false),
_show(true), _show(true),
_vDialActive(false), _vDialActive(false),
...@@ -121,7 +120,7 @@ boost::shared_ptr<pv::data::Dso> DsoSignal::dso_data() const ...@@ -121,7 +120,7 @@ boost::shared_ptr<pv::data::Dso> DsoSignal::dso_data() const
void DsoSignal::set_scale(int height) void DsoSignal::set_scale(int height)
{ {
_scale = height / (_ref_max - _ref_min) * _stop_scale; _scale = height / (_ref_max - _ref_min) * _view->session().stop_scale();
} }
float DsoSignal::get_scale() float DsoSignal::get_scale()
...@@ -218,7 +217,7 @@ bool DsoSignal::go_vDialPre(bool manul) ...@@ -218,7 +217,7 @@ bool DsoSignal::go_vDialPre(bool manul)
_dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_VDIV, _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_VDIV,
g_variant_new_uint64(_vDial->get_value())); g_variant_new_uint64(_vDial->get_value()));
if (_view->session().get_capture_state() == SigSession::Stopped) { if (_view->session().get_capture_state() == SigSession::Stopped) {
_stop_scale *= pre_vdiv/_vDial->get_value(); _view->session().set_stop_scale(_view->session().stop_scale() * (pre_vdiv/_vDial->get_value()));
set_scale(get_view_rect().height()); set_scale(get_view_rect().height());
} }
_dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET, _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET,
...@@ -248,7 +247,7 @@ bool DsoSignal::go_vDialNext(bool manul) ...@@ -248,7 +247,7 @@ bool DsoSignal::go_vDialNext(bool manul)
_dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_VDIV, _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_VDIV,
g_variant_new_uint64(_vDial->get_value())); g_variant_new_uint64(_vDial->get_value()));
if (_view->session().get_capture_state() == SigSession::Stopped) { if (_view->session().get_capture_state() == SigSession::Stopped) {
_stop_scale *= pre_vdiv/_vDial->get_value(); _view->session().set_stop_scale(_view->session().stop_scale() * (pre_vdiv/_vDial->get_value()));
set_scale(get_view_rect().height()); set_scale(get_view_rect().height());
} }
_dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET, _dev_inst->set_config(_probe, NULL, SR_CONF_PROBE_OFFSET,
...@@ -839,9 +838,6 @@ void DsoSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QColor ...@@ -839,9 +838,6 @@ void DsoSignal::paint_mid(QPainter &p, int left, int right, QColor fore, QColor
assert(_view); assert(_view);
assert(right >= left); assert(right >= left);
if (_view->session().get_capture_state() == SigSession::Running)
_stop_scale = 1;
if (enabled()) { if (enabled()) {
const int index = get_index(); const int index = get_index();
const int width = right - left; const int width = right - left;
......
...@@ -232,7 +232,6 @@ private: ...@@ -232,7 +232,6 @@ private:
private: private:
boost::shared_ptr<pv::data::Dso> _data; boost::shared_ptr<pv::data::Dso> _data;
float _scale; float _scale;
float _stop_scale;
bool _en_lock; bool _en_lock;
bool _show; bool _show;
......
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