Open Reality Reference Guide
fbio.h
Go to the documentation of this file.
1 #ifndef __FBIO_H__
2 #define __FBIO_H__
3 /**************************************************************************
4  Copyright (c) 1994 - 2009 Autodesk, Inc. and/or its licensors.
5  All Rights Reserved.
6 
7  The coded instructions, statements, computer programs, and/or related
8  material (collectively the "Data") in these files contain unpublished
9  information proprietary to Autodesk, Inc. and/or its licensors, which is
10  protected by Canada and United States of America federal copyright law
11  and by international treaties.
12 
13  The Data may not be disclosed or distributed to third parties, in whole
14  or in part, without the prior written consent of Autodesk, Inc.
15  ("Autodesk").
16 
17  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
18  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
19  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR
20  ARISING BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES
21  OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
22  PURPOSE OR USE. WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT
23  WARRANT THAT THE OPERATION OF THE DATA WILL BE UNINTERRUPTED OR ERROR
24  FREE.
25 
26  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
27  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR
28  EXPENSES OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE
29  DAMAGES OR OTHER SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS
30  OF PROFITS, REVENUE OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR
31  DAMAGES OF ANY KIND), HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF
32  LIABILITY, WHETHER DERIVED FROM CONTRACT, TORT (INCLUDING, BUT NOT
33  LIMITED TO, NEGLIGENCE), OR OTHERWISE, ARISING OUT OF OR RELATING TO THE
34  DATA OR ITS USE OR ANY OTHER PERFORMANCE, WHETHER OR NOT AUTODESK HAS
35  BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
36 
37 **************************************************************************/
38 
44 #include <kaydaradef.h>
45 #ifndef FBSDK_DLL
46 
49  #define FBSDK_DLL K_DLLIMPORT
50 #endif
51 
52 #include <fbsdk/fbcomponent.h>
53 
54 #ifdef FBSDKUseNamespace
55  namespace FBSDKNamespace {
56 #endif
57 
59 // FBCommPort
62 #define FBCOMMPORT_DEFAULT_BLOCKING_TIMEOUT 500 // Millisecs
63 
65 enum FBParity {
69 };
70 
72 enum FBRSType {
74  kFBRS422
75 };
81 };
82 
83 
84 FB_DEFINE_ENUM ( FBSDK_DLL, Parity );
85 FB_DEFINE_ENUM ( FBSDK_DLL, RSType );
86 FB_DEFINE_ENUM ( FBSDK_DLL, CommPortType );
87 FB_DEFINE_COMPONENT ( FBSDK_DLL, CommPort );
88 
90 
94 public:
95 
98 
105  bool Read( void* lpBuffer, int nNumberOfBytesToRead, int* lpNumberOfBytesRead=NULL );
106 
115  bool ReadBlocking( void* lpBuffer, int nNumberOfBytesToRead, int* lpNumberOfBytesRead=NULL, kULong pTimeOut = FBCOMMPORT_DEFAULT_BLOCKING_TIMEOUT);
116 
123  bool Write( void* lpBuffer, int nNumberOfBytesToWrite, int *lpNumberOfBytesWritten=NULL );
124 
133  bool WriteBlocking( void* lpBuffer, int nNumberOfBytesToWrite, int* lpNumberOfBytesWritten=NULL, kULong pTimeOut = FBCOMMPORT_DEFAULT_BLOCKING_TIMEOUT);
134 
138  bool EmptyBuffer();
139 
144 
145  FBPropertyParity Parity;
148  FBPropertyRSType RSType;
149  FBPropertyCommPortType CommPortType;
150 
152 };
153 
155 // Property list Comm Port
160 
163 {
164 public:
169  virtual int Add ( int pItem );
174  virtual int Remove ( int pItem );
178  virtual void RemoveAt( int pIndex );
183  virtual int operator[](int pIndex);
187  virtual int GetCount();
188 };
189 
191 // FBTCPIP
194 #define FBTCPIP_DEFAULT_BLOCKING_TIMEOUT 500 // Millisecs
195 
200  kFBTCPIP_RAW
201 };
202 
204 
206 class FBSDK_DLL FBTCPIP : public FBComponent {
208 public:
211 
219  bool Read( int pSocket, void* lpBuffer, int nNumberOfBytesToRead, int* lpNumberOfBytesRead=NULL );
220 
230  bool ReadBlocking( int pSocket, void* lpBuffer, int nNumberOfBytesToRead, int* lpNumberOfBytesRead=NULL, kULong pTimeOut = FBTCPIP_DEFAULT_BLOCKING_TIMEOUT );
231 
241  bool ReadDatagram( int pSocket, void* lpBuffer, int nNumberOfBytesToRead, int* lpNumberOfBytesRead=NULL, kULong* pAddr=NULL, unsigned short *pPort=NULL );
242 
250  bool Write( int pSocket, void* lpBuffer, int nNumberOfBytesToWrite, int* lpNumberOfBytesWritten=NULL );
251 
261  bool WriteBlocking( int pSocket, void* lpBuffer, int nNumberOfBytesToWrite, int* lpNumberOfBytesToWrite=NULL, kULong pTimeOut = FBTCPIP_DEFAULT_BLOCKING_TIMEOUT );
262 
272  bool WriteDatagram( int pSocket, void* lpBuffer, int nNumberOfBytesToWrite, int* lpNumberOfBytesToWrite, kULong pAddr, unsigned short pPort );
273 
281  bool CreateSocket( int &pSocket, FBTCPIPSocketType pType, const char *pProtocol = "ip", bool pNonBlocking=true );
282 
289  bool Bind( int &pSocket, kULong pAddr /*=INADDR_ANY*/, int pPort=0 );
290 
297  bool Connect( int &pSocket, char *pAddr, int pPort );
298 
303  bool CloseSocket( int &pSocket );
304 
310  int Listen( int pSocket, int pBackLog=1 );
311 
317  int Accept( int pSocket, kULong *pOutAddr=NULL );
318 
327  int Select( int pSocket, bool pTestRead, bool pTestWrite, bool pTestError, kULong pTimeOutMilisecond=0 );
328 };
329 
330 #ifdef FBSDKUseNamespace
331  }
332 #endif
333 
334 
335 #endif
FBPropertyListCommPort::operator[]
virtual int operator[](int pIndex)
Get the comm port at pIndex.
FBTCPIP::WriteDatagram
bool WriteDatagram(int pSocket, void *lpBuffer, int nNumberOfBytesToWrite, int *lpNumberOfBytesToWrite, kULong pAddr, unsigned short pPort)
Write a datagram to a network socket.
FBParity
FBParity
Parity modes.
Definition: fbio.h:65
FBTCPIP::ReadBlocking
bool ReadBlocking(int pSocket, void *lpBuffer, int nNumberOfBytesToRead, int *lpNumberOfBytesRead=NULL, kULong pTimeOut=500)
Read data from a network socket (blocking).
FBTCPIP::Bind
bool Bind(int &pSocket, kULong pAddr, int pPort=0)
Bind a socket to an address.
FBCommPort::FBCommPort
FBCommPort()
Constructor.
FB_DEFINE_ENUM
#define FB_DEFINE_ENUM(DllTag, Type)
Define an enum and give it the ability to be a property.
Definition: fbproperties.h:150
FBTCPIP::CloseSocket
bool CloseSocket(int &pSocket)
Close a network socket.
FBCommPort::OwnerName
FBPropertyString OwnerName
Property: Owner name.
Definition: fbio.h:141
kFBTCPIP_DGRAM
@ kFBTCPIP_DGRAM
Datagrams (UDP).
Definition: fbio.h:199
FBTCPIP_DEFAULT_BLOCKING_TIMEOUT
#define FBTCPIP_DEFAULT_BLOCKING_TIMEOUT
FBTCPIP_DEFAULT_BLOCKING_TIMEOUT define.
Definition: fbio.h:194
FBPropertyInt
class K_DLLIMPORT FBPropertyBase< int, kFBPT_int > FBPropertyInt
Property: int
Definition: fbproperties.h:1331
FBTCPIPSocketType
FBTCPIPSocketType
Types of TCP/IP Sockets.
Definition: fbio.h:197
FBTCPIP
TCP/IP class.
Definition: fbio.h:206
kFBVirtual
@ kFBVirtual
Virtual.
Definition: fbio.h:79
FBCommPort::ReadBlocking
bool ReadBlocking(void *lpBuffer, int nNumberOfBytesToRead, int *lpNumberOfBytesRead=NULL, kULong pTimeOut=500)
Read data from comm port (blocking).
kFBTCPIP_RAW
@ kFBTCPIP_RAW
Raw data (TCP).
Definition: fbio.h:200
FBCommPort::StopBits
FBPropertyInt StopBits
Property: Stop bits.
Definition: fbio.h:147
FBTCPIP::Accept
int Accept(int pSocket, kULong *pOutAddr=NULL)
Accepts incoming port access.
FBCommPort::ByteSize
FBPropertyInt ByteSize
Property: Byte size.
Definition: fbio.h:146
FBCommPort::WriteBlocking
bool WriteBlocking(void *lpBuffer, int nNumberOfBytesToWrite, int *lpNumberOfBytesWritten=NULL, kULong pTimeOut=500)
Write data to comm port (blocking).
FBCommPort::EmptyBuffer
bool EmptyBuffer()
Empty comm port buffer.
FBPropertyListCommPort::RemoveAt
virtual void RemoveAt(int pIndex)
Remove the comm port at pIndex.
kFBTCPIP_Stream
@ kFBTCPIP_Stream
Streaming data (TCP).
Definition: fbio.h:198
kFBParityOdd
@ kFBParityOdd
Odd parity.
Definition: fbio.h:67
FBPropertyBaseListInt
class K_DLLIMPORT FBPropertyBaseList< int > FBPropertyBaseListInt
typedef class FBSDK_DLL FBPropertyBaseList< int > FBPropertyBaseListInt
Definition: fbio.h:159
FBCOMMPORT_DEFAULT_BLOCKING_TIMEOUT
#define FBCOMMPORT_DEFAULT_BLOCKING_TIMEOUT
FBCOMMPORT_DEFAULT_BLOCKING_TIMEOUT.
Definition: fbio.h:62
FBPropertyListCommPort::Remove
virtual int Remove(int pItem)
Remove Comm Port pItem from property list.
FBTCPIP::ReadDatagram
bool ReadDatagram(int pSocket, void *lpBuffer, int nNumberOfBytesToRead, int *lpNumberOfBytesRead=NULL, kULong *pAddr=NULL, unsigned short *pPort=NULL)
Read datagram from a network socket.
FBTCPIP::Read
bool Read(int pSocket, void *lpBuffer, int nNumberOfBytesToRead, int *lpNumberOfBytesRead=NULL)
Read data from a network socket (non-blocking)
kFBInternal
@ kFBInternal
Internal.
Definition: fbio.h:80
FBCommPort
Comm port class.
Definition: fbio.h:92
FBRSType
FBRSType
RS type for serial port.
Definition: fbio.h:72
FBCommPort::Active
FBPropertyBool Active
Property: Is comm port active?
Definition: fbio.h:151
kFBPhysical
@ kFBPhysical
Physical.
Definition: fbio.h:78
FBCommPortType
FBCommPortType
Communication port type.
Definition: fbio.h:77
FBTCPIP::WriteBlocking
bool WriteBlocking(int pSocket, void *lpBuffer, int nNumberOfBytesToWrite, int *lpNumberOfBytesToWrite=NULL, kULong pTimeOut=500)
Write data to a network socket (blocking)
FBCommPort::BaudRate
FBPropertyInt BaudRate
Property: Baud rate.
Definition: fbio.h:142
FBPropertyListCommPort::GetCount
virtual int GetCount()
Get the number of comm ports recognized.
FBCommPort::Read
bool Read(void *lpBuffer, int nNumberOfBytesToRead, int *lpNumberOfBytesRead=NULL)
Read data from comm port (non-blocking).
FBTCPIP::FBTCPIP
FBTCPIP()
Constructor.
__FBClassDeclare
#define __FBClassDeclare(Name, Parent)
For internal use only.
Definition: fbcomponent.h:131
FBPropertyListCommPort::Add
virtual int Add(int pItem)
Add a commport to the property list.
kFBParityEven
@ kFBParityEven
Even parity.
Definition: fbio.h:68
__FB_FORWARD
#define __FB_FORWARD(ClassName)
Forwarding of class and typedef declaration.
Definition: fbtypes.h:68
FBPropertyBaseList
Definition: fbproperties.h:893
FBTCPIP::Connect
bool Connect(int &pSocket, char *pAddr, int pPort)
Connect to address pAddr, port pPort with socket pSocket.
FBCommPort::RSType
FBPropertyRSType RSType
Property: Communications protocol (RS232 or RS422)?
Definition: fbio.h:148
FBTCPIP::CreateSocket
bool CreateSocket(int &pSocket, FBTCPIPSocketType pType, const char *pProtocol="ip", bool pNonBlocking=true)
Create a network socket.
FBSDK_DLL
#define FBSDK_DLL
Be sure that FBSDK_DLL is defined only once...
Definition: fbio.h:49
FBPropertyBool
class K_DLLIMPORT FBPropertyBase< bool, kFBPT_bool > FBPropertyBool
Property: bool
Definition: fbproperties.h:1308
FBPropertyListCommPort
PropertyList: CommPort.
Definition: fbio.h:163
kFBParityNone
@ kFBParityNone
No parity.
Definition: fbio.h:66
fbcomponent.h
Basic class definitions.
FBCommPort::PortNumber
FBPropertyInt PortNumber
Property: Port number.
Definition: fbio.h:140
FBCommPort::CommPortType
FBPropertyCommPortType CommPortType
Property: Comm type (physical, virtual or internal)?
Definition: fbio.h:149
FBCommPort::Write
bool Write(void *lpBuffer, int nNumberOfBytesToWrite, int *lpNumberOfBytesWritten=NULL)
Write data to comm port (non-blocking).
FB_DEFINE_COMPONENT
FB_DEFINE_COMPONENT(K_DLLIMPORT, AnimationNode)
Animation node class.
FBTCPIP::Select
int Select(int pSocket, bool pTestRead, bool pTestWrite, bool pTestError, kULong pTimeOutMilisecond=0)
Test socket status.
FBTCPIP::Write
bool Write(int pSocket, void *lpBuffer, int nNumberOfBytesToWrite, int *lpNumberOfBytesWritten=NULL)
Write data to a network socket (non-blocking)
FBCommPort::UseHardwareFC
FBPropertyBool UseHardwareFC
Property: Use hardware flow control?
Definition: fbio.h:143
FBPropertyString
Property class: const char * (String).
Definition: fbproperties.h:1281
FBComponent
MotionBuilder SDK base class.
Definition: fbcomponent.h:651
kFBRS232
@ kFBRS232
RS-232 serial protocol.
Definition: fbio.h:73
FBCommPort::Parity
FBPropertyParity Parity
Property: Parity.
Definition: fbio.h:145
kFBRS422
@ kFBRS422
RS-422 serial protocol.
Definition: fbio.h:74
FBTCPIP::Listen
int Listen(int pSocket, int pBackLog=1)
Place socket in mode to receive data.