#include <cassert>
+#ifdef _WIN32
+// Windows: Avoid boost/thread namespace pollution (which includes windows.h).
+#define NOGDI
+#define NORESOURCE
+#endif
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+
#include "storesession.hpp"
+#include <pv/devicemanager.hpp>
#include <pv/session.hpp>
#include <pv/data/logic.hpp>
#include <pv/data/logicsegment.hpp>
+#include <pv/devices/device.hpp>
#include <pv/view/signal.hpp>
#include <libsigrokcxx/libsigrokcxx.hpp>
using sigrok::ConfigKey;
using sigrok::Error;
using sigrok::OutputFormat;
+using sigrok::OutputFlag;
namespace pv {
bool StoreSession::start()
{
- set< shared_ptr<data::SignalData> > data_set =
- session_.get_data();
+ const unordered_set< shared_ptr<view::Signal> > sigs(session_.signals());
+
+ // Add enabled channels to the data set
+ set< shared_ptr<data::SignalData> > data_set;
- shared_lock<shared_mutex> lock(session_.signals_mutex());
- const unordered_set< shared_ptr<view::Signal> > &sigs(
- session_.signals());
+ for (shared_ptr<view::Signal> signal : sigs)
+ if (signal->enabled())
+ data_set.insert(signal->data());
// Check we have logic data
if (data_set.empty() || sigs.empty()) {
shared_ptr<data::Logic> data;
if (!(data = dynamic_pointer_cast<data::Logic>(*data_set.begin()))) {
error_ = tr("PulseView currently only has support for "
- "storing a logic data.");
+ "storing logic data.");
return false;
}
// Begin storing
try {
- auto context = session_.session()->context();
- auto device = session_.device();
+ const auto context = session_.device_manager().context();
+ auto device = session_.device()->device();
map<string, Glib::VariantBase> options = options_;
- // If the output has the capability to write files, use it.
- // Otherwise, open the output stream.
- const auto opt_list = output_format_->options();
- if (opt_list.find("filename") != opt_list.end())
- options["filename"] =
- Glib::Variant<Glib::ustring>::create(file_name_);
- else
+ if (!output_format_->test_flag(OutputFlag::INTERNAL_IO_HANDLING))
output_stream_.open(file_name_, ios_base::binary |
- ios_base::trunc | ios_base::out);
+ ios_base::trunc | ios_base::out);
- output_ = output_format_->create_output(device, options);
+ output_ = output_format_->create_output(file_name_, device, options);
auto meta = context->create_meta_packet(
{{ConfigKey::SAMPLERATE, Glib::Variant<guint64>::create(
segment->samplerate())}});
start_sample + samples_per_block, sample_count);
segment->get_samples(data, start_sample, end_sample);
- size_t length = end_sample - start_sample;
+ size_t length = (end_sample - start_sample) * unit_size;
try {
- auto context = session_.session()->context();
+ const auto context = session_.device_manager().context();
auto logic = context->create_logic_packet(data, length, unit_size);
const string data = output_->receive(logic);
if (output_stream_.is_open())