Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 1 | #pragma once |
2 | |||||
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 3 | #include "interfaces.hpp" |
James Feist | 0c8223b | 2019-05-08 15:33:33 -0700 | [diff] [blame] | 4 | #include "util.hpp" |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 5 | |
Ed Tanous | f8b6e55 | 2025-06-27 13:27:50 -0700 | [diff] [blame^] | 6 | #include <cstdint> |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 7 | #include <string> |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 8 | |
Patrick Venture | a076487 | 2020-08-08 07:48:43 -0700 | [diff] [blame] | 9 | namespace pid_control |
10 | { | ||||
11 | |||||
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 12 | /* |
13 | * A WriteInterface that is expecting a path that's sysfs, but really could be | ||||
14 | * any filesystem path. | ||||
15 | */ | ||||
16 | class SysFsWritePercent : public WriteInterface | ||||
17 | { | ||||
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 18 | public: |
Patrick Venture | a1c5d37 | 2019-02-11 10:03:35 -0800 | [diff] [blame] | 19 | SysFsWritePercent(const std::string& writePath, int64_t min, int64_t max) : |
20 | WriteInterface(min, max), _writePath(FixupPath(writePath)) | ||||
Patrick Venture | a83a3ec | 2020-08-04 09:52:05 -0700 | [diff] [blame] | 21 | {} |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 22 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 23 | void write(double value) override; |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 24 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 25 | private: |
Patrick Venture | a1c5d37 | 2019-02-11 10:03:35 -0800 | [diff] [blame] | 26 | std::string _writePath; |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 27 | }; |
28 | |||||
29 | class SysFsWrite : public WriteInterface | ||||
30 | { | ||||
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 31 | public: |
Patrick Venture | a1c5d37 | 2019-02-11 10:03:35 -0800 | [diff] [blame] | 32 | SysFsWrite(const std::string& writePath, int64_t min, int64_t max) : |
33 | WriteInterface(min, max), _writePath(FixupPath(writePath)) | ||||
Patrick Venture | a83a3ec | 2020-08-04 09:52:05 -0700 | [diff] [blame] | 34 | {} |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 35 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 36 | void write(double value) override; |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 37 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 38 | private: |
Patrick Venture | a1c5d37 | 2019-02-11 10:03:35 -0800 | [diff] [blame] | 39 | std::string _writePath; |
Patrick Venture | 863b924 | 2018-03-08 08:29:23 -0800 | [diff] [blame] | 40 | }; |
Patrick Venture | a076487 | 2020-08-08 07:48:43 -0700 | [diff] [blame] | 41 | |
42 | } // namespace pid_control |