blob: 424902447764306fc69c7dbaf57ea01148c2c9f0 [file] [log] [blame]
Brandon Wyman24e422f2017-07-25 19:40:14 -05001#pragma once
Brandon Wyman1db9a9e2017-07-26 18:50:22 -05002#include "device.hpp"
Brandon Wyman24e422f2017-07-25 19:40:14 -05003
Brandon Wyman1db9a9e2017-07-26 18:50:22 -05004namespace witherspoon
Brandon Wyman24e422f2017-07-25 19:40:14 -05005{
6namespace power
7{
8namespace psu
9{
10
11/**
12 * @class PowerSupply
Brandon Wyman1db9a9e2017-07-26 18:50:22 -050013 * Represents a PMBus power supply device.
Brandon Wyman24e422f2017-07-25 19:40:14 -050014 */
Brandon Wyman1db9a9e2017-07-26 18:50:22 -050015class PowerSupply : public Device
Brandon Wyman24e422f2017-07-25 19:40:14 -050016{
17 public:
18 PowerSupply() = delete;
19 PowerSupply(const PowerSupply&) = delete;
Brandon Wyman24e422f2017-07-25 19:40:14 -050020 PowerSupply(PowerSupply&&) = default;
Brandon Wyman1db9a9e2017-07-26 18:50:22 -050021 PowerSupply& operator=(const PowerSupply&) = default;
Brandon Wyman24e422f2017-07-25 19:40:14 -050022 PowerSupply& operator=(PowerSupply&&) = default;
23 ~PowerSupply() = default;
24
Brandon Wyman1db9a9e2017-07-26 18:50:22 -050025 /**
26 * Constructor
27 *
28 * @param[in] name - the device name
29 * @param[in] inst - the device instance
30 * @param[in] objpath - the path to monitor
31 * @param[in] invpath - the inventory path to use
32 */
33 PowerSupply(const std::string& name, size_t inst,
34 const std::string& objpath, const std::string& invpath)
35 : Device(name, inst), monitorPath(objpath), inventoryPath(invpath)
36 {
37 }
38
39 /**
40 * Power supply specific function to analyze for faults/errors.
41 *
42 * Various PMBus status bits will be checked for fault conditions.
43 * If a certain fault bits are on, the appropriate error will be
44 * committed.
45 */
46 void analyze() override;
47
48 /**
49 * Write PMBus CLEAR_FAULTS
50 *
51 * This function will be called in various situations in order to clear
52 * any fault status bits that may have been set, in order to start over
53 * with a clean state. Presence changes and power state changes will
54 * want to clear any faults logged.
55 */
56 void clearFaults() override;
57
58 private:
59 /**
60 * The path to use for reading various PMBus bits/words.
61 */
62 std::string monitorPath;
63
64 /**
65 * The D-Bus path to use for this power supply's inventory status.
66 */
67 std::string inventoryPath;
Brandon Wyman24e422f2017-07-25 19:40:14 -050068};
69
70}
71}
72}