176833cb5SWludzik, Jozef #pragma once
276833cb5SWludzik, Jozef 
31cdd7e4fSSzymon Dompke #include "report.hpp"
451f0fd50SKrzysztof Grobelny #include "types/duration_types.hpp"
5dcc4e193SKrzysztof Grobelny #include "types/trigger_types.hpp"
61cdd7e4fSSzymon Dompke #include "utils/dbus_path_utils.hpp"
71cdd7e4fSSzymon Dompke #include "utils/transform.hpp"
876833cb5SWludzik, Jozef 
9e8fc5751SKrzysztof Grobelny #include <sdbusplus/message.hpp>
10e8fc5751SKrzysztof Grobelny 
111477fe6aSWludzik, Jozef #include <chrono>
1276833cb5SWludzik, Jozef #include <utility>
1376833cb5SWludzik, Jozef 
141cdd7e4fSSzymon Dompke using sdbusplus::message::object_path;
151cdd7e4fSSzymon Dompke 
1676833cb5SWludzik, Jozef class TriggerParams
1776833cb5SWludzik, Jozef {
1876833cb5SWludzik, Jozef   public:
191cdd7e4fSSzymon Dompke     TriggerParams()
201cdd7e4fSSzymon Dompke     {
211cdd7e4fSSzymon Dompke         reportsProperty =
221cdd7e4fSSzymon Dompke             utils::transform(reportIdsProperty, [](const auto& id) {
231cdd7e4fSSzymon Dompke                 return utils::pathAppend(utils::constants::reportDirPath, id);
241cdd7e4fSSzymon Dompke             });
251cdd7e4fSSzymon Dompke     }
261cdd7e4fSSzymon Dompke 
27*32305f14SSzymon Dompke     TriggerParams& id(std::string_view val)
28e28aa53dSSzymon Dompke     {
29*32305f14SSzymon Dompke         idProperty = val;
30e28aa53dSSzymon Dompke         return *this;
31e28aa53dSSzymon Dompke     }
32e28aa53dSSzymon Dompke 
33e28aa53dSSzymon Dompke     const std::string& id() const
34e28aa53dSSzymon Dompke     {
35e28aa53dSSzymon Dompke         return idProperty;
36e28aa53dSSzymon Dompke     }
37e28aa53dSSzymon Dompke 
38*32305f14SSzymon Dompke     TriggerParams& name(std::string_view val)
3976833cb5SWludzik, Jozef     {
40*32305f14SSzymon Dompke         nameProperty = val;
4176833cb5SWludzik, Jozef         return *this;
4276833cb5SWludzik, Jozef     }
4376833cb5SWludzik, Jozef 
4476833cb5SWludzik, Jozef     const std::string& name() const
4576833cb5SWludzik, Jozef     {
4676833cb5SWludzik, Jozef         return nameProperty;
4776833cb5SWludzik, Jozef     }
4876833cb5SWludzik, Jozef 
4994f71c51SSzymon Dompke     TriggerParams& triggerActions(const std::vector<TriggerAction>& val)
50f763c9e3SSzymon Dompke     {
512001301aSSzymon Dompke         triggerActionsProperty = val;
52f763c9e3SSzymon Dompke         return *this;
53f763c9e3SSzymon Dompke     }
54f763c9e3SSzymon Dompke 
5594f71c51SSzymon Dompke     const std::vector<TriggerAction>& triggerActions() const
5676833cb5SWludzik, Jozef     {
572001301aSSzymon Dompke         return triggerActionsProperty;
5876833cb5SWludzik, Jozef     }
5976833cb5SWludzik, Jozef 
604416fce6SCezary Zwolak     const std::vector<LabeledSensorInfo>& sensors() const
6176833cb5SWludzik, Jozef     {
624416fce6SCezary Zwolak         return labeledSensorsProperty;
6376833cb5SWludzik, Jozef     }
6476833cb5SWludzik, Jozef 
65b8cc78ddSKrzysztof Grobelny     const std::vector<std::string>& reportIds() const
6676833cb5SWludzik, Jozef     {
67b8cc78ddSKrzysztof Grobelny         return reportIdsProperty;
6876833cb5SWludzik, Jozef     }
6976833cb5SWludzik, Jozef 
70b4ef22e4SSzymon Dompke     TriggerParams& reportIds(std::vector<std::string> val)
71b4ef22e4SSzymon Dompke     {
72b4ef22e4SSzymon Dompke         reportIdsProperty = std::move(val);
731cdd7e4fSSzymon Dompke         reportsProperty = utils::transform<std::vector>(
741cdd7e4fSSzymon Dompke             reportIdsProperty, [](const auto& id) {
751cdd7e4fSSzymon Dompke                 return utils::pathAppend(utils::constants::reportDirPath, id);
761cdd7e4fSSzymon Dompke             });
771cdd7e4fSSzymon Dompke         return *this;
781cdd7e4fSSzymon Dompke     }
791cdd7e4fSSzymon Dompke 
801cdd7e4fSSzymon Dompke     const std::vector<object_path>& reports() const
811cdd7e4fSSzymon Dompke     {
821cdd7e4fSSzymon Dompke         return reportsProperty;
831cdd7e4fSSzymon Dompke     }
841cdd7e4fSSzymon Dompke 
851cdd7e4fSSzymon Dompke     TriggerParams& reports(std::vector<object_path> val)
861cdd7e4fSSzymon Dompke     {
871cdd7e4fSSzymon Dompke         reportsProperty = std::move(val);
88b4ef22e4SSzymon Dompke         return *this;
89b4ef22e4SSzymon Dompke     }
90b4ef22e4SSzymon Dompke 
914416fce6SCezary Zwolak     TriggerParams& thresholdParams(LabeledTriggerThresholdParams val)
92f763c9e3SSzymon Dompke     {
934416fce6SCezary Zwolak         labeledThresholdsProperty = std::move(val);
94f763c9e3SSzymon Dompke         return *this;
95f763c9e3SSzymon Dompke     }
96f763c9e3SSzymon Dompke 
974416fce6SCezary Zwolak     const LabeledTriggerThresholdParams& thresholdParams() const
9876833cb5SWludzik, Jozef     {
994416fce6SCezary Zwolak         return labeledThresholdsProperty;
10076833cb5SWludzik, Jozef     }
10176833cb5SWludzik, Jozef 
10276833cb5SWludzik, Jozef   private:
103e28aa53dSSzymon Dompke     std::string idProperty = "Trigger1";
104e28aa53dSSzymon Dompke     std::string nameProperty = "My Numeric Trigger";
10594f71c51SSzymon Dompke     std::vector<TriggerAction> triggerActionsProperty = {
10694f71c51SSzymon Dompke         TriggerAction::UpdateReport};
1074416fce6SCezary Zwolak     std::vector<LabeledSensorInfo> labeledSensorsProperty = {
1084416fce6SCezary Zwolak         {"service1", "/xyz/openbmc_project/sensors/temperature/BMC_Temp",
1094416fce6SCezary Zwolak          "metadata1"}};
1101cdd7e4fSSzymon Dompke     std::vector<std::string> reportIdsProperty = {"Report1",
1111cdd7e4fSSzymon Dompke                                                   "Prefixed/Report2"};
1121cdd7e4fSSzymon Dompke     std::vector<object_path> reportsProperty;
1134416fce6SCezary Zwolak     LabeledTriggerThresholdParams labeledThresholdsProperty =
1144416fce6SCezary Zwolak         std::vector<numeric::LabeledThresholdParam>{
115dcc4e193SKrzysztof Grobelny             numeric::LabeledThresholdParam{numeric::Type::lowerCritical,
116dcc4e193SKrzysztof Grobelny                                            Milliseconds(10).count(),
1174416fce6SCezary Zwolak                                            numeric::Direction::decreasing, 0.5},
1184416fce6SCezary Zwolak             numeric::LabeledThresholdParam{
119dcc4e193SKrzysztof Grobelny                 numeric::Type::upperCritical, Milliseconds(10).count(),
1204416fce6SCezary Zwolak                 numeric::Direction::increasing, 90.2}};
12176833cb5SWludzik, Jozef };
122