-##
+
## This file is part of the PulseView project.
##
## Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
pv/sigsession.cpp
pv/data/analog.cpp
pv/data/analogsnapshot.cpp
- pv/data/decoder.cpp
+ pv/data/decoderstack.cpp
pv/data/logic.cpp
pv/data/logicsnapshot.cpp
pv/data/signaldata.cpp
set(pulseview_HEADERS
pv/mainwindow.h
pv/sigsession.h
- pv/data/decoder.h
+ pv/data/decoderstack.h
pv/dialogs/about.h
pv/dialogs/connect.h
pv/popups/deviceoptions.h
+++ /dev/null
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <libsigrokdecode/libsigrokdecode.h>
-
-#include <boost/thread/thread.hpp>
-
-#include <stdexcept>
-
-#include <QDebug>
-
-#include "decoder.h"
-
-#include <pv/data/logic.h>
-#include <pv/data/logicsnapshot.h>
-#include <pv/view/logicsignal.h>
-#include <pv/view/decode/annotation.h>
-
-using namespace boost;
-using namespace std;
-
-namespace pv {
-namespace data {
-
-const double Decoder::DecodeMargin = 1.0;
-const double Decoder::DecodeThreshold = 0.2;
-const int64_t Decoder::DecodeChunkLength = 4096;
-
-mutex Decoder::_global_decode_mutex;
-
-Decoder::Decoder(const srd_decoder *const dec) :
- _decoder(dec),
- _options(g_hash_table_new_full(g_str_hash,
- g_str_equal, g_free, (GDestroyNotify)g_variant_unref))
-{
-}
-
-Decoder::~Decoder()
-{
- _decode_thread.interrupt();
- _decode_thread.join();
-
- g_hash_table_destroy(_options);
-}
-
-const srd_decoder* Decoder::decoder() const
-{
- return _decoder;
-}
-
-const map<const srd_probe*, shared_ptr<view::LogicSignal> >&
-Decoder::probes() const
-{
- return _probes;
-}
-
-void Decoder::set_probes(std::map<const srd_probe*,
- boost::shared_ptr<view::LogicSignal> > probes)
-{
- _probes = probes;
- begin_decode();
-}
-
-const GHashTable* Decoder::options() const
-{
- return _options;
-}
-
-void Decoder::set_option(const char *id, GVariant *value)
-{
- g_variant_ref(value);
- g_hash_table_replace(_options, (void*)g_strdup(id), value);
- begin_decode();
-}
-
-const vector< shared_ptr<view::decode::Annotation> >
- Decoder::annotations() const
-{
- lock_guard<mutex> lock(_mutex);
- return _annotations;
-}
-
-QString Decoder::error_message()
-{
- lock_guard<mutex> lock(_mutex);
- return _error_message;
-}
-
-void Decoder::begin_decode()
-{
- _decode_thread.interrupt();
- _decode_thread.join();
-
- _annotations.clear();
-
- if (_probes.empty())
- return;
-
- // Get the samplerate and start time
- shared_ptr<pv::view::LogicSignal> logic_signal =
- dynamic_pointer_cast<pv::view::LogicSignal>(
- (*_probes.begin()).second);
- if (logic_signal) {
- shared_ptr<pv::data::Logic> data(
- logic_signal->data());
- if (data) {
- _start_time = data->get_start_time();
- _samplerate = data->get_samplerate();
- if (_samplerate == 0.0)
- _samplerate = 1.0;
- }
- }
-
- // We get the logic data of the first probe in the list.
- // This works because we are currently assuming all
- // LogicSignals have the same data/snapshot
- shared_ptr<pv::view::LogicSignal> sig = (*_probes.begin()).second;
- assert(sig);
- shared_ptr<data::Logic> data = sig->data();
-
- _decode_thread = boost::thread(&Decoder::decode_proc, this,
- data);
-}
-
-void Decoder::clear_snapshots()
-{
-}
-
-void Decoder::decode_proc(shared_ptr<data::Logic> data)
-{
- srd_session *session;
- uint8_t chunk[DecodeChunkLength];
-
- assert(data);
-
- const deque< shared_ptr<pv::data::LogicSnapshot> > &snapshots =
- data->get_snapshots();
- if (snapshots.empty())
- return;
-
- const shared_ptr<pv::data::LogicSnapshot> &snapshot =
- snapshots.front();
- const int64_t sample_count = snapshot->get_sample_count() - 1;
-
- // Create the session
- srd_session_new(&session);
- assert(session);
-
- srd_session_metadata_set(session, SRD_CONF_SAMPLERATE,
- g_variant_new_uint64((uint64_t)_samplerate));
-
- srd_pd_output_callback_add(session, SRD_OUTPUT_ANN,
- Decoder::annotation_callback, this);
-
- // Create the decoder instance
- srd_decoder_inst *const decoder_inst = srd_inst_new(
- session, _decoder->id, _options);
- if(!decoder_inst) {
- _error_message = tr("Failed to initialise decoder");
- return;
- }
-
- // Setup the probes
- GHashTable *const probes = g_hash_table_new_full(g_str_hash,
- g_str_equal, g_free, (GDestroyNotify)g_variant_unref);
-
- for(map<const srd_probe*, shared_ptr<view::LogicSignal> >::
- const_iterator i = _probes.begin();
- i != _probes.end(); i++)
- {
- shared_ptr<view::Signal> signal((*i).second);
- GVariant *const gvar = g_variant_new_int32(
- signal->probe()->index);
- g_variant_ref_sink(gvar);
- g_hash_table_insert(probes, (*i).first->id, gvar);
- }
-
- srd_inst_probe_set_all(decoder_inst, probes);
-
- // Start the session
- srd_session_start(session);
-
- for (int64_t i = 0;
- !this_thread::interruption_requested() && i < sample_count;
- i += DecodeChunkLength)
- {
- lock_guard<mutex> decode_lock(_global_decode_mutex);
-
- const int64_t chunk_end = min(
- i + DecodeChunkLength, sample_count);
- snapshot->get_samples(chunk, i, chunk_end);
-
- if (srd_session_send(session, i, i + sample_count,
- chunk, chunk_end - i) != SRD_OK) {
- _error_message = tr("Failed to initialise decoder");
- break;
- }
- }
-
- // Destroy the session
- srd_session_destroy(session);
-}
-
-void Decoder::annotation_callback(srd_proto_data *pdata, void *decoder)
-{
- using namespace pv::view::decode;
-
- assert(pdata);
- assert(decoder);
-
- Decoder *const d = (Decoder*)decoder;
-
- shared_ptr<Annotation> a(new Annotation(pdata));
- lock_guard<mutex> lock(d->_mutex);
- d->_annotations.push_back(a);
-
- d->new_decode_data();
-}
-
-} // namespace data
-} // namespace pv
+++ /dev/null
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef PULSEVIEW_PV_DATA_DECODER_H
-#define PULSEVIEW_PV_DATA_DECODER_H
-
-#include "signaldata.h"
-
-#include <map>
-
-#include <boost/shared_ptr.hpp>
-#include <boost/thread.hpp>
-
-#include <QObject>
-#include <QString>
-
-#include <glib.h>
-
-struct srd_decoder;
-struct srd_probe;
-struct srd_proto_data;
-
-namespace DecoderTest {
-class TwoDecoder;
-}
-
-namespace pv {
-
-namespace view {
-class LogicSignal;
-
-namespace decode {
-class Annotation;
-}
-
-}
-
-namespace data {
-
-class Logic;
-
-class Decoder : public QObject, public SignalData
-{
- Q_OBJECT
-
-private:
- static const double DecodeMargin;
- static const double DecodeThreshold;
- static const int64_t DecodeChunkLength;
-
-public:
- Decoder(const srd_decoder *const decoder);
-
- virtual ~Decoder();
-
- const srd_decoder* decoder() const;
-
- const std::map<const srd_probe*, boost::shared_ptr<view::LogicSignal> >&
- probes() const;
- void set_probes(std::map<const srd_probe*,
- boost::shared_ptr<view::LogicSignal> > probes);
-
- const GHashTable* options() const;
-
- void set_option(const char *id, GVariant *value);
-
- const std::vector< boost::shared_ptr<pv::view::decode::Annotation> >
- annotations() const;
-
- QString error_message();
-
- void clear_snapshots();
-
-private:
- void begin_decode();
-
- void decode_proc(boost::shared_ptr<data::Logic> data);
-
- static void annotation_callback(srd_proto_data *pdata,
- void *decoder);
-
-signals:
- void new_decode_data();
-
-private:
-
- /**
- * This mutex prevents more than one decode operation occuring
- * concurrently.
- * @todo A proper solution should be implemented to allow multiple
- * decode operations.
- */
- static boost::mutex _global_decode_mutex;
-
- const srd_decoder *const _decoder;
- std::map<const srd_probe*, boost::shared_ptr<view::LogicSignal> >
- _probes;
- GHashTable *_options;
-
- mutable boost::mutex _mutex;
- std::vector< boost::shared_ptr<pv::view::decode::Annotation> >
- _annotations;
- QString _error_message;
-
- boost::thread _decode_thread;
-
- friend class DecoderTest::TwoDecoder;
-};
-
-} // namespace data
-} // namespace pv
-
-#endif // PULSEVIEW_PV_DATA_DECODER_H
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <libsigrokdecode/libsigrokdecode.h>
+
+#include <boost/thread/thread.hpp>
+
+#include <stdexcept>
+
+#include <QDebug>
+
+#include "decoderstack.h"
+
+#include <pv/data/logic.h>
+#include <pv/data/logicsnapshot.h>
+#include <pv/view/logicsignal.h>
+#include <pv/view/decode/annotation.h>
+
+using namespace boost;
+using namespace std;
+
+namespace pv {
+namespace data {
+
+const double DecoderStack::DecodeMargin = 1.0;
+const double DecoderStack::DecodeThreshold = 0.2;
+const int64_t DecoderStack::DecodeChunkLength = 4096;
+
+mutex DecoderStack::_global_decode_mutex;
+
+DecoderStack::DecoderStack(const srd_decoder *const dec) :
+ _decoder(dec),
+ _options(g_hash_table_new_full(g_str_hash,
+ g_str_equal, g_free, (GDestroyNotify)g_variant_unref))
+{
+}
+
+DecoderStack::~DecoderStack()
+{
+ _decode_thread.interrupt();
+ _decode_thread.join();
+
+ g_hash_table_destroy(_options);
+}
+
+const srd_decoder* DecoderStack::decoder() const
+{
+ return _decoder;
+}
+
+const map<const srd_probe*, shared_ptr<view::LogicSignal> >&
+DecoderStack::probes() const
+{
+ return _probes;
+}
+
+void DecoderStack::set_probes(std::map<const srd_probe*,
+ boost::shared_ptr<view::LogicSignal> > probes)
+{
+ _probes = probes;
+ begin_decode();
+}
+
+const GHashTable* DecoderStack::options() const
+{
+ return _options;
+}
+
+void DecoderStack::set_option(const char *id, GVariant *value)
+{
+ g_variant_ref(value);
+ g_hash_table_replace(_options, (void*)g_strdup(id), value);
+ begin_decode();
+}
+
+const vector< shared_ptr<view::decode::Annotation> >
+ DecoderStack::annotations() const
+{
+ lock_guard<mutex> lock(_mutex);
+ return _annotations;
+}
+
+QString DecoderStack::error_message()
+{
+ lock_guard<mutex> lock(_mutex);
+ return _error_message;
+}
+
+void DecoderStack::begin_decode()
+{
+ _decode_thread.interrupt();
+ _decode_thread.join();
+
+ _annotations.clear();
+
+ if (_probes.empty())
+ return;
+
+ // Get the samplerate and start time
+ shared_ptr<pv::view::LogicSignal> logic_signal =
+ dynamic_pointer_cast<pv::view::LogicSignal>(
+ (*_probes.begin()).second);
+ if (logic_signal) {
+ shared_ptr<pv::data::Logic> data(
+ logic_signal->data());
+ if (data) {
+ _start_time = data->get_start_time();
+ _samplerate = data->get_samplerate();
+ if (_samplerate == 0.0)
+ _samplerate = 1.0;
+ }
+ }
+
+ // We get the logic data of the first probe in the list.
+ // This works because we are currently assuming all
+ // LogicSignals have the same data/snapshot
+ shared_ptr<pv::view::LogicSignal> sig = (*_probes.begin()).second;
+ assert(sig);
+ shared_ptr<data::Logic> data = sig->data();
+
+ _decode_thread = boost::thread(&DecoderStack::decode_proc, this,
+ data);
+}
+
+void DecoderStack::clear_snapshots()
+{
+}
+
+void DecoderStack::decode_proc(shared_ptr<data::Logic> data)
+{
+ srd_session *session;
+ uint8_t chunk[DecodeChunkLength];
+
+ assert(data);
+
+ const deque< shared_ptr<pv::data::LogicSnapshot> > &snapshots =
+ data->get_snapshots();
+ if (snapshots.empty())
+ return;
+
+ const shared_ptr<pv::data::LogicSnapshot> &snapshot =
+ snapshots.front();
+ const int64_t sample_count = snapshot->get_sample_count() - 1;
+
+ // Create the session
+ srd_session_new(&session);
+ assert(session);
+
+ srd_session_metadata_set(session, SRD_CONF_SAMPLERATE,
+ g_variant_new_uint64((uint64_t)_samplerate));
+
+ srd_pd_output_callback_add(session, SRD_OUTPUT_ANN,
+ DecoderStack::annotation_callback, this);
+
+ // Create the decoder instance
+ srd_decoder_inst *const decoder_inst = srd_inst_new(
+ session, _decoder->id, _options);
+ if(!decoder_inst) {
+ _error_message = tr("Failed to initialise decoder");
+ return;
+ }
+
+ // Setup the probes
+ GHashTable *const probes = g_hash_table_new_full(g_str_hash,
+ g_str_equal, g_free, (GDestroyNotify)g_variant_unref);
+
+ for(map<const srd_probe*, shared_ptr<view::LogicSignal> >::
+ const_iterator i = _probes.begin();
+ i != _probes.end(); i++)
+ {
+ shared_ptr<view::Signal> signal((*i).second);
+ GVariant *const gvar = g_variant_new_int32(
+ signal->probe()->index);
+ g_variant_ref_sink(gvar);
+ g_hash_table_insert(probes, (*i).first->id, gvar);
+ }
+
+ srd_inst_probe_set_all(decoder_inst, probes);
+
+ // Start the session
+ srd_session_start(session);
+
+ for (int64_t i = 0;
+ !this_thread::interruption_requested() && i < sample_count;
+ i += DecodeChunkLength)
+ {
+ lock_guard<mutex> decode_lock(_global_decode_mutex);
+
+ const int64_t chunk_end = min(
+ i + DecodeChunkLength, sample_count);
+ snapshot->get_samples(chunk, i, chunk_end);
+
+ if (srd_session_send(session, i, i + sample_count,
+ chunk, chunk_end - i) != SRD_OK) {
+ _error_message = tr("Failed to initialise decoder");
+ break;
+ }
+ }
+
+ // Destroy the session
+ srd_session_destroy(session);
+}
+
+void DecoderStack::annotation_callback(srd_proto_data *pdata, void *decoder)
+{
+ using namespace pv::view::decode;
+
+ assert(pdata);
+ assert(decoder);
+
+ DecoderStack *const d = (DecoderStack*)decoder;
+
+ shared_ptr<Annotation> a(new Annotation(pdata));
+ lock_guard<mutex> lock(d->_mutex);
+ d->_annotations.push_back(a);
+
+ d->new_decode_data();
+}
+
+} // namespace data
+} // namespace pv
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef PULSEVIEW_PV_DATA_DECODERSTACK_H
+#define PULSEVIEW_PV_DATA_DECODERSTACK_H
+
+#include "signaldata.h"
+
+#include <map>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/thread.hpp>
+
+#include <QObject>
+#include <QString>
+
+#include <glib.h>
+
+struct srd_decoder;
+struct srd_probe;
+struct srd_proto_data;
+
+namespace DecoderStackTest {
+class TwoDecoderStack;
+}
+
+namespace pv {
+
+namespace view {
+class LogicSignal;
+
+namespace decode {
+class Annotation;
+}
+
+}
+
+namespace data {
+
+class Logic;
+
+class DecoderStack : public QObject, public SignalData
+{
+ Q_OBJECT
+
+private:
+ static const double DecodeMargin;
+ static const double DecodeThreshold;
+ static const int64_t DecodeChunkLength;
+
+public:
+ DecoderStack(const srd_decoder *const decoder);
+
+ virtual ~DecoderStack();
+
+ const srd_decoder* decoder() const;
+
+ const std::map<const srd_probe*, boost::shared_ptr<view::LogicSignal> >&
+ probes() const;
+ void set_probes(std::map<const srd_probe*,
+ boost::shared_ptr<view::LogicSignal> > probes);
+
+ const GHashTable* options() const;
+
+ void set_option(const char *id, GVariant *value);
+
+ const std::vector< boost::shared_ptr<pv::view::decode::Annotation> >
+ annotations() const;
+
+ QString error_message();
+
+ void clear_snapshots();
+
+private:
+ void begin_decode();
+
+ void decode_proc(boost::shared_ptr<data::Logic> data);
+
+ static void annotation_callback(srd_proto_data *pdata,
+ void *decoder);
+
+signals:
+ void new_decode_data();
+
+private:
+
+ /**
+ * This mutex prevents more than one decode operation occuring
+ * concurrently.
+ * @todo A proper solution should be implemented to allow multiple
+ * decode operations.
+ */
+ static boost::mutex _global_decode_mutex;
+
+ const srd_decoder *const _decoder;
+ std::map<const srd_probe*, boost::shared_ptr<view::LogicSignal> >
+ _probes;
+ GHashTable *_options;
+
+ mutable boost::mutex _mutex;
+ std::vector< boost::shared_ptr<pv::view::decode::Annotation> >
+ _annotations;
+ QString _error_message;
+
+ boost::thread _decode_thread;
+
+ friend class DecoderStackTest::TwoDecoderStack;
+};
+
+} // namespace data
+} // namespace pv
+
+#endif // PULSEVIEW_PV_DATA_DECODERSTACK_H
#include <boost/foreach.hpp>
#include <boost/none_t.hpp>
-#include <pv/data/decoder.h>
+#include <pv/data/decoderstack.h>
#include <pv/prop/int.h>
#include <pv/prop/string.h>
namespace prop {
namespace binding {
-DecoderOptions::DecoderOptions(shared_ptr<pv::data::Decoder> decoder) :
+DecoderOptions::DecoderOptions(shared_ptr<pv::data::DecoderStack> decoder) :
_decoder(decoder)
{
assert(_decoder);
namespace pv {
namespace data {
-class Decoder;
+class DecoderStack;
}
namespace prop {
class DecoderOptions : public Binding
{
public:
- DecoderOptions(boost::shared_ptr<pv::data::Decoder> decoder);
+ DecoderOptions(boost::shared_ptr<pv::data::DecoderStack> decoder);
private:
GVariant* getter(const char *id);
void setter(const char *id, GVariant *value);
private:
- boost::shared_ptr<pv::data::Decoder> _decoder;
+ boost::shared_ptr<pv::data::DecoderStack> _decoder;
};
} // binding
#include "data/analog.h"
#include "data/analogsnapshot.h"
-#include "data/decoder.h"
+#include "data/decoderstack.h"
#include "data/logic.h"
#include "data/logicsnapshot.h"
lock_guard<mutex> lock(_signals_mutex);
// Create the decoder
- shared_ptr<data::Decoder> decoder(new data::Decoder(dec));
+ shared_ptr<data::DecoderStack> decoder(new data::DecoderStack(dec));
// Auto select the initial probes
for(const GSList *i = dec->probes; i; i = i->next)
#include "decodetrace.h"
#include <pv/sigsession.h>
-#include <pv/data/decoder.h>
+#include <pv/data/decoderstack.h>
#include <pv/view/logicsignal.h>
#include <pv/view/view.h>
#include <pv/view/decode/annotation.h>
const QColor DecodeTrace::ErrorBgColour = QColor(0xEF, 0x29, 0x29);
DecodeTrace::DecodeTrace(pv::SigSession &session,
- boost::shared_ptr<pv::data::Decoder> decoder, int index) :
- Trace(session, QString(decoder->decoder()->name)),
- _decoder(decoder),
- _binding(decoder)
+ boost::shared_ptr<pv::data::DecoderStack> decoder_stack, int index) :
+ Trace(session, QString(decoder_stack->decoder()->name)),
+ _decoder_stack(decoder_stack),
+ _binding(decoder_stack)
{
- assert(_decoder);
+ assert(_decoder_stack);
_colour = DecodeColours[index % countof(DecodeColours)];
- connect(_decoder.get(), SIGNAL(new_decode_data()),
+ connect(_decoder_stack.get(), SIGNAL(new_decode_data()),
this, SLOT(on_new_decode_data()));
}
return true;
}
-const boost::shared_ptr<pv::data::Decoder>& DecodeTrace::decoder() const
+const boost::shared_ptr<pv::data::DecoderStack>& DecodeTrace::decoder() const
{
- return _decoder;
+ return _decoder_stack;
}
void DecodeTrace::set_view(pv::view::View *view)
{
using namespace pv::view::decode;
- assert(_decoder);
- const QString err = _decoder->error_message();
+ assert(_decoder_stack);
+ const QString err = _decoder_stack->error_message();
if (!err.isEmpty()) {
draw_error(p, err, left, right);
return;
const double scale = _view->scale();
assert(scale > 0);
- double samplerate = _decoder->get_samplerate();
+ double samplerate = _decoder_stack->get_samplerate();
// Show sample rate as 1Hz when it is unknown
if (samplerate == 0.0)
samplerate = 1.0;
const double pixels_offset = (_view->offset() -
- _decoder->get_start_time()) / scale;
+ _decoder_stack->get_start_time()) / scale;
const double samples_per_pixel = samplerate * scale;
- assert(_decoder);
- vector< shared_ptr<Annotation> > annotations(_decoder->annotations());
+ assert(_decoder_stack);
+ vector< shared_ptr<Annotation> > annotations(_decoder_stack->annotations());
BOOST_FOREACH(shared_ptr<Annotation> a, annotations) {
assert(a);
a->paint(p, get_text_colour(), _text_size.height(),
assert(form);
assert(parent);
- assert(_decoder);
+ assert(_decoder_stack);
- const srd_decoder *const decoder = _decoder->decoder();
+ const srd_decoder *const decoder = _decoder_stack->decoder();
assert(decoder);
// Add stacking button
QPushButton *const stack_button =
- new QPushButton(tr("Stack Decoder"), parent);
+ new QPushButton(tr("Stack DecoderStack"), parent);
pv::widgets::DecoderMenu *const decoder_menu =
new pv::widgets::DecoderMenu(parent);
stack_button->setMenu(decoder_menu);
{
const vector< shared_ptr<Signal> > sigs = _session.get_signals();
- assert(_decoder);
+ assert(_decoder_stack);
const map<const srd_probe*,
shared_ptr<LogicSignal> >::const_iterator probe_iter =
- _decoder->probes().find(probe);
+ _decoder_stack->probes().find(probe);
QComboBox *selector = new QComboBox(parent);
selector->addItem("-", qVariantFromValue((void*)NULL));
- if (probe_iter == _decoder->probes().end())
+ if (probe_iter == _decoder_stack->probes().end())
selector->setCurrentIndex(0);
for(size_t i = 0; i < sigs.size(); i++) {
void DecodeTrace::commit_probes()
{
- assert(_decoder);
+ assert(_decoder_stack);
map<const srd_probe*, shared_ptr<LogicSignal> > probe_map;
const vector< shared_ptr<Signal> > sigs = _session.get_signals();
}
}
- _decoder->set_probes(probe_map);
+ _decoder_stack->set_probes(probe_map);
}
void DecodeTrace::on_new_decode_data()
namespace pv {
namespace data {
-class Decoder;
+class DecoderStack;
}
namespace view {
public:
DecodeTrace(pv::SigSession &session,
- boost::shared_ptr<pv::data::Decoder> decoder, int index);
+ boost::shared_ptr<pv::data::DecoderStack> decoder_stack,
+ int index);
bool enabled() const;
- const boost::shared_ptr<pv::data::Decoder>& decoder() const;
+ const boost::shared_ptr<pv::data::DecoderStack>& decoder() const;
void set_view(pv::view::View *view);
void on_probe_selected(int);
private:
- boost::shared_ptr<pv::data::Decoder> _decoder;
+ boost::shared_ptr<pv::data::DecoderStack> _decoder_stack;
uint64_t _decode_start, _decode_end;
${PROJECT_SOURCE_DIR}/pv/view/cursorpair.cpp
${PROJECT_SOURCE_DIR}/pv/data/analog.cpp
${PROJECT_SOURCE_DIR}/pv/data/analogsnapshot.cpp
- ${PROJECT_SOURCE_DIR}/pv/data/decoder.cpp
+ ${PROJECT_SOURCE_DIR}/pv/data/decoderstack.cpp
${PROJECT_SOURCE_DIR}/pv/data/logic.cpp
${PROJECT_SOURCE_DIR}/pv/data/logicsnapshot.cpp
${PROJECT_SOURCE_DIR}/pv/data/snapshot.cpp
${PROJECT_SOURCE_DIR}/pv/widgets/popup.cpp
${PROJECT_SOURCE_DIR}/pv/widgets/wellarray.cpp
data/analogsnapshot.cpp
- data/decoder.cpp
+ data/decoderstack.cpp
data/logicsnapshot.cpp
test.cpp
)
# This list includes only QObject derrived class headers
set(pulseview_TEST_HEADERS
${PROJECT_SOURCE_DIR}/pv/sigsession.h
- ${PROJECT_SOURCE_DIR}/pv/data/decoder.h
+ ${PROJECT_SOURCE_DIR}/pv/data/decoderstack.h
${PROJECT_SOURCE_DIR}/pv/prop/int.h
${PROJECT_SOURCE_DIR}/pv/prop/property.h
${PROJECT_SOURCE_DIR}/pv/prop/string.h
+++ /dev/null
-/*
- * This file is part of the PulseView project.
- *
- * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <libsigrokdecode/libsigrokdecode.h> /* First, so we avoid a _POSIX_C_SOURCE warning. */
-#include <boost/test/unit_test.hpp>
-
-#include <libsigrok/libsigrok.h>
-
-#include "../../pv/data/decoder.h"
-#include "../../pv/devicemanager.h"
-#include "../../pv/sigsession.h"
-#include "../../pv/view/decodetrace.h"
-
-using namespace boost;
-using namespace std;
-
-BOOST_AUTO_TEST_SUITE(DecoderTest)
-
-BOOST_AUTO_TEST_CASE(TwoDecoder)
-{
- using namespace pv;
-
- sr_context *ctx = NULL;
-
- BOOST_REQUIRE(sr_init(&ctx) == SR_OK);
- BOOST_REQUIRE(ctx);
-
- BOOST_REQUIRE(srd_init(NULL) == SRD_OK);
-
- srd_decoder_load_all();
-
- {
- pv::DeviceManager dm(ctx);
- pv::SigSession ss(dm);
-
- const GSList *l = srd_decoder_list();
- BOOST_REQUIRE(l);
- srd_decoder *const dec = (struct srd_decoder*)l->data;
- BOOST_REQUIRE(dec);
-
- ss.add_decoder(dec);
- ss.add_decoder(dec);
-
- // Check the signals were created
- const vector< shared_ptr<view::DecodeTrace> > sigs =
- ss.get_decode_signals();
-
- shared_ptr<data::Decoder> dec0 = sigs[0]->decoder();
- BOOST_REQUIRE(dec0);
-
- shared_ptr<data::Decoder> dec1 = sigs[0]->decoder();
- BOOST_REQUIRE(dec1);
-
- // Wait for the decode threads to complete
- dec0->_decode_thread.join();
- dec1->_decode_thread.join();
-
- // Check there were no errors
- BOOST_CHECK_EQUAL(dec0->error_message().isEmpty(), true);
- BOOST_CHECK_EQUAL(dec1->error_message().isEmpty(), true);
- }
-
-
- srd_exit();
- sr_exit(ctx);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <libsigrokdecode/libsigrokdecode.h> /* First, so we avoid a _POSIX_C_SOURCE warning. */
+#include <boost/test/unit_test.hpp>
+
+#include <libsigrok/libsigrok.h>
+
+#include "../../pv/data/decoderstack.h"
+#include "../../pv/devicemanager.h"
+#include "../../pv/sigsession.h"
+#include "../../pv/view/decodetrace.h"
+
+using namespace boost;
+using namespace std;
+
+BOOST_AUTO_TEST_SUITE(DecoderStackTest)
+
+BOOST_AUTO_TEST_CASE(TwoDecoderStack)
+{
+ using namespace pv;
+
+ sr_context *ctx = NULL;
+
+ BOOST_REQUIRE(sr_init(&ctx) == SR_OK);
+ BOOST_REQUIRE(ctx);
+
+ BOOST_REQUIRE(srd_init(NULL) == SRD_OK);
+
+ srd_decoder_load_all();
+
+ {
+ pv::DeviceManager dm(ctx);
+ pv::SigSession ss(dm);
+
+ const GSList *l = srd_decoder_list();
+ BOOST_REQUIRE(l);
+ srd_decoder *const dec = (struct srd_decoder*)l->data;
+ BOOST_REQUIRE(dec);
+
+ ss.add_decoder(dec);
+ ss.add_decoder(dec);
+
+ // Check the signals were created
+ const vector< shared_ptr<view::DecodeTrace> > sigs =
+ ss.get_decode_signals();
+
+ shared_ptr<data::DecoderStack> dec0 = sigs[0]->decoder();
+ BOOST_REQUIRE(dec0);
+
+ shared_ptr<data::DecoderStack> dec1 = sigs[0]->decoder();
+ BOOST_REQUIRE(dec1);
+
+ // Wait for the decode threads to complete
+ dec0->_decode_thread.join();
+ dec1->_decode_thread.join();
+
+ // Check there were no errors
+ BOOST_CHECK_EQUAL(dec0->error_message().isEmpty(), true);
+ BOOST_CHECK_EQUAL(dec1->error_message().isEmpty(), true);
+ }
+
+
+ srd_exit();
+ sr_exit(ctx);
+}
+
+BOOST_AUTO_TEST_SUITE_END()