CFEL - ASG Software Suite  2.5.0
CASS
rate_plotter.h
Go to the documentation of this file.
1 //Copyright (C) 2010,2013,2016 Lutz Foucar
2 
3 /**
4  * @file rate_plotter.h file contains declaration of class to plot the rate
5  * calculated by ratemeters
6  *
7  * @author Lutz Foucar
8  */
9 
10 #ifndef _RATE_PLOTTER_H_
11 #define _RATE_PLOTTER_H_
12 
13 #include <vector>
14 #include <list>
15 #include <string>
16 #include <tr1/memory>
17 
18 #include <QtCore/QThread>
19 
20 #include "cass.h"
21 
22 namespace cass
23 {
24 //forward declarations
25 class Ratemeter;
26 
27 /** Plotting information about the ongoing processing
28  *
29  * class that will plot various information about the ongoing process
30  *
31  * @cassttng ProcessingStatistics/{ShowInfo} \n
32  * If true, it will display the requested information. If false,
33  * no output is generated. Default is true.
34  * @cassttng ProcessingStatistics/{Output} \n
35  * Filename to which the info will be written. If no parameter is
36  * given, output will be directed to cout.
37  * @cassttng ProcessingStatistics/{UpdateInterval} \n
38  * The updating interval in s. Default is 1.
39  * @cassttng ProcessingStatistics/{ShowTime} \n
40  * Show the current time before plotting any other information.
41  * Default is false.
42  * @cassttng ProcessingStatistics/{TimeFormatString} \n
43  * The format string in which the time will be plotted. Default is
44  * "dd-MMM-yy_HH:mm:ss".
45  * @cassttng ProcessingStatistics/{ShowInputRate} \n
46  * If true, it will show the input rate. Default is true.
47  * @cassttng ProcessingStatistics/{ShowInputLoad} \n
48  * If true, it will show the input load. Default is true.
49  * @cassttng ProcessingStatistics/{ShowAnalysisRate} \n
50  * If true, it will show the analysis rate. Default is true.
51  * @cassttng ProcessingStatistics/{ShowProgress} \n
52  * If true, it will show the progress of the process. Default is true.
53  * @cassttng ProcessingStatistics/{ShowNbrProcessedEvents} \n
54  * If true, it will show the number of events processed. Default is
55  * false.
56  * @cassttng ProcessingStatistics/{ShowNbrSkippedEvents} \n
57  * If true, it will show the number of events skipped. Default is
58  * false.
59  * @cassttng ProcessingStatistics/{NewLine} \n
60  * If true, it will show the input rate. Default is true.
61  * @cassttng ProcessingStatistics/ValueProcessors/{size} \n
62  * the number of value like processors to be plotted.
63  * @cassttng ProcessingStatistics/ValueProcessors/\%id\%/{Name} \n
64  * Name of the value like processor. If Unknown, then it won't be
65  * added to the list. Default is Unknown.
66  * @cassttng ProcessingStatistics/ValueProcessors/\%id\%/{FieldWidth} \n
67  * Width of the value field. Used in setw(). Default is 10.
68  * @cassttng ProcessingStatistics/ValueProcessors/\%id\%/{Precision} \n
69  * Precsion after the decimal point for floating. Used in
70  * setprecision(). Default is 7.
71  * @cassttng ProcessingStatistics/ValueProcessors/\%id\%/{Unit} \n
72  * The unit to be displayed after the value. Default is "".
73  *
74  * @author Lutz Foucar
75  */
76 class RatePlotter : public QThread
77 {
78 public:
79  /** a shared pointer of this type */
80  typedef std::tr1::shared_ptr<RatePlotter> shared_pointer;
81 
82  /** constructor.
83  *
84  * @param inputrate the ratemeter of the input thread
85  * @param inputload ratemeter to measure the data load
86  * @param analyzerate the ratemeter of the worker threads
87  * @param parent the qt parent of this object
88  */
89  RatePlotter(Ratemeter &inputrate,
90  Ratemeter &inputload,
91  Ratemeter &analyzerate,
92  QObject *parent=0);
93 
94  /** destructor
95  *
96  * checks whether thread is still running in which case it will be terminated.
97  * Then waits until thread has finished.
98  */
99  virtual ~RatePlotter();
100 
101 protected:
102  /** the plotting loop
103  *
104  * sleep for interval time and then retrieve the rate from the ratemeters
105  * and plot it.
106  */
107  void run();
108 
109 private:
110  /** reference to the input Ratemeter */
112 
113  /** reference to the input Ratemeter */
115 
116  /** reference to the workers (analysis) Ratemeter */
118 
119  /** flag to tell whether to show the info at all */
120  bool _showInfo;
121 
122  /** the interval in which the rate is plottet in s */
124 
125  /** the filename to which the status will be written */
126  std::string _filename;
127 
128  /** flag to tell whether the input rate should be reported */
130 
131  /** flag to tell whether the input load should be reported */
133 
134  /** flag to tell whether the analysis rate should be reported */
136 
137  /** flag to tell whether the how much is processed ratio should be reported */
139 
140  /** flag to tell whether to report on how many events have been processed */
142 
143  /** flag to tell whether to report on how many events have been processed */
145 
146  /** flag to tell whether the updated info should be put into a new line */
147  bool _newLine;
148 
149  /** flag to tell whether to display the time when the output was written */
150  bool _showTime;
151 
152  /** string to tell how to format the time output */
153  std::string _timeformat;
154 
155  /** define the processor properties */
157  {
158  /** the name of the processor */
159  std::string name;
160 
161  /** how much space should be used for the output of the variable */
163 
164  /** how much digits after the decimal point should be used */
166 
167  /** the unit that should be displayed after the value */
168  std::string unit;
169  };
170 
171  /** define the processor list */
172  typedef std::list<ProcProperties> proclist_t;
173 
174  /** list of value like processors that should be reported on */
175  proclist_t _procs;
176 };
177 }//end namespace cass
178 
179 #endif // RATEMETER_H
std::string _filename
the filename to which the status will be written
Definition: rate_plotter.h:126
bool _newLine
flag to tell whether the updated info should be put into a new line
Definition: rate_plotter.h:147
bool _showAnalysisRate
flag to tell whether the analysis rate should be reported
Definition: rate_plotter.h:135
class calculating a rate in Hz.
Definition: ratemeter.h:28
bool _showNProcessedEvents
flag to tell whether to report on how many events have been processed
Definition: rate_plotter.h:141
Ratemeter & _analyzerate
reference to the workers (analysis) Ratemeter
Definition: rate_plotter.h:117
int fieldWidth
how much space should be used for the output of the variable
Definition: rate_plotter.h:162
RatePlotter(Ratemeter &inputrate, Ratemeter &inputload, Ratemeter &analyzerate, QObject *parent=0)
constructor.
void run()
the plotting loop
proclist_t _procs
list of value like processors that should be reported on
Definition: rate_plotter.h:175
virtual ~RatePlotter()
destructor
std::string name
the name of the processor
Definition: rate_plotter.h:159
std::string _timeformat
string to tell how to format the time output
Definition: rate_plotter.h:153
bool _showTime
flag to tell whether to display the time when the output was written
Definition: rate_plotter.h:150
bool _showNSkippedEvents
flag to tell whether to report on how many events have been processed
Definition: rate_plotter.h:144
Ratemeter & _inputload
reference to the input Ratemeter
Definition: rate_plotter.h:114
int _interval
the interval in which the rate is plottet in s
Definition: rate_plotter.h:123
std::list< ProcProperties > proclist_t
define the processor list
Definition: rate_plotter.h:172
int precision
how much digits after the decimal point should be used
Definition: rate_plotter.h:165
file contains global definitions for project cass
std::string unit
the unit that should be displayed after the value
Definition: rate_plotter.h:168
std::tr1::shared_ptr< RatePlotter > shared_pointer
a shared pointer of this type
Definition: rate_plotter.h:80
Plotting information about the ongoing processing.
Definition: rate_plotter.h:76
Ratemeter & _inputrate
reference to the input Ratemeter
Definition: rate_plotter.h:111
define the processor properties
Definition: rate_plotter.h:156
bool _showProgress
flag to tell whether the how much is processed ratio should be reported
Definition: rate_plotter.h:138
bool _showInputLoad
flag to tell whether the input load should be reported
Definition: rate_plotter.h:132
bool _showInputRate
flag to tell whether the input rate should be reported
Definition: rate_plotter.h:129
bool _showInfo
flag to tell whether to show the info at all
Definition: rate_plotter.h:120