X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fbinding%2Fdevice.cpp;h=401644fd0672fa616c5c21586f619590e8b1cff1;hb=bf627f7065138ab21a25302b0f0e86b5111f692c;hp=6f9788932c8dd0d4377d98771cee69ad6b6760e3;hpb=1e1b3a668e6f3462d45c2047484dc1b86f41da51;p=pulseview.git
diff --git a/pv/binding/device.cpp b/pv/binding/device.cpp
index 6f97889..401644f 100644
--- a/pv/binding/device.cpp
+++ b/pv/binding/device.cpp
@@ -14,27 +14,27 @@
* 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
+ * along with this program; if not, see .
*/
-#include
+#include
#include
#include "device.hpp"
#include
-#include
#include
#include
#include
using boost::optional;
+
using std::function;
using std::make_pair;
using std::pair;
+using std::set;
using std::shared_ptr;
using std::string;
using std::vector;
@@ -45,7 +45,6 @@ using sigrok::ConfigKey;
using sigrok::Error;
using pv::prop::Bool;
-using pv::prop::Double;
using pv::prop::Enum;
using pv::prop::Int;
using pv::prop::Property;
@@ -56,17 +55,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))
@@ -88,15 +82,14 @@ Device::Device(shared_ptr configurable) :
config_changed();
};
- switch (key->id())
- {
+ switch (key->id()) {
case SR_CONF_SAMPLERATE:
// Sample rate values are not bound because they are shown
// in the MainBar
break;
case SR_CONF_CAPTURE_RATIO:
- bind_int(name, "%", pair(0, 100),
+ bind_int(name, "", "%", pair(0, 100),
get, set);
break;
@@ -104,32 +97,35 @@ 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);
+ 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:
- bind_bool(name, get, set);
+ bind_bool(name, "", get, set);
break;
case SR_CONF_TIMEBASE:
- bind_enum(name, key, capabilities, get, set, print_timebase);
+ bind_enum(name, "", key, capabilities, get, set, print_timebase);
break;
case SR_CONF_VDIV:
- bind_enum(name, key, capabilities, get, set, print_vdiv);
+ bind_enum(name, "", key, capabilities, get, set, print_vdiv);
break;
case SR_CONF_VOLTAGE_THRESHOLD:
- bind_enum(name, key, capabilities, get, set, print_voltage_threshold);
+ bind_enum(name, "", key, capabilities, get, set, print_voltage_threshold);
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:
@@ -138,16 +134,16 @@ Device::Device(shared_ptr configurable) :
}
}
-void Device::bind_bool(const QString &name,
+void Device::bind_bool(const QString &name, const QString &desc,
Property::Getter getter, Property::Setter setter)
{
assert(configurable_);
properties_.push_back(shared_ptr(new Bool(
- name, getter, setter)));
+ name, desc, getter, setter)));
}
-void Device::bind_enum(const QString &name,
- const ConfigKey *key, std::set capabilities,
+void Device::bind_enum(const QString &name, const QString &desc,
+ const ConfigKey *key, set capabilities,
Property::Getter getter,
Property::Setter setter, function printer)
{
@@ -163,25 +159,25 @@ void Device::bind_enum(const QString &name,
while ((iter.next_value(gvar)))
values.push_back(make_pair(gvar, printer(gvar)));
- properties_.push_back(shared_ptr(new Enum(name, values,
+ properties_.push_back(shared_ptr(new Enum(name, desc, values,
getter, setter)));
}
-void Device::bind_int(const QString &name, QString suffix,
- optional< std::pair > range,
+void Device::bind_int(const QString &name, const QString &desc, QString suffix,
+ optional< pair > range,
Property::Getter getter, Property::Setter setter)
{
assert(configurable_);
- properties_.push_back(shared_ptr(new Int(name, suffix, range,
- getter, setter)));
+ properties_.push_back(shared_ptr(new Int(name, desc, suffix,
+ range, getter, setter)));
}
QString Device::print_timebase(Glib::VariantBase gvar)
{
uint64_t p, q;
g_variant_get(gvar.gobj(), "(tt)", &p, &q);
- return QString::fromUtf8(sr_period_string(p * q));
+ return QString::fromUtf8(sr_period_string(p, q));
}
QString Device::print_vdiv(Glib::VariantBase gvar)
@@ -198,5 +194,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);
}
-} // binding
-} // pv
+QString Device::print_probe_factor(Glib::VariantBase gvar)
+{
+ uint64_t factor;
+ factor = g_variant_get_uint64(gvar.gobj());
+ return QString("%1x").arg(factor);
+}
+
+} // namespace binding
+} // namespace pv