CaenIO.cpp

Go to the documentation of this file.
00001 /*
00002     This software is Copyright by the Board of Trustees of Michigan
00003     State University (c) Copyright 2005.
00004 
00005     You may use this software under the terms of the GNU public license
00006     (GPL).  The terms of this license are described at:
00007 
00008      http://www.gnu.org/licenses/gpl.txt
00009 
00010      Author:
00011              Ron Fox
00012              NSCL
00013              Michigan State University
00014              East Lansing, MI 48824-1321
00015 */
00016 
00017 
00018 #include <config.h>
00019 #include <CaenIO.h>
00020 #include <CVME.h>
00021 
00022 #ifdef HAVE_STD_NAMESPACE
00023 using namespace std;
00024 #endif
00025 
00038 CCaenIO::CCaenIO(UInt_t base, int nCrate) :
00039   CVmeModule(CVmeModule::a24d16, base, LENGTH, nCrate),
00040   m_nOutputMask(0)
00041 {
00042 
00043 }
00044 
00055 CCaenIO::CCaenIO(const CCaenIO& aCCaenIO) :
00056   CVmeModule(aCCaenIO)
00057 {
00058   m_nOutputMask = aCCaenIO.m_nOutputMask;
00059 }
00060 
00069 CCaenIO&
00070 CCaenIO::operator=(const CCaenIO& aCCaenIO)
00071 {
00072   if(this == &aCCaenIO) return *this;
00073   CVmeModule::operator= (aCCaenIO);
00074   m_nOutputMask = aCCaenIO.m_nOutputMask;
00075 
00076   return *this;
00077 }
00078 
00090 Int_t
00091 CCaenIO::operator== (const CCaenIO& aCCaenIO)
00092 {
00093   return ((CVmeModule::operator== (aCCaenIO)) &&
00094           (m_nOutputMask == aCCaenIO.m_nOutputMask));
00095 }
00096 
00110 UShort_t
00111 CCaenIO::ReadInput(UInt_t input)
00112 {
00113   if((input < 0) || (input > 3)) {
00114     throw string("\nInvalid input on read operation. Must be between 0 and 3.\n");
00115   }
00116   return ((peekw(5) & (1 << input)) ? 1 : 0);
00117 }
00121 UShort_t
00122 CCaenIO::ReadInputs() 
00123 {
00124   return peekw(5);
00125 }
00126 
00135 void
00136 CCaenIO::PulseOutput(UInt_t output)
00137 {
00138   if((output < 0) || (output > 3)) {
00139     cerr << "\nInvalid output on assert operation. Must be between 0 and 3.\n";
00140     exit(0);
00141   }
00142 
00143   pokew((1 << output), 4);
00144 }
00145 
00157 void
00158 CCaenIO::SetLevel(UInt_t output)
00159 {
00160   if((output < 0) || (output > 3)) {
00161     cerr << "\nInvalid output on assert operation. Must be between 0 and 3.\n";
00162     exit(0);
00163   }
00164 
00165   m_nOutputMask = m_nOutputMask | (1 << output);
00166   pokew(m_nOutputMask, 3);
00167 }
00168 
00179 void
00180 CCaenIO::ClearLevel(UInt_t output)
00181 {
00182   UInt_t clear_mask = ~(1 << output);
00183   m_nOutputMask = m_nOutputMask & clear_mask;
00184   pokew(m_nOutputMask, 3);
00185 }
00186 
00198 void
00199 CCaenIO::SetECL(UShort_t value)
00200 {
00201   pokew(value, 2);
00202 }
00203 
00210 void
00211 CCaenIO::ClearECL()
00212 {
00213   pokew(0, 2);
00214 }
00215 
00222 void
00223 CCaenIO::ClearAll()
00224 {
00225   pokew(0, 2);
00226   pokew(0, 3);
00227 }
00228 #ifdef HAVE_VME_MAPPING
00229 
00237 short*
00238 CCaenIO::getInputPointer()
00239 {
00240   CVME<UShort_t>& map(getCVME());
00241   return ((short*)(map.getStart())+5);
00242 
00243 }
00249 short* 
00250 CCaenIO::getPulsedOutputPointer()
00251 {
00252   CVME<UShort_t>& map(getCVME());
00253   return ((short*)(map.getStart()) + 4);
00254 }
00260 short* 
00261 CCaenIO::getLatchedOutputPointer() 
00262 {
00263   CVME<UShort_t>& map(getCVME());
00264   return ((short*)(map.getStart()) + 3);
00265 }
00272 short* 
00273 CCaenIO::getECLOutputPointer() 
00274 {
00275   CVME<UShort_t>& map(getCVME());
00276   return ((short*)(map.getStart()) + 2);
00277 }
00278 
00279 #endif

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