From: Joel Holdsworth Date: Sat, 11 Jan 2014 11:36:19 +0000 (+0000) Subject: Added probe group support to DeviceOptions binding X-Git-Tag: pulseview-0.2.0~152 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=941c1ba74ba3ba6dd44bf23aafee28809138032b;p=pulseview.git Added probe group support to DeviceOptions binding --- diff --git a/pv/prop/binding/deviceoptions.cpp b/pv/prop/binding/deviceoptions.cpp index e661b195..a5b9dd23 100644 --- a/pv/prop/binding/deviceoptions.cpp +++ b/pv/prop/binding/deviceoptions.cpp @@ -45,15 +45,17 @@ namespace pv { namespace prop { namespace binding { -DeviceOptions::DeviceOptions(const sr_dev_inst *sdi) : - _sdi(sdi) +DeviceOptions::DeviceOptions(const sr_dev_inst *sdi, + const sr_probe_group *group) : + _sdi(sdi), + _group(group) { assert(sdi); GVariant *gvar_opts, *gvar_list; gsize num_opts; - if ((sr_config_list(sdi->driver, sdi, NULL, SR_CONF_DEVICE_OPTIONS, + if ((sr_config_list(sdi->driver, sdi, group, SR_CONF_DEVICE_OPTIONS, &gvar_opts) != SR_OK)) /* Driver supports no device instance options. */ return; @@ -69,7 +71,8 @@ DeviceOptions::DeviceOptions(const sr_dev_inst *sdi) : const int key = info->key; - if (sr_config_list(_sdi->driver, _sdi, NULL, key, &gvar_list) != SR_OK) + if (sr_config_list(_sdi->driver, _sdi, group, + key, &gvar_list) != SR_OK) gvar_list = NULL; const QString name = QString::fromUtf8(info->name); @@ -117,10 +120,10 @@ DeviceOptions::DeviceOptions(const sr_dev_inst *sdi) : } GVariant* DeviceOptions::config_getter( - const struct sr_dev_inst *sdi, int key) + const sr_dev_inst *sdi, const sr_probe_group *group, int key) { GVariant *data = NULL; - if (sr_config_get(sdi->driver, sdi, NULL, key, &data) != SR_OK) { + if (sr_config_get(sdi->driver, sdi, group, key, &data) != SR_OK) { qDebug() << "WARNING: Failed to get value of config id" << key; return NULL; @@ -129,17 +132,18 @@ GVariant* DeviceOptions::config_getter( } void DeviceOptions::config_setter( - const struct sr_dev_inst *sdi, int key, GVariant* value) + const struct sr_dev_inst *sdi, const sr_probe_group *group, int key, + GVariant* value) { - if (sr_config_set(sdi, NULL, key, value) != SR_OK) + if (sr_config_set(sdi, group, key, value) != SR_OK) qDebug() << "WARNING: Failed to set value of sample rate"; } void DeviceOptions::bind_bool(const QString &name, int key) { _properties.push_back(shared_ptr( - new Bool(name, bind(config_getter, _sdi, key), - bind(config_setter, _sdi, key, _1)))); + new Bool(name, bind(config_getter, _sdi, _group, key), + bind(config_setter, _sdi, _group, key, _1)))); } void DeviceOptions::bind_enum(const QString &name, int key, @@ -157,8 +161,8 @@ void DeviceOptions::bind_enum(const QString &name, int key, _properties.push_back(shared_ptr( new Enum(name, values, - bind(config_getter, _sdi, key), - bind(config_setter, _sdi, key, _1)))); + bind(config_getter, _sdi, _group, key), + bind(config_setter, _sdi, _group, key, _1)))); } void DeviceOptions::bind_int(const QString &name, int key, QString suffix, @@ -166,8 +170,8 @@ void DeviceOptions::bind_int(const QString &name, int key, QString suffix, { _properties.push_back(shared_ptr( new Int(name, suffix, range, - bind(config_getter, _sdi, key), - bind(config_setter, _sdi, key, _1)))); + bind(config_getter, _sdi, _group, key), + bind(config_setter, _sdi, _group, key, _1)))); } QString DeviceOptions::print_gvariant(GVariant *const gvar) diff --git a/pv/prop/binding/deviceoptions.h b/pv/prop/binding/deviceoptions.h index f27823bd..ab0f0171 100644 --- a/pv/prop/binding/deviceoptions.h +++ b/pv/prop/binding/deviceoptions.h @@ -37,14 +37,16 @@ namespace binding { class DeviceOptions : public Binding { public: - DeviceOptions(const sr_dev_inst *sdi); + DeviceOptions(const sr_dev_inst *sdi, + const sr_probe_group *group = NULL); private: static GVariant* config_getter( - const struct sr_dev_inst *sdi, int key); + const sr_dev_inst *sdi, const sr_probe_group *group, int key); static void config_setter( - const struct sr_dev_inst *sdi, int key, GVariant* value); + const sr_dev_inst *sdi, const sr_probe_group *group, int key, + GVariant* value); void bind_bool(const QString &name, int key); void bind_enum(const QString &name, int key, @@ -61,6 +63,7 @@ private: protected: const sr_dev_inst *const _sdi; + const sr_probe_group *const _group; }; } // binding