00001
00012 #ifndef __V890_H
00013 #define __V890_H
00014
00015
00016 class CAENV890 {
00017 int m_nSlot;
00018 int m_nCrate;
00019 bool m_fGeographical;
00020 unsigned long m_lBase;
00021 void* m_pModule;
00022 void* m_pVmeDevice;
00023 unsigned m_nModuleType;
00024 public:
00025 static const int m_nTdcClock;
00026 static const int m_nTdcMaxVal;
00027 typedef struct TriggerInfo {
00028 unsigned short Window;
00029 short Offset;
00030 short ExtraSearchWindow;
00031 short RejectMargin;
00032 short SubtractionEnabled;
00033 };
00034 typedef enum _EdgeDetectSelection {
00035 EdgePairs = 0,
00036 TrailingEdge = 1,
00037 LeadingEdge = 2,
00038 EitherEdge = 3
00039 } EdgeDetectSelection;
00040
00041 typedef enum _ResolutionSelection {
00042 ps800 = 0,
00043 ps200 = 1,
00044 ps100 = 2
00045 } ResolutionSelection;
00046
00047 typedef enum _MaxHitSelection {
00048 HitMax0,
00049 HitMax1,
00050 HitMax2,
00051 HitMax4,
00052 HitMax8,
00053 HitMax16,
00054 HitMax32,
00055 HitMax64,
00056 HitMax128,
00057 HitMaxNoLimit
00058 } MaxHitSelection;
00059 public:
00060
00061
00062 CAENV890(int nSlot,
00063 int nCrate = 0,
00064 bool fGeo = true,
00065 unsigned long lBase = 0);
00066 ~CAENV890();
00067
00068
00069
00070 public:
00071 int getSlot() const {
00072 return m_nSlot;
00073 }
00074 int getCrate() const {
00075 return m_nCrate;
00076 }
00077 bool getGeo() const {
00078 return m_fGeographical;
00079 }
00080 unsigned long getBase() const {
00081 return m_lBase;
00082 }
00083 void* getRegisters() {
00084 return m_pModule;
00085 }
00086 void* getVmeDevice() {
00087 return m_pVmeDevice;
00088 }
00089 unsigned getModuleType() const {
00090 return m_nModuleType;
00091 }
00092
00093
00094
00095
00096 unsigned getSlotRegister() const;
00097 void EmptyEvent(bool state);
00098 bool EmptyEventOn();
00099 void Reset();
00100 void Clear();
00101 void TestMode(bool enable, unsigned long nPattern = 0);
00102 void LoadDefaultConfig();
00103 bool isTriggerMatching();
00104 void ReadTriggerConfig(TriggerInfo* pTriggerInfo);
00105
00107
00108 void SetTriggerMatchingMode();
00109 void SetContinuousStorageMode();
00110 bool isTriggerMatchingMode();
00111
00113
00114 void EnableChannel(int nChan);
00115 void DisableChannel(int nChan);
00116 void EnableAllChannels();
00117 void DisableAllChannels();
00118 void SetChannelMask(unsigned short* pMask);
00119 void ReadChannelEnables(unsigned short* pEnables);
00120 void SetWindowWidth(int ns);
00121 int GetWindowWidth();
00122 void SetWindowOffset(int ns);
00123 int GetWindowOffset();
00124 void EnableTriggerSubtraction();
00125 void DisableTriggerSubtraction();
00126 bool TriggerSubtractionEnabled();
00127 void SetEdgeDetection(EdgeDetectSelection edge);
00128 EdgeDetectSelection GetEdgeDetection();
00129 void SetResolution(ResolutionSelection res);
00130 ResolutionSelection GetResolution();
00131 void EnableDelimeters();
00132 void DisableDelimeters();
00133 bool DelimetersEnabled();
00134 void SetMaxHits(MaxHitSelection hits);
00135 MaxHitSelection GetMaxHits();
00136 bool DataReady();
00137
00138
00139
00140 unsigned int Read(unsigned int nBufferSize, void* pBuffer);
00141
00142
00143 protected:
00144 void MapModule();
00145 void* MapRegions(void* pfd, unsigned long base);
00146 void WriteMicro(unsigned short opcode);
00147 unsigned short ReadMicro();
00148 void ReadMicroArray(unsigned short opcode,
00149 unsigned short nWords, void* pBuffer);
00150 void WriteMicroArray(unsigned short opcode,
00151 unsigned short nWords, void* pBuffer);
00152 static int ReadModuleType(void* prom);
00153 static int TicksToNs(int ticks);
00154 static int NsToTicks(int ns);
00155 };
00156
00157 #endif