From a007f5ad25bad88cf62443d5471449ce8a6f5f29 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Mon, 2 Dec 2013 21:01:51 +0000 Subject: [PATCH] Implemented pv::data::SignalData::get_max_sample_count --- pv/data/analog.cpp | 12 ++++++++++++ pv/data/analog.h | 2 ++ pv/data/decoderstack.cpp | 7 +++++++ pv/data/decoderstack.h | 2 ++ pv/data/logic.cpp | 12 ++++++++++++ pv/data/logic.h | 2 ++ pv/data/signaldata.h | 2 ++ pv/view/decode/annotation.cpp | 10 ++++++++++ pv/view/decode/annotation.h | 3 +++ 9 files changed, 52 insertions(+) diff --git a/pv/data/analog.cpp b/pv/data/analog.cpp index 6e2f2db8..dd4097a8 100644 --- a/pv/data/analog.cpp +++ b/pv/data/analog.cpp @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "analog.h" #include "analogsnapshot.h" @@ -47,5 +49,15 @@ void Analog::clear() _snapshots.clear(); } +uint64_t Analog::get_max_sample_count() const +{ + uint64_t l = 0; + BOOST_FOREACH(const boost::shared_ptr s, _snapshots) { + assert(s); + l = max(l, s->get_sample_count()); + } + return l; +} + } // namespace data } // namespace pv diff --git a/pv/data/analog.h b/pv/data/analog.h index 47514ad9..42e31677 100644 --- a/pv/data/analog.h +++ b/pv/data/analog.h @@ -44,6 +44,8 @@ public: void clear(); + uint64_t get_max_sample_count() const; + private: std::deque< boost::shared_ptr > _snapshots; }; diff --git a/pv/data/decoderstack.cpp b/pv/data/decoderstack.cpp index 333741ad..f0bdd6bd 100644 --- a/pv/data/decoderstack.cpp +++ b/pv/data/decoderstack.cpp @@ -146,6 +146,13 @@ void DecoderStack::clear() _annotations.clear(); } +uint64_t DecoderStack::get_max_sample_count() const +{ + if (_annotations.empty()) + return 0; + return _annotations.back()->end_sample(); +} + void DecoderStack::decode_proc(shared_ptr data) { srd_session *session; diff --git a/pv/data/decoderstack.h b/pv/data/decoderstack.h index 029ca25c..dc656f91 100644 --- a/pv/data/decoderstack.h +++ b/pv/data/decoderstack.h @@ -85,6 +85,8 @@ public: void clear(); + uint64_t get_max_sample_count() const; + void begin_decode(); private: diff --git a/pv/data/logic.cpp b/pv/data/logic.cpp index 4317d44d..d13cd766 100644 --- a/pv/data/logic.cpp +++ b/pv/data/logic.cpp @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "logic.h" #include "logicsnapshot.h" @@ -55,5 +57,15 @@ void Logic::clear() _snapshots.clear(); } +uint64_t Logic::get_max_sample_count() const +{ + uint64_t l = 0; + BOOST_FOREACH(boost::shared_ptr s, _snapshots) { + assert(s); + l = max(l, s->get_sample_count()); + } + return l; +} + } // namespace data } // namespace pv diff --git a/pv/data/logic.h b/pv/data/logic.h index 739b52e8..3d833942 100644 --- a/pv/data/logic.h +++ b/pv/data/logic.h @@ -46,6 +46,8 @@ public: void clear(); + uint64_t get_max_sample_count() const; + private: const unsigned int _num_probes; std::deque< boost::shared_ptr > _snapshots; diff --git a/pv/data/signaldata.h b/pv/data/signaldata.h index eb9d14c6..ba80ac3a 100644 --- a/pv/data/signaldata.h +++ b/pv/data/signaldata.h @@ -39,6 +39,8 @@ public: virtual void clear() = 0; + virtual uint64_t get_max_sample_count() const = 0; + protected: double _start_time; double _samplerate; diff --git a/pv/view/decode/annotation.cpp b/pv/view/decode/annotation.cpp index 3a0a51fd..00058476 100644 --- a/pv/view/decode/annotation.cpp +++ b/pv/view/decode/annotation.cpp @@ -67,6 +67,16 @@ Annotation::Annotation(const srd_proto_data *const pdata) : } } +uint64_t Annotation::start_sample() const +{ + return _start_sample; +} + +uint64_t Annotation::end_sample() const +{ + return _end_sample; +} + void Annotation::paint(QPainter &p, QColor text_color, int h, int left, int right, double samples_per_pixel, double pixels_offset, int y) diff --git a/pv/view/decode/annotation.h b/pv/view/decode/annotation.h index 078c12a1..d0282114 100644 --- a/pv/view/decode/annotation.h +++ b/pv/view/decode/annotation.h @@ -42,6 +42,9 @@ private: public: Annotation(const srd_proto_data *const pdata); + uint64_t start_sample() const; + uint64_t end_sample() const; + void paint(QPainter &p, QColor text_colour, int text_height, int left, int right, double samples_per_pixel, double pixels_offset, int y); -- 2.30.2