summaryrefslogtreecommitdiffstats
path: root/pid/fancontroller.hpp
blob: f3d3f4eca5c0a71d2bf018ba072ccc5c6d4676de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once

#include "ec/pid.hpp"
#include "fan.hpp"
#include "pidcontroller.hpp"

#include <memory>
#include <string>
#include <vector>

/*
 * A FanController is a PID controller that reads a number of fans and given
 * the output then tries to set them to the goal values set by the thermal
 * controllers.
 */
class FanController : public PIDController
{
  public:
    static std::unique_ptr<PIDController>
        createFanPid(ZoneInterface* owner, const std::string& id,
                     const std::vector<std::string>& inputs,
                     const ec::pidinfo& initial);

    FanController(const std::string& id, const std::vector<std::string>& inputs,
                  ZoneInterface* owner) :
        PIDController(id, owner),
        _inputs(inputs), _direction(FanSpeedDirection::NEUTRAL)
    {
    }

    double inputProc(void) override;
    double setptProc(void) override;
    void outputProc(double value) override;

    FanSpeedDirection getFanDirection(void) const
    {
        return _direction;
    }

    void setFanDirection(FanSpeedDirection direction)
    {
        _direction = direction;
    };

  private:
    std::vector<std::string> _inputs;
    FanSpeedDirection _direction;
};
OpenPOWER on IntegriCloud