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>
2 files changed