#pragma once
#include "average.hpp"
#include "device.hpp"
#include "maximum.hpp"
#include "names_values.hpp"
#include "pmbus.hpp"
#include "record_manager.hpp"

#include <sdbusplus/bus/match.hpp>
#include <sdeventplus/clock.hpp>
#include <sdeventplus/event.hpp>
#include <sdeventplus/utility/timer.hpp>

namespace witherspoon
{
namespace power
{
namespace psu
{

namespace sdbusRule = sdbusplus::bus::match::rules;

constexpr auto FAULT_COUNT = 3;

/**
 * @class PowerSupply
 * Represents a PMBus power supply device.
 */
class PowerSupply : public Device
{
  public:
    PowerSupply() = delete;
    PowerSupply(const PowerSupply&) = delete;
    PowerSupply(PowerSupply&&) = default;
    PowerSupply& operator=(const PowerSupply&) = default;
    PowerSupply& operator=(PowerSupply&&) = default;
    ~PowerSupply() = default;

    /**
     * Constructor
     *
     * @param[in] name - the device name
     * @param[in] inst - the device instance
     * @param[in] objpath - the path to monitor
     * @param[in] invpath - the inventory path to use
     * @param[in] bus - D-Bus bus object
     * @param[in] e - event object
     * @param[in] t - time to allow power supply to assert PG#
     * @param[in] p - time to allow power supply presence state to
     *                settle/deglitch and allow for application of power
     *                prior to fault checking
     */
    PowerSupply(const std::string& name, size_t inst,
                const std::string& objpath, const std::string& invpath,
                sdbusplus::bus_t& bus, const sdeventplus::Event& e,
                std::chrono::seconds& t, std::chrono::seconds& p);

    /**
     * Power supply specific function to analyze for faults/errors.
     *
     * Various PMBus status bits will be checked for fault conditions.
     * If a certain fault bits are on, the appropriate error will be
     * committed.
     */
    void analyze() override;

    /**
     * Write PMBus CLEAR_FAULTS
     *
     * This function will be called in various situations in order to clear
     * any fault status bits that may have been set, in order to start over
     * with a clean state. Presence changes and power state changes will
     * want to clear any faults logged.
     */
    void clearFaults() override;

    /**
     * Mark error for specified callout and message as resolved.
     *
     * @param[in] callout - The callout to be resolved (inventory path)
     * @parma[in] message - The message for the fault to be resolved
     */
    void resolveError(const std::string& callout, const std::string& message);

    /**
     * Enables making the input power history available on D-Bus
     *
     * @param[in] objectPath - the D-Bus object path to use
     * @param[in] maxRecords - the number of history records to keep
     * @param[in] syncGPIOPath - The gpiochip device path to use for
     *                           sending the sync command
     * @paramp[in] syncGPIONum - the GPIO number for the sync command
     */
    void enableHistory(const std::string& objectPath, size_t numRecords,
                       const std::string& syncGPIOPath, size_t syncGPIONum);

  private:
    /**
     * The path to use for reading various PMBus bits/words.
     */
    std::string monitorPath;

    /**
     * @brief Pointer to the PMBus interface
     *
     * Used to read out of or write to the /sysfs tree(s) containing files
     * that a device driver monitors the PMBus interface to the power
     * supplies.
     */
    witherspoon::pmbus::PMBus pmbusIntf;

    /**
     * @brief D-Bus path to use for this power supply's inventory status.
     */
    std::string inventoryPath;

    /** @brief Connection for sdbusplus bus */
    sdbusplus::bus_t& bus;

    /** @brief True if the power supply is present. */
    bool present = false;

    /** @brief Used to subscribe to D-Bus property changes for Present */
    std::unique_ptr<sdbusplus::bus::match_t> presentMatch;

    /**
     * @brief Interval for setting present to true.
     *
     * The amount of time to wait from not present to present change before
     * updating the internal present indicator. Allows person servicing
     * the power supply some time to plug in the cable.
     */
    std::chrono::seconds presentInterval;

    /**
     * @brief Timer used to delay setting the internal present state.
     *
     * The timer used to do the callback after the present property has
     * changed.
     */
    sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> presentTimer;

    /** @brief True if a fault has already been found and not cleared */
    bool faultFound = false;

    /** @brief True if the power is on. */
    bool powerOn = false;

    /**
     * @brief Equal to FAULT_COUNT if power on fault has been
     * detected.
     */
    size_t powerOnFault = 0;

    /**
     * @brief Interval to setting powerOn to true.
     *
     * The amount of time to wait from power state on to setting the
     * internal powerOn state to true. The amount of time the power supply
     * is allowed to delay setting DGood/PG#.
     */
    std::chrono::seconds powerOnInterval;

    /**
     * @brief Timer used to delay setting the internal powerOn state.
     *
     * The timer used to do the callback after the power state has been on
     * long enough.
     */
    sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic> powerOnTimer;

    /** @brief Used to subscribe to D-Bus power on state changes */
    std::unique_ptr<sdbusplus::bus::match_t> powerOnMatch;

    /** @brief Indicates that a read failure has occurred.
     *
     * @details This will be incremented each time a read failure is
     *          encountered. If it is incremented to FAULT_COUNT, an error
     *          will be logged.
     */
    size_t readFail = 0;

    /** @brief Has a PMBus read failure already been logged? */
    bool readFailLogged = false;

    /**
     * @brief Indicates an input fault or warning if equal to FAULT_COUNT.
     *
     * @details This is the "INPUT FAULT OR WARNING" bit in the high byte,
     *          or the VIN_UV_FAULT bit in the low byte in the STATUS_WORD
     *          command response. If either of those bits are on, this will
     *          be incremented.
     */
    size_t inputFault = 0;

    /**
     * @brief Indicates output over current fault if equal to FAULT_COUNT
     *
     * @details This is incremented when the "IOUT_OC_FAULT" bit in the low
     *          byte from the STATUS_WORD command response is on.
     */
    size_t outputOCFault = 0;

    /**
     * @brief Indicates output overvoltage fault if equal to FAULT_COUNT.
     *
     * @details This is incremented when the "VOUT_OV_FAULT" bit in the
     *          STATUS_WORD command response is on.
     */
    size_t outputOVFault = 0;

    /**
     * @brief Indicates a fan fault or warning condition was detected if
     *        equal to FAULT_COUNT.
     *
     * @details This is incremented when the 'FAN_FAULT' bit in the
     *          STATUS_WORD command response is on.
     */
    size_t fanFault = 0;

    /**
     * @brief Indicates a temperature fault or warn condition was detected
     *        if equal to FAULT_COUNT.
     *
     * @details This is incremented when the 'TEMPERATURE_FAULT_WARN' bit
     *          in the STATUS_WORD command response is on, or if the
     *          'OT_FAULT' bit in the STATUS_TEMPERATURE command response
     *          is on.
     */
    size_t temperatureFault = 0;

    /**
     * @brief Class that manages the input power history records.
     */
    std::unique_ptr<history::RecordManager> recordManager;

    /**
     * @brief The D-Bus object for the average input power history
     */
    std::unique_ptr<history::Average> average;

    /**
     * @brief The D-Bus object for the maximum input power history
     */
    std::unique_ptr<history::Maximum> maximum;

    /**
     * @brief The base D-Bus object path to use for the average
     *        and maximum objects.
     */
    std::string historyObjectPath;

    /**
     * @brief The GPIO device path to use for sending the 'sync'
     *        command to the PS.
     */
    std::string syncGPIODevPath;

    /**
     * @brief The GPIO number to use for sending the 'sync'
     *        command to the PS.
     */
    size_t syncGPIONumber = 0;

    /**
     * @brief Callback for inventory property changes
     *
     * Process change of Present property for power supply.
     *
     * @param[in]  msg - Data associated with Present change signal
     *
     */
    void inventoryChanged(sdbusplus::message_t& msg);

    /**
     * Updates the presence status by querying D-Bus
     *
     * The D-Bus inventory properties for this power supply will be read to
     * determine if the power supply is present or not and update this
     * objects present member variable to reflect current status.
     */
    void updatePresence();

    /**
     * @brief Updates the poweredOn status by querying D-Bus
     *
     * The D-Bus property for the system power state will be read to
     * determine if the system is powered on or not.
     */
    void updatePowerState();

    /**
     * @brief Callback for power state property changes
     *
     * Process changes to the powered on stat property for the system.
     *
     * @param[in] msg - Data associated with the power state signal
     */
    void powerStateChanged(sdbusplus::message_t& msg);

    /**
     * @brief Wrapper for PMBus::read() and adding metadata
     *
     * @param[out] nv - NamesValues instance to store cmd string and value
     * @param[in] cmd - String for the command to read data from.
     * @param[in] type - The type of file to read the command from.
     */
    void captureCmd(util::NamesValues& nv, const std::string& cmd,
                    witherspoon::pmbus::Type type);

    /**
     * @brief Checks for input voltage faults and logs error if needed.
     *
     * Check for voltage input under voltage fault (VIN_UV_FAULT) and/or
     * input fault or warning (INPUT_FAULT), and logs appropriate error(s).
     *
     * @param[in] statusWord  - 2 byte STATUS_WORD value read from sysfs
     */
    void checkInputFault(const uint16_t statusWord);

    /**
     * @brief Checks for power good negated or unit is off in wrong state
     *
     * @param[in] statusWord  - 2 byte STATUS_WORD value read from sysfs
     */
    void checkPGOrUnitOffFault(const uint16_t statusWord);

    /**
     * @brief Checks for output current over current fault.
     *
     * IOUT_OC_FAULT is checked, if on, appropriate error is logged.
     *
     * @param[in] statusWord  - 2 byte STATUS_WORD value read from sysfs
     */
    void checkCurrentOutOverCurrentFault(const uint16_t statusWord);

    /**
     * @brief Checks for output overvoltage fault.
     *
     * VOUT_OV_FAULT is checked, if on, appropriate error is logged.
     *
     * @param[in] statusWord  - 2 byte STATUS_WORD value read from sysfs
     */
    void checkOutputOvervoltageFault(const uint16_t statusWord);

    /**
     * @brief Checks for a fan fault or warning condition.
     *
     * The high byte of STATUS_WORD is checked to see if the "FAN FAULT OR
     * WARNING" bit is turned on. If it is on, log an error.
     *
     * @param[in] statusWord - 2 byte STATUS_WORD value read from sysfs
     */
    void checkFanFault(const uint16_t statusWord);

    /**
     * @brief Checks for a temperature fault or warning condition.
     *
     * The low byte of STATUS_WORD is checked to see if the "TEMPERATURE
     * FAULT OR WARNING" bit is turned on. If it is on, log an error,
     * call out the power supply indicating the fault/warning condition.
     *
     * @parma[in] statusWord - 2 byte STATUS_WORD value read from sysfs
     */
    void checkTemperatureFault(const uint16_t statusWord);

    /**
     * @brief Adds properties to the inventory.
     *
     * Reads the values from the device and writes them to the
     * associated power supply D-Bus inventory object.
     *
     * This needs to be done on startup, and each time the presence
     * state changes.
     *
     * Properties added:
     * - Serial Number
     * - Part Number
     * - CCIN (Customer Card Identification Number) - added as the Model
     * - Firmware version
     */
    void updateInventory();

    /**
     * @brief Toggles the GPIO to sync power supply input history readings
     *
     * This GPIO is connected to all supplies.  This will clear the
     * previous readings out of the supplies and restart them both at the
     * same time zero and at record ID 0.  The supplies will return 0
     * bytes of data for the input history command right after this until
     * a new entry shows up.
     *
     * This will cause the code to delete all previous history data and
     * start fresh.
     */
    void syncHistory();

    /**
     * @brief Reads the most recent input history record from the power
     *        supply and updates the average and maximum properties in
     *        D-Bus if there is a new reading available.
     *
     * This will still run every time analyze() is called so code can
     * post new data as soon as possible and the timestamp will more
     * accurately reflect the correct time.
     *
     * D-Bus is only updated if there is a change and the oldest record
     * will be pruned if the property already contains the max number of
     * records.
     */
    void updateHistory();
};

} // namespace psu
} // namespace power
} // namespace witherspoon
