]> sigrok.org Git - pulseview.git/blobdiff - pv/data/decodesignal.hpp
Session: Fix issue #67 by improving error handling
[pulseview.git] / pv / data / decodesignal.hpp
index c59b20b816d6a29ce4dee4dd60891a5d9fa07f92..333e953b2d63e66c415b403092ad48cc2975b0f5 100644 (file)
@@ -26,8 +26,8 @@
 #include <unordered_set>
 #include <vector>
 
+#include <QDebug>
 #include <QSettings>
-#include <QString>
 
 #include <libsigrokdecode/libsigrokdecode.h>
 
@@ -77,11 +77,17 @@ struct DecodeBinaryClass
 
 struct DecodeSegment
 {
-       map<const Row*, RowData> annotation_rows;
+       // Constructor is a no-op
+       DecodeSegment() { };
+       // Copy constructor is a no-op
+       DecodeSegment(DecodeSegment&& ds) { (void)ds; qCritical() << "Empty DecodeSegment copy constructor called"; };
+
+       map<const Row*, RowData> annotation_rows;  // Note: Row is the same for all segments while RowData is not
        pv::util::Timestamp start_time;
        double samplerate;
        int64_t samples_decoded_incl, samples_decoded_excl;
        vector<DecodeBinaryClass> binary_classes;
+       deque<const Annotation*> all_annotations;
 };
 
 class DecodeSignal : public SignalBase
@@ -97,6 +103,16 @@ public:
        DecodeSignal(pv::Session &session);
        virtual ~DecodeSignal();
 
+       /**
+        * Sets the name of the signal.
+        */
+       virtual void set_name(QString name);
+
+       /**
+        * Set the color of the signal.
+        */
+       virtual void set_color(QColor color);
+
        bool is_decode_signal() const;
        const vector< shared_ptr<Decoder> >& decoder_stack() const;
 
@@ -109,16 +125,17 @@ public:
        void pause_decode();
        void resume_decode();
        bool is_paused() const;
-       QString error_message() const;
 
        const vector<decode::DecodeChannel> get_channels() const;
        void auto_assign_signals(const shared_ptr<Decoder> dec);
-       void assign_signal(const uint16_t channel_id, const SignalBase *signal);
+       void assign_signal(const uint16_t channel_id, shared_ptr<const SignalBase> signal);
        int get_assigned_signal_count() const;
 
+       void update_output_signals();
+
        void set_initial_pin_state(const uint16_t channel_id, const int init_state);
 
-       double samplerate() const;
+       virtual double get_samplerate() const;
        const pv::util::Timestamp start_time() const;
 
        /**
@@ -149,7 +166,7 @@ public:
         * Note: The annotations may be unsorted and only annotations that fully
         * fit into the sample range are considered.
         */
-       void get_annotation_subset(vector<const Annotation*> &dest, const Row* row,
+       void get_annotation_subset(deque<const Annotation*> &dest, const Row* row,
                uint32_t segment_id, uint64_t start_sample, uint64_t end_sample) const;
 
        /**
@@ -157,7 +174,7 @@ public:
         * Note: The annotations may be unsorted and only annotations that fully
         * fit into the sample range are considered.
         */
-       void get_annotation_subset(vector<const Annotation*> &dest, uint32_t segment_id,
+       void get_annotation_subset(deque<const 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,
@@ -176,15 +193,16 @@ public:
        const DecodeBinaryClass* get_binary_data_class(uint32_t segment_id,
                const Decoder* dec, uint32_t bin_class_id) const;
 
+       const deque<const Annotation*>* get_all_annotations_by_segment(uint32_t segment_id) const;
+
        virtual void save_settings(QSettings &settings) const;
 
        virtual void restore_settings(QSettings &settings);
 
 private:
-       void set_error_message(QString msg);
-
+       bool all_input_segments_complete(uint32_t segment_id) const;
        uint32_t get_input_segment_count() const;
-       uint32_t get_input_samplerate(uint32_t segment_id) const;
+       double get_input_samplerate(uint32_t segment_id) const;
 
        Decoder* get_decoder_by_instance(const srd_decoder *const srd_dec);
 
@@ -196,7 +214,7 @@ private:
        void logic_mux_proc();
 
        void decode_data(const int64_t abs_start_samplenum, const int64_t sample_count,
-               const shared_ptr<LogicSegment> input_segment);
+               const shared_ptr<const LogicSegment> input_segment);
        void decode_proc();
 
        void start_srd_session();
@@ -204,11 +222,13 @@ private:
        void stop_srd_session();
 
        void connect_input_notifiers();
+       void disconnect_input_notifiers();
 
        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);
+       static void logic_output_callback(srd_proto_data *pdata, void *decode_signal);
 
 Q_SIGNALS:
        void decoder_stacked(void* decoder); ///< decoder is of type decode::Decoder*
@@ -218,11 +238,15 @@ Q_SIGNALS:
        void decode_reset();
        void decode_finished();
        void channels_updated();
+       void annotation_visibility_changed();
 
 private Q_SLOTS:
        void on_capture_state_changed(int state);
        void on_data_cleared();
        void on_data_received();
+       void on_input_segment_completed();
+
+       void on_annotation_visibility_changed();
 
 private:
        pv::Session &session_;
@@ -238,7 +262,7 @@ private:
        vector< shared_ptr<Decoder> > stack_;
        bool stack_config_changed_;
 
-       vector<DecodeSegment> segments_;
+       deque<DecodeSegment> segments_;
        uint32_t current_segment_id_;
 
        mutable mutex input_mutex_, output_mutex_, decode_pause_mutex_, logic_mux_mutex_;
@@ -250,7 +274,9 @@ private:
 
        bool decode_paused_;
 
-       QString error_message_;
+       map<const srd_decoder*, shared_ptr<Logic>> output_logic_;
+       map<const srd_decoder*, vector<uint8_t>> output_logic_muxed_data_;
+       vector< shared_ptr<SignalBase>> output_signals_;
 };
 
 } // namespace data