]> sigrok.org Git - pulseview.git/commitdiff
Implemented pv::data::SignalData::get_max_sample_count
authorJoel Holdsworth <redacted>
Mon, 2 Dec 2013 21:01:51 +0000 (21:01 +0000)
committerJoel Holdsworth <redacted>
Mon, 2 Dec 2013 21:02:56 +0000 (21:02 +0000)
pv/data/analog.cpp
pv/data/analog.h
pv/data/decoderstack.cpp
pv/data/decoderstack.h
pv/data/logic.cpp
pv/data/logic.h
pv/data/signaldata.h
pv/view/decode/annotation.cpp
pv/view/decode/annotation.h

index 6e2f2db8413a2b9917f246aa59ad539dda574f29..dd4097a8d2a7cea131e7d3eea6912a4caead690e 100644 (file)
@@ -18,6 +18,8 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#include <boost/foreach.hpp>
+
 #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<AnalogSnapshot> s, _snapshots) {
+               assert(s);
+               l = max(l, s->get_sample_count());
+       }
+       return l;
+}
+
 } // namespace data
 } // namespace pv
index 47514ad9246d50c1b3f5077db9ca22bc5bc53f23..42e31677ebdcae8f350fc5ebbfd859d99ba86914 100644 (file)
@@ -44,6 +44,8 @@ public:
 
        void clear();
 
+       uint64_t get_max_sample_count() const;
+
 private:
        std::deque< boost::shared_ptr<AnalogSnapshot> > _snapshots;
 };
index 333741ad80c2219f1f961566a9a3784319c3b45f..f0bdd6bd4f6e3556a3777e7cabfea49d06b2acc6 100644 (file)
@@ -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::Logic> data)
 {
        srd_session *session;
index 029ca25c21c91350c7709074aacd6c7a758ff88d..dc656f91f7f9b503ff13a850cc35e0328a68a3f5 100644 (file)
@@ -85,6 +85,8 @@ public:
 
        void clear();
 
+       uint64_t get_max_sample_count() const;
+
        void begin_decode();
 
 private:
index 4317d44d5922b71a76aa598aa4af2b2530e8fc1d..d13cd766cc69f9eabfed4930ab6c4550ce9a7808 100644 (file)
@@ -18,6 +18,8 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#include <boost/foreach.hpp>
+
 #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<LogicSnapshot> s, _snapshots) {
+               assert(s);
+               l = max(l, s->get_sample_count());
+       }
+       return l;
+}
+
 } // namespace data
 } // namespace pv
index 739b52e86327caf42f788c46972cf28b680d0926..3d8339421f18506d0882160fa8ab3e8639c20d57 100644 (file)
@@ -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<LogicSnapshot> > _snapshots;
index eb9d14c67b421124fd7319cdc38dab14d32d1d4c..ba80ac3a579dcc976413d7610c49f43c77dd7d39 100644 (file)
@@ -39,6 +39,8 @@ public:
 
        virtual void clear() = 0;
 
+       virtual uint64_t get_max_sample_count() const = 0;
+
 protected:
        double _start_time;
        double _samplerate;
index 3a0a51fda26adc24605d2f55eb3ade98a3fd2e56..0005847655fcfbc77d1451c2cc0f7d232f54e7c4 100644 (file)
@@ -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)
index 078c12a19190d47ed7baeedb4c28fe79b84e7b25..d0282114a21972c3eb53de8b253a55c5c5fd2556 100644 (file)
@@ -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);