]> sigrok.org Git - pulseview.git/blame - pv/data/decode/decoder.hpp
Initial support for SRD_OUTPUT_LOGIC
[pulseview.git] / pv / data / decode / decoder.hpp
CommitLineData
7491a29f
JH
1/*
2 * This file is part of the PulseView project.
3 *
4 * Copyright (C) 2013 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/>.
7491a29f
JH
18 */
19
7a01bd36
JH
20#ifndef PULSEVIEW_PV_DATA_DECODE_DECODER_HPP
21#define PULSEVIEW_PV_DATA_DECODE_DECODER_HPP
7491a29f 22
02078aa1 23#include <deque>
7491a29f 24#include <map>
f9abf97e 25#include <memory>
ddee4cf8 26#include <set>
27a3f09b 27#include <vector>
7491a29f 28
7491a29f
JH
29#include <glib.h>
30
02078aa1
SA
31#include <QObject>
32
6a26fc44 33#include <pv/data/decode/row.hpp>
a82325d1 34
02078aa1 35using std::deque;
6f925ba9 36using std::map;
1e948182 37using std::shared_ptr;
6f925ba9 38using std::string;
27a3f09b 39using std::vector;
6f925ba9 40
7491a29f
JH
41struct srd_decoder;
42struct srd_decoder_inst;
8bd26d8b 43struct srd_channel;
7491a29f
JH
44struct srd_session;
45
46namespace pv {
47
7491a29f 48namespace data {
ddee4cf8
JH
49
50class Logic;
04394ded 51class SignalBase;
ddee4cf8 52
7491a29f
JH
53namespace decode {
54
a82325d1
SA
55class Decoder;
56
02078aa1 57class AnnotationClass: public QObject
6a26fc44 58{
02078aa1
SA
59 Q_OBJECT
60
61public:
62 AnnotationClass(size_t _id, char* _name, char* _description, Row* _row);
63
64 bool visible() const;
65 void set_visible(bool visible);
66
67Q_SIGNALS:
68 void visibility_changed();
69
70public:
6a26fc44
SA
71 size_t id;
72 char* name;
73 char* description;
74 Row* row;
02078aa1
SA
75
76private:
77 bool visible_;
6a26fc44
SA
78};
79
a82325d1
SA
80struct DecodeChannel
81{
82 uint16_t id; ///< Global numerical ID for the decode channels in the stack
83 uint16_t bit_id; ///< Tells which bit within a sample represents this channel
84 const bool is_optional;
cf1541a1 85 shared_ptr<const pv::data::SignalBase> assigned_signal;
a82325d1
SA
86 const QString name, desc;
87 int initial_pin_state;
88 const shared_ptr<Decoder> decoder_;
89 const srd_channel *pdch_;
90};
91
04b04675
SA
92struct DecoderLogicOutputChannel {
93 DecoderLogicOutputChannel (QString id, QString desc, uint64_t sr) :
94 id(id), desc(desc), samplerate(sr) {};
95 QString id, desc;
96 uint64_t samplerate;
97};
98
e77de61f
SA
99struct DecodeBinaryClassInfo
100{
ac9494ef 101 uint32_t bin_class_id;
e77de61f
SA
102 char* name;
103 char* description;
104};
105
a82325d1 106
02078aa1 107class Decoder : public QObject
7491a29f 108{
02078aa1
SA
109 Q_OBJECT
110
7491a29f 111public:
f54e68b0 112 Decoder(const srd_decoder *const dec, uint8_t stack_level);
7491a29f
JH
113
114 virtual ~Decoder();
115
6a26fc44 116 const srd_decoder* get_srd_decoder() const;
7491a29f 117
f54e68b0
SA
118 uint8_t get_stack_level() const;
119
e77de61f
SA
120 const char* name() const;
121
5d3ca591
SA
122 bool visible() const;
123 void set_visible(bool visible);
dd048a7e 124
a82325d1
SA
125 const vector<DecodeChannel*>& channels() const;
126 void set_channels(vector<DecodeChannel*> channels);
7491a29f 127
6f925ba9 128 const map<string, GVariant*>& options() const;
7491a29f
JH
129 void set_option(const char *id, GVariant *value);
130
72486b78
SA
131 void apply_all_options();
132
6ac6242b 133 bool have_required_channels() const;
a2d4b551 134
8ce0e732
SA
135 srd_decoder_inst* create_decoder_inst(srd_session *session);
136 void invalidate_decoder_inst();
7491a29f 137
6a26fc44
SA
138 vector<Row*> get_rows();
139 Row* get_row_by_id(size_t id);
140
141 vector<const AnnotationClass*> ann_classes() const;
41293691 142 vector<AnnotationClass*> ann_classes();
6a26fc44 143 AnnotationClass* get_ann_class_by_id(size_t id);
761f8302 144 const AnnotationClass* get_ann_class_by_id(size_t id) const;
6a26fc44 145
ac9494ef
SA
146 uint32_t get_binary_class_count() const;
147 const DecodeBinaryClassInfo* get_binary_class(uint32_t id) const;
a82325d1 148
04b04675
SA
149 bool has_logic_output() const;
150 const vector<DecoderLogicOutputChannel> logic_output_channels() const;
151
02078aa1
SA
152Q_SIGNALS:
153 void annotation_visibility_changed();
154
155private Q_SLOTS:
156 void on_row_visibility_changed();
157 void on_class_visibility_changed();
158
7491a29f 159private:
cbb2e4da 160 const srd_decoder* const srd_decoder_;
f54e68b0 161 uint8_t stack_level_;
dd048a7e 162
5d3ca591 163 bool visible_;
dd048a7e 164
a82325d1 165 vector<DecodeChannel*> channels_;
02078aa1
SA
166 deque<Row> rows_;
167 deque<AnnotationClass> ann_classes_;
e77de61f 168 vector<DecodeBinaryClassInfo> bin_classes_;
6f925ba9 169 map<string, GVariant*> options_;
8ce0e732 170 srd_decoder_inst *decoder_inst_;
7491a29f
JH
171};
172
173} // namespace decode
174} // namespace data
175} // namespace pv
176
7a01bd36 177#endif // PULSEVIEW_PV_DATA_DECODE_DECODER_HPP