From 3b056a00425c8c1cc907a14983611268efb86878 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 23 Jul 2010 21:53:37 -0700 Subject: uhd: added gain group and unit testing for it --- host/include/uhd/utils/CMakeLists.txt | 1 + host/include/uhd/utils/gain_group.hpp | 85 +++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 host/include/uhd/utils/gain_group.hpp (limited to 'host/include') diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt index d484788b2..4a5f20e3c 100644 --- a/host/include/uhd/utils/CMakeLists.txt +++ b/host/include/uhd/utils/CMakeLists.txt @@ -22,6 +22,7 @@ INSTALL(FILES byteswap.hpp byteswap.ipp exception.hpp + gain_group.hpp gain_handler.hpp pimpl.hpp props.hpp diff --git a/host/include/uhd/utils/gain_group.hpp b/host/include/uhd/utils/gain_group.hpp new file mode 100644 index 000000000..3955dfa9a --- /dev/null +++ b/host/include/uhd/utils/gain_group.hpp @@ -0,0 +1,85 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#ifndef INCLUDED_UHD_UTILS_GAIN_GROUP_HPP +#define INCLUDED_UHD_UTILS_GAIN_GROUP_HPP + +#include +#include +#include +#include +#include + +namespace uhd{ + +/*! + * A set of function to control a gain element. + */ +struct UHD_API gain_fcns_t{ + boost::function get_range; + boost::function get_value; + boost::function set_value; +}; + +class UHD_API gain_group : boost::noncopyable{ +public: + typedef boost::shared_ptr sptr; + + /*! + * Get the overall gain range for this group. + * Overall step is defined as the minimum step size. + * \return a gain range with overall min, max, step + */ + virtual gain_range_t get_range(void) = 0; + + /*! + * Get the overall gain value for this group. + * \return a summation of all the gain values + */ + virtual float get_value(void) = 0; + + /*! + * Set the overall gain value for this group. + * The power will be distributed across individual gain elements. + * The semantics of how to do this are determined by the priority. + * \param gain the gain to set across the group + */ + virtual void set_value(float gain) = 0; + + /*! + * Register a set of gain functions into this group. + * Priority determines how power will be distributed + * with higher priorities getting the power first, + * and lower priorities getting the remainder power. + * \param gain_fcns the set of gain functions + * \param priority the priority of the gain element + */ + virtual void register_fcns( + const gain_fcns_t &gain_fcns, size_t priority = 0 + ) = 0; + + /*! + * Make a new empty gain group. + * \return a gain group object. + */ + static sptr make(void); +}; + +} //namespace uhd + +#endif /* INCLUDED_UHD_UTILS_GAIN_GROUP_HPP */ + -- cgit v1.2.3