X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fstoresession.cpp;h=eaa17ea5f98096519f88f44be1373a8a697c171c;hp=9a481dd86696ba60ae5e4b61c03bd9719156b1c8;hb=09f55d9665efb3b17ba7de4bae47be6989e884fe;hpb=c51ae0b4200f11bfcb352677cfd07b62ac12230c;ds=sidebyside diff --git a/pv/storesession.cpp b/pv/storesession.cpp index 9a481dd8..eaa17ea5 100644 --- a/pv/storesession.cpp +++ b/pv/storesession.cpp @@ -14,8 +14,7 @@ * 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 . */ #include @@ -36,8 +35,8 @@ #include #include #include +#include #include -#include #include @@ -62,6 +61,7 @@ using std::vector; using Glib::VariantBase; +using sigrok::ChannelType; using sigrok::ConfigKey; using sigrok::Error; using sigrok::OutputFormat; @@ -105,22 +105,20 @@ const QString& StoreSession::error() const bool StoreSession::start() { - const unordered_set< shared_ptr > sigs(session_.signals()); + const unordered_set< shared_ptr > sigs(session_.signalbases()); shared_ptr any_segment; shared_ptr lsegment; - vector< shared_ptr > achannel_list; + vector< shared_ptr > achannel_list; vector< shared_ptr > asegment_list; - for (shared_ptr signal : sigs) { + for (shared_ptr signal : sigs) { if (!signal->enabled()) continue; - shared_ptr data = signal->data(); - - if (dynamic_pointer_cast(data)) { + if (signal->type() == ChannelType::LOGIC) { // All logic channels share the same data segments - shared_ptr ldata = dynamic_pointer_cast(data); + shared_ptr ldata = signal->logic_data(); const deque< shared_ptr > &lsegments = ldata->logic_segments(); @@ -134,10 +132,9 @@ bool StoreSession::start() any_segment = lsegment; } - if (dynamic_pointer_cast(data)) { + if (signal->type() == ChannelType::ANALOG) { // Each analog channel has its own segments - shared_ptr adata = - dynamic_pointer_cast(data); + shared_ptr adata = signal->analog_data(); const deque< shared_ptr > &asegments = adata->analog_segments(); @@ -150,7 +147,7 @@ bool StoreSession::start() asegment_list.push_back(asegments.front()); any_segment = asegments.front(); - achannel_list.push_back(signal->channel()); + achannel_list.push_back(signal); } } @@ -160,16 +157,20 @@ bool StoreSession::start() } // Check whether the user wants to export a certain sample range + uint64_t end_sample; + if (sample_range_.first == sample_range_.second) { start_sample_ = 0; sample_count_ = any_segment->get_sample_count(); } else { if (sample_range_.first > sample_range_.second) { start_sample_ = sample_range_.second; - sample_count_ = sample_range_.first - sample_range_.second; + end_sample = min(sample_range_.first, any_segment->get_sample_count()); + sample_count_ = end_sample - start_sample_; } else { start_sample_ = sample_range_.first; - sample_count_ = sample_range_.second - sample_range_.first; + end_sample = min(sample_range_.second, any_segment->get_sample_count()); + sample_count_ = end_sample - start_sample_; } } @@ -210,7 +211,7 @@ void StoreSession::cancel() interrupt_ = true; } -void StoreSession::store_proc(vector< shared_ptr > achannel_list, +void StoreSession::store_proc(vector< shared_ptr > achannel_list, vector< shared_ptr > asegment_list, shared_ptr lsegment) { @@ -255,7 +256,7 @@ void StoreSession::store_proc(vector< shared_ptr > achannel_lis const auto context = session_.device_manager().context(); for (unsigned int i = 0; i < achannel_list.size(); i++) { - shared_ptr achannel = achannel_list.at(i); + shared_ptr achannel = (achannel_list.at(i))->channel(); shared_ptr asegment = asegment_list.at(i); const float *adata = @@ -299,6 +300,7 @@ void StoreSession::store_proc(vector< shared_ptr > achannel_lis // Zeroing the progress variables indicates completion units_stored_ = unit_count_ = 0; + store_successful(); progress_updated(); output_.reset();