Patrick Venture | aadb30d | 2020-08-10 09:17:11 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | ef1f886 | 2020-08-17 09:34:35 -0700 | [diff] [blame] | 3 | #include <stdexcept> |
Patrick Venture | 84c188f | 2020-08-10 12:39:12 -0700 | [diff] [blame] | 4 | #include <string> |
Patrick Venture | aadb30d | 2020-08-10 09:17:11 -0700 | [diff] [blame] | 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 | |
Patrick Venture | 84c188f | 2020-08-10 12:39:12 -0700 | [diff] [blame] | 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 | |
Patrick Venture | aadb30d | 2020-08-10 09:17:11 -0700 | [diff] [blame] | 31 | } // namespace pid_control |