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