]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * This file is part of the PulseView project. | |
3 | * | |
4 | * Copyright (C) 2012 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 | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
20 | ||
21 | #ifndef PULSEVIEW_PV_DATA_DECODERSTACK_H | |
22 | #define PULSEVIEW_PV_DATA_DECODERSTACK_H | |
23 | ||
24 | #include "signaldata.h" | |
25 | ||
26 | #include <list> | |
27 | ||
28 | #include <boost/shared_ptr.hpp> | |
29 | #include <boost/thread.hpp> | |
30 | ||
31 | #include <QObject> | |
32 | #include <QString> | |
33 | ||
34 | struct srd_decoder; | |
35 | struct srd_probe; | |
36 | struct srd_proto_data; | |
37 | ||
38 | namespace DecoderStackTest { | |
39 | class TwoDecoderStack; | |
40 | } | |
41 | ||
42 | namespace pv { | |
43 | ||
44 | namespace view { | |
45 | class LogicSignal; | |
46 | ||
47 | namespace decode { | |
48 | class Annotation; | |
49 | } | |
50 | ||
51 | } | |
52 | ||
53 | namespace data { | |
54 | ||
55 | namespace decode { | |
56 | class Decoder; | |
57 | } | |
58 | ||
59 | class Logic; | |
60 | ||
61 | class DecoderStack : public QObject, public SignalData | |
62 | { | |
63 | Q_OBJECT | |
64 | ||
65 | private: | |
66 | static const double DecodeMargin; | |
67 | static const double DecodeThreshold; | |
68 | static const int64_t DecodeChunkLength; | |
69 | ||
70 | public: | |
71 | DecoderStack(const srd_decoder *const decoder); | |
72 | ||
73 | virtual ~DecoderStack(); | |
74 | ||
75 | const std::list< boost::shared_ptr<decode::Decoder> >& stack() const; | |
76 | void push(boost::shared_ptr<decode::Decoder> decoder); | |
77 | void remove(int index); | |
78 | ||
79 | const std::vector< boost::shared_ptr<pv::view::decode::Annotation> > | |
80 | annotations() const; | |
81 | ||
82 | QString error_message(); | |
83 | ||
84 | void clear_snapshots(); | |
85 | ||
86 | void begin_decode(); | |
87 | ||
88 | private: | |
89 | void decode_proc(boost::shared_ptr<data::Logic> data); | |
90 | ||
91 | static void annotation_callback(srd_proto_data *pdata, | |
92 | void *decoder); | |
93 | ||
94 | signals: | |
95 | void new_decode_data(); | |
96 | ||
97 | private: | |
98 | ||
99 | /** | |
100 | * This mutex prevents more than one decode operation occuring | |
101 | * concurrently. | |
102 | * @todo A proper solution should be implemented to allow multiple | |
103 | * decode operations. | |
104 | */ | |
105 | static boost::mutex _global_decode_mutex; | |
106 | ||
107 | std::list< boost::shared_ptr<decode::Decoder> > _stack; | |
108 | ||
109 | mutable boost::mutex _mutex; | |
110 | std::vector< boost::shared_ptr<pv::view::decode::Annotation> > | |
111 | _annotations; | |
112 | QString _error_message; | |
113 | ||
114 | boost::thread _decode_thread; | |
115 | ||
116 | friend class DecoderStackTest::TwoDecoderStack; | |
117 | }; | |
118 | ||
119 | } // namespace data | |
120 | } // namespace pv | |
121 | ||
122 | #endif // PULSEVIEW_PV_DATA_DECODERSTACK_H |