CFEL - ASG Software Suite
2.5.0
CASS
|
ZMQ Input for receiving data. More...
#include <zmq_input.h>
Public Member Functions | |
void | runthis () |
starts the thread More... | |
void | load () |
do not load anything 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 (RingBuffer< CASSEvent > &buffer, Ratemeter &ratemeter, Ratemeter &loadmeter, bool quitwhendone=false, 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 | |
ZMQInput (RingBuffer< CASSEvent > &buffer, Ratemeter &ratemeter, Ratemeter &loadmeter, bool quitwhendone, QObject *parent=0) | |
constructor More... | |
Private Attributes | |
bool | _quitWhenDone |
flag to tell the thread to quit when its done with all files More... | |
uint64_t | _counter |
the counter for all events More... | |
uint64_t | _scounter |
the counter for all events More... | |
Additional Inherited Members | |
Public Types inherited from cass::InputBase | |
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... | |
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 | |
virtual void | end () |
tell the thread to quit More... | |
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... | |
ZMQ Input for receiving data.
This class is a thread that connects to a ZMQ Server and retrieves the data from it.
Definition at line 33 of file zmq_input.h.
|
private |
constructor
creates the thread. Connects to the tcp server and then retrieves the data streams. The data within the stream will be deserialized with the help of deserialization functions, where the user has to choose which one is appropriate via the .ini file parameters. The thread runs as long as noone calls the end() member of the base class. In case a timeout occurs when waiting for a new event, it will just continue and wait for the next timeout. In case that a timeout occurred when waiting for the data of an event it throws an runtime error.
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 |
quitwhendone | flag to tell whether to quit the input when done |
parent | the parent of this object |
Definition at line 38 of file zmq_input.cpp.
|
inlinevirtual |
retrieve the number of processed events
Reimplemented from cass::InputBase.
Definition at line 67 of file zmq_input.h.
References _counter.
|
static |
create an instance of this
this initializes the _instance member of the base class. Check here if it is already initialized, if so throw logic error.
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 |
quitwhendone | flag to tell whether to quit the input when done |
parent | the parent of this object |
Definition at line 27 of file zmq_input.cpp.
|
inlinevirtual |
|
virtual |
starts the thread
Starts the thread and the loop that waits for data. When an timout occured it will just restart the loop until the quit flag is set.
info specific to the zeromq server
things needed to iterate through the xfel data
things needed to parse the msgpack data
get the name within the msgpack that should be extracted
check what kind of data this will be, skip if type of data is unkown
extract additional info that one needs to add the parsed info to the CASSEvent
connect to the zmq socket
run until the thread is told to quit
here we can safely pause the execution
now retrive new data from the socket
now deserialize the data from the socket
clear the info container
how many pixels has a detector
retrieve a new element from the ringbuffer, continue with next iteration in case the retrieved element is the iterator to the last element of the buffer.
get reference to all devices of the CASSEvent and an iterator
go through the list of requested infos an put them in to the event
check if the requested data was sent
output the shape of the pixeldetector
retrieve the pixel detector part of the cassevent
retrieve the right detector from the cassevent and reset it
get iterators to the corresponding data and advance it to the right bunch within the train
copy the det data to the frame
set the additional info of the detector
retrieve the pixel detector part of the cassevent
tell the ringbuffer that we're done with the event
Implements cass::InputBase.
Definition at line 267 of file zmq_input.cpp.
References _counter, cass::InputBase::_ringbuffer, lmf::PausableThread::_status, cass::Log::add(), cass::MachineData::Device::BeamlineData(), QSettings::beginGroup(), QSettings::beginReadArray(), Info::CASSDeviceType, Info::CASSID, Info::CASSValueName, Info::data, cass::Log::DEBUG0, cass::pixeldetector::Device::dets(), cass::CASSEvent::devices(), QSettings::endArray(), QSettings::endGroup(), cass::pixeldetector::Detector::frame(), cass::InputBase::getNextFillable(), cass::CASSEvent::id(), cass::Log::INFO, Info::isPerTrain, iterate(), cass::CASSEvent::MachineData, Info::nCols, cass::InputBase::newEventAdded(), Info::nPixels, Info::nRows, lmf::PausableThread::pausePoint(), cass::CASSEvent::PixelDetectors, lmf::PausableThread::running, QSettings::setArrayIndex(), Info::shape, lmf::PausableThread::shouldQuit(), size, cass::toString(), QSettings::value(), and cass::Log::WARNING.
|
inlinevirtual |
retrieve the number of skipped processed events
Reimplemented from cass::InputBase.
Definition at line 73 of file zmq_input.h.
References _scounter.
|
private |
the counter for all events
Definition at line 102 of file zmq_input.h.
Referenced by eventcounter(), and runthis().
|
private |
flag to tell the thread to quit when its done with all files
Definition at line 99 of file zmq_input.h.
|
private |
the counter for all events
Definition at line 105 of file zmq_input.h.
Referenced by skippedeventcounter().