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

TRs232cModule.hh

解説を見る。
00001 // =====================================================================
00028 // =====================================================================
00029 #ifndef CLDAQ__TRS232CMODULE_HH
00030 #define CLDAQ__TRS232CMODULE_HH
00031 
00032 #include "Tglobals.h"
00033 #include "TModule.hh"
00034 
00035 class TDataElement;
00036 
00037 
00057 class TRs232cModule
00058   : public TModule
00059 {
00060 
00061   protected:
00062     Tint theFileDescriptor;
00063     Tstring theDeviceFile;
00064     struct termio theSerialPort;
00065 
00066   public:
00067     TRs232cModule( const Tstring devfile = "/dev/ttyS0", Tint nchannel = 1 );
00068     TRs232cModule( Tint nchannel, Tstring devfile = "/dev/ttyS0" );
00069     TRs232cModule( const TRs232cModule& right );
00070 
00071   protected:
00072     virtual ~TRs232cModule();
00073 
00074   public:
00075     virtual const TRs232cModule& operator=( const TRs232cModule& right );
00076     virtual Tbool operator==( const TRs232cModule& right ) const;
00077     virtual Tbool operator!=( const TRs232cModule& right ) const;
00078 
00079   public:
00080     virtual Tint Clear();
00081     virtual Tint Update();
00082     virtual Tint Initialize();
00083     virtual Tvoid FillData( TDataElement& element, Tint channel );
00084 
00085   public:
00086     Tvoid DoClearMethod( Tint channel );
00087     Tvoid DoUpdateMethod( Tint channel );
00088     Tvoid DoInitializeMethod( Tint channel );
00089     Tstring DoReadMethod( Tint channel );
00090 
00091   protected:
00092     virtual Tvoid defineClearMethod( Tint channel ) = 0;
00093     virtual Tvoid defineUpdateMethod( Tint channel ) = 0;
00094     virtual Tvoid defineInitializeMethod( Tint channel ) = 0;
00095     virtual Tvoid defineReadMethod( Tint channel ) = 0;
00096     virtual Tbool modifyData( const Tstring& accept, Tdouble& databuf ) const;
00097 
00098   public:
00099     Tint Open();
00100     Tstring Read();
00101     Tint Write( const Tstring& token );
00102     Tint Close();
00103 
00104   public:
00105     Tbool IsOpen() const;
00106     Tint GetFileDescriptor() const;
00107     const Tstring& GetDeviceFile() const;
00108     Tvoid SetFileDescriptor( Tint fd );
00109     Tvoid SetDeviceFile( const Tstring& devfile );
00110     const struct termio& GetSerialPort() const;
00111     struct termio& GetSerialPort();
00112     Tvoid SetSerialPort( const struct termio& serial );
00113 
00114 #ifdef __CLDAQ_ROOT_DLL
00115     ClassDef(TRs232cModule,0)
00116 #endif
00117 
00118 };
00119 
00120 inline Tbool TRs232cModule::IsOpen() const
00121 {
00122   if ( theFileDescriptor != -1 ) {
00123     return Ttrue;
00124   } else {
00125     return Tfalse;
00126   }
00127 }
00128 
00129 inline Tint TRs232cModule::GetFileDescriptor() const
00130 {
00131   return theFileDescriptor;
00132 }
00133 
00134 inline const Tstring& TRs232cModule::GetDeviceFile() const
00135 {
00136   return theDeviceFile;
00137 }
00138 
00139 inline Tvoid TRs232cModule::SetFileDescriptor( Tint fd )
00140 {
00141   theFileDescriptor = fd;
00142   return;
00143 }
00144 
00145 inline Tvoid TRs232cModule::SetDeviceFile( const Tstring& devfile )
00146 {
00147   theDeviceFile = devfile;
00148   return;
00149 }
00150 
00151 inline const struct termio& TRs232cModule::GetSerialPort() const
00152 {
00153   return theSerialPort;
00154 }
00155 
00156 inline struct termio& TRs232cModule::GetSerialPort()
00157 {
00158   return theSerialPort;
00159 }
00160 
00161 inline Tvoid TRs232cModule::SetSerialPort( const struct termio& serial )
00162 {
00163   theSerialPort = serial;
00164   return;
00165 }
00166 
00167 inline Tvoid TRs232cModule::DoClearMethod( Tint channel )
00168 {
00169   defineClearMethod( channel );
00170   return;
00171 }
00172 
00173 inline Tvoid TRs232cModule::DoUpdateMethod( Tint channel )
00174 {
00175   defineUpdateMethod( channel );
00176   return;
00177 }
00178 
00179 inline Tvoid TRs232cModule::DoInitializeMethod( Tint channel )
00180 {
00181   defineInitializeMethod( channel );
00182   return;
00183 }
00184 
00185 inline Tstring TRs232cModule::DoReadMethod( Tint channel )
00186 {
00187   defineReadMethod( channel );
00188   return Read();
00189 }
00190 
00191 inline Tbool TRs232cModule::modifyData( const Tstring& accept, Tdouble& databuf ) const
00192 {
00193   return Tfalse;
00194 }
00195 
00196 #endif

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