From: Joel Holdsworth Date: Mon, 31 Dec 2012 14:00:14 +0000 (+0000) Subject: Made Decoder dialog export a map of probes, and routed through to pv::data::Decoder X-Git-Tag: pulseview-0.2.0~310 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=708c552391bc942e91bc09bc808577e2564347bd;p=pulseview.git Made Decoder dialog export a map of probes, and routed through to pv::data::Decoder --- diff --git a/pv/data/decoder.cpp b/pv/data/decoder.cpp index ea0fed6b..cdfe57f9 100644 --- a/pv/data/decoder.cpp +++ b/pv/data/decoder.cpp @@ -20,11 +20,16 @@ #include "decoder.h" +#include + namespace pv { namespace data { -Decoder::Decoder(const srd_decoder *const dec) : - _decoder(dec) +Decoder::Decoder(const srd_decoder *const dec, + std::map > probes) : + _decoder(dec), + _probes(probes) { } diff --git a/pv/data/decoder.h b/pv/data/decoder.h index 228aedab..ddcf6674 100644 --- a/pv/data/decoder.h +++ b/pv/data/decoder.h @@ -23,15 +23,26 @@ #include "signaldata.h" +#include + +#include + struct srd_decoder; +struct srd_probe; namespace pv { + +namespace view { +class Signal; +} + namespace data { class Decoder : public SignalData { public: - Decoder(const srd_decoder *const dec); + Decoder(const srd_decoder *const dec, std::map > probes); const srd_decoder* get_decoder() const; @@ -39,6 +50,8 @@ public: private: const srd_decoder *const _decoder; + std::map > + _probes; }; } // namespace data diff --git a/pv/dialogs/decoder.cpp b/pv/dialogs/decoder.cpp index 292e4722..97df5d45 100644 --- a/pv/dialogs/decoder.cpp +++ b/pv/dialogs/decoder.cpp @@ -22,8 +22,15 @@ extern "C" { #include } +#include + +#include + +#include + #include "decoder.h" +#include #include using namespace boost; @@ -115,5 +122,28 @@ QComboBox* Decoder::create_probe_selector( return selector; } +map > Decoder::get_probes() +{ + map > probe_map; + for(map::const_iterator i = + _probe_selector_map.begin(); + i != _probe_selector_map.end(); i++) + { + const QComboBox *const combo = (*i).second; + 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"; + } + } + + return probe_map; +} + } // namespace dialogs } // namespace pv diff --git a/pv/dialogs/decoder.h b/pv/dialogs/decoder.h index 150d02c5..08af38cb 100644 --- a/pv/dialogs/decoder.h +++ b/pv/dialogs/decoder.h @@ -49,6 +49,9 @@ public: Decoder(QWidget *parent, const srd_decoder *decoder, const std::vector< boost::shared_ptr > &sigs); + std::map > + get_probes(); + private: QComboBox* create_probe_selector( QWidget *parent, const char *name); diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index 0397c7f4..6f852ce6 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -395,7 +395,7 @@ void MainWindow::add_decoder(QObject *action) if(dlg.exec() != QDialog::Accepted) return; - _session.add_decoder(dec); + _session.add_decoder(dec, dlg.get_probes()); } void MainWindow::run_stop() diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index 95af663b..cea71bda 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -198,12 +198,14 @@ boost::shared_ptr SigSession::get_data() return _logic_data; } -void SigSession::add_decoder(srd_decoder *const dec) +void SigSession::add_decoder(srd_decoder *const dec, + std::map > probes) { { lock_guard lock(_signals_mutex); shared_ptr decoder( - new data::Decoder(dec)); + new data::Decoder(dec, probes)); shared_ptr d( new view::DecodeSignal(*this, decoder)); _decode_traces.push_back(d); diff --git a/pv/sigsession.h b/pv/sigsession.h index 50768e6c..4ce6131d 100644 --- a/pv/sigsession.h +++ b/pv/sigsession.h @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -35,6 +36,7 @@ #include struct srd_decoder; +struct srd_probe; namespace pv { @@ -92,7 +94,9 @@ public: boost::shared_ptr get_data(); - void add_decoder(srd_decoder *const dec); + void add_decoder(srd_decoder *const dec, + std::map > probes); private: void set_capture_state(capture_state state);