1aadb30ddSPatrick Venture #pragma once 2aadb30ddSPatrick Venture 3b8cfc642SPatrick Venture #include <cstdint> 4b8cfc642SPatrick Venture #include <map> 5ef1f8864SPatrick Venture #include <stdexcept> 684c188feSPatrick Venture #include <string> 71a7c49f9SPatrick Venture #include <unordered_map> 81a7c49f9SPatrick Venture #include <utility> 91a7c49f9SPatrick Venture #include <vector> 10aadb30ddSPatrick Venture 11aadb30ddSPatrick Venture namespace pid_control 12aadb30ddSPatrick Venture { 13aadb30ddSPatrick Venture 14aadb30ddSPatrick Venture struct VariantToDoubleVisitor 15aadb30ddSPatrick Venture { 16aadb30ddSPatrick Venture template <typename T> 17aadb30ddSPatrick Venture std::enable_if_t<std::is_arithmetic<T>::value, double> operator ()pid_control::VariantToDoubleVisitor18aadb30ddSPatrick Venture operator()(const T& t) const 19aadb30ddSPatrick Venture { 20aadb30ddSPatrick Venture return static_cast<double>(t); 21aadb30ddSPatrick Venture } 22aadb30ddSPatrick Venture 23aadb30ddSPatrick Venture template <typename T> 24aadb30ddSPatrick Venture std::enable_if_t<!std::is_arithmetic<T>::value, double> operator ()pid_control::VariantToDoubleVisitor25*a1ae4fa1SHarvey.Wu operator()([[maybe_unused]] const T& t) const 26aadb30ddSPatrick Venture { 27aadb30ddSPatrick Venture throw std::invalid_argument("Cannot translate type to double"); 28aadb30ddSPatrick Venture } 29aadb30ddSPatrick Venture }; 30aadb30ddSPatrick Venture 3184c188feSPatrick Venture std::string getSensorPath(const std::string& type, const std::string& id); 32f2efcbbdSHarvey.Wu std::string getMatch(const std::string& path); 3384c188feSPatrick Venture void scaleSensorReading(const double min, const double max, double& value); 3484c188feSPatrick Venture bool validType(const std::string& type); 3584c188feSPatrick Venture 361a7c49f9SPatrick Venture bool findSensors(const std::unordered_map<std::string, std::string>& sensors, 371a7c49f9SPatrick Venture const std::string& search, 381a7c49f9SPatrick Venture std::vector<std::pair<std::string, std::string>>& matches); 391a7c49f9SPatrick Venture 40b8cfc642SPatrick Venture // Set zone number for a zone, 0-based 41b8cfc642SPatrick Venture int64_t setZoneIndex(const std::string& name, 42b8cfc642SPatrick Venture std::map<std::string, int64_t>& zones, int64_t index); 43b8cfc642SPatrick Venture 44b8cfc642SPatrick Venture // Read zone number for a zone. 45b8cfc642SPatrick Venture int64_t getZoneIndex(const std::string& name, 46b8cfc642SPatrick Venture std::map<std::string, int64_t>& zones); 47b8cfc642SPatrick Venture 48aadb30ddSPatrick Venture } // namespace pid_control 49