From: Joel Holdsworth Date: Mon, 10 Feb 2014 22:02:44 +0000 (+0000) Subject: Moved all sr_probe modification into pv::DevInst X-Git-Tag: pulseview-0.2.0~73 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e183f4e328db8bb134652254ba9bf0707dc16c66;p=pulseview.git Moved all sr_probe modification into pv::DevInst --- diff --git a/pv/devinst.cpp b/pv/devinst.cpp index 4cae04ae..c0b87fe2 100644 --- a/pv/devinst.cpp +++ b/pv/devinst.cpp @@ -93,4 +93,16 @@ GVariant* DevInst::list_config(const sr_probe_group *group, int key) return data; } +void DevInst::enable_probe(const sr_probe *probe, bool enable) +{ + for (const GSList *p = _sdi->probes; p; p = p->next) + if (probe == p->data) { + const_cast(probe)->enabled = enable; + return; + } + + // Probe was not found in the device + assert(0); +} + } // pv diff --git a/pv/devinst.h b/pv/devinst.h index 400f7c32..0ce76745 100644 --- a/pv/devinst.h +++ b/pv/devinst.h @@ -30,6 +30,7 @@ #include struct sr_dev_inst; +struct sr_probe; struct sr_probe_group; namespace pv { @@ -51,6 +52,8 @@ public: GVariant* list_config(const sr_probe_group *group, int key); + void enable_probe(const sr_probe *probe, bool enable = true); + signals: void config_changed(); diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index 292d5f9e..a64cf70f 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -45,7 +45,7 @@ const QColor AnalogSignal::SignalColours[4] = { const float AnalogSignal::EnvelopeThreshold = 256.0f; AnalogSignal::AnalogSignal(shared_ptr dev_inst, - sr_probe *const probe, shared_ptr data) : + const sr_probe *const probe, shared_ptr data) : Signal(dev_inst, probe), _data(data), _scale(1.0f) diff --git a/pv/view/analogsignal.h b/pv/view/analogsignal.h index a312b3e8..3b6f7f4f 100644 --- a/pv/view/analogsignal.h +++ b/pv/view/analogsignal.h @@ -43,7 +43,7 @@ private: public: AnalogSignal(boost::shared_ptr dev_inst, - sr_probe *const probe, + const sr_probe *const probe, boost::shared_ptr data); virtual ~AnalogSignal(); diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index 7eb56da6..89c375cc 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -64,7 +64,7 @@ const QColor LogicSignal::SignalColours[10] = { }; LogicSignal::LogicSignal(shared_ptr dev_inst, - sr_probe *const probe, shared_ptr data) : + const sr_probe *const probe, shared_ptr data) : Signal(dev_inst, probe), _data(data), _trigger_none(NULL), diff --git a/pv/view/logicsignal.h b/pv/view/logicsignal.h index cc63884e..17f6eb26 100644 --- a/pv/view/logicsignal.h +++ b/pv/view/logicsignal.h @@ -50,7 +50,7 @@ private: public: LogicSignal(boost::shared_ptr dev_inst, - sr_probe *const probe, + const sr_probe *const probe, boost::shared_ptr data); virtual ~LogicSignal(); diff --git a/pv/view/signal.cpp b/pv/view/signal.cpp index f054eb2a..61f79a8c 100644 --- a/pv/view/signal.cpp +++ b/pv/view/signal.cpp @@ -32,6 +32,8 @@ #include "signal.h" #include "view.h" +#include + using boost::shared_ptr; namespace pv { @@ -55,7 +57,7 @@ const char *const ProbeNames[] = { }; Signal::Signal(shared_ptr dev_inst, - sr_probe *const probe) : + const sr_probe *const probe) : Trace(probe->name), _dev_inst(dev_inst), _probe(probe), @@ -80,7 +82,7 @@ bool Signal::enabled() const void Signal::enable(bool enable) { - _probe->enabled = enable; + _dev_inst->enable_probe(_probe, enable); visibility_changed(); } diff --git a/pv/view/signal.h b/pv/view/signal.h index a8642d24..25b671f4 100644 --- a/pv/view/signal.h +++ b/pv/view/signal.h @@ -47,7 +47,8 @@ class Signal : public Trace Q_OBJECT protected: - Signal(boost::shared_ptr dev_inst, sr_probe *const probe); + Signal(boost::shared_ptr dev_inst, + const sr_probe *const probe); public: /** @@ -77,7 +78,7 @@ private slots: protected: boost::shared_ptr _dev_inst; - sr_probe *const _probe; + const sr_probe *const _probe; QComboBox *_name_widget; bool _updating_name_widget;