artdaq_mfextensions  v1_06_02
MsgAnalyzerDlg.h
1 #ifndef _NOVA_MSG_ANALYZER_DLG_H_
2 #define _NOVA_MSG_ANALYZER_DLG_H_
3 
4 #include "ui_MsgAnalyzerDlg.h"
5 
6 #include "ErrorHandler/Components/NodeInfo.h"
7 #include "ErrorHandler/Components/qt_rule_engine.h"
8 #include "ErrorHandler/MessageAnalyzer/ma_utils.h"
9 #include "mfextensions/Receivers/ReceiverManager.hh"
10 
11 #include <QtCore/QMutex>
12 #include <QtCore/QSignalMapper>
13 #include <QtWidgets/QMenu>
14 
15 #include <boost/regex.hpp>
16 #include <boost/shared_ptr.hpp>
17 
18 #include <list>
19 #include <map>
20 #include <string>
21 
22 namespace novadaq {
23 namespace errorhandler {
24 
25 typedef boost::regex regex_t;
26 typedef std::vector<regex_t> vregex_t;
27 
28 typedef std::map<std::string, NodeInfo *> map_t;
29 
30 enum display_field_t
31 {
32  DESCRIPTION,
33  EXPRESSION
34 };
35 
36 class MsgAnalyzerDlg : public QDialog, private Ui::MsgAnalyzerDlg
37 {
38  Q_OBJECT
39 
40 public:
41  MsgAnalyzerDlg(std::string const &cfgfile, int p, QDialog *parent = 0);
42 
43  virtual ~MsgAnalyzerDlg();
44 
45 protected:
46  void closeEvent(QCloseEvent *event) final;
47 
48 private slots:
49 
50  void onNewMsg(qt_mf_msg const &mfmsg);
51  void onNewSysMsg(sev_code_t, QString const &msg);
52 
53  void onNewAlarm(QString const &rule_name, QString const &msg);
54  void onConditionMatch(QString const &name);
55 
56  void reset();
57  void exit();
58 
59  void onNodeClicked(QListWidgetItem *item);
60 
61  void show_main_context_menu(const QPoint &pos);
62  void show_dcm_context_menu(const QPoint &pos);
63  void show_evb_context_menu(const QPoint &pos);
64 
65  void context_menu_reset();
66  void context_menu_warning();
67  void context_menu_error();
68 
69  void rule_enable();
70  void rule_disable();
71  void rule_reset_selection();
72  void reset_rule(int idx);
73  void reset_rule(QString);
74 
75  void onRuleDesc(bool checked)
76  {
77  rule_display = checked ? DESCRIPTION : EXPRESSION;
78  updateRuleDisplay();
79  }
80  void onCondDesc(bool checked)
81  {
82  cond_display = checked ? DESCRIPTION : EXPRESSION;
83  updateCondDisplay();
84  }
85 
86  void onEstablishPartition(int partition);
87  void onSetParticipants(QVector<QString> const &dcm, QVector<QString> const &bnevb);
88 
89 private:
90  void reset_node_status();
91  void reset_rule_engine();
92 
93  void initNodeStatus();
94  void initParticipants();
95  void initRuleEngineTable();
96  void updateRuleDisplay();
97  void updateCondDisplay();
98 
99  void publishMessage(message_type_t type, QString const &msg) const;
100 
101  void show_context_menu(QPoint const &pos, QListWidget *list);
102  bool check_node_aow(std::string const &key);
103  bool check_node_aoe(std::string const &key);
104 
105 private:
106  // data member
107  fhicl::ParameterSet pset;
108  qt_rule_engine engine;
109  mfviewer::ReceiverManager receiver;
110 
111  map_t map;
112  int nmsgs;
113 
114  // number of rules/conditions
115  size_t rule_size;
116  size_t cond_size;
117 
118  // rule/cond name --> row index map
119  std::map<QString, int> rule_idx_map;
120  std::map<QString, int> cond_idx_map;
121 
122  // whether to show description or expression
123  display_field_t rule_display;
124  display_field_t cond_display;
125 
126  // map lock
127  QMutex map_lock;
128 
129  // signal mapper
130  QSignalMapper sig_mapper;
131 
132  // conext menu
133  QMenu *context_menu;
134  QMenu *rule_act_menu;
135  QMenu *cond_act_menu;
136 
137  // context menu actions
138  QAction *act_reset;
139  QAction *act_warning;
140  QAction *act_error;
141  QAction *act_rule_enable;
142  QAction *act_rule_disable;
143  QAction *act_rule_reset;
144 
145  // QListWidgetItem related to the context menu
146  QListWidgetItem *list_item;
147 
148  // Node Status related members
149  bool aow_any; // alarm on warning on any nodes
150  bool aoe_any; // alarm on error on any nodes
151  vregex_t e_aow; // regex expressions for aow
152  vregex_t e_aoe; // regex expressions for aoe
153  boost::smatch what_;
154 };
155 
156 } // end of namespace errorhandler
157 } // end of namespace novadaq
158 
159 #endif
Qt wrapper around MessageFacility message
Definition: qt_mf_msg.hh:37
The ReceiverManager loads one or more receiver plugins and displays messages received by those plugin...