CCAENChain Class Reference

#include <CCAENChain.h>

List of all members.

Public Member Functions

 CCAENChain (int nFirstSlot, int nLastSlot, STD(vector)< unsigned long > &vBases, int nCrate=0, bool geo=true) throw (STD(string))
 ~CCAENChain ()
 STD (vector)< CAENcard * > getCards()
unsigned long getCBLTAddress () const
int getCrate () const
void * getVmeHandle ()
unsigned short getMaxBytes () const
CAENcardoperator[] (int index) throw (CRangeError)
 Retrieve a card pointer.
int ReadEvent (void *pBuffer)
 Read an event from cards.
void ClearData ()
 Clear constituent cards.
void lastModuleEmptyEnable ()
void lastModuleEmptyDisable ()

Protected Member Functions

void setCards (const STD(vector)< CAENcard * > vCards)
void setCBLTAddress (unsigned long nCBLTAddress)
void setCrate (int nCrate)
void setHandle (void *pHandle)
void setMaxBytes (unsigned short nBytes)

Private Member Functions

 STD (vector)< CAENcard * > m_vCards
 Card driver objects for the chain.
 CCAENChain (const CCAENChain &rhs)
 forbidden!!
CCAENChainoperator= (const CCAENChain &rhs)
 forbidden!!
int operator== (const CCAENChain &rhs)
 Forbidden!!
int operator!= (const CCAENChain &rhs)
 Forbidden!!!
void FreeModules ()
 Kill all modules driver objects.
CAENcardlastCard ()

Private Attributes

unsigned long m_nCBLTAddress
 CBLT address assigned to the chain.
int m_nCrate
 VME crate containing the chain.
void * m_pHandle
 Handle to he VME crate for Read.
unsigned short m_nMaxBytes
 Calculated maximum transfer size.
void * m_pBase
 Ptr to base address.


Detailed Description

This class allows the user to compose a set of modules into a chain for CBLT readout. The CBLT readout support allows a set of crate contiguous modules to be readout in a unit. As each module finishes presenting the data associated with an event, it uses the IRQ/IACK daisy chain to pass control on to the next module. This makes large systems amenable to block mode readout (and that's what this class sets up).

Chains consist of a start card (left most module in the chain), an end card (right most module in the chain) and a set of intermediate cards which must not skip any slots, and must live to the right of the start card and to the left of the end card.

Sample good chain for a crate:


   +-+-+-+-+-+-+-+-+-+
   |S I I I E x x x x|
   +-----------------+
 
   S - Start card
   I - Intermediate card
   E - End card
   x - Don't care
   - - Empty slot.

   

Sample invalid chains:


   +-+-+-+-+-+-+-+-+-+
   |S I - I E x x x x|
   +-----------------+

   Empty slot in the middle of a chain.

   +-+-+-+-+-+-+-+-+
   |I S I I E x x x| 
   +---------------+
 
   Intermediate card not in between Start and End cards.

   

In general, if you have a system of geographical addressing, you won't need to worry about this, just plug the cards in and designate to the constructor the range of slots you'll be using.

If you don't have slot addressable cards, you'll have to be sure that the STD(vector) of base addresses you supply really corresponds to a valid chain or errors will occur.

Definition at line 99 of file CCAENChain.h.


Constructor & Destructor Documentation

CCAENChain::CCAENChain ( int  nFirstSlot,
int  nLastSlot,
STD(vector)< unsigned long > &  vBases,
int  nCrate = 0,
bool  geo = true 
) throw (STD(string))

CCAENChain::~CCAENChain (  ) 

Destroy the chain. This involves:

Definition at line 220 of file CCAENChain.cpp.

References FreeModules(), and m_pHandle.

CCAENChain::CCAENChain ( const CCAENChain rhs  )  [private]

forbidden!!


Member Function Documentation

CCAENChain::STD ( vector   )  [private]

Card driver objects for the chain.

CCAENChain& CCAENChain::operator= ( const CCAENChain rhs  )  [private]

forbidden!!

int CCAENChain::operator== ( const CCAENChain rhs  )  [private]

Forbidden!!

int CCAENChain::operator!= ( const CCAENChain rhs  )  [private]

Forbidden!!!

CCAENChain::STD ( vector   )  [inline]

Definition at line 127 of file CCAENChain.h.

unsigned long CCAENChain::getCBLTAddress (  )  const [inline]

Definition at line 130 of file CCAENChain.h.

References m_nCBLTAddress.

int CCAENChain::getCrate (  )  const [inline]

Definition at line 133 of file CCAENChain.h.

References m_nCrate.

void* CCAENChain::getVmeHandle (  )  [inline]

Definition at line 136 of file CCAENChain.h.

References m_pHandle.

unsigned short CCAENChain::getMaxBytes (  )  const [inline]

Definition at line 139 of file CCAENChain.h.

References m_nMaxBytes.

void CCAENChain::setCards ( const STD(vector)< CAENcard * >  vCards  )  [inline, protected]

Definition at line 148 of file CCAENChain.h.

void CCAENChain::setCBLTAddress ( unsigned long  nCBLTAddress  )  [inline, protected]

Definition at line 151 of file CCAENChain.h.

References m_nCBLTAddress.

void CCAENChain::setCrate ( int  nCrate  )  [inline, protected]

Definition at line 154 of file CCAENChain.h.

References m_nCrate.

void CCAENChain::setHandle ( void *  pHandle  )  [inline, protected]

Definition at line 157 of file CCAENChain.h.

References m_pHandle.

void CCAENChain::setMaxBytes ( unsigned short  nBytes  )  [inline, protected]

Definition at line 160 of file CCAENChain.h.

References m_nMaxBytes.

CAENcard * CCAENChain::operator[] ( int  index  )  throw (CRangeError)

Retrieve a card pointer.

Select a module from the chain.

Parameters:
index (int in): Index of the module to select.
Returns:
CAENCard* pointer to the module selected. The intent is that the user can then configure the module appropriately.
Exceptions:
CRangeError If the index is out of range.

Definition at line 236 of file CCAENChain.cpp.

int CCAENChain::ReadEvent ( void *  pBuffer  ) 

Read an event from cards.

Read an event from the chain. This is done by issuing a read of m_nMaxBytes long. The cards set themselves up in a chain to Buserr on end of data so the actual number of bytes read will, in general, be fewer.

Parameters:
pBuffer (void* out): User buffer into which the chain is read.
Returns:
int Number of words actually read.
Note:
This function does not detect buffer overruns. A good way to declare the user buffer is either:

	   CCAENChain  chain(...);
	   ...
	   long buffer[chain.getMaxBytes()/sizeof(long)];
	   ...
	   ReadEvent(buffer);

	   
Or of course:

	   ...
	   long* pBuffer = new long[chain.getMaxByte()/sizeof(long)];
	   ...
	   ReadEvent(pBuffer);

	   

Definition at line 282 of file CCAENChain.cpp.

References DMA_THRESHOLD, m_nCBLTAddress, m_nCrate, m_nMaxBytes, and m_pHandle.

void CCAENChain::ClearData (  ) 

Clear constituent cards.

Clear the data in all cards.

Definition at line 308 of file CCAENChain.cpp.

void CCAENChain::lastModuleEmptyEnable (  ) 

Turns on the EMPTY_PROG bit of the Bit2 control/status register on the right most module in the chain.. When enabled, this bit implies that the last module in the chain will provide a header/trailer longword if it got a gate, if there is no data. This is intended to help unambiguously identify the end of data.

The SBS PCI/VME interface has a deeply pipelined DMA engine. It is not able to reliably deliver partial transfer counts for DMA that end in a BUSERR e.g. However, in most cases, doing a CBLT read will result in a partial transfer terminating in a BUSERR.

If the modules in the chain all have a common GATE, this ensures there are always a header/trailer from the last module in the chain, and that data can allow an unambiguous determination of the end of the chain data. Typically one would use this by placing the data from the chain read in a packet. Processing the data in the packet until the trailer from the last ADC in the chain, but using the packet word count to determine where the next chunk of data is.

Definition at line 351 of file CCAENChain.cpp.

References CAENcard::emptyEnable(), and lastCard().

void CCAENChain::lastModuleEmptyDisable (  ) 

This turns off the EMPTY_PROG bit of the Bit2 stat of the right most module in the chain. See lastModuleEmptyEnable for an full discussion of what that means. This is the default state (disabled).

Definition at line 365 of file CCAENChain.cpp.

References CAENcard::emptyDisable(), and lastCard().

void CCAENChain::FreeModules (  )  [private]

Kill all modules driver objects.

(utility).

Frees the set of moudules that exist in the chain. This is done both at destruction and for exceptions that occur in the constructor.

Definition at line 324 of file CCAENChain.cpp.

Referenced by ~CCAENChain().

CAENcard * CCAENChain::lastCard (  )  [private]

Definition at line 375 of file CCAENChain.cpp.

Referenced by lastModuleEmptyDisable(), and lastModuleEmptyEnable().


Member Data Documentation

unsigned long CCAENChain::m_nCBLTAddress [private]

CBLT address assigned to the chain.

Definition at line 103 of file CCAENChain.h.

Referenced by getCBLTAddress(), ReadEvent(), and setCBLTAddress().

int CCAENChain::m_nCrate [private]

VME crate containing the chain.

Definition at line 104 of file CCAENChain.h.

Referenced by getCrate(), ReadEvent(), and setCrate().

void* CCAENChain::m_pHandle [private]

Handle to he VME crate for Read.

Definition at line 105 of file CCAENChain.h.

Referenced by getVmeHandle(), ReadEvent(), setHandle(), and ~CCAENChain().

unsigned short CCAENChain::m_nMaxBytes [private]

Calculated maximum transfer size.

Definition at line 106 of file CCAENChain.h.

Referenced by getMaxBytes(), ReadEvent(), and setMaxBytes().

void* CCAENChain::m_pBase [private]

Ptr to base address.

Definition at line 107 of file CCAENChain.h.


The documentation for this class was generated from the following files:
Generated on Wed Sep 17 08:38:11 2008 for NSCL Device support. by  doxygen 1.5.1