From: Joel Holdsworth Date: Sun, 20 Oct 2013 10:15:53 +0000 (+0100) Subject: Modified Decode to only use LogicSignals X-Git-Tag: pulseview-0.2.0~235 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=3045c869ada2e32bf55cbb68633b5213b9b11e28;p=pulseview.git Modified Decode to only use LogicSignals --- diff --git a/pv/data/decoder.cpp b/pv/data/decoder.cpp index d8a538cb..92314039 100644 --- a/pv/data/decoder.cpp +++ b/pv/data/decoder.cpp @@ -45,7 +45,7 @@ const int64_t Decoder::DecodeChunkLength = 4096; Decoder::Decoder(const srd_decoder *const dec, std::map > probes, + boost::shared_ptr > probes, GHashTable *options) : _decoder(dec), _probes(probes), @@ -93,12 +93,9 @@ void Decoder::begin_decode() // We get the logic data of the first probe in the list. // This works because we are currently assuming all // LogicSignals have the same data/snapshot - shared_ptr sig = (*_probes.begin()).second; + shared_ptr sig = (*_probes.begin()).second; assert(sig); - const pv::view::LogicSignal *const l = - dynamic_cast(sig.get()); - assert(l); - shared_ptr data = l->data(); + shared_ptr data = sig->data(); _decode_thread = boost::thread(&Decoder::decode_proc, this, data); @@ -139,7 +136,7 @@ bool Decoder::init_decoder() GHashTable *probes = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_variant_unref); - for(map >:: + for(map >:: const_iterator i = _probes.begin(); i != _probes.end(); i++) { diff --git a/pv/data/decoder.h b/pv/data/decoder.h index 264920a7..cdeb7e7a 100644 --- a/pv/data/decoder.h +++ b/pv/data/decoder.h @@ -41,7 +41,7 @@ struct srd_session; namespace pv { namespace view { -class Signal; +class LogicSignal; namespace decode { class Annotation; @@ -65,7 +65,7 @@ private: public: Decoder(const srd_decoder *const decoder, std::map > probes, + boost::shared_ptr > probes, GHashTable *options); virtual ~Decoder(); @@ -92,7 +92,7 @@ signals: private: const srd_decoder *const _decoder; - std::map > + std::map > _probes; GHashTable *_options; diff --git a/pv/dialogs/decoder.cpp b/pv/dialogs/decoder.cpp index 88ccf760..07375f64 100644 --- a/pv/dialogs/decoder.cpp +++ b/pv/dialogs/decoder.cpp @@ -40,7 +40,8 @@ namespace pv { namespace dialogs { Decoder::Decoder(QWidget *parent, const srd_decoder *decoder, - const vector< shared_ptr > &sigs, GHashTable *options) : + const vector< shared_ptr > &sigs, + GHashTable *options) : QDialog(parent), _sigs(sigs), _binding(decoder, options), @@ -121,10 +122,11 @@ QComboBox* Decoder::create_probe_selector( selector->setCurrentIndex(0); for(size_t i = 0; i < _sigs.size(); i++) { - const shared_ptr s(_sigs[i]); + const shared_ptr s(_sigs[i]); assert(s); - if (s->enabled()) { + if (s->enabled()) + { selector->addItem(s->get_name(), qVariantFromValue(i)); if(s->get_name().toLower().contains( QString(name).toLower())) @@ -135,9 +137,9 @@ QComboBox* Decoder::create_probe_selector( return selector; } -map > Decoder::get_probes() +map > Decoder::get_probes() { - map > probe_map; + map > probe_map; for(map::const_iterator i = _probe_selector_map.begin(); i != _probe_selector_map.end(); i++) @@ -146,12 +148,8 @@ map > Decoder::get_probes() const int probe_index = combo->itemData(combo->currentIndex()).value(); if(probe_index >= 0) { - shared_ptr sig = _sigs[probe_index]; - if(dynamic_cast(sig.get())) - probe_map[(*i).first] = sig; - else - qDebug() << "Currently only logic signals " - "are supported for decoding"; + shared_ptr sig = _sigs[probe_index]; + probe_map[(*i).first] = sig; } } diff --git a/pv/dialogs/decoder.h b/pv/dialogs/decoder.h index 56f02aa4..926d015b 100644 --- a/pv/dialogs/decoder.h +++ b/pv/dialogs/decoder.h @@ -40,7 +40,7 @@ struct srd_decoder; namespace pv { namespace view { -class Signal; +class LogicSignal; } namespace dialogs { @@ -49,12 +49,12 @@ class Decoder : public QDialog { public: Decoder(QWidget *parent, const srd_decoder *decoder, - const std::vector< boost::shared_ptr > &sigs, + const std::vector< boost::shared_ptr > &sigs, GHashTable *options); void accept(); - std::map > + std::map > get_probes(); private: @@ -62,7 +62,7 @@ private: QWidget *parent, const char *name); private: - const std::vector< boost::shared_ptr > &_sigs; + const std::vector< boost::shared_ptr > &_sigs; std::map _probe_selector_map; diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index f7b86120..183e841e 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -41,6 +41,7 @@ #include "dialogs/connect.h" #include "dialogs/decoder.h" #include "toolbars/samplingbar.h" +#include "view/logicsignal.h" #include "view/view.h" /* __STDC_FORMAT_MACROS is required for PRIu64 and friends (in C++). */ @@ -375,13 +376,21 @@ void MainWindow::add_decoder(QObject *action) (srd_decoder*)((QAction*)action)->data().value(); assert(dec); - const std::vector< boost::shared_ptr > &sigs = + vector< shared_ptr > logic_sigs; + const vector< shared_ptr > &sigs = _session.get_signals(); + BOOST_FOREACH(shared_ptr s, sigs) { + assert(s); + shared_ptr l = + dynamic_pointer_cast(s); + if (l) + logic_sigs.push_back(l); + } GHashTable *const options = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_variant_unref); - dialogs::Decoder dlg(this, dec, sigs, options); + dialogs::Decoder dlg(this, dec, logic_sigs, options); if(dlg.exec() != QDialog::Accepted) { g_hash_table_destroy(options); return; diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index e81d3605..aadaf450 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -197,7 +197,7 @@ boost::shared_ptr SigSession::get_data() bool SigSession::add_decoder(srd_decoder *const dec, std::map > probes, + boost::shared_ptr > probes, GHashTable *options) { try diff --git a/pv/sigsession.h b/pv/sigsession.h index 499814ca..5c69a9bc 100644 --- a/pv/sigsession.h +++ b/pv/sigsession.h @@ -50,6 +50,7 @@ class LogicSnapshot; namespace view { class DecodeSignal; +class LogicSignal; class Signal; } @@ -95,7 +96,7 @@ public: bool add_decoder(srd_decoder *const dec, std::map > probes, + boost::shared_ptr > probes, GHashTable *options); std::vector< boost::shared_ptr > diff --git a/test/data/decoder.cpp b/test/data/decoder.cpp index 4a74c417..641064da 100644 --- a/test/data/decoder.cpp +++ b/test/data/decoder.cpp @@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(TwoDecoder) srd_decoder *const dec = (struct srd_decoder*)l->data; BOOST_REQUIRE(dec); - map > probes; + map > probes; BOOST_CHECK (ss.add_decoder(dec, probes, g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_variant_unref)));