blob: adf091d7e83115f55fa39cbe5e8a757c6f979673 [file] [log] [blame]
Patrick Venture863b9242018-03-08 08:29:23 -08001#pragma once
2
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07003#include "interfaces.hpp"
James Feist0c8223b2019-05-08 15:33:33 -07004#include "util.hpp"
Patrick Ventureda4a5dd2018-08-31 09:42:48 -07005
Patrick Venture0df7c0f2018-06-13 09:02:13 -07006#include <sdbusplus/bus.hpp>
Patrick Venturea83a3ec2020-08-04 09:52:05 -07007
8#include <memory>
Patrick Venture863b9242018-03-08 08:29:23 -08009#include <string>
10
Patrick Venturea0764872020-08-08 07:48:43 -070011namespace pid_control
12{
13
Patrick Venture863b9242018-03-08 08:29:23 -080014/*
15 * This ReadInterface will actively reach out over dbus upon calling read to
16 * get the value from whomever owns the associated dbus path.
17 */
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070018class DbusActiveRead : public ReadInterface
Patrick Venture863b9242018-03-08 08:29:23 -080019{
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070020 public:
21 DbusActiveRead(sdbusplus::bus::bus& bus, const std::string& path,
22 const std::string& service, DbusHelperInterface* helper) :
23 ReadInterface(),
24 _bus(bus), _path(path), _service(service), _helper(helper)
Patrick Venturea83a3ec2020-08-04 09:52:05 -070025 {}
Patrick Venture863b9242018-03-08 08:29:23 -080026
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070027 ReadReturn read(void) override;
Patrick Venture863b9242018-03-08 08:29:23 -080028
Patrick Ventureda4a5dd2018-08-31 09:42:48 -070029 private:
30 sdbusplus::bus::bus& _bus;
31 const std::string _path;
32 const std::string _service; // the sensor service.
33 DbusHelperInterface* _helper;
Patrick Venture863b9242018-03-08 08:29:23 -080034};
Patrick Venturea0764872020-08-08 07:48:43 -070035
36} // namespace pid_control