Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

CNSCLOutputBuffer Class Reference

#include <CNSCLOutputBuffer.h>

Inheritance diagram for CNSCLOutputBuffer:

CNSCLControlBuffer CNSCLPhysicsBuffer CNSCLScalerBuffer CNSCLStringListBuffer CNSCLBeginBuffer CNSCLEndBuffer CNSCLPauseBuffer CNSCLResumeBuffer CNSCLDocumentationBuffer CRunVariableBuffer CStateVariableBuffer List of all members.

Public Methods

 CNSCLOutputBuffer (unsigned nWords=4096)
 Default constructor.

 ~CNSCLOutputBuffer ()
 Destructor.

DAQWordBuffer & getBuffer ()
DAQWordBufferPtr getBufferPtr () const
int getWords () const
unsigned long getSequence () const
unsigned short getEntityCount ()
void ComputeSize ()
void SetType (int nType)
void ComputeChecksum ()
DAQWordBufferPtr StartEntity ()
void EndEntity (const DAQWordBufferPtr &ePtr)
void SetCpuNum (unsigned short nValue=0)
void SetNbitRegisters (unsigned nBitReg=1)
void SetLamRegisters (unsigned short nLams=0)
void PutEntity (void *pEntity, unsigned int nWords)
void PutLong (const unsigned long &rLong)
void PutWord (unsigned short nData)
void PutWords (const unsigned short *pWords, unsigned int nWords)
void PutString (const char *pData, int nMaxSize=-1)
void SetRun (unsigned short nRun)
bool EntityFits (unsigned short nWords)
void Route (bool NextSequence=true)
void Seek (int nOffset, int whence=SEEK_SET)
void Seek (DAQWordBufferPtr &rPtr)
void Resize (int newsize)

Static Public Methods

void IncrementSequence ()
void ClearSequence ()

Protected Methods

void InitializeHeader ()

Protected Attributes

DAQWordBuffer m_Buffer
 Spectrodaq Buffer to hold the data being emitted.


Static Protected Attributes

int m_ControlTag = 3
int m_EventTag = 2

Private Methods

 CNSCLOutputBuffer (const CNSCLOutputBuffer &rhs)
 Copy constructor.

CNSCLOutputBuffer & operator= (const CNSCLOutputBuffer &rhs)
 Assignment.

int operator== (const CNSCLOutputBuffer &rhs) const
 Comparison for equality.

int operator!= (const CNSCLOutputBuffer &rhs) const

Private Attributes

DAQWordBufferPtr m_BufferPtr
 'pointer' to the current slot of the buffer.

int m_nWords
 Number of words the buffer can hold.


Static Private Attributes

unsigned long m_nSequence = 0
 Sequence number for the buffer.


Detailed Description

CNSCLOutputBuffer is the base class of a class hierarchy whidh supports creating NSCL formatted buffers that can be emitted into the Data Acquisition system.

NSCL Data Acquisition system buffers have a fixed header and variable body. The "shape" of the body depends on the 'type' word of the buffer header. This set of classes simplifies the creation of the body of a buffer as well as synchonizing the body contents with the appropriate fields of the header.

Definition at line 314 of file CNSCLOutputBuffer.h.


Constructor & Destructor Documentation

CNSCLOutputBuffer::CNSCLOutputBuffer unsigned    nWords = 4096
 

Default constructor.

Default constructor. This is called when declarations of the form e.g.:

  • CNSCLOutputBuffer object; are performed.

Definition at line 343 of file CNSCLOutputBuffer.cpp.

References InitializeHeader().

CNSCLOutputBuffer::~CNSCLOutputBuffer   [inline]
 

Destructor.

Definition at line 330 of file CNSCLOutputBuffer.h.

CNSCLOutputBuffer::CNSCLOutputBuffer const CNSCLOutputBuffer &    rhs [private]
 

Copy constructor.


Member Function Documentation

void CNSCLOutputBuffer::ClearSequence   [static]
 

Clears the sequence number.

Definition at line 778 of file CNSCLOutputBuffer.cpp.

References m_nSequence.

Referenced by CExperiment::EmitStart().

void CNSCLOutputBuffer::ComputeChecksum  
 

Computes the buffer checksum and places it in the checksum field of the buffer. The checksum is computed such that the sum of the used words in the buffer is zero.

Note:
The checksum will change as items are added or changed in the buffer. Route automatically calls ComputeChecksum(). While there is no programmatic harm in recomputing the checksum over and over again, there is a performance loss in doing so.. You are best off letting Route() do that for you.
Note:
It is assumed that m_Buffer[hdrWSIZE] is correct.

Definition at line 393 of file CNSCLOutputBuffer.cpp.

References hdrWCKS, hdrWSIZE, and m_Buffer.

Referenced by Route().

void CNSCLOutputBuffer::ComputeSize  
 

Uses the current buffer pointer to determine the number of words in the buffer. The resulting value is set in the buffer size word of the buffer header.

Definition at line 360 of file CNSCLOutputBuffer.cpp.

References hdrWSIZE, m_Buffer, and m_BufferPtr.

Referenced by Route().

void CNSCLOutputBuffer::EndEntity const DAQWordBufferPtr &    rpBuf
 

Ends an entity insertion into the buffer. The Entity count field of the buffer is incremented.

Parameters:
rpBuf  - Pointer to word after event.

Definition at line 429 of file CNSCLOutputBuffer.cpp.

References hdrWENTITY, m_Buffer, and m_BufferPtr.

Referenced by PutEntity(), and CNSCLStringListBuffer::PutEntityString().

bool CNSCLOutputBuffer::EntityFits unsigned short    nWords
 

Determines if an entity will fit in the buffer free space. The free space is defined to be the words between the current offset of m_BufferPtr and the end of the buffer.

Parameters:
nWords  - Size of the entity.

Definition at line 674 of file CNSCLOutputBuffer.cpp.

References m_BufferPtr, and m_nWords.

Referenced by CNSCLStringListBuffer::PutEntityString(), and CExperiment::ReadEvent().

DAQWordBuffer& CNSCLOutputBuffer::getBuffer   [inline]
 

Definition at line 344 of file CNSCLOutputBuffer.h.

References m_Buffer.

Referenced by CNSCLControlBuffer::CNSCLControlBuffer(), CNSCLPhysicsBuffer::CNSCLPhysicsBuffer(), CNSCLScalerBuffer::CNSCLScalerBuffer(), and CNSCLStringListBuffer::CNSCLStringListBuffer().

DAQWordBufferPtr CNSCLOutputBuffer::getBufferPtr   const [inline]
 

Definition at line 348 of file CNSCLOutputBuffer.h.

References m_BufferPtr.

Referenced by CNSCLStringListBuffer::PutEntityString().

unsigned short CNSCLOutputBuffer::getEntityCount  
 

Return the number of entities currently in the buffer.

Definition at line 826 of file CNSCLOutputBuffer.cpp.

References hdrWENTITY, and m_Buffer.

Referenced by CExperiment::TriggerScalerReadout().

unsigned long CNSCLOutputBuffer::getSequence   const [inline]
 

Definition at line 356 of file CNSCLOutputBuffer.h.

References m_nSequence.

int CNSCLOutputBuffer::getWords   const [inline]
 

Definition at line 352 of file CNSCLOutputBuffer.h.

References m_nWords.

Referenced by CNSCLPhysicsBuffer::EndEvent().

void CNSCLOutputBuffer::IncrementSequence   [static]
 

Increments the sequence number.

Definition at line 767 of file CNSCLOutputBuffer.cpp.

References m_nSequence.

Referenced by Route().

void CNSCLOutputBuffer::InitializeHeader   [protected]
 

Utility function to initialize the buffer header.

Definition at line 786 of file CNSCLOutputBuffer.cpp.

References BODYOFFSET, hdrLSEQ, hdrLSIG, hdrWBUFFMT, hdrWCKS, hdrWENTITY, hdrWSIG, hdrWSIZE, hdrWTYPE, hdrWUNUSED1, hdrWUNUSED2, hdrWUNUSED3, LSIGNATURE, m_Buffer, m_BufferPtr, m_nSequence, REVLEVEL, and SSIGNATURE.

Referenced by CNSCLOutputBuffer(), and Route().

int CNSCLOutputBuffer::operator!= const CNSCLOutputBuffer &    rhs const [private]
 

CNSCLOutputBuffer& CNSCLOutputBuffer::operator= const CNSCLOutputBuffer &    rhs [private]
 

Assignment.

int CNSCLOutputBuffer::operator== const CNSCLOutputBuffer &    rhs const [private]
 

Comparison for equality.

void CNSCLOutputBuffer::PutEntity void *    pEntity,
unsigned int    nWords
 

Puts a stream of words into the buffer and increments the entity count field of the buffer header.

Parameters:
void  * pEntity, unsigned int nWords

Definition at line 509 of file CNSCLOutputBuffer.cpp.

References EndEntity(), and StartEntity().

Referenced by CNSCLScalerBuffer::PutScalerVector().

void CNSCLOutputBuffer::PutLong const unsigned long &    rLong
 

Put a long word in the buffer in native system order. The buffer pointer is affected. This is only useful for non-entity words.

Parameters:
rLong  - refers to the long word to put.

Definition at line 532 of file CNSCLOutputBuffer.cpp.

References m_BufferPtr.

Referenced by CNSCLControlBuffer::PutTimeOffset().

void CNSCLOutputBuffer::PutString const char *    pData,
int    nMaxSize = -1
 

Put a null terminated character array into the buffer. Note that strings in NSCL buffers must be an even number of bytes (including their null terminator). If necessary, an additional blank is added to the string. If the string is being put into a fixed size field and is shorter than the buffer field, it is null filled, otherwise it is truncated in a manner which allows the buffer to contain a trailing null.

Parameters:
pData  - Pointer to the string to insert in the buffer (null terminated).
nMaxSize  [-1] - Size of the field into which the data must fit. Note that if -1, the entire string is inserted (the destination is treated as variable length.
Note:
- If nMaxSize is odd, it is incremented to make the maximum field size even since this is a word buffer.

Definition at line 601 of file CNSCLOutputBuffer.cpp.

References m_BufferPtr.

Referenced by CNSCLStringListBuffer::PutEntityString(), and CNSCLControlBuffer::PutTitle().

void CNSCLOutputBuffer::PutWord unsigned short    nData
 

Puts a word of data into the buffer. This is only useful for non-entity words.

Parameters:
nData  - the word to put.

Definition at line 554 of file CNSCLOutputBuffer.cpp.

References m_BufferPtr.

Referenced by CNSCLControlBuffer::SetTime().

void CNSCLOutputBuffer::PutWords const unsigned short *    pWords,
unsigned int    nWords
 

Puts an array of words into the buffer.

Parameters:
pWords  - The array to put.
nWords  - The number of words to put.
Note:
The entity count is not affected, but the buffer pointer is incremented. This is only useful to put words which are not part of a counted entity.

Definition at line 572 of file CNSCLOutputBuffer.cpp.

References m_BufferPtr.

void CNSCLOutputBuffer::Resize int    newsize
 

Resize the buffer as requested.

Parameters:
-  newsize int [in] Number of words for the new buffer size.Note that data may be lost if newsize is smaller than the current buffersize.

Definition at line 836 of file CNSCLOutputBuffer.cpp.

References m_Buffer.

void CNSCLOutputBuffer::Route bool    NextSequence = true
 

Submits the buffer to the spectrodaq server for distribution. The buffer state is set to empty again, once this is done... although to work around bugs in the spectrodaq server it is recommended that this buffer be destroyed after a route.

Parameters:
NextSequence  [true] - If set the sequence number is incremented after the buffer is routed. I most cases it is correct to do so, but for some non-data buffers it's better to leave the sequence fixed so that efficiency calculations are not spoiled by buffer sequences that don't represent buffers with data.
Full set of actions:
  • The buffer size is computed
  • The buffer checksum is computed.
  • The buffer is routed.
  • If desired, the sequence number is incremented.
  • The buffer is recreated at m_nWords size.
  • The new buffer's header is filled in.

Definition at line 705 of file CNSCLOutputBuffer.cpp.

References ComputeChecksum(), ComputeSize(), IncrementSequence(), InitializeHeader(), m_Buffer, and m_nWords.

Referenced by CExperiment::EmitEnd(), CExperiment::EmitPause(), CExperiment::EmitResume(), CExperiment::EmitStart(), CExperiment::Overflow(), CExperiment::ReadEvent(), CExperiment::TriggerDocBuffer(), CExperiment::TriggerRunVariableBuffer(), CExperiment::TriggerScalerReadout(), CExperiment::TriggerSnapshotScaler(), and CExperiment::TriggerStateVariableBuffer().

void CNSCLOutputBuffer::Seek DAQWordBufferPtr &    rPtr [inline]
 

Definition at line 384 of file CNSCLOutputBuffer.h.

References m_BufferPtr.

void CNSCLOutputBuffer::Seek int    nOffset,
int    whence = SEEK_SET
 

Seek the buffer pointer to a particular location.

Parameters:
nOffset  - Offset to seek to (see next).
whence  - Meaning of the offset. This value comes from any of the meanings for lseek, and is symbolically defined in <unistd.h>:
  • SEEK_SET - nOffset is an absolute offset (better be >= 0).
  • SEEK_CUR - nOffset is relative to the current value of m_BufferPtr. -SEEK_END - nOffset is relative to the end of the buffer and better be negative.
Exceptions:
CRangeError  - If whence is invalid or nOffset results in an out of bounds condition.

Definition at line 732 of file CNSCLOutputBuffer.cpp.

References m_Buffer, m_BufferPtr, and m_nWords.

Referenced by CNSCLScalerBuffer::CNSCLScalerBuffer(), CNSCLPhysicsBuffer::EndEvent(), CNSCLControlBuffer::PutTimeOffset(), CNSCLControlBuffer::PutTitle(), and CNSCLControlBuffer::SetTime().

void CNSCLOutputBuffer::SetCpuNum unsigned short    nValue = 0
 

Sets the Cpu number field of the buffer. The CPU number field is used to identify wich system the data in this buffer came from. By convention, this field is the least two significant octets of the system's IP address.. in network byte order. If the function's parameter value is zero, this is determined and used. Otherwise, the parameter is the value.

Note:
CPU number can not be zero.
Parameters:
nValue  If non zero, this overrides the default which comes from gethostid()

Definition at line 452 of file CNSCLOutputBuffer.cpp.

References hdrWCPU, and m_Buffer.

void CNSCLOutputBuffer::SetLamRegisters unsigned short    nLams = 0
 

Sets the nlam field of the buffer header.

Parameters:
nLams  [0] - Number of lam masks.
Note:
As of buffer revision 5, with the use of tagged packets, this field is being decomissioned. This member is provided for compatibility and currently will fill in offset 7 (hdrWUNUSED1), later versions of this software may make this function a no-op.

Definition at line 495 of file CNSCLOutputBuffer.cpp.

References hdrWUNUSED1, and m_Buffer.

void CNSCLOutputBuffer::SetNbitRegisters unsigned    nBitReg = 1
 

Sets the nbit field in the buffer header.

Parameters:
nBitReg  [1] - Number of bit registers to set in the buffer header.
Note:
As of buffer revision 5, with the use of tagged packets, this field is being decomissioned. This member is provided for compatibility and currently will fill in offset 9 (hdrWUNUSED2), later versions of this software may make this function a no-op.

Definition at line 476 of file CNSCLOutputBuffer.cpp.

References hdrWUNUSED2, and m_Buffer.

void CNSCLOutputBuffer::SetRun unsigned short    nRun
 

Set the run number field of the buffer header.

Parameters:
nRun  - Run number to insert in the buffer.

Definition at line 659 of file CNSCLOutputBuffer.cpp.

References hdrWRUN, and m_Buffer.

Referenced by CExperiment::EmitEnd(), CExperiment::EmitPause(), CExperiment::EmitResume(), CExperiment::EmitStart(), CExperiment::Overflow(), CExperiment::ReadEvent(), CExperiment::TriggerDocBuffer(), CExperiment::TriggerRunVariableBuffer(), CExperiment::TriggerScalerReadout(), CExperiment::TriggerSnapshotScaler(), and CExperiment::TriggerStateVariableBuffer().

void CNSCLOutputBuffer::SetType int    nType
 

Sets the type field of the buffer

Parameters:
nType  - Type of the buffer.
nType  - Buffer type field.

Definition at line 373 of file CNSCLOutputBuffer.cpp.

References hdrWTYPE, and m_Buffer.

Referenced by CNSCLBeginBuffer::CNSCLBeginBuffer(), CNSCLDocumentationBuffer::CNSCLDocumentationBuffer(), CNSCLEndBuffer::CNSCLEndBuffer(), CNSCLPauseBuffer::CNSCLPauseBuffer(), CNSCLPhysicsBuffer::CNSCLPhysicsBuffer(), CNSCLResumeBuffer::CNSCLResumeBuffer(), CNSCLScalerBuffer::CNSCLScalerBuffer(), CRunVariableBuffer::CRunVariableBuffer(), CStateVariableBuffer::CStateVariableBuffer(), CExperiment::EmitEnd(), CExperiment::EmitPause(), CExperiment::EmitResume(), CExperiment::EmitStart(), and CExperiment::TriggerSnapshotScaler().

DAQWordBufferPtr CNSCLOutputBuffer::StartEntity  
 

Begins an entity in the buffer. At present this is a no-op.

Parameters:

Definition at line 415 of file CNSCLOutputBuffer.cpp.

References m_BufferPtr.

Referenced by PutEntity(), CNSCLStringListBuffer::PutEntityString(), and CNSCLPhysicsBuffer::StartEvent().


Member Data Documentation

DAQWordBuffer CNSCLOutputBuffer::m_Buffer [protected]
 

Spectrodaq Buffer to hold the data being emitted.

Definition at line 320 of file CNSCLOutputBuffer.h.

Referenced by ComputeChecksum(), ComputeSize(), EndEntity(), getBuffer(), getEntityCount(), InitializeHeader(), Resize(), Route(), Seek(), SetCpuNum(), CNSCLScalerBuffer::SetEndTime(), SetLamRegisters(), SetNbitRegisters(), SetRun(), CNSCLScalerBuffer::SetStartTime(), and SetType().

DAQWordBufferPtr CNSCLOutputBuffer::m_BufferPtr [private]
 

'pointer' to the current slot of the buffer.

Definition at line 322 of file CNSCLOutputBuffer.h.

Referenced by ComputeSize(), EndEntity(), EntityFits(), getBufferPtr(), InitializeHeader(), PutLong(), PutString(), PutWord(), PutWords(), Seek(), and StartEntity().

int CNSCLOutputBuffer::m_ControlTag = 3 [static, protected]
 

Definition at line 333 of file CNSCLOutputBuffer.cpp.

Referenced by CNSCLControlBuffer::CNSCLControlBuffer(), CNSCLScalerBuffer::CNSCLScalerBuffer(), and CNSCLStringListBuffer::CNSCLStringListBuffer().

int CNSCLOutputBuffer::m_EventTag = 2 [static, protected]
 

Definition at line 334 of file CNSCLOutputBuffer.cpp.

Referenced by CNSCLPhysicsBuffer::CNSCLPhysicsBuffer().

unsigned long CNSCLOutputBuffer::m_nSequence = 0 [static, private]
 

Sequence number for the buffer.

Definition at line 331 of file CNSCLOutputBuffer.cpp.

Referenced by ClearSequence(), getSequence(), IncrementSequence(), and InitializeHeader().

int CNSCLOutputBuffer::m_nWords [private]
 

Number of words the buffer can hold.

Definition at line 323 of file CNSCLOutputBuffer.h.

Referenced by EntityFits(), getWords(), Route(), and Seek().


The documentation for this class was generated from the following files:
Generated on Fri Nov 8 13:37:18 2002 for Event Readout system. by doxygen1.2.16