X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdata%2Flogic.cpp;h=b094a0c828334059029936cd48d40cbd22844dc8;hp=cd80ac99de13ca54384e9a7013239d68076f7823;hb=eeceee9955e7db4ac777d49d1b7a766069476b08;hpb=7db61e770abd2d1c7eb326a09e35cd4266664c1d diff --git a/pv/data/logic.cpp b/pv/data/logic.cpp index cd80ac99..b094a0c8 100644 --- a/pv/data/logic.cpp +++ b/pv/data/logic.cpp @@ -42,10 +42,9 @@ unsigned int Logic::num_channels() const return num_channels_; } -void Logic::push_segment( - shared_ptr &segment) +void Logic::push_segment(shared_ptr &segment) { - segments_.push_front(segment); + segments_.push_back(segment); } const deque< shared_ptr >& Logic::logic_segments() const @@ -55,8 +54,12 @@ const deque< shared_ptr >& Logic::logic_segments() const vector< shared_ptr > Logic::segments() const { - return vector< shared_ptr >( - segments_.begin(), segments_.end()); + return vector< shared_ptr >(segments_.begin(), segments_.end()); +} + +uint32_t Logic::get_segment_count() const +{ + return (uint32_t)segments_.size(); } void Logic::clear() @@ -66,10 +69,18 @@ void Logic::clear() samples_cleared(); } +double Logic::get_samplerate() const +{ + if (segments_.empty()) + return 1.0; + + return segments_.front()->samplerate(); +} + uint64_t Logic::max_sample_count() const { uint64_t l = 0; - for (std::shared_ptr s : segments_) { + for (shared_ptr s : segments_) { assert(s); l = max(l, s->get_sample_count()); }