メインページ   モジュール   名前空間一覧   クラス階層   アルファベット順一覧   構成   ファイル一覧   構成メンバ   ファイルメンバ   関連ページ    

TCamacCrateController.cc

解説を見る。
00001 // =====================================================================
00002 //  $Id: TCamacCrateController.cc,v 1.4 2004/03/07 10:30:31 goiwai Exp $
00003 //  $Name: CLDAQ-1-14-03 $
00004 //  $Log: TCamacCrateController.cc,v $
00005 //  Revision 1.4  2004/03/07 10:30:31  goiwai
00006 //  ROOTに組みこむためのおまじないマクロを埋めこみました。
00007 //  全てにおいて完全に動作するわけではありません。
00008 //
00009 //  Revision 1.3  2003/10/06 17:02:40  goiwai
00010 //  *** empty log message ***
00011 //
00012 //  Revision 1.2  2003/07/30 16:19:09  goiwai
00013 //  ファイルにコミットログをつけることにしました.
00014 //
00015 // =====================================================================
00016 #include "TCamacCrateController.hh"
00017 
00018 TCamacCrateController::TCamacCrateController()
00019   : TModule( 0 ), theCrateControllerType( tCamacCrateControllerUnknown ), 
00020     theCrateID( -1 ), theFileDescriptor( -1 ), theISA7000( Tfalse )
00021 {
00022   theStatus = tStatusSuccess;
00023 }
00024 
00025 TCamacCrateController::TCamacCrateController( TcamacCrateController_t cctype )
00026   : TModule( 0 ), theCrateControllerType( cctype ), 
00027     theCrateID( -1 ), theFileDescriptor( -1 ),
00028     theISA7000( Tfalse )
00029 {
00030   const Tstring head = "TCamacCrateController::TCamacCrateController";
00031   
00032   // open device file
00033   if ( !IsOpen() )
00034     Open();
00035   if ( theFileDescriptor < 0 ) {
00036     perror( head.c_str() );
00037     exit( theStatus );
00038   }
00039 
00040   // check the power
00041   if ( !IsOnline() ) {
00042     perror( head.c_str() );
00043     exit( theStatus );
00044   }
00045 
00046   theISA7000 |= ( theCrateControllerType == tISAcc7000_1 );
00047   theISA7000 |= ( theCrateControllerType == tISAcc7000_2 );
00048   theISA7000 |= ( theCrateControllerType == tISAcc7000_3 );
00049   theISA7000 |= ( theCrateControllerType == tISAcc7000_4 );
00050 
00051   theStatus = tStatusSuccess;
00052 }
00053 
00054 TCamacCrateController::TCamacCrateController( const TCamacCrateController& right )
00055   : TModule( right ),
00056     theCrateControllerType( right.theCrateControllerType ), 
00057     theCrateID( -1 ), theFileDescriptor( -1 ),
00058     theISA7000( Tfalse )
00059 {
00060   const Tstring head = "TCamacCrateController::TCamacCrateController";
00061   
00062   // open device file
00063   if ( !IsOpen() )
00064     Open();
00065   if ( theFileDescriptor < 0 ) {
00066     perror( head.c_str() );
00067     exit( theStatus );
00068   }
00069 
00070   // check the power
00071   if ( !IsOnline() ) {
00072     perror( head.c_str() );
00073     exit( theStatus );
00074   }
00075 
00076   theISA7000 |= ( theCrateControllerType == tISAcc7000_1 );
00077   theISA7000 |= ( theCrateControllerType == tISAcc7000_2 );
00078   theISA7000 |= ( theCrateControllerType == tISAcc7000_3 );
00079   theISA7000 |= ( theCrateControllerType == tISAcc7000_4 );
00080 
00081   theStatus = tStatusSuccess;
00082 }
00083 
00084 const TCamacCrateController& TCamacCrateController::operator=( const TCamacCrateController& right )
00085 {
00086   const Tstring head = "TCamacCrateController::operator=";
00087 
00088   *( (TModule*)this ) = *( (TModule*)(&right) );
00089 
00090   theCrateControllerType = right.theCrateControllerType;
00091   theCrateID = -1;
00092   theFileDescriptor = -1;
00093   theStatus = -1;
00094   theISA7000 = Tfalse;
00095 
00096   // open device file
00097   if ( !IsOpen() )
00098     Open();
00099   if ( theFileDescriptor < 0 ) {
00100     perror( head.c_str() );
00101     exit( theStatus );
00102   }
00103 
00104   // check the power
00105   if ( !IsOnline() ) {
00106     perror( head.c_str() );
00107     exit( theStatus );
00108   }
00109 
00110   theISA7000 |= ( theCrateControllerType == tISAcc7000_1 );
00111   theISA7000 |= ( theCrateControllerType == tISAcc7000_2 );
00112   theISA7000 |= ( theCrateControllerType == tISAcc7000_3 );
00113   theISA7000 |= ( theCrateControllerType == tISAcc7000_4 );
00114 
00115   theStatus = tStatusSuccess;
00116   return *this;
00117 }
00118 
00119 Tbool TCamacCrateController::operator==( const TCamacCrateController& right ) const
00120 {
00121   Tbool ret = Ttrue;
00122   ret &= ( *( (TModule*)this ) == *( (TModule*)(&right) ) );
00123   ret &= ( theCrateControllerType == right.theCrateControllerType );
00124   ret &= ( theCrateID == right.theCrateID );
00125   ret &= ( theISA7000 == right.theISA7000 );
00126   return ret;
00127 }
00128 
00129 Tbool TCamacCrateController::operator!=( const TCamacCrateController& right ) const
00130 {
00131   Tbool ret = Tfalse;
00132   ret |= ( *( (TModule*)this ) != *( (TModule*)(&right) ) );
00133   ret |= ( theCrateControllerType != right.theCrateControllerType );
00134   ret |= ( theCrateID != right.theCrateID );
00135   ret |= ( theISA7000 != right.theISA7000 );
00136   return ret;
00137 }
00138 
00139 TCamacCrateController::~TCamacCrateController()
00140 {
00141   if ( IsOpen() )
00142     Close();
00143 }
00144 
00145 Tvoid TCamacCrateController::Open()
00146 {
00147   errno ^= errno;
00148   theFileDescriptor =
00149     open( ( TcamacDevices[ theCrateControllerType ] ).c_str(), O_RDWR );
00150   theStatus = -errno;
00151   return;
00152 }
00153 
00154 Tvoid TCamacCrateController::Close()
00155 {
00156   errno ^= errno;
00157   close( theFileDescriptor );
00158   theFileDescriptor = -1;
00159   theStatus = -errno;
00160   return;
00161 }
00162 
00163 Tbool TCamacCrateController::IsOpen()
00164 {
00165   if ( theFileDescriptor < 0 )
00166     return Tfalse;
00167   return Ttrue;
00168 }
00169 
00170 Tbool TCamacCrateController::IsOnline()
00171 {
00172   errno ^= errno;
00173   Tint retval = ioctl( theFileDescriptor, IOC_TEST_ONLINE );
00174   theStatus = -errno;
00175   if ( retval < 0 )
00176     return Tfalse;
00177   return Ttrue;
00178 }
00179 
00180 Tint TCamacCrateController::Reset()
00181 {
00182   errno ^= errno;
00183   ioctl( theFileDescriptor, IOC_RESET_CRATE );
00184   return theStatus = -errno;
00185 }
00186 
00187 Tint TCamacCrateController::Initialize()
00188 {
00189   errno ^= errno;
00190   ioctl( theFileDescriptor, IOC_SET_Z );
00191   return theStatus = -errno;
00192 }
00193 
00194 Tint TCamacCrateController::Clear()
00195 {
00196   errno ^= errno;
00197   ioctl( theFileDescriptor, IOC_SET_C );
00198   return theStatus = -errno;
00199 }
00200 
00201 Tint TCamacCrateController::Update()
00202 {
00203   return Clear();
00204 }
00205 
00206 Tvoid TCamacCrateController::FillData( TDataElement& element, Tint channel )
00207 {
00208   // nothing to do.
00209   return;
00210 }
00211 
00212 Tint TCamacCrateController::SetInhibition()
00213 {
00214   errno ^= errno;
00215   ioctl( theFileDescriptor, IOC_SET_I );
00216   return theStatus = -errno;
00217 }
00218 
00219 Tint TCamacCrateController::ReleaseInhibition()
00220 {
00221   errno ^= errno;
00222   ioctl( theFileDescriptor, IOC_RESET_I );
00223   return theStatus = -errno;
00224 }
00225 
00226 Tint TCamacCrateController::EnableInterrupt()
00227 {
00228   errno ^= errno;
00229   ioctl( theFileDescriptor, IOC_SET_EI );
00230   return theStatus = -errno;
00231 }
00232 
00233 Tint TCamacCrateController::DisableInterrupt()
00234 {
00235   errno ^= errno;
00236   ioctl( theFileDescriptor, IOC_RESET_EI );
00237   return theStatus = -errno;
00238 }
00239 
00240 Tvoid TCamacCrateController::SetCrateID( Tint crateid )
00241 {
00242   errno ^= errno;
00243   ioctl( theFileDescriptor, IOC_SET_CN, crateid );
00244   theStatus = -errno;
00245   return;
00246 }
00247 
00248 Tvoid TCamacCrateController::SetCrateControllerType( TcamacCrateController_t type )
00249 {
00250   theCrateControllerType = type;
00251   theISA7000 = Tfalse;
00252   theISA7000 |= ( theCrateControllerType == tISAcc7000_1 );
00253   theISA7000 |= ( theCrateControllerType == tISAcc7000_2 );
00254   theISA7000 |= ( theCrateControllerType == tISAcc7000_3 );
00255   theISA7000 |= ( theCrateControllerType == tISAcc7000_4 );
00256   return;
00257 }
00258 
00259 #ifdef __CLDAQ_ROOT_DLL
00260     ClassImp(TCamacCrateController)
00261 #endif


CLDAQ - a Class Library for DataAcQuisition (Version 1.14.3)
Go IWAI -- goiwai at users.sourceforge.jp