29#ifndef USRP_PROP_TREE_HDR
30#define USRP_PROP_TREE_HDR
33#include <uhd/usrp/multi_usrp.hpp>
34#include <uhd/property_tree.hpp>
35#include <SoDa/Format.hxx>
55 USRPPropTree(
const uhd::usrp::multi_usrp::sptr usrp,
const std::string &requester,
int mb_index = 0)
60 mb0_name = usrp->get_device()->get_tree()->list(
"/mboards").at(mb_index);
62 catch (std::runtime_error e)
64 complain((SoDa::Format(
"Exception looking for motherboard %0").addI(mb_index)).str(), e,
false);
71 tree = usrp->get_device()->get_tree()->subtree(
fqpn);
73 catch (std::runtime_error e)
75 complain(
"Exception while creating initial motherboard property tree",
fqpn, e,
false);
113 std::vector<std::string> pslis =
tree->list(
"");
114 ret = std::find(pslis.begin(), pslis.end(), propname) != pslis.end();
116 catch (std::runtime_error e)
118 complain(
"Exception while looking for property",
fqpn +
"/" + propname, e,
false);
123 std::vector<std::string>
getPropNames(
const std::string &path = std::string(
""))
125 return tree->list(path);
128 std::string
getStringProp(
const std::string &propname,
const std::string defval = std::string(
"None"))
133 int getIntProp(
const std::string &propname,
const int defval = 0)
143 bool getBoolProp(
const std::string &propname,
const bool defval =
false)
148 void setStringProp(
const std::string &propname,
const std::string val = std::string(
"None"))
153 void setIntProp(
const std::string &propname,
const int val = 0)
163 void setBoolProp(
const std::string &propname,
const bool val =
false)
168 template <
typename T>
172 std::string path =
fqpn +
"/" + propname;
175 ret =
tree->access<T>(propname).get();
177 catch (std::runtime_error e)
179 complain(
"getProperty Unknown exception -- unknown property", path, e);
184 template <
typename T>
188 std::string path =
fqpn +
"/" + propname;
191 ret =
tree->access<T>(propname).get();
193 catch (std::runtime_error e)
195 complain(
"getProperty Unknown exception -- unknown property", path, e,
false);
200 template <
typename T>
203 std::string path =
fqpn +
"/" + propname;
206 tree->access<T>(propname).set(val);
208 catch (std::runtime_error e)
210 complain(
"setProperty Unknown exception -- unknown property", path, e);
222 catch (std::runtime_error e)
224 complain(
"Exception while creating a subtree", path, e,
false);
231 std::runtime_error &e,
232 bool continue_p =
true)
234 std::cerr << SoDa::Format(
"USRPPropTree encountered %0\n\tRequester: %1\n\tException: [%2]\n\t%3\n")
235 .addS(explain_string)
238 .addS((continue_p ?
"Thread will continue" :
"Thread will terminate"));
244 const std::string &path,
245 std::runtime_error &e,
246 bool continue_p =
true)
248 std::cerr << SoDa::Format(
"USRPPropTree encountered %0\n\twhile looking for path [%1]\n\tRequester: %2\n\tException: [%3]\n\t%4\n")
249 .addS(explain_string)
253 .addS((continue_p ?
"Thread will continue" :
"Thread will terminate"));
void setDoubleProp(const std::string &propname, const double val=0.0)
uhd::property_tree::sptr tree
void setProperty(const std::string &propname, const T val)
USRPPropTree(USRPPropTree *ptree, const std::string &path)
Constructor – build a property tree widget that is a subtree of the mboard property tree.
void complain(const std::string &explain_string, std::runtime_error &e, bool continue_p=true)
T getProperty(const std::string &propname, const T defval)
int getIntProp(const std::string &propname, const int defval=0)
void init(USRPPropTree *ptree, const std::string &path)
std::string client_name
the name of the runtime object/thread that created this tree.
void setBoolProp(const std::string &propname, const bool val=false)
std::string getStringProp(const std::string &propname, const std::string defval=std::string("None"))
bool getBoolProp(const std::string &propname, const bool defval=false)
void setIntProp(const std::string &propname, const int val=0)
void setStringProp(const std::string &propname, const std::string val=std::string("None"))
int getDoubleProp(const std::string &propname, const double defval=0.0)
std::vector< std::string > getPropNames(const std::string &path=std::string(""))
void complain(const std::string &explain_string, const std::string &path, std::runtime_error &e, bool continue_p=true)
USRPPropTree(USRPPropTree &ptree, const std::string &path)
Constructor – build a property tree widget that is a subtree of the mboard property tree.
USRPPropTree(const uhd::usrp::multi_usrp::sptr usrp, const std::string &requester, int mb_index=0)
Constructor – build a property tree widget rooted at the first motherboard in this multi-usrp.
bool hasProperty(const std::string &propname)
does the property tree have this property name as a child?
T getProperty(const std::string &propname)