X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fsession.cpp;h=f96fc869ecad613816196072409c4d1458e198ad;hp=516e1acd5ad6ff1e6b52a277f97c042e28e37872;hb=5b6ae10391736ab2f81de851686dee15bbcbf9f9;hpb=724f29f311db4f8b47169e58f3f3b50e6a50ed08
diff --git a/pv/session.cpp b/pv/session.cpp
index 516e1acd..f96fc869 100644
--- a/pv/session.cpp
+++ b/pv/session.cpp
@@ -17,6 +17,7 @@
* along with this program; if not, see .
*/
+#include
#include
#include
@@ -32,7 +33,6 @@
#include "data/analog.hpp"
#include "data/analogsegment.hpp"
#include "data/decode/decoder.hpp"
-#include "data/decoderstack.hpp"
#include "data/logic.hpp"
#include "data/logicsegment.hpp"
#include "data/signalbase.hpp"
@@ -53,6 +53,7 @@
#ifdef ENABLE_DECODE
#include
+#include "data/decodesignal.hpp"
#endif
using std::bad_alloc;
@@ -172,7 +173,7 @@ void Session::save_settings(QSettings &settings) const
{
map dev_info;
list key_list;
- int stacks = 0, views = 0;
+ int decode_signals = 0, views = 0;
if (device_) {
shared_ptr hw_device =
@@ -216,14 +217,8 @@ void Session::save_settings(QSettings &settings) const
for (shared_ptr base : signalbases_) {
#ifdef ENABLE_DECODE
if (base->is_decode_signal()) {
- shared_ptr decoder_stack =
- base->decoder_stack();
- shared_ptr top_decoder =
- decoder_stack->stack().front();
-
- settings.beginGroup("decoder_stack" + QString::number(stacks++));
- settings.setValue("id", top_decoder->decoder()->id);
- settings.setValue("name", top_decoder->decoder()->name);
+ settings.beginGroup("decode_signal" + QString::number(decode_signals++));
+ base->save_settings(settings);
settings.endGroup();
} else
#endif
@@ -234,7 +229,7 @@ void Session::save_settings(QSettings &settings) const
}
}
- settings.setValue("decoder_stacks", stacks);
+ settings.setValue("decode_signals", decode_signals);
// Save view states and their signal settings
// Note: main_view must be saved as view0
@@ -318,14 +313,12 @@ void Session::restore_settings(QSettings &settings)
// Restore decoders
#ifdef ENABLE_DECODE
- int stacks = settings.value("decoder_stacks").toInt();
-
- for (int i = 0; i < stacks; i++) {
- settings.beginGroup("decoder_stack" + QString::number(i++));
-
- QString id = settings.value("id").toString();
- add_decoder(srd_decoder_get_by_id(id.toStdString().c_str()));
+ int decode_signals = settings.value("decode_signals").toInt();
+ for (int i = 0; i < decode_signals; i++) {
+ settings.beginGroup("decode_signal" + QString::number(i++));
+ // TODO Split up add_decoder() into add_decode_signal() and add_decoder(),
+ // then call add_decode_signal() and signal->restore_settings() here
settings.endGroup();
}
#endif
@@ -437,10 +430,10 @@ void Session::set_default_device()
/**
* Convert generic options to data types that are specific to InputFormat.
*
- * @param[in] user_spec vector of tokenized words, string format
- * @param[in] fmt_opts input format's options, result of InputFormat::options()
+ * @param[in] user_spec Vector of tokenized words, string format.
+ * @param[in] fmt_opts Input format's options, result of InputFormat::options().
*
- * @return map of options suitable for InputFormat::create_input()
+ * @return Map of options suitable for InputFormat::create_input().
*/
map
Session::input_format_options(vector user_spec,
@@ -657,62 +650,34 @@ bool Session::add_decoder(srd_decoder *const dec)
if (!dec)
return false;
- map > channels;
- shared_ptr decoder_stack;
-
try {
- // Create the decoder
- decoder_stack = make_shared(*this, dec);
-
- // Make a list of all the channels
- vector all_channels;
- for (const GSList *i = dec->channels; i; i = i->next)
- all_channels.push_back((const srd_channel*)i->data);
- for (const GSList *i = dec->opt_channels; i; i = i->next)
- all_channels.push_back((const srd_channel*)i->data);
-
- // Auto select the initial channels
- for (const srd_channel *pdch : all_channels)
- for (shared_ptr b : signalbases_) {
- if (b->logic_data()) {
- if (QString::fromUtf8(pdch->name).toLower().
- contains(b->name().toLower()))
- channels[pdch] = b;
- }
- }
-
- assert(decoder_stack);
- assert(!decoder_stack->stack().empty());
- assert(decoder_stack->stack().front());
- decoder_stack->stack().front()->set_channels(channels);
-
// Create the decode signal
- shared_ptr signalbase =
- make_shared(nullptr, data::SignalBase::DecodeChannel);
+ shared_ptr signal =
+ make_shared(*this);
- signalbase->set_decoder_stack(decoder_stack);
- signalbases_.insert(signalbase);
+ signalbases_.insert(signal);
+ // Add the decode signal to all views
for (shared_ptr view : views_)
- view->add_decode_signal(signalbase);
+ view->add_decode_signal(signal);
+
+ // Add decoder
+ signal->stack_decoder(dec);
} catch (runtime_error e) {
return false;
}
signals_changed();
- // Do an initial decode
- decoder_stack->begin_decode();
-
return true;
}
-void Session::remove_decode_signal(shared_ptr signalbase)
+void Session::remove_decode_signal(shared_ptr signal)
{
- signalbases_.erase(signalbase);
+ signalbases_.erase(signal);
for (shared_ptr view : views_)
- view->remove_decode_signal(signalbase);
+ view->remove_decode_signal(signal);
signals_changed();
}