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

TSoftwareScalerModule.hh

解説を見る。
00001 // =====================================================================
00028 // =====================================================================
00029 #ifndef CLDAQ__TSOFTWARESCALERMODULE_HH
00030 #define CLDAQ__TSOFTWARESCALERMODULE_HH
00031 
00032 #include "Tglobals.h"
00033 #include "TSoftwareModule.hh"
00034 #include "TChannel.hh"
00035 
00036 class TDataSegment;
00037 class TDataElement;
00038 
00039 
00059 class TSoftwareScalerModule
00060   : public TSoftwareModule
00061 {
00062 
00063   protected:
00064     enum { tDefaultChannel = 8 };
00065 
00066   protected:
00067     TChannel theChannel;
00068 
00069   public:
00070     TSoftwareScalerModule( Tint nchannel = tDefaultChannel );
00071     TSoftwareScalerModule( const TSoftwareScalerModule& right );
00072     virtual ~TSoftwareScalerModule();
00073 
00074   public:
00075     virtual Tint Clear();
00076     virtual Tint Update();
00077     virtual Tint Initialize();
00078     virtual Tvoid FillData( TDataElement& element, Tint channel );
00079 
00080   public:
00081     virtual Tint Increase( Tint channel );
00082     virtual Tint Increase();
00083     virtual Tint Decrease( Tint channel );
00084     virtual Tint Decrease();
00085     virtual Tint GetData( Tint channel ) const;
00086     virtual Tvoid SetData( Tint channel, Tint data );
00087 
00088   public:
00089     virtual const TSoftwareScalerModule& operator=( const TSoftwareScalerModule& right );
00090     virtual Tbool operator==( const TSoftwareScalerModule& right ) const;
00091     virtual Tbool operator!=( const TSoftwareScalerModule& right ) const;
00092 
00093   public:
00094     virtual const TChannel& GetChannel() const;
00095     virtual Tvoid SetChannel( const TChannel& channels );
00096 
00097 #ifdef __CLDAQ_ROOT_DLL
00098     ClassDef(TSoftwareScalerModule,0)
00099 #endif
00100 
00101 };
00102 
00103 inline Tint TSoftwareScalerModule::GetData( Tint channel ) const
00104 {
00105   if ( channel < 0 || channel >= theNumberOfChannels ) {
00106     Tcerr << "TSoftwareScalerModule::GetData: invalid ID" << Tendl;
00107     return -EFAULT;
00108   } else {
00109     return theChannel[ channel ];
00110   }
00111 }
00112 
00113 inline Tvoid TSoftwareScalerModule::SetData( Tint channel, Tint data )
00114 {
00115   if ( channel < 0 || channel >= theNumberOfChannels ) {
00116     Tcerr << "TSoftwareScalerModule::SetData: invalid ID" << Tendl;
00117     return;
00118   } else {
00119     theChannel[ channel ] = data;
00120     return;
00121   }
00122 }
00123 
00124 inline const TChannel& TSoftwareScalerModule::GetChannel() const
00125 {
00126   return theChannel;
00127 }
00128 
00129 inline Tvoid TSoftwareScalerModule::SetChannel( const TChannel& channels )
00130 {
00131   theChannel = channels;
00132   return;
00133 }
00134 
00135 inline Tint TSoftwareScalerModule::Increase( Tint channel )
00136 {
00137   if ( channel < 0 || channel >= theNumberOfChannels ) {
00138     Tcerr << "TSoftwareScalerModule::Increase: invalid ID" << Tendl;
00139     return theStatus = -EFAULT;
00140   } else {
00141     Tint data = GetData( channel );
00142     SetData( channel, ++ data );
00143     return theStatus = tStatusSuccess;
00144   }
00145 }
00146 
00147 inline Tint TSoftwareScalerModule::Decrease( Tint channel )
00148 {
00149   if ( channel < 0 || channel >= theNumberOfChannels ) {
00150     Tcerr << "TSoftwareScalerModule::Decrease: invalid ID" << Tendl;
00151     return theStatus = -EFAULT;
00152   } else {
00153     Tint data = GetData( channel );
00154     SetData( channel, -- data );
00155     return theStatus = tStatusSuccess;
00156   }
00157 }
00158 
00159 inline Tint TSoftwareScalerModule::Increase()
00160 {
00161   Tint ret = tStatusSuccess;
00162   for ( Tint i = 0; i < theNumberOfChannels; i ++ )
00163     ret &= Increase( i );
00164   return ret;
00165 }
00166 
00167 inline Tint TSoftwareScalerModule::Decrease()
00168 {
00169   Tint ret = tStatusSuccess;
00170   for ( Tint i = 0; i < theNumberOfChannels; i ++ )
00171     ret &= Decrease( i );
00172   return ret;
00173 }
00174 
00175 inline Tint TSoftwareScalerModule::Clear()
00176 {
00177   for ( Tint i = 0; i < theNumberOfChannels; i ++ )
00178     theChannel[ i ] = 0;
00179   return theStatus = tStatusSuccess;
00180 }
00181 
00182 inline Tint TSoftwareScalerModule::Update()
00183 {
00184   return Increase();
00185 }
00186 
00187 inline Tint TSoftwareScalerModule::Initialize()
00188 {
00189   return Clear();
00190 }
00191 
00192 #endif

CLDAQ - a Class Library for Data AcQuisition (Version 1.13.0)
Go IWAI <goiwai@users.sourceforge.jp>