Add MaxValue/MinValue setting in config
- Adding MaxValue, MinValue setting in json config file,
so sel-logger could show correct sensor value on journal log
if user set MaxValue, MinValue in config.
Tested:
- set MaxValue: 127, MinValue: -128
- modified virtual sensor formula to let trigger CriticalHigh
- trigger threshold and see journal log and sel log
Jan 01 00:48:29 gbs sel-logger[435]: i2cool_0 sensor crossed a warning high threshold going high. Reading=57.000000 Threshold=35.000000.
Jan 01 00:48:29 gbs sel-logger[435]: i2cool_0 sensor crossed a critical high threshold going high. Reading=57.000000 Threshold=35.000000.
1 | Pre-Init |0000002909| Temperature i2cool_0 | Upper Critical going high | Asserted | Reading 57 > Threshold 35 degrees C
Signed-off-by: Harvey Wu <Harvey.Wu@quantatw.com>
Change-Id: I6d908fc206ef9c50316df606f71f47316ae6f9cf
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/virtualSensor.cpp b/virtualSensor.cpp
index e136db1..29e71eb 100644
--- a/virtualSensor.cpp
+++ b/virtualSensor.cpp
@@ -148,6 +148,19 @@
}
}
+ /* Get MaxValue, MinValue setting if defined in config */
+ auto confDesc = sensorConfig.value("Desc", empty);
+ if (auto maxConf = confDesc.find("MaxValue");
+ maxConf != confDesc.end() && maxConf->is_number())
+ {
+ ValueIface::maxValue(maxConf->get<double>());
+ }
+ if (auto minConf = confDesc.find("MinValue");
+ minConf != confDesc.end() && minConf->is_number())
+ {
+ ValueIface::minValue(minConf->get<double>());
+ }
+
/* Get expression string */
exprStr = sensorConfig.value("Expression", "");
diff --git a/virtual_sensor_config.json b/virtual_sensor_config.json
index a394fae..6ccc403 100644
--- a/virtual_sensor_config.json
+++ b/virtual_sensor_config.json
@@ -3,7 +3,9 @@
"Desc" :
{
"Name" : "Virtual_Inlet_Temp",
- "SensorType" : "temperature"
+ "SensorType" : "temperature",
+ "MaxValue": 127.0,
+ "MinValue": -128.0
},
"Threshold" :
{