a

Dependencies:   mbed mbed-rtos

Committer:
alexpirciu
Date:
Thu Mar 28 07:44:42 2019 +0000
Revision:
1:ceee5a608e7c
assa

Who changed what in which revision?

UserRevisionLine numberNew contents of line
alexpirciu 1:ceee5a608e7c 1 /**
alexpirciu 1:ceee5a608e7c 2 ******************************************************************************
alexpirciu 1:ceee5a608e7c 3 * @file converters.hpp
alexpirciu 1:ceee5a608e7c 4 * @author RBRO/PJ-IU
alexpirciu 1:ceee5a608e7c 5 * @version V1.0.0
alexpirciu 1:ceee5a608e7c 6 * @date 2018-10-29
alexpirciu 1:ceee5a608e7c 7 * @brief
alexpirciu 1:ceee5a608e7c 8 ******************************************************************************
alexpirciu 1:ceee5a608e7c 9 */
alexpirciu 1:ceee5a608e7c 10 #ifndef CONVERTERS_H
alexpirciu 1:ceee5a608e7c 11 #define CONVERTERS_H
alexpirciu 1:ceee5a608e7c 12
alexpirciu 1:ceee5a608e7c 13 #include<cmath>
alexpirciu 1:ceee5a608e7c 14 #include<stdint.h>
alexpirciu 1:ceee5a608e7c 15 #include<array>
alexpirciu 1:ceee5a608e7c 16
alexpirciu 1:ceee5a608e7c 17 namespace controllers{
alexpirciu 1:ceee5a608e7c 18 /**
alexpirciu 1:ceee5a608e7c 19 * @brief Converter interface with single input and single output
alexpirciu 1:ceee5a608e7c 20 *
alexpirciu 1:ceee5a608e7c 21 */
alexpirciu 1:ceee5a608e7c 22 class IConverter{
alexpirciu 1:ceee5a608e7c 23 public:
alexpirciu 1:ceee5a608e7c 24 virtual float operator()(float) = 0;
alexpirciu 1:ceee5a608e7c 25 };
alexpirciu 1:ceee5a608e7c 26
alexpirciu 1:ceee5a608e7c 27 /**
alexpirciu 1:ceee5a608e7c 28 * @brief Polynomial converter.
alexpirciu 1:ceee5a608e7c 29 *
alexpirciu 1:ceee5a608e7c 30 * @tparam NOrd The degree of the polynomial converter
alexpirciu 1:ceee5a608e7c 31 */
alexpirciu 1:ceee5a608e7c 32 template<uint8_t NOrd>
alexpirciu 1:ceee5a608e7c 33 class CConverterPolynom:public IConverter
alexpirciu 1:ceee5a608e7c 34 {
alexpirciu 1:ceee5a608e7c 35 public:
alexpirciu 1:ceee5a608e7c 36 CConverterPolynom(std::array<float,NOrd+1>);
alexpirciu 1:ceee5a608e7c 37 float operator()(float);
alexpirciu 1:ceee5a608e7c 38
alexpirciu 1:ceee5a608e7c 39 private:
alexpirciu 1:ceee5a608e7c 40 std::array<float,NOrd+1> m_coeff;
alexpirciu 1:ceee5a608e7c 41 };
alexpirciu 1:ceee5a608e7c 42
alexpirciu 1:ceee5a608e7c 43 /**
alexpirciu 1:ceee5a608e7c 44 * @brief A converter based on the set of break point and the multiple polynomial function.
alexpirciu 1:ceee5a608e7c 45 *
alexpirciu 1:ceee5a608e7c 46 * @tparam NrBreak Number of the break.
alexpirciu 1:ceee5a608e7c 47 * @tparam NOrd Degree of the polynomial converter.
alexpirciu 1:ceee5a608e7c 48 */
alexpirciu 1:ceee5a608e7c 49 template<uint8_t NrBreak,uint8_t NOrd>
alexpirciu 1:ceee5a608e7c 50 class CConverterSpline:public IConverter
alexpirciu 1:ceee5a608e7c 51 {
alexpirciu 1:ceee5a608e7c 52 public:
alexpirciu 1:ceee5a608e7c 53 using CCoeffContainerType = std::array<float,NOrd+1>;
alexpirciu 1:ceee5a608e7c 54 using CSplineContainerType = std::array<CCoeffContainerType,NrBreak+1>;
alexpirciu 1:ceee5a608e7c 55 using CBreakContainerType = std::array<float,NrBreak>;
alexpirciu 1:ceee5a608e7c 56
alexpirciu 1:ceee5a608e7c 57
alexpirciu 1:ceee5a608e7c 58 CConverterSpline(CBreakContainerType f_breaks,CSplineContainerType f_splines);
alexpirciu 1:ceee5a608e7c 59 float operator()(float);
alexpirciu 1:ceee5a608e7c 60 private:
alexpirciu 1:ceee5a608e7c 61 float splineValue( CCoeffContainerType,float);
alexpirciu 1:ceee5a608e7c 62
alexpirciu 1:ceee5a608e7c 63 CBreakContainerType m_breaks;
alexpirciu 1:ceee5a608e7c 64 CSplineContainerType m_splines;
alexpirciu 1:ceee5a608e7c 65
alexpirciu 1:ceee5a608e7c 66 };
alexpirciu 1:ceee5a608e7c 67
alexpirciu 1:ceee5a608e7c 68 #include "converters.inl"
alexpirciu 1:ceee5a608e7c 69 }; //namespace controllers
alexpirciu 1:ceee5a608e7c 70
alexpirciu 1:ceee5a608e7c 71
alexpirciu 1:ceee5a608e7c 72
alexpirciu 1:ceee5a608e7c 73 #endif // CONVERTERS_H
alexpirciu 1:ceee5a608e7c 74