sensor.hpp (ac47309f62f91ccfa421e432eb7ff9f7a1da9613) | sensor.hpp (043d32306e00484afc446a44789b61869ea14f84) |
---|---|
1#pragma once 2 | 1#pragma once 2 |
3#include <unordered_set> 4#include "types.hpp" 5#include "sensorset.hpp" | |
6#include "hwmonio.hpp" | 3#include "hwmonio.hpp" |
4#include "sensorset.hpp" 5#include "types.hpp" |
|
7 | 6 |
7#include <unordered_set> 8 |
|
8namespace sensor 9{ 10 11struct valueAdjust 12{ 13 double gain = 1.0; 14 int offset = 0; 15 std::unordered_set<int> rmRCs; 16}; 17 18/** @class Sensor 19 * @brief Sensor object based on a SensorSet container's key type 20 * @details Sensor object to create and modify an associated device's sensor 21 * attributes based on the key type of each sensor in the set provided by the 22 * device. 23 */ 24class Sensor 25{ | 9namespace sensor 10{ 11 12struct valueAdjust 13{ 14 double gain = 1.0; 15 int offset = 0; 16 std::unordered_set<int> rmRCs; 17}; 18 19/** @class Sensor 20 * @brief Sensor object based on a SensorSet container's key type 21 * @details Sensor object to create and modify an associated device's sensor 22 * attributes based on the key type of each sensor in the set provided by the 23 * device. 24 */ 25class Sensor 26{ |
26 public: 27 Sensor() = delete; 28 Sensor(const Sensor&) = delete; 29 Sensor(Sensor&&) = default; 30 Sensor& operator=(const Sensor&) = delete; 31 Sensor& operator=(Sensor&&) = default; 32 ~Sensor() = default; | 27 public: 28 Sensor() = delete; 29 Sensor(const Sensor&) = delete; 30 Sensor(Sensor&&) = default; 31 Sensor& operator=(const Sensor&) = delete; 32 Sensor& operator=(Sensor&&) = default; 33 ~Sensor() = default; |
33 | 34 |
34 /** 35 * @brief Constructs Sensor object 36 * 37 * @param[in] sensor - A pair of sensor indentifiers 38 * @param[in] ioAccess - Hwmon sysfs access 39 * @param[in] devPath - Device sysfs path 40 */ 41 explicit Sensor(const SensorSet::key_type& sensor, 42 const hwmonio::HwmonIO& ioAccess, 43 const std::string& devPath); | 35 /** 36 * @brief Constructs Sensor object 37 * 38 * @param[in] sensor - A pair of sensor indentifiers 39 * @param[in] ioAccess - Hwmon sysfs access 40 * @param[in] devPath - Device sysfs path 41 */ 42 explicit Sensor(const SensorSet::key_type& sensor, 43 const hwmonio::HwmonIO& ioAccess, 44 const std::string& devPath); |
44 | 45 |
45 /** 46 * @brief Adds any sensor removal return codes for the sensor 47 * @details Add all return codes defined within a device's config file 48 * for the entire device or for the specific sensor. 49 * 50 * @param[in] rcList - List of return codes found for the sensor 51 */ 52 void addRemoveRCs(const std::string& rcList); | 46 /** 47 * @brief Adds any sensor removal return codes for the sensor 48 * @details Add all return codes defined within a device's config file 49 * for the entire device or for the specific sensor. 50 * 51 * @param[in] rcList - List of return codes found for the sensor 52 */ 53 void addRemoveRCs(const std::string& rcList); |
53 | 54 |
54 /** 55 * @brief Get the adjustments struct for the sensor 56 * 57 * @return - Sensor adjustment struct 58 */ 59 inline const valueAdjust& getAdjusts() 60 { 61 return sensorAdjusts; 62 } | 55 /** 56 * @brief Get the adjustments struct for the sensor 57 * 58 * @return - Sensor adjustment struct 59 */ 60 inline const valueAdjust& getAdjusts() 61 { 62 return sensorAdjusts; 63 } |
63 | 64 |
64 /** 65 * @brief Adjusts a sensor value 66 * @details Adjusts the value given by any gain and/or offset defined 67 * for this sensor object and returns that adjusted value. 68 * 69 * @param[in] value - Value to be adjusted 70 * 71 * @return - Adjusted sensor value 72 */ 73 int64_t adjustValue(int64_t value); | 65 /** 66 * @brief Adjusts a sensor value 67 * @details Adjusts the value given by any gain and/or offset defined 68 * for this sensor object and returns that adjusted value. 69 * 70 * @param[in] value - Value to be adjusted 71 * 72 * @return - Adjusted sensor value 73 */ 74 int64_t adjustValue(int64_t value); |
74 | 75 |
75 /** 76 * @brief Add value interface and value property for sensor 77 * @details When a sensor has an associated input file, the Sensor.Value 78 * interface is added along with setting the Value property to the 79 * corresponding value found in the input file. 80 * 81 * @param[in] retryIO - Hwmon sysfs file retry constraints 82 * (number of and delay between) 83 * @param[in] info - Sensor object information 84 * 85 * @return - Shared pointer to the value object 86 */ 87 std::shared_ptr<ValueObject> addValue( 88 const RetryIO& retryIO, 89 ObjectInfo& info); | 76 /** 77 * @brief Add value interface and value property for sensor 78 * @details When a sensor has an associated input file, the Sensor.Value 79 * interface is added along with setting the Value property to the 80 * corresponding value found in the input file. 81 * 82 * @param[in] retryIO - Hwmon sysfs file retry constraints 83 * (number of and delay between) 84 * @param[in] info - Sensor object information 85 * 86 * @return - Shared pointer to the value object 87 */ 88 std::shared_ptr<ValueObject> addValue(const RetryIO& retryIO, 89 ObjectInfo& info); |
90 | 90 |
91 /** 92 * @brief Add status interface and functional property for sensor 93 * @details When a sensor has an associated fault file, the 94 * OperationalStatus interface is added along with setting the 95 * Functional property to the corresponding value found in the 96 * fault file. 97 * 98 * @param[in] info - Sensor object information 99 * 100 * @return - Shared pointer to the status object 101 */ 102 std::shared_ptr<StatusObject> addStatus( 103 ObjectInfo& info); | 91 /** 92 * @brief Add status interface and functional property for sensor 93 * @details When a sensor has an associated fault file, the 94 * OperationalStatus interface is added along with setting the 95 * Functional property to the corresponding value found in the 96 * fault file. 97 * 98 * @param[in] info - Sensor object information 99 * 100 * @return - Shared pointer to the status object 101 */ 102 std::shared_ptr<StatusObject> addStatus(ObjectInfo& info); |
104 | 103 |
105 private: 106 /** @brief Sensor object's identifiers */ 107 SensorSet::key_type sensor; | 104 private: 105 /** @brief Sensor object's identifiers */ 106 SensorSet::key_type sensor; |
108 | 107 |
109 /** @brief Hwmon sysfs access. */ 110 const hwmonio::HwmonIO& ioAccess; | 108 /** @brief Hwmon sysfs access. */ 109 const hwmonio::HwmonIO& ioAccess; |
111 | 110 |
112 /** @brief Physical device sysfs path. */ 113 const std::string& devPath; | 111 /** @brief Physical device sysfs path. */ 112 const std::string& devPath; |
114 | 113 |
115 /** @brief Structure for storing sensor adjustments */ 116 valueAdjust sensorAdjusts; | 114 /** @brief Structure for storing sensor adjustments */ 115 valueAdjust sensorAdjusts; |
117}; 118 119} // namespace sensor | 116}; 117 118} // namespace sensor |