artdaq_mfextensions  v1_03_06
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  void scrollToBottom();
93 
94  //---------------------------------------------------------------------------
95 
96  private:
97  // Display all messages stored in the buffer
98  void displayMsg(int display);
99 
100  void UpdateTextAreaDisplay(QString text, QTextEdit* widget);
101 
102  void updateDisplays();
103 
104  void removeMsg(msgs_t::iterator it);
105 
106  // test if the message is suppressed or throttled
107  bool msg_throttled(qt_mf_msg const& mfmsg);
108 
109  unsigned int update_index(msgs_t::iterator it);
110 
111  // Update the list. Returns true if there's a change in the selection
112  // before and after the update. e.g., the selected entry has been deleted
113  // during the process of updateMap(); otherwise it returns a false.
114  template <typename M>
115  bool updateList(QListWidget* lw, M const& map);
116 
117  void displayMsg(msgs_t::const_iterator it, int display);
118 
119  void readSettings();
120 
121  void writeSettings();
122 
123  void parseConf(fhicl::ParameterSet const& conf);
124 
125  QStringList toQStringList(QList<QListWidgetItem*> in);
126 
127  msg_iters_t list_intersect(msg_iters_t const& l1, msg_iters_t const& l2);
128 
129  //---------------------------------------------------------------------------
130 
131  private:
132  bool paused;
133  bool shortMode_;
134 
135  // # of received messages
136  int nMsgs;
137  int nSupMsgs; // suppressed msgs
138  int nThrMsgs; // throttled msgs
139  int nFilters;
140  size_t maxMsgs; // Maximum number of messages to store
141  size_t maxDeletedMsgs; // Maximum number of deleted messages to display
142  int nDeleted;
143 
144  // Rendering messages in speed mode or full mode
145  bool simpleRender;
146 
147  // suppression regex
148  std::vector<suppress> e_sup_host;
149  std::vector<suppress> e_sup_app;
150  std::vector<suppress> e_sup_cat;
151 
152  // throttling regex
153  std::vector<throttle> e_thr_host;
154  std::vector<throttle> e_thr_app;
155  std::vector<throttle> e_thr_cat;
156 
157  // search string
158  QString searchStr;
159 
160  // msg pool storing the formatted text body
161  msgs_t msg_pool_;
162 
163  // map of a key to a list of msg iters
164  msg_iters_map_t host_msgs_;
165  msg_iters_map_t cat_msgs_;
166  msg_iters_map_t app_msgs_;
167 
168  // context menu for "suppression" and "throttling" button
169  QMenu* sup_menu;
170  QMenu* thr_menu;
171 
172  // Receiver Plugin Manager
173  mfviewer::ReceiverManager receivers_;
174 
175  struct MsgFilterDisplay {
176  int nDisplayMsgs;
177  int nDisplayedDeletedMsgs;
178  msg_iters_t msgs;
179  QStringList hostFilter;
180  QStringList appFilter;
181  QStringList catFilter;
182  QTextEdit* txtDisplay;
183 
184  // severity threshold
185  sev_code_t sevThresh;
186  };
187  std::vector<MsgFilterDisplay> msgFilters_;
188 
189  mutable std::mutex updating_mutex_;
190 };
191 
192 enum list_mask_t { LIST_APP = 0x01, LIST_CAT = 0x02, LIST_HOST = 0x04 };
193 
194 #endif
void exit()
Exit the program.
Definition: mvdlg.cc:721
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:723
Message Viewer Dialog Window
Definition: mvdlg.hh:27
void pause()
Pause message receiving.
Definition: mvdlg.cc:709
void changeSeverity(int sev)
Change the severity threshold.
Definition: mvdlg.cc:768
void shortMode()
Switch to/from Short message mode.
Definition: mvdlg.cc:757
void closeEvent(QCloseEvent *event)
Perform actions on window close.
Definition: mvdlg.cc:940
msgViewerDlg(std::string const &conf, QDialog *parent=0)
Message Viewer Dialog Constructor.
Definition: mvdlg.cc:77