]> sigrok.org Git - pulseview.git/commitdiff
Made Decoder dialog export a map of probes, and routed through to pv::data::Decoder
authorJoel Holdsworth <redacted>
Mon, 31 Dec 2012 14:00:14 +0000 (14:00 +0000)
committerJoel Holdsworth <redacted>
Sun, 29 Sep 2013 01:34:42 +0000 (10:34 +0900)
pv/data/decoder.cpp
pv/data/decoder.h
pv/dialogs/decoder.cpp
pv/dialogs/decoder.h
pv/mainwindow.cpp
pv/sigsession.cpp
pv/sigsession.h

index ea0fed6bd47a0faf9f506a43053060c9f2889363..cdfe57f9540b3bd8de3c8c787ed8121490567523 100644 (file)
 
 #include "decoder.h"
 
+#include <pv/view/signal.h>
+
 namespace pv {
 namespace data {
 
-Decoder::Decoder(const srd_decoder *const dec) :
-       _decoder(dec)
+Decoder::Decoder(const srd_decoder *const dec,
+       std::map<const srd_probe*,
+               boost::shared_ptr<pv::view::Signal> > probes) :
+       _decoder(dec),
+       _probes(probes)
 {
 }
 
index 228aedabe1a03899b6adc5c1dccbe219cf678309..ddcf6674ba15c0d5bb59dc6abd37ae81a7683e33 100644 (file)
 
 #include "signaldata.h"
 
+#include <map>
+
+#include <boost/shared_ptr.hpp>
+
 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<const srd_probe*,
+               boost::shared_ptr<pv::view::Signal> > probes);
 
        const srd_decoder* get_decoder() const;
 
@@ -39,6 +50,8 @@ public:
 
 private:
        const srd_decoder *const _decoder;
+       std::map<const srd_probe*, boost::shared_ptr<view::Signal> >
+               _probes;
 };
 
 } // namespace data
index 292e4722c3928bdae995c1cd03030fa597059ba0..97df5d45f43c605f3d774d25848d4d0557247e93 100644 (file)
@@ -22,8 +22,15 @@ extern "C" {
 #include <libsigrokdecode/libsigrokdecode.h>
 }
 
+#include <utility>
+
+#include <boost/foreach.hpp>
+
+#include <QDebug>
+
 #include "decoder.h"
 
+#include <pv/view/logicsignal.h>
 #include <pv/view/signal.h>
 
 using namespace boost;
@@ -115,5 +122,28 @@ QComboBox* Decoder::create_probe_selector(
        return selector;
 }
 
+map<const srd_probe*, shared_ptr<view::Signal> > Decoder::get_probes()
+{
+       map<const srd_probe*, shared_ptr<view::Signal> > probe_map;
+       for(map<const srd_probe*, QComboBox*>::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<int>();
+               if(probe_index >= 0) {
+                       shared_ptr<view::Signal> sig = _sigs[probe_index];
+                       if(dynamic_cast<pv::view::LogicSignal*>(sig.get()))
+                               probe_map[(*i).first] = sig;
+                       else
+                               qDebug() << "Currently only logic signals "
+                                       "are supported for decoding";
+               }
+       }
+
+       return probe_map;
+}
+
 } // namespace dialogs
 } // namespace pv
index 150d02c5cf8d4305fbd15e217cbb9cd17cbe480c..08af38cb71bf6a655218deed04b7fc62e551f020 100644 (file)
@@ -49,6 +49,9 @@ public:
        Decoder(QWidget *parent, const srd_decoder *decoder,
                const std::vector< boost::shared_ptr<view::Signal> > &sigs);
 
+       std::map<const srd_probe*, boost::shared_ptr<view::Signal> >
+               get_probes();
+
 private:
        QComboBox* create_probe_selector(
                QWidget *parent, const char *name);
index 0397c7f4a6076de6782f364be497ae8f462ad560..6f852ce6044e16a1fe305c2334b21b36227bc6c0 100644 (file)
@@ -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()
index 95af663babd1b01d2a6d9182acc9f94c8e723c92..cea71bda9cdc6ea4ab42ef42f1ed423762357362 100644 (file)
@@ -198,12 +198,14 @@ boost::shared_ptr<data::Logic> SigSession::get_data()
        return _logic_data;
 }
 
-void SigSession::add_decoder(srd_decoder *const dec)
+void SigSession::add_decoder(srd_decoder *const dec,
+       std::map<const srd_probe*,
+               boost::shared_ptr<view::Signal> > probes)
 {
        {
                lock_guard<mutex> lock(_signals_mutex);
                shared_ptr<data::Decoder> decoder(
-                       new data::Decoder(dec));
+                       new data::Decoder(dec, probes));
                shared_ptr<view::DecodeSignal> d(
                        new view::DecodeSignal(*this, decoder));
                _decode_traces.push_back(d);
index 50768e6caf037152aafc62cf21ebae4799c4fb83..4ce6131d4bd39f9a7daf09c43e3b2044aa290df9 100644 (file)
@@ -25,6 +25,7 @@
 #include <boost/shared_ptr.hpp>
 #include <boost/thread.hpp>
 
+#include <map>
 #include <string>
 #include <utility>
 #include <vector>
@@ -35,6 +36,7 @@
 #include <libsigrok/libsigrok.h>
 
 struct srd_decoder;
+struct srd_probe;
 
 namespace pv {
 
@@ -92,7 +94,9 @@ public:
 
        boost::shared_ptr<data::Logic> get_data();
 
-       void add_decoder(srd_decoder *const dec);
+       void add_decoder(srd_decoder *const dec,
+               std::map<const srd_probe*,
+                       boost::shared_ptr<view::Signal> > probes);
 
 private:
        void set_capture_state(capture_state state);