Add a modified median calculation

This is for virtual sensors added via D-Bus.

We use the median value if there is 3 or more valid values. If there
are only two valid values we used the biggest and if there is only one
valid value we use that.

Tested:
- Modified temperature values of sensors like this:

busctl set-property xyz.openbmc_project.HwmonTempSensor
/xyz/openbmc_project/sensors/temperature/Ambient_0_Temp
xyz.openbmc_project.Sensor.Value Value d 30

and expected changes were observed in the value of the Ambient Virtual
Temp value.

busctl get-property xyz.openbmc_project.VirtualSensor
/xyz/openbmc_project/sensors/temperature/Ambient_Virtual_Temp
xyz.openbmc_project.Sensor.Value Value

- Threshold alarms were asserted and deasserted when expected.

- Temperature values were not used when out of range.

Change-Id: I58ff7dcc17c6f87209434a754f91a99f483140aa
Signed-off-by: Rashmica Gupta <rashmica.g@gmail.com>
diff --git a/virtualSensor.hpp b/virtualSensor.hpp
index ada20d9..b4fd815 100644
--- a/virtualSensor.hpp
+++ b/virtualSensor.hpp
@@ -122,6 +122,8 @@
     void setSensorValue(double value);
     /** @brief Update sensor at regular intrval */
     void updateVirtualSensor();
+    /** @brief Check if sensor value is in valid range */
+    bool sensorInRange(double value);
 
     /** @brief Map of list of parameters */
     using ParamMap =
@@ -175,7 +177,11 @@
                            const std::string& calculationType);
 
     /** @brief Returns which calculation function or expression to use */
-    double calculateValue();
+    double calculateValue(const std::string& sensortype,
+                          const VirtualSensor::ParamMap& paramMap);
+    /** @brief Calculate median value from sensors */
+    double
+        calculateModifiedMedianValue(const VirtualSensor::ParamMap& paramMap);
     /** @brief create threshold objects from json config */
     void createThresholds(const Json& threshold, const std::string& objPath);
     /** @brief parse config from entity manager **/