2 * This file is part of the PulseView project.
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
5 * Copyright (C) 2016 Soeren Apel <soeren@apelpie.net>
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.
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.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #ifndef PULSEVIEW_PV_DATA_SIGNALBASE_HPP
22 #define PULSEVIEW_PV_DATA_SIGNALBASE_HPP
31 #include <libsigrokcxx/libsigrokcxx.hpp>
33 using std::shared_ptr;
47 class SignalBase : public QObject
56 A2LChannel, // Analog converted to logic, joint representation
62 A2LConversionByTreshold = 1,
63 A2LConversionBySchmittTrigger = 2
67 static const int ColourBGAlpha;
70 SignalBase(shared_ptr<sigrok::Channel> channel, ChannelType channel_type);
71 virtual ~SignalBase();
75 * Returns the underlying SR channel.
77 shared_ptr<sigrok::Channel> channel() const;
80 * Returns enabled status of this channel.
85 * Sets the enabled status of this channel.
86 * @param value Boolean value to set.
88 void set_enabled(bool value);
91 * Gets the type of this channel.
93 ChannelType type() const;
96 * Gets the index number of this channel.
98 unsigned int index() const;
101 * Gets the name of this signal.
103 QString name() const;
106 * Gets the internal name of this signal, i.e. how the device calls it.
108 QString internal_name() const;
111 * Sets the name of the signal.
113 virtual void set_name(QString name);
116 * Get the colour of the signal.
118 QColor colour() const;
121 * Set the colour of the signal.
123 void set_colour(QColor colour);
126 * Get the background colour of the signal.
128 QColor bgcolour() const;
131 * Sets the internal data object.
133 void set_data(shared_ptr<pv::data::SignalData> data);
136 * Get the internal data as analog data object in case of analog type.
138 shared_ptr<pv::data::Analog> analog_data() const;
141 * Get the internal data as logic data object in case of logic type.
143 shared_ptr<pv::data::Logic> logic_data() const;
146 * Changes the kind of conversion performed on this channel.
148 void set_conversion_type(ConversionType t);
151 bool is_decode_signal() const;
153 shared_ptr<pv::data::DecoderStack> decoder_stack() const;
155 void set_decoder_stack(shared_ptr<pv::data::DecoderStack> decoder_stack);
158 void save_settings(QSettings &settings) const;
160 void restore_settings(QSettings &settings);
163 uint8_t convert_a2l_threshold(float threshold, float value);
164 uint8_t convert_a2l_schmitt_trigger(float lo_thr, float hi_thr, float value);
166 void conversion_thread_proc(QObject* segment, uint64_t start_sample,
167 uint64_t end_sample);
170 void enabled_changed(const bool &value);
172 void name_changed(const QString &name);
174 void colour_changed(const QColor &colour);
176 void conversion_type_changed(const ConversionType t);
179 void on_samples_cleared();
181 void on_samples_added(QObject* segment, uint64_t start_sample,
182 uint64_t end_sample);
184 void on_capture_state_changed(int state);
187 shared_ptr<sigrok::Channel> channel_;
188 ChannelType channel_type_;
189 shared_ptr<pv::data::SignalData> data_;
190 shared_ptr<pv::data::SignalData> converted_data_;
191 int conversion_type_;
194 shared_ptr<pv::data::DecoderStack> decoder_stack_;
197 std::thread conversion_thread_;
199 QString internal_name_, name_;
200 QColor colour_, bgcolour_;
206 #endif // PULSEVIEW_PV_DATA_SIGNALBASE_HPP