aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/utils
diff options
context:
space:
mode:
authorPhilip Balister <philip@opensdr.com>2010-10-27 06:27:05 -0400
committerPhilip Balister <philip@opensdr.com>2010-10-27 06:27:05 -0400
commitfbdb002223f54bedbc7a4093494011c1b266fa75 (patch)
treec8ba9446f117893cb28c00b91f953b5339c71f5f /host/lib/utils
parentdb0e3e574e9058ad51cacea91ccc42f0baed95fa (diff)
parentef8ed898cbc6cb6cd1994d2a8b090112f4f3a664 (diff)
downloaduhd-fbdb002223f54bedbc7a4093494011c1b266fa75.tar.gz
uhd-fbdb002223f54bedbc7a4093494011c1b266fa75.tar.bz2
uhd-fbdb002223f54bedbc7a4093494011c1b266fa75.zip
Merge branch 'master' of ettus.sourcerepo.com:ettus/uhdpriv into usrp_e
Diffstat (limited to 'host/lib/utils')
-rw-r--r--host/lib/utils/gain_group.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/host/lib/utils/gain_group.cpp b/host/lib/utils/gain_group.cpp
index 078fe56b2..54146726a 100644
--- a/host/lib/utils/gain_group.cpp
+++ b/host/lib/utils/gain_group.cpp
@@ -63,7 +63,9 @@ public:
/*NOP*/
}
- gain_range_t get_range(void){
+ gain_range_t get_range(const std::string &name){
+ if (not name.empty()) return _name_to_fcns[name].get_range();
+
float overall_min = 0, overall_max = 0, overall_step = 0;
BOOST_FOREACH(const gain_fcns_t &fcns, get_all_fcns()){
const gain_range_t range = fcns.get_range();
@@ -76,7 +78,9 @@ public:
return gain_range_t(overall_min, overall_max, overall_step);
}
- float get_value(void){
+ float get_value(const std::string &name){
+ if (not name.empty()) return _name_to_fcns[name].get_value();
+
float overall_gain = 0;
BOOST_FOREACH(const gain_fcns_t &fcns, get_all_fcns()){
overall_gain += fcns.get_value();
@@ -84,7 +88,9 @@ public:
return overall_gain;
}
- void set_value(float gain){
+ void set_value(float gain, const std::string &name){
+ if (not name.empty()) return _name_to_fcns[name].set_value(gain);
+
std::vector<gain_fcns_t> all_fcns = get_all_fcns();
if (all_fcns.size() == 0) return; //nothing to set!
@@ -140,10 +146,21 @@ public:
}
}
+ const std::vector<std::string> get_names(void){
+ return _name_to_fcns.keys();
+ }
+
void register_fcns(
- const gain_fcns_t &gain_fcns, size_t priority
+ const std::string &name,
+ const gain_fcns_t &gain_fcns,
+ size_t priority
){
+ if (name.empty() or _name_to_fcns.has_key(name)){
+ //ensure the name name is unique and non-empty
+ return register_fcns(name + "_", gain_fcns, priority);
+ }
_registry[priority].push_back(gain_fcns);
+ _name_to_fcns[name] = gain_fcns;
}
private:
@@ -158,6 +175,7 @@ private:
}
uhd::dict<size_t, std::vector<gain_fcns_t> > _registry;
+ uhd::dict<std::string, gain_fcns_t> _name_to_fcns;
};
/***********************************************************************