Patrick Venture | aadb30d | 2020-08-10 09:17:11 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | b8cfc64 | 2020-10-07 08:30:22 -0700 | [diff] [blame^] | 3 | #include <cstdint> |
| 4 | #include <map> |
Patrick Venture | ef1f886 | 2020-08-17 09:34:35 -0700 | [diff] [blame] | 5 | #include <stdexcept> |
Patrick Venture | 84c188f | 2020-08-10 12:39:12 -0700 | [diff] [blame] | 6 | #include <string> |
Patrick Venture | 1a7c49f | 2020-10-06 15:49:27 -0700 | [diff] [blame] | 7 | #include <unordered_map> |
| 8 | #include <utility> |
| 9 | #include <vector> |
Patrick Venture | aadb30d | 2020-08-10 09:17:11 -0700 | [diff] [blame] | 10 | |
| 11 | namespace pid_control |
| 12 | { |
| 13 | |
| 14 | struct VariantToDoubleVisitor |
| 15 | { |
| 16 | template <typename T> |
| 17 | std::enable_if_t<std::is_arithmetic<T>::value, double> |
| 18 | operator()(const T& t) const |
| 19 | { |
| 20 | return static_cast<double>(t); |
| 21 | } |
| 22 | |
| 23 | template <typename T> |
| 24 | std::enable_if_t<!std::is_arithmetic<T>::value, double> |
| 25 | operator()(const T& t) const |
| 26 | { |
| 27 | throw std::invalid_argument("Cannot translate type to double"); |
| 28 | } |
| 29 | }; |
| 30 | |
Patrick Venture | 84c188f | 2020-08-10 12:39:12 -0700 | [diff] [blame] | 31 | std::string getSensorPath(const std::string& type, const std::string& id); |
| 32 | std::string getMatch(const std::string& type, const std::string& id); |
| 33 | void scaleSensorReading(const double min, const double max, double& value); |
| 34 | bool validType(const std::string& type); |
| 35 | |
Patrick Venture | 1a7c49f | 2020-10-06 15:49:27 -0700 | [diff] [blame] | 36 | bool findSensors(const std::unordered_map<std::string, std::string>& sensors, |
| 37 | const std::string& search, |
| 38 | std::vector<std::pair<std::string, std::string>>& matches); |
| 39 | |
Patrick Venture | b8cfc64 | 2020-10-07 08:30:22 -0700 | [diff] [blame^] | 40 | // Set zone number for a zone, 0-based |
| 41 | int64_t setZoneIndex(const std::string& name, |
| 42 | std::map<std::string, int64_t>& zones, int64_t index); |
| 43 | |
| 44 | // Read zone number for a zone. |
| 45 | int64_t getZoneIndex(const std::string& name, |
| 46 | std::map<std::string, int64_t>& zones); |
| 47 | |
Patrick Venture | aadb30d | 2020-08-10 09:17:11 -0700 | [diff] [blame] | 48 | } // namespace pid_control |