artdaq_mfextensions  v1_03_01
mvdlg.hh
1 #ifndef MSGVIEWERDLG_H
2 #define MSGVIEWERDLG_H
3 
4 #include "ui_msgviewerdlgui.h"
5 #include "mfextensions/Extensions/throttle.hh"
6 #include "mfextensions/Extensions/suppress.hh"
7 #include "mfextensions/Receivers/qt_mf_msg.hh"
8 #include "mfextensions/Binaries/ReceiverManager.hh"
9 
10 #include <QtCore/QTimer>
11 #include <QtCore/QMutex>
12 
13 #include <boost/regex.hpp>
14 
15 #include <string>
16 #include <vector>
17 #include <map>
18 #include <list>
19 
20 namespace fhicl
21 {
22  class ParameterSet;
23 }
24 
28 class msgViewerDlg : public QDialog, private Ui::MsgViewerDlg
29 {
30  Q_OBJECT
31 
32 public:
33  msgViewerDlg(std::string const& conf, QDialog* parent = 0);
34 
35  virtual ~msgViewerDlg();
36 
37 
38 public slots:
39 
40  void pause();
41 
42  void exit();
43 
44  void clear();
45 
46  void shortMode();
47 
48  void changeSeverity(int sev);
49 
50 protected:
51  void closeEvent(QCloseEvent* event);
52 
53 private slots:
54 
55  void onNewMsg(qt_mf_msg const& mfmsg);
56 
57  void setFilter();
58 
59  void renderMode();
60 
61  void setSevError();
62 
63  void setSevWarning();
64 
65  void setSevInfo();
66 
67  void setSevDebug();
68 
69  void searchMsg();
70 
71  void searchClear();
72 
73  void setSuppression(QAction* act);
74 
75  void setThrottling(QAction* act);
76 
77  void tabWidgetCurrentChanged(int newTab);
78 
79  void tabCloseRequested(int tabIndex);
80 
81  //---------------------------------------------------------------------------
82 
83 private:
84 
85  // Display all messages stored in the buffer
86  void displayMsg(int display);
87 
88  void updateDisplays();
89 
90  // test if the message is suppressed or throttled
91  bool msg_throttled(qt_mf_msg const& mfmsg);
92 
93  unsigned int update_index(msgs_t::iterator it);
94 
95  // Update the list. Returns true if there's a change in the selection
96  // before and after the update. e.g., the selected entry has been deleted
97  // during the process of updateMap(); otherwise it returns a false.
98  template <typename M>
99  bool updateList(QListWidget* lw, M const& map);
100 
101  void displayMsg(msgs_t::const_iterator it, int display);
102 
103  void readSettings();
104 
105  void writeSettings();
106 
107  void parseConf(fhicl::ParameterSet const& conf);
108 
109  QStringList toQStringList(QList<QListWidgetItem *> in);
110 
111  msg_iters_t list_intersect(msg_iters_t const& l1, msg_iters_t const& l2);
112 
113  //---------------------------------------------------------------------------
114 
115 private:
116  bool updating;
117  bool paused;
118  bool shortMode_;
119 
120  // # of received messages
121  int nMsgs;
122  int nSupMsgs; // suppressed msgs
123  int nThrMsgs; // throttled msgs
124  int nFilters;
125 
126  // Rendering messages in speed mode or full mode
127  bool simpleRender;
128 
129  // severity threshold
130  sev_code_t sevThresh;
131 
132  // suppression regex
133  std::vector<suppress> e_sup_host;
134  std::vector<suppress> e_sup_app;
135  std::vector<suppress> e_sup_cat;
136 
137  // throttling regex
138  std::vector<throttle> e_thr_host;
139  std::vector<throttle> e_thr_app;
140  std::vector<throttle> e_thr_cat;
141 
142  // search string
143  QString searchStr;
144 
145  // msg pool storing the formatted text body
146  msgs_t msg_pool_;
147 
148  // map of a key to a list of msg iters
149  msg_iters_map_t host_msgs_;
150  msg_iters_map_t cat_msgs_;
151  msg_iters_map_t app_msgs_;
152 
153  // context menu for "suppression" and "throttling" button
154  QMenu* sup_menu;
155  QMenu* thr_menu;
156 
157  //Receiver Plugin Manager
158  mfviewer::ReceiverManager receivers_;
159 
160  struct MsgFilterDisplay
161  {
162  int nDisplayMsgs;
163  msg_iters_t msgs;
164  QStringList hostFilter;
165  QStringList appFilter;
166  QStringList catFilter;
167  QTextEdit* txtDisplay;
168  };
169  std::vector<MsgFilterDisplay> msgFilters_;
170 };
171 
172 enum list_mask_t
173 {
174  LIST_APP = 0x01,
175  LIST_CAT = 0x02,
176  LIST_HOST = 0x04
177 };
178 
179 #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...
Message Viewer Dialog Window
Definition: mvdlg.hh:28