Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame^] | 3 | #include "interfaces/metric.hpp" |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 4 | #include "interfaces/report.hpp" |
| 5 | #include "interfaces/report_manager.hpp" |
| 6 | #include "interfaces/types.hpp" |
| 7 | |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 8 | #include <boost/asio/io_context.hpp> |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame^] | 9 | #include <boost/asio/steady_timer.hpp> |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 10 | #include <sdbusplus/asio/object_server.hpp> |
| 11 | |
| 12 | #include <chrono> |
| 13 | #include <memory> |
| 14 | |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 15 | class Report : public interfaces::Report |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 16 | { |
| 17 | public: |
| 18 | Report(boost::asio::io_context& ioc, |
| 19 | const std::shared_ptr<sdbusplus::asio::object_server>& objServer, |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 20 | const std::string& reportName, const std::string& reportingType, |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 21 | const bool emitsReadingsSignal, |
| 22 | const bool logToMetricReportsCollection, |
| 23 | const std::chrono::milliseconds period, |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 24 | const ReadingParameters& metricParams, |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame^] | 25 | interfaces::ReportManager& reportManager, |
| 26 | std::vector<std::shared_ptr<interfaces::Metric>> metrics); |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 27 | ~Report() = default; |
| 28 | |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame^] | 29 | Report(const Report&) = delete; |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 30 | Report(Report&&) = delete; |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame^] | 31 | Report& operator=(const Report&) = delete; |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 32 | Report& operator=(Report&&) = delete; |
| 33 | |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 34 | std::string getName() const override |
| 35 | { |
| 36 | return name; |
| 37 | } |
| 38 | |
| 39 | std::string getPath() const override |
| 40 | { |
| 41 | return path; |
| 42 | } |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 43 | |
| 44 | private: |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame^] | 45 | static void timerProc(boost::system::error_code, Report& self); |
| 46 | void scheduleTimer(std::chrono::milliseconds interval); |
| 47 | void updateReadings(); |
| 48 | |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 49 | const std::string name; |
| 50 | const std::string path; |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 51 | std::chrono::milliseconds interval; |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame^] | 52 | Readings readings = {}; |
| 53 | std::tuple_element_t<1, Readings> readingsCache = {}; |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 54 | std::shared_ptr<sdbusplus::asio::object_server> objServer; |
| 55 | std::unique_ptr<sdbusplus::asio::dbus_interface> reportIface; |
| 56 | std::unique_ptr<sdbusplus::asio::dbus_interface> deleteIface; |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame^] | 57 | std::vector<std::shared_ptr<interfaces::Metric>> metrics; |
| 58 | boost::asio::steady_timer timer; |
Wludzik, Jozef | 2f9f9b8 | 2020-10-13 09:07:45 +0200 | [diff] [blame] | 59 | |
| 60 | public: |
| 61 | static constexpr const char* reportIfaceName = |
| 62 | "xyz.openbmc_project.Telemetry.Report"; |
| 63 | static constexpr const char* reportDir = |
| 64 | "/xyz/openbmc_project/Telemetry/Reports/"; |
| 65 | static constexpr const char* deleteIfaceName = |
| 66 | "xyz.openbmc_project.Object.Delete"; |
Wludzik, Jozef | cb88cfd | 2020-09-28 16:38:57 +0200 | [diff] [blame] | 67 | }; |