CAENcard.h

Go to the documentation of this file.
00001 /*
00002 #
00003 #    This software is Copyright by the Board of Trustees of Michigan
00004 #    State University (c) Copyright 2005.
00005 #
00006 #    You may use this software under the terms of the GNU public license
00007 #    (GPL).  The terms of this license are described at:
00008 #
00009 #     http://www.gnu.org/licenses/gpl.txt
00010 #
00011 #     Author:
00012 #             Ron Fox
00013 #            NSCL
00014 #            Michigan State University
00015 #            East Lansing, MI 48824-1321
00016 #
00017 */
00018 
00019 #ifndef CAENCARD_H
00020 #define CAENCARD_H
00021 
00022 #include <stdio.h>
00023 #include <sys/types.h>
00024 #include <sys/stat.h>
00025 #include <sys/mman.h>
00026 #include <errno.h>
00027 #include <fcntl.h>
00028 #include <unistd.h>
00029 #include <signal.h>
00030 #include <sys/ioctl.h>
00031 
00032 #ifndef __CVMEINTERFACE_H
00033 #include <CVMEInterface.h>
00034 #endif
00035 
00036 #ifndef SPECTRODAQ_H
00037  // Hate to do this here, but I have no real choice:
00038 
00039 #ifdef HAVE_STD_NAMESPACE
00040 using namespace std;
00041 #endif
00042 
00043 #include <spectrodaq.h>
00044 #endif
00045 
00046 
00047 #ifndef HAVE_VME_MAPPING
00048 #include <VmeModule.h>          // Needed to access registers via peek/poke.
00049 #endif
00050 
00051 //Constants used to determine the type of data being returned from the card
00052 
00053 #define CAEN_DATUM_TYPE    0x07000000
00054 #define CAEN_HEADER        0x02000000
00055 #define CAEN_DATA          0x00000000
00056 #define CAEN_FOOTER        0x04000000
00057 #define CAEN_INVALID       0x06000000
00058 
00059 
00078 class CAENcard {
00079  public:                        // Data types
00080   typedef enum _ChainMember {   // Possible chain memberships
00081     NotInChain,
00082     FirstInChain,
00083     LastInChain,
00084     IntermediateInChain
00085   } ChainMember;
00086 
00087  protected:
00088   int    m_nSlot;               
00089   int    m_nCrate;              
00090   bool   m_fGeo;                
00091   unsigned long   m_nBase;      
00092 #ifdef HAVE_VME_MAPPING
00093   volatile unsigned short* m_pModule;   
00094 #else
00095   CVmeModule* m_pModule;
00096 #endif
00097   long   m_nCardType;          
00098   void*  m_nFd;                 
00099   int    m_nSerialno;           
00100   int    m_nHardwareRev;        
00101   bool   m_fSmallThresholds;    
00102   int    m_nInvalidTrailers;    
00103   int    m_nChancountHigh;      
00104   int    m_nChancountLow;       
00105   int    m_nEvents;             
00106   unsigned short m_nFirmware;    
00107 
00108 
00109 
00110 
00111 /*************************begin public section*********************************/
00112 public:
00113   //
00114   // Constructors and canonical operations.
00115   //
00116   
00117   CAENcard(int slotNum = -1, int crateNum = 0, 
00118            bool fGeo=true, long nBase = 0); 
00119   CAENcard(const CAENcard& card); 
00120   CAENcard& operator=(const CAENcard& card); 
00121   ~CAENcard();          
00122 
00123   // selectors:
00124   int getPhysicalCrate() const {
00125     return m_nCrate;
00126   }
00127   int getSlot() const {
00128     return m_nSlot;
00129   }
00130   bool isGeo() const {
00131     return m_fGeo;
00132   }
00133   unsigned long getBase() const {
00134     return m_nBase;
00135   }
00136   int getSerial() const {
00137     return  m_nSerialno;
00138   }
00139   int getHardwareRev() const {
00140     return m_nHardwareRev;
00141   }
00142 
00143   //   Operations on the card.
00144 
00145     int  cardType();            
00146   int  getFirmware();           
00147     int  getCrate();            
00148     void setCrate(int crateNum);  
00149     void setThreshold(int ch, int threshold); 
00150     void setThresholdVoltage(int ch, double voltage);
00151     void keepUnderThresholdData(); 
00152     void discardUnderThresholdData(); 
00153     void keepOverflowData();    
00154     void discardOverflowData(); 
00155     void keepInvalidData();     
00156     void discardInvalidData();  
00157     void emptyEnable();         
00158     void emptyDisable();        
00159     void commonStart();         
00160     void commonStop();          
00161     void setRange(int range);   
00162     void setPedestalCurrent(int ped);
00163     void cardOff();             
00164     void cardOn();              
00165     void channelOff(int ch);    
00166     void channelOn(int ch);     
00167     void resetEventCounter();   
00168     void clearData();           
00169     void reset();               
00170     bool dataPresent();         
00171     bool gdataPresent();
00172     bool Busy();
00173     bool gBusy();
00174     bool MEBFull();
00175     bool MEBEmpty();
00176     int readEvent(void* buf);   
00177     int readEvent(DAQWordBuffer& wbuf, int offset);
00178     int readEvent(DAQWordBufferPtr& wp); 
00179     int readEvent(DAQDWordBuffer& dwbuf, int offset);
00180     int readEvent(DAQDWordBufferPtr& dwp); 
00181     void setIped(int value); 
00182     int  getIped();     
00183     void setFastClearWindow(int n);  
00184     void enableSmallThresholds();   
00185     void disableSmallThresholds();  
00186   void SetCBLTChainMembership(int cbltaddr,
00187                               ChainMember where); 
00188 
00189   void ClearStatistics();       
00190   int  InvalidTrailerCount();
00191   int  ChannelsTooBigCount();
00192   int  ChannelsTooSmallCount();
00193   int  EventCount();
00194 
00195   //Utility functions:
00196 protected:
00197   void  DestroyCard();          
00198   void  slotInit();             
00199   void  MapCard();              
00200 private:
00201    void Bitset1(short mask);    
00202    void Bitclear1(short mask);  
00203    void Bitset2(short mask);    
00204    void Bitclear2(short mask);  
00205    void ReadBufferBlock(int* pDest, Int_t size); // Read block from data buf.
00206 };
00207 
00208 #endif

Generated on Wed Sep 17 08:38:09 2008 for NSCL Device support. by  doxygen 1.5.1