]>
Commit | Line | Data |
---|---|---|
ad908057 SA |
1 | /* |
2 | * This file is part of the PulseView project. | |
3 | * | |
4 | * Copyright (C) 2017 Soeren Apel <soeren@apelpie.net> | |
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, see <http://www.gnu.org/licenses/>. | |
18 | */ | |
19 | ||
20 | #ifndef PULSEVIEW_PV_DATA_DECODESIGNAL_HPP | |
21 | #define PULSEVIEW_PV_DATA_DECODESIGNAL_HPP | |
22 | ||
132a5c6d | 23 | #include <unordered_set> |
ecd07c20 SA |
24 | #include <vector> |
25 | ||
26 | #include <QString> | |
27 | ||
ad908057 SA |
28 | #include <libsigrokdecode/libsigrokdecode.h> |
29 | ||
30 | #include <pv/data/signalbase.hpp> | |
946b52e1 | 31 | #include <pv/util.hpp> |
ad908057 | 32 | |
ecd07c20 | 33 | using std::list; |
132a5c6d | 34 | using std::unordered_set; |
ecd07c20 | 35 | using std::vector; |
ad908057 SA |
36 | using std::shared_ptr; |
37 | ||
38 | namespace pv { | |
39 | namespace data { | |
40 | ||
ecd07c20 SA |
41 | namespace decode { |
42 | class Annotation; | |
43 | class Decoder; | |
44 | class Row; | |
45 | } | |
46 | ||
ad908057 SA |
47 | class DecoderStack; |
48 | class Logic; | |
9f97b357 | 49 | class SignalBase; |
ad908057 SA |
50 | class SignalData; |
51 | ||
9f97b357 SA |
52 | struct DecodeChannel |
53 | { | |
54 | uint16_t id; // Also tells which bit within a sample represents this channel | |
55 | const bool is_optional; | |
56 | const pv::data::SignalBase *assigned_signal; | |
57 | const QString name, desc; | |
58 | int initial_pin_state; | |
59 | const shared_ptr<pv::data::decode::Decoder> decoder_; | |
60 | const srd_channel *pdch_; | |
61 | }; | |
62 | ||
ad908057 SA |
63 | class DecodeSignal : public SignalBase |
64 | { | |
65 | Q_OBJECT | |
66 | ||
67 | public: | |
132a5c6d SA |
68 | DecodeSignal(shared_ptr<pv::data::DecoderStack> decoder_stack, |
69 | const unordered_set< shared_ptr<data::SignalBase> > &all_signals); | |
ad908057 SA |
70 | virtual ~DecodeSignal(); |
71 | ||
72 | bool is_decode_signal() const; | |
ecd07c20 SA |
73 | shared_ptr<data::DecoderStack> decoder_stack() const; |
74 | const list< shared_ptr<data::decode::Decoder> >& decoder_stack_list() const; | |
ad908057 SA |
75 | |
76 | void stack_decoder(srd_decoder *decoder); | |
77 | void remove_decoder(int index); | |
78 | bool toggle_decoder_visibility(int index); | |
79 | ||
946b52e1 | 80 | void begin_decode(); |
ecd07c20 SA |
81 | QString error_message() const; |
82 | ||
9f97b357 | 83 | const list<data::DecodeChannel> get_channels() const; |
132a5c6d | 84 | void auto_assign_signals(); |
9f97b357 SA |
85 | void assign_signal(const uint16_t channel_id, const SignalBase *signal); |
86 | ||
87 | void set_initial_pin_state(const uint16_t channel_id, const int init_state); | |
88 | ||
ff83d980 SA |
89 | double samplerate() const; |
90 | const pv::util::Timestamp& start_time() const; | |
91 | int64_t sample_count() const; | |
92 | int64_t samples_decoded() const; | |
93 | ||
ecd07c20 SA |
94 | vector<decode::Row> visible_rows() const; |
95 | ||
96 | /** | |
97 | * Extracts sorted annotations between two period into a vector. | |
98 | */ | |
99 | void get_annotation_subset( | |
100 | vector<pv::data::decode::Annotation> &dest, | |
101 | const decode::Row &row, uint64_t start_sample, | |
102 | uint64_t end_sample) const; | |
103 | ||
9f97b357 SA |
104 | private: |
105 | void update_channel_list(); | |
106 | ||
ad908057 SA |
107 | Q_SIGNALS: |
108 | void new_annotations(); | |
9f97b357 | 109 | void channels_updated(); |
ad908057 SA |
110 | |
111 | private Q_SLOTS: | |
112 | void on_new_annotations(); | |
113 | ||
114 | private: | |
115 | shared_ptr<pv::data::DecoderStack> decoder_stack_; | |
132a5c6d | 116 | const unordered_set< shared_ptr<data::SignalBase> > &all_signals_; |
9f97b357 | 117 | list<data::DecodeChannel> channels_; |
ad908057 SA |
118 | }; |
119 | ||
120 | } // namespace data | |
121 | } // namespace pv | |
122 | ||
123 | #endif // PULSEVIEW_PV_DATA_DECODESIGNAL_HPP |