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

TSoftwareScalerModule.hh

解説を見る。
00001 // =====================================================================
00002 //  $Id: TSoftwareScalerModule.hh,v 1.2 2003/07/30 16:19:11 goiwai Exp $
00003 //  $Name: CLDAQ-1-08-02 $
00004 //
00005 //  $Log: TSoftwareScalerModule.hh,v $
00006 //  Revision 1.2  2003/07/30 16:19:11  goiwai
00007 //  ファイルにコミットログをつけることにしました.
00008 //
00009 // =====================================================================
00010 #ifndef __TSOFTWARESCALERMODULE_HH
00011 #define __TSOFTWARESCALERMODULE_HH
00012 
00013 #include "Tglobals.h"
00014 #include "TSoftwareModule.hh"
00015 #include "TChannel.hh"
00016 
00017 class TDataSegment;
00018 class TDataElement;
00019 
00020 class TSoftwareScalerModule
00021   : public TSoftwareModule
00022 {
00023 
00024   protected:
00025     enum { tDefaultChannel = 8 };
00026 
00027   protected:
00028     TChannel theChannel;
00029 
00030   public:
00031     TSoftwareScalerModule( Tint nchannel = tDefaultChannel );
00032     TSoftwareScalerModule( const TSoftwareScalerModule& right );
00033     virtual ~TSoftwareScalerModule();
00034 
00035   public:
00036     virtual Tint Clear();
00037     virtual Tint Update();
00038     virtual Tint Initialize();
00039     virtual Tvoid FillData( TDataElement& element, Tint channel );
00040 
00041   public:
00042     virtual Tint Increase( Tint channel );
00043     virtual Tint Increase();
00044     virtual Tint Decrease( Tint channel );
00045     virtual Tint Decrease();
00046     virtual Tint GetData( Tint channel ) const;
00047     virtual Tvoid SetData( Tint channel, Tint data );
00048 
00049   public:
00050     virtual const TSoftwareScalerModule& operator=( const TSoftwareScalerModule& right );
00051     virtual Tbool operator==( const TSoftwareScalerModule& right ) const;
00052     virtual Tbool operator!=( const TSoftwareScalerModule& right ) const;
00053 
00054   public:
00055     virtual const TChannel& GetChannel() const;
00056     virtual Tvoid SetChannel( const TChannel& channels );
00057 
00058 };
00059 
00060 inline Tint TSoftwareScalerModule::GetData( Tint channel ) const
00061 {
00062   if ( channel < 0 || channel >= theNumberOfChannels ) {
00063     Tcerr << "TSoftwareScalerModule::GetData: invalid ID" << Tendl;
00064     return( -EFAULT );
00065   } else {
00066     return( theChannel[ channel ] );
00067   }
00068 }
00069 
00070 inline Tvoid TSoftwareScalerModule::SetData( Tint channel, Tint data )
00071 {
00072   if ( channel < 0 || channel >= theNumberOfChannels ) {
00073     Tcerr << "TSoftwareScalerModule::SetData: invalid ID" << Tendl;
00074     return;
00075   } else {
00076     theChannel[ channel ] = data;
00077     return;
00078   }
00079 }
00080 
00081 inline const TChannel& TSoftwareScalerModule::GetChannel() const
00082 {
00083   return( theChannel );
00084 }
00085 
00086 inline Tvoid TSoftwareScalerModule::SetChannel( const TChannel& channels )
00087 {
00088   theChannel = channels;
00089   return;
00090 }
00091 
00092 inline Tint TSoftwareScalerModule::Increase( Tint channel )
00093 {
00094   if ( channel < 0 || channel >= theNumberOfChannels ) {
00095     Tcerr << "TSoftwareScalerModule::Increase: invalid ID" << Tendl;
00096     return( theStatus = -EFAULT );
00097   } else {
00098     Tint data = GetData( channel );
00099     SetData( channel, ++ data );
00100     return( theStatus = tStatusSuccess );
00101   }
00102 }
00103 
00104 inline Tint TSoftwareScalerModule::Decrease( Tint channel )
00105 {
00106   if ( channel < 0 || channel >= theNumberOfChannels ) {
00107     Tcerr << "TSoftwareScalerModule::Decrease: invalid ID" << Tendl;
00108     return( theStatus = -EFAULT );
00109   } else {
00110     Tint data = GetData( channel );
00111     SetData( channel, -- data );
00112     return( theStatus = tStatusSuccess );
00113   }
00114 }
00115 
00116 inline Tint TSoftwareScalerModule::Increase()
00117 {
00118   Tint ret = tStatusSuccess;
00119   for ( Tint i = 0; i < theNumberOfChannels; i ++ )
00120     ret &= Increase( i );
00121   return( ret );
00122 }
00123 
00124 inline Tint TSoftwareScalerModule::Decrease()
00125 {
00126   Tint ret = tStatusSuccess;
00127   for ( Tint i = 0; i < theNumberOfChannels; i ++ )
00128     ret &= Decrease( i );
00129   return( ret );
00130 }
00131 
00132 inline Tint TSoftwareScalerModule::Clear()
00133 {
00134   for ( Tint i = 0; i < theNumberOfChannels; i ++ )
00135     theChannel[ i ] = 0;
00136   return( theStatus = tStatusSuccess );
00137 }
00138 
00139 inline Tint TSoftwareScalerModule::Update()
00140 {
00141   return( Increase() );
00142 }
00143 
00144 inline Tint TSoftwareScalerModule::Initialize()
00145 {
00146   return( Clear() );
00147 }
00148 
00149 #endif

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