X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdata%2Fsignalbase.hpp;h=7e1196521d0d3ae303a8b6258e6f62dce71cb798;hp=16a94bd43b816ce47ac6c7ca067b0611ea19bb93;hb=999869aa676f7077b7181355eee28e9b025d4cea;hpb=932bc2461d7b84b084d3a77ccfeb3bdb1a2d0d6c diff --git a/pv/data/signalbase.hpp b/pv/data/signalbase.hpp index 16a94bd4..7e119652 100644 --- a/pv/data/signalbase.hpp +++ b/pv/data/signalbase.hpp @@ -35,6 +35,8 @@ #include +#include "segment.hpp" + using std::atomic; using std::condition_variable; using std::map; @@ -51,8 +53,11 @@ namespace pv { namespace data { class Analog; +class AnalogSegment; class DecoderStack; class Logic; +class LogicSegment; +class Segment; class SignalData; class SignalBase : public QObject @@ -84,7 +89,7 @@ public: }; private: - static const int ColourBGAlpha; + static const int ColorBGAlpha; static const uint64_t ConversionBlockSize; static const uint32_t ConversionDelay; @@ -95,6 +100,7 @@ public: public: /** * Returns the underlying SR channel. + * Generated channels don't have a SR channel. */ shared_ptr channel() const; @@ -120,6 +126,13 @@ public: */ unsigned int index() const; + /** + * Sets the index number of this channel, i.e. a unique ID assigned by + * the device driver or the logic bit index (see below). + * Only use immediately after creating the signal and leave it untouched after. + */ + void set_index(unsigned int index); + /** * Returns which bit of a given sample for this signal represents the * signal itself. This is relevant for compound signals like logic, @@ -134,35 +147,52 @@ public: QString name() const; /** - * Gets the internal name of this signal, i.e. how the device calls it. + * Gets the internal name of this signal, i.e. how the device/generator calls it. */ QString internal_name() const; + /** + * Sets the internal name of this signal, i.e. how the device/generator calls it. + * Only use immediately after creating the signal and leave it untouched after. + */ + void set_internal_name(QString internal_name); + + /** + * Produces a string for this signal that can be used for display, + * i.e. it contains one or both of the signal/internal names. + */ + QString display_name() const; + /** * Sets the name of the signal. */ virtual void set_name(QString name); /** - * Get the colour of the signal. + * Get the color of the signal. */ - QColor colour() const; + QColor color() const; /** - * Set the colour of the signal. + * Set the color of the signal. */ - void set_colour(QColor colour); + void set_color(QColor color); /** - * Get the background colour of the signal. + * Get the background color of the signal. */ - QColor bgcolour() const; + QColor bgcolor() const; /** * Sets the internal data object. */ void set_data(shared_ptr data); + /** + * Clears all sample data and removes all associated segments. + */ + void clear_sample_data(); + /** * Get the internal data as analog data object in case of analog type. */ @@ -173,6 +203,22 @@ public: */ shared_ptr logic_data() const; + /** + * Determines whether a given segment is complete (i.e. end-of-frame has + * been seen). It only considers the original data, not the converted data. + */ + bool segment_is_complete(uint32_t segment_id) const; + + /** + * Determines whether this signal has any sample data at all. + */ + bool has_samples() const; + + /** + * Returns the sample rate for this signal. + */ + virtual double get_samplerate() const; + /** * Queries the kind of conversion performed on this channel. */ @@ -266,7 +312,11 @@ private: uint8_t convert_a2l_schmitt_trigger(float lo_thr, float hi_thr, float value, uint8_t &state); - void conversion_thread_proc(QObject* segment); + void convert_single_segment_range(AnalogSegment *asegment, + LogicSegment *lsegment, uint64_t start_sample, uint64_t end_sample); + void convert_single_segment(pv::data::AnalogSegment *asegment, + pv::data::LogicSegment *lsegment); + void conversion_thread_proc(); void stop_conversion(); @@ -275,19 +325,21 @@ Q_SIGNALS: void name_changed(const QString &name); - void colour_changed(const QColor &colour); + void color_changed(const QColor &color); void conversion_type_changed(const ConversionType t); void samples_cleared(); - void samples_added(QObject* segment, uint64_t start_sample, + void samples_added(uint64_t segment_id, uint64_t start_sample, uint64_t end_sample); + void min_max_changed(float min, float max); + private Q_SLOTS: void on_samples_cleared(); - void on_samples_added(QObject* segment, uint64_t start_sample, + void on_samples_added(SharedPtrToSegment segment, uint64_t start_sample, uint64_t end_sample); void on_min_max_changed(float min, float max); @@ -313,7 +365,8 @@ protected: QTimer delayed_conversion_starter_; QString internal_name_, name_; - QColor colour_, bgcolour_; + QColor color_, bgcolor_; + unsigned int index_; }; } // namespace data