blob: d24dca43a5c6f9d61a6118d34f4b8cf26e9304b5 [file] [log] [blame]
Patrick Venture863b9242018-03-08 08:29:23 -08001#pragma once
2
Patrick Venture863b9242018-03-08 08:29:23 -08003#include "interfaces.hpp"
James Feist0c8223b2019-05-08 15:33:33 -07004#include "util.hpp"
Patrick Venture863b9242018-03-08 08:29:23 -08005
Ed Tanousf8b6e552025-06-27 13:27:50 -07006#include <cstdint>
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07007#include <string>
Patrick Venture863b9242018-03-08 08:29:23 -08008
Patrick Venturea0764872020-08-08 07:48:43 -07009namespace pid_control
10{
11
Patrick Venture863b9242018-03-08 08:29:23 -080012/*
13 * A WriteInterface that is expecting a path that's sysfs, but really could be
14 * any filesystem path.
15 */
16class SysFsWritePercent : public WriteInterface
17{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070018 public:
Patrick Venturea1c5d372019-02-11 10:03:35 -080019 SysFsWritePercent(const std::string& writePath, int64_t min, int64_t max) :
20 WriteInterface(min, max), _writePath(FixupPath(writePath))
Patrick Venturea83a3ec2020-08-04 09:52:05 -070021 {}
Patrick Venture863b9242018-03-08 08:29:23 -080022
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070023 void write(double value) override;
Patrick Venture863b9242018-03-08 08:29:23 -080024
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070025 private:
Patrick Venturea1c5d372019-02-11 10:03:35 -080026 std::string _writePath;
Patrick Venture863b9242018-03-08 08:29:23 -080027};
28
29class SysFsWrite : public WriteInterface
30{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070031 public:
Patrick Venturea1c5d372019-02-11 10:03:35 -080032 SysFsWrite(const std::string& writePath, int64_t min, int64_t max) :
33 WriteInterface(min, max), _writePath(FixupPath(writePath))
Patrick Venturea83a3ec2020-08-04 09:52:05 -070034 {}
Patrick Venture863b9242018-03-08 08:29:23 -080035
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070036 void write(double value) override;
Patrick Venture863b9242018-03-08 08:29:23 -080037
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070038 private:
Patrick Venturea1c5d372019-02-11 10:03:35 -080039 std::string _writePath;
Patrick Venture863b9242018-03-08 08:29:23 -080040};
Patrick Venturea0764872020-08-08 07:48:43 -070041
42} // namespace pid_control