]> sigrok.org Git - pulseview.git/commitdiff
Introduce PV-internal channel types
authorSoeren Apel <redacted>
Wed, 22 Mar 2017 21:45:41 +0000 (22:45 +0100)
committerSoeren Apel <redacted>
Wed, 22 Mar 2017 21:45:41 +0000 (22:45 +0100)
pv/data/signalbase.cpp
pv/data/signalbase.hpp
pv/session.cpp
pv/storesession.cpp
pv/view/decodetrace.cpp

index 06b3e1d866b671b397bb396d95f1c714b6b340f6..ccdc1da7f931fa4b69e0523986876c93467b3aca 100644 (file)
@@ -30,15 +30,15 @@ using std::dynamic_pointer_cast;
 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());
@@ -82,9 +82,9 @@ void SignalBase::set_enabled(bool value)
        }
 }
 
-const ChannelType *SignalBase::type() const
+SignalBase::ChannelType SignalBase::type() const
 {
-       return (channel_) ? channel_->type() : nullptr;
+       return channel_type_;
 }
 
 unsigned int SignalBase::index() const
@@ -119,7 +119,7 @@ void SignalBase::set_data(shared_ptr<pv::data::SignalData> data)
 
 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>();
@@ -127,7 +127,7 @@ shared_ptr<data::Analog> SignalBase::analog_data() const
 
 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>();
index 8b60c36688dcf6f1665ae8c4c7745bb4b60bcc90..4889d16acd4bc1ba75878cfe132e2d07b1202193 100644 (file)
@@ -32,7 +32,6 @@ using std::shared_ptr;
 
 namespace sigrok {
 class Channel;
-class ChannelType;
 }
 
 namespace pv {
@@ -47,11 +46,20 @@ class SignalBase : public QObject
 {
        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:
@@ -74,7 +82,7 @@ public:
        /**
         * Gets the type of this channel.
         */
-       const sigrok::ChannelType *type() const;
+       ChannelType type() const;
 
        /**
         * Gets the index number of this channel.
@@ -147,6 +155,7 @@ Q_SIGNALS:
 
 private:
        shared_ptr<sigrok::Channel> channel_;
+       ChannelType channel_type_;
        shared_ptr<pv::data::SignalData> data_;
 
 #ifdef ENABLE_DECODE
index e84f78042b89593e9cb96adef18ed187067e5b11..2712af1200ab12082bb400c50d0e3f493b0ee5c5 100644 (file)
@@ -89,7 +89,6 @@ using std::vector;
 
 using sigrok::Analog;
 using sigrok::Channel;
-using sigrok::ChannelType;
 using sigrok::ConfigKey;
 using sigrok::DatafeedCallbackFunction;
 using sigrok::Error;
@@ -638,7 +637,7 @@ bool Session::add_decoder(srd_decoder *const dec)
                // 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;
@@ -652,7 +651,7 @@ bool Session::add_decoder(srd_decoder *const dec)
 
                // 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);
@@ -730,7 +729,7 @@ void Session::update_signals()
        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
        {
@@ -780,7 +779,8 @@ void Session::update_signals()
                                        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_);
@@ -796,7 +796,8 @@ void Session::update_signals()
                                        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());
index c2135ab3383564b007c70c3484d0d59155b4eaeb..3c5d899f2ce71a410a5e8845dbecbb703d2389e1 100644 (file)
@@ -60,7 +60,6 @@ using std::vector;
 
 using Glib::VariantBase;
 
-using sigrok::ChannelType;
 using sigrok::ConfigKey;
 using sigrok::Error;
 using sigrok::OutputFormat;
@@ -115,7 +114,7 @@ bool StoreSession::start()
                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();
 
@@ -131,7 +130,7 @@ bool StoreSession::start()
                        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();
 
index c650ee1421d3dd5732887ff7a92a4bbf94d34615..5944fd6430876471f1976c3e992318fc9419ae86 100644 (file)
@@ -877,7 +877,7 @@ QComboBox* DecodeTrace::create_channel_selector(
 
        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()));