From 4613f454c781d258d6d9b210ff1b9043a2125981 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 11 Feb 2011 21:52:13 -0800 Subject: uhd: added to_ calls to sensors to make it easy --- host/include/uhd/types/sensors.hpp | 19 +++++++++++-------- host/include/uhd/usrp/multi_usrp.hpp | 7 +++---- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'host/include') 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 #include #include -#include //needed until deprecated routines removed #include #include #include @@ -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(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(); } /*! -- cgit v1.2.3