CFEL - ASG Software Suite
2.5.0
CASS
|
Shared Memory Input for receiving xtc datagrams. More...
#include <sharedmemory_input.h>
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... | |
![]() | |
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... | |
![]() | |
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 |
![]() | |
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 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 | |
![]() | |
typedef std::tr1::shared_ptr< InputBase > | shared_pointer |
shared pointer of this type More... | |
typedef RingBuffer< CASSEvent >::iter_type | rbItem_t |
define an item in the ringbuffer More... | |
![]() | |
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... | |
![]() | |
![]() | |
QMutex | lock |
a mutex so that external program can lock access to this More... | |
![]() | |
InputBase (RingBuffer< CASSEvent > &ringbuffer, Ratemeter &ratemeter, Ratemeter &loadmeter, QObject *parent=0) | |
protected constructor since it should be a singelton More... | |
![]() | |
void | pausePoint () |
point where the thread will be paused More... | |
![]() | |
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... | |
![]() | |
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 shared_pointer | _instance |
singelton instance More... | |
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.
Definition at line 37 of file sharedmemory_input.h.
|
private |
constructor
creates the thread. The base class will create the interface to the shared memory.
PartitionTag | the name of the partition tag we want to connect to |
index | the client index of the connection to the shared memory |
buffer | the ringbuffer, that we take events out and fill it with the incomming information |
ratemeter | reference to the ratemeter to measure the rate of the input |
loadmeter | reference to the ratemeter to measure the load of the input |
parent | the parent of this object |
Definition at line 40 of file sharedmemory_input.cpp.
References load().
|
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().
|
virtual |
retrieve the number of processed events
Reimplemented from cass::InputBase.
Definition at line 122 of file sharedmemory_input.cpp.
References _eventscounter.
|
static |
create an instance of this
PartitionTag | the name of the partition tag we want to connect to |
buffer | the ringbuffer, that we take events out and fill it with the incomming information |
ratemeter | reference to the ratemeter to measure the rate of the input |
loadmeter | reference to the ratemeter to measure the load of the input |
index | the client index of the shared memory |
parent | the parent of this object |
Definition at line 23 of file sharedmemory_input.cpp.
|
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.
[in] | dg | The 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().
|
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().
|
virtual |
retrieve the number of skipped processed events
Reimplemented from cass::InputBase.
Definition at line 127 of file sharedmemory_input.cpp.
References _skippedeventscounter.
|
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().
|
private |
a counter for the events
Definition at line 132 of file sharedmemory_input.h.
Referenced by eventcounter(), and processDgram().
|
private |
the client index of the shared memory
Definition at line 123 of file sharedmemory_input.h.
Referenced by runthis().
|
private |
the name of the partition tag we connect to
Definition at line 120 of file sharedmemory_input.h.
Referenced by runthis().
|
private |
a counter for the skipped events
Definition at line 135 of file sharedmemory_input.h.
Referenced by processDgram(), and skippedeventcounter().