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

HDF5 File Input for cass. More...

#include <hdf5_file_input.h>

+ Inheritance diagram for cass::HDF5FileInput:
+ Collaboration diagram for cass::HDF5FileInput:

Classes

struct  AcqirisParams
 parameters needed to retrieve the Acqiris data More...
 
struct  PixeldetectorParams
 parameters needed to retrieve the pixeldetector data More...
 

Public Member Functions

void runthis ()
 function with the main loop More...
 
void load ()
 load the parameters used for the multifile input 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...
 
virtual uint64_t eventcounter ()
 retrieve the number of events that have been input so far More...
 
virtual uint64_t skippedeventcounter ()
 retrieve the number of skipped events that have been input so far 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 (std::string filelistname, RingBuffer< CASSEvent > &, Ratemeter &ratemeter, Ratemeter &loadmeter, bool quitwhendone, QObject *parent=0)
 create 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

 HDF5FileInput (std::string filelistname, RingBuffer< CASSEvent > &, 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...
 
std::string _filelistname
 name of the file containing all files that we need to process 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
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...
 

Detailed Description

HDF5 File Input for cass.

The HDF5 file is expected to contain the data separated by the events. For each event there should be a group that contains the data of all the detectors and deveices that were recorded for this event. The reader will gather a list of all the "root" groups and then iterate through them. Thus all dataset keys should be given with respect to the event group.

User definable Parameters:

HDF5FileInput/{EventIDKey}
The name of the dataset within the hdf5 file that allows to retrieve the current event ID. The Groupname of the Event can be omitted. Default is "EventID"

HDF5FileInput/MachineValues/{size}
The number of machine parameters that one wants to retrieve. Ensure that each parameter has a unique id in the list. All reuested machine parameters will be stored in the beamlineparameter part of the CASSEvent. Use PostProcessor 120 to retrieve those values for processing later on.

HDF5FileInput/MachineValues/%index%/{HDF5Key}
Name of the dataset that contains the requested machine parameter. The Groupname of the Event can be omitted. Default is "Invalid"

HDF5FileInput/MachineValues/%index%/{CASSName}
Name of the parameter within the Beamlineparameter part of the CASSEvent. Default is "Invalid" in which case the name of the dataset will be used.

HDF5FileInput/MachineValues/%index%/{ArrayIndex}
In case the value is contained within an array. This is the index at which the values stand within the array. Default is 0

HDF5FileInput/AcqirisValues/{size}
The number of acqirs instrument channels that one wants to retrieve. Each channel of an instrument has to be defined separately. Ensure that each parameter has a unique id in the list.

HDF5FileInput/AcqirisValues/%index%/{HDF5DataKey}
Name of the dataset that contains the requested acqiris channel data. The Groupname of the Event can be omitted. Default is "Invalid"

HDF5FileInput/AcqirisValues/%index%/{HDF5HorposKey}
Name of the dataset that contains the Horpos value of the requested acqiris channel. The Groupname of the Event can be omitted. Default is "Invalid"

HDF5FileInput/AcqirisValues/%index%/{HDF5VerticalOffsetKey}
Name of the dataset that contains vertical offset value of the requested acqiris channel. The Groupname of the Event can be omitted. Default is "Invalid"

HDF5FileInput/AcqirisValues/%index%/{HDF5GainKey}
Name of the dataset that contains the vertical gain value of the requested acqiris channel. The Groupname of the Event can be omitted. Default is "Invalid"

HDF5FileInput/AcqirisValues/%index%/{HDF5SampleIntervalKey}
Name of the dataset that contains the sample interval value of the requested acqiris channel. The Groupname of the Event can be omitted. Default is "Invalid"

HDF5FileInput/AcqirisValues/%index%/{CASSInstrumentID}
The id of the insturment within the CASSEVent that the acqiris data should be copied to. Default is "1". This should not be changed since this is the generic instrument id. Note that not all ids are available.

HDF5FileInput/AcqirisValues/%index%/{CASSChannelNumber}
The channel number within the instrument of the CASSEvent that the channel data should be copied to. Default is 0.

HDF5FileInput/PixelDetectorValues/{size}
The number of pixeldetectors that one wants to retrieve. Ensure that each parameter has a unique id in the list.

HDF5FileInput/PixelDetectorValues/%index%/{HDF5DataKey}
Name of the dataset that contains the requested pixel detector data. The Groupname of the Event can be omitted. Default is "Invalid"

HDF5FileInput/PixelDetectorValues/%index%/{CASSID}
The id that the pixel detector should have whithin the CASSEvent Default is 0.

Author
Lutz Foucar

Definition at line 92 of file hdf5_file_input.h.

Constructor & Destructor Documentation

HDF5FileInput::HDF5FileInput ( std::string  filelistname,
RingBuffer< CASSEvent > &  ringbuffer,
Ratemeter ratemeter,
Ratemeter loadmeter,
bool  quitwhendone,
QObject parent = 0 
)
private

constructor

Parameters
filelistnamename of the file containing all files that should be processed
ringbufferreference to the ringbuffer containing the CASSEvents
ratemeterreference to the ratemeter to measure the rate of the input
loadmeterreference to the ratemeter to measure the load of the input
quitwhendoneflag that tells this class that it should quit the Program when its done reading all events
parentThe parent QT Object of this class

Definition at line 66 of file hdf5_file_input.cpp.

References cass::Log::add(), and cass::Log::VERBOSEINFO.

Member Function Documentation

void HDF5FileInput::instance ( std::string  filelistname,
RingBuffer< CASSEvent > &  ringbuffer,
Ratemeter ratemeter,
Ratemeter loadmeter,
bool  quitwhendone,
QObject parent = 0 
)
static

create instance of this

Parameters
filelistnamename of the file containing all files that should be processed
ringbufferreference to the ringbuffer containing the CASSEvents
ratemeterreference to the ratemeter to measure the rate of the input
loadmeterreference to the ratemeter to measure the load of the input
quitwhendoneflag that tells this class that it should quit the Program when its done reading all events
parentThe parent QT Object of this class

Definition at line 55 of file hdf5_file_input.cpp.

void HDF5FileInput::load ( )
virtual

load the parameters used for the multifile input

Implements cass::InputBase.

Definition at line 78 of file hdf5_file_input.cpp.

void HDF5FileInput::runthis ( )
virtual

function with the main loop

load the settings from the ini file

the string for the event id of the current event

list of machine variables to extract from the hdf5 files

skip if the value name has not been set

list of acqiris channels that should be extracted from the hdf5 files

skip if the name has not been set

list of pixeldetectors that should be extracted from the hdf5 files

skip if the name has not been set

retrieve all files in a list from the file

go through the list of files and create a processor for each file and add them to the list of processors

check if file exists, then load it

open the hdf5 file

get the list of groups of the root group ('/') as they should reflect the events

iterate through the list and extract the requested informations

retrieve a new element from the ringbuffer. If one didn't get a an element (when the end iterator of the buffer is returned). Continue to the next iteration, where it is checked if the thread should quit.

fill the cassevent object with the contents from the file

set the event id from the retrieved id field

check if the eventid is valid (non zero number)

get reference to all devices of the CASSEvent and an iterator

try to retrieve the data

machine data

check if the event contains the machine data container, if so get a reference to it. Otherwise throw an error.

go through all requested machine data events and retrieve the corresponding values for the tag

check if dimension is correct

acqiris data

retrieve a pointer to the right acqiris instrument

go through all requested acqiris data

retrieve a reference to the right instrument

retrieve a reference to the channel container of the instrument

resize the channel vector to how many channels are in the device

retrieve a reference to the channel we are working on

retrieve a reference to waveform container

extract the meta infos from the hdf5 file

extract the wavefrom and copy it to the CASSEvent container

image data

retrieve the pixel detector part of the cassevent

go through all requested detectors and retrieve the data

retrieve the right detector from the cassevent and reset it

get the data from the file

set the metadata of the frame

add the event back to the ringbuffer and let the world know if its a good event. Also do some output about the rate

quit the program if requested otherwise wait until the program is signalled to quit

Implements cass::InputBase.

Definition at line 82 of file hdf5_file_input.cpp.

References _filelistname, _quitWhenDone, cass::InputBase::_ringbuffer, lmf::PausableThread::_status, cass::CASSEvent::Acqiris, cass::Log::add(), cass::MachineData::Device::BeamlineData(), QSettings::beginGroup(), QSettings::beginReadArray(), cass::ACQIRIS::Channel::channelNbr(), cass::pixeldetector::Device::dets(), cass::CASSEvent::devices(), hdf5::Handler::dimension(), QSettings::endArray(), QSettings::endGroup(), cass::Log::ERROR, cass::InputBase::eventcounter(), QFileInfo::exists(), cass::pixeldetector::Detector::frame(), QString::fromStdString(), cass::ACQIRIS::Channel::gain(), cass::InputBase::getNextFillable(), cass::ACQIRIS::Channel::horpos(), cass::CASSEvent::id(), cass::Log::INFO, info, cass::ACQIRIS::Device::instruments(), cass::CASSEvent::MachineData, cass::InputBase::newEventAdded(), cass::ACQIRIS::Channel::offset(), cass::CASSEvent::PixelDetectors, hdf5::Handler::readArray(), hdf5::Handler::readMatrix(), hdf5::Handler::readScalar(), hdf5::Handler::rootGroups(), lmf::PausableThread::running, cass::ACQIRIS::Channel::sampleInterval(), QSettings::setArrayIndex(), lmf::PausableThread::shouldQuit(), size, QThread::sleep(), cass::toString(), QSettings::value(), cass::Log::VERBOSEINFO, cass::Log::WARNING, and cass::ACQIRIS::Channel::waveform().

Member Data Documentation

std::string cass::HDF5FileInput::_filelistname
private

name of the file containing all files that we need to process

Definition at line 174 of file hdf5_file_input.h.

Referenced by runthis().

bool cass::HDF5FileInput::_quitWhenDone
private

flag to tell the thread to quit when its done with all files

Definition at line 171 of file hdf5_file_input.h.

Referenced by runthis().


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