From: Joel Holdsworth Date: Tue, 28 May 2013 19:36:11 +0000 (+0100) Subject: Added AwaitTrigger capture state X-Git-Tag: pulseview-0.2.0~334 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=2b49eeb02d92b4744f8ebfcfd38ef27384cdd751;p=pulseview.git Added AwaitTrigger capture state --- diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index e70ca989..ca532ee2 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -355,6 +355,7 @@ void MainWindow::run_stop() QString("Capture failed"), _1)); break; + case SigSession::AwaitingTrigger: case SigSession::Running: _session.stop_capture(); break; @@ -363,7 +364,7 @@ void MainWindow::run_stop() void MainWindow::capture_state_changed(int state) { - _sampling_bar->set_sampling(state != SigSession::Stopped); + _sampling_bar->set_capture_state((pv::SigSession::capture_state)state); } void MainWindow::view_selection_changed() diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index 793a5e8a..cbdbac07 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -164,8 +164,10 @@ boost::shared_ptr SigSession::get_data() void SigSession::set_capture_state(capture_state state) { lock_guard lock(_sampling_mutex); + const bool changed = _capture_state != state; _capture_state = state; - capture_state_changed(state); + if(changed) + capture_state_changed(state); } /** @@ -323,6 +325,19 @@ void SigSession::update_signals() signals_changed(); } +bool SigSession::is_trigger_enabled() const +{ + assert(_sdi); + for (const GSList *l = _sdi->probes; l; l = l->next) { + const sr_probe *const p = (const sr_probe *)l->data; + assert(p); + if (p->trigger && p->trigger[0] != '\0') + return true; + } + + return false; +} + void SigSession::load_thread_proc(const string name, function error_handler) { @@ -387,7 +402,7 @@ void SigSession::sample_thread_proc(struct sr_dev_inst *sdi, return; } - set_capture_state(Running); + set_capture_state(is_trigger_enabled() ? AwaitingTrigger : Running); sr_session_run(); sr_session_destroy(); @@ -455,6 +470,8 @@ void SigSession::feed_in_logic(const sr_datafeed_logic &logic) if (!_cur_logic_snapshot) { + set_capture_state(Running); + // Create a new data snapshot _cur_logic_snapshot = shared_ptr( new data::LogicSnapshot(logic)); @@ -481,6 +498,8 @@ void SigSession::feed_in_analog(const sr_datafeed_analog &analog) if (!_cur_analog_snapshot) { + set_capture_state(Running); + // Create a new data snapshot _cur_analog_snapshot = shared_ptr( new data::AnalogSnapshot(analog)); diff --git a/pv/sigsession.h b/pv/sigsession.h index f4e3d4af..6e23c632 100644 --- a/pv/sigsession.h +++ b/pv/sigsession.h @@ -56,6 +56,7 @@ class SigSession : public QObject public: enum capture_state { Stopped, + AwaitingTrigger, Running }; @@ -93,6 +94,8 @@ private: void update_signals(); + bool is_trigger_enabled() const; + private: /** * Attempts to autodetect the format. Failing that diff --git a/pv/toolbars/samplingbar.cpp b/pv/toolbars/samplingbar.cpp index 0754f001..7d94594c 100644 --- a/pv/toolbars/samplingbar.cpp +++ b/pv/toolbars/samplingbar.cpp @@ -70,6 +70,7 @@ SamplingBar::SamplingBar(QWidget *parent) : _configure_button(this), _record_length_selector(this), _sample_rate_list(this), + _icon_red(":/icons/status-red.svg"), _icon_green(":/icons/status-green.svg"), _icon_grey(":/icons/status-grey.svg"), _run_stop_button(this) @@ -96,7 +97,7 @@ SamplingBar::SamplingBar(QWidget *parent) : _record_length_selector.setCurrentIndex(i); } - set_sampling(false); + set_capture_state(pv::SigSession::Stopped); _configure_button.setIcon(QIcon::fromTheme("configure", QIcon(":/icons/configure.png"))); @@ -158,10 +159,12 @@ uint64_t SamplingBar::get_record_length() const return _record_length_selector.itemData(index).value(); } -void SamplingBar::set_sampling(bool sampling) +void SamplingBar::set_capture_state(pv::SigSession::capture_state state) { - _run_stop_button.setIcon(sampling ? _icon_green : _icon_grey); - _run_stop_button.setText(sampling ? "Stop" : "Run"); + const QIcon *icons[] = {&_icon_grey, &_icon_red, &_icon_green}; + _run_stop_button.setIcon(*icons[state]); + _run_stop_button.setText((state == pv::SigSession::Stopped) ? + tr("Run") : tr("Stop")); } void SamplingBar::update_sample_rate_selector() diff --git a/pv/toolbars/samplingbar.h b/pv/toolbars/samplingbar.h index d24534be..1f40d045 100644 --- a/pv/toolbars/samplingbar.h +++ b/pv/toolbars/samplingbar.h @@ -30,6 +30,8 @@ #include #include +#include + struct st_dev_inst; class QAction; @@ -54,7 +56,7 @@ public: uint64_t get_record_length() const; - void set_sampling(bool sampling); + void set_capture_state(pv::SigSession::capture_state state); signals: void device_selected(); @@ -83,6 +85,7 @@ private: QDoubleSpinBox _sample_rate_value; QAction *_sample_rate_value_action; + QIcon _icon_red; QIcon _icon_green; QIcon _icon_grey; QToolButton _run_stop_button;