Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 3 | #include "interfaces/json_storage.hpp" |
Wludzik, Jozef | 1477fe6 | 2021-01-02 11:56:10 +0100 | [diff] [blame] | 4 | #include "interfaces/threshold.hpp" |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 5 | #include "interfaces/trigger.hpp" |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 6 | #include "interfaces/trigger_factory.hpp" |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 7 | #include "interfaces/trigger_manager.hpp" |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 8 | #include "types/trigger_types.hpp" |
Krzysztof Grobelny | e6d4887 | 2022-02-08 13:41:30 +0100 | [diff] [blame] | 9 | #include "utils/messanger.hpp" |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 10 | |
| 11 | #include <boost/asio/io_context.hpp> |
| 12 | #include <sdbusplus/asio/object_server.hpp> |
Szymon Dompke | 1cdd7e4 | 2022-06-08 14:43:13 +0200 | [diff] [blame] | 13 | #include <sdbusplus/message.hpp> |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 14 | |
| 15 | #include <memory> |
| 16 | |
| 17 | class Trigger : public interfaces::Trigger |
| 18 | { |
| 19 | public: |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 20 | Trigger(boost::asio::io_context& ioc, |
| 21 | const std::shared_ptr<sdbusplus::asio::object_server>& objServer, |
Szymon Dompke | b7b7e1b | 2022-05-19 10:15:48 +0200 | [diff] [blame] | 22 | TriggerId&& id, const std::string& name, |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 23 | const std::vector<TriggerAction>& triggerActions, |
| 24 | const std::shared_ptr<std::vector<std::string>> reportIds, |
Cezary Zwolak | 4416fce | 2021-03-17 03:21:06 +0100 | [diff] [blame] | 25 | std::vector<std::shared_ptr<interfaces::Threshold>>&& thresholds, |
| 26 | interfaces::TriggerManager& triggerManager, |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 27 | interfaces::JsonStorage& triggerStorage, |
Krzysztof Grobelny | e6d4887 | 2022-02-08 13:41:30 +0100 | [diff] [blame] | 28 | const interfaces::TriggerFactory& triggerFactory, |
| 29 | Sensors sensorsIn); |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 30 | |
| 31 | Trigger(const Trigger&) = delete; |
| 32 | Trigger(Trigger&&) = delete; |
| 33 | Trigger& operator=(const Trigger&) = delete; |
| 34 | Trigger& operator=(Trigger&&) = delete; |
| 35 | |
Szymon Dompke | e28aa53 | 2021-10-27 12:33:12 +0200 | [diff] [blame] | 36 | std::string getId() const override |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 37 | { |
Szymon Dompke | b7b7e1b | 2022-05-19 10:15:48 +0200 | [diff] [blame] | 38 | return *id; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | std::string getPath() const override |
| 42 | { |
Szymon Dompke | 1cdd7e4 | 2022-06-08 14:43:13 +0200 | [diff] [blame] | 43 | return path.str; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 44 | } |
| 45 | |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 46 | bool storeConfiguration() const; |
| 47 | |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 48 | private: |
Krzysztof Grobelny | 5582455 | 2022-02-18 16:15:31 +0100 | [diff] [blame] | 49 | std::vector<LabeledSensorInfo> getLabeledSensorInfo() const; |
| 50 | std::vector<LabeledThresholdParam> getLabeledThresholds() const; |
| 51 | bool isDiscreate() const; |
| 52 | |
Szymon Dompke | b7b7e1b | 2022-05-19 10:15:48 +0200 | [diff] [blame] | 53 | const TriggerId id; |
Szymon Dompke | 1cdd7e4 | 2022-06-08 14:43:13 +0200 | [diff] [blame] | 54 | const sdbusplus::message::object_path path; |
Szymon Dompke | e28aa53 | 2021-10-27 12:33:12 +0200 | [diff] [blame] | 55 | std::string name; |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 56 | std::vector<TriggerAction> triggerActions; |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 57 | bool persistent = false; |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 58 | std::shared_ptr<std::vector<std::string>> reportIds; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 59 | std::unique_ptr<sdbusplus::asio::dbus_interface> deleteIface; |
| 60 | std::unique_ptr<sdbusplus::asio::dbus_interface> triggerIface; |
Wludzik, Jozef | 1477fe6 | 2021-01-02 11:56:10 +0100 | [diff] [blame] | 61 | std::vector<std::shared_ptr<interfaces::Threshold>> thresholds; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 62 | |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 63 | interfaces::JsonStorage::FilePath fileName; |
| 64 | interfaces::JsonStorage& triggerStorage; |
Szymon Dompke | 94f71c5 | 2021-12-10 07:16:33 +0100 | [diff] [blame] | 65 | Sensors sensors; |
Krzysztof Grobelny | e6d4887 | 2022-02-08 13:41:30 +0100 | [diff] [blame] | 66 | utils::Messanger messanger; |
Cezary Zwolak | a4e6761 | 2021-02-18 13:16:16 +0100 | [diff] [blame] | 67 | |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 68 | public: |
| 69 | static constexpr const char* triggerIfaceName = |
| 70 | "xyz.openbmc_project.Telemetry.Trigger"; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 71 | static constexpr const char* deleteIfaceName = |
| 72 | "xyz.openbmc_project.Object.Delete"; |
Szymon Dompke | b7b7e1b | 2022-05-19 10:15:48 +0200 | [diff] [blame] | 73 | static constexpr size_t triggerVersion = 2; |
Wludzik, Jozef | 76833cb | 2020-12-21 14:42:41 +0100 | [diff] [blame] | 74 | }; |