X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdata%2Fsignalbase.hpp;h=a2d23244f0e1d007aad79543f909fce796c8ab0c;hp=97dbd8477d58dea4537e117a25946338f48f64c3;hb=06b6ce26694bdde31c7d5b703c4dda36f4a25938;hpb=ad908057e13224eee9f983685e0ccc7db1ded0e9 diff --git a/pv/data/signalbase.hpp b/pv/data/signalbase.hpp index 97dbd847..a2d23244 100644 --- a/pv/data/signalbase.hpp +++ b/pv/data/signalbase.hpp @@ -21,6 +21,8 @@ #ifndef PULSEVIEW_PV_DATA_SIGNALBASE_HPP #define PULSEVIEW_PV_DATA_SIGNALBASE_HPP +#include +#include #include #include @@ -30,6 +32,9 @@ #include +using std::atomic; +using std::condition_variable; +using std::mutex; using std::shared_ptr; namespace sigrok { @@ -50,11 +55,11 @@ class SignalBase : public QObject public: enum ChannelType { - AnalogChannel = 1, - LogicChannel, - DecodeChannel, - A2LChannel, // Analog converted to logic, joint representation - MathChannel + AnalogChannel = 1, ///< Analog data + LogicChannel, ///< Logic data + DecodeChannel, ///< Protocol Decoder channel using libsigrokdecode + A2LChannel, ///< Analog converted to logic, joint representation + MathChannel ///< Virtual channel generated by math operations }; enum ConversionType { @@ -65,6 +70,7 @@ public: private: static const int ColourBGAlpha; + static const uint64_t ConversionBlockSize; public: SignalBase(shared_ptr channel, ChannelType channel_type); @@ -93,10 +99,19 @@ public: ChannelType type() const; /** - * Gets the index number of this channel. + * Gets the index number of this channel, i.e. a unique ID assigned by + * the device driver. */ unsigned int index() const; + /** + * Returns which bit of a given sample for this signal represents the + * signal itself. This is relevant for compound signals like logic, + * rather meaningless for everything else but provided in case there + * is a conversion active that provides a digital signal using bit #0. + */ + unsigned int logic_bit_index() const; + /** * Gets the name of this signal. */ @@ -142,28 +157,35 @@ public: */ shared_ptr logic_data() const; + /** + * Queries the kind of conversion performed on this channel. + */ + ConversionType get_conversion_type() const; + /** * Changes the kind of conversion performed on this channel. */ void set_conversion_type(ConversionType t); #ifdef ENABLE_DECODE - virtual bool is_decode_signal() const; - - virtual shared_ptr decoder_stack() const; + bool is_decode_signal() const; #endif - void save_settings(QSettings &settings) const; + virtual void save_settings(QSettings &settings) const; - void restore_settings(QSettings &settings); + virtual void restore_settings(QSettings &settings); private: + bool conversion_is_a2l() const; + uint8_t convert_a2l_threshold(float threshold, float value); uint8_t convert_a2l_schmitt_trigger(float lo_thr, float hi_thr, float value, uint8_t &state); - void conversion_thread_proc(QObject* segment, uint64_t start_sample, - uint64_t end_sample); + void conversion_thread_proc(QObject* segment); + + void start_conversion(); + void stop_conversion(); Q_SIGNALS: void enabled_changed(const bool &value); @@ -192,9 +214,12 @@ protected: ChannelType channel_type_; shared_ptr data_; shared_ptr converted_data_; - int conversion_type_; + ConversionType conversion_type_; std::thread conversion_thread_; + atomic conversion_interrupt_; + mutex conversion_input_mutex_; + condition_variable conversion_input_cond_; QString internal_name_, name_; QColor colour_, bgcolour_;