1 #pragma once 2 3 #include <stdexcept> 4 #include <string> 5 6 namespace pid_control 7 { 8 9 struct VariantToDoubleVisitor 10 { 11 template <typename T> 12 std::enable_if_t<std::is_arithmetic<T>::value, double> 13 operator()(const T& t) const 14 { 15 return static_cast<double>(t); 16 } 17 18 template <typename T> 19 std::enable_if_t<!std::is_arithmetic<T>::value, double> 20 operator()(const T& t) const 21 { 22 throw std::invalid_argument("Cannot translate type to double"); 23 } 24 }; 25 26 std::string getSensorPath(const std::string& type, const std::string& id); 27 std::string getMatch(const std::string& type, const std::string& id); 28 void scaleSensorReading(const double min, const double max, double& value); 29 bool validType(const std::string& type); 30 31 } // namespace pid_control 32