#include "decoder.h"
+#include <pv/view/signal.h>
+
namespace pv {
namespace data {
-Decoder::Decoder(const srd_decoder *const dec) :
- _decoder(dec)
+Decoder::Decoder(const srd_decoder *const dec,
+ std::map<const srd_probe*,
+ boost::shared_ptr<pv::view::Signal> > probes) :
+ _decoder(dec),
+ _probes(probes)
{
}
#include "signaldata.h"
+#include <map>
+
+#include <boost/shared_ptr.hpp>
+
struct srd_decoder;
+struct srd_probe;
namespace pv {
+
+namespace view {
+class Signal;
+}
+
namespace data {
class Decoder : public SignalData
{
public:
- Decoder(const srd_decoder *const dec);
+ Decoder(const srd_decoder *const dec, std::map<const srd_probe*,
+ boost::shared_ptr<pv::view::Signal> > probes);
const srd_decoder* get_decoder() const;
private:
const srd_decoder *const _decoder;
+ std::map<const srd_probe*, boost::shared_ptr<view::Signal> >
+ _probes;
};
} // namespace data
#include <libsigrokdecode/libsigrokdecode.h>
}
+#include <utility>
+
+#include <boost/foreach.hpp>
+
+#include <QDebug>
+
#include "decoder.h"
+#include <pv/view/logicsignal.h>
#include <pv/view/signal.h>
using namespace boost;
return selector;
}
+map<const srd_probe*, shared_ptr<view::Signal> > Decoder::get_probes()
+{
+ map<const srd_probe*, shared_ptr<view::Signal> > probe_map;
+ for(map<const srd_probe*, QComboBox*>::const_iterator i =
+ _probe_selector_map.begin();
+ i != _probe_selector_map.end(); i++)
+ {
+ const QComboBox *const combo = (*i).second;
+ const int probe_index =
+ combo->itemData(combo->currentIndex()).value<int>();
+ if(probe_index >= 0) {
+ shared_ptr<view::Signal> sig = _sigs[probe_index];
+ if(dynamic_cast<pv::view::LogicSignal*>(sig.get()))
+ probe_map[(*i).first] = sig;
+ else
+ qDebug() << "Currently only logic signals "
+ "are supported for decoding";
+ }
+ }
+
+ return probe_map;
+}
+
} // namespace dialogs
} // namespace pv
Decoder(QWidget *parent, const srd_decoder *decoder,
const std::vector< boost::shared_ptr<view::Signal> > &sigs);
+ std::map<const srd_probe*, boost::shared_ptr<view::Signal> >
+ get_probes();
+
private:
QComboBox* create_probe_selector(
QWidget *parent, const char *name);
if(dlg.exec() != QDialog::Accepted)
return;
- _session.add_decoder(dec);
+ _session.add_decoder(dec, dlg.get_probes());
}
void MainWindow::run_stop()
return _logic_data;
}
-void SigSession::add_decoder(srd_decoder *const dec)
+void SigSession::add_decoder(srd_decoder *const dec,
+ std::map<const srd_probe*,
+ boost::shared_ptr<view::Signal> > probes)
{
{
lock_guard<mutex> lock(_signals_mutex);
shared_ptr<data::Decoder> decoder(
- new data::Decoder(dec));
+ new data::Decoder(dec, probes));
shared_ptr<view::DecodeSignal> d(
new view::DecodeSignal(*this, decoder));
_decode_traces.push_back(d);
#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp>
+#include <map>
#include <string>
#include <utility>
#include <vector>
#include <libsigrok/libsigrok.h>
struct srd_decoder;
+struct srd_probe;
namespace pv {
boost::shared_ptr<data::Logic> get_data();
- void add_decoder(srd_decoder *const dec);
+ void add_decoder(srd_decoder *const dec,
+ std::map<const srd_probe*,
+ boost::shared_ptr<view::Signal> > probes);
private:
void set_capture_state(capture_state state);