X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fdevice%2Fdevice.cpp;h=4f9a7799539b5e125b01e0a1591ac8c165da7414;hb=4871ed92f2d9e6e514223383ba16e6ad78c81161;hp=be25b5cb1cd017abb7ae0dd46f55650aeeb31878;hpb=29efe92a807a93572b44369d2703f572778ebb15;p=pulseview.git diff --git a/pv/device/device.cpp b/pv/device/device.cpp index be25b5c..4f9a779 100644 --- a/pv/device/device.cpp +++ b/pv/device/device.cpp @@ -41,6 +41,28 @@ 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 { ostringstream s; @@ -66,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->channels; l; l = l->next) { + const sr_channel *const p = (const sr_channel *)l->data; + assert(p); + if (p->trigger && p->trigger[0] != '\0') + return true; + } + return false; +} + } // device } // pv