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

TRs232cModule.hh

解説を見る。
00001 // =====================================================================
00002 //  $Id: TRs232cModule.hh,v 1.1.1.1 2003/06/27 02:56:41 goiwai Exp $
00003 //  $Name: CLDAQ-1-06-00 $
00004 // =====================================================================
00005 #ifndef __TRS232CMODULE_HH
00006 #define __TRS232CMODULE_HH
00007 
00008 #include "Tglobals.h"
00009 #include "TModule.hh"
00010 
00011 class TDataElement;
00012 
00013 class TRs232cModule
00014   : public TModule
00015 {
00016 
00017   protected:
00018     Tint theFileDescriptor;
00019     Tstring theDeviceFile;
00020     struct termio theSerialPort;
00021 
00022   public:
00023     TRs232cModule( const Tstring devfile = "/dev/ttyS0", Tint nchannel = 1 );
00024     TRs232cModule( Tint nchannel, Tstring devfile = "/dev/ttyS0" );
00025     TRs232cModule( const TRs232cModule& right );
00026 
00027   protected:
00028     virtual ~TRs232cModule();
00029 
00030   public:
00031     virtual const TRs232cModule& operator=( const TRs232cModule& right );
00032     virtual Tbool operator==( const TRs232cModule& right ) const;
00033     virtual Tbool operator!=( const TRs232cModule& right ) const;
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     Tvoid DoClearMethod( Tint channel );
00043     Tvoid DoUpdateMethod( Tint channel );
00044     Tvoid DoInitializeMethod( Tint channel );
00045     Tstring DoReadMethod( Tint channel );
00046 
00047   protected:
00048     virtual Tvoid defineClearMethod( Tint channel ) = 0;
00049     virtual Tvoid defineUpdateMethod( Tint channel ) = 0;
00050     virtual Tvoid defineInitializeMethod( Tint channel ) = 0;
00051     virtual Tvoid defineReadMethod( Tint channel ) = 0;
00052     virtual Tbool modifyData( const Tstring& accept, Tdouble& databuf ) const;
00053 
00054   public:
00055     Tint Open();
00056     Tstring Read();
00057     Tint Write( const Tstring& token );
00058     Tint Close();
00059 
00060   public:
00061     Tbool IsOpen() const;
00062     Tint GetFileDescriptor() const;
00063     const Tstring& GetDeviceFile() const;
00064     Tvoid SetFileDescriptor( Tint fd );
00065     Tvoid SetDeviceFile( const Tstring& devfile );
00066     const struct termio& GetSerialPort() const;
00067     struct termio& GetSerialPort();
00068     Tvoid SetSerialPort( const struct termio& serial );
00069 
00070 };
00071 
00072 inline Tbool TRs232cModule::IsOpen() const
00073 {
00074   if ( theFileDescriptor != -1 ) {
00075     return( Ttrue );
00076   } else {
00077     return( Tfalse );
00078   }
00079 }
00080 
00081 inline Tint TRs232cModule::GetFileDescriptor() const
00082 {
00083   return( theFileDescriptor );
00084 }
00085 
00086 inline const Tstring& TRs232cModule::GetDeviceFile() const
00087 {
00088   return( theDeviceFile );
00089 }
00090 
00091 inline Tvoid TRs232cModule::SetFileDescriptor( Tint fd )
00092 {
00093   theFileDescriptor = fd;
00094   return;
00095 }
00096 
00097 inline Tvoid TRs232cModule::SetDeviceFile( const Tstring& devfile )
00098 {
00099   theDeviceFile = devfile;
00100   return;
00101 }
00102 
00103 inline const struct termio& TRs232cModule::GetSerialPort() const
00104 {
00105   return( theSerialPort );
00106 }
00107 
00108 inline struct termio& TRs232cModule::GetSerialPort()
00109 {
00110   return( theSerialPort );
00111 }
00112 
00113 inline Tvoid TRs232cModule::SetSerialPort( const struct termio& serial )
00114 {
00115   theSerialPort = serial;
00116   return;
00117 }
00118 
00119 inline Tvoid TRs232cModule::DoClearMethod( Tint channel )
00120 {
00121   defineClearMethod( channel );
00122   return;
00123 }
00124 
00125 inline Tvoid TRs232cModule::DoUpdateMethod( Tint channel )
00126 {
00127   defineUpdateMethod( channel );
00128   return;
00129 }
00130 
00131 inline Tvoid TRs232cModule::DoInitializeMethod( Tint channel )
00132 {
00133   defineInitializeMethod( channel );
00134   return;
00135 }
00136 
00137 inline Tstring TRs232cModule::DoReadMethod( Tint channel )
00138 {
00139   defineReadMethod( channel );
00140   return( Read() );
00141 }
00142 
00143 inline Tbool TRs232cModule::modifyData( const Tstring& accept, Tdouble& databuf ) const
00144 {
00145   return( Tfalse );
00146 }
00147 
00148 #endif

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