]> sigrok.org Git - pulseview.git/commitdiff
Channels: Let "Enable all changing" also check for sample data
authorSoeren Apel <redacted>
Sun, 8 Apr 2018 21:03:33 +0000 (23:03 +0200)
committerSoeren Apel <redacted>
Sun, 15 Apr 2018 06:18:42 +0000 (08:18 +0200)
pv/data/signalbase.cpp
pv/data/signalbase.hpp
pv/popups/channels.cpp

index 2972d4043cf7a7bb3e6b48b49e9b190589b92884..5f6dc398f012d8507ca499f56b84887e04ec5a97 100644 (file)
@@ -238,6 +238,33 @@ bool SignalBase::segment_is_complete(uint32_t segment_id) const
        return result;
 }
 
+bool SignalBase::has_samples() const
+{
+       bool result = false;
+
+       if (channel_type_ == AnalogChannel)
+       {
+               shared_ptr<Analog> data = dynamic_pointer_cast<Analog>(data_);
+               if (data) {
+                       auto segments = data->analog_segments();
+                       if ((segments.size() > 0) && (segments.front()->get_sample_count() > 0))
+                               result = true;
+               }
+       }
+
+       if (channel_type_ == LogicChannel)
+       {
+               shared_ptr<Logic> data = dynamic_pointer_cast<Logic>(data_);
+               if (data) {
+                       auto segments = data->logic_segments();
+                       if ((segments.size() > 0) && (segments.front()->get_sample_count() > 0))
+                               result = true;
+               }
+       }
+
+       return result;
+}
+
 SignalBase::ConversionType SignalBase::get_conversion_type() const
 {
        return conversion_type_;
index efe4a54abe484bbd571a1209aacdad6d729beaff..3356af5b786ad3fefeace38f7d42fe32dc7bdfa7 100644 (file)
@@ -187,6 +187,11 @@ public:
         */
        bool segment_is_complete(uint32_t segment_id) const;
 
+       /**
+        * Determines whether this signal has any sample data at all.
+        */
+       bool has_samples() const;
+
        /**
         * Queries the kind of conversion performed on this channel.
         */
index a24c26517245b31021ab650098a6bb061abf0b51..fdb97728f59fe080506c81ecd9acbae0039f3d6d 100644 (file)
@@ -311,6 +311,10 @@ void Channels::enable_all_changing_channels()
 {
        set_all_channels_conditionally([](const shared_ptr<SignalBase> signal)
                {
+                       // Never enable channels without sample data
+                       if (!signal->has_samples())
+                               return false;
+
                        // Non-logic channels are considered to always have a signal
                        if (signal->type() != SignalBase::LogicChannel)
                                return true;