Add median* condition
The median condition determines the median value from a configured group
of properties and checks that against a defined condition to determine
whether or not the callback is called.
*Note: When 2 properties are used with the median condition, the
property determined to be the max is used instead of the average of the
2 properties. This is for providing a "worst case" median value.
An example would be to create a group consisting of multiple ambient
sensors where the median value from these ambient sensors would be used
to shutdown the system if above a given temperature.
i.e.)
- name: median temps
description: >
'If this condition passes the median ambient temperature
is too high(>= 45C). Shut the system down.'
class: condition
condition: median
paths: ambient sensors
properties: ambient temp
callback: ambient log and shutdown
op: '>='
bound: 45000
oneshot: true
Tested:
A defined median condition is generated according to the
MedianCondition class
The MedianCondition class produces a single median value from a
group of property values
Median value used against the given operation to determine if
callback is called or not
Change-Id: Icd53e1a6e30a263b7706a935f040eea97dcc2414
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/src/templates/generated.mako.hpp b/src/templates/generated.mako.hpp
index d0a5ead..3436b49 100644
--- a/src/templates/generated.mako.hpp
+++ b/src/templates/generated.mako.hpp
@@ -6,6 +6,7 @@
#include <chrono>
#include <string>
#include "count.hpp"
+#include "median.hpp"
#include "data_types.hpp"
#include "journal.hpp"
#include "elog.hpp"
diff --git a/src/templates/median.mako.cpp b/src/templates/median.mako.cpp
new file mode 100644
index 0000000..7730483
--- /dev/null
+++ b/src/templates/median.mako.cpp
@@ -0,0 +1,4 @@
+std::make_unique<MedianCondition<${c.datatype}>>(
+${indent(1)}ConfigPropertyIndicies::get()[${c.instances}],
+${indent(1)}[](const auto& item){return item ${c.op} ${c.bound.argument(loader, indent=indent +1)};},
+${indent(1)}${c.oneshot.argument(loader, indent=indent +1)})\