]> sigrok.org Git - pulseview.git/blobdiff - pv/data/decoder.h
Moved all srd commands into decode thread, implemented error messages
[pulseview.git] / pv / data / decoder.h
index 228aedabe1a03899b6adc5c1dccbe219cf678309..09002ac911153ed06901af6ab1ba3e0927b1f4c7 100644 (file)
 
 #include "signaldata.h"
 
+#include <map>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/thread.hpp>
+
+#include <QObject>
+#include <QString>
+
+#include <glib.h>
+
 struct srd_decoder;
+struct srd_probe;
+struct srd_proto_data;
+
+namespace DecoderTest {
+class TwoDecoder;
+}
 
 namespace pv {
+
+namespace view {
+class LogicSignal;
+
+namespace decode {
+class Annotation;
+}
+
+}
+
 namespace data {
 
-class Decoder : public SignalData
+class Logic;
+
+class Decoder : public QObject, public SignalData
 {
+       Q_OBJECT
+
+private:
+       static const double DecodeMargin;
+       static const double DecodeThreshold;
+       static const int64_t DecodeChunkLength;
+
 public:
-       Decoder(const srd_decoder *const dec);
+       Decoder(const srd_decoder *const decoder,
+               std::map<const srd_probe*,
+                       boost::shared_ptr<pv::view::LogicSignal> > probes,
+               GHashTable *options);
+
+       virtual ~Decoder();
 
        const srd_decoder* get_decoder() const;
 
+       const std::vector< boost::shared_ptr<pv::view::decode::Annotation> >
+               annotations() const;
+
+       QString error_message();
+
        void clear_snapshots();
 
+private:
+       void begin_decode();
+
+       void init_decoder();
+
+       void decode_proc(boost::shared_ptr<data::Logic> data);
+
+       static void annotation_callback(srd_proto_data *pdata,
+               void *decoder);
+
+signals:
+       void new_decode_data();
+
 private:
        const srd_decoder *const _decoder;
+       std::map<const srd_probe*, boost::shared_ptr<view::LogicSignal> >
+               _probes;
+       GHashTable *_options;
+
+       mutable boost::mutex _mutex;
+       std::vector< boost::shared_ptr<pv::view::decode::Annotation> >
+               _annotations;
+       QString _error_message;
+
+       boost::thread _decode_thread;
+
+       friend class DecoderTest::TwoDecoder;
 };
 
 } // namespace data