]>
Commit | Line | Data |
---|---|---|
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 | ||
6f925ba9 UH |
37 | using std::atomic; |
38 | using std::string; | |
39 | using std::shared_ptr; | |
40 | using std::pair; | |
41 | using std::map; | |
42 | using std::vector; | |
43 | using std::thread; | |
44 | using std::mutex; | |
45 | using std::ofstream; | |
46 | ||
7223eb62 ML |
47 | namespace sigrok { |
48 | class Output; | |
4764bc4d | 49 | class OutputFormat; |
7223eb62 ML |
50 | } |
51 | ||
0fbda3c2 JH |
52 | namespace pv { |
53 | ||
2b81ae46 | 54 | class Session; |
0fbda3c2 JH |
55 | |
56 | namespace data { | |
bf0edd2b | 57 | class SignalBase; |
c51ae0b4 | 58 | class AnalogSegment; |
f3d66e52 | 59 | class LogicSegment; |
0fbda3c2 JH |
60 | } |
61 | ||
62 | class StoreSession : public QObject | |
63 | { | |
64 | Q_OBJECT | |
65 | ||
66 | private: | |
67 | static const size_t BlockSize; | |
68 | ||
69 | public: | |
6f925ba9 UH |
70 | StoreSession(const string &file_name, |
71 | const shared_ptr<sigrok::OutputFormat> &output_format, | |
72 | const map<string, Glib::VariantBase> &options, | |
73 | const pair<uint64_t, uint64_t> sample_range, | |
2b81ae46 | 74 | const Session &session); |
0fbda3c2 JH |
75 | |
76 | ~StoreSession(); | |
77 | ||
6f925ba9 | 78 | pair<int, int> progress() const; |
0fbda3c2 JH |
79 | |
80 | const QString& error() const; | |
81 | ||
82 | bool start(); | |
83 | ||
84 | void wait(); | |
85 | ||
86 | void cancel(); | |
87 | ||
88 | private: | |
6f925ba9 UH |
89 | void store_proc(vector< shared_ptr<data::SignalBase> > achannel_list, |
90 | vector< shared_ptr<pv::data::AnalogSegment> > asegment_list, | |
91 | shared_ptr<pv::data::LogicSegment> lsegment); | |
0fbda3c2 | 92 | |
e9213170 | 93 | Q_SIGNALS: |
0fbda3c2 JH |
94 | void progress_updated(); |
95 | ||
5ccfc97e SA |
96 | void store_successful(); |
97 | ||
0fbda3c2 | 98 | private: |
6f925ba9 UH |
99 | const string file_name_; |
100 | const shared_ptr<sigrok::OutputFormat> output_format_; | |
101 | const map<string, Glib::VariantBase> options_; | |
102 | const pair<uint64_t, uint64_t> sample_range_; | |
2b81ae46 | 103 | const Session &session_; |
0fbda3c2 | 104 | |
6f925ba9 UH |
105 | shared_ptr<sigrok::Output> output_; |
106 | ofstream output_stream_; | |
7223eb62 | 107 | |
8dbbc7f0 | 108 | std::thread thread_; |
3b68d03d | 109 | |
6f925ba9 | 110 | atomic<bool> interrupt_; |
0fbda3c2 | 111 | |
6f925ba9 | 112 | atomic<int> units_stored_, unit_count_; |
b101c41e | 113 | |
6f925ba9 | 114 | mutable mutex mutex_; |
8dbbc7f0 | 115 | QString error_; |
d2fc6be9 SA |
116 | |
117 | uint64_t start_sample_, sample_count_; | |
0fbda3c2 JH |
118 | }; |
119 | ||
120 | } // pv | |
121 | ||
7a01bd36 | 122 | #endif // PULSEVIEW_PV_STORESESSION_HPP |