#include <cassert>
-#include "storesession.h"
+#include "storesession.hpp"
-#include <pv/sigsession.h>
-#include <pv/data/logic.h>
-#include <pv/data/logicsnapshot.h>
-#include <pv/view/signal.h>
+#include <pv/session.hpp>
+#include <pv/data/logic.hpp>
+#include <pv/data/logicsegment.hpp>
+#include <pv/view/signal.hpp>
#include <libsigrok/libsigrok.hpp>
const size_t StoreSession::BlockSize = 1024 * 1024;
StoreSession::StoreSession(const std::string &file_name,
- const SigSession &session) :
+ const Session &session) :
file_name_(file_name),
session_(session),
interrupt_(false),
return false;
}
- // Get the snapshot
- const deque< shared_ptr<data::LogicSnapshot> > &snapshots =
- data->get_snapshots();
+ // Get the segment
+ const deque< shared_ptr<data::LogicSegment> > &segments =
+ data->logic_segments();
- if (snapshots.empty()) {
- error_ = tr("No snapshots to save.");
+ if (segments.empty()) {
+ error_ = tr("No segments to save.");
return false;
}
- const shared_ptr<data::LogicSnapshot> snapshot(snapshots.front());
- assert(snapshot);
+ const shared_ptr<data::LogicSegment> segment(segments.front());
+ assert(segment);
// Begin storing
try {
{{"filename",
Glib::Variant<Glib::ustring>::create(file_name_)}});
auto meta = context->create_meta_packet(
- {{ConfigKey::SAMPLERATE,
- Glib::Variant<guint64>::create(data->samplerate())}});
+ {{ConfigKey::SAMPLERATE, Glib::Variant<guint64>::create(
+ segment->samplerate())}});
output_->receive(meta);
} catch (Error error) {
error_ = tr("Error while saving.");
return false;
}
- thread_ = std::thread(&StoreSession::store_proc, this, snapshot);
+ thread_ = std::thread(&StoreSession::store_proc, this, segment);
return true;
}
interrupt_ = true;
}
-void StoreSession::store_proc(shared_ptr<data::LogicSnapshot> snapshot)
+void StoreSession::store_proc(shared_ptr<data::LogicSegment> segment)
{
- assert(snapshot);
+ assert(segment);
uint64_t start_sample = 0, sample_count;
unsigned progress_scale = 0;
uint8_t *const data = new uint8_t[BlockSize];
assert(data);
- const int unit_size = snapshot->unit_size();
+ const int unit_size = segment->unit_size();
assert(unit_size != 0);
- sample_count = snapshot->get_sample_count();
+ sample_count = segment->get_sample_count();
// Qt needs the progress values to fit inside an int. If they would
// not, scale the current and max values down until they do.
const uint64_t end_sample = min(
start_sample + samples_per_block, sample_count);
- snapshot->get_samples(data, start_sample, end_sample);
+ segment->get_samples(data, start_sample, end_sample);
size_t length = end_sample - start_sample;
units_stored_ = start_sample >> progress_scale;
}
+ // Zeroing the progress variables indicates completion
+ units_stored_ = unit_count_ = 0;
+
progress_updated();
output_.reset();