CFEL - ASG Software Suite  2.5.0
CASS
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
cass::SharedMemoryInput Class Reference

Shared Memory Input for receiving xtc datagrams. More...

#include <sharedmemory_input.h>

+ Inheritance diagram for cass::SharedMemoryInput:
+ Collaboration diagram for cass::SharedMemoryInput:

Public Member Functions

void runthis ()
 starts the thread More...
 
int processDgram (Pds::Dgram *dg)
 overwrite the base class function with our code More...
 
void end ()
 do all clean up when quitting More...
 
void load ()
 load the parameters of the FormatConverter More...
 
uint64_t eventcounter ()
 retrieve the number of processed events More...
 
uint64_t skippedeventcounter ()
 retrieve the number of skipped processed events More...
 
- Public Member Functions inherited from cass::InputBase
virtual ~InputBase ()
 destructor More...
 
virtual double progress ()
 retrieve the fraction of how much of the input has been processed More...
 
void newEventAdded (const size_t eventsize)
 increment the numer of events received in the ratemeter More...
 
RingBuffer< CASSEvent > & ringbuffer ()
 retrieve a reference to the the ringbuffer More...
 
rbItem_t getNextFillable (unsigned timeout=500)
 retrieve an iterator to the next fillable event More...
 
- Public Member Functions inherited from lmf::PausableThread
 PausableThread (control_t control=_run, QObject *parent=0)
 constructor More...
 
virtual ~PausableThread ()
 destructor More...
 
void run ()
 run the thread More...
 
void pause (bool block=false)
 pause the thread More...
 
void waitUntilPaused ()
 waits until thread is paused More...
 
void resume ()
 resume the thread More...
 
status_t status () const
 return the current status of the thread More...
 
bool shouldQuit () const
 query whether this thread is told to quit More...
 
void rethrowException () const
 rethrow the thrown exception More...
 
exception_t exceptionThrown () const
 
- Public Member Functions inherited from QThread
 QThread (QObject *parent=0)
 
 currentThread ()
 
 HANDLE QThread::currentThreadId()
 
 exec ()
 
 exit (int returnCode=0)
 
 finished ()
 
 idealThreadCount ()
 
 isFinished ()
 
 isRunning ()
 
 msleep (unsigned long msecs)
 
 priority ()
 
 quit ()
 
 run ()
 
 setPriority (Priority priority)
 
 setStackSize (uint stackSize)
 
 setTerminationEnabled (bool enabled=true)
 
 sleep (unsigned long secs)
 
 stackSize ()
 
 start (Priority priority=InheritPriority)
 
 started ()
 
 terminate ()
 
 terminated ()
 
 usleep (unsigned long usecs)
 
 wait (unsigned long time=ULONG_MAX)
 
 yieldCurrentThread ()
 

Static Public Member Functions

static void instance (const std::string &PartitionTag, int index, cass::RingBuffer< cass::CASSEvent > &buffer, Ratemeter &ratemeter, Ratemeter &loadmeter, QObject *parent=0)
 create an instance of this More...
 
- Static Public Member Functions inherited from cass::InputBase
static shared_pointer instance ()
 get the signelton instance More...
 
static shared_pointer::element_type & reference ()
 get reference to the singelton instance More...
 

Private Member Functions

 SharedMemoryInput (const std::string &PartitionTag, int index, RingBuffer< CASSEvent > &buffer, Ratemeter &ratemeter, Ratemeter &loadmeter, QObject *parent=0)
 constructor More...
 

Private Attributes

std::string _partitionTag
 the name of the partition tag we connect to More...
 
int _index
 the client index of the shared memory More...
 
FormatConverter_convert
 a reference to the format converter functor More...
 
uint64_t _eventscounter
 a counter for the events More...
 
uint64_t _skippedeventscounter
 a counter for the skipped events More...
 

Additional Inherited Members

- Public Types inherited from cass::InputBase
typedef std::tr1::shared_ptr< InputBaseshared_pointer
 shared pointer of this type More...
 
typedef RingBuffer< CASSEvent >::iter_type rbItem_t
 define an item in the ringbuffer More...
 
- Public Types inherited from lmf::PausableThread
enum  status_t { running, paused, notstarted }
 enum describing the internal status of the thread More...
 
enum  control_t { _run, _quit, _pause }
 enum describing the control status of the thread More...
 
enum  exception_t {
  NO_EXCEPTION, INVALID_ARGUMENT_EXCEPTION, RUNTIME_ERROR_EXCEPTION, OUT_OF_RANGE_EXCEPTION,
  LOGIC_ERROR_EXCEPTION, STANDART_EXCEPTION, UNKNOWN_EXCEPTION
}
 enum describing which exception was thrown More...
 
- Public Slots inherited from lmf::PausableThread
- Public Attributes inherited from cass::InputBase
QMutex lock
 a mutex so that external program can lock access to this More...
 
- Protected Member Functions inherited from cass::InputBase
 InputBase (RingBuffer< CASSEvent > &ringbuffer, Ratemeter &ratemeter, Ratemeter &loadmeter, QObject *parent=0)
 protected constructor since it should be a singelton More...
 
- Protected Member Functions inherited from lmf::PausableThread
void pausePoint ()
 point where the thread will be paused More...
 
- Protected Attributes inherited from cass::InputBase
RingBuffer< CASSEvent > & _ringbuffer
 reference to the ringbuffer More...
 
Ratemeter_ratemeter
 ratemeter to measure the rate More...
 
Ratemeter_loadmeter
 meter to measure the data load More...
 
- Protected Attributes inherited from lmf::PausableThread
QMutex _pauseMutex
 mutex to wait on until thread is paused More...
 
QWaitCondition _pauseCondition
 wait condition to wait on until thread is resumed More...
 
QWaitCondition _waitUntilPausedCondition
 wait condition to wait unitl thread is paused More...
 
status_t _status
 the internal status of the thread More...
 
control_t _control
 the internal control status of the thread More...
 
size_t _pausecount
 a counter how many threads have pause this thread More...
 
exception_t _exception_thrown
 flag to show that general exception was thrown More...
 
std::invalid_argument _invarg_excep
 the invalid arguemnt exception thrown More...
 
std::runtime_error _runt_excep
 the invalid arguemnt exception thrown More...
 
std::out_of_range _outrange_excep
 the invalid arguemnt exception thrown More...
 
std::logic_error _logic_excep
 the invalid arguemnt exception thrown More...
 
- Static Protected Attributes inherited from cass::InputBase
static shared_pointer _instance
 singelton instance More...
 

Detailed Description

Shared Memory Input for receiving xtc datagrams.

This class is a thread that connects to the sahred memory of LCLS. The baseclass does all the connection and once there is new data available it calles processDatagram, where we can add code that we want to use. The first datagram that will be send to this class is a datagram containing the last known configure transition. This is to make sure that when starting the program we will always get the latest state of the DAQ.

Author
Lutz Foucar

Definition at line 37 of file sharedmemory_input.h.

Constructor & Destructor Documentation

SharedMemoryInput::SharedMemoryInput ( const std::string &  PartitionTag,
int  index,
RingBuffer< CASSEvent > &  buffer,
Ratemeter ratemeter,
Ratemeter loadmeter,
QObject parent = 0 
)
private

constructor

creates the thread. The base class will create the interface to the shared memory.

Parameters
PartitionTagthe name of the partition tag we want to connect to
indexthe client index of the connection to the shared memory
bufferthe ringbuffer, that we take events out and fill it with the incomming information
ratemeterreference to the ratemeter to measure the rate of the input
loadmeterreference to the ratemeter to measure the load of the input
parentthe parent of this object

Definition at line 40 of file sharedmemory_input.cpp.

References load().

Member Function Documentation

void SharedMemoryInput::end ( )
virtual

do all clean up when quitting

this function from the base class needs to be overwritten, since it might happen that we loose connection to the shared memory in wich case we will never be able to check the quit status. Therefore after waiting 5 s this will just terminate the thread.

Reimplemented from lmf::PausableThread.

Definition at line 70 of file sharedmemory_input.cpp.

References lmf::PausableThread::_control, lmf::PausableThread::_quit, cass::Log::add(), cass::Log::DEBUG0, QThread::terminate(), and QThread::wait().

uint64_t SharedMemoryInput::eventcounter ( )
virtual

retrieve the number of processed events

Returns
number of processed events

Reimplemented from cass::InputBase.

Definition at line 122 of file sharedmemory_input.cpp.

References _eventscounter.

void SharedMemoryInput::instance ( const std::string &  PartitionTag,
int  index,
cass::RingBuffer< cass::CASSEvent > &  buffer,
Ratemeter ratemeter,
Ratemeter loadmeter,
QObject parent = 0 
)
static

create an instance of this

Parameters
PartitionTagthe name of the partition tag we want to connect to
bufferthe ringbuffer, that we take events out and fill it with the incomming information
ratemeterreference to the ratemeter to measure the rate of the input
loadmeterreference to the ratemeter to measure the load of the input
indexthe client index of the shared memory
parentthe parent of this object

Definition at line 23 of file sharedmemory_input.cpp.

void SharedMemoryInput::load ( )
virtual

load the parameters of the FormatConverter

Implements cass::InputBase.

Definition at line 56 of file sharedmemory_input.cpp.

References _convert, and cass::FormatConverter::loadSettings().

Referenced by SharedMemoryInput().

int SharedMemoryInput::processDgram ( Pds::Dgram *  dg)

overwrite the base class function with our code

This is called once the eventqueue has new data available.

Returns
the errorcode, when != 0, then the baseclasses will exit its loop
Parameters
[in]dgThe datagram we can work on

check if it just timed out, if so return

retrieve a new element from the ringbuffer

read the datagram to the ringbuffer element

now convert the datagram to a cassevent

advance the counters

tell the buffer that we are done, but also let it know whether it is a good event

for ratemeter purposes send a signal that we added a new event

return the quit code

Definition at line 88 of file sharedmemory_input.cpp.

References _convert, _eventscounter, cass::InputBase::_ringbuffer, _skippedeventscounter, cass::InputBase::getNextFillable(), cass::InputBase::newEventAdded(), lmf::PausableThread::pausePoint(), and lmf::PausableThread::shouldQuit().

void SharedMemoryInput::runthis ( )
virtual

starts the thread

Starts the thread and the loop in the shared memory client we inerhited from. The loop will be notified when there are new events available in the shared memory.

Implements cass::InputBase.

Definition at line 61 of file sharedmemory_input.cpp.

References _index, _partitionTag, lmf::PausableThread::_status, cass::Log::add(), cass::Log::DEBUG0, lmf::PausableThread::running, and cass::toString().

uint64_t SharedMemoryInput::skippedeventcounter ( )
virtual

retrieve the number of skipped processed events

Returns
number of processed events

Reimplemented from cass::InputBase.

Definition at line 127 of file sharedmemory_input.cpp.

References _skippedeventscounter.

Member Data Documentation

FormatConverter& cass::SharedMemoryInput::_convert
private

a reference to the format converter functor

The converter will convert the incomming data to our CASSEvent

Definition at line 129 of file sharedmemory_input.h.

Referenced by load(), and processDgram().

uint64_t cass::SharedMemoryInput::_eventscounter
private

a counter for the events

Definition at line 132 of file sharedmemory_input.h.

Referenced by eventcounter(), and processDgram().

int cass::SharedMemoryInput::_index
private

the client index of the shared memory

Definition at line 123 of file sharedmemory_input.h.

Referenced by runthis().

std::string cass::SharedMemoryInput::_partitionTag
private

the name of the partition tag we connect to

Definition at line 120 of file sharedmemory_input.h.

Referenced by runthis().

uint64_t cass::SharedMemoryInput::_skippedeventscounter
private

a counter for the skipped events

Definition at line 135 of file sharedmemory_input.h.

Referenced by processDgram(), and skippedeventcounter().


The documentation for this class was generated from the following files: