#include <CCAENChain.h>
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 |
CAENcard * | operator[] (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!! | |
CCAENChain & | operator= (const CCAENChain &rhs) |
forbidden!! | |
int | operator== (const CCAENChain &rhs) |
Forbidden!! | |
int | operator!= (const CCAENChain &rhs) |
Forbidden!!! | |
void | FreeModules () |
Kill all modules driver objects. | |
CAENcard * | lastCard () |
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. |
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.
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!!
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] |
int CCAENChain::getCrate | ( | ) | const [inline] |
void* CCAENChain::getVmeHandle | ( | ) | [inline] |
unsigned short CCAENChain::getMaxBytes | ( | ) | const [inline] |
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] |
void CCAENChain::setCrate | ( | int | nCrate | ) | [inline, protected] |
void CCAENChain::setHandle | ( | void * | pHandle | ) | [inline, protected] |
void CCAENChain::setMaxBytes | ( | unsigned short | nBytes | ) | [inline, protected] |
CAENcard * CCAENChain::operator[] | ( | int | index | ) | throw (CRangeError) |
Retrieve a card pointer.
Select a module from the chain.
index | (int in): Index of the module to select. |
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.
pBuffer | (void* out): User buffer into which the chain is read. |
CCAENChain chain(...); ... long buffer[chain.getMaxBytes()/sizeof(long)]; ... ReadEvent(buffer);
... 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().
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] |