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

Helper for Acqiris related Postprocessors. More...

#include <acqiris_detectors_helper.h>

+ Collaboration diagram for cass::ACQIRIS::HelperAcqirisDetectors:

Public Types

typedef std::tr1::shared_ptr< HelperAcqirisDetectorsshared_pointer
 typedef a shared pointer of this More...
 
typedef std::map< std::string, shared_pointerhelperinstancesmap_t
 typedef describing the instances of the helper More...
 
typedef std::tr1::shared_ptr< DetectorBackendDet_sptr
 a shared pointer of the detector backend More...
 
typedef CASSEvent::id_t id_type
 define the type of the id used More...
 
typedef std::pair< id_type, Det_sptrKeyDetPair_t
 defining a key - value pair for the list More...
 
typedef std::vector< KeyDetPair_tdetectorList_t
 typedef defining the list of detectors for more readable code More...
 
typedef detectorList_t::iterator iter_type
 define an iterator for the list More...
 

Public Member Functions

DetectorBackenddetector (const CASSEvent &evt)
 retrieve detector for event More...
 
const DetectorBackenddetector () const
 retrieve detector More...
 
void loadSettings (size_t i=0)
 load the settings of the detectors in the detector list More...
 
DetectorType detectortype ()
 retrieve the detector type that the helper is there for More...
 

Static Public Member Functions

static shared_pointer instance (const helperinstancesmap_t::key_type &detector)
 static function creating instance of this. More...
 
static void releaseDetector (const id_type &id)
 release the detector of all helpers that is blocked for the event More...
 
static const helperinstancesmap_tinstances ()
 return all known instances fo this More...
 

Protected Member Functions

DetectorBackendvalidate (const CASSEvent &evt)
 validate that this event has been associated with the detector. More...
 

Protected Attributes

detectorList_t _detectorList
 list of pairs of id-detectors. More...
 

Private Member Functions

 HelperAcqirisDetectors ()
 prevent people from constructin other than using instance(). More...
 
 HelperAcqirisDetectors (const helperinstancesmap_t::key_type &detname)
 private constructor. More...
 
 HelperAcqirisDetectors (const HelperAcqirisDetectors &)
 prevent copy-construction More...
 
HelperAcqirisDetectorsoperator= (const HelperAcqirisDetectors &)
 prevent assingment More...
 
iter_type findId (const id_type &id)
 find an element with a given id in the list More...
 
void release (const id_type &id)
 release the detector element in the list by settings its key (eventid) back to 0 More...
 

Private Attributes

QMutex _helperMutex
 Mutex for each helper. More...
 
DetectorType _dettype
 the type of detector that the individual helper is there for More...
 
iter_type _lastEntry
 the iterator to the last element returned More...
 

Static Private Attributes

static helperinstancesmap_t _instances
 the helperclass instances. More...
 
static QMutex _mutex
 Singleton Mutex to lock write operations. More...
 

Detailed Description

Helper for Acqiris related Postprocessors.

This class will return the requested detector, which signals are going to a Acqiris Instrument. It is implemented as a singleton such that every processor can call it without knowing about it.

User definable Parameters:
AcqirisDetectors/%name%/{DetectorType}
Type of the detector that this helper should be managing. Default is 1 (TofDetector). Possible choises are
Todo:
make sure that the detectors are protected from beeing written while they are read from
Author
Lutz Foucar

Definition at line 52 of file acqiris_detectors_helper.h.

Member Typedef Documentation

a shared pointer of the detector backend

Definition at line 62 of file acqiris_detectors_helper.h.

typedef defining the list of detectors for more readable code

Definition at line 71 of file acqiris_detectors_helper.h.

typedef describing the instances of the helper

Definition at line 59 of file acqiris_detectors_helper.h.

define the type of the id used

Definition at line 65 of file acqiris_detectors_helper.h.

typedef detectorList_t::iterator cass::ACQIRIS::HelperAcqirisDetectors::iter_type

define an iterator for the list

Definition at line 74 of file acqiris_detectors_helper.h.

defining a key - value pair for the list

Definition at line 68 of file acqiris_detectors_helper.h.

typedef a shared pointer of this

Definition at line 56 of file acqiris_detectors_helper.h.

Constructor & Destructor Documentation

cass::ACQIRIS::HelperAcqirisDetectors::HelperAcqirisDetectors ( )
inlineprivate

prevent people from constructin other than using instance().

Definition at line 159 of file acqiris_detectors_helper.h.

HelperAcqirisDetectors::HelperAcqirisDetectors ( const helperinstancesmap_t::key_type &  detname)
private

private constructor.

Creates the list of detectors. The detectors are of the user chosen type. The type can be chosen by the user via the .cass ini setting dettype. The instance of the detectors are created by DetectorBackend::instance()
The name of the detector is also the key in the instances map.

Parameters
detnamethe name of the detector

Definition at line 55 of file acqiris_detectors_helper.cpp.

References cass::Log::add(), QSettings::beginGroup(), cass::Log::DEBUG0, QSettings::endGroup(), QString::fromStdString(), cass::ACQIRIS::DetectorBackend::instance(), cass::NbrOfWorkers, cass::ACQIRIS::ToF, cass::toString(), and QSettings::value().

cass::ACQIRIS::HelperAcqirisDetectors::HelperAcqirisDetectors ( const HelperAcqirisDetectors )
private

prevent copy-construction

Member Function Documentation

DetectorBackend& cass::ACQIRIS::HelperAcqirisDetectors::detector ( const CASSEvent evt)
inline

retrieve detector for event

this just calls validate(). See validate() for further information

Returns
pointer to the detector that contains the data related to the requested event
Parameters
evtthe event whos data we need to relate to the detector.

Definition at line 105 of file acqiris_detectors_helper.h.

References validate().

const DetectorBackend& cass::ACQIRIS::HelperAcqirisDetectors::detector ( ) const
inline

retrieve detector

this just retrieves the first detector from the _detectorList. Can be used for chekcking the properties of the detector.

Returns
const pointer to the first detector in _detectorList

Definition at line 114 of file acqiris_detectors_helper.h.

References _detectorList.

DetectorType cass::ACQIRIS::HelperAcqirisDetectors::detectortype ( )
inline

retrieve the detector type that the helper is there for

Definition at line 127 of file acqiris_detectors_helper.h.

References _dettype.

HelperAcqirisDetectors::iter_type HelperAcqirisDetectors::findId ( const id_type id)
private

find an element with a given id in the list

Returns
iterator to the found element
Parameters
idthe id of the element

Definition at line 70 of file acqiris_detectors_helper.cpp.

HelperAcqirisDetectors::shared_pointer HelperAcqirisDetectors::instance ( const helperinstancesmap_t::key_type &  detector)
static

static function creating instance of this.

return the instance of the helper that is managing the detector. If the helper is not yet inside the _instances map the helper instance will be created and put into the _instances map.

Returns
instance of the helper manaing the detector
Parameters
detectorkey (name) of the detector to find it in the _instances map

Definition at line 30 of file acqiris_detectors_helper.cpp.

References cass::Log::add(), cass::Log::DEBUG0, and detector.

Referenced by cass::ACQIRIS::loadDelayDet(), cass::ACQIRIS::loadLayer(), and cass::ACQIRIS::loadParticle().

const HelperAcqirisDetectors::helperinstancesmap_t & HelperAcqirisDetectors::instances ( )
static

return all known instances fo this

Definition at line 49 of file acqiris_detectors_helper.cpp.

void HelperAcqirisDetectors::loadSettings ( size_t  i = 0)

load the settings of the detectors in the detector list

go through the list of detectors and tell each of the detector to load its settings.

Parameters
iunused parameter

Definition at line 104 of file acqiris_detectors_helper.cpp.

References QSettings::beginGroup(), and QSettings::endGroup().

HelperAcqirisDetectors& cass::ACQIRIS::HelperAcqirisDetectors::operator= ( const HelperAcqirisDetectors )
private

prevent assingment

void HelperAcqirisDetectors::release ( const id_type id)
private

release the detector element in the list by settings its key (eventid) back to 0

Parameters
idthe detector event id that should be released

Definition at line 77 of file acqiris_detectors_helper.cpp.

void HelperAcqirisDetectors::releaseDetector ( const id_type id)
static

release the detector of all helpers that is blocked for the event

Parameters
idthe eventid that is assinged for the detector

Definition at line 42 of file acqiris_detectors_helper.cpp.

Referenced by cass::ProcessorManager::operator()().

DetectorBackend & HelperAcqirisDetectors::validate ( const CASSEvent evt)
protected

validate that this event has been associated with the detector.

This function will lock, so that it can be consecutivly called by different threads.
Check if the event is already associated with one of the detectors in the detector list. If so just return the pointer to the detector that is associated with this event.
If not then take the detector of the last element in the _detectorList and call its associate() member with this event. Then create a new element to be put into the _detectorList, where the key of the element is the id of the event and the value is the pointer to the detector, that we associated with this event. Put the newly created element in the beginning of the _detectorList and erase the last element.

Returns
reference to the validated detector
Parameters
evtthe cass event to validate

Definition at line 85 of file acqiris_detectors_helper.cpp.

References cass::CASSEvent::id().

Referenced by detector().

Member Data Documentation

detectorList_t cass::ACQIRIS::HelperAcqirisDetectors::_detectorList
protected

list of pairs of id-detectors.

Note
Needs to be at least the size of workers that can possibly call this helper simultaniously, but should be shrinked if it gets much bigger than the number of workers.

Definition at line 155 of file acqiris_detectors_helper.h.

Referenced by detector().

DetectorType cass::ACQIRIS::HelperAcqirisDetectors::_dettype
private

the type of detector that the individual helper is there for

Definition at line 207 of file acqiris_detectors_helper.h.

Referenced by detectortype().

QMutex cass::ACQIRIS::HelperAcqirisDetectors::_helperMutex
private

Mutex for each helper.

Definition at line 204 of file acqiris_detectors_helper.h.

HelperAcqirisDetectors::helperinstancesmap_t HelperAcqirisDetectors::_instances
staticprivate

the helperclass instances.

the instances of this class put into map one instance for each available detector

Definition at line 198 of file acqiris_detectors_helper.h.

iter_type cass::ACQIRIS::HelperAcqirisDetectors::_lastEntry
private

the iterator to the last element returned

Definition at line 210 of file acqiris_detectors_helper.h.

QMutex HelperAcqirisDetectors::_mutex
staticprivate

Singleton Mutex to lock write operations.

Definition at line 201 of file acqiris_detectors_helper.h.


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