Break CFM out into its own sensor
Break CFM out into its own sensor to be the System Airflow
sensor. Also change CFM calculation to use rpm instead of pwm
as it is more accurate.
Change-Id: Ic152465f8c0cd9256176b6a673f121562cff8580
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/include/ExitAirTempSensor.hpp b/include/ExitAirTempSensor.hpp
index 44c736c..f18fd9b 100644
--- a/include/ExitAirTempSensor.hpp
+++ b/include/ExitAirTempSensor.hpp
@@ -6,23 +6,40 @@
#include <limits>
#include <vector>
-struct CFMInfo
+struct ExitAirTempSensor;
+struct CFMSensor : public Sensor
{
- std::vector<std::string> pwm;
+ std::vector<std::string> tachs;
int32_t c1;
int32_t c2;
int32_t maxCFM;
- double pwmMin;
- double pwmMax;
+ double tachMinPercent;
+ double tachMaxPercent;
+
+ std::shared_ptr<ExitAirTempSensor> parent;
+
+ CFMSensor(std::shared_ptr<sdbusplus::asio::connection> &conn,
+ const std::string &name, const std::string &sensorConfiguration,
+ sdbusplus::asio::object_server &objectServer,
+ std::vector<thresholds::Threshold> &&thresholds,
+ std::shared_ptr<ExitAirTempSensor> &parent);
+ ~CFMSensor() = default;
+
+ bool calculate(double &);
+ void updateReading(void);
+ void checkThresholds(void) override;
+
+ private:
+ std::vector<sdbusplus::bus::match::match> matches;
+ boost::container::flat_map<std::string, double> tachReadings;
+ boost::container::flat_map<std::string, std::pair<double, double>>
+ tachRanges;
+ std::shared_ptr<sdbusplus::asio::connection> dbusConnection;
+ void addTachRanges(const std::string &serviceName, const std::string &path);
};
struct ExitAirTempSensor : public Sensor
{
- boost::container::flat_map<std::string, double> pwmReadings;
- boost::container::flat_map<std::string, double> powerReadings;
- std::vector<sdbusplus::bus::match::match> matches;
-
- double inletTemp = std::numeric_limits<double>::quiet_NaN();
double powerFactorMin;
double powerFactorMax;
@@ -32,8 +49,12 @@
double alphaF;
double pOffset = 0;
- std::vector<CFMInfo> cfmData;
+ // todo: make this private once we don't have to hack in a reading
+ boost::container::flat_map<std::string, double> powerReadings;
+
+ std::vector<std::unique_ptr<CFMSensor>> cfmSensors;
ExitAirTempSensor(std::shared_ptr<sdbusplus::asio::connection> &conn,
+ const std::string &name,
const std::string &sensorConfiguration,
sdbusplus::asio::object_server &objectServer,
std::vector<thresholds::Threshold> &&thresholds);
@@ -45,9 +66,12 @@
private:
double lastReading;
+ std::vector<sdbusplus::bus::match::match> matches;
+ double inletTemp = std::numeric_limits<double>::quiet_NaN();
+
std::shared_ptr<sdbusplus::asio::connection> dbusConnection;
std::chrono::time_point<std::chrono::system_clock> lastTime;
- int32_t getTotalCFM(void);
+ double getTotalCFM(void);
bool calculate(double &val);
void setupMatches(void);
};
\ No newline at end of file