fbio.h

Go to the documentation of this file.
00001 #ifndef __FBIO_H__
00002 #define __FBIO_H__
00003 /**************************************************************************
00004  Copyright (c) 1994 - 2009 Autodesk, Inc. and/or its licensors.
00005  All Rights Reserved.
00006  
00007  The coded instructions, statements, computer programs, and/or related 
00008  material (collectively the "Data") in these files contain unpublished 
00009  information proprietary to Autodesk, Inc. and/or its licensors, which is 
00010  protected by Canada and United States of America federal copyright law 
00011  and by international treaties.
00012  
00013  The Data may not be disclosed or distributed to third parties, in whole 
00014  or in part, without the prior written consent of Autodesk, Inc. 
00015  ("Autodesk").
00016  
00017  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00018  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO 
00019  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR 
00020  ARISING BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES 
00021  OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR 
00022  PURPOSE OR USE. WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT 
00023  WARRANT THAT THE OPERATION OF THE DATA WILL BE UNINTERRUPTED OR ERROR 
00024  FREE.
00025  
00026  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS 
00027  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR 
00028  EXPENSES OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE 
00029  DAMAGES OR OTHER SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS 
00030  OF PROFITS, REVENUE OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR 
00031  DAMAGES OF ANY KIND), HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF 
00032  LIABILITY, WHETHER DERIVED FROM CONTRACT, TORT (INCLUDING, BUT NOT 
00033  LIMITED TO, NEGLIGENCE), OR OTHERWISE, ARISING OUT OF OR RELATING TO THE 
00034  DATA OR ITS USE OR ANY OTHER PERFORMANCE, WHETHER OR NOT AUTODESK HAS 
00035  BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
00036  
00037 **************************************************************************/
00038 
00044 #include <kaydaradef.h>
00045 #ifndef FBSDK_DLL 
00046 
00049     #define FBSDK_DLL K_DLLIMPORT
00050 #endif
00051 
00052 #include <fbsdk/fbcomponent.h>
00053 
00054 #ifdef FBSDKUseNamespace
00055     namespace FBSDKNamespace {
00056 #endif
00057 
00059 // FBCommPort
00062 #define FBCOMMPORT_DEFAULT_BLOCKING_TIMEOUT 500  // Millisecs
00063 
00065 enum FBParity   { 
00066     kFBParityNone,  
00067     kFBParityOdd,   
00068     kFBParityEven   
00069 };
00070 
00072 enum FBRSType {
00073     kFBRS232,       
00074     kFBRS422        
00075 };
00077 enum FBCommPortType { 
00078     kFBPhysical,    
00079     kFBVirtual,     
00080     kFBInternal     
00081 };
00082 
00083 
00084 FB_DEFINE_ENUM      ( FBSDK_DLL, Parity     );
00085 FB_DEFINE_ENUM      ( FBSDK_DLL, RSType     );
00086 FB_DEFINE_ENUM      ( FBSDK_DLL, CommPortType   );
00087 FB_DEFINE_COMPONENT ( FBSDK_DLL, CommPort   );
00088 
00089 __FB_FORWARD( FBCommPort );
00090 
00092 class FBSDK_DLL FBCommPort : public FBComponent {
00093     __FBClassDeclare( FBCommPort,FBComponent );
00094 public:
00095 
00097     FBCommPort();
00098 
00105     bool Read( void* lpBuffer, int nNumberOfBytesToRead, int* lpNumberOfBytesRead=NULL );
00106 
00115     bool ReadBlocking( void* lpBuffer, int nNumberOfBytesToRead, int* lpNumberOfBytesRead=NULL, kULong pTimeOut = FBCOMMPORT_DEFAULT_BLOCKING_TIMEOUT);
00116 
00123     bool Write( void* lpBuffer, int nNumberOfBytesToWrite, int *lpNumberOfBytesWritten=NULL );
00124 
00133     bool WriteBlocking( void* lpBuffer, int nNumberOfBytesToWrite, int* lpNumberOfBytesWritten=NULL, kULong pTimeOut = FBCOMMPORT_DEFAULT_BLOCKING_TIMEOUT);
00134 
00138     bool EmptyBuffer();
00139 
00140     FBPropertyInt       PortNumber;         
00141     FBPropertyString    OwnerName;          
00142     FBPropertyInt       BaudRate;           
00143     FBPropertyBool      UseHardwareFC;      
00144 
00145     FBPropertyParity    Parity;             
00146     FBPropertyInt       ByteSize;           
00147     FBPropertyInt       StopBits;           
00148     FBPropertyRSType    RSType;             
00149     FBPropertyCommPortType  CommPortType;       
00150 
00151     FBPropertyBool      Active;             
00152 };
00153 
00155 // Property list Comm Port
00157 __FB_FORWARD( FBPropertyListCommPort );
00159 typedef class FBSDK_DLL FBPropertyBaseList< int > FBPropertyBaseListInt;
00160 
00162 class FBSDK_DLL FBPropertyListCommPort : public FBPropertyBaseList< int >
00163 {
00164 public:
00169     virtual int  Add    ( int pItem );
00174     virtual int  Remove ( int pItem );
00178     virtual void RemoveAt( int pIndex );
00183     virtual int operator[](int pIndex);
00187     virtual int  GetCount();
00188 };
00189 
00191 // FBTCPIP
00194 #define FBTCPIP_DEFAULT_BLOCKING_TIMEOUT 500  // Millisecs
00195 
00197 enum FBTCPIPSocketType { 
00198     kFBTCPIP_Stream,    
00199     kFBTCPIP_DGRAM,     
00200     kFBTCPIP_RAW        
00201 };
00202 
00203 __FB_FORWARD( FBTCPIP );
00204 
00206 class FBSDK_DLL FBTCPIP : public FBComponent {
00207     __FBClassDeclare( FBTCPIP,FBComponent );
00208 public:
00210     FBTCPIP();
00211 
00219     bool Read( int pSocket, void* lpBuffer, int nNumberOfBytesToRead, int* lpNumberOfBytesRead=NULL );
00220 
00230     bool ReadBlocking( int pSocket, void* lpBuffer, int nNumberOfBytesToRead, int* lpNumberOfBytesRead=NULL, kULong pTimeOut = FBTCPIP_DEFAULT_BLOCKING_TIMEOUT );
00231 
00241     bool ReadDatagram( int pSocket, void* lpBuffer, int nNumberOfBytesToRead, int* lpNumberOfBytesRead=NULL, kULong* pAddr=NULL, unsigned short *pPort=NULL );
00242 
00250     bool Write( int pSocket, void* lpBuffer, int nNumberOfBytesToWrite, int* lpNumberOfBytesWritten=NULL );
00251 
00261     bool WriteBlocking( int pSocket, void* lpBuffer, int nNumberOfBytesToWrite, int* lpNumberOfBytesToWrite=NULL, kULong pTimeOut = FBTCPIP_DEFAULT_BLOCKING_TIMEOUT );
00262 
00272     bool WriteDatagram( int pSocket, void* lpBuffer, int nNumberOfBytesToWrite, int* lpNumberOfBytesToWrite, kULong pAddr, unsigned short pPort );
00273 
00281     bool CreateSocket( int &pSocket, FBTCPIPSocketType pType, char *pProtocol = "ip", bool pNonBlocking=true );
00282 
00289     bool Bind( int &pSocket, kULong pAddr /*=INADDR_ANY*/, int pPort=0 );
00290 
00297     bool Connect( int &pSocket, char *pAddr, int pPort );
00298 
00303     bool CloseSocket( int &pSocket );
00304 
00310     int  Listen( int pSocket, int pBackLog=1 );
00311 
00317     int  Accept( int pSocket, kULong *pOutAddr=NULL );
00318 
00327     int  Select( int pSocket, bool pTestRead, bool pTestWrite, bool pTestError, kULong pTimeOutMilisecond=0 );
00328 };
00329 
00330 #ifdef FBSDKUseNamespace
00331     }
00332 #endif
00333 
00334 
00335 #endif