artdaq_mfextensions  v1_05_00
ma_function_count.cpp
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 
9 using namespace novadaq::errorhandler;
10 
11 REG_MA_FUNCTION( count, ma_func_count )
12 
13 bool
14  ma_func_count::parse_arguments( anys_t const & args )
15 {
16  // override 1: int count(cond)
17  if( args.empty() )
18  {
19  count_type = NONE;
20  return true;
21  }
22 
23  // override 2: double count(cond, 'type')
24  // return the absolute value of count(cond) in the given type
25  // type = 'SOURCE'
26  // type = 'TARGET'
27  // type = 'MESSAGE'
28  std::string type = boost::any_cast<std::string>(args[0]);
29  boost::to_upper(type);
30 
31  if( type == "SOURCE" ) count_type = SOURCE;
32  else if( type == "TARGET" ) count_type = TARGET;
33  else if( type == "MESSAGE" ) count_type = NONE;
34  else return false;
35 
36  return true;
37 }
38 
39 boost::any
40  ma_func_count::evaluate( ma_condition const & cond
41  , ma_cond_domain dom )
42 {
43  // get triggering count from hitmap of the condition with give domain
44  int count = cond.get_alarm_count( dom, count_type );
45 
46  TLOG(TLVL_DEBUG) << "count = " << count;
47 
48  return boost::any(count);
49 }
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60