From 21605b4e8b58053f4fa91a0a5136261da33e3bfb Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 29 Sep 2017 13:51:43 -0700 Subject: types: sensor_value_t can now be created from map - Adds unit tests for sensor_value_t also --- host/include/uhd/types/sensors.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'host/include') diff --git a/host/include/uhd/types/sensors.hpp b/host/include/uhd/types/sensors.hpp index 6dede02dd..66501a7e9 100644 --- a/host/include/uhd/types/sensors.hpp +++ b/host/include/uhd/types/sensors.hpp @@ -8,6 +8,7 @@ #define INCLUDED_UHD_TYPES_SENSORS_HPP #include +#include #include namespace uhd{ @@ -25,6 +26,7 @@ namespace uhd{ * //prints Temperature: 38.5 C */ struct UHD_API sensor_value_t{ + typedef std::map sensor_map_t; /*! * Create a sensor value from a boolean. @@ -80,6 +82,18 @@ namespace uhd{ const std::string &unit ); + /*! + * Create a sensor value from a map. + * + * The map must have the following keys: name, type, value, and unit. + * + * type must one of the following strings: BOOLEAN, INTEGER, REALNUM, + * or STRING (see data_type_t). + */ + sensor_value_t( + const std::map &sensor_dict + ); + /*! * Create a sensor value from another sensor value. * \param source the source sensor value to copy -- cgit v1.2.3