1 /** 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" 19 20 #include <memory> 21 #include <utility> 22 #include <vector> 23 24 namespace phosphor::power::regulators 25 { 26 27 /** 28 * @class SensorMonitoring 29 * 30 * Defines how to read the sensors for a voltage rail, such as voltage output, 31 * current output, and temperature. 32 * 33 * Sensor values are measured, actual values rather than target values. 34 * 35 * Sensors are read once per second. The sensor values are stored on D-Bus, 36 * making them available to external interfaces like Redfish. 37 * 38 * Sensors are read by executing actions, such as PMBusReadSensorAction. To 39 * read multiple sensors for a rail, multiple actions need to be executed. 40 */ 41 class SensorMonitoring 42 { 43 public: 44 // Specify which compiler-generated methods we want 45 SensorMonitoring() = delete; 46 SensorMonitoring(const SensorMonitoring&) = delete; 47 SensorMonitoring(SensorMonitoring&&) = delete; 48 SensorMonitoring& operator=(const SensorMonitoring&) = delete; 49 SensorMonitoring& operator=(SensorMonitoring&&) = delete; 50 ~SensorMonitoring() = default; 51 52 /** 53 * Constructor. 54 * 55 * @param actions actions that read the sensors for a rail 56 */ 57 explicit SensorMonitoring(std::vector<std::unique_ptr<Action>> actions) : 58 actions{std::move(actions)} 59 { 60 } 61 62 /** 63 * Executes the actions to read the sensors for a rail. 64 */ 65 void execute() 66 { 67 // TODO: Create ActionEnvironment, execute actions, store sensor values 68 // on D-Bus, catch and handle any exceptions 69 } 70 71 /** 72 * Returns the actions that read the sensors for a rail. 73 * 74 * @return actions 75 */ 76 const std::vector<std::unique_ptr<Action>>& getActions() const 77 { 78 return actions; 79 } 80 81 private: 82 /** 83 * Actions that read the sensors for a rail. 84 */ 85 std::vector<std::unique_ptr<Action>> actions{}; 86 }; 87 88 } // namespace phosphor::power::regulators 89