blob: 44c736c203682f45a29abdabb2be62ac7f3f974f [file] [log] [blame]
James Feistbc896df2018-11-26 16:28:17 -08001#pragma once
2#include "sensor.hpp"
3
4#include <boost/container/flat_map.hpp>
5#include <chrono>
6#include <limits>
7#include <vector>
8
9struct CFMInfo
10{
11 std::vector<std::string> pwm;
12 int32_t c1;
13 int32_t c2;
14 int32_t maxCFM;
15 double pwmMin;
16 double pwmMax;
17};
18
19struct ExitAirTempSensor : public Sensor
20{
21 boost::container::flat_map<std::string, double> pwmReadings;
22 boost::container::flat_map<std::string, double> powerReadings;
23 std::vector<sdbusplus::bus::match::match> matches;
24
25 double inletTemp = std::numeric_limits<double>::quiet_NaN();
26
27 double powerFactorMin;
28 double powerFactorMax;
29 double qMin;
30 double qMax;
31 double alphaS;
32 double alphaF;
33 double pOffset = 0;
34
35 std::vector<CFMInfo> cfmData;
36 ExitAirTempSensor(std::shared_ptr<sdbusplus::asio::connection> &conn,
37 const std::string &sensorConfiguration,
38 sdbusplus::asio::object_server &objectServer,
39 std::vector<thresholds::Threshold> &&thresholds);
40 ~ExitAirTempSensor();
41
42 void checkThresholds(void) override;
43 void updateReading(void);
44
45 private:
46 double lastReading;
47
48 std::shared_ptr<sdbusplus::asio::connection> dbusConnection;
49 std::chrono::time_point<std::chrono::system_clock> lastTime;
50 int32_t getTotalCFM(void);
51 bool calculate(double &val);
52 void setupMatches(void);
53};