Lines Matching +full:range +full:- +full:double
8 // http://www.apache.org/licenses/LICENSE-2.0
23 #include <phosphor-logging/lg2.hpp>
34 static constexpr double sysPwmMax = 255.0;
35 static constexpr double psuPwmMax = 100.0;
36 static constexpr double defaultPwm = 30.0;
37 static constexpr double targetIfaceMax = sysPwmMax;
68 double fValue = 100.0 * (static_cast<double>(pwmValue) / pwmMax); in PwmSensor()
69 sensorInterface->register_property( in PwmSensor()
71 [this](const double& req, double& resp) { in PwmSensor()
74 // Reject attempted change, if to NaN or other non-numeric in PwmSensor()
75 return -1; in PwmSensor()
81 throw std::runtime_error("Value out of range"); in PwmSensor()
82 return -1; in PwmSensor()
85 double reqValue = (req / 100.0) * pwmMax; in PwmSensor()
86 double respValue = (resp / 100.0) * pwmMax; in PwmSensor()
89 // Avoid floating-point equality, compare as integers in PwmSensor()
97 controlInterface->signal_property("Target"); in PwmSensor()
101 [this](double& curVal) { in PwmSensor()
102 double currScaled = (curVal / 100.0) * pwmMax; in PwmSensor()
105 // Avoid floating-point equality, compare as integers in PwmSensor()
108 double getScaled = in PwmSensor()
109 100.0 * (static_cast<double>(getInt) / pwmMax); in PwmSensor()
111 controlInterface->signal_property("Target"); in PwmSensor()
112 sensorInterface->signal_property("Value"); in PwmSensor()
117 sensorInterface->register_property("MaxValue", static_cast<double>(100)); in PwmSensor()
118 sensorInterface->register_property("MinValue", static_cast<double>(0)); in PwmSensor()
119 sensorInterface->register_property("Unit", sensor_paths::unitPercent); in PwmSensor()
124 controlInterface->register_property( in PwmSensor()
129 throw std::runtime_error("Value out of range"); in PwmSensor()
130 return -1; in PwmSensor()
136 auto scaledValue = static_cast<double>(req) / targetIfaceMax; in PwmSensor()
141 sensorInterface->signal_property("Value"); in PwmSensor()
147 auto scaledValue = static_cast<double>(getInt) / pwmMax; in PwmSensor()
153 controlInterface->signal_property("Target"); in PwmSensor()
154 sensorInterface->signal_property("Value"); in PwmSensor()
159 sensorInterface->initialize(); in PwmSensor()
160 controlInterface->initialize(); in PwmSensor()
166 conn, sensorInterface->get_object_path(), in PwmSensor()
168 valueMutabilityInterface->register_property("Mutable", true); in PwmSensor()
169 if (!valueMutabilityInterface->initialize()) in PwmSensor()