artdaq_mfextensions  v1_03_02
mvdlg.hh
1 #ifndef MSGVIEWERDLG_H
2 #define MSGVIEWERDLG_H
3 
4 #include "ui_msgviewerdlgui.h"
5 #include "mfextensions/Extensions/throttle.hh"
6 #include "mfextensions/Extensions/suppress.hh"
7 #include "mfextensions/Receivers/qt_mf_msg.hh"
8 #include "mfextensions/Binaries/ReceiverManager.hh"
9 
10 #include <QtCore/QTimer>
11 #include <QtCore/QMutex>
12 
13 #include <boost/regex.hpp>
14 
15 #include <string>
16 #include <vector>
17 #include <map>
18 #include <list>
19 
20 namespace fhicl
21 {
22  class ParameterSet;
23 }
24 
28 class msgViewerDlg : public QDialog, private Ui::MsgViewerDlg
29 {
30  Q_OBJECT
31 
32 public:
38  msgViewerDlg(std::string const& conf, QDialog* parent = 0);
39 
40  virtual ~msgViewerDlg();
41 
42 
43  public slots:
44 
46  void pause();
47 
49  void exit();
50 
52  void clear();
53 
55  void shortMode();
56 
58  void changeSeverity(int sev);
59 
60 protected:
65  void closeEvent(QCloseEvent* event);
66 
67  private slots:
68 
69  void onNewMsg(qt_mf_msg const& mfmsg);
70 
71  void setFilter();
72 
73  void renderMode();
74 
75  void setSevError();
76 
77  void setSevWarning();
78 
79  void setSevInfo();
80 
81  void setSevDebug();
82 
83  void searchMsg();
84 
85  void searchClear();
86 
87  void setSuppression(QAction* act);
88 
89  void setThrottling(QAction* act);
90 
91  void tabWidgetCurrentChanged(int newTab);
92 
93  void tabCloseRequested(int tabIndex);
94 
95  //---------------------------------------------------------------------------
96 
97 private:
98 
99  // Display all messages stored in the buffer
100  void displayMsg(int display);
101 
102  void UpdateTextAreaDisplay(QString text, QTextEdit* widget);
103 
104  void updateDisplays();
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 updating;
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 
142  // Rendering messages in speed mode or full mode
143  bool simpleRender;
144 
145  // severity threshold
146  sev_code_t sevThresh;
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  msg_iters_t msgs;
180  QStringList hostFilter;
181  QStringList appFilter;
182  QStringList catFilter;
183  QTextEdit* txtDisplay;
184  };
185  std::vector<MsgFilterDisplay> msgFilters_;
186 };
187 
188 enum list_mask_t
189 {
190  LIST_APP = 0x01,
191  LIST_CAT = 0x02,
192  LIST_HOST = 0x04
193 };
194 
195 #endif
void exit()
Exit the program.
Definition: mvdlg.cc:721
Qt wrapper around MessageFacility message
Definition: qt_mf_msg.hh:37
The ReceiverManager loads one or more receiver plugins and displays messages received by those plugin...
void clear()
Clear the message buffer.
Definition: mvdlg.cc:726
Message Viewer Dialog Window
Definition: mvdlg.hh:28
void pause()
Pause message receiving.
Definition: mvdlg.cc:706
void changeSeverity(int sev)
Change the severity threshold.
Definition: mvdlg.cc:773
void shortMode()
Switch to/from Short message mode.
Definition: mvdlg.cc:758
void closeEvent(QCloseEvent *event)
Perform actions on window close.
Definition: mvdlg.cc:955
msgViewerDlg(std::string const &conf, QDialog *parent=0)
Message Viewer Dialog Constructor.
Definition: mvdlg.cc:88