CFEL - ASG Software Suite  2.5.0
CASS
sacla_offline_input.h
Go to the documentation of this file.
1 // Copyright (C) 2014, 2015 Lutz Foucar
2 
3 /**
4  * @file sacla_offline_input.h file contains declaration of sacla offline input
5  *
6  * @author Lutz Foucar
7  */
8 
9 #ifndef _SACLAOFFLINEINPUT_
10 #define _SACLAOFFLINEINPUT_
11 
12 #include <string>
13 
14 #include "input_base.h"
15 #include "cass.h"
16 #include "ringbuffer.hpp"
17 #include "cass_event.h"
18 
19 namespace cass
20 {
21 /** forward declaration of the tag processor */
22 class TagListProcessor;
23 
24 /** SACLA Offline Input for cass
25  *
26  * This class will be used in offline modus. I will take an string that
27  * contains a filename. In the file that the filename points to has to be a
28  * list with beamline number and runnumbers to analyse. These need to be given
29  * as a comma separated list. If only these two numbers are provided the list
30  * of tags will be retrieved for the given run. Optionally one can also provide
31  * a list of tags to be analysed for that given run / beamline number
32  * combination. This has to be provided as comma separated list immediatly
33  * following the beamline / runnumber combination.
34  * The filename name must be passed to the program with the -i parameter.
35  *
36  * For each run in the list it will retrieve the tagnumbers and extract the data
37  * associated with the tag number using the cass::SACLAConverter
38  *
39  * @cassttng SACLAOfflineInput/{NbrThreads}\n
40  * Will tell CASS in how many chunks the tag list will be splitted.
41  * Each chunk will be processed individually by a separate thread.
42  * Default is 1.
43  *
44  * @author Lutz Foucar
45  */
47 {
48 public:
49  /** create instance of this
50  *
51  * @param runlistname name of the file containing all runs that should be
52  * processed
53  * @param ringbuffer reference to the ringbuffer containing the CASSEvents
54  * @param ratemeter reference to the ratemeter to measure the rate of the input
55  * @param loadmeter reference to the ratemeter to measure the load of the input
56  * @param quitwhendone flag that tells this class that it should quit the
57  * Program when its done reading all events
58  * @param parent The parent QT Object of this class
59  */
60  static void instance(std::string runlistname,
62  Ratemeter &ratemeter,
63  Ratemeter &loadmeter,
64  bool quitwhendone,
65  QObject *parent=0);
66 
67  /** function with the main loop */
68  void runthis();
69 
70  /** load the parameters used for the input */
71  void load();
72 
73  /** retrieve the progress state
74  *
75  * @return the processing progress
76  */
77  double progress();
78 
79  /** retrieve the number of processed events
80  *
81  * @return number of processed events
82  */
83  uint64_t eventcounter();
84 
85  /** retrieve the number of skipped processed events
86  *
87  * @return number of processed events
88  */
89  uint64_t skippedeventcounter();
90 
91 private:
92  /** constructor
93  *
94  * @param runlistname name of the file containing all runs that should be
95  * processed
96  * @param ringbuffer reference to the ringbuffer containing the CASSEvents
97  * @param ratemeter reference to the ratemeter to measure the rate of the input
98  * @param loadmeter reference to the ratemeter to measure the load of the input
99  * @param quitwhendone flag that tells this class that it should quit the
100  * Program when its done reading all events
101  * @param parent The parent QT Object of this class
102  */
103  SACLAOfflineInput(std::string runlistname,
105  Ratemeter &ratemeter,
106  Ratemeter &loadmeter,
107  bool quitwhendone,
108  QObject *parent=0);
109 
110 
111  /** number of chuncks that the list should be split into */
112  int _chunks;
113 
114  /** flag to tell the thread to quit when its done with all files */
116 
117  /** name of the file containing all files that we need to process */
118  std::string _runlistname;
119 
120  /** define the processors container */
121  typedef std::vector<std::tr1::shared_ptr<TagListProcessor> > proc_t;
122 
123  /** the processor container */
124  proc_t _procs;
125 };
126 
127 }//end namespace cass
128 
129 #endif
uint64_t eventcounter()
retrieve the number of processed events
class calculating a rate in Hz.
Definition: ratemeter.h:28
file contains declaration of the CASSEvent
double progress()
retrieve the progress state
proc_t _procs
the processor container
void runthis()
function with the main loop
Input base class.
Definition: input_base.h:31
std::vector< std::tr1::shared_ptr< TagListProcessor > > proc_t
define the processors container
uint64_t skippedeventcounter()
retrieve the number of skipped processed events
void load()
load the parameters used for the input
std::string _runlistname
name of the file containing all files that we need to process
A Ringbuffer, handles communication between Input and Worker Threads.
Definition: ringbuffer.hpp:52
file contains the ringbuffer class
file contains global definitions for project cass
SACLA Offline Input for cass.
static shared_pointer instance()
get the signelton instance
Definition: input_base.cpp:20
contains the base class for all input modules
int _chunks
number of chuncks that the list should be split into
SACLAOfflineInput(std::string runlistname, RingBuffer< CASSEvent > &, Ratemeter &ratemeter, Ratemeter &loadmeter, bool quitwhendone, QObject *parent=0)
constructor
bool _quitWhenDone
flag to tell the thread to quit when its done with all files