]>
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 | ||
7223eb62 ML |
37 | namespace sigrok { |
38 | class Output; | |
4764bc4d | 39 | class OutputFormat; |
7223eb62 ML |
40 | } |
41 | ||
0fbda3c2 JH |
42 | namespace pv { |
43 | ||
2b81ae46 | 44 | class Session; |
0fbda3c2 JH |
45 | |
46 | namespace data { | |
bf0edd2b | 47 | class SignalBase; |
c51ae0b4 | 48 | class AnalogSegment; |
f3d66e52 | 49 | class LogicSegment; |
0fbda3c2 JH |
50 | } |
51 | ||
52 | class StoreSession : public QObject | |
53 | { | |
54 | Q_OBJECT | |
55 | ||
56 | private: | |
57 | static const size_t BlockSize; | |
58 | ||
59 | public: | |
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 | ||
78 | private: | |
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 | 83 | Q_SIGNALS: |
0fbda3c2 JH |
84 | void progress_updated(); |
85 | ||
86 | private: | |
8dbbc7f0 | 87 | const std::string file_name_; |
4764bc4d | 88 | const std::shared_ptr<sigrok::OutputFormat> output_format_; |
e93f5538 | 89 | const std::map<std::string, Glib::VariantBase> options_; |
d2fc6be9 | 90 | const std::pair<uint64_t, uint64_t> sample_range_; |
2b81ae46 | 91 | const Session &session_; |
0fbda3c2 | 92 | |
8dbbc7f0 | 93 | std::shared_ptr<sigrok::Output> output_; |
c1035a14 | 94 | std::ofstream output_stream_; |
7223eb62 | 95 | |
8dbbc7f0 | 96 | std::thread thread_; |
3b68d03d | 97 | |
8dbbc7f0 | 98 | std::atomic<bool> interrupt_; |
0fbda3c2 | 99 | |
8dbbc7f0 | 100 | std::atomic<int> units_stored_, unit_count_; |
b101c41e | 101 | |
8dbbc7f0 JH |
102 | mutable std::mutex mutex_; |
103 | QString error_; | |
d2fc6be9 SA |
104 | |
105 | uint64_t start_sample_, sample_count_; | |
0fbda3c2 JH |
106 | }; |
107 | ||
108 | } // pv | |
109 | ||
7a01bd36 | 110 | #endif // PULSEVIEW_PV_STORESESSION_HPP |