#ifndef COMPLIB_SERVER_PID_HPP
#define COMPLIB_SERVER_PID_HPP

#include <chrono>

#define PID_RESET_DELAY_S 0.1L

class PID
{
public:
    PID(float P, float I, float D, float ramp, float limit);
    ~PID() = default;

    float operator() (float setpoint, float process_variable);
    void reset();

    float P = 1;
    float I = 0;
    float D = 0;
    float setpoint_ramp = 0;
    float limit = 0;

protected:
    float error_prev = 0;
    float setpoint_prev = 0;
    float integral_prev = 0;
    std::chrono::system_clock::time_point timestamp_prev = std::chrono::high_resolution_clock::now();
};

#endif // COMPLIB_SERVER_PID_HPP