]> sigrok.org Git - pulseview.git/blobdiff - pv/sigsession.cpp
Renamed pv::data::Decoder to DecoderStack
[pulseview.git] / pv / sigsession.cpp
index b27fd6ec7f80e8d77635e4219a2fed65c4cfde63..a6a2875e62657ca7dacc458808f854fc6dfbe88c 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#include <libsigrokdecode/libsigrokdecode.h>
+
 #include "sigsession.h"
 
 #include "devicemanager.h"
 
 #include "data/analog.h"
 #include "data/analogsnapshot.h"
-#include "data/decoder.h"
+#include "data/decoderstack.h"
 #include "data/logic.h"
 #include "data/logicsnapshot.h"
 
 #include "view/analogsignal.h"
-#include "view/decodesignal.h"
+#include "view/decodetrace.h"
 #include "view/logicsignal.h"
 
 #include <assert.h>
 
 #include <stdexcept>
 
+#include <boost/foreach.hpp>
+
 #include <sys/stat.h>
 
 #include <QDebug>
@@ -195,19 +199,36 @@ boost::shared_ptr<data::Logic> SigSession::get_data()
        return _logic_data;
 }
 
-bool SigSession::add_decoder(srd_decoder *const dec,
-       std::map<const srd_probe*,
-               boost::shared_ptr<view::LogicSignal> > probes,
-       GHashTable *options)
+bool SigSession::add_decoder(srd_decoder *const dec)
 {
+       map<const srd_probe*, shared_ptr<view::LogicSignal> > probes;
+
        try
        {
                lock_guard<mutex> lock(_signals_mutex);
 
-               shared_ptr<data::Decoder> decoder(
-                       new data::Decoder(dec, probes, options));
-               shared_ptr<view::DecodeSignal> d(
-                       new view::DecodeSignal(*this, decoder,
+               // Create the decoder
+               shared_ptr<data::DecoderStack> decoder(new data::DecoderStack(dec));
+
+               // Auto select the initial probes
+               for(const GSList *i = dec->probes; i; i = i->next)
+               {
+                       const srd_probe *const probe = (const srd_probe*)i->data;
+                       BOOST_FOREACH(shared_ptr<view::Signal> s, _signals)
+                       {
+                               shared_ptr<view::LogicSignal> l =
+                                       dynamic_pointer_cast<view::LogicSignal>(s);
+                               if (l && QString(probe->name).toLower().contains(
+                                       l->get_name().toLower()))
+                                       probes[probe] = l;
+                       }
+               }
+
+               decoder->set_probes(probes);
+
+               // Create the decode signal
+               shared_ptr<view::DecodeTrace> d(
+                       new view::DecodeTrace(*this, decoder,
                                _decode_traces.size()));
                _decode_traces.push_back(d);
        }
@@ -221,15 +242,15 @@ bool SigSession::add_decoder(srd_decoder *const dec,
        return true;
 }
 
-vector< shared_ptr<view::DecodeSignal> > SigSession::get_decode_signals() const
+vector< shared_ptr<view::DecodeTrace> > SigSession::get_decode_signals() const
 {
        lock_guard<mutex> lock(_signals_mutex);
        return _decode_traces;
 }
 
-void SigSession::remove_decode_signal(view::DecodeSignal *signal)
+void SigSession::remove_decode_signal(view::DecodeTrace *signal)
 {
-       for (vector< shared_ptr<view::DecodeSignal> >::iterator i =
+       for (vector< shared_ptr<view::DecodeTrace> >::iterator i =
                _decode_traces.begin();
                i != _decode_traces.end();
                i++)