]> sigrok.org Git - pulseview.git/blobdiff - pv/data/decodesignal.hpp
Fix #1446 by starting the decode only for the last PD in the stack
[pulseview.git] / pv / data / decodesignal.hpp
index da66d5289c494703615410d63b78d635c3deeced..74ffbd1ff470c64cd88678ef429ccfc739997883 100644 (file)
@@ -21,6 +21,7 @@
 #define PULSEVIEW_PV_DATA_DECODESIGNAL_HPP
 
 #include <atomic>
+#include <deque>
 #include <condition_variable>
 #include <unordered_set>
 #include <vector>
@@ -30,6 +31,7 @@
 
 #include <libsigrokdecode/libsigrokdecode.h>
 
+#include <pv/data/decode/decoder.hpp>
 #include <pv/data/decode/row.hpp>
 #include <pv/data/decode/rowdata.hpp>
 #include <pv/data/signalbase.hpp>
@@ -37,6 +39,7 @@
 
 using std::atomic;
 using std::condition_variable;
+using std::deque;
 using std::map;
 using std::mutex;
 using std::pair;
@@ -59,16 +62,17 @@ class LogicSegment;
 class SignalBase;
 class SignalData;
 
-struct DecodeChannel
+struct DecodeBinaryDataChunk
 {
-       uint16_t id;     ///< Global numerical ID for the decode channels in the stack
-       uint16_t bit_id; ///< Tells which bit within a sample represents this channel
-       const bool is_optional;
-       const pv::data::SignalBase *assigned_signal;
-       const QString name, desc;
-       int initial_pin_state;
-       const shared_ptr<pv::data::decode::Decoder> decoder_;
-       const srd_channel *pdch_;
+       vector<uint8_t> data;
+       uint64_t sample;   ///< Number of the sample where this data was provided by the PD
+};
+
+struct DecodeBinaryClass
+{
+       const decode::Decoder* decoder;
+       const decode::DecodeBinaryClassInfo* info;
+       deque<DecodeBinaryDataChunk> chunks;
 };
 
 struct DecodeSegment
@@ -77,6 +81,7 @@ struct DecodeSegment
        pv::util::Timestamp start_time;
        double samplerate;
        int64_t samples_decoded_incl, samples_decoded_excl;
+       vector<DecodeBinaryClass> binary_classes;
 };
 
 class DecodeSignal : public SignalBase
@@ -95,7 +100,7 @@ public:
        bool is_decode_signal() const;
        const vector< shared_ptr<data::decode::Decoder> >& decoder_stack() const;
 
-       void stack_decoder(const srd_decoder *decoder);
+       void stack_decoder(const srd_decoder *decoder, bool restart_decode=true);
        void remove_decoder(int index);
        bool toggle_decoder_visibility(int index);
 
@@ -106,7 +111,7 @@ public:
        bool is_paused() const;
        QString error_message() const;
 
-       const vector<data::DecodeChannel> get_channels() const;
+       const vector<data::decode::DecodeChannel> get_channels() const;
        void auto_assign_signals(const shared_ptr<pv::data::decode::Decoder> dec);
        void assign_signal(const uint16_t channel_id, const SignalBase *signal);
        int get_assigned_signal_count() const;
@@ -155,6 +160,22 @@ public:
                vector<pv::data::decode::Annotation> &dest,
                uint32_t segment_id, uint64_t start_sample, uint64_t end_sample) const;
 
+       uint32_t get_binary_data_chunk_count(uint32_t segment_id,
+               const data::decode::Decoder* dec, uint32_t bin_class_id) const;
+       void get_binary_data_chunk(uint32_t segment_id, const data::decode::Decoder* dec,
+               uint32_t bin_class_id, uint32_t chunk_id, const vector<uint8_t> **dest,
+               uint64_t *size);
+       void get_merged_binary_data_chunks_by_sample(uint32_t segment_id,
+               const data::decode::Decoder* dec, uint32_t bin_class_id,
+               uint64_t start_sample, uint64_t end_sample,
+               vector<uint8_t> *dest) const;
+       void get_merged_binary_data_chunks_by_offset(uint32_t segment_id,
+               const data::decode::Decoder* dec, uint32_t bin_class_id,
+               uint64_t start, uint64_t end,
+               vector<uint8_t> *dest) const;
+       const DecodeBinaryClass* get_binary_data_class(uint32_t segment_id,
+               const data::decode::Decoder* dec, uint32_t bin_class_id) const;
+
        virtual void save_settings(QSettings &settings) const;
 
        virtual void restore_settings(QSettings &settings);
@@ -188,9 +209,13 @@ private:
        void create_decode_segment();
 
        static void annotation_callback(srd_proto_data *pdata, void *decode_signal);
+       static void binary_callback(srd_proto_data *pdata, void *decode_signal);
 
 Q_SIGNALS:
+       void decoder_stacked(void* decoder); ///< decoder is of type decode::Decoder*
+       void decoder_removed(void* decoder); ///< decoder is of type decode::Decoder*
        void new_annotations(); // TODO Supply segment for which they belong to
+       void new_binary_data(unsigned int segment_id, void* decoder, unsigned int bin_class_id);
        void decode_reset();
        void decode_finished();
        void channels_updated();
@@ -203,7 +228,7 @@ private Q_SLOTS:
 private:
        pv::Session &session_;
 
-       vector<data::DecodeChannel> channels_;
+       vector<data::decode::DecodeChannel> channels_;
 
        struct srd_session *srd_session_;