USRP Hardware Driver and USRP Manual: uhd::sensor_value_t Struct Reference

| USRP Hardware Driver and USRP Manual Version: 4.9.0.makepkg-0-g9ec1f582 UHD and USRP Manual |

Loading...
Searching...
No Matches
uhd::sensor_value_t Struct Reference

`#include <uhd/types/sensors.hpp>`

## Public Types
enum | data_type_t { BOOLEAN = 'b' , INTEGER = 'i' , REALNUM = 'r' , STRING = 's' }
| Enumeration of possible data types in a sensor. More...
typedef std::map< std::string, std::string > | sensor_map_t

## Public Member Functions
| sensor_value_t (const std::string &name, bool value, const std::string &utrue, const std::string &ufalse)
| sensor_value_t (const std::string &name, signed value, const std::string &unit, const std::string &formatter="%d")
| sensor_value_t (const std::string &name, double value, const std::string &unit, const std::string &formatter="%f")
| sensor_value_t (const std::string &name, const std::string &value, const std::string &unit)
| sensor_value_t (const std::map< std::string, std::string > &sensor_dict)
| sensor_value_t (const sensor_value_t &source)
bool | to_bool (void) const
| convert the sensor value to a boolean
signed | to_int (void) const
| convert the sensor value to an integer
double | to_real (void) const
| convert the sensor value to real number
sensor_map_t | to_map (void) const
| convert the sensor value to sensor_map_t
std::string | to_pp_string (void) const
| Convert this sensor value into a printable string.
sensor_value_t & | operator= (const sensor_value_t &value)
| Assignment operator for sensor value.

## Public Attributes
std::string | name
| The name of the sensor value.
std::string | value
std::string | unit
data_type_t | type
| The data type of the value.

## Detailed Description

A sensor value stores a sensor reading as a string with unit and data type. The sensor value class can be used in the following way:

sensor_value_t ref_lock_sensor("Reference", my_lock, "unlocked", "locked"); std::cout << ref_lock_sensor.to_pp_string() << std::endl; //prints Reference: locked

sensor_value_t temp_sensor("Temperature", my_temp, "C"); std::cout << temp_sensor.to_pp_string() << std::endl; //prints Temperature: 38.5 C

## Member Typedef Documentation

## ◆ sensor_map_t

typedef std::map<std::string, std::string> uhd::sensor_value_t::sensor_map_t

## Member Enumeration Documentation

## ◆ data_type_t

enum uhd::sensor_value_t::data_type_t

Enumeration of possible data types in a sensor.

Enumerator
BOOLEAN |
INTEGER |
REALNUM |
STRING |

## Constructor & Destructor Documentation

## ◆ sensor_value_t() [1/6]

uhd::sensor_value_t::sensor_value_t | ( | const std::string & | name,
|  | bool | value,
|  | const std::string & | utrue,
|  | const std::string & | ufalse )

Create a sensor value from a boolean.

Parameters

  name | the name of the sensor
  value | the value true or false
  utrue | the unit string when value is true
  ufalse | the unit string when value is false

## ◆ sensor_value_t() [2/6]

uhd::sensor_value_t::sensor_value_t | ( | const std::string & | name,
|  | signed | value,
|  | const std::string & | unit,
|  | const std::string & | formatter = "%d" )

Create a sensor value from an integer.

Parameters

  name | the name of the sensor
  value | the signed integer value
  unit | the associated unit type
  formatter | the formatter string

## ◆ sensor_value_t() [3/6]

uhd::sensor_value_t::sensor_value_t | ( | const std::string & | name,
|  | double | value,
|  | const std::string & | unit,
|  | const std::string & | formatter = "%f" )

Create a sensor value from a real number.

Parameters

  name | the name of the sensor
  value | the real number value
  unit | the associated unit type
  formatter | the formatter string

## ◆ sensor_value_t() [4/6]

uhd::sensor_value_t::sensor_value_t | ( | const std::string & | name,
|  | const std::string & | value,
|  | const std::string & | unit )

Create a sensor value from a string.

Parameters

  name | the name of the sensor
  value | the real number value
  unit | the associated unit type

## ◆ sensor_value_t() [5/6]

uhd::sensor_value_t::sensor_value_t | ( | const std::map< std::string, std::string > & | sensor_dict | ) |

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() [6/6]

uhd::sensor_value_t::sensor_value_t | ( | const sensor_value_t & | source | ) |

Create a sensor value from another sensor value.

Parameters

  source | the source sensor value to copy

## Member Function Documentation

## ◆ operator=()

sensor_value_t & uhd::sensor_value_t::operator= | ( | const sensor_value_t & | value | ) |

Assignment operator for sensor value.

## ◆ to_bool()

bool uhd::sensor_value_t::to_bool | ( | void |  | ) | const

convert the sensor value to a boolean

## ◆ to_int()

signed uhd::sensor_value_t::to_int | ( | void |  | ) | const

convert the sensor value to an integer

## ◆ to_map()

sensor_map_t uhd::sensor_value_t::to_map | ( | void |  | ) | const

convert the sensor value to sensor_map_t

## ◆ to_pp_string()

std::string uhd::sensor_value_t::to_pp_string | ( | void |  | ) | const

Convert this sensor value into a printable string.

## ◆ to_real()

double uhd::sensor_value_t::to_real | ( | void |  | ) | const

convert the sensor value to real number

## Member Data Documentation

## ◆ name

std::string uhd::sensor_value_t::name

The name of the sensor value.

## ◆ type

data_type_t uhd::sensor_value_t::type

The data type of the value.

## ◆ unit

std::string uhd::sensor_value_t::unit

The sensor value's unit type. For boolean types, this will be the one of the two units depending upon the value of the boolean true or false.

## ◆ value

std::string uhd::sensor_value_t::value

The sensor value as a string. For integer and real number types, this will be the output of the formatter. For boolean types, the value will be the string literal "true" or "false".

The documentation for this struct was generated from the following file:

- sensors.hpp