artdaq_mfextensions  v1_05_00
ma_cell.h
1 #ifndef ERROR_HANDLER_MA_FREQUENCY_H
2 #define ERROR_HANDLER_MA_FREQUENCY_H
3 
4 #include "ErrorHandler/MessageAnalyzer/ma_utils.h"
5 
6 #include <boost/multi_array.hpp>
7 #include <boost/regex.hpp>
8 
9 namespace novadaq {
10 namespace errorhandler {
11 
12 class ma_cell
13 {
14 public:
15  ma_cell();
16  ~ma_cell();
17 
18  // reset to ground state
19  void
20  reset( );
21 
22  // call hit method when a message passes filtering and match tests
23  // returns true if the status has changed (off->on or on->off), or
24  // false if not
25  //
26  // if persistent (persistent=true), the status never turns off.
27  // otherwise, the status can change to off when it slides out of
28  // the time window
29  bool
30  hit( qt_mf_msg const & msg
31  , boost::smatch const & w
32  , ma_condition & cond
33  , size_t s_idx
34  , size_t t_idx );
35 
36  bool event(time_t t, ma_condition & cond);
37 
38  // get status
39  bool
40  is_on() const { return on; }
41 
42  // get number of messages
43  size_t
44  get_message_count() const { return msgs.size(); }
45 
46  // get messages
47  const msgs_t &
48  get_messages() const { return msgs; }
49 
50  // get latest message
51  std::string
52  get_latest_message() const
53  { assert( !msgs.empty() ); return msgs.back().text(false).toStdString(); }
54 
55  // get group
56  std::string
57  get_message_group(size_t i) const
58  { if(i>what_.size()) throw std::runtime_error("group does not exist");
59  return std::string(what_[i].first, what_[i].second); }
60 
61 private:
62  msgs_t msgs;
63  bool on;
64 
65  // groups from last hit
66  boost::smatch what_;
67 
68  // time of next event
69  time_t t_event;
70 };
71 
72 typedef boost::multi_array<ma_cell, 2> hitmap_t;
73 typedef hitmap_t::index index_t;
74 
75 typedef hitmap_t::const_array_view<2>::type hitmap_view_t;
76 typedef hitmap_view_t ma_cond_domain_view;
77 typedef ma_cond_domain_view::const_iterator ma_cond_domain_view_iter;
78 typedef std::vector<ma_cond_domain_view_iter> ma_cond_domain_view_iters;
79 typedef std::vector<ma_cond_domain_view> ma_domain_view;
80 typedef ma_domain_view::const_iterator ma_domain_view_iter;
81 typedef std::list<ma_domain_view> ma_domain_views;
82 
83 typedef boost::multi_array_types::index_range range;
84 
85 } // end of namespace errorhandler
86 } // end of namespace novadaq
87 
88 #endif
Qt wrapper around MessageFacility message
Definition: qt_mf_msg.hh:37