X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fdevice%2Fdevice.cpp;h=e70be02592f0c58e3c2b59340068b39478f94842;hb=a28c30252fd32d3185c62062dfad74ae659ae383;hp=ca18fc13a73e2f63432832a9b536568d658f0437;hpb=921b90c0b3ae0cf44247da3d87bd7dc0612e9681;p=pulseview.git diff --git a/pv/device/device.cpp b/pv/device/device.cpp index ca18fc13..e70be025 100644 --- a/pv/device/device.cpp +++ b/pv/device/device.cpp @@ -31,8 +31,36 @@ namespace pv { namespace device { Device::Device(sr_dev_inst *sdi) : - DevInst(sdi) + _sdi(sdi) { + assert(_sdi); +} + +sr_dev_inst* Device::dev_inst() const +{ + return _sdi; +} + +void Device::use(SigSession *owner) throw(QString) +{ + DevInst::use(owner); + + sr_session_new(); + + assert(_sdi); + sr_dev_open(_sdi); + if (sr_session_dev_add(_sdi) != SR_OK) + throw QString(tr("Failed to use device.")); +} + +void Device::release() +{ + if (_owner) { + DevInst::release(); + sr_session_destroy(); + } + + sr_dev_close(_sdi); } std::string Device::format_device_title() const @@ -60,5 +88,17 @@ std::string Device::format_device_title() const return s.str(); } +bool Device::is_trigger_enabled() const +{ + assert(_sdi); + for (const GSList *l = _sdi->probes; l; l = l->next) { + const sr_probe *const p = (const sr_probe *)l->data; + assert(p); + if (p->trigger && p->trigger[0] != '\0') + return true; + } + return false; +} + } // device } // pv