using std::shared_ptr;
using sigrok::Channel;
-using sigrok::ChannelType;
namespace pv {
namespace data {
const int SignalBase::ColourBGAlpha = 8*256/100;
-SignalBase::SignalBase(shared_ptr<sigrok::Channel> channel) :
- channel_(channel)
+SignalBase::SignalBase(shared_ptr<sigrok::Channel> channel, ChannelType channel_type) :
+ channel_(channel),
+ channel_type_(channel_type)
{
if (channel_)
internal_name_ = QString::fromStdString(channel_->name());
}
}
-const ChannelType *SignalBase::type() const
+SignalBase::ChannelType SignalBase::type() const
{
- return (channel_) ? channel_->type() : nullptr;
+ return channel_type_;
}
unsigned int SignalBase::index() const
shared_ptr<data::Analog> SignalBase::analog_data() const
{
- if (type() == ChannelType::ANALOG)
+ if (channel_type_ == AnalogChannel)
return dynamic_pointer_cast<data::Analog>(data_);
else
return shared_ptr<data::Analog>();
shared_ptr<data::Logic> SignalBase::logic_data() const
{
- if (type() == ChannelType::LOGIC)
+ if (channel_type_ == LogicChannel)
return dynamic_pointer_cast<data::Logic>(data_);
else
return shared_ptr<data::Logic>();
namespace sigrok {
class Channel;
-class ChannelType;
}
namespace pv {
{
Q_OBJECT
+public:
+ enum ChannelType {
+ AnalogChannel = 1,
+ LogicChannel,
+ DecodeChannel,
+ A2LChannel, // Analog converted to logic, joint representation
+ MathChannel
+ };
+
private:
static const int ColourBGAlpha;
public:
- SignalBase(shared_ptr<sigrok::Channel> channel);
+ SignalBase(shared_ptr<sigrok::Channel> channel, ChannelType channel_type);
virtual ~SignalBase() {}
public:
/**
* Gets the type of this channel.
*/
- const sigrok::ChannelType *type() const;
+ ChannelType type() const;
/**
* Gets the index number of this channel.
private:
shared_ptr<sigrok::Channel> channel_;
+ ChannelType channel_type_;
shared_ptr<pv::data::SignalData> data_;
#ifdef ENABLE_DECODE
using sigrok::Analog;
using sigrok::Channel;
-using sigrok::ChannelType;
using sigrok::ConfigKey;
using sigrok::DatafeedCallbackFunction;
using sigrok::Error;
// Auto select the initial channels
for (const srd_channel *pdch : all_channels)
for (shared_ptr<data::SignalBase> b : signalbases_) {
- if (b->type() == ChannelType::LOGIC) {
+ if (b->type() == data::SignalBase::LogicChannel) {
if (QString::fromUtf8(pdch->name).toLower().
contains(b->name().toLower()))
channels[pdch] = b;
// Create the decode signal
shared_ptr<data::SignalBase> signalbase =
- make_shared<data::SignalBase>(nullptr);
+ make_shared<data::SignalBase>(nullptr, data::SignalBase::DecodeChannel);
signalbase->set_decoder_stack(decoder_stack);
signalbases_.insert(signalbase);
unsigned int logic_channel_count = count_if(
channels.begin(), channels.end(),
[] (shared_ptr<Channel> channel) {
- return channel->type() == ChannelType::LOGIC; });
+ return channel->type() == sigrok::ChannelType::LOGIC; });
// Create data containers for the logic data segments
{
switch(channel->type()->id()) {
case SR_CHANNEL_LOGIC:
if (!signalbase) {
- signalbase = make_shared<data::SignalBase>(channel);
+ signalbase = make_shared<data::SignalBase>(channel,
+ data::SignalBase::LogicChannel);
signalbases_.insert(signalbase);
all_signal_data_.insert(logic_data_);
case SR_CHANNEL_ANALOG:
{
if (!signalbase) {
- signalbase = make_shared<data::SignalBase>(channel);
+ signalbase = make_shared<data::SignalBase>(channel,
+ data::SignalBase::AnalogChannel);
signalbases_.insert(signalbase);
shared_ptr<data::Analog> data(new data::Analog());
using Glib::VariantBase;
-using sigrok::ChannelType;
using sigrok::ConfigKey;
using sigrok::Error;
using sigrok::OutputFormat;
if (!signal->enabled())
continue;
- if (signal->type() == ChannelType::LOGIC) {
+ if (signal->type() == data::SignalBase::LogicChannel) {
// All logic channels share the same data segments
shared_ptr<data::Logic> ldata = signal->logic_data();
any_segment = lsegment;
}
- if (signal->type() == ChannelType::ANALOG) {
+ if (signal->type() == data::SignalBase::AnalogChannel) {
// Each analog channel has its own segments
shared_ptr<data::Analog> adata = signal->analog_data();
for (const shared_ptr<data::SignalBase> &b : sig_list) {
assert(b);
- if (b->type() == sigrok::ChannelType::LOGIC && b->enabled()) {
+ if (b->type() == data::SignalBase::LogicChannel && b->enabled()) {
selector->addItem(b->name(),
qVariantFromValue((void*)b.get()));