X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fdevice%2Fdevinst.cpp;fp=pv%2Fdevice%2Fdevinst.cpp;h=0000000000000000000000000000000000000000;hb=e8d009288de28cb194bc7964f96677c2baf900c9;hp=0301063440200d4b693105623f329fbce303b9f6;hpb=87b79835014a386fb51b52bc993dbb693bd27197;p=pulseview.git diff --git a/pv/device/devinst.cpp b/pv/device/devinst.cpp deleted file mode 100644 index 0301063..0000000 --- a/pv/device/devinst.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - * This file is part of the PulseView project. - * - * Copyright (C) 2014 Joel Holdsworth - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#include - -#include - -#include "devinst.h" - -#include - -namespace pv { -namespace device { - -DevInst::DevInst() : - _owner(NULL) -{ -} - -void DevInst::use(SigSession *owner) throw(QString) -{ - assert(owner); - assert(!_owner); - _owner = owner; -} - -void DevInst::release() -{ - if (_owner) { - _owner->release_device(this); - _owner = NULL; - } -} - -SigSession* DevInst::owner() const -{ - return _owner; -} - -GVariant* DevInst::get_config(const sr_channel_group *group, int key) -{ - GVariant *data = NULL; - 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_channel_group *group, int key, GVariant *data) -{ - 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_channel_group *group, int key) -{ - GVariant *data = NULL; - 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_channel(const sr_channel *channel, bool 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; - } - - // Channel was not found in the device - assert(0); -} - -uint64_t DevInst::get_sample_limit() -{ - uint64_t sample_limit; - GVariant* gvar = get_config(NULL, SR_CONF_LIMIT_SAMPLES); - if (gvar != NULL) { - sample_limit = g_variant_get_uint64(gvar); - g_variant_unref(gvar); - } else { - sample_limit = 0U; - } - 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