]> sigrok.org Git - pulseview.git/commitdiff
Added record length selector
authorJoel Holdsworth <redacted>
Sat, 7 Jul 2012 08:41:17 +0000 (09:41 +0100)
committerJoel Holdsworth <redacted>
Mon, 3 Sep 2012 12:59:06 +0000 (13:59 +0100)
mainwindow.cpp
samplingbar.cpp
samplingbar.h
sigsession.cpp
sigsession.h

index 510e552af9b1e751e6b44f4d04dc33363e9c627f..3390e183e0b4b89617f6abdfa88b6fab6b650ae8 100644 (file)
@@ -79,5 +79,6 @@ void MainWindow::run_stop()
 {
        _session.start_capture(
                _sampling_bar->get_selected_device(),
+               _sampling_bar->get_record_length(),
                _sampling_bar->get_sample_rate());
 }
index acb106466b961e7084667b053d9bea6cb8d90ac8..711f6f4eae92ebc265d63c1d321f8d81f61cb391 100644 (file)
@@ -20,6 +20,8 @@
 
 #include <assert.h>
 
+#include <boost/foreach.hpp>
+
 extern "C" {
 #include <libsigrok/libsigrok.h>
 }
@@ -28,9 +30,24 @@ extern "C" {
 
 #include "samplingbar.h"
 
+const uint64_t SamplingBar::RecordLengths[11] = {
+       1000000,
+       2000000,
+       5000000,
+       10000000,
+       25000000,
+       50000000,
+       100000000,
+       250000000,
+       500000000,
+       1000000000,
+       10000000000
+};
+
 SamplingBar::SamplingBar(QWidget *parent) :
        QToolBar("Sampling Bar", parent),
        _device_selector(this),
+       _record_length_selector(this),
        _sample_rate_list(this),
        _run_stop_button(this)
 {
@@ -41,9 +58,18 @@ SamplingBar::SamplingBar(QWidget *parent) :
        _sample_rate_value.setDecimals(0);
        _sample_rate_value.setSuffix("Hz");
 
+       BOOST_FOREACH(uint64_t l, RecordLengths)
+       {
+               char *const text = sr_si_string_u64(l, " samples");
+               _record_length_selector.addItem(QString(text),
+                       qVariantFromValue(l));
+               g_free(text);
+       }
+
        _run_stop_button.setText("Run");
 
        addWidget(&_device_selector);
+       addWidget(&_record_length_selector);
        _sample_rate_list_action = addWidget(&_sample_rate_list);
        _sample_rate_value_action = addWidget(&_sample_rate_value);
        addWidget(&_run_stop_button);
@@ -62,6 +88,15 @@ struct sr_dev_inst* SamplingBar::get_selected_device() const
                index).value<void*>();
 }
 
+uint64_t SamplingBar::get_record_length() const
+{
+       const int index = _record_length_selector.currentIndex();
+       if(index < 0)
+               return 0;
+
+       return _record_length_selector.itemData(index).value<uint64_t>();
+}
+
 uint64_t SamplingBar::get_sample_rate() const
 {
        assert(_sample_rate_value_action);
index e7738656b168c55fb60b50308e267ee28af57cc3..ad269624406bc7e9f3fce9e8464dbc233e5927c0 100644 (file)
@@ -34,10 +34,14 @@ class SamplingBar : public QToolBar
 {
        Q_OBJECT
 
+private:
+       static const uint64_t RecordLengths[11];
+
 public:
        SamplingBar(QWidget *parent);
 
        struct sr_dev_inst* get_selected_device() const;
+       uint64_t get_record_length() const;
        uint64_t get_sample_rate() const;
 
 signals:
@@ -53,6 +57,8 @@ private slots:
 private:
        QComboBox _device_selector;
 
+       QComboBox _record_length_selector;
+
        QComboBox _sample_rate_list;
        QAction *_sample_rate_list_action;
        QDoubleSpinBox _sample_rate_value;
index 21c5624bc40790ca410002e0b5320a70ff99ae2d..16b84f1487348871fa6af367278a2284433a998d 100644 (file)
@@ -58,7 +58,7 @@ void SigSession::load_file(const std::string &name)
 }
 
 void SigSession::start_capture(struct sr_dev_inst *sdi,
-       uint64_t sample_rate)
+       uint64_t record_length, uint64_t sample_rate)
 {
        sr_session_new();
        sr_session_datafeed_callback_add(data_feed_in_proc);
@@ -69,9 +69,8 @@ void SigSession::start_capture(struct sr_dev_inst *sdi,
                return;
        }
 
-       uint64_t limit_samples = 10000;
        if (sr_dev_config_set(sdi, SR_HWCAP_LIMIT_SAMPLES,
-               &limit_samples) != SR_OK) {
+               &record_length) != SR_OK) {
                qDebug() << "Failed to configure time-based sample limit.";
                sr_session_destroy();
                return;
index 24726dfe916a322098e9a6fdaab23ec9616cd8d8..bf262bbf6cc675c7a8136e6cb72f139995538cf0 100644 (file)
@@ -47,7 +47,8 @@ public:
 
        void load_file(const std::string &name);
 
-       void start_capture(struct sr_dev_inst* sdi, uint64_t sample_rate);
+       void start_capture(struct sr_dev_inst* sdi, uint64_t record_length,
+               uint64_t sample_rate);
 
        std::vector< boost::shared_ptr<Signal> >&
                get_signals();