blob: 8f92cb4a147dfa1a9817bd515126c9ecd91ed619 [file] [log] [blame]
Patrick Venture863b9242018-03-08 08:29:23 -08001#pragma once
2
Patrick Ventureaadb30d2020-08-10 09:17:11 -07003#include "dbushelper_interface.hpp"
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07004#include "interfaces.hpp"
James Feist0c8223b2019-05-08 15:33:33 -07005#include "util.hpp"
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07006
Patrick Venture0df7c0f2018-06-13 09:02:13 -07007#include <sdbusplus/bus.hpp>
Patrick Venturea83a3ec2020-08-04 09:52:05 -07008
9#include <memory>
Patrick Venture863b9242018-03-08 08:29:23 -080010#include <string>
11
Patrick Venturea0764872020-08-08 07:48:43 -070012namespace pid_control
13{
14
Patrick Venture863b9242018-03-08 08:29:23 -080015/*
16 * This ReadInterface will actively reach out over dbus upon calling read to
17 * get the value from whomever owns the associated dbus path.
18 */
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070019class DbusActiveRead : public ReadInterface
Patrick Venture863b9242018-03-08 08:29:23 -080020{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070021 public:
22 DbusActiveRead(sdbusplus::bus::bus& bus, const std::string& path,
Patrick Venture8729eb92020-08-10 10:38:44 -070023 const std::string& service,
24 std::unique_ptr<DbusHelperInterface> helper) :
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070025 ReadInterface(),
Patrick Venture8729eb92020-08-10 10:38:44 -070026 _bus(bus), _path(path), _service(service), _helper(std::move(helper))
Patrick Venturea83a3ec2020-08-04 09:52:05 -070027 {}
Patrick Venture863b9242018-03-08 08:29:23 -080028
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070029 ReadReturn read(void) override;
Patrick Venture863b9242018-03-08 08:29:23 -080030
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070031 private:
32 sdbusplus::bus::bus& _bus;
33 const std::string _path;
34 const std::string _service; // the sensor service.
Patrick Venture8729eb92020-08-10 10:38:44 -070035 std::unique_ptr<DbusHelperInterface> _helper;
Patrick Venture863b9242018-03-08 08:29:23 -080036};
Patrick Venturea0764872020-08-08 07:48:43 -070037
38} // namespace pid_control