artdaq_mfextensions  v1_05_00
qt_rule_engine.h
1 #ifndef ERROR_HANDLER_QT_RULE_ENGINE_H
2 #define ERROR_HANDLER_QT_RULE_ENGINE_H
3 
4 
5 #include "ErrorHandler/MessageAnalyzer/ma_rule_engine.h"
6 
7 #include <QtCore/QObject>
8 #include <QtCore/QVector>
9 
10 namespace fhicl
11 {
12  class ParameterSet;
13 }
14 
15 namespace novadaq {
16 namespace errorhandler {
17 
18 
19 class qt_rule_engine : public QObject
20 {
21  Q_OBJECT
22 
23 public:
24 
25  // c'tor
26  qt_rule_engine( fhicl::ParameterSet const & pset
27  , QObject *parent = 0 );
28 
29  // d'tor
30  ~qt_rule_engine();
31 
32  // rule_engine accessor
33  size_t cond_size() const { return engine.cond_size(); }
34  size_t rule_size() const { return engine.rule_size(); }
35 
36  QVector<QString> cond_names() const;
37  QVector<QString> rule_names() const;
38 
39  bool is_EHS() const { return engine.is_EHS(); }
40 
41  // raw configuration
42  fhicl::ParameterSet get_configuration() const
43  { return engine.get_configuration(); }
44 
45  // condition fields
46  QString cond_description( QString const & name ) const
47  { return QString(engine.cond_description(name.toUtf8().constData()).c_str()); }
48 
49  QString cond_sources ( QString const & name ) const
50  { return QString(engine.cond_sources(name.toUtf8().constData()).c_str()); }
51 
52  QString cond_regex ( QString const & name ) const
53  { return QString(engine.cond_regex(name.toUtf8().constData()).c_str()); }
54 
55  int cond_msg_count ( QString const & name ) const
56  { return engine.cond_msg_count(name.toUtf8().constData()); }
57 
58  // rule fields
59  QString rule_description( QString const & name ) const
60  { return QString(engine.rule_description(name.toUtf8().constData()).c_str()); }
61 
62  QString rule_expr ( QString const & name ) const
63  { return QString(engine.rule_expr(name.toUtf8().constData()).c_str()); }
64 
65  int rule_alarm_count( QString const & name ) const
66  { return engine.rule_alarm_count(name.toUtf8().constData()); }
67 
68  // name list of conditions associated with a rule
69  QVector<QString> rule_cond_names ( QString const & name ) const;
70 
71  // enable/disable the rule with given name
72  void enable_rule( QString const & name, bool flag )
73  { engine.enable_rule(name.toUtf8().constData(), flag); }
74 
75  // enable/disable action
76  void enable_EHS( bool flag )
77  { engine.enable_EHS(flag); }
78 
79  // reset named rule
80  void reset_rule( QString const & name )
81  { engine.reset_rule(name.toUtf8().constData()); }
82 
83  // reset all rules
84  void reset_rules( )
85  { engine.reset_rules(); }
86 
87  // reset named cond
88  void reset_cond( QString const & name )
89  { engine.reset_cond(name.toUtf8().constData()); }
90 
91  // reset all conds
92  void reset_conds( )
93  { engine.reset_conds(); }
94 
95  // reset everything
96  void reset( )
97  { engine.reset(); }
98 
99  // participants
100  void add_participant_group( std::string const & group )
101  { engine.add_participant_group( group ); }
102 
103  void add_participant_group( std::string const & group, size_t size )
104  { engine.add_participant_group( group, size ); }
105 
106  void add_participant ( std::string const & group, std::string const & app )
107  { engine.add_participant( group, app ); }
108 
109  void add_participant ( std::string const & app )
110  { engine.add_participant( app ); }
111 
112  size_t get_group_participant_count( std::string const & group ) const
113  { return engine.get_group_participant_count(group); }
114 
115  size_t get_participant_count( ) const
116  { return engine.get_participant_count(); }
117 
118 
119 public slots:
120 
121  // receiving a new message
122  void feed( qt_mf_msg const & msg ) { engine.feed(msg); }
123 
124 signals:
125 
126  // emits when alarms triggered
127  void alarm( QString const & /*rule name*/
128  , QString const & /*message body*/);
129 
130  void match( QString const & );
131 
132 private:
133 
134  void new_alarm ( std::string const & rule_name, std::string const & msg );
135  void cond_match( std::string const & cond_name );
136 
137 private:
138 
139  ma_rule_engine engine;
140 
141 };
142 
143 
144 } // end of errorhandler
145 } // end of novadaq
146 
147 
148 #endif
Qt wrapper around MessageFacility message
Definition: qt_mf_msg.hh:37