diff options
author | Josh Blum <josh@joshknows.com> | 2011-02-11 21:52:13 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-02-11 21:52:13 -0800 |
commit | 4613f454c781d258d6d9b210ff1b9043a2125981 (patch) | |
tree | b69eab37b2099a5d699ac6b480673134d29e7fda /host/include | |
parent | 9de6f36bc5d9f5d9d602547166c92b53b278b428 (diff) | |
download | uhd-4613f454c781d258d6d9b210ff1b9043a2125981.tar.gz uhd-4613f454c781d258d6d9b210ff1b9043a2125981.tar.bz2 uhd-4613f454c781d258d6d9b210ff1b9043a2125981.zip |
uhd: added to_<type> calls to sensors to make it easy
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/types/sensors.hpp | 19 | ||||
-rw-r--r-- | host/include/uhd/usrp/multi_usrp.hpp | 7 |
2 files changed, 14 insertions, 12 deletions
diff --git a/host/include/uhd/types/sensors.hpp b/host/include/uhd/types/sensors.hpp index 6f003bb40..b6215367f 100644 --- a/host/include/uhd/types/sensors.hpp +++ b/host/include/uhd/types/sensors.hpp @@ -37,12 +37,6 @@ namespace uhd{ */ struct UHD_API sensor_value_t{ - //! typedef for the signed integer type - typedef signed int_type; - - //! typedef for the real number type - typedef double real_type; - /*! * Create a sensor value from a boolean. * \param name the name of the sensor @@ -66,7 +60,7 @@ namespace uhd{ */ sensor_value_t( const std::string &name, - int_type value, + signed value, const std::string &unit, const std::string &formatter = "%d" ); @@ -80,7 +74,7 @@ namespace uhd{ */ sensor_value_t( const std::string &name, - real_type value, + double value, const std::string &unit, const std::string &formatter = "%f" ); @@ -97,6 +91,15 @@ namespace uhd{ const std::string &unit ); + //! convert the sensor value to a boolean + bool to_bool(void) const; + + //! convert the sensor value to an integer + signed to_int(void) const; + + //! convert the sensor value to real number + double to_real(void) const; + //! The name of the sensor value const std::string name; diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp index da52e6dce..3c8dd5fac 100644 --- a/host/include/uhd/usrp/multi_usrp.hpp +++ b/host/include/uhd/usrp/multi_usrp.hpp @@ -28,7 +28,6 @@ #include <uhd/types/sensors.hpp> #include <uhd/usrp/subdev_spec.hpp> #include <uhd/usrp/dboard_iface.hpp> -#include <boost/lexical_cast.hpp> //needed until deprecated routines removed #include <boost/shared_ptr.hpp> #include <boost/utility.hpp> #include <vector> @@ -395,7 +394,7 @@ public: * \return true for locked */ UHD_DEPRECATED bool get_rx_lo_locked(size_t chan = 0){ - return this->get_rx_sensor("lo_locked", chan).value == "true"; + return this->get_rx_sensor("lo_locked", chan).to_bool(); } /*! @@ -419,7 +418,7 @@ public: * \throw exception if RSSI readback not supported */ UHD_DEPRECATED double read_rssi(size_t chan = 0){ - return boost::lexical_cast<double>(this->get_rx_sensor("rssi", chan).value); + return this->get_rx_sensor("rssi", chan).to_real(); } /*! @@ -593,7 +592,7 @@ public: * \return true for locked */ UHD_DEPRECATED bool get_tx_lo_locked(size_t chan = 0){ - return this->get_tx_sensor("lo_locked", chan).value == "true"; + return this->get_tx_sensor("lo_locked", chan).to_bool(); } /*! |