Opto MMP Toolkit
 All Classes Functions Variables
O22SIOST.h
1 //-----------------------------------------------------------------------------
2 //
3 // O22SIOST.h
4 // Copyright (c) 2000-2004 by Opto 22
5 //
6 // Header for the O22SnapIoStream C++ class.
7 //
8 // While this code was developed on Microsoft Windows 32-bit operating
9 // systems, it is intended to be as generic as possible. For Windows specific
10 // code, search for "_WIN32". For Linux specific code, search for "_LINUX".
11 //
12 //-----------------------------------------------------------------------------
13 
14 #ifndef __O22SIOST_H_
15 #define __O22SIOST_H_
16 
17 
18 #ifndef __O22SIOUT_H
19 #include "O22SIOUT.h"
20 #endif
21 
22 
23 #ifndef __O22STRCT_H
24 #include "O22STRCT.h"
25 #endif
26 
27 
28 // These type #defines are used in OpenStreaming()
29 #define SIOMM_STREAM_TYPE_STANDARD 1
30 #define SIOMM_STREAM_TYPE_CUSTOM 2
31 
32 // These callback functions definitions are used in StartStreamListening()
33 typedef int (* STREAM_CALLBACK_PROC)(void * pUserParam);
34 typedef int (* STREAM_EVENT_CALLBACK_PROC)
35  (int nTCPIPAddress, void * pUserParam, int nResult);
36 
37 
43 {
44  uint32_t nIpAddress;
45  uint32_t nTimeout;
47  bool bTimeoutSent;
49 };
50 
78 
79  public:
80  // Public data
81 
82  // Public Construction/Destruction
84  ~O22SnapIoStream();
85 
86  // Public Members
87 
88  // Stream functions
89 
100  int OpenStreaming(long nType, long nLength, long nPort);
101 
106  int CloseStreaming();
107 
125  int SetCallbackFunctions(STREAM_CALLBACK_PROC pStartThreadCallbackFunc,
126  void * pStartThreadParam,
127  STREAM_EVENT_CALLBACK_PROC pStreamEventCallbackFunc,
128  void * pStreamEventParam,
129  STREAM_CALLBACK_PROC pStopThreadCallbackFunc,
130  void * pStopThreadParam);
131 
142  int StartStreamListening(char * pchIpAddressArg, long nTimeoutMS);
143 
149  int StopStreamListening(char * pchIpAddressArg);
150 
162 
173  *
175 
176 
186  int StreamHandler();
187 
188 
195  int CheckStreamTimeouts();
196 
197 
198 
200 
202 
204 
207 
208  // The following members are used to store the callback functions and
209  // user parameters set in the SetCallbackFuntions() function.
210  STREAM_CALLBACK_PROC m_pStartThreadCallbackFunc;
211  STREAM_EVENT_CALLBACK_PROC m_pStreamEventCallbackFunc;
212  STREAM_CALLBACK_PROC m_pStopThreadCallbackFunc;
216 
217  protected:
218 
219  // Protected data
220 
221  // Member data for streaming
222  SOCKET m_StreamSocket;
223 
226 
227 #ifdef _WIN32
228  uintptr_t m_hStreamThread;
229  CRITICAL_SECTION m_StreamCriticalSection;
230 #endif
231 #ifdef _LINUX
232  pthread_t m_hStreamThread;
233  pthread_mutex_t m_StreamCriticalSection;
234 #endif
235 
236 
237  // This class keeps a linked list of I/O units to listen for.
238  // The O22StreamItem structure keeps information on each I/O unit and has
239  // a pNext pointer to let us make the list structure.
242 };
243 
244 
245 #endif // __O22SIOST_H_
int CheckStreamTimeouts()
Definition: O22SIOST.cpp:362
int OpenStreaming(long nType, long nLength, long nPort)
Definition: O22SIOST.cpp:92
O22StreamItem * pNext
Next item in the list.
Definition: O22SIOST.h:48
int StartStreamListening(char *pchIpAddressArg, long nTimeoutMS)
Definition: O22SIOST.cpp:467
uint32_t nIpAddress
IP address of brain.
Definition: O22SIOST.h:44
Definition: O22STRCT.h:437
uint8_t * m_pbyLastStreamBlock
Byte array containing the last block received.
Definition: O22SIOST.h:201
int GetLastStreamStandardBlockEx(SIOMM_StreamStandardBlock *pStreamData)
Definition: O22SIOST.cpp:806
Definition: O22SIOST.h:42
uint32_t nLastPacketTickCount
For tracking timeouts.
Definition: O22SIOST.h:46
SOCKET m_StreamSocket
The handle to the UDP socket.
Definition: O22SIOST.h:222
int StreamHandler()
Definition: O22SIOST.cpp:648
STREAM_EVENT_CALLBACK_PROC m_pStreamEventCallbackFunc
User callback function.
Definition: O22SIOST.h:211
bool m_bListenToStreaming
A flag used in StreamThread() to know when to stop listening.
Definition: O22SIOST.h:199
long nStreamListCount
The number of items in pStreamList.
Definition: O22SIOST.h:241
uint32_t nTimeout
Timeout duration.
Definition: O22SIOST.h:45
int SetCallbackFunctions(STREAM_CALLBACK_PROC pStartThreadCallbackFunc, void *pStartThreadParam, STREAM_EVENT_CALLBACK_PROC pStreamEventCallbackFunc, void *pStreamEventParam, STREAM_CALLBACK_PROC pStopThreadCallbackFunc, void *pStopThreadParam)
Definition: O22SIOST.cpp:435
Definition: O22SIOST.h:77
SIOMM_StreamCustomBlock m_LastStreamBlock
Definition: O22SIOST.h:203
*int GetLastStreamCustomBlockEx(SIOMM_StreamCustomBlock *pStreamData)
Definition: O22SIOST.cpp:832
long m_nStreamType
The type set in OpenStreaming()
Definition: O22SIOST.h:224
STREAM_CALLBACK_PROC m_pStopThreadCallbackFunc
User callback functio.
Definition: O22SIOST.h:212
void * m_pStartThreadParam
User callback parameter.
Definition: O22SIOST.h:213
O22StreamItem * pStreamList
Head of a list of I/O units to listen for.
Definition: O22SIOST.h:240
void * m_pStreamEventParam
User callback parameter.
Definition: O22SIOST.h:214
long m_nStreamLength
The length set in OpenStreaming()
Definition: O22SIOST.h:225
STREAM_CALLBACK_PROC m_pStartThreadCallbackFunc
User callback function.
Definition: O22SIOST.h:210
void * m_pStopThreadParam
User callback parameter.
Definition: O22SIOST.h:215
Definition: O22STRCT.h:447
int CloseStreaming()
Definition: O22SIOST.cpp:225
int StopStreamListening(char *pchIpAddressArg)
Definition: O22SIOST.cpp:566
bool bTimeoutSent
Flag for if a timeout error was sent already.
Definition: O22SIOST.h:47