artdaq_mfextensions  v1_05_00
mvdlg.hh
1 #ifndef MSGVIEWERDLG_H
2 #define MSGVIEWERDLG_H
3 
4 #include "mfextensions/Receivers/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 = nullptr);
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(msg_ptr_t 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  msgViewerDlg(msgViewerDlg const&) = delete;
99  msgViewerDlg(msgViewerDlg&&) = delete;
100  msgViewerDlg& operator=(msgViewerDlg const&) = delete;
101  msgViewerDlg& operator=(msgViewerDlg&&) = delete;
102 
103  // Display all messages stored in the buffer
104  void displayMsgs(int display);
105 
106  void UpdateTextAreaDisplay(QStringList const& texts, QPlainTextEdit* widget);
107 
108  void updateDisplays();
109 
110  void trim_msg_pool();
111 
112  // test if the message is suppressed or throttled
113  bool msg_throttled(msg_ptr_t const& mfmsg);
114 
115  void update_index(msg_ptr_t const& msg);
116 
117  // Update the list. Returns true if there's a change in the selection
118  // before and after the update. e.g., the selected entry has been deleted
119  // during the process of updateMap(); otherwise it returns a false.
120  bool updateList(QListWidget* lw, msgs_map_t const& map);
121 
122  void displayMsg(msg_ptr_t const& msg, int display);
123 
124  void readSettings();
125 
126  void writeSettings();
127 
128  void parseConf(fhicl::ParameterSet const& conf);
129 
130  QStringList toQStringList(QList<QListWidgetItem*> in);
131 
132  msgs_t list_intersect(msgs_t const& l1, msgs_t const& l2);
133 
134  //---------------------------------------------------------------------------
135 
136 private:
137  bool paused;
138  bool shortMode_;
139 
140  // # of received messages
141  int nMsgs;
142  int nSupMsgs; // suppressed msgs
143  int nThrMsgs; // throttled msgs
144  int nFilters;
145  size_t maxMsgs; // Maximum number of messages to store
146  size_t maxDeletedMsgs; // Maximum number of deleted messages to display
147  int nDeleted;
148 
149  // Rendering messages in speed mode or full mode
150  bool simpleRender;
151 
152  // suppression regex
153  std::vector<suppress> e_sup_host;
154  std::vector<suppress> e_sup_app;
155  std::vector<suppress> e_sup_cat;
156 
157  // throttling regex
158  std::vector<throttle> e_thr_host;
159  std::vector<throttle> e_thr_app;
160  std::vector<throttle> e_thr_cat;
161 
162  // search string
163  QString searchStr;
164 
165  // msg pool storing the formatted text body
166  mutable std::mutex msg_pool_mutex_;
167  msgs_t msg_pool_;
168 
169  // map of a key to a list of msg iters
170  mutable std::mutex msg_classification_mutex_;
171  msgs_map_t host_msgs_;
172  msgs_map_t cat_msgs_;
173  msgs_map_t app_msgs_;
174 
175  // context menu for "suppression" and "throttling" button
176  QMenu* sup_menu;
177  QMenu* thr_menu;
178 
179  // Receiver Plugin Manager
180  mfviewer::ReceiverManager receivers_;
181 
182  mutable std::mutex filter_mutex_;
183  struct MsgFilterDisplay
184  {
185  int nDisplayMsgs;
186  int nDisplayedDeletedMsgs;
187  msgs_t msgs;
188  QStringList hostFilter;
189  QStringList appFilter;
190  QStringList catFilter;
191  QString filterExpression;
192  QPlainTextEdit* txtDisplay;
193 
194  // severity threshold
195  sev_code_t sevThresh;
196  };
197  std::vector<MsgFilterDisplay> msgFilters_;
198 };
199 
200 enum list_mask_t
201 {
202  LIST_APP = 0x01,
203  LIST_CAT = 0x02,
204  LIST_HOST = 0x04
205 };
206 
207 #endif
void exit()
Exit the program.
Definition: mvdlg.cc:858
The ReceiverManager loads one or more receiver plugins and displays messages received by those plugin...
void clear()
Clear the message buffer.
Definition: mvdlg.cc:860
msgViewerDlg(std::string const &conf, QDialog *parent=nullptr)
Message Viewer Dialog Constructor.
Definition: mvdlg.cc:85
Message Viewer Dialog Window
Definition: mvdlg.hh:27
void pause()
Pause message receiving.
Definition: mvdlg.cc:842
void changeSeverity(int sev)
Change the severity threshold.
Definition: mvdlg.cc:918
void shortMode()
Switch to/from Short message mode.
Definition: mvdlg.cc:903
void closeEvent(QCloseEvent *event)
Perform actions on window close.
Definition: mvdlg.cc:1122