CFEL - ASG Software Suite  2.5.0
CASS
sharedmemory_input.h
Go to the documentation of this file.
1 // Copyright (C) 2009,2010,2013 Lutz Foucar
2 
3 /**
4  * @file sharedmemory_input.h file contains declaration of class that interfaces
5  * the LCLS shared memory
6  *
7  * @author Lutz Foucar
8  */
9 
10 #ifndef __SHAREDMEMORYINPUT_H__
11 #define __SHAREDMEMORYINPUT_H__
12 
13 #include <string>
14 
15 #include "cass.h"
16 #include "input_base.h"
17 #include "pdsdata/app/XtcMonitorClient.hh"
18 #include "ringbuffer.hpp"
19 #include "cass_event.h"
20 
21 namespace cass
22 {
23 //forward declaration//
24 class FormatConverter;
25 
26 /** Shared Memory Input for receiving xtc datagrams
27  *
28  * This class is a thread that connects to the sahred memory of LCLS. The
29  * baseclass does all the connection and once there is new data available
30  * it calles processDatagram, where we can add code that we want to use.
31  * The first datagram that will be send to this class is a datagram
32  * containing the last known configure transition. This is to make sure that
33  * when starting the program we will always get the latest state of the DAQ.
34  *
35  * @author Lutz Foucar
36  */
38  : public InputBase, Pds::XtcMonitorClient
39 {
40 public:
41  /** create an instance of this
42  *
43  * @param PartitionTag the name of the partition tag we want to connect to
44  * @param buffer the ringbuffer, that we take events out and fill it
45  * with the incomming information
46  * @param ratemeter reference to the ratemeter to measure the rate of the input
47  * @param loadmeter reference to the ratemeter to measure the load of the input
48  * @param index the client index of the shared memory
49  * @param parent the parent of this object
50  */
51  static void instance(const std::string &PartitionTag,
52  int index,
54  Ratemeter &ratemeter, Ratemeter &loadmeter,
55  QObject *parent=0);
56 
57  /** starts the thread
58  *
59  * Starts the thread and the loop in the shared memory client we inerhited
60  * from. The loop will be notified when there are new events available in
61  * the shared memory.
62  */
63  void runthis();
64 
65  /** overwrite the base class function with our code
66  *
67  * This is called once the eventqueue has new data available.
68  *
69  * @return the errorcode, when != 0, then the baseclasses will exit its loop
70  * @param[in] dg The datagram we can work on
71  */
72  int processDgram(Pds::Dgram*dg);
73 
74  /** do all clean up when quitting
75  *
76  * this function from the base class needs to be overwritten, since it might
77  * happen that we loose connection to the shared memory in wich case we
78  * will never be able to check the quit status. Therefore after waiting 5 s
79  * this will just terminate the thread.
80  */
81  void end();
82 
83  /** load the parameters of the FormatConverter */
84  void load();
85 
86  /** retrieve the number of processed events
87  *
88  * @return number of processed events
89  */
90  uint64_t eventcounter();
91 
92  /** retrieve the number of skipped processed events
93  *
94  * @return number of processed events
95  */
96  uint64_t skippedeventcounter();
97 
98 private:
99  /** constructor
100  *
101  * creates the thread. The base class will create the interface to the shared
102  * memory.
103  *
104  * @param PartitionTag the name of the partition tag we want to connect to
105  * @param index the client index of the connection to the shared memory
106  * @param buffer the ringbuffer, that we take events out and fill it
107  * with the incomming information
108  * @param ratemeter reference to the ratemeter to measure the rate of the input
109  * @param loadmeter reference to the ratemeter to measure the load of the input
110  * @param parent the parent of this object
111  */
112  SharedMemoryInput(const std::string &PartitionTag,
113  int index,
114  RingBuffer<CASSEvent> &buffer,
115  Ratemeter &ratemeter,
116  Ratemeter &loadmeter,
117  QObject *parent=0);
118 
119  /** the name of the partition tag we connect to*/
120  std::string _partitionTag;
121 
122  /** the client index of the shared memory */
123  int _index;
124 
125  /** a reference to the format converter functor
126  *
127  * The converter will convert the incomming data to our CASSEvent
128  */
130 
131  /** a counter for the events */
132  uint64_t _eventscounter;
133 
134  /** a counter for the skipped events */
136 };
137 
138 }//end namespace cass
139 
140 #endif
FormatConverter & _convert
a reference to the format converter functor
Shared Memory Input for receiving xtc datagrams.
uint64_t _skippedeventscounter
a counter for the skipped events
class calculating a rate in Hz.
Definition: ratemeter.h:28
int _index
the client index of the shared memory
void load()
load the parameters of the FormatConverter
file contains declaration of the CASSEvent
int processDgram(Pds::Dgram *dg)
overwrite the base class function with our code
uint64_t skippedeventcounter()
retrieve the number of skipped processed events
Input base class.
Definition: input_base.h:31
Format converter container.
SharedMemoryInput(const std::string &PartitionTag, int index, RingBuffer< CASSEvent > &buffer, Ratemeter &ratemeter, Ratemeter &loadmeter, QObject *parent=0)
constructor
uint64_t eventcounter()
retrieve the number of processed events
file contains the ringbuffer class
file contains global definitions for project cass
void runthis()
starts the thread
static shared_pointer instance()
get the signelton instance
Definition: input_base.cpp:20
contains the base class for all input modules
uint64_t _eventscounter
a counter for the events
std::string _partitionTag
the name of the partition tag we connect to
void end()
do all clean up when quitting