blob: 615cb3741c9096d701b2a23465a1695ead12774b [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
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07006#include <string>
Patrick Venture863b9242018-03-08 08:29:23 -08007
Patrick Venturea0764872020-08-08 07:48:43 -07008namespace pid_control
9{
10
Patrick Venture863b9242018-03-08 08:29:23 -080011/*
12 * A WriteInterface that is expecting a path that's sysfs, but really could be
13 * any filesystem path.
14 */
15class SysFsWritePercent : public WriteInterface
16{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070017 public:
Patrick Venturea1c5d372019-02-11 10:03:35 -080018 SysFsWritePercent(const std::string& writePath, int64_t min, int64_t max) :
19 WriteInterface(min, max), _writePath(FixupPath(writePath))
Patrick Venturea83a3ec2020-08-04 09:52:05 -070020 {}
Patrick Venture863b9242018-03-08 08:29:23 -080021
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070022 void write(double value) override;
Patrick Venture863b9242018-03-08 08:29:23 -080023
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070024 private:
Patrick Venturea1c5d372019-02-11 10:03:35 -080025 std::string _writePath;
Patrick Venture863b9242018-03-08 08:29:23 -080026};
27
28class SysFsWrite : public WriteInterface
29{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070030 public:
Patrick Venturea1c5d372019-02-11 10:03:35 -080031 SysFsWrite(const std::string& writePath, int64_t min, int64_t max) :
32 WriteInterface(min, max), _writePath(FixupPath(writePath))
Patrick Venturea83a3ec2020-08-04 09:52:05 -070033 {}
Patrick Venture863b9242018-03-08 08:29:23 -080034
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070035 void write(double value) override;
Patrick Venture863b9242018-03-08 08:29:23 -080036
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070037 private:
Patrick Venturea1c5d372019-02-11 10:03:35 -080038 std::string _writePath;
Patrick Venture863b9242018-03-08 08:29:23 -080039};
Patrick Venturea0764872020-08-08 07:48:43 -070040
41} // namespace pid_control