diff options
author | Paul David <paul.david@ettus.com> | 2016-09-23 10:48:32 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2016-11-29 15:02:16 -0800 |
commit | a9dfc903fa3c141d58a2575898b47c9592d51e98 (patch) | |
tree | e663a1918a3a66dccd5d40749eac8abf26ed69d9 /host/include | |
parent | fc54c27b48028c9c8139175d40b4b061800f32e3 (diff) | |
download | uhd-a9dfc903fa3c141d58a2575898b47c9592d51e98.tar.gz uhd-a9dfc903fa3c141d58a2575898b47c9592d51e98.tar.bz2 uhd-a9dfc903fa3c141d58a2575898b47c9592d51e98.zip |
calibration: generic containers for datasets
- Includes a container for power calibration data
- Unit tests to check underlying container functionality
- Nearest neighbor and bilinear interpolation
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/include/uhd/cal/CMakeLists.txt | 23 | ||||
-rw-r--r-- | host/include/uhd/cal/container.hpp | 104 | ||||
-rw-r--r-- | host/include/uhd/cal/power_container.hpp | 79 |
4 files changed, 207 insertions, 0 deletions
diff --git a/host/include/uhd/CMakeLists.txt b/host/include/uhd/CMakeLists.txt index e31ff80a0..42c89a9f3 100644 --- a/host/include/uhd/CMakeLists.txt +++ b/host/include/uhd/CMakeLists.txt @@ -18,6 +18,7 @@ ADD_SUBDIRECTORY(rfnoc) ADD_SUBDIRECTORY(transport) ADD_SUBDIRECTORY(types) +ADD_SUBDIRECTORY(cal) ADD_SUBDIRECTORY(usrp) ADD_SUBDIRECTORY(usrp_clock) ADD_SUBDIRECTORY(utils) diff --git a/host/include/uhd/cal/CMakeLists.txt b/host/include/uhd/cal/CMakeLists.txt new file mode 100644 index 000000000..14107ee53 --- /dev/null +++ b/host/include/uhd/cal/CMakeLists.txt @@ -0,0 +1,23 @@ +# +# Copyright 2016 Ettus Research +# +# 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 <http://www.gnu.org/licenses/>. +# + +UHD_INSTALL(FILES + container.hpp + power_container.hpp + DESTINATION ${INCLUDE_DIR}/uhd/cal + COMPONENT headers +) diff --git a/host/include/uhd/cal/container.hpp b/host/include/uhd/cal/container.hpp new file mode 100644 index 000000000..e4f418311 --- /dev/null +++ b/host/include/uhd/cal/container.hpp @@ -0,0 +1,104 @@ +// +// Copyright 2016 Ettus Research +// +// 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 <http://www.gnu.org/licenses/>. +// + +#ifndef INCLUDED_UHD_CAL_CONTAINER_HPP +#define INCLUDED_UHD_CAL_CONTAINER_HPP + +#include <uhd/config.hpp> +#include <boost/serialization/serialization.hpp> +#include <boost/serialization/vector.hpp> +#include <boost/serialization/string.hpp> +#include <boost/serialization/map.hpp> +#include <boost/archive/text_iarchive.hpp> +#include <boost/archive/text_oarchive.hpp> +#include <boost/shared_ptr.hpp> + +namespace uhd { +namespace cal { + +class base_container { +public: + typedef std::map<std::string, std::string> metadata_t; + typedef boost::shared_ptr<base_container> sptr; +}; + +/*! + * An interface for creating and managing a generic calibration + * data container. + * + * These containers are used to represent N dimensional data structures + * in order to accommodate a mapping from multi-variable input to a scalar + * value (e.g. gain, frequency, temperature -> power level [dBm]). + * + * The container only supports inputs of the same type to be mapped. + * + */ +template<typename in_type, typename out_type> +class UHD_API cal_container : public base_container { +public: + typedef std::map<in_type, out_type> container_t; + + /*! + * Get the mapping from an input to an output + * from the calibration container. + * + * \param args input values + * \returns the output of the mapping (a scalar value) + * \throws uhd::assertion_error if the dimensions of the input args + * are incorrect for this container + */ + virtual out_type get(const in_type &args) = 0; + + /*! + * Add a data point to the container. + * This function records a mapping R^n -> R between an input vector + * and output scalar. + * + * \param output the output of the data point mapping + * \param args input values + */ + virtual void add(const out_type output, const in_type &args) = 0; + + /*! + * Associate some metadata with the container. + * + * \param data a map of metadata (string -> string). + */ + virtual void add_metadata(const metadata_t &data) = 0; + + /*! + * Retrieve metadata from the container. + * + * \returns map of metadata. + */ + virtual const metadata_t &get_metadata() = 0; + +public: + typedef boost::archive::text_iarchive iarchive_type; + typedef boost::archive::text_oarchive oarchive_type; + +protected: + friend class boost::serialization::access; + + virtual void serialize(iarchive_type & ar, const unsigned int) = 0; + virtual void serialize(oarchive_type & ar, const unsigned int) = 0; +}; + +} // namespace cal +} // namespace uhd + +#endif /* INCLUDED_UHD_CAL_CONTAINER_HPP */ diff --git a/host/include/uhd/cal/power_container.hpp b/host/include/uhd/cal/power_container.hpp new file mode 100644 index 000000000..37f7bd8df --- /dev/null +++ b/host/include/uhd/cal/power_container.hpp @@ -0,0 +1,79 @@ +// +// Copyright 2016 Ettus Research +// +// 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 <http://www.gnu.org/licenses/>. +// + +#ifndef INCLUDED_UHD_CAL_POWER_CONTAINER_HPP +#define INCLUDED_UHD_CAL_POWER_CONTAINER_HPP + +#include <uhd/config.hpp> +#include <uhd/cal/container.hpp> +#include <boost/shared_ptr.hpp> + +namespace uhd { +namespace cal { + +class UHD_API power_container : public cal_container<std::vector<double>, double> { +public: + typedef boost::shared_ptr<power_container> sptr; + + /*! + * Create a container for data related to power calibration. + * + * \returns shared pointer to the container + */ + static sptr make(); + + /*! + * Get the mapping from an input to an output + * from the calibration container. + * + * \param args input values + * \returns the output of the mapping (a scalar value) + * \throws uhd::assertion_error if the number of input values are incorrect + * for the container type + */ + virtual double get(const std::vector<double> &args) = 0; + + /*! + * Add a data point to the container. + * This function records a mapping R^n -> R between an input vector + * and output scalar. For example, a mapping might be + * (power level, frequency, temperature) -> gain. + * + * \param output the output of the data point mapping + * \param args input values + */ + virtual void add(const double output, const std::vector<double> &args) = 0; + + /*! + * Associate some metadata with the container. + * + * \param data a map of metadata (string -> string). + */ + virtual void add_metadata(const metadata_t &data) = 0; + + /*! + * Retrieve metadata from the container. + * + * \returns map of metadata. + */ + virtual const metadata_t &get_metadata() = 0; +}; + +} // namespace cal +} // namespace uhd + +#endif /* INCLUDED_UHD_CAL_POWER_CONTAINER_HPP */ |