projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use <cmath> in favor of <math.h> everywhere.
[pulseview.git]
/
pv
/
storesession.cpp
diff --git
a/pv/storesession.cpp
b/pv/storesession.cpp
index 95b8da8738a33f8c808633df283b7190ea6b6d70..6ecde13aff92a5594eb3a0f931687e5fa7170d9d 100644
(file)
--- a/
pv/storesession.cpp
+++ b/
pv/storesession.cpp
@@
-20,15
+20,18
@@
#include <cassert>
#include <cassert>
-#include "storesession.h"
+#include "storesession.h
pp
"
-#include <pv/s
igsession.h
>
-#include <pv/data/logic.h>
-#include <pv/data/logics
napshot.h
>
-#include <pv/view/signal.h>
+#include <pv/s
ession.hpp
>
+#include <pv/data/logic.h
pp
>
+#include <pv/data/logics
egment.hpp
>
+#include <pv/view/signal.h
pp
>
#include <libsigrok/libsigrok.hpp>
#include <libsigrok/libsigrok.hpp>
+using boost::shared_lock;
+using boost::shared_mutex;
+
using std::deque;
using std::dynamic_pointer_cast;
using std::lock_guard;
using std::deque;
using std::dynamic_pointer_cast;
using std::lock_guard;
@@
-50,12
+53,12
@@
namespace pv {
const size_t StoreSession::BlockSize = 1024 * 1024;
StoreSession::StoreSession(const std::string &file_name,
const size_t StoreSession::BlockSize = 1024 * 1024;
StoreSession::StoreSession(const std::string &file_name,
- const S
igS
ession &session) :
-
_file_name
(file_name),
-
_session
(session),
-
_interrupt
(false),
-
_units_stored
(0),
-
_unit_count
(0)
+ const Session &session) :
+
file_name_
(file_name),
+
session_
(session),
+
interrupt_
(false),
+
units_stored_
(0),
+
unit_count_
(0)
{
}
{
}
@@
-66,31
+69,31
@@
StoreSession::~StoreSession()
pair<int, int> StoreSession::progress() const
{
pair<int, int> StoreSession::progress() const
{
- return make_pair(
_units_stored.load(), _unit_count
.load());
+ return make_pair(
units_stored_.load(), unit_count_
.load());
}
const QString& StoreSession::error() const
{
}
const QString& StoreSession::error() const
{
- lock_guard<mutex> lock(
_mutex
);
- return
_error
;
+ lock_guard<mutex> lock(
mutex_
);
+ return
error_
;
}
bool StoreSession::start()
{
set< shared_ptr<data::SignalData> > data_set =
}
bool StoreSession::start()
{
set< shared_ptr<data::SignalData> > data_set =
-
_session
.get_data();
+
session_
.get_data();
-
lock_guard<mutex> lock(_session
.signals_mutex());
- const vector< shared_ptr<view::Signal> > &sigs(
_session
.signals());
+
shared_lock<shared_mutex> lock(session_
.signals_mutex());
+ const vector< shared_ptr<view::Signal> > &sigs(
session_
.signals());
// Check we have logic data
if (data_set.empty() || sigs.empty()) {
// Check we have logic data
if (data_set.empty() || sigs.empty()) {
-
_error
= tr("No data to save.");
+
error_
= tr("No data to save.");
return false;
}
if (data_set.size() > 1) {
return false;
}
if (data_set.size() > 1) {
-
_error
= tr("PulseView currently only has support for "
+
error_
= tr("PulseView currently only has support for "
"storing a single data stream.");
return false;
}
"storing a single data stream.");
return false;
}
@@
-98,58
+101,58
@@
bool StoreSession::start()
// Get the logic data
shared_ptr<data::Logic> data;
if (!(data = dynamic_pointer_cast<data::Logic>(*data_set.begin()))) {
// Get the logic data
shared_ptr<data::Logic> data;
if (!(data = dynamic_pointer_cast<data::Logic>(*data_set.begin()))) {
-
_error
= tr("PulseView currently only has support for "
+
error_
= tr("PulseView currently only has support for "
"storing a logic data.");
return false;
}
"storing a logic data.");
return false;
}
- // Get the s
napsho
t
- const deque< shared_ptr<data::LogicS
napshot> > &snapsho
ts =
- data->
get_snapsho
ts();
+ // Get the s
egmen
t
+ const deque< shared_ptr<data::LogicS
egment> > &segmen
ts =
+ data->
logic_segmen
ts();
- if (s
napsho
ts.empty()) {
-
_error = tr("No snapsho
ts to save.");
+ if (s
egmen
ts.empty()) {
+
error_ = tr("No segmen
ts to save.");
return false;
}
return false;
}
- const shared_ptr<data::LogicS
napshot> snapshot(snapsho
ts.front());
- assert(s
napsho
t);
+ const shared_ptr<data::LogicS
egment> segment(segmen
ts.front());
+ assert(s
egmen
t);
// Begin storing
try {
// Begin storing
try {
- auto context =
_session
.session()->context();
+ auto context =
session_
.session()->context();
auto output_format = context->output_formats()["srzip"];
auto output_format = context->output_formats()["srzip"];
- auto device =
_session
.device();
-
_output
= output_format->create_output(device,
+ auto device =
session_
.device();
+
output_
= output_format->create_output(device,
{{"filename",
{{"filename",
- Glib::Variant<Glib::ustring>::create(
_file_name
)}});
+ Glib::Variant<Glib::ustring>::create(
file_name_
)}});
auto meta = context->create_meta_packet(
auto meta = context->create_meta_packet(
- {{ConfigKey::SAMPLERATE,
-
Glib::Variant<guint64>::create(data
->samplerate())}});
-
_output
->receive(meta);
+ {{ConfigKey::SAMPLERATE,
Glib::Variant<guint64>::create(
+
segment
->samplerate())}});
+
output_
->receive(meta);
} catch (Error error) {
} catch (Error error) {
-
_error
= tr("Error while saving.");
+
error_
= tr("Error while saving.");
return false;
}
return false;
}
-
_thread = std::thread(&StoreSession::store_proc, this, snapsho
t);
+
thread_ = std::thread(&StoreSession::store_proc, this, segmen
t);
return true;
}
void StoreSession::wait()
{
return true;
}
void StoreSession::wait()
{
- if (
_thread
.joinable())
-
_thread
.join();
+ if (
thread_
.joinable())
+
thread_
.join();
}
void StoreSession::cancel()
{
}
void StoreSession::cancel()
{
-
_interrupt
= true;
+
interrupt_
= true;
}
}
-void StoreSession::store_proc(shared_ptr<data::LogicS
napshot> snapsho
t)
+void StoreSession::store_proc(shared_ptr<data::LogicS
egment> segmen
t)
{
{
- assert(s
napsho
t);
+ assert(s
egmen
t);
uint64_t start_sample = 0, sample_count;
unsigned progress_scale = 0;
uint64_t start_sample = 0, sample_count;
unsigned progress_scale = 0;
@@
-158,46
+161,49
@@
void StoreSession::store_proc(shared_ptr<data::LogicSnapshot> snapshot)
uint8_t *const data = new uint8_t[BlockSize];
assert(data);
uint8_t *const data = new uint8_t[BlockSize];
assert(data);
- const int unit_size = s
napsho
t->unit_size();
+ const int unit_size = s
egmen
t->unit_size();
assert(unit_size != 0);
assert(unit_size != 0);
- sample_count = s
napsho
t->get_sample_count();
+ sample_count = s
egmen
t->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.
while ((sample_count >> progress_scale) > INT_MAX)
progress_scale ++;
// Qt needs the progress values to fit inside an int. If they would
// not, scale the current and max values down until they do.
while ((sample_count >> progress_scale) > INT_MAX)
progress_scale ++;
-
_unit_count
= sample_count >> progress_scale;
+
unit_count_
= sample_count >> progress_scale;
const unsigned int samples_per_block = BlockSize / unit_size;
const unsigned int samples_per_block = BlockSize / unit_size;
- while (!
_interrupt
&& start_sample < sample_count)
+ while (!
interrupt_
&& start_sample < sample_count)
{
progress_updated();
const uint64_t end_sample = min(
start_sample + samples_per_block, sample_count);
{
progress_updated();
const uint64_t end_sample = min(
start_sample + samples_per_block, sample_count);
- s
napsho
t->get_samples(data, start_sample, end_sample);
+ s
egmen
t->get_samples(data, start_sample, end_sample);
size_t length = end_sample - start_sample;
try {
size_t length = end_sample - start_sample;
try {
- auto context =
_session
.session()->context();
+ auto context =
session_
.session()->context();
auto logic = context->create_logic_packet(data, length, unit_size);
auto logic = context->create_logic_packet(data, length, unit_size);
-
_output
->receive(logic);
+
output_
->receive(logic);
} catch (Error error) {
} catch (Error error) {
-
_error
= tr("Error while saving.");
+
error_
= tr("Error while saving.");
break;
}
start_sample = end_sample;
break;
}
start_sample = end_sample;
-
_units_stored
= start_sample >> progress_scale;
+
units_stored_
= start_sample >> progress_scale;
}
}
+ // Zeroing the progress variables indicates completion
+ units_stored_ = unit_count_ = 0;
+
progress_updated();
progress_updated();
-
_output
.reset();
+
output_
.reset();
delete[] data;
}
delete[] data;
}