X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdata%2Fsignalbase.hpp;h=90a13555fb41938db36eb6063aef096bc6da20ef;hp=db1af1c718e4ddb0b8262b6790b5e2fd9afea2da;hb=bcaf033478ecf9a482f53b3dc973b7d2b9c4c52b;hpb=bf0edd2b0cbb5f4bd5d69b0f00bcea7d037e2287 diff --git a/pv/data/signalbase.hpp b/pv/data/signalbase.hpp index db1af1c7..90a13555 100644 --- a/pv/data/signalbase.hpp +++ b/pv/data/signalbase.hpp @@ -15,44 +15,67 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * along with this program; if not, see . */ #ifndef PULSEVIEW_PV_DATA_SIGNALBASE_HPP #define PULSEVIEW_PV_DATA_SIGNALBASE_HPP +#include + #include #include +#include #include #include +using std::shared_ptr; namespace sigrok { class Channel; -class ChannelType; } namespace pv { namespace data { +class Analog; +class DecoderStack; +class Logic; +class SignalData; + class SignalBase : public QObject { Q_OBJECT +public: + enum ChannelType { + AnalogChannel = 1, + LogicChannel, + DecodeChannel, + A2LChannel, // Analog converted to logic, joint representation + MathChannel + }; + + enum ConversionType { + NoConversion = 0, + A2LConversionByTreshold = 1, + A2LConversionBySchmittTrigger = 2 + }; + private: static const int ColourBGAlpha; + static const uint64_t ConversionBlockSize; public: - SignalBase(std::shared_ptr channel); - virtual ~SignalBase() {} + SignalBase(shared_ptr channel, ChannelType channel_type); + virtual ~SignalBase(); public: /** * Returns the underlying SR channel. */ - std::shared_ptr channel() const; + shared_ptr channel() const; /** * Returns enabled status of this channel. @@ -68,7 +91,7 @@ public: /** * Gets the type of this channel. */ - const sigrok::ChannelType *type() const; + ChannelType type() const; /** * Gets the index number of this channel. @@ -80,6 +103,11 @@ public: */ QString name() const; + /** + * Gets the internal name of this signal, i.e. how the device calls it. + */ + QString internal_name() const; + /** * Sets the name of the signal. */ @@ -100,6 +128,42 @@ public: */ QColor bgcolour() const; + /** + * Sets the internal data object. + */ + void set_data(shared_ptr data); + + /** + * Get the internal data as analog data object in case of analog type. + */ + shared_ptr analog_data() const; + + /** + * Get the internal data as logic data object in case of logic type. + */ + shared_ptr logic_data() const; + + /** + * Changes the kind of conversion performed on this channel. + */ + void set_conversion_type(ConversionType t); + +#ifdef ENABLE_DECODE + bool is_decode_signal() const; +#endif + + virtual void save_settings(QSettings &settings) const; + + virtual void restore_settings(QSettings &settings); + +private: + 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); + Q_SIGNALS: void enabled_changed(const bool &value); @@ -107,9 +171,31 @@ Q_SIGNALS: void colour_changed(const QColor &colour); -private: - std::shared_ptr channel_; - QString name_; + void conversion_type_changed(const ConversionType t); + + void samples_cleared(); + + void samples_added(QObject* segment, uint64_t start_sample, + uint64_t end_sample); + +private Q_SLOTS: + void on_samples_cleared(); + + void on_samples_added(QObject* segment, uint64_t start_sample, + uint64_t end_sample); + + void on_capture_state_changed(int state); + +protected: + shared_ptr channel_; + ChannelType channel_type_; + shared_ptr data_; + shared_ptr converted_data_; + int conversion_type_; + + std::thread conversion_thread_; + + QString internal_name_, name_; QColor colour_, bgcolour_; };