Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 1 | /** |
| 2 | * Copyright 2017 Google Inc. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /* Configuration. */ |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 18 | #include "zone.hpp" |
| 19 | |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 20 | #include "conf.hpp" |
| 21 | #include "pid/controller.hpp" |
| 22 | #include "pid/ec/pid.hpp" |
| 23 | #include "pid/fancontroller.hpp" |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 24 | #include "pid/stepwisecontroller.hpp" |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 25 | #include "pid/thermalcontroller.hpp" |
Patrick Venture | c32e3fc | 2019-02-28 10:01:11 -0800 | [diff] [blame] | 26 | #include "pid/tuning.hpp" |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 27 | |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 28 | #include <algorithm> |
| 29 | #include <chrono> |
| 30 | #include <cstring> |
| 31 | #include <fstream> |
| 32 | #include <iostream> |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 33 | #include <memory> |
| 34 | |
Patrick Venture | a076487 | 2020-08-08 07:48:43 -0700 | [diff] [blame] | 35 | namespace pid_control |
| 36 | { |
| 37 | |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 38 | using tstamp = std::chrono::high_resolution_clock::time_point; |
| 39 | using namespace std::literals::chrono_literals; |
| 40 | |
Patrick Venture | f7a2dd5 | 2019-07-16 14:31:13 -0700 | [diff] [blame] | 41 | double PIDZone::getMaxSetPointRequest(void) const |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 42 | { |
Patrick Venture | f7a2dd5 | 2019-07-16 14:31:13 -0700 | [diff] [blame] | 43 | return _maximumSetPoint; |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | bool PIDZone::getManualMode(void) const |
| 47 | { |
| 48 | return _manualMode; |
| 49 | } |
| 50 | |
| 51 | void PIDZone::setManualMode(bool mode) |
| 52 | { |
| 53 | _manualMode = mode; |
| 54 | } |
| 55 | |
| 56 | bool PIDZone::getFailSafeMode(void) const |
| 57 | { |
| 58 | // If any keys are present at least one sensor is in fail safe mode. |
| 59 | return !_failSafeSensors.empty(); |
| 60 | } |
| 61 | |
Patrick Venture | 0bbeaf8 | 2018-10-30 18:50:31 -0700 | [diff] [blame] | 62 | int64_t PIDZone::getZoneID(void) const |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 63 | { |
| 64 | return _zoneId; |
| 65 | } |
| 66 | |
Patrick Venture | 9bbf333 | 2019-07-16 10:50:37 -0700 | [diff] [blame] | 67 | void PIDZone::addSetPoint(double setpoint) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 68 | { |
Patrick Venture | 9bbf333 | 2019-07-16 10:50:37 -0700 | [diff] [blame] | 69 | _SetPoints.push_back(setpoint); |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 70 | } |
| 71 | |
James Feist | 608304d | 2019-02-25 10:01:42 -0800 | [diff] [blame] | 72 | void PIDZone::addRPMCeiling(double ceiling) |
| 73 | { |
| 74 | _RPMCeilings.push_back(ceiling); |
| 75 | } |
| 76 | |
| 77 | void PIDZone::clearRPMCeilings(void) |
| 78 | { |
| 79 | _RPMCeilings.clear(); |
| 80 | } |
| 81 | |
Patrick Venture | 9bbf333 | 2019-07-16 10:50:37 -0700 | [diff] [blame] | 82 | void PIDZone::clearSetPoints(void) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 83 | { |
Patrick Venture | 9bbf333 | 2019-07-16 10:50:37 -0700 | [diff] [blame] | 84 | _SetPoints.clear(); |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 85 | } |
| 86 | |
Patrick Venture | 5f59c0f | 2018-11-11 12:55:14 -0800 | [diff] [blame] | 87 | double PIDZone::getFailSafePercent(void) const |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 88 | { |
| 89 | return _failSafePercent; |
| 90 | } |
| 91 | |
Patrick Venture | f7a2dd5 | 2019-07-16 14:31:13 -0700 | [diff] [blame] | 92 | double PIDZone::getMinThermalSetpoint(void) const |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 93 | { |
James Feist | 3484bed | 2019-02-25 13:28:18 -0800 | [diff] [blame] | 94 | return _minThermalOutputSetPt; |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 95 | } |
| 96 | |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 97 | void PIDZone::addFanPID(std::unique_ptr<Controller> pid) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 98 | { |
| 99 | _fans.push_back(std::move(pid)); |
| 100 | } |
| 101 | |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 102 | void PIDZone::addThermalPID(std::unique_ptr<Controller> pid) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 103 | { |
| 104 | _thermals.push_back(std::move(pid)); |
| 105 | } |
| 106 | |
| 107 | double PIDZone::getCachedValue(const std::string& name) |
| 108 | { |
| 109 | return _cachedValuesByName.at(name); |
| 110 | } |
| 111 | |
Patrick Venture | c399f6f | 2018-10-30 19:24:47 -0700 | [diff] [blame] | 112 | void PIDZone::addFanInput(const std::string& fan) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 113 | { |
| 114 | _fanInputs.push_back(fan); |
| 115 | } |
| 116 | |
Patrick Venture | c399f6f | 2018-10-30 19:24:47 -0700 | [diff] [blame] | 117 | void PIDZone::addThermalInput(const std::string& therm) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 118 | { |
| 119 | _thermalInputs.push_back(therm); |
| 120 | } |
| 121 | |
Patrick Venture | f7a2dd5 | 2019-07-16 14:31:13 -0700 | [diff] [blame] | 122 | void PIDZone::determineMaxSetPointRequest(void) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 123 | { |
Patrick Venture | 5f59c0f | 2018-11-11 12:55:14 -0800 | [diff] [blame] | 124 | double max = 0; |
| 125 | std::vector<double>::iterator result; |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 126 | |
Patrick Venture | 9bbf333 | 2019-07-16 10:50:37 -0700 | [diff] [blame] | 127 | if (_SetPoints.size() > 0) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 128 | { |
Patrick Venture | 9bbf333 | 2019-07-16 10:50:37 -0700 | [diff] [blame] | 129 | result = std::max_element(_SetPoints.begin(), _SetPoints.end()); |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 130 | max = *result; |
| 131 | } |
| 132 | |
James Feist | 608304d | 2019-02-25 10:01:42 -0800 | [diff] [blame] | 133 | if (_RPMCeilings.size() > 0) |
| 134 | { |
| 135 | result = std::min_element(_RPMCeilings.begin(), _RPMCeilings.end()); |
| 136 | max = std::min(max, *result); |
| 137 | } |
| 138 | |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 139 | /* |
Patrick Venture | 7280e27 | 2019-02-11 10:45:32 -0800 | [diff] [blame] | 140 | * If the maximum RPM setpoint output is below the minimum RPM |
| 141 | * setpoint, set it to the minimum. |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 142 | */ |
Patrick Venture | f7a2dd5 | 2019-07-16 14:31:13 -0700 | [diff] [blame] | 143 | max = std::max(getMinThermalSetpoint(), max); |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 144 | |
Patrick Venture | de79ee0 | 2019-05-08 14:50:00 -0700 | [diff] [blame] | 145 | if (tuningEnabled) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 146 | { |
Patrick Venture | c32e3fc | 2019-02-28 10:01:11 -0800 | [diff] [blame] | 147 | /* |
| 148 | * We received no setpoints from thermal sensors. |
| 149 | * This is a case experienced during tuning where they only specify |
| 150 | * fan sensors and one large fan PID for all the fans. |
| 151 | */ |
| 152 | static constexpr auto setpointpath = "/etc/thermal.d/setpoint"; |
| 153 | try |
Patrick Venture | da4a5dd | 2018-08-31 09:42:48 -0700 | [diff] [blame] | 154 | { |
Patrick Venture | c32e3fc | 2019-02-28 10:01:11 -0800 | [diff] [blame] | 155 | std::ifstream ifs; |
| 156 | ifs.open(setpointpath); |
| 157 | if (ifs.good()) |
| 158 | { |
| 159 | int value; |
| 160 | ifs >> value; |
Patrick Venture | df766f2 | 2018-10-13 09:30:58 -0700 | [diff] [blame] | 161 | |
Patrick Venture | c32e3fc | 2019-02-28 10:01:11 -0800 | [diff] [blame] | 162 | /* expecting RPM setpoint, not pwm% */ |
| 163 | max = static_cast<double>(value); |
| 164 | } |
| 165 | } |
| 166 | catch (const std::exception& e) |
| 167 | { |
| 168 | /* This exception is uninteresting. */ |
| 169 | std::cerr << "Unable to read from '" << setpointpath << "'\n"; |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 170 | } |
| 171 | } |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 172 | |
Patrick Venture | f7a2dd5 | 2019-07-16 14:31:13 -0700 | [diff] [blame] | 173 | _maximumSetPoint = max; |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 174 | return; |
| 175 | } |
| 176 | |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 177 | void PIDZone::initializeLog(void) |
| 178 | { |
Patrick Venture | 5f02ad2 | 2018-04-24 10:18:40 -0700 | [diff] [blame] | 179 | /* Print header for log file: |
| 180 | * epoch_ms,setpt,fan1,fan2,fanN,sensor1,sensor2,sensorN,failsafe |
| 181 | */ |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 182 | |
| 183 | _log << "epoch_ms,setpt"; |
| 184 | |
Patrick Venture | 4a2dc4d | 2018-10-23 09:02:55 -0700 | [diff] [blame] | 185 | for (const auto& f : _fanInputs) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 186 | { |
| 187 | _log << "," << f; |
| 188 | } |
Patrick Venture | 4a2dc4d | 2018-10-23 09:02:55 -0700 | [diff] [blame] | 189 | for (const auto& t : _thermalInputs) |
Patrick Venture | 5f02ad2 | 2018-04-24 10:18:40 -0700 | [diff] [blame] | 190 | { |
| 191 | _log << "," << t; |
| 192 | } |
| 193 | _log << ",failsafe"; |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 194 | _log << std::endl; |
| 195 | |
| 196 | return; |
| 197 | } |
| 198 | |
| 199 | std::ofstream& PIDZone::getLogHandle(void) |
| 200 | { |
| 201 | return _log; |
| 202 | } |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 203 | |
| 204 | /* |
| 205 | * TODO(venture) This is effectively updating the cache and should check if the |
| 206 | * values they're using to update it are new or old, or whatnot. For instance, |
| 207 | * if we haven't heard from the host in X time we need to detect this failure. |
| 208 | * |
| 209 | * I haven't decided if the Sensor should have a lastUpdated method or whether |
| 210 | * that should be for the ReadInterface or etc... |
| 211 | */ |
| 212 | |
| 213 | /** |
| 214 | * We want the PID loop to run with values cached, so this will get all the |
| 215 | * fan tachs for the loop. |
| 216 | */ |
| 217 | void PIDZone::updateFanTelemetry(void) |
| 218 | { |
| 219 | /* TODO(venture): Should I just make _log point to /dev/null when logging |
| 220 | * is disabled? I think it's a waste to try and log things even if the |
| 221 | * data is just being dropped though. |
| 222 | */ |
Will Liang | ded0ab5 | 2019-05-15 17:10:06 +0800 | [diff] [blame] | 223 | tstamp now = std::chrono::high_resolution_clock::now(); |
Patrick Venture | de79ee0 | 2019-05-08 14:50:00 -0700 | [diff] [blame] | 224 | if (loggingEnabled) |
Patrick Venture | c32e3fc | 2019-02-28 10:01:11 -0800 | [diff] [blame] | 225 | { |
Patrick Venture | c32e3fc | 2019-02-28 10:01:11 -0800 | [diff] [blame] | 226 | _log << std::chrono::duration_cast<std::chrono::milliseconds>( |
| 227 | now.time_since_epoch()) |
| 228 | .count(); |
Patrick Venture | f7a2dd5 | 2019-07-16 14:31:13 -0700 | [diff] [blame] | 229 | _log << "," << _maximumSetPoint; |
Patrick Venture | c32e3fc | 2019-02-28 10:01:11 -0800 | [diff] [blame] | 230 | } |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 231 | |
Patrick Venture | 4a2dc4d | 2018-10-23 09:02:55 -0700 | [diff] [blame] | 232 | for (const auto& f : _fanInputs) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 233 | { |
Patrick Venture | a58197c | 2018-06-11 15:29:45 -0700 | [diff] [blame] | 234 | auto sensor = _mgr.getSensor(f); |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 235 | ReadReturn r = sensor->read(); |
| 236 | _cachedValuesByName[f] = r.value; |
Will Liang | ded0ab5 | 2019-05-15 17:10:06 +0800 | [diff] [blame] | 237 | int64_t timeout = sensor->getTimeout(); |
| 238 | tstamp then = r.updated; |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 239 | |
Will Liang | ded0ab5 | 2019-05-15 17:10:06 +0800 | [diff] [blame] | 240 | auto duration = |
| 241 | std::chrono::duration_cast<std::chrono::seconds>(now - then) |
| 242 | .count(); |
| 243 | auto period = std::chrono::seconds(timeout).count(); |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 244 | /* |
| 245 | * TODO(venture): We should check when these were last read. |
| 246 | * However, these are the fans, so if I'm not getting updated values |
| 247 | * for them... what should I do? |
| 248 | */ |
Patrick Venture | de79ee0 | 2019-05-08 14:50:00 -0700 | [diff] [blame] | 249 | if (loggingEnabled) |
Patrick Venture | c32e3fc | 2019-02-28 10:01:11 -0800 | [diff] [blame] | 250 | { |
| 251 | _log << "," << r.value; |
| 252 | } |
Will Liang | ded0ab5 | 2019-05-15 17:10:06 +0800 | [diff] [blame] | 253 | |
| 254 | // check if fan fail. |
| 255 | if (sensor->getFailed()) |
| 256 | { |
| 257 | _failSafeSensors.insert(f); |
| 258 | } |
| 259 | else if (timeout != 0 && duration >= period) |
| 260 | { |
| 261 | _failSafeSensors.insert(f); |
| 262 | } |
| 263 | else |
| 264 | { |
| 265 | // Check if it's in there: remove it. |
| 266 | auto kt = _failSafeSensors.find(f); |
| 267 | if (kt != _failSafeSensors.end()) |
| 268 | { |
| 269 | _failSafeSensors.erase(kt); |
| 270 | } |
| 271 | } |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 272 | } |
| 273 | |
Patrick Venture | de79ee0 | 2019-05-08 14:50:00 -0700 | [diff] [blame] | 274 | if (loggingEnabled) |
Patrick Venture | 5f02ad2 | 2018-04-24 10:18:40 -0700 | [diff] [blame] | 275 | { |
Patrick Venture | c32e3fc | 2019-02-28 10:01:11 -0800 | [diff] [blame] | 276 | for (const auto& t : _thermalInputs) |
| 277 | { |
| 278 | _log << "," << _cachedValuesByName[t]; |
| 279 | } |
Patrick Venture | 5f02ad2 | 2018-04-24 10:18:40 -0700 | [diff] [blame] | 280 | } |
Patrick Venture | 5f02ad2 | 2018-04-24 10:18:40 -0700 | [diff] [blame] | 281 | |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 282 | return; |
| 283 | } |
| 284 | |
| 285 | void PIDZone::updateSensors(void) |
| 286 | { |
| 287 | using namespace std::chrono; |
| 288 | /* margin and temp are stored as temp */ |
| 289 | tstamp now = high_resolution_clock::now(); |
| 290 | |
Patrick Venture | 4a2dc4d | 2018-10-23 09:02:55 -0700 | [diff] [blame] | 291 | for (const auto& t : _thermalInputs) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 292 | { |
Patrick Venture | a58197c | 2018-06-11 15:29:45 -0700 | [diff] [blame] | 293 | auto sensor = _mgr.getSensor(t); |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 294 | ReadReturn r = sensor->read(); |
Patrick Venture | 563a356 | 2018-10-30 09:31:26 -0700 | [diff] [blame] | 295 | int64_t timeout = sensor->getTimeout(); |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 296 | |
| 297 | _cachedValuesByName[t] = r.value; |
| 298 | tstamp then = r.updated; |
| 299 | |
James Feist | 473d68d | 2019-02-25 09:19:13 -0800 | [diff] [blame] | 300 | auto duration = duration_cast<std::chrono::seconds>(now - then).count(); |
| 301 | auto period = std::chrono::seconds(timeout).count(); |
| 302 | |
James Feist | 36b7d8e | 2018-10-05 15:39:01 -0700 | [diff] [blame] | 303 | if (sensor->getFailed()) |
| 304 | { |
| 305 | _failSafeSensors.insert(t); |
| 306 | } |
James Feist | 473d68d | 2019-02-25 09:19:13 -0800 | [diff] [blame] | 307 | else if (timeout != 0 && duration >= period) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 308 | { |
James Feist | 473d68d | 2019-02-25 09:19:13 -0800 | [diff] [blame] | 309 | // std::cerr << "Entering fail safe mode.\n"; |
| 310 | _failSafeSensors.insert(t); |
| 311 | } |
| 312 | else |
| 313 | { |
| 314 | // Check if it's in there: remove it. |
| 315 | auto kt = _failSafeSensors.find(t); |
| 316 | if (kt != _failSafeSensors.end()) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 317 | { |
James Feist | 473d68d | 2019-02-25 09:19:13 -0800 | [diff] [blame] | 318 | _failSafeSensors.erase(kt); |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 319 | } |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | return; |
| 324 | } |
| 325 | |
| 326 | void PIDZone::initializeCache(void) |
| 327 | { |
Patrick Venture | 4a2dc4d | 2018-10-23 09:02:55 -0700 | [diff] [blame] | 328 | for (const auto& f : _fanInputs) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 329 | { |
| 330 | _cachedValuesByName[f] = 0; |
Will Liang | ded0ab5 | 2019-05-15 17:10:06 +0800 | [diff] [blame] | 331 | |
| 332 | // Start all fans in fail-safe mode. |
| 333 | _failSafeSensors.insert(f); |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 334 | } |
| 335 | |
Patrick Venture | 4a2dc4d | 2018-10-23 09:02:55 -0700 | [diff] [blame] | 336 | for (const auto& t : _thermalInputs) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 337 | { |
| 338 | _cachedValuesByName[t] = 0; |
| 339 | |
| 340 | // Start all sensors in fail-safe mode. |
| 341 | _failSafeSensors.insert(t); |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | void PIDZone::dumpCache(void) |
| 346 | { |
| 347 | std::cerr << "Cache values now: \n"; |
Patrick Venture | 4a2dc4d | 2018-10-23 09:02:55 -0700 | [diff] [blame] | 348 | for (const auto& k : _cachedValuesByName) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 349 | { |
| 350 | std::cerr << k.first << ": " << k.second << "\n"; |
| 351 | } |
| 352 | } |
| 353 | |
Patrick Venture | 563a356 | 2018-10-30 09:31:26 -0700 | [diff] [blame] | 354 | void PIDZone::processFans(void) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 355 | { |
| 356 | for (auto& p : _fans) |
| 357 | { |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 358 | p->process(); |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 359 | } |
| 360 | } |
| 361 | |
Patrick Venture | 563a356 | 2018-10-30 09:31:26 -0700 | [diff] [blame] | 362 | void PIDZone::processThermals(void) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 363 | { |
| 364 | for (auto& p : _thermals) |
| 365 | { |
James Feist | 22c257a | 2018-08-31 14:07:12 -0700 | [diff] [blame] | 366 | p->process(); |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 367 | } |
| 368 | } |
| 369 | |
Patrick Venture | 2d8e785 | 2018-10-30 19:14:07 -0700 | [diff] [blame] | 370 | Sensor* PIDZone::getSensor(const std::string& name) |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 371 | { |
Patrick Venture | fe75b19 | 2018-06-08 11:19:43 -0700 | [diff] [blame] | 372 | return _mgr.getSensor(name); |
Patrick Venture | d801218 | 2018-03-08 08:21:38 -0800 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | bool PIDZone::manual(bool value) |
| 376 | { |
| 377 | std::cerr << "manual: " << value << std::endl; |
| 378 | setManualMode(value); |
| 379 | return ModeObject::manual(value); |
| 380 | } |
| 381 | |
| 382 | bool PIDZone::failSafe() const |
| 383 | { |
| 384 | return getFailSafeMode(); |
| 385 | } |
Patrick Venture | a076487 | 2020-08-08 07:48:43 -0700 | [diff] [blame] | 386 | |
| 387 | } // namespace pid_control |