X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdata%2Fsignalbase.cpp;h=173610d945e7b66ff5ce3e1b45e05b1c821a3b2e;hp=09e4400e20a9d1584ca88dc6caa7d8974ddd3bb4;hb=ccccb91439b9de48a7bcc76c6fa45d1dc166a297;hpb=3fbddf7f0e83fe72b8f0e0e69faf05579c096f84 diff --git a/pv/data/signalbase.cpp b/pv/data/signalbase.cpp index 09e4400e..173610d9 100644 --- a/pv/data/signalbase.cpp +++ b/pv/data/signalbase.cpp @@ -185,6 +185,13 @@ void SignalBase::set_conversion_type(ConversionType t) conversion_type_ = t; + // Re-create an empty container + // so that the signal is recognized as providing logic data + // and thus can be assigned to a decoder + if (conversion_is_a2l()) + if (!converted_data_) + converted_data_ = make_shared(1); // Contains only one channel + start_conversion(); conversion_type_changed(t); @@ -229,6 +236,13 @@ uint8_t SignalBase::convert_a2l_schmitt_trigger(float lo_thr, float hi_thr, return state; } +bool SignalBase::conversion_is_a2l() const +{ + return ((channel_type_ == AnalogChannel) && + ((conversion_type_ == A2LConversionByTreshold) || + (conversion_type_ == A2LConversionBySchmittTrigger))); +} + void SignalBase::conversion_thread_proc(QObject* segment) { // TODO Support for multiple segments is missing @@ -237,19 +251,11 @@ void SignalBase::conversion_thread_proc(QObject* segment) start_sample = end_sample = 0; do { - if ((channel_type_ == AnalogChannel) && - ((conversion_type_ == A2LConversionByTreshold) || - (conversion_type_ == A2LConversionBySchmittTrigger))) { + if (conversion_is_a2l()) { AnalogSegment *asegment = qobject_cast(segment); - // Create the logic data container if needed - shared_ptr logic_data; - if (!converted_data_) { - logic_data = make_shared(1); // Contains only one channel - converted_data_ = logic_data; - } else - logic_data = dynamic_pointer_cast(converted_data_); + const shared_ptr logic_data = dynamic_pointer_cast(converted_data_); // Create the initial logic data segment if needed if (logic_data->segments().size() == 0) { @@ -339,10 +345,7 @@ void SignalBase::start_conversion() { stop_conversion(); - if ((channel_type_ == AnalogChannel) && - ((conversion_type_ == A2LConversionByTreshold) || - (conversion_type_ == A2LConversionBySchmittTrigger))) { - + if (conversion_is_a2l()) { shared_ptr analog_data = dynamic_pointer_cast(data_); if (analog_data->analog_segments().size() > 0) {