Line data Source code
1 :
2 : #include "ErrorHandler/MessageAnalyzer/ma_function_count.h"
3 : #include "ErrorHandler/MessageAnalyzer/ma_condition.h"
4 : #include "ErrorHandler/MessageAnalyzer/ma_participants.h"
5 :
6 : #include <boost/algorithm/string.hpp>
7 :
8 : using namespace novadaq::errorhandler;
9 :
10 0 : REG_MA_FUNCTION(count, ma_func_count)
11 :
12 0 : bool ma_func_count::parse_arguments(anys_t const& args)
13 : {
14 : // override 1: int count(cond)
15 0 : if (args.empty())
16 : {
17 0 : count_type = NONE;
18 0 : return true;
19 : }
20 :
21 : // override 2: double count(cond, 'type')
22 : // return the absolute value of count(cond) in the given type
23 : // type = 'SOURCE'
24 : // type = 'TARGET'
25 : // type = 'MESSAGE'
26 0 : std::string type = boost::any_cast<std::string>(args[0]);
27 0 : boost::to_upper(type);
28 :
29 0 : if (type == "SOURCE")
30 0 : count_type = SOURCE;
31 0 : else if (type == "TARGET")
32 0 : count_type = TARGET;
33 0 : else if (type == "MESSAGE")
34 0 : count_type = NONE;
35 : else
36 0 : return false;
37 :
38 0 : return true;
39 0 : }
40 :
41 : boost::any
42 0 : ma_func_count::evaluate(ma_condition const& cond, ma_cond_domain dom)
43 : {
44 : // get triggering count from hitmap of the condition with give domain
45 0 : int count = cond.get_alarm_count(dom, count_type);
46 :
47 0 : TLOG(TLVL_DEBUG) << "count = " << count;
48 :
49 0 : return boost::any(count);
50 : }
|