blob: c46ff1a8bd1230f74841cf8e72e7bd27927c4ca6 [file] [log] [blame]
Bob King833b8e02020-06-11 14:56:38 +08001/**
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
17#include "sensor_monitoring.hpp"
18
19#include "action_environment.hpp"
20#include "action_utils.hpp"
21#include "chassis.hpp"
22#include "device.hpp"
Shawn McCarney81a2f902021-03-23 21:41:34 -050023#include "error_logging_utils.hpp"
Bob King833b8e02020-06-11 14:56:38 +080024#include "exception_utils.hpp"
Bob King833b8e02020-06-11 14:56:38 +080025#include "rail.hpp"
26#include "system.hpp"
27
28#include <exception>
29
30namespace phosphor::power::regulators
31{
32
Bob King8a552922020-08-05 17:02:31 +080033void SensorMonitoring::execute(Services& services, System& system,
34 Chassis& /*chassis*/, Device& device, Rail& rail)
Bob King833b8e02020-06-11 14:56:38 +080035{
36 try
37 {
38 // Create ActionEnvironment
Bob King73eacee2020-10-23 13:58:02 +080039 ActionEnvironment environment{system.getIDMap(), device.getID(),
40 services};
Bob King833b8e02020-06-11 14:56:38 +080041
42 // Execute the actions
43 action_utils::execute(actions, environment);
44 }
45 catch (const std::exception& e)
46 {
47 // Log error messages in journal
Bob King8a552922020-08-05 17:02:31 +080048 services.getJournal().logError(exception_utils::getMessages(e));
49 services.getJournal().logError("Unable to monitor sensors for rail " +
50 rail.getID());
Bob King833b8e02020-06-11 14:56:38 +080051
Shawn McCarney81a2f902021-03-23 21:41:34 -050052 // Create error log entry
53 // TODO: Add ErrorHistory data member and specify as parameter below
54 error_logging_utils::logError(std::current_exception(),
55 Entry::Level::Warning, services);
Bob King833b8e02020-06-11 14:56:38 +080056 }
57}
58
59} // namespace phosphor::power::regulators