]> sigrok.org Git - pulseview.git/commitdiff
Added AwaitTrigger capture state
authorJoel Holdsworth <redacted>
Tue, 28 May 2013 19:36:11 +0000 (20:36 +0100)
committerJoel Holdsworth <redacted>
Tue, 28 May 2013 19:36:11 +0000 (20:36 +0100)
pv/mainwindow.cpp
pv/sigsession.cpp
pv/sigsession.h
pv/toolbars/samplingbar.cpp
pv/toolbars/samplingbar.h

index e70ca9891c565ca81891ef30e2f1b2246aa661d8..ca532ee2044ca598cbb1d99fefa6a29a354d3b42 100644 (file)
@@ -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()
index 793a5e8a894147073f2d91fe5143690cd1e1e10d..cbdbac07c2031d6232af8089bbf51b7f25d403ac 100644 (file)
@@ -164,8 +164,10 @@ boost::shared_ptr<data::Logic> SigSession::get_data()
 void SigSession::set_capture_state(capture_state state)
 {
        lock_guard<mutex> 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<void (const QString)> 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<data::LogicSnapshot>(
                        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<data::AnalogSnapshot>(
                        new data::AnalogSnapshot(analog));
index f4e3d4af34d70b21cebe96992fc8f755797fb8a1..6e23c63240b21489e4031d5b1f3066a72d5603e3 100644 (file)
@@ -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
index 0754f001e9a1828b3cd2fa66e7d8d9ee497da330..7d94594c1509765bce99f158d516d86f7ccfdb5d 100644 (file)
@@ -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<uint64_t>();
 }
 
-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()
index d24534bef185867883ec9657b5360011b1bafebb..1f40d0452ff6ca8d7265cc30703eab46bcf388d4 100644 (file)
@@ -30,6 +30,8 @@
 #include <QToolBar>
 #include <QToolButton>
 
+#include <pv/sigsession.h>
+
 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;