blob: 211c53446026f1026f8bbda48cfd9d7f36899d97 [file] [log] [blame]
Shawn McCarneybc47c1b2020-03-10 15:38:07 -05001/**
2 * Copyright © 2020 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
18#include "action.hpp"
Bob King8a552922020-08-05 17:02:31 +080019#include "services.hpp"
Shawn McCarneybc47c1b2020-03-10 15:38:07 -050020
21#include <memory>
22#include <utility>
23#include <vector>
24
25namespace phosphor::power::regulators
26{
27
Bob King833b8e02020-06-11 14:56:38 +080028// Forward declarations to avoid circular dependencies
29class Chassis;
30class Device;
31class Rail;
32class System;
33
Shawn McCarneybc47c1b2020-03-10 15:38:07 -050034/**
35 * @class SensorMonitoring
36 *
37 * Defines how to read the sensors for a voltage rail, such as voltage output,
38 * current output, and temperature.
39 *
40 * Sensor values are measured, actual values rather than target values.
41 *
42 * Sensors are read once per second. The sensor values are stored on D-Bus,
43 * making them available to external interfaces like Redfish.
44 *
45 * Sensors are read by executing actions, such as PMBusReadSensorAction. To
46 * read multiple sensors for a rail, multiple actions need to be executed.
47 */
48class SensorMonitoring
49{
50 public:
51 // Specify which compiler-generated methods we want
52 SensorMonitoring() = delete;
53 SensorMonitoring(const SensorMonitoring&) = delete;
54 SensorMonitoring(SensorMonitoring&&) = delete;
55 SensorMonitoring& operator=(const SensorMonitoring&) = delete;
56 SensorMonitoring& operator=(SensorMonitoring&&) = delete;
57 ~SensorMonitoring() = default;
58
59 /**
60 * Constructor.
61 *
62 * @param actions actions that read the sensors for a rail
63 */
64 explicit SensorMonitoring(std::vector<std::unique_ptr<Action>> actions) :
65 actions{std::move(actions)}
66 {
67 }
68
69 /**
70 * Executes the actions to read the sensors for a rail.
Bob King833b8e02020-06-11 14:56:38 +080071 *
Bob King8a552922020-08-05 17:02:31 +080072 * @param services system services like error logging and the journal
Bob King833b8e02020-06-11 14:56:38 +080073 * @param system system that contains the chassis
74 * @param chassis chassis that contains the device
75 * @param device device that contains the rail
76 * @param rail rail associated with the sensors
Shawn McCarneybc47c1b2020-03-10 15:38:07 -050077 */
Bob King8a552922020-08-05 17:02:31 +080078 void execute(Services& services, System& system, Chassis& chassis,
79 Device& device, Rail& rail);
Shawn McCarneybc47c1b2020-03-10 15:38:07 -050080
81 /**
82 * Returns the actions that read the sensors for a rail.
83 *
84 * @return actions
85 */
86 const std::vector<std::unique_ptr<Action>>& getActions() const
87 {
88 return actions;
89 }
90
91 private:
92 /**
93 * Actions that read the sensors for a rail.
94 */
95 std::vector<std::unique_ptr<Action>> actions{};
96};
97
98} // namespace phosphor::power::regulators