#pragma once

#include "Thresholds.hpp"
#include "sensor.hpp"

#include <sdbusplus/asio/object_server.hpp>

#include <chrono>
#include <string>
#include <vector>

class ExternalSensor :
    public Sensor,
    public std::enable_shared_from_this<ExternalSensor>
{
  public:
    ExternalSensor(const std::string& objectType,
                   sdbusplus::asio::object_server& objectServer,
                   std::shared_ptr<sdbusplus::asio::connection>& conn,
                   const std::string& sensorName,
                   const std::string& sensorUnits,
                   std::vector<thresholds::Threshold>&& thresholdsIn,
                   const std::string& sensorConfiguration, double maxReading,
                   double minReading, double timeoutSecs,
                   const PowerState& powerState);
    ~ExternalSensor() override;

    // Call this immediately after calling the constructor
    void initWriteHook(
        std::function<void(std::chrono::steady_clock::time_point now)>&&
            writeHookIn);

    // Returns true if sensor has external Value that is subject to timeout
    bool isAliveAndPerishable() const;

    // Returns true if AliveAndPerishable and timeout has not yet happened
    bool
        isAliveAndFresh(const std::chrono::steady_clock::time_point& now) const;

    // Marks the time when Value successfully received from external source
    void writeBegin(const std::chrono::steady_clock::time_point& now);

    // Marks sensor as timed out, replacing Value with floating-point "NaN"
    void writeInvalidate();

    // Returns amount of time elapsed since last writeBegin() happened
    std::chrono::steady_clock::duration
        ageElapsed(const std::chrono::steady_clock::time_point& now) const;

    // Returns amount of time remaining until sensor timeout will happen
    std::chrono::steady_clock::duration
        ageRemaining(const std::chrono::steady_clock::time_point& now) const;

  private:
    sdbusplus::asio::object_server& objServer;

    std::chrono::steady_clock::time_point writeLast;
    std::chrono::steady_clock::duration writeTimeout;
    bool writeAlive{false};
    bool writePerishable;
    std::function<void(const std::chrono::steady_clock::time_point& now)>
        writeHook;

    void checkThresholds() override;
    void externalSetTrigger();
};
