Shawn McCarney | 421128e | 2021-08-25 10:00:59 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2021 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 | |
Shawn McCarney | e6d54a1 | 2021-09-02 15:21:50 -0500 | [diff] [blame] | 18 | #include "error_history.hpp" |
| 19 | |
Shawn McCarney | 421128e | 2021-08-25 10:00:59 -0500 | [diff] [blame] | 20 | #include <string> |
| 21 | |
| 22 | namespace phosphor::power::regulators |
| 23 | { |
| 24 | |
| 25 | /** |
| 26 | * Redundant phase fault type. |
| 27 | * |
| 28 | * A voltage regulator is sometimes called a "phase controller" because it |
| 29 | * controls one or more phases that perform the actual voltage regulation. |
| 30 | * |
| 31 | * A regulator may have redundant phases. If a redundant phase fails, the |
| 32 | * regulator will continue to provide the desired output voltage. However, a |
| 33 | * phase fault error should be logged warning the user that the regulator has |
| 34 | * lost redundancy. |
| 35 | */ |
| 36 | enum class PhaseFaultType : unsigned char |
| 37 | { |
| 38 | /** |
| 39 | * N phase fault type. |
| 40 | * |
| 41 | * Regulator has lost all redundant phases. The regulator is now at |
| 42 | * redundancy level N. |
| 43 | */ |
| 44 | n, |
| 45 | |
| 46 | /** |
| 47 | * N+1 phase fault type. |
| 48 | * |
| 49 | * An "N+2" regulator has lost one redundant phase. The regulator is now at |
| 50 | * redundancy level "N+1". |
| 51 | */ |
| 52 | n_plus_1 |
| 53 | }; |
| 54 | |
| 55 | /** |
Shawn McCarney | e6d54a1 | 2021-09-02 15:21:50 -0500 | [diff] [blame] | 56 | * Returns the ErrorType that corresponds to the specified PhaseFaultType. |
| 57 | * |
| 58 | * The ErrorType enum is used with the ErrorHistory class. |
| 59 | * |
| 60 | * @param type phase fault type |
| 61 | * @return error type |
| 62 | */ |
| 63 | inline ErrorType toErrorType(PhaseFaultType type) |
| 64 | { |
| 65 | ErrorType errorType; |
| 66 | switch (type) |
| 67 | { |
| 68 | case PhaseFaultType::n: |
| 69 | errorType = ErrorType::phaseFaultN; |
| 70 | break; |
| 71 | case PhaseFaultType::n_plus_1: |
| 72 | errorType = ErrorType::phaseFaultNPlus1; |
| 73 | break; |
| 74 | } |
| 75 | return errorType; |
| 76 | } |
| 77 | |
| 78 | /** |
Shawn McCarney | 421128e | 2021-08-25 10:00:59 -0500 | [diff] [blame] | 79 | * Returns the name of the specified PhaseFaultType. |
| 80 | * |
| 81 | * @param type phase fault type |
| 82 | * @return phase fault type name |
| 83 | */ |
| 84 | inline std::string toString(PhaseFaultType type) |
| 85 | { |
| 86 | std::string name{}; |
| 87 | switch (type) |
| 88 | { |
| 89 | case PhaseFaultType::n: |
| 90 | name = "n"; |
| 91 | break; |
| 92 | case PhaseFaultType::n_plus_1: |
| 93 | name = "n+1"; |
| 94 | break; |
| 95 | } |
| 96 | return name; |
| 97 | } |
| 98 | |
| 99 | } // namespace phosphor::power::regulators |