Patrick Venture | aadb30d | 2020-08-10 09:17:11 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | aadb30d | 2020-08-10 09:17:11 -0700 | [diff] [blame] | 3 | #include <cstdint> |
| 4 | #include <string> |
| 5 | |
| 6 | namespace pid_control |
| 7 | { |
| 8 | |
| 9 | struct SensorProperties |
| 10 | { |
| 11 | int64_t scale; |
| 12 | double value; |
| 13 | double min; |
| 14 | double max; |
| 15 | std::string unit; |
Alex.Song | 8f73ad7 | 2021-10-07 00:18:27 +0800 | [diff] [blame] | 16 | bool available; |
| 17 | bool unavailableAsFailed; |
Patrick Venture | aadb30d | 2020-08-10 09:17:11 -0700 | [diff] [blame] | 18 | }; |
| 19 | |
| 20 | class DbusHelperInterface |
| 21 | { |
| 22 | public: |
| 23 | virtual ~DbusHelperInterface() = default; |
| 24 | |
| 25 | /** @brief Get the service providing the interface for the path. |
| 26 | * |
| 27 | * @warning Throws exception on dbus failure. |
| 28 | */ |
Patrick Venture | 9b93692 | 2020-08-10 11:28:39 -0700 | [diff] [blame] | 29 | virtual std::string getService(const std::string& intf, |
Patrick Venture | aadb30d | 2020-08-10 09:17:11 -0700 | [diff] [blame] | 30 | const std::string& path) = 0; |
| 31 | |
| 32 | /** @brief Get all Sensor.Value properties for a service and path. |
| 33 | * |
| 34 | * @param[in] bus - A bus to use for the call. |
| 35 | * @param[in] service - The service providing the interface. |
| 36 | * @param[in] path - The dbus path. |
Patrick Venture | 1df9e87 | 2020-10-08 15:35:01 -0700 | [diff] [blame] | 37 | * @param[out] prop - A pointer to a properties to fill out. |
Patrick Venture | aadb30d | 2020-08-10 09:17:11 -0700 | [diff] [blame] | 38 | * |
| 39 | * @warning Throws exception on dbus failure. |
| 40 | */ |
Patrick Venture | 9b93692 | 2020-08-10 11:28:39 -0700 | [diff] [blame] | 41 | virtual void getProperties(const std::string& service, |
Patrick Venture | aadb30d | 2020-08-10 09:17:11 -0700 | [diff] [blame] | 42 | const std::string& path, |
Patrick Venture | 1df9e87 | 2020-10-08 15:35:01 -0700 | [diff] [blame] | 43 | SensorProperties* prop) = 0; |
Patrick Venture | aadb30d | 2020-08-10 09:17:11 -0700 | [diff] [blame] | 44 | |
| 45 | /** @brief Get Critical Threshold current assert status |
| 46 | * |
| 47 | * @param[in] bus - A bus to use for the call. |
| 48 | * @param[in] service - The service providing the interface. |
| 49 | * @param[in] path - The dbus path. |
| 50 | */ |
Patrick Venture | 9b93692 | 2020-08-10 11:28:39 -0700 | [diff] [blame] | 51 | virtual bool thresholdsAsserted(const std::string& service, |
Patrick Venture | aadb30d | 2020-08-10 09:17:11 -0700 | [diff] [blame] | 52 | const std::string& path) = 0; |
| 53 | }; |
| 54 | |
| 55 | } // namespace pid_control |