MAK RTIspy API Documentation for HLA 1516
asyConMgr.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 1998 MaK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: asyConMgr.h,v $ $Revision: 1.39 $ $State: Exp $
7 *******************************************************************************/
8 
11 
12 #ifndef VXWORKS
13 
14 #ifndef DtAsyncConnectionMgr_H_
15 #define DtAsyncConnectionMgr_H_
16 
17 
18 #include "rtiMsConfig.h"
19 #include "connectMgr.h"
20 #include <vlutil/vlThreadSafe.h>
21 #include <vlutil/vlMutex.h>
22 #include "fedAmbCallbackQueue.h"
23 
24 #ifdef _WIN32
25 #include "windows.h"
26 #else
27 #include "pthread.h"
28 #endif
29 
30 #ifdef DtIFSPEC13DLC
31 #define RTI rti13
32 #endif
33 
34 namespace MAKRti
35 {
36  class DtSelectParamWithWrite;
37 }
39 
41 {
42 public:
43  DtQueuePacket( DtRtiMsg* msg,
44  MAKRti::DtTransportType transport,
45  const MAKRti::DtInetAddr& addr = MAKRti::DtInetAddr::inaddrAny() );
46 
47  ~DtQueuePacket();
48 
50  MAKRti::DtInetAddr addr;
51  MAKRti::DtTransportType transport;
52 };
53 
58 
60 {
61 protected:
62 
63  DtAsyncConnectionMgr( DtRIDParameters* params, bool isFederate = false,
64  DtBoost::shared_ptr<DtRtiAssistantLrcClient> assistantClient =
65  DtBoost::shared_ptr<DtRtiAssistantLrcClient>() );
66 
67 public:
68 
69  virtual ~DtAsyncConnectionMgr();
70 
76  virtual int init( DtRIDParameters* params );
77 
79  virtual void setFederateMgr( DtFederateMgr* fedMgrPtr );
80 
82  virtual void shutdown();
83 
85  virtual bool isAsynchronous();
86 
87  virtual void disconnectFederation();
88  virtual void connectFederation(
89 #ifdef DtIFSPEC1516
91 #elif defined(DtIFSPEC13)
93 #endif
94  DtLogicalTimeFactory* logicalTimeFactoryPtr,
95  MAKRti::DtString fedExName,
96  DtFederateHandle fedHandle,
97  int fedExHandle );
98 
101  virtual void queueMsg( DtRtiMsg* msg,
102  MAKRti::DtTransportType transport,
103  const MAKRti::DtInetAddr& addr = MAKRti::DtInetAddr::inaddrAny() );
104 
106  virtual int send( const DtRtiMsg& msg,
107  MAKRti::DtTransportType transport,
108  const MAKRti::DtInetAddr& addr = MAKRti::DtInetAddr::inaddrAny() );
109 
112  virtual int sendAndDelete( DtRtiMsg* msg,
113  MAKRti::DtTransportType transport,
114  const MAKRti::DtInetAddr& addr = MAKRti::DtInetAddr::inaddrAny() );
115 
117  virtual bool tick();
118 
123  virtual bool processConnections();
124 
127  virtual DtRtiMsg* getMessage();
128 
130  virtual DtNetReadStatus handleMsg( DtRtiMsg& msg );
131 
136  virtual bool flush();
137 
139  virtual void workerThread();
140 
143  virtual bool wait( MAKRti::DtTime periodInSeconds, bool unlockWhileWaiting = false );
144 
153 #ifdef DtIFSPEC1516
154  virtual int readFileDescriptor(rti1516::TransportationType transport);
155 #elif defined(DtIFSPEC1516E)
156  virtual int readFileDescriptor(rti1516e::TransportationType transport);
157 #else
158  virtual int readFileDescriptor(RTI::TransportType transport);
159 #endif
160 
161 #ifdef _WIN32
162 
163  virtual HANDLE waitEvent();
166 #ifdef DtIFSPEC1516
167  virtual WSAEVENT readFileEvent(rti1516::TransportationType transport);
168 #elif defined(DtIFSPEC1516E)
169  virtual WSAEVENT readFileEvent(rti1516e::TransportationType transport);
170 #else
171  virtual WSAEVENT readFileEvent(RTI::TransportType transport);
172 #endif
173 #else
174 
175  virtual int waitEvent();
176 #endif
177 
180  virtual void signalReceiveEvent();
181 
184  virtual void clearReceiveEvent();
185 
188  virtual void signalSendEvent();
189 
192  virtual void clearSendEvent();
193 
195  virtual void yield();
196 
197 protected:
198 
200  virtual void doDisconnectFederation();
201 
203  virtual bool doWait(MAKRti::DtTime period);
204 
206  virtual void processCallbackMsg(const DtFedAmbCallbackMsg& callbackMsg);
207 
210  virtual DtQueuePacket* getPacket();
211 
216  virtual bool sendPackets();
217 
223  virtual DtNetReadStatus receivePacket(DtRtiConnection* conn,
224  MAKRti::DtTransportType transportType, unsigned int& receivedPacketCount);
225 
230  virtual bool receivePackets();
231 
235  virtual DtNetReadStatus processMsgQueueCallbacks(DtRtiMsg& msg,
236  unsigned int& receivedPacketCount);
237 
240  virtual void processPendingMsgQueueCallbacks();
241 
243  virtual void processPendingMsgMakeCallbacks();
244 
246  virtual void setMessageTracking(DtRtiMsg& msg);
247 
249 #ifdef _WIN32
250  virtual void waitOnIO();
251 #else
252  virtual void waitOnIO(DtSelectParamWithWrite& params);
253 #endif
254 
257  virtual void destroyPackets();
258 
260  virtual void destroyRelConn();
261 
263  virtual void destroyAncillaryRelConn(DtRtiConnection* conn);
264 
266  virtual void destroyAncillaryRelConns();
267 
269  virtual void startAsynchronousProcessing();
270 
272  virtual void stopAsynchronousProcessing();
273 
274 public:
275 
277  static DtConnectionMgr* create( DtRIDParameters* p, bool isFederate = false,
278  DtBoost::shared_ptr<DtRtiAssistantLrcClient> assistantClient =
279  DtBoost::shared_ptr<DtRtiAssistantLrcClient>() );
280 
282 #ifdef _WIN32
283  static unsigned long run( void* usr );
284 #else
285  static void* run( void* usr );
286 #endif
287 
288 protected:
289 
291  static void processCallbackMsg(const DtFedAmbCallbackMsg& callbackMsg, void* usr);
292 
293 protected:
302 
303  DtMutex* mySendLock;
304  DtMutex* myReceiveLock;
305 
306 #ifdef _WIN32
307  HANDLE myThreadHandle;
308  HANDLE myEvent;
309  HANDLE* myWaitEvents;
310  unsigned int myNumWaitEvents;
311 #else
312  pthread_t myThreadHandle;
313  int mySendEvent[2];
314  int myRecvEvent[2];
315 #endif
316 
317  float myIoPeriod;
319  unsigned int myMaxQueue;
320  unsigned int myMaxCount;
321  unsigned int myLockQueue;
322 
327 
329  unsigned int myCurrentSendPacket;
330  unsigned int myPacketsToSendCount;
331  std::vector<DtQueuePacket*> mySendPacketBuffer;
332  std::vector<DtQueuePacket*> myRecvPacketBuffer;
333 
335  unsigned int myReadPacketCount;
336 
338  MAKRti::DtClock myBestEffortRetryTimer;
340  MAKRti::DtTime myBestEffortTimeToRetry;
341 
346  MAKRti::DtList* mySendQueue;
347  MAKRti::DtList* myReceiveQueue;
348 
350  DtCallbackQueue* myCallbackQueue;
351 
352  DtThreadSafe<bool> myAsynchronousConnectionIsOk;
353 
358 
359 
360 };
361 
362 #endif
363 
364 #endif
365 

Document ID: Generated on Tue May 7 16:26:47 EDT 2013 from SVN revision 126903
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)