1 #pragma once 2 #include <boost/container/flat_map.hpp> 3 #include <sdbusplus/bus/match.hpp> 4 #include <sensor.hpp> 5 6 #include <chrono> 7 #include <limits> 8 #include <memory> 9 #include <string> 10 #include <vector> 11 12 struct ExitAirTempSensor; 13 struct CFMSensor : public Sensor, std::enable_shared_from_this<CFMSensor> 14 { 15 std::vector<std::string> tachs; 16 double c1 = 0.0; 17 double c2 = 0.0; 18 double maxCFM = 0.0; 19 double tachMinPercent = 0.0; 20 double tachMaxPercent = 0.0; 21 22 std::shared_ptr<ExitAirTempSensor> parent; 23 24 CFMSensor(std::shared_ptr<sdbusplus::asio::connection>& conn, 25 const std::string& name, const std::string& sensorConfiguration, 26 sdbusplus::asio::object_server& objectServer, 27 std::vector<thresholds::Threshold>&& thresholdData, 28 std::shared_ptr<ExitAirTempSensor>& parent); 29 ~CFMSensor() override; 30 31 bool calculate(double& /*value*/); 32 void updateReading(); 33 void setupMatches(); 34 void createMaxCFMIface(); 35 void addTachRanges(const std::string& serviceName, const std::string& path); 36 void checkThresholds() override; 37 uint64_t getMaxRpm(uint64_t cfmMax) const; 38 39 private: 40 std::vector<sdbusplus::bus::match_t> matches; 41 boost::container::flat_map<std::string, double> tachReadings; 42 boost::container::flat_map<std::string, std::pair<double, double>> 43 tachRanges; 44 std::shared_ptr<sdbusplus::asio::dbus_interface> pwmLimitIface; 45 std::shared_ptr<sdbusplus::asio::dbus_interface> cfmLimitIface; 46 sdbusplus::asio::object_server& objServer; 47 }; 48 49 struct ExitAirTempSensor : 50 public Sensor, 51 std::enable_shared_from_this<ExitAirTempSensor> 52 { 53 double powerFactorMin = 0.0; 54 double powerFactorMax = 0.0; 55 double qMin = 0.0; 56 double qMax = 0.0; 57 double alphaS = 0.0; 58 double alphaF = 0.0; 59 double pOffset = 0.0; 60 61 ExitAirTempSensor(std::shared_ptr<sdbusplus::asio::connection>& conn, 62 const std::string& name, 63 const std::string& sensorConfiguration, 64 sdbusplus::asio::object_server& objectServer, 65 std::vector<thresholds::Threshold>&& thresholdData); 66 ~ExitAirTempSensor() override; 67 68 void checkThresholds() override; 69 void updateReading(); 70 void setupMatches(); 71 72 private: 73 double lastReading = 0.0; 74 75 std::vector<sdbusplus::bus::match_t> matches; 76 double inletTemp = std::numeric_limits<double>::quiet_NaN(); 77 boost::container::flat_map<std::string, double> powerReadings; 78 79 sdbusplus::asio::object_server& objServer; 80 std::chrono::time_point<std::chrono::steady_clock> lastTime; 81 static double getTotalCFM(); 82 bool calculate(double& val); 83 }; 84