X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fsession.cpp;h=008ee6a282cc3ba326abe6b106a503576d7d753c;hb=d0f22e70fac3829be356143b4f2b6693f162f682;hp=0fef9c91764bc75366bc8db57cfd6880783465b3;hpb=83b1c8d251386ac1980284c4668cbdd8e425550f;p=pulseview.git
diff --git a/pv/session.cpp b/pv/session.cpp
index 0fef9c9..008ee6a 100644
--- a/pv/session.cpp
+++ b/pv/session.cpp
@@ -17,30 +17,25 @@
* along with this program; if not, see .
*/
-#ifdef _WIN32
-// Windows: Avoid boost/thread namespace pollution (which includes windows.h).
-#define NOGDI
-#define NORESOURCE
-#endif
-
+#include
#include
#include
+#include
#include
#include
#include
-#include "session.hpp"
#include "devicemanager.hpp"
+#include "session.hpp"
#include "data/analog.hpp"
#include "data/analogsegment.hpp"
-#include "data/decoderstack.hpp"
+#include "data/decode/decoder.hpp"
#include "data/logic.hpp"
#include "data/logicsegment.hpp"
#include "data/signalbase.hpp"
-#include "data/decode/decoder.hpp"
#include "devices/hardwaredevice.hpp"
#include "devices/inputfile.hpp"
@@ -48,16 +43,17 @@
#include "toolbars/mainbar.hpp"
-#include "view/analogsignal.hpp"
-#include "view/decodetrace.hpp"
-#include "view/logicsignal.hpp"
-#include "view/signal.hpp"
-#include "view/view.hpp"
+#include "views/trace/analogsignal.hpp"
+#include "views/trace/decodetrace.hpp"
+#include "views/trace/logicsignal.hpp"
+#include "views/trace/signal.hpp"
+#include "views/trace/view.hpp"
#include
#ifdef ENABLE_DECODE
#include
+#include "data/decodesignal.hpp"
#endif
using std::bad_alloc;
@@ -77,6 +73,7 @@ using std::recursive_mutex;
using std::runtime_error;
using std::shared_ptr;
using std::string;
+using std::unique_ptr;
using std::unordered_set;
using std::vector;
@@ -94,6 +91,9 @@ using sigrok::Session;
using Glib::VariantBase;
namespace pv {
+
+shared_ptr Session::sr_context;
+
Session::Session(DeviceManager &device_manager, QString name) :
device_manager_(device_manager),
default_name_(name),
@@ -176,7 +176,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 =
@@ -220,14 +220,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
@@ -238,7 +232,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
@@ -322,14 +316,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));
+ shared_ptr signal = add_decode_signal();
+ signal->restore_settings(settings);
settings.endGroup();
}
#endif
@@ -360,8 +352,7 @@ void Session::select_device(shared_ptr device)
else
set_default_device();
} catch (const QString &e) {
- main_bar_->session_error(tr("Failed to Select Device"),
- tr("Failed to Select Device"));
+ main_bar_->session_error(tr("Failed to select device"), e);
}
}
@@ -409,6 +400,7 @@ void Session::set_device(shared_ptr device)
device_->open();
} catch (const QString &e) {
device_.reset();
+ main_bar_->session_error(tr("Failed to open device"), e);
}
if (device_) {
@@ -434,30 +426,80 @@ void Session::set_default_device()
// Try and find the demo device and select that by default
const auto iter = find_if(devices.begin(), devices.end(),
[] (const shared_ptr &d) {
- return d->hardware_device()->driver()->name() == "demo"; });
+ return d->hardware_device()->driver()->name() == "demo"; });
set_device((iter == devices.end()) ? devices.front() : *iter);
}
+/**
+ * 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().
+ *
+ * @return Map of options suitable for InputFormat::create_input().
+ */
+map
+Session::input_format_options(vector user_spec,
+ map> fmt_opts)
+{
+ map result;
+
+ for (auto entry : user_spec) {
+ /*
+ * Split key=value specs. Accept entries without separator
+ * (for simplified boolean specifications).
+ */
+ string key, val;
+ size_t pos = entry.find("=");
+ if (pos == std::string::npos) {
+ key = entry;
+ val = "";
+ } else {
+ key = entry.substr(0, pos);
+ val = entry.substr(pos + 1);
+ }
+
+ /*
+ * Skip user specifications that are not a member of the
+ * format's set of supported options. Have the text input
+ * spec converted to the required input format specific
+ * data type.
+ */
+ auto found = fmt_opts.find(key);
+ if (found == fmt_opts.end())
+ continue;
+ shared_ptr