sensors: Add threshold event log definitions

Add threshold event logs as defined in the Redfish SensorEvent.1.0.1.
It is expected that services use the new interface to log threshold
events while maintaining the state.

We are leaving out the implementation of ReadingCritical,
ReadingNoLongerCritical, ReadingWarning since these are equivalents
but do not specify the threshold values.

More information:

[1] https://lore.kernel.org/openbmc/SJ2PR15MB5801EA7FA684D3B21EE32CE3AB8D2@SJ2PR15MB5801.namprd15.prod.outlook.com/

Change-Id: I6159dd9c1f3f9dc6e3e5d697c2b9b4a131c9ce2e
Signed-off-by: Amithash Prasasd <amithash@meta.com>
diff --git a/gen/xyz/openbmc_project/Sensor/Threshold/meson.build b/gen/xyz/openbmc_project/Sensor/Threshold/meson.build
index 9ff9f98..5001111 100644
--- a/gen/xyz/openbmc_project/Sensor/Threshold/meson.build
+++ b/gen/xyz/openbmc_project/Sensor/Threshold/meson.build
@@ -1,8 +1,8 @@
 # Generated file; do not modify.
 generated_sources += custom_target(
     'xyz/openbmc_project/Sensor/Threshold__cpp'.underscorify(),
-    input: [ '../../../../../yaml/xyz/openbmc_project/Sensor/Threshold.errors.yaml',  ],
-    output: [ 'error.cpp', 'error.hpp',  ],
+    input: [ '../../../../../yaml/xyz/openbmc_project/Sensor/Threshold.errors.yaml', '../../../../../yaml/xyz/openbmc_project/Sensor/Threshold.events.yaml',  ],
+    output: [ 'error.cpp', 'error.hpp', 'event.cpp', 'event.hpp',  ],
     depend_files: sdbusplusplus_depfiles,
     command: [
         sdbuspp_gen_meson_prog, '--command', 'cpp',
diff --git a/gen/xyz/openbmc_project/Sensor/meson.build b/gen/xyz/openbmc_project/Sensor/meson.build
index 7b9c7a0..f2b948e 100644
--- a/gen/xyz/openbmc_project/Sensor/meson.build
+++ b/gen/xyz/openbmc_project/Sensor/meson.build
@@ -32,7 +32,7 @@
 subdir('Threshold')
 generated_others += custom_target(
     'xyz/openbmc_project/Sensor/Threshold__markdown'.underscorify(),
-    input: [ '../../../../yaml/xyz/openbmc_project/Sensor/Threshold.errors.yaml',  ],
+    input: [ '../../../../yaml/xyz/openbmc_project/Sensor/Threshold.errors.yaml', '../../../../yaml/xyz/openbmc_project/Sensor/Threshold.events.yaml',  ],
     output: [ 'Threshold.md' ],
     depend_files: sdbusplusplus_depfiles,
     command: [
diff --git a/yaml/xyz/openbmc_project/Sensor/Threshold.events.yaml b/yaml/xyz/openbmc_project/Sensor/Threshold.events.yaml
new file mode 100644
index 0000000..af9a958
--- /dev/null
+++ b/yaml/xyz/openbmc_project/Sensor/Threshold.events.yaml
@@ -0,0 +1,399 @@
+version: 1.0.0
+
+errors:
+    - name: InvalidSensorReading
+      severity: warning
+      errno: EIO
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+      redfish-mapping: SensorEvent.InvalidSensorReading
+
+    - name: ReadingAboveLowerCriticalThreshold
+      severity: warning
+      errno: ERANGE
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+          - name: READING_VALUE
+            description: The reading of the sensor.
+            type: double
+            primary: true
+          - name: UNITS
+            description: The reading units of measure.
+            type: enum[xyz.openbmc_project.Sensor.Value.Unit]
+            primary: true
+          - name: THRESHOLD_VALUE
+            description: The configured threshold value for this sensor.
+            type: double
+            primary: true
+      redfish-mapping: SensorEvent.ReadingAboveLowerCriticalThreshold
+
+    - name: ReadingAboveLowerSoftShutdownThreshold
+      severity: critical
+      errno: ERANGE
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+          - name: READING_VALUE
+            description: The reading of the sensor.
+            type: double
+            primary: true
+          - name: UNITS
+            description: The reading units of measure.
+            type: enum[xyz.openbmc_project.Sensor.Value.Unit]
+            primary: true
+          - name: THRESHOLD_VALUE
+            description: The configured threshold value for this sensor.
+            type: double
+            primary: true
+      redfish-mapping: SensorEvent.ReadingAboveLowerFatalThreshold
+
+    - name: ReadingAboveLowerHardShutdownThreshold
+      severity: critical
+      errno: ERANGE
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+          - name: READING_VALUE
+            description: The reading of the sensor.
+            type: double
+            primary: true
+          - name: UNITS
+            description: The reading units of measure.
+            type: enum[xyz.openbmc_project.Sensor.Value.Unit]
+            primary: true
+          - name: THRESHOLD_VALUE
+            description: The configured threshold value for this sensor.
+            type: double
+            primary: true
+      redfish-mapping: SensorEvent.ReadingAboveLowerFatalThreshold
+
+    - name: ReadingAboveUpperWarningThreshold
+      severity: warning
+      errno: ERANGE
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+          - name: READING_VALUE
+            description: The reading of the sensor.
+            type: double
+            primary: true
+          - name: UNITS
+            description: The reading units of measure.
+            type: enum[xyz.openbmc_project.Sensor.Value.Unit]
+            primary: true
+          - name: THRESHOLD_VALUE
+            description: The configured threshold value for this sensor.
+            type: double
+            primary: true
+      redfish-mapping: SensorEvent.ReadingAboveUpperCautionThreshold
+
+    - name: ReadingAboveUpperPerformanceLossThreshold
+      severity: warning
+      errno: ERANGE
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+          - name: READING_VALUE
+            description: The reading of the sensor.
+            type: double
+            primary: true
+          - name: UNITS
+            description: The reading units of measure.
+            type: enum[xyz.openbmc_project.Sensor.Value.Unit]
+            primary: true
+          - name: THRESHOLD_VALUE
+            description: The configured threshold value for this sensor.
+            type: double
+            primary: true
+      redfish-mapping: SensorEvent.ReadingAboveUpperCautionThreshold
+
+    - name: ReadingAboveUpperCriticalThreshold
+      severity: critical
+      errno: ERANGE
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+          - name: READING_VALUE
+            description: The reading of the sensor.
+            type: double
+            primary: true
+          - name: UNITS
+            description: The reading units of measure.
+            type: enum[xyz.openbmc_project.Sensor.Value.Unit]
+            primary: true
+          - name: THRESHOLD_VALUE
+            description: The configured threshold value for this sensor.
+            type: double
+            primary: true
+      redfish-mapping: SensorEvent.ReadingAboveUpperCriticalThreshold
+
+    - name: ReadingAboveUpperSoftShutdownThreshold
+      severity: critical
+      errno: ERANGE
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+          - name: READING_VALUE
+            description: The reading of the sensor.
+            type: double
+            primary: true
+          - name: UNITS
+            description: The reading units of measure.
+            type: enum[xyz.openbmc_project.Sensor.Value.Unit]
+            primary: true
+          - name: THRESHOLD_VALUE
+            description: The configured threshold value for this sensor.
+            type: double
+            primary: true
+      redfish-mapping: SensorEvent.ReadingAboveUpperFatalThreshold
+
+    - name: ReadingAboveUpperHardShutdownThreshold
+      severity: critical
+      errno: ERANGE
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+          - name: READING_VALUE
+            description: The reading of the sensor.
+            type: double
+            primary: true
+          - name: UNITS
+            description: The reading units of measure.
+            type: enum[xyz.openbmc_project.Sensor.Value.Unit]
+            primary: true
+          - name: THRESHOLD_VALUE
+            description: The configured threshold value for this sensor.
+            type: double
+            primary: true
+      redfish-mapping: SensorEvent.ReadingAboveUpperFatalThreshold
+
+    - name: ReadingBelowLowerWarningThreshold
+      severity: warning
+      errno: ERANGE
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+          - name: READING_VALUE
+            description: The reading of the sensor.
+            type: double
+            primary: true
+          - name: UNITS
+            description: The reading units of measure.
+            type: enum[xyz.openbmc_project.Sensor.Value.Unit]
+            primary: true
+          - name: THRESHOLD_VALUE
+            description: The configured threshold value for this sensor.
+            type: double
+            primary: true
+      redfish-mapping: SensorEvent.ReadingBelowLowerCautionThreshold
+
+    - name: ReadingBelowLowerPerformanceLossThreshold
+      severity: warning
+      errno: ERANGE
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+          - name: READING_VALUE
+            description: The reading of the sensor.
+            type: double
+            primary: true
+          - name: UNITS
+            description: The reading units of measure.
+            type: enum[xyz.openbmc_project.Sensor.Value.Unit]
+            primary: true
+          - name: THRESHOLD_VALUE
+            description: The configured threshold value for this sensor.
+            type: double
+            primary: true
+      redfish-mapping: SensorEvent.ReadingBelowLowerCautionThreshold
+
+    - name: ReadingBelowLowerCriticalThreshold
+      severity: critical
+      errno: ERANGE
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+          - name: READING_VALUE
+            description: The reading of the sensor.
+            type: double
+            primary: true
+          - name: UNITS
+            description: The reading units of measure.
+            type: enum[xyz.openbmc_project.Sensor.Value.Unit]
+            primary: true
+          - name: THRESHOLD_VALUE
+            description: The configured threshold value for this sensor.
+            type: double
+            primary: true
+      redfish-mapping: SensorEvent.ReadingBelowLowerCriticalThreshold
+
+    - name: ReadingBelowLowerSoftShutdownThreshold
+      severity: critical
+      errno: ERANGE
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+          - name: READING_VALUE
+            description: The reading of the sensor.
+            type: double
+            primary: true
+          - name: UNITS
+            description: The reading units of measure.
+            type: enum[xyz.openbmc_project.Sensor.Value.Unit]
+            primary: true
+          - name: THRESHOLD_VALUE
+            description: The configured threshold value for this sensor.
+            type: double
+            primary: true
+      redfish-mapping: SensorEvent.ReadingBelowLowerFatalThreshold
+
+    - name: ReadingBelowLowerHardShutdownThreshold
+      severity: critical
+      errno: ERANGE
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+          - name: READING_VALUE
+            description: The reading of the sensor.
+            type: double
+            primary: true
+          - name: UNITS
+            description: The reading units of measure.
+            type: enum[xyz.openbmc_project.Sensor.Value.Unit]
+            primary: true
+          - name: THRESHOLD_VALUE
+            description: The configured threshold value for this sensor.
+            type: double
+            primary: true
+      redfish-mapping: SensorEvent.ReadingBelowLowerFatalThreshold
+
+    - name: ReadingBelowUpperCriticalThreshold
+      severity: warning
+      errno: ERANGE
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+          - name: READING_VALUE
+            description: The reading of the sensor.
+            type: double
+            primary: true
+          - name: UNITS
+            description: The reading units of measure.
+            type: enum[xyz.openbmc_project.Sensor.Value.Unit]
+            primary: true
+          - name: THRESHOLD_VALUE
+            description: The configured threshold value for this sensor.
+            type: double
+            primary: true
+      redfish-mapping: SensorEvent.ReadingBelowUpperCriticalThreshold
+
+    - name: ReadingBelowUpperSoftShutdownThreshold
+      severity: critical
+      errno: ERANGE
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+          - name: READING_VALUE
+            description: The reading of the sensor.
+            type: double
+            primary: true
+          - name: UNITS
+            description: The reading units of measure.
+            type: enum[xyz.openbmc_project.Sensor.Value.Unit]
+            primary: true
+          - name: THRESHOLD_VALUE
+            description: The configured threshold value for this sensor.
+            type: double
+            primary: true
+      redfish-mapping: SensorEvent.ReadingBelowFatalThreshold
+
+    - name: ReadingBelowUpperHardShutdownThreshold
+      severity: critical
+      errno: ERANGE
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+          - name: READING_VALUE
+            description: The reading of the sensor.
+            type: double
+            primary: true
+          - name: UNITS
+            description: The reading units of measure.
+            type: enum[xyz.openbmc_project.Sensor.Value.Unit]
+            primary: true
+          - name: THRESHOLD_VALUE
+            description: The configured threshold value for this sensor.
+            type: double
+            primary: true
+      redfish-mapping: SensorEvent.ReadingBelowFatalThreshold
+
+    - name: SensorFailure
+      severity: critical
+      errno: EIO
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+      redfish-mapping: SensorEvent.SensorFailure
+
+events:
+    - name: SensorReadingNormalRange
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+          - name: READING_VALUE
+            description: The reading of the sensor.
+            type: double
+            primary: true
+          - name: UNITS
+            description: The reading units of measure.
+            type: enum[xyz.openbmc_project.Sensor.Value.Unit]
+            primary: true
+      redfish-mapping: SensorEvent.SensorReadingNormalRange
+
+    - name: SensorRestored
+      metadata:
+          - name: SENSOR_NAME
+            description: The name or identifier of the sensor.
+            type: object_path
+            primary: true
+      redfish-mapping: SensorEvent.SensorRestored