CFEL - ASG Software Suite  2.5.0
CASS
xfel_online_input.h
Go to the documentation of this file.
1 // Copyright (C) 2017 Lutz Foucar
2 
3 /**
4  * @file zmq_input.h contains input that uses ZMQ as interface
5  *
6  * @author Lutz Foucar
7  */
8 
9 #ifndef __XFELONLINEINPUT_H__
10 #define __XFELONLINEINPUT_H__
11 
12 #include <string>
13 
14 #include "cass.h"
15 #include "input_base.h"
16 #include "cass_event.h"
17 #include "ringbuffer.hpp"
18 
19 
20 namespace cass
21 {
22 /** XFEL Input for receiving data
23  *
24  * This class is a thread that connects to a XFEL Server and retrieves the data
25  * from it.
26  *
27  * @cassttng XFELOnlineInput/{ServerAddress}\n
28  * The name or ip address of the machine that the server is running on.
29  * Default is "tcp://localhost:1234"
30  * @cassttng XFELOnlineInput/{NbrPulsesInTrain}\n
31  * The number of pulses within the train. Default is 64
32  * @cassttng XFELOnlineInput/{Source}\n
33  * The data source within the transferred kb_data. Default is
34  * SPB_DET_AGIPD1M-1/DET/detector-1
35  * @cassttng XFELOnlineInput/{CASSID}\n
36  * The id of the image data within the cassevent. Default is 30.
37  * @cassttng XFELOnlineInput/{PathToImage}\n
38  * path to the image data within the transferred data. Default is
39  * "image.data"
40  *
41  * @author Lutz Foucar
42  */
43 class XFELOnlineInput : public InputBase
44 {
45 public:
46  /** create an instance of this
47  *
48  * this initializes the _instance member of the base class. Check here if
49  * it is already initialized, if so throw logic error.
50  *
51  * @param buffer the ringbuffer, that we take events out and fill it
52  * with the incomming information
53  * @param ratemeter reference to the ratemeter to measure the rate of the input
54  * @param loadmeter reference to the ratemeter to measure the load of the input
55  * @param quitwhendone flag to tell whether to quit the input when done
56  * @param parent the parent of this object
57  */
58  static void instance(RingBuffer<CASSEvent>& buffer,
59  Ratemeter &ratemeter, Ratemeter &loadmeter,
60  bool quitwhendone=false,
61  QObject *parent=0);
62 
63  /** starts the thread
64  *
65  * Starts the thread and the loop that waits for data. When an timout occured
66  * it will just restart the loop until the quit flag is set.
67  */
68  void runthis();
69 
70  /** do not load anything */
71  void load() {}
72 
73  /** retrieve the number of processed events
74  *
75  * @return number of processed events
76  */
77  uint64_t eventcounter() {return _counter;}
78 
79  /** retrieve the number of skipped processed events
80  *
81  * @return number of processed events
82  */
83  uint64_t skippedeventcounter() {return _scounter;}
84 
85 private:
86  /** constructor
87  *
88  * creates the thread. Connects to the tcp server and then retrieves the
89  * data streams. The data within the stream will be deserialized with the
90  * help of deserialization functions, where the user has to choose which
91  * one is appropriate via the .ini file parameters. The thread runs as long
92  * as noone calls the end() member of the base class.
93  * In case a timeout occurs when waiting for a new event, it will just continue
94  * and wait for the next timeout. In case that a timeout occurred when waiting
95  * for the data of an event it throws an runtime error.
96  *
97  * @param buffer the ringbuffer, that we take events out and fill it
98  * with the incomming information
99  * @param ratemeter reference to the ratemeter to measure the rate of the input
100  * @param loadmeter reference to the ratemeter to measure the load of the input
101  * @param quitwhendone flag to tell whether to quit the input when done
102  * @param parent the parent of this object
103  */
105  Ratemeter &ratemeter, Ratemeter &loadmeter, bool quitwhendone,
106  QObject *parent=0);
107 
108  /** flag to tell the thread to quit when its done with all files */
110 
111  /** the counter for all events */
112  uint64_t _counter;
113 
114  /** the counter for all events */
115  uint64_t _scounter;
116 };
117 
118 }//end namespace cass
119 
120 #endif
class calculating a rate in Hz.
Definition: ratemeter.h:28
file contains declaration of the CASSEvent
Input base class.
Definition: input_base.h:31
uint64_t skippedeventcounter()
retrieve the number of skipped processed events
uint64_t eventcounter()
retrieve the number of processed events
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
static shared_pointer instance()
get the signelton instance
Definition: input_base.cpp:20
contains the base class for all input modules
XFELOnlineInput(RingBuffer< CASSEvent > &buffer, Ratemeter &ratemeter, Ratemeter &loadmeter, bool quitwhendone, QObject *parent=0)
constructor
uint64_t _scounter
the counter for all events
XFEL Input for receiving data.
void load()
do not load anything
void runthis()
starts the thread
bool _quitWhenDone
flag to tell the thread to quit when its done with all files
uint64_t _counter
the counter for all events