#include "common/types.hpp"
#include "pldm_cmd_helper.hpp"

#include <libpldm/entity.h>
#include <libpldm/platform.h>
#include <libpldm/state_set.h>

#include <algorithm>
#include <cstddef>
#include <format>
#include <map>
#include <memory>
#include <ranges>

#ifdef OEM_IBM
#include "oem/ibm/oem_ibm_state_set.hpp"
#endif

using namespace pldm::utils;

namespace pldmtool
{
namespace platform
{
namespace
{
using namespace pldmtool::helper;

static const std::map<uint8_t, std::string> sensorPresState{
    {PLDM_SENSOR_UNKNOWN, "Sensor Unknown"},
    {PLDM_SENSOR_NORMAL, "Sensor Normal"},
    {PLDM_SENSOR_WARNING, "Sensor Warning"},
    {PLDM_SENSOR_CRITICAL, "Sensor Critical"},
    {PLDM_SENSOR_FATAL, "Sensor Fatal"},
    {PLDM_SENSOR_LOWERWARNING, "Sensor Lower Warning"},
    {PLDM_SENSOR_LOWERCRITICAL, "Sensor Lower Critical"},
    {PLDM_SENSOR_LOWERFATAL, "Sensor Lower Fatal"},
    {PLDM_SENSOR_UPPERWARNING, "Sensor Upper Warning"},
    {PLDM_SENSOR_UPPERCRITICAL, "Sensor Upper Critical"},
    {PLDM_SENSOR_UPPERFATAL, "Sensor Upper Fatal"}};

static const std::map<uint8_t, std::string> sensorOpState{
    {PLDM_SENSOR_ENABLED, "Sensor Enabled"},
    {PLDM_SENSOR_DISABLED, "Sensor Disabled"},
    {PLDM_SENSOR_UNAVAILABLE, "Sensor Unavailable"},
    {PLDM_SENSOR_STATUSUNKOWN, "Sensor Status Unknown"},
    {PLDM_SENSOR_FAILED, "Sensor Failed"},
    {PLDM_SENSOR_INITIALIZING, "Sensor Sensor Initializing"},
    {PLDM_SENSOR_SHUTTINGDOWN, "Sensor Shutting down"},
    {PLDM_SENSOR_INTEST, "Sensor Intest"}};

const std::map<uint8_t, std::string> effecterOpState{
    {EFFECTER_OPER_STATE_ENABLED_UPDATEPENDING,
     "Effecter Enabled Update Pending"},
    {EFFECTER_OPER_STATE_ENABLED_NOUPDATEPENDING,
     "Effecter Enabled No Update Pending"},
    {EFFECTER_OPER_STATE_DISABLED, "Effecter Disabled"},
    {EFFECTER_OPER_STATE_UNAVAILABLE, "Effecter Unavailable"},
    {EFFECTER_OPER_STATE_STATUSUNKNOWN, "Effecter Status Unknown"},
    {EFFECTER_OPER_STATE_FAILED, "Effecter Failed"},
    {EFFECTER_OPER_STATE_INITIALIZING, "Effecter Initializing"},
    {EFFECTER_OPER_STATE_SHUTTINGDOWN, "Effecter Shutting Down"},
    {EFFECTER_OPER_STATE_INTEST, "Effecter In Test"}};

std::string getEffecterOpState(uint8_t state)
{
    return effecterOpState.contains(state) ? effecterOpState.at(state)
                                           : std::to_string(state);
}

std::vector<std::unique_ptr<CommandInterface>> commands;

} // namespace

using ordered_json = nlohmann::ordered_json;

class GetPDR : public CommandInterface
{
  public:
    ~GetPDR() = default;
    GetPDR() = delete;
    GetPDR(const GetPDR&) = delete;
    GetPDR(GetPDR&&) = default;
    GetPDR& operator=(const GetPDR&) = delete;
    GetPDR& operator=(GetPDR&&) = delete;

    using CommandInterface::CommandInterface;

    explicit GetPDR(const char* type, const char* name, CLI::App* app) :
        CommandInterface(type, name, app), dataTransferHandle(0),
        operationFlag(PLDM_GET_FIRSTPART), requestCount(UINT16_MAX),
        recordChangeNumber(0), nextPartRequired(false)
    {
        auto pdrOptionGroup = app->add_option_group(
            "Required Option",
            "Retrieve individual PDR, all PDRs, PDRs of a requested type or retrieve all PDRs of the requested terminusID");
        pdrOptionGroup->add_option(
            "-d,--data", recordHandle,
            "retrieve individual PDRs from a PDR Repository\n"
            "eg: The recordHandle value for the PDR to be retrieved and 0 "
            "means get first PDR in the repository.");
        pdrRecType = "";
        pdrOptionGroup->add_option(
            "-t, --type", pdrRecType,
            "retrieve all PDRs of the requested type\n"
            "supported types:\n"
            "[terminusLocator, stateSensor, "
            "numericEffecter, stateEffecter, "
            "compactNumericSensor, sensorauxname, "
            "efffecterAuxName, numericsensor, "
            "EntityAssociation, fruRecord, ... ]");

        getPDRGroupOption = pdrOptionGroup->add_option(
            "-i, --terminusID", pdrTerminus,
            "retrieve all PDRs of the requested terminusID\n"
            "supported IDs:\n [1, 2, 208...]");

        allPDRs = false;
        pdrOptionGroup->add_flag("-a, --all", allPDRs,
                                 "retrieve all PDRs from a PDR repository");

        pdrOptionGroup->require_option(1);
    }

    void parseGetPDROptions()
    {
        optTIDSet = false;
        if (getPDRGroupOption->count() > 0)
        {
            optTIDSet = true;
            getPDRs();
        }
    }

    void getPDRs()
    {
        // start the array
        std::cout << "[";

        recordHandle = 0;
        do
        {
            CommandInterface::exec();
        } while (recordHandle != 0);

        // close the array
        std::cout << "]\n";

        if (handleFound)
        {
            recordHandle = 0;
            uint32_t prevRecordHandle = 0;
            do
            {
                CommandInterface::exec();
                if (recordHandle == prevRecordHandle)
                {
                    return;
                }
                prevRecordHandle = recordHandle;
            } while (recordHandle != 0);
        }
    }

    void exec() override
    {
        if (allPDRs || !pdrRecType.empty())
        {
            if (!pdrRecType.empty())
            {
                std::transform(pdrRecType.begin(), pdrRecType.end(),
                               pdrRecType.begin(), tolower);
            }

            // start the array
            std::cout << "[\n";

            // Retrieve all PDR records starting from the first
            recordHandle = 0;
            uint32_t prevRecordHandle = 0;
            std::map<uint32_t, uint32_t> recordsSeen;
            do
            {
                CommandInterface::exec();
                // recordHandle is updated to nextRecord when
                // CommandInterface::exec() is successful.
                // In case of any error, return.
                if (recordHandle == prevRecordHandle && !nextPartRequired)
                {
                    return;
                }

                // check for circular references.
                auto result =
                    recordsSeen.emplace(recordHandle, prevRecordHandle);
                if (!result.second && !nextPartRequired)
                {
                    std::cerr
                        << "Record handle " << recordHandle
                        << " has multiple references: " << result.first->second
                        << ", " << prevRecordHandle << "\n";
                    return;
                }
                prevRecordHandle = recordHandle;

                if (recordHandle != 0)
                {
                    // close the array
                    std::cout << ",";
                }
            } while (recordHandle != 0);

            // close the array
            std::cout << "]\n";
        }
        else
        {
            do
            {
                CommandInterface::exec();
            } while (nextPartRequired);
        }
    }

    std::pair<int, std::vector<uint8_t>> createRequestMsg() override
    {
        std::vector<uint8_t> requestMsg(
            sizeof(pldm_msg_hdr) + PLDM_GET_PDR_REQ_BYTES);
        auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());

        auto rc = encode_get_pdr_req(
            instanceId, recordHandle, dataTransferHandle, operationFlag,
            requestCount, recordChangeNumber, request, PLDM_GET_PDR_REQ_BYTES);
        return {rc, requestMsg};
    }

    void parseResponseMsg(pldm_msg* responsePtr, size_t payloadLength) override
    {
        uint8_t completionCode = 0;
        uint8_t respRecordData[UINT16_MAX] = {0};
        uint32_t nextRecordHndl = 0;
        uint32_t nextDataTransferHndl = 0;
        uint8_t transferFlag = 0;
        uint16_t respCnt = 0;
        uint8_t transferCRC = 0;

        auto rc = decode_get_pdr_resp(
            responsePtr, payloadLength, &completionCode, &nextRecordHndl,
            &nextDataTransferHndl, &transferFlag, &respCnt, respRecordData,
            sizeof(respRecordData), &transferCRC);

        if (rc != PLDM_SUCCESS || completionCode != PLDM_SUCCESS)
        {
            std::cerr << "Response Message Error: "
                      << "rc=" << rc << ",cc=" << (int)completionCode
                      << std::endl;
            nextPartRequired = false;
            return;
        }

        if (optTIDSet && !handleFound)
        {
            terminusHandle = getTerminusHandle(respRecordData, pdrTerminus);
            if (terminusHandle.has_value())
            {
                recordHandle = 0;
                return;
            }
            else
            {
                recordHandle = nextRecordHndl;
                return;
            }
        }
        else
        {
            recordData.insert(recordData.end(), respRecordData,
                              respRecordData + respCnt);

            // End or StartAndEnd
            if (transferFlag == PLDM_PLATFORM_TRANSFER_END ||
                transferFlag == PLDM_PLATFORM_TRANSFER_START_AND_END)
            {
                printPDRMsg(nextRecordHndl, respCnt, recordData.data(),
                            terminusHandle);
                nextPartRequired = false;
                recordHandle = nextRecordHndl;
                dataTransferHandle = 0;
                recordChangeNumber = 0;
                operationFlag = PLDM_GET_FIRSTPART;
                recordData.clear();
            }
            else
            {
                nextPartRequired = true;
                dataTransferHandle = nextDataTransferHndl;
                struct pldm_pdr_hdr* pdr_hdr =
                    reinterpret_cast<struct pldm_pdr_hdr*>(respRecordData);
                recordChangeNumber = pdr_hdr->record_change_num;
                operationFlag = PLDM_GET_NEXTPART;
            }
        }
    }

  private:
    const std::map<pldm::pdr::EntityType, std::string> entityType = {
        {PLDM_ENTITY_UNSPECIFIED, "Unspecified"},
        {PLDM_ENTITY_OTHER, "Other"},
        {PLDM_ENTITY_NETWORK, "Network"},
        {PLDM_ENTITY_GROUP, "Group"},
        {PLDM_ENTITY_REMOTE_MGMT_COMM_DEVICE,
         "Remote Management Communication Device"},
        {PLDM_ENTITY_EXTERNAL_ENVIRONMENT, "External Environment"},
        {PLDM_ENTITY_COMM_CHANNEL, " Communication Channel"},
        {PLDM_ENTITY_TERMINUS, "PLDM Terminus"},
        {PLDM_ENTITY_PLATFORM_EVENT_LOG, " Platform Event Log"},
        {PLDM_ENTITY_KEYPAD, "keypad"},
        {PLDM_ENTITY_SWITCH, "Switch"},
        {PLDM_ENTITY_PUSHBUTTON, "Pushbutton"},
        {PLDM_ENTITY_DISPLAY, "Display"},
        {PLDM_ENTITY_INDICATOR, "Indicator"},
        {PLDM_ENTITY_SYS_MGMT_SW, "System Management Software"},
        {PLDM_ENTITY_SYS_FIRMWARE, "System Firmware"},
        {PLDM_ENTITY_OPERATING_SYS, "Operating System"},
        {PLDM_ENTITY_VIRTUAL_MACHINE_MANAGER, "Virtual Machine Manager"},
        {PLDM_ENTITY_OS_LOADER, "OS Loader"},
        {PLDM_ENTITY_DEVICE_DRIVER, "Device Driver"},
        {PLDM_ENTITY_MGMT_CONTROLLER_FW, "Management Controller Firmware"},
        {PLDM_ENTITY_SYSTEM_CHASSIS, "System chassis (main enclosure)"},
        {PLDM_ENTITY_SUB_CHASSIS, "Sub-chassis"},
        {PLDM_ENTITY_DISK_DRIVE_BAY, "Disk Drive Bay"},
        {PLDM_ENTITY_PERIPHERAL_BAY, "Peripheral Bay"},
        {PLDM_ENTITY_DEVICE_BAY, "Device bay"},
        {PLDM_ENTITY_DOOR, "Door"},
        {PLDM_ENTITY_ACCESS_PANEL, "Access Panel"},
        {PLDM_ENTITY_COVER, "Cover"},
        {PLDM_ENTITY_BOARD, "Board"},
        {PLDM_ENTITY_CARD, "Card"},
        {PLDM_ENTITY_MODULE, "Module"},
        {PLDM_ENTITY_SYS_MGMT_MODULE, "System management module"},
        {PLDM_ENTITY_SYS_BOARD, "System Board"},
        {PLDM_ENTITY_MEMORY_BOARD, "Memory Board"},
        {PLDM_ENTITY_MEMORY_MODULE, "Memory Module"},
        {PLDM_ENTITY_PROC_MODULE, "Processor Module"},
        {PLDM_ENTITY_ADD_IN_CARD, "Add-in Card"},
        {PLDM_ENTITY_CHASSIS_FRONT_PANEL_BOARD,
         "Chassis front panel board(control panel)"},
        {PLDM_ENTITY_BACK_PANEL_BOARD, "Back panel board"},
        {PLDM_ENTITY_POWER_MGMT, "Power management board"},
        {PLDM_ENTITY_POWER_SYS_BOARD, "Power system board"},
        {PLDM_ENTITY_DRIVE_BACKPLANE, "Drive backplane"},
        {PLDM_ENTITY_SYS_INTERNAL_EXPANSION_BOARD,
         "System internal expansion board"},
        {PLDM_ENTITY_OTHER_SYS_BOARD, "Other system board"},
        {PLDM_ENTITY_CHASSIS_BACK_PANEL_BOARD, "Chassis back panel board"},
        {PLDM_ENTITY_PROCESSING_BLADE, "Processing blade"},
        {PLDM_ENTITY_CONNECTIVITY_SWITCH, "Connectivity switch"},
        {PLDM_ENTITY_PROC_MEMORY_MODULE, "Processor/Memory Module"},
        {PLDM_ENTITY_IO_MODULE, "I/O Module"},
        {PLDM_ENTITY_PROC_IO_MODULE, "Processor I/O Module"},
        {PLDM_ENTITY_COOLING_DEVICE, "Cooling device"},
        {PLDM_ENTITY_COOLING_SUBSYSTEM, "Cooling subsystem"},
        {PLDM_ENTITY_COOLING_UNIT, "Cooling Unit"},
        {PLDM_ENTITY_FAN, "Fan"},
        {PLDM_ENTITY_PELTIER_COOLING_DEVICE, "Peltier Cooling Device"},
        {PLDM_ENTITY_LIQUID_COOLING_DEVICE, "Liquid Cooling Device"},
        {PLDM_ENTITY_LIQUID_COOLING_SUBSYSTEM, "Liquid Colling Subsystem"},
        {PLDM_ENTITY_OTHER_STORAGE_DEVICE, "Other Storage Device"},
        {PLDM_ENTITY_FLOPPY_DRIVE, "Floppy Drive"},
        {PLDM_ENTITY_FIXED_DISK_HARD_DRIVE, "Hard Drive"},
        {PLDM_ENTITY_CD_DRIVE, "CD Drive"},
        {PLDM_ENTITY_CD_DVD_DRIVE, "CD/DVD Drive"},
        {PLDM_ENTITY_OTHER_SILICON_STORAGE_DEVICE,
         "Other Silicon Storage Device"},
        {PLDM_ENTITY_SOLID_STATE_SRIVE, "Solid State Drive"},
        {PLDM_ENTITY_POWER_SUPPLY, "Power supply"},
        {PLDM_ENTITY_BATTERY, "Battery"},
        {PLDM_ENTITY_SUPER_CAPACITOR, "Super Capacitor"},
        {PLDM_ENTITY_POWER_CONVERTER, "Power Converter"},
        {PLDM_ENTITY_DC_DC_CONVERTER, "DC-DC Converter"},
        {PLDM_ENTITY_AC_MAINS_POWER_SUPPLY, "AC mains power supply"},
        {PLDM_ENTITY_DC_MAINS_POWER_SUPPLY, "DC mains power supply"},
        {PLDM_ENTITY_PROC, "Processor"},
        {PLDM_ENTITY_CHIPSET_COMPONENT, "Chipset Component"},
        {PLDM_ENTITY_MGMT_CONTROLLER, "Management Controller"},
        {PLDM_ENTITY_PERIPHERAL_CONTROLLER, "Peripheral Controller"},
        {PLDM_ENTITY_SEEPROM, "SEEPROM"},
        {PLDM_ENTITY_NVRAM_CHIP, "NVRAM Chip"},
        {PLDM_ENTITY_FLASH_MEMORY_CHIP, "FLASH Memory chip"},
        {PLDM_ENTITY_MEMORY_CHIP, "Memory Chip"},
        {PLDM_ENTITY_MEMORY_CONTROLLER, "Memory Controller"},
        {PLDM_ENTITY_NETWORK_CONTROLLER, "Network Controller"},
        {PLDM_ENTITY_IO_CONTROLLER, "I/O Controller"},
        {PLDM_ENTITY_SOUTH_BRIDGE, "South Bridge"},
        {PLDM_ENTITY_REAL_TIME_CLOCK, "Real Time Clock (RTC)"},
        {PLDM_ENTITY_FPGA_CPLD_DEVICE, "FPGA/CPLD Configurable Logic Device"},
        {PLDM_ENTITY_OTHER_BUS, "Other Bus"},
        {PLDM_ENTITY_SYS_BUS, "System Bus"},
        {PLDM_ENTITY_I2C_BUS, "I2C Bus"},
        {PLDM_ENTITY_SMBUS_BUS, "SMBus Bus"},
        {PLDM_ENTITY_SPI_BUS, "SPI Bus"},
        {PLDM_ENTITY_PCI_BUS, "PCI Bus"},
        {PLDM_ENTITY_PCI_EXPRESS_BUS, "PCI Express Bus"},
        {PLDM_ENTITY_PECI_BUS, "PECI Bus"},
        {PLDM_ENTITY_LPC_BUS, "LPC Bus"},
        {PLDM_ENTITY_USB_BUS, "USB Bus"},
        {PLDM_ENTITY_FIREWIRE_BUS, "FireWire Bus"},
        {PLDM_ENTITY_SCSI_BUS, "SCSI Bus"},
        {PLDM_ENTITY_SATA_SAS_BUS, "SATA/SAS Bus"},
        {PLDM_ENTITY_PROC_FRONT_SIDE_BUS, "Processor/Front-side Bus"},
        {PLDM_ENTITY_INTER_PROC_BUS, "Inter-processor Bus"},
        {PLDM_ENTITY_CONNECTOR, "Connector"},
        {PLDM_ENTITY_SLOT, "Slot"},
        {PLDM_ENTITY_CABLE, "Cable(electrical or optical)"},
        {PLDM_ENTITY_INTERCONNECT, "Interconnect"},
        {PLDM_ENTITY_PLUG, "Plug"},
        {PLDM_ENTITY_SOCKET, "Socket"},
    };

    const std::map<uint16_t, std::string> stateSet = {
        {PLDM_STATE_SET_HEALTH_STATE, "Health State"},
        {PLDM_STATE_SET_AVAILABILITY, "Availability"},
        {PLDM_STATE_SET_PREDICTIVE_CONDITION, "Predictive Condition"},
        {PLDM_STATE_SET_REDUNDANCY_STATUS, "Redundancy Status"},
        {PLDM_STATE_SET_HEALTH_REDUNDANCY_TREND, "Health/Redundancy Trend"},
        {PLDM_STATE_SET_GROUP_RESOURCE_LEVEL, "Group Resource Level"},
        {PLDM_STATE_SET_REDUNDANCY_ENTITY_ROLE, "Redundancy Entity Role"},
        {PLDM_STATE_SET_OPERATIONAL_STATUS, "Operational Status"},
        {PLDM_STATE_SET_OPERATIONAL_STRESS_STATUS, "Operational Stress Status"},
        {PLDM_STATE_SET_OPERATIONAL_FAULT_STATUS, "Operational Fault Status"},
        {PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS,
         "Operational Running Status"},
        {PLDM_STATE_SET_OPERATIONAL_CONNECTION_STATUS,
         "Operational Connection Status"},
        {PLDM_STATE_SET_PRESENCE, "Presence"},
        {PLDM_STATE_SET_PERFORMANCE, "Performance"},
        {PLDM_STATE_SET_CONFIGURATION_STATE, "Configuration State"},
        {PLDM_STATE_SET_CHANGED_CONFIGURATION, "Changed Configuration"},
        {PLDM_STATE_SET_IDENTIFY_STATE, "Identify State"},
        {PLDM_STATE_SET_VERSION, "Version"},
        {PLDM_STATE_SET_ALARM_STATE, "Alarm State"},
        {PLDM_STATE_SET_DEVICE_INITIALIZATION, "Device Initialization"},
        {PLDM_STATE_SET_THERMAL_TRIP, "Thermal Trip"},
        {PLDM_STATE_SET_HEARTBEAT, "Heartbeat"},
        {PLDM_STATE_SET_LINK_STATE, "Link State"},
        {PLDM_STATE_SET_SMOKE_STATE, "Smoke State"},
        {PLDM_STATE_SET_HUMIDITY_STATE, "Humidity State"},
        {PLDM_STATE_SET_DOOR_STATE, "Door State"},
        {PLDM_STATE_SET_SWITCH_STATE, "Switch State"},
        {PLDM_STATE_SET_LOCK_STATE, "Lock State"},
        {PLDM_STATE_SET_PHYSICAL_SECURITY, "Physical Security"},
        {PLDM_STATE_SET_DOCK_AUTHORIZATION, "Dock Authorization"},
        {PLDM_STATE_SET_HW_SECURITY, "Hardware Security"},
        {PLDM_STATE_SET_PHYSICAL_COMM_CONNECTION,
         "Physical Communication Connection"},
        {PLDM_STATE_SET_COMM_LEASH_STATUS, "Communication Leash Status"},
        {PLDM_STATE_SET_FOREIGN_NW_DETECTION_STATUS,
         "Foreign Network Detection Status"},
        {PLDM_STATE_SET_PASSWORD_PROTECTED_ACCESS_SECURITY,
         "Password-Protected Access Security"},
        {PLDM_STATE_SET_SECURITY_ACCESS_PRIVILEGE_LEVEL,
         "Security Access –PrivilegeLevel"},
        {PLDM_STATE_SET_SESSION_AUDIT, "PLDM Session Audit"},
        {PLDM_STATE_SET_SW_TERMINATION_STATUS, "Software Termination Status"},
        {PLDM_STATE_SET_STORAGE_MEDIA_ACTIVITY, "Storage Media Activity"},
        {PLDM_STATE_SET_BOOT_RESTART_CAUSE, "Boot/Restart Cause"},
        {PLDM_STATE_SET_BOOT_RESTART_REQUEST, "Boot/Restart Request"},
        {PLDM_STATE_SET_ENTITY_BOOT_STATUS, "Entity Boot Status"},
        {PLDM_STATE_SET_BOOT_ERROR_STATUS, "Boot ErrorStatus"},
        {PLDM_STATE_SET_BOOT_PROGRESS, "Boot Progress"},
        {PLDM_STATE_SET_SYS_FIRMWARE_HANG, "System Firmware Hang"},
        {PLDM_STATE_SET_POST_ERRORS, "POST Errors"},
        {PLDM_STATE_SET_LOG_FILL_STATUS, "Log Fill Status"},
        {PLDM_STATE_SET_LOG_FILTER_STATUS, "Log Filter Status"},
        {PLDM_STATE_SET_LOG_TIMESTAMP_CHANGE, "Log Timestamp Change"},
        {PLDM_STATE_SET_INTERRUPT_REQUESTED, "Interrupt Requested"},
        {PLDM_STATE_SET_INTERRUPT_RECEIVED, "Interrupt Received"},
        {PLDM_STATE_SET_DIAGNOSTIC_INTERRUPT_REQUESTED,
         "Diagnostic Interrupt Requested"},
        {PLDM_STATE_SET_DIAGNOSTIC_INTERRUPT_RECEIVED,
         "Diagnostic Interrupt Received"},
        {PLDM_STATE_SET_IO_CHANNEL_CHECK_NMI_REQUESTED,
         "I/O Channel Check NMI Requested"},
        {PLDM_STATE_SET_IO_CHANNEL_CHECK_NMI_RECEIVED,
         "I/O Channel Check NMI Received"},
        {PLDM_STATE_SET_FATAL_NMI_REQUESTED, "Fatal NMI Requested"},
        {PLDM_STATE_SET_FATAL_NMI_RECEIVED, "Fatal NMI Received"},
        {PLDM_STATE_SET_SOFTWARE_NMI_REQUESTED, "Software NMI Requested"},
        {PLDM_STATE_SET_SOFTWARE_NMI_RECEIVED, "Software NMI Received"},
        {PLDM_STATE_SET_SMI_REQUESTED, "SMI Requested"},
        {PLDM_STATE_SET_SMI_RECEIVED, "SMI Received"},
        {PLDM_STATE_SET_PCI_PERR_REQUESTED, "PCI PERR Requested"},
        {PLDM_STATE_SET_PCI_PERR_RECEIVED, "PCI PERR Received"},
        {PLDM_STATE_SET_PCI_SERR_REQUESTED, "PCI SERR Requested "},
        {PLDM_STATE_SET_PCI_SERR_RECEIVED, "PCI SERR Received"},
        {PLDM_STATE_SET_BUS_ERROR_STATUS, "Bus Error Status"},
        {PLDM_STATE_SET_WATCHDOG_STATUS, "Watchdog Status"},
        {PLDM_STATE_SET_POWER_SUPPLY_STATE, "Power Supply State"},
        {PLDM_STATE_SET_DEVICE_POWER_STATE, "Device Power State"},
        {PLDM_STATE_SET_ACPI_POWER_STATE, "ACPI Power State"},
        {PLDM_STATE_SET_BACKUP_POWER_SOURCE, "Backup Power Source"},
        {PLDM_STATE_SET_SYSTEM_POWER_STATE, "System Power State "},
        {PLDM_STATE_SET_BATTERY_ACTIVITY, "Battery Activity"},
        {PLDM_STATE_SET_BATTERY_STATE, "Battery State"},
        {PLDM_STATE_SET_PROC_POWER_STATE, "Processor Power State"},
        {PLDM_STATE_SET_POWER_PERFORMANCE_STATE, "Power-Performance State"},
        {PLDM_STATE_SET_PROC_ERROR_STATUS, "Processor Error Status"},
        {PLDM_STATE_SET_BIST_FAILURE_STATUS, "BIST FailureStatus"},
        {PLDM_STATE_SET_IBIST_FAILURE_STATUS, "IBIST FailureStatus"},
        {PLDM_STATE_SET_PROC_HANG_IN_POST, "Processor Hang in POST"},
        {PLDM_STATE_SET_PROC_STARTUP_FAILURE, "Processor Startup Failure"},
        {PLDM_STATE_SET_UNCORRECTABLE_CPU_ERROR, "Uncorrectable CPU Error"},
        {PLDM_STATE_SET_MACHINE_CHECK_ERROR, "Machine Check Error"},
        {PLDM_STATE_SET_CORRECTED_MACHINE_CHECK, "Corrected Machine Check"},
        {PLDM_STATE_SET_CACHE_STATUS, "Cache Status"},
        {PLDM_STATE_SET_MEMORY_ERROR_STATUS, "Memory Error Status"},
        {PLDM_STATE_SET_REDUNDANT_MEMORY_ACTIVITY_STATUS,
         "Redundant Memory Activity Status"},
        {PLDM_STATE_SET_ERROR_DETECTION_STATUS, "Error Detection Status"},
        {PLDM_STATE_SET_STUCK_BIT_STATUS, "Stuck Bit Status"},
        {PLDM_STATE_SET_SCRUB_STATUS, "Scrub Status"},
        {PLDM_STATE_SET_SLOT_OCCUPANCY, "Slot Occupancy"},
        {PLDM_STATE_SET_SLOT_STATE, "Slot State"},
    };

    const std::array<std::string_view, 4> sensorInit = {
        "noInit", "useInitPDR", "enableSensor", "disableSensor"};

    const std::array<std::string_view, 4> effecterInit = {
        "noInit", "useInitPDR", "enableEffecter", "disableEffecter"};

    const std::map<uint8_t, std::string> pdrType = {
        {PLDM_TERMINUS_LOCATOR_PDR, "Terminus Locator PDR"},
        {PLDM_NUMERIC_SENSOR_PDR, "Numeric Sensor PDR"},
        {PLDM_NUMERIC_SENSOR_INITIALIZATION_PDR,
         "Numeric Sensor Initialization PDR"},
        {PLDM_STATE_SENSOR_PDR, "State Sensor PDR"},
        {PLDM_STATE_SENSOR_INITIALIZATION_PDR,
         "State Sensor Initialization PDR"},
        {PLDM_SENSOR_AUXILIARY_NAMES_PDR, "Sensor Auxiliary Names PDR"},
        {PLDM_OEM_UNIT_PDR, "OEM Unit PDR"},
        {PLDM_OEM_STATE_SET_PDR, "OEM State Set PDR"},
        {PLDM_NUMERIC_EFFECTER_PDR, "Numeric Effecter PDR"},
        {PLDM_NUMERIC_EFFECTER_INITIALIZATION_PDR,
         "Numeric Effecter Initialization PDR"},
        {PLDM_COMPACT_NUMERIC_SENSOR_PDR, "Compact Numeric Sensor PDR"},
        {PLDM_STATE_EFFECTER_PDR, "State Effecter PDR"},
        {PLDM_STATE_EFFECTER_INITIALIZATION_PDR,
         "State Effecter Initialization PDR"},
        {PLDM_EFFECTER_AUXILIARY_NAMES_PDR, "Effecter Auxiliary Names PDR"},
        {PLDM_EFFECTER_OEM_SEMANTIC_PDR, "Effecter OEM Semantic PDR"},
        {PLDM_PDR_ENTITY_ASSOCIATION, "Entity Association PDR"},
        {PLDM_ENTITY_AUXILIARY_NAMES_PDR, "Entity Auxiliary Names PDR"},
        {PLDM_OEM_ENTITY_ID_PDR, "OEM Entity ID PDR"},
        {PLDM_INTERRUPT_ASSOCIATION_PDR, "Interrupt Association PDR"},
        {PLDM_EVENT_LOG_PDR, "PLDM Event Log PDR"},
        {PLDM_PDR_FRU_RECORD_SET, "FRU Record Set PDR"},
        {PLDM_OEM_DEVICE_PDR, "OEM Device PDR"},
        {PLDM_OEM_PDR, "OEM PDR"},
    };

    static inline const std::map<uint8_t, std::string> setThermalTrip{
        {PLDM_STATE_SET_THERMAL_TRIP_STATUS_NORMAL, "Normal"},
        {PLDM_STATE_SET_THERMAL_TRIP_STATUS_THERMAL_TRIP, "Thermal Trip"}};

    static inline const std::map<uint8_t, std::string> setIdentifyState{
        {PLDM_STATE_SET_IDENTIFY_STATE_UNASSERTED, "Identify State Unasserted"},
        {PLDM_STATE_SET_IDENTIFY_STATE_ASSERTED, "Identify State Asserted"}};

    static inline const std::map<uint8_t, std::string> setBootProgressState{
        {PLDM_STATE_SET_BOOT_PROG_STATE_NOT_ACTIVE, "Boot Not Active"},
        {PLDM_STATE_SET_BOOT_PROG_STATE_COMPLETED, "Boot Completed"},
        {PLDM_STATE_SET_BOOT_PROG_STATE_MEM_INITIALIZATION,
         "Memory Initialization"},
        {PLDM_STATE_SET_BOOT_PROG_STATE_SEC_PROC_INITIALIZATION,
         "Secondary Processor(s) Initialization"},
        {PLDM_STATE_SET_BOOT_PROG_STATE_PCI_RESORUCE_CONFIG,
         "PCI Resource Configuration"},
        {PLDM_STATE_SET_BOOT_PROG_STATE_STARTING_OP_SYS,
         "Starting Operating System"},
        {PLDM_STATE_SET_BOOT_PROG_STATE_BASE_BOARD_INITIALIZATION,
         "Baseboard Initialization"},
        {PLDM_STATE_SET_BOOT_PROG_STATE_PRIMARY_PROC_INITIALIZATION,
         "Primary Processor Initialization"},
        {PLDM_STATE_SET_BOOT_PROG_STATE_OSSTART, "OSStart"}};

    static inline const std::map<uint8_t, std::string> setOpFaultStatus{
        {PLDM_STATE_SET_OPERATIONAL_FAULT_STATUS_NORMAL, "Normal"},
        {PLDM_STATE_SET_OPERATIONAL_FAULT_STATUS_ERROR, "Error"},
        {PLDM_STATE_SET_OPERATIONAL_FAULT_STATUS_NON_RECOVERABLE_ERROR,
         "Non Recoverable Error"}};

    static inline const std::map<uint8_t, std::string> setSysPowerState{
        {PLDM_STATE_SET_SYS_POWER_STATE_OFF_SOFT_GRACEFUL,
         "Off-Soft Graceful"}};

    static inline const std::map<uint8_t, std::string> setSWTerminationStatus{
        {PLDM_SW_TERM_GRACEFUL_RESTART_REQUESTED,
         "Graceful Restart Requested"}};

    static inline const std::map<uint8_t, std::string> setAvailability{
        {PLDM_STATE_SET_AVAILABILITY_REBOOTING, "Rebooting"}};

    static inline const std::map<uint8_t, std::string> setHealthState{
        {PLDM_STATE_SET_HEALTH_STATE_NORMAL, "Normal"},
        {PLDM_STATE_SET_HEALTH_STATE_NON_CRITICAL, "Non-Critical"},
        {PLDM_STATE_SET_HEALTH_STATE_CRITICAL, "Critical"},
        {PLDM_STATE_SET_HEALTH_STATE_FATAL, "Fatal"},
        {PLDM_STATE_SET_HEALTH_STATE_UPPER_NON_CRITICAL, "Upper Non-Critical"},
        {PLDM_STATE_SET_HEALTH_STATE_LOWER_NON_CRITICAL, "Lower Non-Critical"},
        {PLDM_STATE_SET_HEALTH_STATE_UPPER_CRITICAL, "Upper Critical"},
        {PLDM_STATE_SET_HEALTH_STATE_LOWER_CRITICAL, "Lower Critical"},
        {PLDM_STATE_SET_HEALTH_STATE_UPPER_FATAL, "Upper Fatal"},
        {PLDM_STATE_SET_HEALTH_STATE_LOWER_FATAL, "Lower Fatal"}};

    static inline const std::map<uint8_t, std::string>
        setOperationalRunningState{
            {PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_STARTING, "Starting"},
            {PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_STOPPING, "Stopping"},
            {PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_STOPPED, "Stopped"},
            {PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_IN_SERVICE,
             "In Service"},
            {PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_ABORTED, "Aborted"},
            {PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS_DORMANT, "Dormant"}};

    static inline const std::map<uint8_t, std::string> setPowerDeviceState{
        {PLDM_STATE_SET_ACPI_DEVICE_POWER_STATE_UNKNOWN, "Unknown"},
        {PLDM_STATE_SET_ACPI_DEVICE_POWER_STATE_FULLY_ON, "Fully-On"},
        {PLDM_STATE_SET_ACPI_DEVICE_POWER_STATE_INTERMEDIATE_1,
         "Intermediate State-1"},
        {PLDM_STATE_SET_ACPI_DEVICE_POWER_STATE_INTERMEDIATE_2,
         "Intermediate State-2"},
        {PLDM_STATE_SET_ACPI_DEVICE_POWER_STATE_OFF, "Off"}};

    static inline const std::map<uint16_t, const std::map<uint8_t, std::string>>
        populatePStateMaps{
            {PLDM_STATE_SET_THERMAL_TRIP, setThermalTrip},
            {PLDM_STATE_SET_IDENTIFY_STATE, setIdentifyState},
            {PLDM_STATE_SET_BOOT_PROGRESS, setBootProgressState},
            {PLDM_STATE_SET_OPERATIONAL_FAULT_STATUS, setOpFaultStatus},
            {PLDM_STATE_SET_SYSTEM_POWER_STATE, setSysPowerState},
            {PLDM_STATE_SET_SW_TERMINATION_STATUS, setSWTerminationStatus},
            {PLDM_STATE_SET_AVAILABILITY, setAvailability},
            {PLDM_STATE_SET_HEALTH_STATE, setHealthState},
            {PLDM_STATE_SET_OPERATIONAL_RUNNING_STATUS,
             setOperationalRunningState},
            {PLDM_STATE_SET_DEVICE_POWER_STATE, setPowerDeviceState},
        };

    const std::map<std::string, uint8_t> strToPdrType = {
        {"terminuslocator", PLDM_TERMINUS_LOCATOR_PDR},
        {"statesensor", PLDM_STATE_SENSOR_PDR},
        {"sensorauxname", PLDM_SENSOR_AUXILIARY_NAMES_PDR},
        {"numericeffecter", PLDM_NUMERIC_EFFECTER_PDR},
        {"efffecterauxname", PLDM_EFFECTER_AUXILIARY_NAMES_PDR},
        {"numericsensor", PLDM_NUMERIC_SENSOR_PDR},
        {"compactnumericsensor", PLDM_COMPACT_NUMERIC_SENSOR_PDR},
        {"stateeffecter", PLDM_STATE_EFFECTER_PDR},
        {"entityassociation", PLDM_PDR_ENTITY_ASSOCIATION},
        {"frurecord", PLDM_PDR_FRU_RECORD_SET},
        // Add other types
    };

    bool isLogicalBitSet(const uint16_t entity_type)
    {
        return entity_type & 0x8000;
    }

    uint16_t getEntityTypeForLogicalEntity(const uint16_t logical_entity_type)
    {
        return logical_entity_type & 0x7FFF;
    }

    std::string getEntityName(pldm::pdr::EntityType type)
    {
        uint16_t entityNumber = type;
        std::string entityName = "[Physical] ";

        if (isLogicalBitSet(type))
        {
            entityName = "[Logical] ";
            entityNumber = getEntityTypeForLogicalEntity(type);
        }

        try
        {
            return entityName + entityType.at(entityNumber);
        }
        catch (const std::out_of_range& e)
        {
            auto OemString =
                std::to_string(static_cast<unsigned>(entityNumber));
            if (type >= PLDM_OEM_ENTITY_TYPE_START &&
                type <= PLDM_OEM_ENTITY_TYPE_END)
            {
#ifdef OEM_IBM
                if (OemIBMEntityType.contains(entityNumber))
                {
                    return entityName + OemIBMEntityType.at(entityNumber) +
                           "(OEM)";
                }
#endif
                return entityName + OemString + "(OEM)";
            }
            return OemString;
        }
    }

    std::string getStateSetName(uint16_t id)
    {
        auto typeString = std::to_string(id);
        try
        {
            return stateSet.at(id) + "(" + typeString + ")";
        }
        catch (const std::out_of_range& e)
        {
            return typeString;
        }
    }

    std::vector<std::string> getStateSetPossibleStateNames(
        uint16_t stateId, const std::vector<uint8_t>& value)
    {
        std::vector<std::string> data{};

        for (const auto& s : value)
        {
            std::map<uint8_t, std::string> stateNameMaps;
            auto pstr = std::to_string(s);

#ifdef OEM_IBM
            if (stateId >= PLDM_OEM_STATE_SET_ID_START &&
                stateId < PLDM_OEM_STATE_SET_ID_END)
            {
                if (populateOemIBMStateMaps.contains(stateId))
                {
                    const std::map<uint8_t, std::string> stateNames =
                        populateOemIBMStateMaps.at(stateId);
                    stateNameMaps.insert(stateNames.begin(), stateNames.end());
                }
            }
#endif
            if (populatePStateMaps.contains(stateId))
            {
                const std::map<uint8_t, std::string> stateNames =
                    populatePStateMaps.at(stateId);
                stateNameMaps.insert(stateNames.begin(), stateNames.end());
            }
            if (stateNameMaps.contains(s))
            {
                data.push_back(stateNameMaps.at(s) + "(" + pstr + ")");
            }
            else
            {
                data.push_back(pstr);
            }
        }
        return data;
    }

    std::string getPDRType(uint8_t type)
    {
        auto typeString = std::to_string(type);
        try
        {
            return pdrType.at(type);
        }
        catch (const std::out_of_range& e)
        {
            return typeString;
        }
    }

    void printCommonPDRHeader(const pldm_pdr_hdr* hdr, ordered_json& output)
    {
        output["recordHandle"] = hdr->record_handle;
        output["PDRHeaderVersion"] = unsigned(hdr->version);
        output["PDRType"] = getPDRType(hdr->type);
        output["recordChangeNumber"] = hdr->record_change_num;
        output["dataLength"] = hdr->length;
    }

    std::vector<uint8_t> printPossibleStates(uint8_t possibleStatesSize,
                                             const bitfield8_t* states)
    {
        uint8_t possibleStatesPos{};
        std::vector<uint8_t> data{};
        auto printStates = [&possibleStatesPos, &data](const bitfield8_t& val) {
            std::stringstream pstates;
            for (int i = 0; i < CHAR_BIT; i++)
            {
                if (val.byte & (1 << i))
                {
                    pstates << (possibleStatesPos * CHAR_BIT + i);
                    data.push_back(
                        static_cast<uint8_t>(std::stoi(pstates.str())));
                    pstates.str("");
                }
            }
            possibleStatesPos++;
        };
        std::for_each(states, states + possibleStatesSize, printStates);
        return data;
    }

    void printStateSensorPDR(const uint8_t* data, ordered_json& output)
    {
        auto pdr = reinterpret_cast<const pldm_state_sensor_pdr*>(data);
        output["PLDMTerminusHandle"] = pdr->terminus_handle;
        output["sensorID"] = pdr->sensor_id;
        output["entityType"] = getEntityName(pdr->entity_type);
        output["entityInstanceNumber"] = pdr->entity_instance;
        output["containerID"] = pdr->container_id;
        output["sensorInit"] = sensorInit[pdr->sensor_init];
        output["sensorAuxiliaryNamesPDR"] =
            (pdr->sensor_auxiliary_names_pdr ? true : false);
        output["compositeSensorCount"] = unsigned(pdr->composite_sensor_count);

        auto statesPtr = pdr->possible_states;
        auto compCount = pdr->composite_sensor_count;

        while (compCount--)
        {
            auto state = reinterpret_cast<const state_sensor_possible_states*>(
                statesPtr);
            output.emplace(("stateSetID[" + std::to_string(compCount) + "]"),
                           getStateSetName(state->state_set_id));
            output.emplace(
                ("possibleStatesSize[" + std::to_string(compCount) + "]"),
                state->possible_states_size);
            output.emplace(
                ("possibleStates[" + std::to_string(compCount) + "]"),
                getStateSetPossibleStateNames(
                    state->state_set_id,
                    printPossibleStates(state->possible_states_size,
                                        state->states)));

            if (compCount)
            {
                statesPtr += sizeof(state_sensor_possible_states) +
                             state->possible_states_size - 1;
            }
        }
    }

    void printPDRFruRecordSet(uint8_t* data, ordered_json& output)
    {
        if (data == NULL)
        {
            return;
        }

        data += sizeof(pldm_pdr_hdr);
        pldm_pdr_fru_record_set* pdr =
            reinterpret_cast<pldm_pdr_fru_record_set*>(data);
        if (!pdr)
        {
            std::cerr << "Failed to get the FRU record set PDR" << std::endl;
            return;
        }

        output["PLDMTerminusHandle"] = unsigned(pdr->terminus_handle);
        output["FRURecordSetIdentifier"] = unsigned(pdr->fru_rsi);
        output["entityType"] = getEntityName(pdr->entity_type);
        output["entityInstanceNumber"] = unsigned(pdr->entity_instance);
        output["containerID"] = unsigned(pdr->container_id);
    }

    void printPDREntityAssociation(uint8_t* data, ordered_json& output)
    {
        const std::map<uint8_t, const char*> assocationType = {
            {PLDM_ENTITY_ASSOCIAION_PHYSICAL, "Physical"},
            {PLDM_ENTITY_ASSOCIAION_LOGICAL, "Logical"},
        };

        if (data == NULL)
        {
            return;
        }

        data += sizeof(pldm_pdr_hdr);
        pldm_pdr_entity_association* pdr =
            reinterpret_cast<pldm_pdr_entity_association*>(data);
        if (!pdr)
        {
            std::cerr << "Failed to get the PDR eneity association"
                      << std::endl;
            return;
        }

        output["containerID"] = int(pdr->container_id);
        if (assocationType.contains(pdr->association_type))
        {
            output["associationType"] =
                assocationType.at(pdr->association_type);
        }
        else
        {
            std::cout << "Get associationType failed.\n";
        }
        output["containerEntityType"] =
            getEntityName(pdr->container.entity_type);
        output["containerEntityInstanceNumber"] =
            int(pdr->container.entity_instance_num);
        output["containerEntityContainerID"] =
            int(pdr->container.entity_container_id);
        output["containedEntityCount"] =
            static_cast<unsigned>(pdr->num_children);

        auto child = reinterpret_cast<pldm_entity*>(&pdr->children[0]);
        for (int i = 0; i < pdr->num_children; ++i)
        {
            output.emplace("containedEntityType[" + std::to_string(i + 1) + "]",
                           getEntityName(child->entity_type));
            output.emplace("containedEntityInstanceNumber[" +
                               std::to_string(i + 1) + "]",
                           unsigned(child->entity_instance_num));
            output.emplace("containedEntityContainerID[" +
                               std::to_string(i + 1) + "]",
                           unsigned(child->entity_container_id));

            ++child;
        }
    }

    /** @brief Format the Sensor/Effecter Aux Name PDR types to json output
     *
     *  @param[in] data - reference to the Sensor/Effecter Aux Name PDR
     *  @param[out] output - PDRs data fields in Json format
     */
    void printAuxNamePDR(uint8_t* data, ordered_json& output)
    {
        constexpr uint8_t nullTerminator = 0;
        struct pldm_effecter_aux_name_pdr* auxNamePdr =
            (struct pldm_effecter_aux_name_pdr*)data;

        if (!auxNamePdr)
        {
            std::cerr << "Failed to get Aux Name PDR" << std::endl;
            return;
        }

        std::string sPrefix = "effecter";
        if (auxNamePdr->hdr.type == PLDM_SENSOR_AUXILIARY_NAMES_PDR)
        {
            sPrefix = "sensor";
        }
        output["terminusHandle"] = int(auxNamePdr->terminus_handle);
        output[sPrefix + "Id"] = int(auxNamePdr->effecter_id);
        output[sPrefix + "Count"] = int(auxNamePdr->effecter_count);

        const uint8_t* ptr = auxNamePdr->effecter_names;
        for (auto i : std::views::iota(0, (int)auxNamePdr->effecter_count))
        {
            const uint8_t nameStringCount = static_cast<uint8_t>(*ptr);
            ptr += sizeof(uint8_t);
            for (auto j : std::views::iota(0, (int)nameStringCount))
            {
                std::string nameLanguageTagKey =
                    sPrefix + std::to_string(j) + "_nameLanguageTag" +
                    std::to_string(i);
                std::string entityAuxNameKey =
                    sPrefix + std::to_string(j) + "_entityAuxName" +
                    std::to_string(i);
                std::string nameLanguageTag(reinterpret_cast<const char*>(ptr),
                                            0, PLDM_STR_UTF_8_MAX_LEN);
                ptr += nameLanguageTag.size() + sizeof(nullTerminator);
                std::u16string u16NameString(
                    reinterpret_cast<const char16_t*>(ptr), 0,
                    PLDM_STR_UTF_16_MAX_LEN);
                ptr += (u16NameString.size() + sizeof(nullTerminator)) *
                       sizeof(uint16_t);
                std::transform(u16NameString.cbegin(), u16NameString.cend(),
                               u16NameString.begin(),
                               [](uint16_t utf16) { return be16toh(utf16); });
                std::string nameString =
                    std::wstring_convert<std::codecvt_utf8_utf16<char16_t>,
                                         char16_t>{}
                        .to_bytes(u16NameString);
                output[nameLanguageTagKey] = nameLanguageTag;
                output[entityAuxNameKey] = nameString;
            }
        }
    }

    void printNumericEffecterPDR(uint8_t* data, ordered_json& output)
    {
        struct pldm_numeric_effecter_value_pdr* pdr =
            (struct pldm_numeric_effecter_value_pdr*)data;
        if (!pdr)
        {
            std::cerr << "Failed to get numeric effecter PDR" << std::endl;
            return;
        }

        output["PLDMTerminusHandle"] = int(pdr->terminus_handle);
        output["effecterID"] = int(pdr->effecter_id);
        output["entityType"] = int(pdr->entity_type);
        output["entityInstanceNumber"] = int(pdr->entity_instance);
        output["containerID"] = int(pdr->container_id);
        output["effecterSemanticID"] = int(pdr->effecter_semantic_id);
        output["effecterInit"] = unsigned(pdr->effecter_init);
        output["effecterAuxiliaryNames"] =
            (unsigned(pdr->effecter_auxiliary_names) ? true : false);
        output["baseUnit"] = unsigned(pdr->base_unit);
        output["unitModifier"] = unsigned(pdr->unit_modifier);
        output["rateUnit"] = unsigned(pdr->rate_unit);
        output["baseOEMUnitHandle"] = unsigned(pdr->base_oem_unit_handle);
        output["auxUnit"] = unsigned(pdr->aux_unit);
        output["auxUnitModifier"] = unsigned(pdr->aux_unit_modifier);
        output["auxrateUnit"] = unsigned(pdr->aux_rate_unit);
        output["auxOEMUnitHandle"] = unsigned(pdr->aux_oem_unit_handle);
        output["isLinear"] = (unsigned(pdr->is_linear) ? true : false);
        output["effecterDataSize"] = unsigned(pdr->effecter_data_size);
        output["resolution"] = unsigned(pdr->resolution);
        output["offset"] = unsigned(pdr->offset);
        output["accuracy"] = unsigned(pdr->accuracy);
        output["plusTolerance"] = unsigned(pdr->plus_tolerance);
        output["minusTolerance"] = unsigned(pdr->minus_tolerance);
        output["stateTransitionInterval"] =
            unsigned(pdr->state_transition_interval);
        output["TransitionInterval"] = unsigned(pdr->transition_interval);

        switch (pdr->effecter_data_size)
        {
            case PLDM_EFFECTER_DATA_SIZE_UINT8:
                output["maxSettable"] = unsigned(pdr->max_settable.value_u8);
                output["minSettable"] = unsigned(pdr->min_settable.value_u8);
                break;
            case PLDM_EFFECTER_DATA_SIZE_SINT8:
                output["maxSettable"] = unsigned(pdr->max_settable.value_s8);
                output["minSettable"] = unsigned(pdr->min_settable.value_s8);
                break;
            case PLDM_EFFECTER_DATA_SIZE_UINT16:
                output["maxSettable"] = unsigned(pdr->max_settable.value_u16);
                output["minSettable"] = unsigned(pdr->min_settable.value_u16);
                break;
            case PLDM_EFFECTER_DATA_SIZE_SINT16:
                output["maxSettable"] = unsigned(pdr->max_settable.value_s16);
                output["minSettable"] = unsigned(pdr->min_settable.value_s16);
                break;
            case PLDM_EFFECTER_DATA_SIZE_UINT32:
                output["maxSettable"] = unsigned(pdr->max_settable.value_u32);
                output["minSettable"] = unsigned(pdr->min_settable.value_u32);
                break;
            case PLDM_EFFECTER_DATA_SIZE_SINT32:
                output["maxSettable"] = unsigned(pdr->max_settable.value_s32);
                output["minSettable"] = unsigned(pdr->min_settable.value_s32);
                break;
            default:
                break;
        }

        output["rangeFieldFormat"] = unsigned(pdr->range_field_format);
        output["rangeFieldSupport"] = unsigned(pdr->range_field_support.byte);

        switch (pdr->range_field_format)
        {
            case PLDM_RANGE_FIELD_FORMAT_UINT8:
                output["nominalValue"] = unsigned(pdr->nominal_value.value_u8);
                output["normalMax"] = unsigned(pdr->normal_max.value_u8);
                output["normalMin"] = unsigned(pdr->normal_min.value_u8);
                output["ratedMax"] = unsigned(pdr->rated_max.value_u8);
                output["ratedMin"] = unsigned(pdr->rated_min.value_u8);
                break;
            case PLDM_RANGE_FIELD_FORMAT_SINT8:
                output["nominalValue"] = unsigned(pdr->nominal_value.value_s8);
                output["normalMax"] = unsigned(pdr->normal_max.value_s8);
                output["normalMin"] = unsigned(pdr->normal_min.value_s8);
                output["ratedMax"] = unsigned(pdr->rated_max.value_s8);
                output["ratedMin"] = unsigned(pdr->rated_min.value_s8);
                break;
            case PLDM_RANGE_FIELD_FORMAT_UINT16:
                output["nominalValue"] = unsigned(pdr->nominal_value.value_u16);
                output["normalMax"] = unsigned(pdr->normal_max.value_u16);
                output["normalMin"] = unsigned(pdr->normal_min.value_u16);
                output["ratedMax"] = unsigned(pdr->rated_max.value_u16);
                output["ratedMin"] = unsigned(pdr->rated_min.value_u16);
                break;
            case PLDM_RANGE_FIELD_FORMAT_SINT16:
                output["nominalValue"] = unsigned(pdr->nominal_value.value_s16);
                output["normalMax"] = unsigned(pdr->normal_max.value_s16);
                output["normalMin"] = unsigned(pdr->normal_min.value_s16);
                output["ratedMax"] = unsigned(pdr->rated_max.value_s16);
                output["ratedMin"] = unsigned(pdr->rated_min.value_s16);
                break;
            case PLDM_RANGE_FIELD_FORMAT_UINT32:
                output["nominalValue"] = unsigned(pdr->nominal_value.value_u32);
                output["normalMax"] = unsigned(pdr->normal_max.value_u32);
                output["normalMin"] = unsigned(pdr->normal_min.value_u32);
                output["ratedMax"] = unsigned(pdr->rated_max.value_u32);
                output["ratedMin"] = unsigned(pdr->rated_min.value_u32);
                break;
            case PLDM_RANGE_FIELD_FORMAT_SINT32:
                output["nominalValue"] = unsigned(pdr->nominal_value.value_s32);
                output["normalMax"] = unsigned(pdr->normal_max.value_s32);
                output["normalMin"] = unsigned(pdr->normal_min.value_s32);
                output["ratedMax"] = unsigned(pdr->rated_max.value_s32);
                output["ratedMin"] = unsigned(pdr->rated_min.value_s32);
                break;
            case PLDM_RANGE_FIELD_FORMAT_REAL32:
                output["nominalValue"] = unsigned(pdr->nominal_value.value_f32);
                output["normalMax"] = unsigned(pdr->normal_max.value_f32);
                output["normalMin"] = unsigned(pdr->normal_min.value_f32);
                output["ratedMax"] = unsigned(pdr->rated_max.value_f32);
                output["ratedMin"] = unsigned(pdr->rated_min.value_f32);
                break;
            default:
                break;
        }
    }

    void printStateEffecterPDR(const uint8_t* data, ordered_json& output)
    {
        auto pdr = reinterpret_cast<const pldm_state_effecter_pdr*>(data);

        output["PLDMTerminusHandle"] = pdr->terminus_handle;
        output["effecterID"] = pdr->effecter_id;
        output["entityType"] = getEntityName(pdr->entity_type);
        output["entityInstanceNumber"] = pdr->entity_instance;
        output["containerID"] = pdr->container_id;
        output["effecterSemanticID"] = pdr->effecter_semantic_id;
        output["effecterInit"] = effecterInit[pdr->effecter_init];
        output["effecterDescriptionPDR"] =
            (pdr->has_description_pdr ? true : false);
        output["compositeEffecterCount"] =
            unsigned(pdr->composite_effecter_count);

        auto statesPtr = pdr->possible_states;
        auto compEffCount = pdr->composite_effecter_count;

        while (compEffCount--)
        {
            auto state =
                reinterpret_cast<const state_effecter_possible_states*>(
                    statesPtr);
            output.emplace(("stateSetID[" + std::to_string(compEffCount) + "]"),
                           getStateSetName(state->state_set_id));
            output.emplace(
                ("possibleStatesSize[" + std::to_string(compEffCount) + "]"),
                state->possible_states_size);
            output.emplace(
                ("possibleStates[" + std::to_string(compEffCount) + "]"),
                getStateSetPossibleStateNames(
                    state->state_set_id,
                    printPossibleStates(state->possible_states_size,
                                        state->states)));

            if (compEffCount)
            {
                statesPtr += sizeof(state_effecter_possible_states) +
                             state->possible_states_size - 1;
            }
        }
    }

    bool checkTerminusHandle(const uint8_t* data,
                             std::optional<uint16_t> terminusHandle)
    {
        struct pldm_pdr_hdr* pdr = (struct pldm_pdr_hdr*)data;

        if (pdr->type == PLDM_TERMINUS_LOCATOR_PDR)
        {
            auto tlpdr =
                reinterpret_cast<const pldm_terminus_locator_pdr*>(data);

            if (tlpdr->terminus_handle != terminusHandle)
            {
                return true;
            }
        }
        else if (pdr->type == PLDM_STATE_SENSOR_PDR)
        {
            auto sensor = reinterpret_cast<const pldm_state_sensor_pdr*>(data);

            if (sensor->terminus_handle != terminusHandle)
            {
                return true;
            }
        }
        else if (pdr->type == PLDM_NUMERIC_EFFECTER_PDR)
        {
            auto numericEffecter =
                reinterpret_cast<const pldm_numeric_effecter_value_pdr*>(data);

            if (numericEffecter->terminus_handle != terminusHandle)
            {
                return true;
            }
        }

        else if (pdr->type == PLDM_STATE_EFFECTER_PDR)
        {
            auto stateEffecter =
                reinterpret_cast<const pldm_state_effecter_pdr*>(data);
            if (stateEffecter->terminus_handle != terminusHandle)
            {
                return true;
            }
        }
        else if (pdr->type == PLDM_PDR_FRU_RECORD_SET)
        {
            data += sizeof(pldm_pdr_hdr);
            auto fru = reinterpret_cast<const pldm_pdr_fru_record_set*>(data);

            if (fru->terminus_handle != terminusHandle)
            {
                return true;
            }
        }
        else
        {
            // Entity association PDRs does not have terminus handle
            return true;
        }

        return false;
    }

    void printTerminusLocatorPDR(const uint8_t* data, ordered_json& output)
    {
        const std::array<std::string_view, 4> terminusLocatorType = {
            "UID", "MCTP_EID", "SMBusRelative", "systemSoftware"};

        auto pdr = reinterpret_cast<const pldm_terminus_locator_pdr*>(data);

        output["PLDMTerminusHandle"] = pdr->terminus_handle;
        output["validity"] = (pdr->validity ? "valid" : "notValid");
        output["TID"] = unsigned(pdr->tid);
        output["containerID"] = pdr->container_id;
        output["terminusLocatorType"] =
            terminusLocatorType[pdr->terminus_locator_type];
        output["terminusLocatorValueSize"] =
            unsigned(pdr->terminus_locator_value_size);

        if (pdr->terminus_locator_type == PLDM_TERMINUS_LOCATOR_TYPE_MCTP_EID)
        {
            auto locatorValue =
                reinterpret_cast<const pldm_terminus_locator_type_mctp_eid*>(
                    pdr->terminus_locator_value);
            output["EID"] = unsigned(locatorValue->eid);
        }
    }

    std::optional<uint16_t> getTerminusHandle(uint8_t* data,
                                              std::optional<uint8_t> tid)
    {
        struct pldm_pdr_hdr* pdr = (struct pldm_pdr_hdr*)data;
        if (pdr->type == PLDM_TERMINUS_LOCATOR_PDR)
        {
            auto pdr = reinterpret_cast<const pldm_terminus_locator_pdr*>(data);
            if (pdr->tid == tid)
            {
                handleFound = true;
                return pdr->terminus_handle;
            }
        }
        return std::nullopt;
    }

    /** @brief Format the Numeric Sensor PDR types to json output
     *
     *  @param[in] data - reference to the Numeric Sensor PDR
     *  @param[in] data_length - number of PDR data bytes
     *  @param[out] output - PDRs data fields in Json format
     */
    void printNumericSensorPDR(const uint8_t* data, const uint16_t data_length,
                               ordered_json& output)
    {
        struct pldm_numeric_sensor_value_pdr pdr;
        int rc =
            decode_numeric_sensor_pdr_data(data, (size_t)data_length, &pdr);
        if (rc != PLDM_SUCCESS)
        {
            std::cerr << "Failed to get numeric sensor PDR" << std::endl;
            return;
        }
        output["PLDMTerminusHandle"] = pdr.terminus_handle;
        output["sensorID"] = pdr.sensor_id;
        output["entityType"] = getEntityName(pdr.entity_type);
        output["entityInstanceNumber"] = pdr.entity_instance_num;
        output["containerID"] = pdr.container_id;
        output["sensorInit"] = pdr.sensor_init;
        output["sensorAuxiliaryNamesPDR"] =
            (pdr.sensor_auxiliary_names_pdr) ? true : false;
        output["baseUnit"] = pdr.base_unit;
        output["unitModifier"] = pdr.unit_modifier;
        output["rateUnit"] = pdr.rate_unit;
        output["baseOEMUnitHandle"] = pdr.base_oem_unit_handle;
        output["auxUnit"] = pdr.aux_unit;
        output["auxUnitModifier"] = pdr.aux_unit_modifier;
        output["auxrateUnit"] = pdr.aux_rate_unit;
        output["rel"] = pdr.rel;
        output["auxOEMUnitHandle"] = pdr.aux_oem_unit_handle;
        output["isLinear"] = (pdr.is_linear) ? true : false;
        output["sensorDataSize"] = pdr.sensor_data_size;
        output["resolution"] = pdr.resolution;
        output["offset"] = pdr.offset;
        output["accuracy"] = pdr.accuracy;
        output["plusTolerance"] = pdr.plus_tolerance;
        output["minusTolerance"] = pdr.minus_tolerance;

        switch (pdr.sensor_data_size)
        {
            case PLDM_SENSOR_DATA_SIZE_UINT8:
                output["hysteresis"] = pdr.hysteresis.value_u8;
                output["maxReadable"] = pdr.max_readable.value_u8;
                output["minReadable"] = pdr.min_readable.value_u8;
                break;
            case PLDM_SENSOR_DATA_SIZE_SINT8:
                output["hysteresis"] = pdr.hysteresis.value_s8;
                output["maxReadable"] = pdr.max_readable.value_s8;
                output["minReadable"] = pdr.min_readable.value_s8;
                break;
            case PLDM_SENSOR_DATA_SIZE_UINT16:
                output["hysteresis"] = pdr.hysteresis.value_u16;
                output["maxReadable"] = pdr.max_readable.value_u16;
                output["minReadable"] = pdr.min_readable.value_u16;
                break;
            case PLDM_SENSOR_DATA_SIZE_SINT16:
                output["hysteresis"] = pdr.hysteresis.value_s16;
                output["maxReadable"] = pdr.max_readable.value_s16;
                output["minReadable"] = pdr.min_readable.value_s16;
                break;
            case PLDM_SENSOR_DATA_SIZE_UINT32:
                output["hysteresis"] = pdr.hysteresis.value_u32;
                output["maxReadable"] = pdr.max_readable.value_u32;
                output["minReadable"] = pdr.min_readable.value_u32;
                break;
            case PLDM_SENSOR_DATA_SIZE_SINT32:
                output["hysteresis"] = pdr.hysteresis.value_s32;
                output["maxReadable"] = pdr.max_readable.value_s32;
                output["minReadable"] = pdr.min_readable.value_s32;
                break;
            default:
                break;
        }

        output["supportedThresholds"] = pdr.supported_thresholds.byte;
        output["thresholAndHysteresisVolatility"] =
            pdr.threshold_and_hysteresis_volatility.byte;
        output["stateTransitionInterval"] = pdr.state_transition_interval;
        output["updateInterval"] = pdr.update_interval;
        output["rangeFieldFormat"] = pdr.range_field_format;
        output["rangeFieldSupport"] = pdr.range_field_support.byte;

        switch (pdr.range_field_format)
        {
            case PLDM_RANGE_FIELD_FORMAT_UINT8:
                output["nominalValue"] = pdr.nominal_value.value_u8;
                output["normalMax"] = pdr.normal_max.value_u8;
                output["normalMin"] = pdr.normal_min.value_u8;
                output["warningHigh"] = pdr.warning_high.value_u8;
                output["warningLow"] = pdr.warning_low.value_u8;
                output["criticalHigh"] = pdr.critical_high.value_u8;
                output["criticalLow"] = pdr.critical_low.value_u8;
                output["fatalHigh"] = pdr.fatal_high.value_u8;
                output["fatalLeow"] = pdr.fatal_low.value_u8;
                break;
            case PLDM_RANGE_FIELD_FORMAT_SINT8:
                output["nominalValue"] = pdr.nominal_value.value_s8;
                output["normalMax"] = pdr.normal_max.value_s8;
                output["normalMin"] = pdr.normal_min.value_s8;
                output["warningHigh"] = pdr.warning_high.value_s8;
                output["warningLow"] = pdr.warning_low.value_s8;
                output["criticalHigh"] = pdr.critical_high.value_s8;
                output["criticalLow"] = pdr.critical_low.value_s8;
                output["fatalHigh"] = pdr.fatal_high.value_s8;
                output["fatalLeow"] = pdr.fatal_low.value_s8;
                break;
            case PLDM_RANGE_FIELD_FORMAT_UINT16:
                output["nominalValue"] = pdr.nominal_value.value_u16;
                output["normalMax"] = pdr.normal_max.value_u16;
                output["normalMin"] = pdr.normal_min.value_u16;
                output["warningHigh"] = pdr.warning_high.value_u16;
                output["warningLow"] = pdr.warning_low.value_u16;
                output["criticalHigh"] = pdr.critical_high.value_u16;
                output["criticalLow"] = pdr.critical_low.value_u16;
                output["fatalHigh"] = pdr.fatal_high.value_u16;
                output["fatalLeow"] = pdr.fatal_low.value_u16;
                break;
            case PLDM_RANGE_FIELD_FORMAT_SINT16:
                output["nominalValue"] = pdr.nominal_value.value_s16;
                output["normalMax"] = pdr.normal_max.value_s16;
                output["normalMin"] = pdr.normal_min.value_s16;
                output["warningHigh"] = pdr.warning_high.value_s16;
                output["warningLow"] = pdr.warning_low.value_s16;
                output["criticalHigh"] = pdr.critical_high.value_s16;
                output["criticalLow"] = pdr.critical_low.value_s16;
                output["fatalHigh"] = pdr.fatal_high.value_s16;
                output["fatalLeow"] = pdr.fatal_low.value_s16;
                break;
            case PLDM_RANGE_FIELD_FORMAT_UINT32:
                output["nominalValue"] = pdr.nominal_value.value_u32;
                output["normalMax"] = pdr.normal_max.value_u32;
                output["normalMin"] = pdr.normal_min.value_u32;
                output["warningHigh"] = pdr.warning_high.value_u32;
                output["warningLow"] = pdr.warning_low.value_u32;
                output["criticalHigh"] = pdr.critical_high.value_u32;
                output["criticalLow"] = pdr.critical_low.value_u32;
                output["fatalHigh"] = pdr.fatal_high.value_u32;
                output["fatalLeow"] = pdr.fatal_low.value_u32;
                break;
            case PLDM_RANGE_FIELD_FORMAT_SINT32:
                output["nominalValue"] = pdr.nominal_value.value_s32;
                output["normalMax"] = pdr.normal_max.value_s32;
                output["normalMin"] = pdr.normal_min.value_s32;
                output["warningHigh"] = pdr.warning_high.value_s32;
                output["warningLow"] = pdr.warning_low.value_s32;
                output["criticalHigh"] = pdr.critical_high.value_s32;
                output["criticalLow"] = pdr.critical_low.value_s32;
                output["fatalHigh"] = pdr.fatal_high.value_s32;
                output["fatalLeow"] = pdr.fatal_low.value_s32;
                break;
            case PLDM_RANGE_FIELD_FORMAT_REAL32:
                output["nominalValue"] = pdr.nominal_value.value_f32;
                output["normalMax"] = pdr.normal_max.value_f32;
                output["normalMin"] = pdr.normal_min.value_f32;
                output["warningHigh"] = pdr.warning_high.value_f32;
                output["warningLow"] = pdr.warning_low.value_f32;
                output["criticalHigh"] = pdr.critical_high.value_f32;
                output["criticalLow"] = pdr.critical_low.value_f32;
                output["fatalHigh"] = pdr.fatal_high.value_f32;
                output["fatalLeow"] = pdr.fatal_low.value_f32;
                break;
            default:
                break;
        }
    }

    /** @brief Format the Compact Numeric Sensor PDR types to json output
     *
     *  @param[in] data - reference to the Compact Numeric Sensor PDR
     *  @param[out] output - PDRs data fields in Json format
     */
    void printCompactNumericSensorPDR(const uint8_t* data, ordered_json& output)
    {
        struct pldm_compact_numeric_sensor_pdr* pdr =
            (struct pldm_compact_numeric_sensor_pdr*)data;
        if (!pdr)
        {
            std::cerr << "Failed to get compact numeric sensor PDR"
                      << std::endl;
            return;
        }
        output["PLDMTerminusHandle"] = int(pdr->terminus_handle);
        output["sensorID"] = int(pdr->sensor_id);
        output["entityType"] = getEntityName(pdr->entity_type);
        output["entityInstanceNumber"] = int(pdr->entity_instance);
        output["containerID"] = int(pdr->container_id);
        output["sensorNameStringByteLength"] = int(pdr->sensor_name_length);
        if (pdr->sensor_name_length == 0)
        {
            output["Name"] = std::format("PLDM_Device_TID{}_SensorId{}",
                                         unsigned(pdr->terminus_handle),
                                         unsigned(pdr->sensor_id));
        }
        else
        {
            std::string sTemp(reinterpret_cast<const char*>(pdr->sensor_name),
                              pdr->sensor_name_length);
            output["Name"] = sTemp;
        }
        output["baseUnit"] = unsigned(pdr->base_unit);
        output["unitModifier"] = signed(pdr->unit_modifier);
        output["occurrenceRate"] = unsigned(pdr->occurrence_rate);
        output["rangeFieldSupport"] = unsigned(pdr->range_field_support.byte);
        if (pdr->range_field_support.bits.bit0)
        {
            output["warningHigh"] = int(pdr->warning_high);
        }
        if (pdr->range_field_support.bits.bit1)
        {
            output["warningLow"] = int(pdr->warning_low);
        }
        if (pdr->range_field_support.bits.bit2)
        {
            output["criticalHigh"] = int(pdr->critical_high);
        }
        if (pdr->range_field_support.bits.bit3)
        {
            output["criticalLow"] = int(pdr->critical_low);
        }
        if (pdr->range_field_support.bits.bit4)
        {
            output["fatalHigh"] = int(pdr->fatal_high);
        }
        if (pdr->range_field_support.bits.bit5)
        {
            output["fatalLow"] = int(pdr->fatal_low);
        }
    }

    void printPDRMsg(uint32_t& nextRecordHndl, const uint16_t respCnt,
                     uint8_t* data, std::optional<uint16_t> terminusHandle)
    {
        if (data == NULL)
        {
            std::cerr << "Failed to get PDR message" << std::endl;
            return;
        }

        ordered_json output;
        output["nextRecordHandle"] = nextRecordHndl;
        output["responseCount"] = respCnt;

        struct pldm_pdr_hdr* pdr = (struct pldm_pdr_hdr*)data;
        if (!pdr)
        {
            return;
        }

        if (!pdrRecType.empty())
        {
            // Need to return if the requested PDR type
            // is not supported
            if (!strToPdrType.contains(pdrRecType))
            {
                std::cerr << "PDR type '" << pdrRecType
                          << "' is not supported or invalid\n";
                // PDR type not supported, setting next record handle to
                // 0 to avoid looping through all PDR records
                nextRecordHndl = 0;
                return;
            }

            // Do not print PDR record if the current record
            // PDR type does not match with requested type
            if (pdr->type != strToPdrType.at(pdrRecType))
            {
                return;
            }
        }

        if (pdrTerminus.has_value())
        {
            if (checkTerminusHandle(data, terminusHandle))
            {
                std::cerr << "The Terminus handle doesn't match return"
                          << std::endl;
                return;
            }
        }

        printCommonPDRHeader(pdr, output);

        switch (pdr->type)
        {
            case PLDM_TERMINUS_LOCATOR_PDR:
                printTerminusLocatorPDR(data, output);
                break;
            case PLDM_STATE_SENSOR_PDR:
                printStateSensorPDR(data, output);
                break;
            case PLDM_NUMERIC_EFFECTER_PDR:
                printNumericEffecterPDR(data, output);
                break;
            case PLDM_NUMERIC_SENSOR_PDR:
                printNumericSensorPDR(data, respCnt, output);
                break;
            case PLDM_SENSOR_AUXILIARY_NAMES_PDR:
                printAuxNamePDR(data, output);
                break;
            case PLDM_EFFECTER_AUXILIARY_NAMES_PDR:
                printAuxNamePDR(data, output);
                break;
            case PLDM_STATE_EFFECTER_PDR:
                printStateEffecterPDR(data, output);
                break;
            case PLDM_PDR_ENTITY_ASSOCIATION:
                printPDREntityAssociation(data, output);
                break;
            case PLDM_PDR_FRU_RECORD_SET:
                printPDRFruRecordSet(data, output);
                break;
            case PLDM_COMPACT_NUMERIC_SENSOR_PDR:
                printCompactNumericSensorPDR(data, output);
                break;
            default:
                break;
        }
        pldmtool::helper::DisplayInJson(output);
    }

  private:
    bool optTIDSet = false;
    uint32_t recordHandle;
    bool allPDRs;
    std::string pdrRecType;
    std::optional<uint8_t> pdrTerminus;
    std::optional<uint16_t> terminusHandle;
    bool handleFound = false;
    CLI::Option* getPDRGroupOption = nullptr;
    uint32_t dataTransferHandle;
    uint8_t operationFlag;
    uint16_t requestCount;
    uint16_t recordChangeNumber;
    std::vector<uint8_t> recordData;
    bool nextPartRequired;
};

class SetStateEffecter : public CommandInterface
{
  public:
    ~SetStateEffecter() = default;
    SetStateEffecter() = delete;
    SetStateEffecter(const SetStateEffecter&) = delete;
    SetStateEffecter(SetStateEffecter&&) = default;
    SetStateEffecter& operator=(const SetStateEffecter&) = delete;
    SetStateEffecter& operator=(SetStateEffecter&&) = delete;

    // compositeEffecterCount(value: 0x01 to 0x08) * stateField(2)
    static constexpr auto maxEffecterDataSize = 16;

    // compositeEffecterCount(value: 0x01 to 0x08)
    static constexpr auto minEffecterCount = 1;
    static constexpr auto maxEffecterCount = 8;
    explicit SetStateEffecter(const char* type, const char* name,
                              CLI::App* app) : CommandInterface(type, name, app)
    {
        app->add_option(
               "-i, --id", effecterId,
               "A handle that is used to identify and access the effecter")
            ->required();
        app->add_option("-c, --count", effecterCount,
                        "The number of individual sets of effecter information")
            ->required();
        app->add_option(
               "-d,--data", effecterData,
               "Set effecter state data\n"
               "eg: requestSet0 effecterState0 noChange1 dummyState1 ...")
            ->required();
    }

    std::pair<int, std::vector<uint8_t>> createRequestMsg() override
    {
        std::vector<uint8_t> requestMsg(
            sizeof(pldm_msg_hdr) + PLDM_SET_STATE_EFFECTER_STATES_REQ_BYTES);
        auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());

        if (effecterCount > maxEffecterCount ||
            effecterCount < minEffecterCount)
        {
            std::cerr << "Request Message Error: effecterCount size "
                      << effecterCount << "is invalid\n";
            auto rc = PLDM_ERROR_INVALID_DATA;
            return {rc, requestMsg};
        }

        if (effecterData.size() > maxEffecterDataSize)
        {
            std::cerr << "Request Message Error: effecterData size "
                      << effecterData.size() << "is invalid\n";
            auto rc = PLDM_ERROR_INVALID_DATA;
            return {rc, requestMsg};
        }

        auto stateField = parseEffecterData(effecterData, effecterCount);
        if (!stateField)
        {
            std::cerr << "Failed to parse effecter data, effecterCount size "
                      << effecterCount << "\n";
            auto rc = PLDM_ERROR_INVALID_DATA;
            return {rc, requestMsg};
        }

        auto rc = encode_set_state_effecter_states_req(
            instanceId, effecterId, effecterCount, stateField->data(), request);
        return {rc, requestMsg};
    }

    void parseResponseMsg(pldm_msg* responsePtr, size_t payloadLength) override
    {
        uint8_t completionCode = 0;
        auto rc = decode_set_state_effecter_states_resp(
            responsePtr, payloadLength, &completionCode);

        if (rc != PLDM_SUCCESS || completionCode != PLDM_SUCCESS)
        {
            std::cerr << "Response Message Error: "
                      << "rc=" << rc << ",cc=" << (int)completionCode << "\n";
            return;
        }

        ordered_json data;
        data["Response"] = "SUCCESS";
        pldmtool::helper::DisplayInJson(data);
    }

  private:
    uint16_t effecterId;
    uint8_t effecterCount;
    std::vector<uint8_t> effecterData;
};

class SetNumericEffecterValue : public CommandInterface
{
  public:
    ~SetNumericEffecterValue() = default;
    SetNumericEffecterValue() = delete;
    SetNumericEffecterValue(const SetNumericEffecterValue&) = delete;
    SetNumericEffecterValue(SetNumericEffecterValue&&) = default;
    SetNumericEffecterValue& operator=(const SetNumericEffecterValue&) = delete;
    SetNumericEffecterValue& operator=(SetNumericEffecterValue&&) = delete;

    explicit SetNumericEffecterValue(const char* type, const char* name,
                                     CLI::App* app) :
        CommandInterface(type, name, app)
    {
        app->add_option(
               "-i, --id", effecterId,
               "A handle that is used to identify and access the effecter")
            ->required();
        app->add_option("-s, --size", effecterDataSize,
                        "The bit width and format of the setting value for the "
                        "effecter. enum value: {uint8, sint8, uint16, sint16, "
                        "uint32, sint32}\n")
            ->required();
        app->add_option("-d,--data", maxEffecterValue,
                        "The setting value of numeric effecter being "
                        "requested\n")
            ->required();
    }

    std::pair<int, std::vector<uint8_t>> createRequestMsg() override
    {
        std::vector<uint8_t> requestMsg(
            sizeof(pldm_msg_hdr) +
            PLDM_SET_NUMERIC_EFFECTER_VALUE_MIN_REQ_BYTES + 3);

        uint8_t* effecterValue = (uint8_t*)&maxEffecterValue;

        auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());
        size_t payload_length = PLDM_SET_NUMERIC_EFFECTER_VALUE_MIN_REQ_BYTES;

        if (effecterDataSize == PLDM_EFFECTER_DATA_SIZE_UINT16 ||
            effecterDataSize == PLDM_EFFECTER_DATA_SIZE_SINT16)
        {
            payload_length = PLDM_SET_NUMERIC_EFFECTER_VALUE_MIN_REQ_BYTES + 1;
        }
        if (effecterDataSize == PLDM_EFFECTER_DATA_SIZE_UINT32 ||
            effecterDataSize == PLDM_EFFECTER_DATA_SIZE_SINT32)
        {
            payload_length = PLDM_SET_NUMERIC_EFFECTER_VALUE_MIN_REQ_BYTES + 3;
        }
        auto rc = encode_set_numeric_effecter_value_req(
            0, effecterId, effecterDataSize, effecterValue, request,
            payload_length);

        return {rc, requestMsg};
    }

    void parseResponseMsg(pldm_msg* responsePtr, size_t payloadLength) override
    {
        uint8_t completionCode = 0;
        auto rc = decode_set_numeric_effecter_value_resp(
            responsePtr, payloadLength, &completionCode);

        if (rc != PLDM_SUCCESS || completionCode != PLDM_SUCCESS)
        {
            std::cerr << "Response Message Error: "
                      << "rc=" << rc << ",cc=" << (int)completionCode
                      << std::endl;
            return;
        }

        ordered_json data;
        data["Response"] = "SUCCESS";
        pldmtool::helper::DisplayInJson(data);
    }

  private:
    uint16_t effecterId;
    uint8_t effecterDataSize;
    uint64_t maxEffecterValue;
};

class GetStateSensorReadings : public CommandInterface
{
  public:
    ~GetStateSensorReadings() = default;
    GetStateSensorReadings() = delete;
    GetStateSensorReadings(const GetStateSensorReadings&) = delete;
    GetStateSensorReadings(GetStateSensorReadings&&) = default;
    GetStateSensorReadings& operator=(const GetStateSensorReadings&) = delete;
    GetStateSensorReadings& operator=(GetStateSensorReadings&&) = delete;

    explicit GetStateSensorReadings(const char* type, const char* name,
                                    CLI::App* app) :
        CommandInterface(type, name, app)
    {
        app->add_option(
               "-i, --sensor_id", sensorId,
               "Sensor ID that is used to identify and access the sensor")
            ->required();
        app->add_option("-r, --rearm", sensorRearm,
                        "Each bit location in this field corresponds to a "
                        "particular sensor")
            ->required();
    }

    std::pair<int, std::vector<uint8_t>> createRequestMsg() override
    {
        std::vector<uint8_t> requestMsg(
            sizeof(pldm_msg_hdr) + PLDM_GET_STATE_SENSOR_READINGS_REQ_BYTES);
        auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());

        uint8_t reserved = 0;
        bitfield8_t bf;
        bf.byte = sensorRearm;
        auto rc = encode_get_state_sensor_readings_req(instanceId, sensorId, bf,
                                                       reserved, request);

        return {rc, requestMsg};
    }

    void parseResponseMsg(pldm_msg* responsePtr, size_t payloadLength) override
    {
        uint8_t completionCode = 0;
        uint8_t compSensorCount = 0;
        std::array<get_sensor_state_field, 8> stateField{};
        auto rc = decode_get_state_sensor_readings_resp(
            responsePtr, payloadLength, &completionCode, &compSensorCount,
            stateField.data());

        if (rc != PLDM_SUCCESS || completionCode != PLDM_SUCCESS)
        {
            std::cerr << "Response Message Error: "
                      << "rc=" << rc << ",cc=" << (int)completionCode
                      << std::endl;
            return;
        }
        ordered_json output;
        output["compositeSensorCount"] = (int)compSensorCount;

        for (size_t i = 0; i < compSensorCount; i++)
        {
            if (sensorOpState.contains(stateField[i].sensor_op_state))
            {
                output.emplace(("sensorOpState[" + std::to_string(i) + "]"),
                               sensorOpState.at(stateField[i].sensor_op_state));
            }

            if (sensorPresState.contains(stateField[i].present_state))
            {
                output.emplace(("presentState[" + std::to_string(i) + "]"),
                               sensorPresState.at(stateField[i].present_state));
            }

            if (sensorPresState.contains(stateField[i].previous_state))
            {
                output.emplace(
                    ("previousState[" + std::to_string(i) + "]"),
                    sensorPresState.at(stateField[i].previous_state));
            }

            if (sensorPresState.contains(stateField[i].event_state))
            {
                output.emplace(("eventState[" + std::to_string(i) + "]"),
                               sensorPresState.at(stateField[i].event_state));
            }
        }

        pldmtool::helper::DisplayInJson(output);
    }

  private:
    uint16_t sensorId;
    uint8_t sensorRearm;
};

class GetSensorReading : public CommandInterface
{
  public:
    ~GetSensorReading() = default;
    GetSensorReading() = delete;
    GetSensorReading(const GetSensorReading&) = delete;
    GetSensorReading(GetSensorReading&&) = default;
    GetSensorReading& operator=(const GetSensorReading&) = delete;
    GetSensorReading& operator=(GetSensorReading&&) = delete;

    explicit GetSensorReading(const char* type, const char* name,
                              CLI::App* app) : CommandInterface(type, name, app)
    {
        app->add_option(
               "-i, --sensor_id", sensorId,
               "Sensor ID that is used to identify and access the sensor")
            ->required();
        app->add_option("-r, --rearm", rearm,
                        "Manually re-arm EventState after "
                        "responding to this request")
            ->required();
    }

    std::pair<int, std::vector<uint8_t>> createRequestMsg() override
    {
        std::vector<uint8_t> requestMsg(
            sizeof(pldm_msg_hdr) + PLDM_GET_SENSOR_READING_REQ_BYTES);
        auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());

        auto rc =
            encode_get_sensor_reading_req(instanceId, sensorId, rearm, request);

        return {rc, requestMsg};
    }

    void parseResponseMsg(pldm_msg* responsePtr, size_t payloadLength) override
    {
        uint8_t completionCode = 0;
        uint8_t sensorDataSize = 0;
        uint8_t sensorOperationalState = 0;
        uint8_t sensorEventMessageEnable = 0;
        uint8_t presentState = 0;
        uint8_t previousState = 0;
        uint8_t eventState = 0;
        std::array<uint8_t, sizeof(uint32_t)>
            presentReading{}; // maximum size for the present Value is uint32
                              // according to spec DSP0248

        auto rc = decode_get_sensor_reading_resp(
            responsePtr, payloadLength, &completionCode, &sensorDataSize,
            &sensorOperationalState, &sensorEventMessageEnable, &presentState,
            &previousState, &eventState, presentReading.data());

        if (rc != PLDM_SUCCESS || completionCode != PLDM_SUCCESS)
        {
            std::cerr << "Response Message Error: "
                      << "rc=" << rc << ",cc=" << (int)completionCode
                      << std::endl;
            return;
        }

        ordered_json output;
        output["sensorDataSize"] =
            getSensorState(sensorDataSize, &sensorDataSz);
        output["sensorOperationalState"] =
            getSensorState(sensorOperationalState, &sensorOpState);
        output["sensorEventMessageEnable"] =
            getSensorState(sensorEventMessageEnable, &sensorEventMsgEnable);
        output["presentState"] = getSensorState(presentState, &sensorPresState);
        output["previousState"] =
            getSensorState(previousState, &sensorPresState);
        output["eventState"] = getSensorState(eventState, &sensorPresState);

        switch (sensorDataSize)
        {
            case PLDM_SENSOR_DATA_SIZE_UINT8:
            {
                output["presentReading"] =
                    *(reinterpret_cast<uint8_t*>(presentReading.data()));
                break;
            }
            case PLDM_SENSOR_DATA_SIZE_SINT8:
            {
                output["presentReading"] =
                    *(reinterpret_cast<int8_t*>(presentReading.data()));
                break;
            }
            case PLDM_SENSOR_DATA_SIZE_UINT16:
            {
                output["presentReading"] =
                    *(reinterpret_cast<uint16_t*>(presentReading.data()));
                break;
            }
            case PLDM_SENSOR_DATA_SIZE_SINT16:
            {
                output["presentReading"] =
                    *(reinterpret_cast<int16_t*>(presentReading.data()));
                break;
            }
            case PLDM_SENSOR_DATA_SIZE_UINT32:
            {
                output["presentReading"] =
                    *(reinterpret_cast<uint32_t*>(presentReading.data()));
                break;
            }
            case PLDM_SENSOR_DATA_SIZE_SINT32:
            {
                output["presentReading"] =
                    *(reinterpret_cast<int32_t*>(presentReading.data()));
                break;
            }
            default:
            {
                std::cerr << "Unknown Sensor Data Size : "
                          << static_cast<int>(sensorDataSize) << std::endl;
                break;
            }
        }

        pldmtool::helper::DisplayInJson(output);
    }

  private:
    uint16_t sensorId;
    uint8_t rearm;

    const std::map<uint8_t, std::string> sensorDataSz = {
        {PLDM_SENSOR_DATA_SIZE_UINT8, "uint8"},
        {PLDM_SENSOR_DATA_SIZE_SINT8, "uint8"},
        {PLDM_SENSOR_DATA_SIZE_UINT16, "uint16"},
        {PLDM_SENSOR_DATA_SIZE_SINT16, "uint16"},
        {PLDM_SENSOR_DATA_SIZE_UINT32, "uint32"},
        {PLDM_SENSOR_DATA_SIZE_SINT32, "uint32"}};

    static inline const std::map<uint8_t, std::string> sensorEventMsgEnable{
        {PLDM_NO_EVENT_GENERATION, "Sensor No Event Generation"},
        {PLDM_EVENTS_DISABLED, "Sensor Events Disabled"},
        {PLDM_EVENTS_ENABLED, "Sensor Events Enabled"},
        {PLDM_OP_EVENTS_ONLY_ENABLED, "Sensor Op Events Only Enabled"},
        {PLDM_STATE_EVENTS_ONLY_ENABLED, "Sensor State Events Only Enabled"}};

    std::string getSensorState(uint8_t state,
                               const std::map<uint8_t, std::string>* cont)
    {
        auto typeString = std::to_string(state);
        try
        {
            return cont->at(state);
        }
        catch (const std::out_of_range& e)
        {
            return typeString;
        }
    }
};

class GetStateEffecterStates : public CommandInterface
{
  public:
    ~GetStateEffecterStates() = default;
    GetStateEffecterStates() = delete;
    GetStateEffecterStates(const GetStateEffecterStates&) = delete;
    GetStateEffecterStates(GetStateEffecterStates&&) = default;
    GetStateEffecterStates& operator=(const GetStateEffecterStates&) = delete;
    GetStateEffecterStates& operator=(GetStateEffecterStates&&) = delete;

    explicit GetStateEffecterStates(const char* type, const char* name,
                                    CLI::App* app) :
        CommandInterface(type, name, app)
    {
        app->add_option(
               "-i, --effecter_id", effecter_id,
               "Effecter ID that is used to identify and access the effecter")
            ->required();
    }

    std::pair<int, std::vector<uint8_t>> createRequestMsg() override
    {
        std::vector<uint8_t> requestMsg(
            sizeof(pldm_msg_hdr) + PLDM_GET_STATE_EFFECTER_STATES_REQ_BYTES);
        auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());

        auto rc = encode_get_state_effecter_states_req(
            instanceId, effecter_id, request,
            PLDM_GET_STATE_EFFECTER_STATES_REQ_BYTES);

        return {rc, requestMsg};
    }

    void parseResponseMsg(pldm_msg* responsePtr, size_t payloadLength) override
    {
        struct pldm_get_state_effecter_states_resp resp;
        auto rc = decode_get_state_effecter_states_resp(responsePtr,
                                                        payloadLength, &resp);

        if (rc || resp.completion_code != PLDM_SUCCESS)
        {
            std::cerr << "Response Message Error: "
                      << "rc=" << rc << ",cc="
                      << static_cast<int>(resp.completion_code) << std::endl;
            return;
        }
        ordered_json output;
        auto comp_effecter_count = static_cast<int>(resp.comp_effecter_count);
        output["compositeEffecterCount"] = comp_effecter_count;

        for (auto i : std::views::iota(0, comp_effecter_count))
        {
            output[std::format("effecterOpState[{}])", i)] =
                getEffecterOpState(resp.field[i].effecter_op_state);

            output[std::format("pendingState[{}]", i)] =
                resp.field[i].pending_state;

            output[std::format("presentState[{}]", i)] =
                resp.field[i].present_state;
        }

        pldmtool::helper::DisplayInJson(output);
    }

  private:
    uint16_t effecter_id;
};

class GetNumericEffecterValue : public CommandInterface
{
  public:
    ~GetNumericEffecterValue() = default;
    GetNumericEffecterValue() = delete;
    GetNumericEffecterValue(const GetNumericEffecterValue&) = delete;
    GetNumericEffecterValue(GetNumericEffecterValue&&) = default;
    GetNumericEffecterValue& operator=(const GetNumericEffecterValue&) = delete;
    GetNumericEffecterValue& operator=(GetNumericEffecterValue&&) = delete;

    explicit GetNumericEffecterValue(const char* type, const char* name,
                                     CLI::App* app) :
        CommandInterface(type, name, app)
    {
        app->add_option(
               "-i, --effecter_id", effecterId,
               "A handle that is used to identify and access the effecter")
            ->required();
    }

    std::pair<int, std::vector<uint8_t>> createRequestMsg() override
    {
        std::vector<uint8_t> requestMsg(
            sizeof(pldm_msg_hdr) + PLDM_GET_NUMERIC_EFFECTER_VALUE_REQ_BYTES);
        auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());

        auto rc = encode_get_numeric_effecter_value_req(instanceId, effecterId,
                                                        request);

        return {rc, requestMsg};
    }

    void parseResponseMsg(pldm_msg* responsePtr, size_t payloadLength) override
    {
        uint8_t completionCode = 0;
        uint8_t effecterDataSize = 0;
        uint8_t effecterOperationalState = 0;
        std::array<uint8_t, sizeof(uint32_t)>
            pendingValue{}; // maximum size for the pending Value is uint32
                            // according to spec DSP0248
        std::array<uint8_t, sizeof(uint32_t)>
            presentValue{}; // maximum size for the present Value is uint32
                            // according to spec DSP0248

        auto rc = decode_get_numeric_effecter_value_resp(
            responsePtr, payloadLength, &completionCode, &effecterDataSize,
            &effecterOperationalState, pendingValue.data(),
            presentValue.data());

        if (rc != PLDM_SUCCESS || completionCode != PLDM_SUCCESS)
        {
            std::cerr << "Response Message Error: "
                      << "rc=" << rc << ",cc="
                      << static_cast<int>(completionCode) << std::endl;
            return;
        }

        ordered_json output;
        output["effecterDataSize"] = static_cast<int>(effecterDataSize);
        output["effecterOperationalState"] =
            getEffecterOpState(effecterOperationalState);

        switch (effecterDataSize)
        {
            case PLDM_EFFECTER_DATA_SIZE_UINT8:
            {
                output["pendingValue"] =
                    *(reinterpret_cast<uint8_t*>(pendingValue.data()));
                output["presentValue"] =
                    *(reinterpret_cast<uint8_t*>(presentValue.data()));
                break;
            }
            case PLDM_EFFECTER_DATA_SIZE_SINT8:
            {
                output["pendingValue"] =
                    *(reinterpret_cast<int8_t*>(pendingValue.data()));
                output["presentValue"] =
                    *(reinterpret_cast<int8_t*>(presentValue.data()));
                break;
            }
            case PLDM_EFFECTER_DATA_SIZE_UINT16:
            {
                output["pendingValue"] =
                    *(reinterpret_cast<uint16_t*>(pendingValue.data()));
                output["presentValue"] =
                    *(reinterpret_cast<uint16_t*>(presentValue.data()));
                break;
            }
            case PLDM_EFFECTER_DATA_SIZE_SINT16:
            {
                output["pendingValue"] =
                    *(reinterpret_cast<int16_t*>(pendingValue.data()));
                output["presentValue"] =
                    *(reinterpret_cast<int16_t*>(presentValue.data()));
                break;
            }
            case PLDM_EFFECTER_DATA_SIZE_UINT32:
            {
                output["pendingValue"] =
                    *(reinterpret_cast<uint32_t*>(pendingValue.data()));
                output["presentValue"] =
                    *(reinterpret_cast<uint32_t*>(presentValue.data()));
                break;
            }
            case PLDM_EFFECTER_DATA_SIZE_SINT32:
            {
                output["pendingValue"] =
                    *(reinterpret_cast<int32_t*>(pendingValue.data()));
                output["presentValue"] =
                    *(reinterpret_cast<int32_t*>(presentValue.data()));
                break;
            }
            default:
            {
                std::cerr << "Unknown Effecter Data Size : "
                          << static_cast<int>(effecterDataSize) << std::endl;
                break;
            }
        }

        pldmtool::helper::DisplayInJson(output);
    }

  private:
    uint16_t effecterId;
};

void registerCommand(CLI::App& app)
{
    auto platform = app.add_subcommand("platform", "platform type command");
    platform->require_subcommand(1);

    auto getPDR =
        platform->add_subcommand("GetPDR", "get platform descriptor records");
    commands.push_back(std::make_unique<GetPDR>("platform", "getPDR", getPDR));

    auto setStateEffecterStates = platform->add_subcommand(
        "SetStateEffecterStates", "set effecter states");
    commands.push_back(std::make_unique<SetStateEffecter>(
        "platform", "setStateEffecterStates", setStateEffecterStates));

    auto setNumericEffecterValue = platform->add_subcommand(
        "SetNumericEffecterValue", "set the value for a PLDM Numeric Effecter");
    commands.push_back(std::make_unique<SetNumericEffecterValue>(
        "platform", "setNumericEffecterValue", setNumericEffecterValue));

    auto getStateSensorReadings = platform->add_subcommand(
        "GetStateSensorReadings", "get the state sensor readings");
    commands.push_back(std::make_unique<GetStateSensorReadings>(
        "platform", "getStateSensorReadings", getStateSensorReadings));

    auto getNumericEffecterValue = platform->add_subcommand(
        "GetNumericEffecterValue", "get the numeric effecter value");
    commands.push_back(std::make_unique<GetNumericEffecterValue>(
        "platform", "getNumericEffecterValue", getNumericEffecterValue));

    auto getSensorReading = platform->add_subcommand(
        "GetSensorReading", "get the numeric sensor reading");
    commands.push_back(std::make_unique<GetSensorReading>(
        "platform", "getSensorReading", getSensorReading));

    auto getStateEffecterStates = platform->add_subcommand(
        "GetStateEffecterStates", "get the state effecter states");
    commands.push_back(std::make_unique<GetStateEffecterStates>(
        "platform", "getStateEffecterStates", getStateEffecterStates));
}

void parseGetPDROption()
{
    for (const auto& command : commands)
    {
        if (command.get()->getPLDMType() == "platform" &&
            command.get()->getCommandName() == "getPDR")
        {
            auto getPDR = dynamic_cast<GetPDR*>(command.get());
            getPDR->parseGetPDROptions();
        }
    }
}

} // namespace platform
} // namespace pldmtool
