CCAENV977.cpp

Go to the documentation of this file.
00001 
00002 //  CCAENV977.cpp
00003 //  Implementation of the Class CCAENV977
00004 //  Created on:      07-Jun-2005 04:42:54 PM
00005 //  Original author: Ron Fox
00007 
00008 #include <config.h>
00009 #include "CCAENV977.h"
00010 #include "VmeModule.h"
00011 #include <string>
00012 
00013 #ifdef __HAVE_STD_NAMESPACE
00014 using namespace std;
00015 #endif
00016 
00017 #define CHECK_ALL
00018 #define _DEBUG
00019 #include <DesignByContract.h>
00020 
00021 using namespace DesignByContract;
00022 
00023 
00024 // The following are word offsets into the device:
00025 
00026 static const UInt_t INPUT_SET(0);
00027 static const UInt_t INPUT_MASK(1);
00028 static const UInt_t INPUT_READ(2);
00029 static const UInt_t SINGLEHIT_READ(3);
00030 static const UInt_t MULTIHIT_READ(4);
00031 static const UInt_t OUTPUT_SET(5);
00032 static const UInt_t OUTPUT_MASK(6);
00033 static const UInt_t INTERRUPT_MASK(7);
00034 static const UInt_t CLEAR_OUTPUT(8);
00035 static const UInt_t SINGLEHIT_RDCLEAR(11);
00036 static const UInt_t MULTIHIT_RDCLEAR(12);
00037 static const UInt_t TEST_CONTROL(13);
00038 static const UInt_t IPL(16);
00039 static const UInt_t INTERRUPT_ID(17);
00040 static const UInt_t SERIAL(18);
00041 static const UInt_t FIRMWARE_REV(19);
00042 static const UInt_t CONTROL_REGISTER(20);
00043 static const UInt_t DUMMY_REGISTER(21);
00044 static const UInt_t SOFTWARE_RESET(23);
00045 
00046 
00047 // Multi bit masks.
00048 
00049 static const UShort_t validTestBits =  (CCAENV977::test_Clear   |
00050                                         CCAENV977::test_Mask    |
00051                                         CCAENV977::test_OrMask  |
00052                                         CCAENV977::test_IrqMask |
00053                                         CCAENV977::test_Read);
00054 
00055   static const UShort_t validControlBits = (CCAENV977::control_Pattern  |
00056                                             CCAENV977::control_gateMask |
00057                                             CCAENV977::control_OrMask);
00058 
00066 CCAENV977::CCAENV977(ULong_t lBase, UShort_t nCrate) :
00067   m_Module(*(new CVmeModule(CVmeModule::a32d32, lBase, 0x100, nCrate)))
00068 {
00069 
00070 }
00071 
00072 
00076 CCAENV977::~CCAENV977()
00077 {
00078   delete &m_Module;
00079 }
00083 CCAENV977::CCAENV977(const CCAENV977& rhs) :
00084   m_Module(*(new CVmeModule(rhs.m_Module)))
00085 {
00086 }
00090 CCAENV977&
00091 CCAENV977::operator=(const CCAENV977& rhs)
00092 {
00093   if(this != &rhs) {
00094     m_Module = rhs.m_Module;
00095   }
00096   return *this;
00097 }
00101 int
00102 CCAENV977::operator==(const CCAENV977& rhs) const
00103 {
00104   return m_Module == rhs.m_Module;
00105 }
00109 int
00110 CCAENV977::operator!=(const CCAENV977& rhs) const
00111 {
00112   return !(*this == rhs);
00113 }
00114 
00116 
00120 UShort_t 
00121 CCAENV977::inputSet()
00122 {
00123   return m_Module.peekw(INPUT_SET);
00124 }
00125 
00126 
00132 void 
00133 CCAENV977::inputSet(UShort_t value)
00134 {
00135   m_Module.pokew(value, INPUT_SET);
00136 }
00137 
00138 
00142 UShort_t 
00143 CCAENV977::inputMask()
00144 {
00145   return m_Module.peekw(INPUT_MASK);
00146 }
00147 
00148 
00154 void 
00155 CCAENV977::inputMask(UShort_t mask)
00156 {
00157   m_Module.pokew(mask, INPUT_MASK);
00158 }
00159 
00160 
00166 UShort_t 
00167 CCAENV977::inputRead()
00168 {
00169   return m_Module.peekw(INPUT_READ);
00170 }
00171 
00172 
00176 UShort_t 
00177 CCAENV977::singleHitRead()
00178 {
00179   return m_Module.peekw(SINGLEHIT_READ);
00180 }
00181 
00182 
00186 UShort_t 
00187 CCAENV977::multihitRead()
00188 {
00189   return m_Module.peekw(MULTIHIT_READ);
00190 }
00191 
00192 
00196 UShort_t 
00197 CCAENV977::outputSet()
00198 {
00199   return m_Module.peekw(OUTPUT_SET);
00200 }
00201 
00202 
00208 void 
00209 CCAENV977::outputSet(UShort_t pattern)
00210 {
00211   m_Module.pokew(pattern, OUTPUT_SET);
00212 }
00213 
00214 
00218 UShort_t 
00219 CCAENV977::outputMask()
00220 {
00221   return m_Module.peekw(OUTPUT_MASK);
00222 }
00223 
00224 
00230 void 
00231 CCAENV977::outputMask(UShort_t mask)
00232 {
00233   m_Module.pokew(mask, OUTPUT_MASK);
00234 }
00235 
00236 
00240 UShort_t 
00241 CCAENV977::interruptMask()
00242 {
00243   return m_Module.peekw(INTERRUPT_MASK);
00244 }
00245 
00246 
00252 void 
00253 CCAENV977::interruptMask(UShort_t mask)
00254 {
00255   m_Module.pokew(mask, INTERRUPT_MASK);
00256 }
00257 
00258 
00262 void 
00263 CCAENV977::outputClear()
00264 {
00265   m_Module.pokew(0, CLEAR_OUTPUT);
00266 }
00267 
00268 
00272 UShort_t 
00273 CCAENV977::singleHitReadAndClear()
00274 {
00275   
00276   return m_Module.peekw(SINGLEHIT_RDCLEAR);
00277 }
00278 
00279 
00283 UShort_t 
00284 CCAENV977::multiHitReadAndClear()
00285 {
00286 
00287   return m_Module.peekw(MULTIHIT_RDCLEAR);
00288 
00289 }
00290 
00291 
00296 UShort_t 
00297 CCAENV977::testControlRegister()
00298 {
00299 
00300   return (m_Module.peekw(TEST_CONTROL) & validTestBits);
00301 }
00302 
00303 
00310 void 
00311 CCAENV977::testControlRegister(UShort_t mask)
00312 {
00313 
00314   REQUIRE(mask == (mask & validTestBits), "Invalid bits in test mask");
00315   m_Module.pokew(mask, TEST_CONTROL);
00316 
00317 }
00318 
00319 
00320 
00324 UShort_t 
00325 CCAENV977::serialNumber()
00326 {
00327 
00328   return m_Module.peekw(SERIAL);
00329 
00330 }
00331 
00332 
00336 UShort_t 
00337 CCAENV977::firmwareLevel()
00338 {
00339 
00340   return m_Module.peekw(FIRMWARE_REV);
00341 
00342 }
00343 
00344 
00351 void 
00352 CCAENV977::controlRegister(UShort_t mask)
00353 {
00354 
00355   REQUIRE(string("Invalid bits in control Register mask"), (mask & validControlBits) == mask);
00356   m_Module.pokew(mask, CONTROL_REGISTER);
00357 
00358 }
00359 
00360 
00364 UShort_t 
00365 CCAENV977::controlRegister()
00366 {
00367 
00368   return (m_Module.peekw(CONTROL_REGISTER) & validControlBits);
00369 }
00370 
00371 
00375 void 
00376 CCAENV977::Reset()
00377 {
00378 
00379   m_Module.pokew(0, SOFTWARE_RESET);
00380 
00381 }
00382 
00383 

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