]>
Commit | Line | Data |
---|---|---|
bf0edd2b SA |
1 | /* |
2 | * This file is part of the PulseView project. | |
3 | * | |
4 | * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk> | |
5 | * Copyright (C) 2016 Soeren Apel <soeren@apelpie.net> | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
efdec55a | 18 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
bf0edd2b SA |
19 | */ |
20 | ||
21 | #ifndef PULSEVIEW_PV_DATA_SIGNALBASE_HPP | |
22 | #define PULSEVIEW_PV_DATA_SIGNALBASE_HPP | |
23 | ||
24 | #include <QColor> | |
25 | #include <QObject> | |
6de38b17 | 26 | #include <QSettings> |
bf0edd2b SA |
27 | #include <QString> |
28 | ||
29 | #include <libsigrokcxx/libsigrokcxx.hpp> | |
30 | ||
6f925ba9 | 31 | using std::shared_ptr; |
bf0edd2b SA |
32 | |
33 | namespace sigrok { | |
34 | class Channel; | |
bf0edd2b SA |
35 | } |
36 | ||
37 | namespace pv { | |
38 | namespace data { | |
39 | ||
cbd2a2de | 40 | class Analog; |
bb7dd726 | 41 | class DecoderStack; |
cbd2a2de SA |
42 | class Logic; |
43 | class SignalData; | |
44 | ||
bf0edd2b SA |
45 | class SignalBase : public QObject |
46 | { | |
47 | Q_OBJECT | |
48 | ||
472a80c5 SA |
49 | public: |
50 | enum ChannelType { | |
51 | AnalogChannel = 1, | |
52 | LogicChannel, | |
53 | DecodeChannel, | |
54 | A2LChannel, // Analog converted to logic, joint representation | |
55 | MathChannel | |
56 | }; | |
57 | ||
bf0edd2b SA |
58 | private: |
59 | static const int ColourBGAlpha; | |
60 | ||
61 | public: | |
472a80c5 | 62 | SignalBase(shared_ptr<sigrok::Channel> channel, ChannelType channel_type); |
bf0edd2b SA |
63 | virtual ~SignalBase() {} |
64 | ||
65 | public: | |
66 | /** | |
67 | * Returns the underlying SR channel. | |
68 | */ | |
6f925ba9 | 69 | shared_ptr<sigrok::Channel> channel() const; |
bf0edd2b SA |
70 | |
71 | /** | |
72 | * Returns enabled status of this channel. | |
73 | */ | |
74 | bool enabled() const; | |
75 | ||
76 | /** | |
77 | * Sets the enabled status of this channel. | |
78 | * @param value Boolean value to set. | |
79 | */ | |
80 | void set_enabled(bool value); | |
81 | ||
82 | /** | |
83 | * Gets the type of this channel. | |
84 | */ | |
472a80c5 | 85 | ChannelType type() const; |
bf0edd2b SA |
86 | |
87 | /** | |
88 | * Gets the index number of this channel. | |
89 | */ | |
90 | unsigned int index() const; | |
91 | ||
92 | /** | |
93 | * Gets the name of this signal. | |
94 | */ | |
95 | QString name() const; | |
96 | ||
050b5a6c SA |
97 | /** |
98 | * Gets the internal name of this signal, i.e. how the device calls it. | |
99 | */ | |
100 | QString internal_name() const; | |
101 | ||
bf0edd2b SA |
102 | /** |
103 | * Sets the name of the signal. | |
104 | */ | |
105 | virtual void set_name(QString name); | |
106 | ||
107 | /** | |
108 | * Get the colour of the signal. | |
109 | */ | |
110 | QColor colour() const; | |
111 | ||
112 | /** | |
113 | * Set the colour of the signal. | |
114 | */ | |
115 | void set_colour(QColor colour); | |
116 | ||
117 | /** | |
118 | * Get the background colour of the signal. | |
119 | */ | |
120 | QColor bgcolour() const; | |
121 | ||
cbd2a2de SA |
122 | /** |
123 | * Sets the internal data object. | |
124 | */ | |
6f925ba9 | 125 | void set_data(shared_ptr<pv::data::SignalData> data); |
cbd2a2de SA |
126 | |
127 | /** | |
128 | * Get the internal data as analog data object in case of analog type. | |
129 | */ | |
6f925ba9 | 130 | shared_ptr<pv::data::Analog> analog_data() const; |
cbd2a2de SA |
131 | |
132 | /** | |
133 | * Get the internal data as logic data object in case of logic type. | |
134 | */ | |
6f925ba9 | 135 | shared_ptr<pv::data::Logic> logic_data() const; |
cbd2a2de | 136 | |
bb7dd726 SA |
137 | #ifdef ENABLE_DECODE |
138 | bool is_decode_signal() const; | |
139 | ||
6f925ba9 | 140 | shared_ptr<pv::data::DecoderStack> decoder_stack() const; |
bb7dd726 | 141 | |
6f925ba9 | 142 | void set_decoder_stack(shared_ptr<pv::data::DecoderStack> decoder_stack); |
bb7dd726 | 143 | #endif |
cbd2a2de | 144 | |
6de38b17 SA |
145 | void save_settings(QSettings &settings) const; |
146 | ||
147 | void restore_settings(QSettings &settings); | |
148 | ||
bf0edd2b SA |
149 | Q_SIGNALS: |
150 | void enabled_changed(const bool &value); | |
151 | ||
152 | void name_changed(const QString &name); | |
153 | ||
154 | void colour_changed(const QColor &colour); | |
155 | ||
156 | private: | |
6f925ba9 | 157 | shared_ptr<sigrok::Channel> channel_; |
472a80c5 | 158 | ChannelType channel_type_; |
6f925ba9 | 159 | shared_ptr<pv::data::SignalData> data_; |
cbd2a2de | 160 | |
bb7dd726 | 161 | #ifdef ENABLE_DECODE |
6f925ba9 | 162 | shared_ptr<pv::data::DecoderStack> decoder_stack_; |
bb7dd726 SA |
163 | #endif |
164 | ||
050b5a6c | 165 | QString internal_name_, name_; |
bf0edd2b SA |
166 | QColor colour_, bgcolour_; |
167 | }; | |
168 | ||
169 | } // namespace data | |
170 | } // namespace pv | |
171 | ||
172 | #endif // PULSEVIEW_PV_DATA_SIGNALBASE_HPP |