#ifndef _PID_H_
#define _PID_H_

class PID {

 private:
  double Min, Max;
  double Kp; 	// proportional factor
  double Ki; 	// integral factor
  double Kd; 	// derivative factor
  double Integral;
  double PreviousError;
  int64_t PreviousTime;

 public:
  PID(double min, double max, double kp, double kd, double ki);
  PID();
  ~PID();

  void Start(void);
  void SetParam(double mi, double ma, double p, double i, double d);
  void GetParam(double *mi, double *ma, double *p, double *i, double *d);
  double GetMax() { return Max; };
  double GetMin() { return Min; };
  double Update(double target, double value, int64_t time);
  double Update(double target, double value);
  static int64_t GetTime(void);
};

#endif
