blob: 39640cca3f6c5077d1e217aad0c5db14712bae25 [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,
23 const std::string& service, DbusHelperInterface* helper) :
24 ReadInterface(),
25 _bus(bus), _path(path), _service(service), _helper(helper)
Patrick Venturea83a3ec2020-08-04 09:52:05 -070026 {}
Patrick Venture863b9242018-03-08 08:29:23 -080027
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070028 ReadReturn read(void) override;
Patrick Venture863b9242018-03-08 08:29:23 -080029
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070030 private:
31 sdbusplus::bus::bus& _bus;
32 const std::string _path;
33 const std::string _service; // the sensor service.
34 DbusHelperInterface* _helper;
Patrick Venture863b9242018-03-08 08:29:23 -080035};
Patrick Venturea0764872020-08-08 07:48:43 -070036
37} // namespace pid_control