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

TVmeDaughterBoardMemoryModule.cc

解説を見る。
00001 // =====================================================================
00002 //  $Id: TVmeDaughterBoardMemoryModule.cc,v 1.6 2004/03/07 10:30:31 goiwai Exp $
00003 //  $Name: CLDAQ-1-14-03 $
00004 //  $Log: TVmeDaughterBoardMemoryModule.cc,v $
00005 //  Revision 1.6  2004/03/07 10:30:31  goiwai
00006 //  ROOTに組みこむためのおまじないマクロを埋めこみました。
00007 //  全てにおいて完全に動作するわけではありません。
00008 //
00009 //  Revision 1.5  2003/11/04 20:25:20  goiwai
00010 //  コメントうっておきました
00011 //
00012 //  Revision 1.4  2003/11/04 17:02:37  goiwai
00013 //  コメントをうっておきました
00014 //
00015 //  Revision 1.3  2003/10/06 17:02:40  goiwai
00016 //  *** empty log message ***
00017 //
00018 //  Revision 1.2  2003/07/30 16:19:12  goiwai
00019 //  ファイルにコミットログをつけることにしました.
00020 //
00021 // =====================================================================
00022 #include "TVmeDaughterBoardMemoryModule.hh"
00023 #include "TVmeMpx201aModule.hh"
00024 #include "TDataSegment.hh"
00025 #include "TDataElement.hh"
00026 
00027 TVmeDaughterBoardMemoryModule::TVmeDaughterBoardMemoryModule( Toff_t offset, Tint mapsize, Tint nblock, Tint nch )
00028   : TVmeModule( nch, offset, mapsize, tA32D32 ),
00029     theNumberOfSampling( nblock * TVmeMpx201aModule::tBlock )
00030 {;}
00031 
00032 TVmeDaughterBoardMemoryModule::TVmeDaughterBoardMemoryModule( const TVmeMpx201aModule* mpx201a, Tint nch )
00033   : TVmeModule( nch, mpx201a->GetOffsetAddressForDaughterBoard(), mpx201a->GetMappingSizeOfDaughterBoard(), tA32D32 ),
00034     theNumberOfSampling( mpx201a->GetNumberOfBlock() * TVmeMpx201aModule::tBlock )
00035 {;}
00036 
00037 TVmeDaughterBoardMemoryModule::TVmeDaughterBoardMemoryModule( const TVmeDaughterBoardMemoryModule& right )
00038   : TVmeModule( right ),
00039     theNumberOfSampling( right.theNumberOfSampling )
00040 {;}
00041 
00042 TVmeDaughterBoardMemoryModule::~TVmeDaughterBoardMemoryModule()
00043 {;}
00044 
00045 const TVmeDaughterBoardMemoryModule& TVmeDaughterBoardMemoryModule::operator=( const TVmeDaughterBoardMemoryModule& right )
00046 {
00047   *( (TVmeModule*)this ) = *( (TVmeModule*)(&right) );
00048   theNumberOfSampling = right.theNumberOfSampling;
00049   return *this;
00050 }
00051 
00052 Tbool TVmeDaughterBoardMemoryModule::operator==( const TVmeDaughterBoardMemoryModule& right ) const
00053 {
00054   Tbool ret = Ttrue;
00055   ret &= ( *( (TVmeModule*)this ) == *( (TVmeModule*)(&right) ) );
00056   ret &= ( theNumberOfSampling == right.theNumberOfSampling );
00057   return ret;
00058 }
00059 
00060 Tbool TVmeDaughterBoardMemoryModule::operator!=( const TVmeDaughterBoardMemoryModule& right ) const
00061 {
00062   Tbool ret = Tfalse;
00063   ret |= ( *( (TVmeModule*)this ) != *( (TVmeModule*)(&right) ) );
00064   ret |= ( theNumberOfSampling != right.theNumberOfSampling );
00065   return ret;
00066 }
00067 
00068 Tint TVmeDaughterBoardMemoryModule::Clear()
00069 {
00070   Tlong* membase = (Tlong*)theBaseAddress;
00071 
00072   Tint nsample = theNumberOfSampling / 2;
00073 
00074   for ( Tint i = 0; i < nsample; i ++ ) {
00075     membase[ i ] = 0x0000;
00076   }
00077   return theStatus = tStatusSuccess;
00078 }
00079 
00080 Tint TVmeDaughterBoardMemoryModule::Update()
00081 {
00082   return Clear();
00083 }
00084 
00085 Tint TVmeDaughterBoardMemoryModule::Initialize()
00086 {
00087   return Clear();
00088 }
00089 
00090 Tvoid TVmeDaughterBoardMemoryModule::FillData( TDataElement& element, Tint channel )
00091 {
00092   if ( channel < 0 || channel >= theNumberOfChannels ) {
00093     Tcerr << "TVmeDaughterBoardMemoryModule::FillData: invalid ID " << channel << Tendl;
00094     theStatus = -EFAULT;
00095     element.FillData( &theStatus, tTypeInt, 1 );
00096   } else {
00097     // 人間はすぐ忘れるのでメモしておきましょ
00098     // テストした環境
00099     // Pentium III(450MHz)が2個のった
00100     // Redhat8くらいでカーネルは Linux-2.4.20smp
00101     //
00102     // たとえば FADC を 16サンプリングに1回にAD変換するようにすると
00103     // 0から数えて
00104     // 15と31でADはされているようだ
00105     // ただし,15は読むことができない31は読める
00106     //
00107     // enum { tDataUnderflow = SHRT_MIN, tDataOverflow = SHRT_MAX };
00108     // データバッファは 16bit だけど
00109     // 読みだす対象のメモリは 32bit ずつインクリメントする
00110     // 32bitのデータは (& 0x0000fff0) されて
00111     // 0〜31bit のうち 4〜11bit目をあつかう
00112     // これが 0x7ff0 なら オーバーフロー 32767
00113     // 0x8000 なら アンダーフロー -32768
00114 
00115     // direct access, processing speed improve.
00116     Tlong* membase = (Tlong*)theBaseAddress;
00117 
00118     const Tint nsample = theNumberOfSampling / 2;
00119     Tshort* databuf = new Tshort[ nsample ];
00120     for ( Tint i = 0; i < nsample; i ++ ) {
00121       databuf[ i ] = modifyData( membase[ i ] );
00122     }
00123     element.FillData( databuf, tTypeShort, nsample );
00124     delete [] databuf;
00125   }
00126 
00127   return;
00128 }
00129 
00130 Tshort TVmeDaughterBoardMemoryModule::modifyData( Tlong databuf ) const
00131 {
00132   if ( ( databuf & 0x0000fff0 ) == 0x7ff0 ) {
00133     // overflow
00134     return tDataOverflow;
00135   } else if ( ( databuf & 0x0000fff0 ) == 0x8000 ) {
00136     // underflow
00137     return tDataUnderflow;
00138   }
00139  
00140   Tshort retval = (Tshort)( databuf & 0x0000fff0 );
00141   Tbit sign = ( retval & 0x8000 ) >> 15;
00142   if ( sign == 1 ) {
00143     // case of negative value
00144     retval &= 0x7ff0;
00145     retval = retval >> 4;
00146   } else if ( sign == 0 ) {
00147     // case of positive value
00148     retval = retval >> 4;
00149     retval += 0x0800;
00150   } else {
00151     Tcerr << "TVmeDaughterBoardMemoryModule::modifyData: failed." << Tendl;
00152   }
00153 
00154   return retval;
00155 }
00156 
00157 #ifdef __CLDAQ_ROOT_DLL
00158     ClassImp(TVmeDaughterBoardMemoryModule)
00159 #endif


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