]> sigrok.org Git - pulseview.git/blame - pv/storesession.hpp
Show sampling points in logic traces.
[pulseview.git] / pv / storesession.hpp
CommitLineData
0fbda3c2
JH
1/*
2 * This file is part of the PulseView project.
3 *
4 * Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
efdec55a 17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
0fbda3c2
JH
18 */
19
7a01bd36
JH
20#ifndef PULSEVIEW_PV_STORESESSION_HPP
21#define PULSEVIEW_PV_STORESESSION_HPP
0fbda3c2
JH
22
23#include <stdint.h>
24
3b68d03d 25#include <atomic>
c1035a14 26#include <fstream>
e93f5538 27#include <map>
4764bc4d 28#include <memory>
3b68d03d 29#include <mutex>
0fbda3c2 30#include <string>
3b68d03d 31#include <thread>
0fbda3c2 32
e93f5538
JH
33#include <glibmm/variant.h>
34
0fbda3c2
JH
35#include <QObject>
36
7223eb62
ML
37namespace sigrok {
38class Output;
4764bc4d 39class OutputFormat;
7223eb62
ML
40}
41
0fbda3c2
JH
42namespace pv {
43
2b81ae46 44class Session;
0fbda3c2
JH
45
46namespace data {
bf0edd2b 47class SignalBase;
c51ae0b4 48class AnalogSegment;
f3d66e52 49class LogicSegment;
0fbda3c2
JH
50}
51
52class StoreSession : public QObject
53{
54 Q_OBJECT
55
56private:
57 static const size_t BlockSize;
58
59public:
60 StoreSession(const std::string &file_name,
4764bc4d 61 const std::shared_ptr<sigrok::OutputFormat> &output_format,
e93f5538 62 const std::map<std::string, Glib::VariantBase> &options,
d2fc6be9 63 const std::pair<uint64_t, uint64_t> sample_range,
2b81ae46 64 const Session &session);
0fbda3c2
JH
65
66 ~StoreSession();
67
e40b2f29 68 std::pair<int, int> progress() const;
0fbda3c2
JH
69
70 const QString& error() const;
71
72 bool start();
73
74 void wait();
75
76 void cancel();
77
78private:
bf0edd2b 79 void store_proc(std::vector< std::shared_ptr<data::SignalBase> > achannel_list,
c51ae0b4
SA
80 std::vector< std::shared_ptr<pv::data::AnalogSegment> > asegment_list,
81 std::shared_ptr<pv::data::LogicSegment> lsegment);
0fbda3c2 82
e9213170 83Q_SIGNALS:
0fbda3c2
JH
84 void progress_updated();
85
5ccfc97e
SA
86 void store_successful();
87
0fbda3c2 88private:
8dbbc7f0 89 const std::string file_name_;
4764bc4d 90 const std::shared_ptr<sigrok::OutputFormat> output_format_;
e93f5538 91 const std::map<std::string, Glib::VariantBase> options_;
d2fc6be9 92 const std::pair<uint64_t, uint64_t> sample_range_;
2b81ae46 93 const Session &session_;
0fbda3c2 94
8dbbc7f0 95 std::shared_ptr<sigrok::Output> output_;
c1035a14 96 std::ofstream output_stream_;
7223eb62 97
8dbbc7f0 98 std::thread thread_;
3b68d03d 99
8dbbc7f0 100 std::atomic<bool> interrupt_;
0fbda3c2 101
8dbbc7f0 102 std::atomic<int> units_stored_, unit_count_;
b101c41e 103
8dbbc7f0
JH
104 mutable std::mutex mutex_;
105 QString error_;
d2fc6be9
SA
106
107 uint64_t start_sample_, sample_count_;
0fbda3c2
JH
108};
109
110} // pv
111
7a01bd36 112#endif // PULSEVIEW_PV_STORESESSION_HPP