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