Matt Spinler | 09d6400 | 2019-09-11 14:29:46 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "data_interface.hpp" |
| 4 | #include "mtms.hpp" |
| 5 | #include "section.hpp" |
| 6 | #include "stream.hpp" |
| 7 | |
| 8 | namespace openpower |
| 9 | { |
| 10 | namespace pels |
| 11 | { |
| 12 | |
| 13 | /** |
| 14 | * @class FailingMTMS |
| 15 | * |
| 16 | * This represents the Failing Enclosure MTMS section in a PEL. |
| 17 | * It is a required section. In the BMC case, the enclosure is |
| 18 | * the system enclosure. |
| 19 | */ |
| 20 | class FailingMTMS : public Section |
| 21 | { |
| 22 | public: |
| 23 | FailingMTMS() = delete; |
| 24 | ~FailingMTMS() = default; |
| 25 | FailingMTMS(const FailingMTMS&) = default; |
| 26 | FailingMTMS& operator=(const FailingMTMS&) = default; |
| 27 | FailingMTMS(FailingMTMS&&) = default; |
| 28 | FailingMTMS& operator=(FailingMTMS&&) = default; |
| 29 | |
| 30 | /** |
| 31 | * @brief Constructor |
| 32 | * |
| 33 | * @param[in] dataIface - The object to use to obtain |
| 34 | * the MTM and SN. |
| 35 | */ |
| 36 | explicit FailingMTMS(const DataInterfaceBase& dataIface); |
| 37 | |
| 38 | /** |
| 39 | * @brief Constructor |
| 40 | * |
| 41 | * Fills in this class's data fields from the stream. |
| 42 | * |
| 43 | * @param[in] pel - the PEL data stream |
| 44 | */ |
| 45 | explicit FailingMTMS(Stream& pel); |
| 46 | |
| 47 | /** |
| 48 | * @brief Flatten the section into the stream |
| 49 | * |
| 50 | * @param[in] stream - The stream to write to |
| 51 | */ |
Matt Spinler | 0688545 | 2019-11-06 10:35:42 -0600 | [diff] [blame] | 52 | void flatten(Stream& stream) const override; |
Matt Spinler | 09d6400 | 2019-09-11 14:29:46 -0500 | [diff] [blame] | 53 | |
| 54 | /** |
| 55 | * @brief Returns the size of this section when flattened into a PEL |
| 56 | * |
| 57 | * @return size_t - the size of the section |
| 58 | */ |
| 59 | static constexpr size_t flattenedSize() |
| 60 | { |
| 61 | return Section::flattenedSize() + MTMS::flattenedSize(); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * @brief Returns the machine type+model as a string |
| 66 | * |
| 67 | * @return std::string the MTM |
| 68 | */ |
Matt Spinler | 4b59f7a | 2019-10-08 13:55:17 -0500 | [diff] [blame] | 69 | std::string getMachineTypeModel() const |
| 70 | { |
| 71 | return _mtms.machineTypeAndModel(); |
| 72 | } |
Matt Spinler | 09d6400 | 2019-09-11 14:29:46 -0500 | [diff] [blame] | 73 | |
| 74 | /** |
| 75 | * @brief Returns the machine serial number as a string |
| 76 | * |
| 77 | * @return std::string the serial number |
| 78 | */ |
Matt Spinler | 4b59f7a | 2019-10-08 13:55:17 -0500 | [diff] [blame] | 79 | std::string getMachineSerialNumber() const |
| 80 | { |
| 81 | return _mtms.machineSerialNumber(); |
| 82 | } |
Matt Spinler | 09d6400 | 2019-09-11 14:29:46 -0500 | [diff] [blame] | 83 | |
Harisuddin Mohamed Isa | e2d1bf3 | 2020-02-06 17:32:38 +0800 | [diff] [blame] | 84 | /** |
| 85 | * @brief Get section in JSON. |
Matt Spinler | b832aa5 | 2023-03-21 15:32:34 -0500 | [diff] [blame] | 86 | * |
| 87 | * @param[in] creatorID - The creator ID for the PEL |
| 88 | * |
Harisuddin Mohamed Isa | e2d1bf3 | 2020-02-06 17:32:38 +0800 | [diff] [blame] | 89 | * @return std::optional<std::string> - Failing MTMS section in JSON |
| 90 | */ |
Matt Spinler | b832aa5 | 2023-03-21 15:32:34 -0500 | [diff] [blame] | 91 | std::optional<std::string> getJSON(uint8_t creatorID) const override; |
Harisuddin Mohamed Isa | e2d1bf3 | 2020-02-06 17:32:38 +0800 | [diff] [blame] | 92 | |
Matt Spinler | 09d6400 | 2019-09-11 14:29:46 -0500 | [diff] [blame] | 93 | private: |
| 94 | /** |
| 95 | * @brief Validates the section contents |
| 96 | * |
| 97 | * Updates _valid (in Section) with the results. |
| 98 | */ |
| 99 | void validate() override; |
| 100 | |
| 101 | /** |
| 102 | * @brief Fills in the object from the stream data |
| 103 | * |
| 104 | * @param[in] stream - The stream to read from |
| 105 | */ |
| 106 | void unflatten(Stream& stream); |
| 107 | |
| 108 | /** |
| 109 | * @brief The structure that holds the TM and SN fields. |
| 110 | * This is also used in other places in the PEL. |
| 111 | */ |
| 112 | MTMS _mtms; |
| 113 | }; |
| 114 | |
| 115 | } // namespace pels |
| 116 | |
| 117 | } // namespace openpower |