11a153794SPatrick Venture #pragma once 21a153794SPatrick Venture 31a153794SPatrick Venture #include "sensors/sensor.hpp" 41a153794SPatrick Venture 51a153794SPatrick Venture #include <string> 61a153794SPatrick Venture 71a153794SPatrick Venture namespace pid_control 81a153794SPatrick Venture { 91a153794SPatrick Venture 107a98c19aSPatrick Venture /** 117a98c19aSPatrick Venture * In a Zone you have a set of PIDs which feed each other. Fan PIDs are fed set 127a98c19aSPatrick Venture * points from Thermal PIDs. 137a98c19aSPatrick Venture */ 141a153794SPatrick Venture class ZoneInterface 151a153794SPatrick Venture { 161a153794SPatrick Venture public: 171a153794SPatrick Venture virtual ~ZoneInterface() = default; 181a153794SPatrick Venture 197a98c19aSPatrick Venture /** If the zone implementation supports logging, initialize the log. */ 207a98c19aSPatrick Venture virtual void initializeLog(void) = 0; 217a98c19aSPatrick Venture /** If the zone implementation supports logging, write string to log. */ 227a98c19aSPatrick Venture virtual void writeLog(const std::string& value) = 0; 237a98c19aSPatrick Venture 247a98c19aSPatrick Venture /** Return a pointer to the sensor specified by name. */ 251a153794SPatrick Venture virtual Sensor* getSensor(const std::string& name) = 0; 267a98c19aSPatrick Venture 277a98c19aSPatrick Venture /* updateFanTelemetry() and updateSensors() both clear the failsafe state 287a98c19aSPatrick Venture * for a sensor if it's no longer in that state. 297a98c19aSPatrick Venture */ 307a98c19aSPatrick Venture /** For each fan input in the zone, read each to update the cachedValue and 317a98c19aSPatrick Venture * check if the fan is beyond its timeout to trigger a failsafe condition. 327a98c19aSPatrick Venture */ 337a98c19aSPatrick Venture virtual void updateFanTelemetry(void) = 0; 347a98c19aSPatrick Venture /** For each thermal input in the zone, read each to update the cachedValue 357a98c19aSPatrick Venture * and check if the sensor is beyond its timeout to trigger a failsafe 367a98c19aSPatrick Venture * condition. 377a98c19aSPatrick Venture */ 387a98c19aSPatrick Venture virtual void updateSensors(void) = 0; 397a98c19aSPatrick Venture /** For each fan and thermal input in the zone, set the cachedValue to 0 and 407a98c19aSPatrick Venture * set the input as failsafe - to default the zone to failsafe before it 417a98c19aSPatrick Venture * starts processing values to control fans. 427a98c19aSPatrick Venture */ 437a98c19aSPatrick Venture virtual void initializeCache(void) = 0; 44a4146eb1SJosh Lehan 457a98c19aSPatrick Venture /** Return cached value for sensor by name. */ 467a98c19aSPatrick Venture virtual double getCachedValue(const std::string& name) = 0; 477a98c19aSPatrick Venture 487a98c19aSPatrick Venture /** Add a set point value for the Max Set Point computation. */ 49*ccc8bb62SNirav Shah virtual void addSetPoint(double setpoint, const std::string& name) = 0; 507a98c19aSPatrick Venture /** Clear all set points specified via addSetPoint */ 517a98c19aSPatrick Venture virtual void clearSetPoints(void) = 0; 527a98c19aSPatrick Venture 537a98c19aSPatrick Venture /** Add maximum RPM value to drive fan pids. */ 547a98c19aSPatrick Venture virtual void addRPMCeiling(double ceiling) = 0; 557a98c19aSPatrick Venture /** Clear any RPM value set with addRPMCeiling. */ 567a98c19aSPatrick Venture virtual void clearRPMCeilings(void) = 0; 577a98c19aSPatrick Venture 587a98c19aSPatrick Venture /** Compute the value returned by getMaxSetPointRequest - called from the 597a98c19aSPatrick Venture * looping mechanism before triggering any Fan PIDs. The value computed is 607a98c19aSPatrick Venture * used by each fan PID. 617a98c19aSPatrick Venture */ 627a98c19aSPatrick Venture virtual void determineMaxSetPointRequest(void) = 0; 637a98c19aSPatrick Venture /** Given the set points added via addSetPoint, return the maximum value - 647a98c19aSPatrick Venture * called from the PID loop that uses that value to drive the fans. 657a98c19aSPatrick Venture */ 667a98c19aSPatrick Venture virtual double getMaxSetPointRequest() const = 0; 677a98c19aSPatrick Venture 687a98c19aSPatrick Venture /** Return if the zone has any sensors in fail safe mode. */ 697a98c19aSPatrick Venture virtual bool getFailSafeMode() const = 0; 707a98c19aSPatrick Venture /** Return the rpm or pwm percent value to drive fan pids when zone is in 717a98c19aSPatrick Venture * fail safe. 727a98c19aSPatrick Venture */ 737a98c19aSPatrick Venture virtual double getFailSafePercent() const = 0; 747a98c19aSPatrick Venture 757a98c19aSPatrick Venture /** Return if the zone is set to manual mode. false equates to automatic 767a98c19aSPatrick Venture * mode (the default). 777a98c19aSPatrick Venture */ 787a98c19aSPatrick Venture virtual bool getManualMode(void) const = 0; 797a98c19aSPatrick Venture 80a4146eb1SJosh Lehan /** Returns true if a redundant fan PWM write is needed. Redundant write 81a4146eb1SJosh Lehan * is used when returning the fan to automatic mode from manual mode. 82a4146eb1SJosh Lehan */ 83a4146eb1SJosh Lehan virtual bool getRedundantWrite(void) const = 0; 84a4146eb1SJosh Lehan 857a98c19aSPatrick Venture /** For each fan pid, do processing. */ 867a98c19aSPatrick Venture virtual void processFans(void) = 0; 877a98c19aSPatrick Venture /** For each thermal pid, do processing. */ 887a98c19aSPatrick Venture virtual void processThermals(void) = 0; 891a153794SPatrick Venture }; 901a153794SPatrick Venture 911a153794SPatrick Venture } // namespace pid_control 92