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