X-Git-Url: http://git.code-monkey.de/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fbinding%2Fdevice.cpp;h=521177ad4bfd3f7fb64a70d9c5f66fd726050aec;hp=77c772c088b07dabcbba1ed782339560527dae09;hb=49c62417b6b306607048b07f86b73f127e3084a3;hpb=2ad82c2e40b6865481733913a2c32735602f63c4 diff --git a/pv/binding/device.cpp b/pv/binding/device.cpp index 77c772c..521177a 100644 --- a/pv/binding/device.cpp +++ b/pv/binding/device.cpp @@ -56,17 +56,12 @@ namespace binding { Device::Device(shared_ptr configurable) : configurable_(configurable) { - std::map< const ConfigKey*, std::set > keys; - try { - keys = configurable->config_keys(ConfigKey::DEVICE_OPTIONS); - } catch (const Error) { - return; - } + auto keys = configurable->config_keys(); - for (auto entry : keys) { - auto key = entry.first; - auto capabilities = entry.second; + for (auto key : keys) { + + auto capabilities = configurable->config_capabilities(key); if (!capabilities.count(Capability::GET) || !capabilities.count(Capability::SET)) @@ -103,12 +98,12 @@ Device::Device(shared_ptr configurable) : case SR_CONF_BUFFERSIZE: case SR_CONF_TRIGGER_SOURCE: case SR_CONF_TRIGGER_SLOPE: - case SR_CONF_FILTER: case SR_CONF_COUPLING: case SR_CONF_CLOCK_EDGE: bind_enum(name, key, capabilities, get, set); break; + case SR_CONF_FILTER: case SR_CONF_EXTERNAL_CLOCK: case SR_CONF_RLE: case SR_CONF_POWER_OFF: @@ -128,7 +123,10 @@ Device::Device(shared_ptr configurable) : break; case SR_CONF_PROBE_FACTOR: - bind_int(name, "", pair(1, 500), get, set); + if (capabilities.count(Capability::LIST)) + bind_enum(name, key, capabilities, get, set, print_probe_factor); + else + bind_int(name, "", pair(1, 500), get, set); break; default: @@ -146,7 +144,7 @@ void Device::bind_bool(const QString &name, } void Device::bind_enum(const QString &name, - const ConfigKey *key, std::set capabilities, + const ConfigKey *key, std::set capabilities, Property::Getter getter, Property::Setter setter, function printer) { @@ -197,5 +195,12 @@ QString Device::print_voltage_threshold(Glib::VariantBase gvar) return QString("L<%1V H>%2V").arg(lo, 0, 'f', 1).arg(hi, 0, 'f', 1); } +QString Device::print_probe_factor(Glib::VariantBase gvar) +{ + uint64_t factor; + factor = g_variant_get_uint64(gvar.gobj()); + return QString("%1x").arg(factor); +} + } // binding } // pv