Add func for Maximum when sensor from DBus

Add function to calculate the maximum value.

Tested:
in entity-manager/baseboard.json:
add virtual sensor use Type=Maximum:
```
    {
        "Exposes": [
            {
                "Name": "NVMe MAX Temp",
                "Sensors": [
                    "NVMe 0 Temp",
                    "NVMe 1 Temp",
                    "NVMe 2 Temp",
                    "NVMe 3 Temp",
                    "NVMe 4 Temp"
                ],
                "Thresholds": [
                    {
                        "Direction": "greater than",
                        "Name": "upper critical",
                        "Severity": 1,
                        "Value": 116
                    },
                    {
                        "Direction": "less than",
                        "Name": "lower critical",
                        "Severity": 1,
                        "Value": 1
                    }
                ],
                "Type": "Maximum",
                "Units": "DegreesC"
            }
        ],
        "Logging": "Off",
        "Name": "NVMe MAX",
        "Probe": "TRUE",
        "Type": "NVMe",
        "xyz.openbmc_project.Inventory.Item.Chassis": {}
    }
```

in phosphor-virtual-sensor/virtual_sensor_config.json
```
{
	"Desc": {
		"Config": "D-Bus",
		"Type": "Maximum"
	}
}
```

root@NULL:~# busctl  tree xyz.openbmc_project.VirtualSensor
`-/xyz
  `-/xyz/openbmc_project
      `-/xyz/openbmc_project/sensors/temperature
        |-/xyz/openbmc_project/sensors/temperature/NVMe_MAX_Temp
root@NULL:~# ipmitool sensor list | grep -i NVMe
NVMe_MAX_Temp |70| degrees C |na| na|1.000|6.000|111.000|116.000|na
root@NULL:~#

Signed-off-by: Tao Lin <lintao.lc@inspur.com>
Change-Id: I620a0ee3c3cc4dbae6485c77fe4e47c62a04a804
2 files changed
tree: 11a78d4ae759bf56c6abcda343cdc9d5eecc6d5e
  1. subprojects/
  2. .clang-format
  3. .editorconfig
  4. .gitignore
  5. .markdownlint.yaml
  6. .prettierrc.yaml
  7. dbusSensor.hpp
  8. dbusUtils.hpp
  9. exprtkTools.hpp
  10. LICENSE
  11. meson.build
  12. OWNERS
  13. phosphor-virtual-sensor.service.in
  14. README.md
  15. thresholds.hpp
  16. virtual_sensor_config.json
  17. virtualSensor.cpp
  18. virtualSensor.hpp
README.md

phosphor-virtual-sensor

phosphor-virtual-sensor reads in virtual_sensor_config.json There are two types of data in this file:

virtual sensor configuration information

See virtual_sensor_config.json in this repository for an example. Sensors added this way can use any expression that is accepted by exprtk.

information to get a virtual sensor configuraton from D-Bus

For example:

{
  "Desc": {
    "Config": "D-Bus",
    "Type": "ModifiedMedian"
  }
}

Sensors added this way can only use a set of restricted calculations. At this stage the only type supported is modifiedMedian.

The virtual sensor configuration information needs to be added into the relevant hardware configuration file in entity-manager. This method of adding a virtual sensor allows a recipe that builds for different hardware configurations to have different virtual sensors for each configuration.

The virtual sensor configuration in entity manager follows a different format to the JSON in virtual_sensor_config.json (specified in entity-manager/schemas/VirtualSensor.json).