blob: ed095bb2a1212ddce6a7547f989944bb86304d86 [file] [log] [blame]
Jim Wright7945dd22021-04-06 16:55:15 -05001#pragma once
2
Jim Wright930458c2022-01-24 14:37:27 -06003#include <sdbusplus/bus.hpp>
4
5#include <map>
6#include <string>
7
Jim Wright7945dd22021-04-06 16:55:15 -05008namespace phosphor::power::sequencer
9{
10
11/**
12 * @class PowerSequencerMonitor
13 * Define a base class for monitoring a power sequencer device.
14 */
15class PowerSequencerMonitor
16{
17 public:
Jim Wright930458c2022-01-24 14:37:27 -060018 PowerSequencerMonitor() = delete;
Jim Wright7945dd22021-04-06 16:55:15 -050019 PowerSequencerMonitor(const PowerSequencerMonitor&) = delete;
20 PowerSequencerMonitor& operator=(const PowerSequencerMonitor&) = delete;
21 PowerSequencerMonitor(PowerSequencerMonitor&&) = delete;
22 PowerSequencerMonitor& operator=(PowerSequencerMonitor&&) = delete;
23 virtual ~PowerSequencerMonitor() = default;
Jim Wright930458c2022-01-24 14:37:27 -060024
25 /**
26 * Create a base device object for power sequence monitoring.
Jim Wright213ffe92022-06-03 08:54:30 -050027 * @param bus D-Bus bus object
Jim Wright930458c2022-01-24 14:37:27 -060028 */
Patrick Williams7354ce62022-07-22 19:26:56 -050029 explicit PowerSequencerMonitor(sdbusplus::bus_t& bus);
Jim Wright930458c2022-01-24 14:37:27 -060030
31 /**
32 * Logs an error using the D-Bus Create method.
Jim Wright213ffe92022-06-03 08:54:30 -050033 * @param message Message property of the error log entry
34 * @param additionalData AdditionalData property of the error log entry
Jim Wright930458c2022-01-24 14:37:27 -060035 */
36 void logError(const std::string& message,
37 std::map<std::string, std::string>& additionalData);
38
39 /**
40 * Analyzes the device for errors when the device is
41 * known to be in an error state. A log will be created.
Jim Wright213ffe92022-06-03 08:54:30 -050042 * @param timeout if the failure state was determined by timing out
43 * @param powerSupplyError The power supply error to log. A default
Jim Wright71a14132022-01-28 09:46:46 -060044 * std:string, i.e. empty string (""), is passed when there is no power
Jim Wright930458c2022-01-24 14:37:27 -060045 * supply error to log.
46 */
47 virtual void onFailure(bool timeout, const std::string& powerSupplyError);
48
49 protected:
50 /**
51 * The D-Bus bus object
52 */
Patrick Williams7354ce62022-07-22 19:26:56 -050053 sdbusplus::bus_t& bus;
Jim Wright213ffe92022-06-03 08:54:30 -050054
55 /*
56 * Create a BMC Dump
57 */
58 void createBmcDump();
Jim Wright7945dd22021-04-06 16:55:15 -050059};
60
61} // namespace phosphor::power::sequencer