Loading...
Searching...
No Matches
sensors.hpp
Go to the documentation of this file.
//
// Copyright 2011 Ettus Research LLC
// Copyright 2018 Ettus Research, a National Instruments Company
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
#pragma once
#include <uhd/config.hpp>
#include <map>
#include <string>
namespace uhd {
struct UHD_API sensor_value_t
{
typedef std::map<std::string, std::string> sensor_map_t;
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;
signed to_int(void) const;
double to_real(void) const;
sensor_map_t to_map(void) const;
std::string name;
std::string value;
std::string unit;
enum data_type_t { BOOLEAN = 'b', INTEGER = 'i', REALNUM = 'r', STRING = 's' };
data_type_t type;
std::string to_pp_string(void) const;
sensor_value_t& operator=(const sensor_value_t& value);
};
} // namespace uhd
UHD_API
#define UHD_API
Definition config.h:87
config.hpp
uhd
Definition build_info.hpp:12
uhd::sensor_value_t::to_bool
bool to_bool(void) const
convert the sensor value to a boolean
uhd::sensor_value_t::data_type_t
data_type_t
Enumeration of possible data types in a sensor.
Definition sensors.hpp:123
uhd::sensor_value_t::REALNUM
@ REALNUM
Definition sensors.hpp:123
uhd::sensor_value_t::INTEGER
@ INTEGER
Definition sensors.hpp:123
uhd::sensor_value_t::BOOLEAN
@ BOOLEAN
Definition sensors.hpp:123
uhd::sensor_value_t::STRING
@ STRING
Definition sensors.hpp:123
uhd::sensor_value_t::to_int
signed to_int(void) const
convert the sensor value to an integer
uhd::sensor_value_t::to_real
double to_real(void) const
convert the sensor value to real number
uhd::sensor_value_t::sensor_value_t
sensor_value_t(const std::string &name, signed value, const std::string &unit, const std::string &formatter="%d")
uhd::sensor_value_t::sensor_map_t
std::map< std::string, std::string > sensor_map_t
Definition sensors.hpp:30
uhd::sensor_value_t::sensor_value_t
sensor_value_t(const std::string &name, const std::string &value, const std::string &unit)
uhd::sensor_value_t::sensor_value_t
sensor_value_t(const std::string &name, bool value, const std::string &utrue, const std::string &ufalse)
uhd::sensor_value_t::value
std::string value
Definition sensors.hpp:113
uhd::sensor_value_t::sensor_value_t
sensor_value_t(const sensor_value_t &source)
uhd::sensor_value_t::to_map
sensor_map_t to_map(void) const
convert the sensor value to sensor_map_t
uhd::sensor_value_t::sensor_value_t
sensor_value_t(const std::string &name, double value, const std::string &unit, const std::string &formatter="%f")
uhd::sensor_value_t::operator=
sensor_value_t & operator=(const sensor_value_t &value)
Assignment operator for sensor value.
uhd::sensor_value_t::name
std::string name
The name of the sensor value.
Definition sensors.hpp:106
uhd::sensor_value_t::sensor_value_t
sensor_value_t(const std::map< std::string, std::string > &sensor_dict)
uhd::sensor_value_t::type
data_type_t type
The data type of the value.
Definition sensors.hpp:126
uhd::sensor_value_t::to_pp_string
std::string to_pp_string(void) const
Convert this sensor value into a printable string.
uhd::sensor_value_t::unit
std::string unit
Definition sensors.hpp:120