X-Git-Url: http://git.code-monkey.de/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdevice%2Fdevinst.cpp;h=0301063440200d4b693105623f329fbce303b9f6;hp=5fe2951756e4b602fca4da0fa4b379f3cfc19ef0;hb=87b79835014a386fb51b52bc993dbb693bd27197;hpb=921b90c0b3ae0cf44247da3d87bd7dc0612e9681 diff --git a/pv/device/devinst.cpp b/pv/device/devinst.cpp index 5fe2951..0301063 100644 --- a/pv/device/devinst.cpp +++ b/pv/device/devinst.cpp @@ -26,55 +26,83 @@ #include "devinst.h" +#include + namespace pv { namespace device { -DevInst::DevInst(sr_dev_inst *sdi) : - _sdi(sdi) +DevInst::DevInst() : + _owner(NULL) { - assert(_sdi); } -sr_dev_inst* DevInst::dev_inst() const +void DevInst::use(SigSession *owner) throw(QString) { - return _sdi; + assert(owner); + assert(!_owner); + _owner = owner; +} + +void DevInst::release() +{ + if (_owner) { + _owner->release_device(this); + _owner = NULL; + } } -GVariant* DevInst::get_config(const sr_probe_group *group, int key) +SigSession* DevInst::owner() const +{ + return _owner; +} + +GVariant* DevInst::get_config(const sr_channel_group *group, int key) { GVariant *data = NULL; - if (sr_config_get(_sdi->driver, _sdi, group, key, &data) != SR_OK) + assert(_owner); + sr_dev_inst *const sdi = dev_inst(); + assert(sdi); + if (sr_config_get(sdi->driver, sdi, group, key, &data) != SR_OK) return NULL; return data; } -bool DevInst::set_config(const sr_probe_group *group, int key, GVariant *data) +bool DevInst::set_config(const sr_channel_group *group, int key, GVariant *data) { - if(sr_config_set(_sdi, group, key, data) == SR_OK) { + assert(_owner); + sr_dev_inst *const sdi = dev_inst(); + assert(sdi); + if(sr_config_set(sdi, group, key, data) == SR_OK) { config_changed(); return true; } return false; } -GVariant* DevInst::list_config(const sr_probe_group *group, int key) +GVariant* DevInst::list_config(const sr_channel_group *group, int key) { GVariant *data = NULL; - if (sr_config_list(_sdi->driver, _sdi, group, key, &data) != SR_OK) + assert(_owner); + sr_dev_inst *const sdi = dev_inst(); + assert(sdi); + if (sr_config_list(sdi->driver, sdi, group, key, &data) != SR_OK) return NULL; return data; } -void DevInst::enable_probe(const sr_probe *probe, bool enable) +void DevInst::enable_channel(const sr_channel *channel, bool enable) { - for (const GSList *p = _sdi->probes; p; p = p->next) - if (probe == p->data) { - const_cast(probe)->enabled = enable; + assert(_owner); + sr_dev_inst *const sdi = dev_inst(); + assert(sdi); + for (const GSList *p = sdi->channels; p; p = p->next) + if (channel == p->data) { + const_cast(channel)->enabled = enable; config_changed(); return; } - // Probe was not found in the device + // Channel was not found in the device assert(0); } @@ -91,5 +119,21 @@ uint64_t DevInst::get_sample_limit() return sample_limit; } +bool DevInst::is_trigger_enabled() const +{ + return false; +} + +void DevInst::start() +{ + if (sr_session_start(SigSession::_sr_session) != SR_OK) + throw tr("Failed to start session."); +} + +void DevInst::run() +{ + sr_session_run(SigSession::_sr_session); +} + } // device } // pv