QCrateReceiverBuffer Class Reference

List of all members.

Detailed Description

class for shared memory handling

Author:
sergio.didomizio@ge.infn.it
One object of this kind will handle a shared memory structure for a single DAQ channel.
Shared memory structure contains some useful variables and a data buffer containing one long word for each acquired sample.
See QBufferStructure_t documentation below for further details about content of shared memory structure.
Follows a description of the format of a single word in data buffer.


Public Member Functions

 QCrateReceiverBuffer (unsigned long ch, bool attach, bool OpenFiles, int RunNumber=0, bool offset_shm=false)
unsigned long Size () const
char * Start () const
 get pointer to first valid word
unsigned long GetNumberOfWords () const
 get number of valid words in buffer
bool EnableTriggerPointer ()
 book trigger pointer
void ReleaseTriggerPointer ()
 release trigger pointer (do nothing if it wasn't booked)
bool EnableBuilderPointer ()
 book builder pointer
void ReleaseBuilderPointer ()
 release builder pointer (do nothing if it wasn't booked)
bool EnableReadPointer ()
 book read pointer
void ReleaseReadPointer ()
 release read pointer (do nothing if it wasn't booked)
void Release (unsigned int n)
 remove data from circular buffer
void Add (int n, const long *data)
 add data to circular buffer
void AddFromNetwork (QConnectedSocket *cs)
 get data from network and add to buffer
int GetLg () const
 get logical channel
int ReadToEnd () const
 distance of read pointer to end of buffer
void SetProcessed (unsigned int n)
 flag n words as processed by trigger
void SetBuilt (unsigned int n)
 flag n words as processed by builder
unsigned long GetToBeProcessed () const
unsigned long GetToBeBuilt () const
 number of valid words still to be processed by builder
unsigned long GetToBeRead () const
 number of valid words still to be read
unsigned long long GetProcessed () const
 get pointer to the first word still to be processed by trigger
unsigned long long GetBuilt () const
 get pointer to the first word to be processed by builder
unsigned long long GetRead () const
 get pointer to the first word to be read
unsigned long long GetWritten () const
 get pointer to the first free word in buffer
long GetData (unsigned long long index) const
 get data
long GetSample (unsigned long long index) const
 get sample
short GetTriggerFlags (unsigned long long index, unsigned long mask=0xF) const
 get trigger flags for given sample
void FlagTrigger (unsigned long long index, int tag)
 flag word with trigger tag
void SetTriggerEnabled (bool enabled)
 set trigger enable/disable flag
void SetSamplingRate (unsigned long rate)
 set sampling rate
unsigned long GetSamplingRate () const
 get sampling rate
long long GetTimeOfSample (unsigned long long index) const
 get time associated to a given sample index
unsigned long long GetSampleOfTime (long long time) const
 get sample index associated to a given time
void Dump ()
void SetScanned (unsigned long long i)
void SetAnalyzed (unsigned long long i)

Private Member Functions

void Release ()
void SetProcessed ()
 private method used to update trigger pointer when it is not booked
void SetBuilt ()
 private method used to update builder pointer when it is not booked
unsigned long GetToBeWritten () const
 get number of words still to be written on gzipped file
void WriteFile ()
 write data in gzipped file
void OpenFile ()
 open new gzipped file
void CloseFile (bool last)
 close current gzipped file

Private Attributes

int fHandle
int fShmid
bool fOwn
QBufferStructure_tp_buffer
gzFile zFile
std::string fGzFileName
unsigned int fPartialFile
bool fReadPtrBooked
bool fBuilderPtrBooked
bool fTrgPtrBooked


Member Function Documentation

bool QCrateReceiverBuffer::EnableTriggerPointer (  ) 

book trigger pointer

For each shared memory, only one instance of QCrateReceiverBuffer can take control of trigger pointer

Returns:
true if booking succeeded, false otherwise

bool QCrateReceiverBuffer::EnableBuilderPointer (  ) 

book builder pointer

For each shared memory, only one instance of QCrateReceiverBuffer can take control of builder pointer

Returns:
true if booking succeeded, false otherwise

bool QCrateReceiverBuffer::EnableReadPointer (  ) 

book read pointer

For each shared memory, only one instance of QCrateReceiverBuffer can take control of read pointer

Returns:
true if booking succeeded, false otherwise

void QCrateReceiverBuffer::Release ( unsigned int  n  )  [inline]

remove data from circular buffer

Parameters:
n number of samples to be removed

void QCrateReceiverBuffer::Add ( int  n,
const long *  data 
)

add data to circular buffer

Parameters:
n number of words to be added
data pointer to buffer containing data

long QCrateReceiverBuffer::GetData ( unsigned long long  index  )  const [inline]

get data

By "data" we mean the complete content of the long word identified by index. Use GetSample method if you're intereste only to the part of long word containing value sampled by ADC (see the top of this file for detailed descripion of data structure).

Parameters:
index index of data to be returned

long QCrateReceiverBuffer::GetSample ( unsigned long long  index  )  const [inline]

get sample

return the value sampled by ADC identified by index. It is not the whole content of the long word contained in the buffer, but a subpart of it. See the top of this file for detailed description of data sctructure.

Parameters:
index index of sample to be returned

short QCrateReceiverBuffer::GetTriggerFlags ( unsigned long long  index,
unsigned long  mask = 0xF 
) const [inline]

get trigger flags for given sample

Parameters:
index index of sample for which trigger flags are returned
mask bit mask that can be used to return only a subset of the trigger flags. Defaults to all (0xF).
Returns:
short containing the 4 trigger flags in the 4 LSB bits.

void QCrateReceiverBuffer::FlagTrigger ( unsigned long long  index,
int  tag 
) [inline]

flag word with trigger tag

documentation to be added

void QCrateReceiverBuffer::SetTriggerEnabled ( bool  enabled  )  [inline]

set trigger enable/disable flag

When this method is called, a flag is set in last sample written by Daq.

Parameters:
enabled if true, bit 26 is flagged. If false, bit 25 is flagged

long long QCrateReceiverBuffer::GetTimeOfSample ( unsigned long long  index  )  const [inline]

get time associated to a given sample index

Parameters:
index sample index for which time is requested
Returns:
time associated to the requested index; if index do not fall between the first and the last valid index (i.e. that sample is not available) a negative time is returned


Member Data Documentation

int QCrateReceiverBuffer::fShmid [private]

shared memory id

bool QCrateReceiverBuffer::fOwn [private]

true if shared memory is owned by this instance of QCrateReceiverBuffer

QBufferStructure_t* QCrateReceiverBuffer::p_buffer [private]

pointer to shared memory buffer

gzFile QCrateReceiverBuffer::zFile [private]

pointer to single channel data file

std::string QCrateReceiverBuffer::fGzFileName [private]

single channel data file name

unsigned int QCrateReceiverBuffer::fPartialFile [private]

partial file number

bool QCrateReceiverBuffer::fReadPtrBooked [private]

true if this instance of QCrateReceiver has control on read ptr

bool QCrateReceiverBuffer::fBuilderPtrBooked [private]

true if this instance of QCrateReceiverBuffer has control on builder pointer

bool QCrateReceiverBuffer::fTrgPtrBooked [private]

true if this instance of QCrateReceiverBuffer has control on trigger pointer


The documentation for this class was generated from the following files:
Generated on Fri Mar 6 13:40:42 2009 for CUORE Software by  doxygen 1.5.1