![]() |
MAK RTIspy API Documentation for HLA 1516
|
00001 /******************************************************************************* 00002 ** Copyright (c) 1998 MaK Technologies, Inc. 00003 ** All rights reserved. 00004 *******************************************************************************/ 00005 /******************************************************************************* 00006 ** $RCSfile: asyConMgr.h,v $ $Revision: 1.39 $ $State: Exp $ 00007 *******************************************************************************/ 00008 00011 00012 #ifndef VXWORKS 00013 00014 #ifndef DtAsyncConnectionMgr_H_ 00015 #define DtAsyncConnectionMgr_H_ 00016 00017 00018 #include "rtiMsConfig.h" 00019 #include "connectMgr.h" 00020 #include <vlutil/vlThreadSafe.h> 00021 #include <vlutil/vlMutex.h> 00022 #include "fedAmbCallbackQueue.h" 00023 00024 #ifdef _WIN32 00025 #include "windows.h" 00026 #else 00027 #include "pthread.h" 00028 #endif 00029 00030 #ifdef DtIFSPEC13DLC 00031 #define RTI rti13 00032 #endif 00033 00034 namespace MAKRti 00035 { 00036 class DtSelectParamWithWrite; 00037 } 00038 class DtFedAmbCallbackMsg; 00039 00040 class DT_DLL_LRC DtQueuePacket 00041 { 00042 public: 00043 DtQueuePacket( DtRtiMsg* msg, 00044 MAKRti::DtTransportType transport, 00045 const MAKRti::DtInetAddr& addr = MAKRti::DtInetAddr::inaddrAny() ); 00046 00047 ~DtQueuePacket(); 00048 00049 DtRtiMsg* msg; 00050 MAKRti::DtInetAddr addr; 00051 MAKRti::DtTransportType transport; 00052 }; 00053 00058 00059 class DT_DLL_LRC DtAsyncConnectionMgr : public DtConnectionMgr 00060 { 00061 protected: 00062 00063 DtAsyncConnectionMgr( DtRIDParameters* params, bool isFederate = false, 00064 DtBoost::shared_ptr<DtRtiAssistantLrcClient> assistantClient = 00065 DtBoost::shared_ptr<DtRtiAssistantLrcClient>() ); 00066 00067 public: 00068 00069 virtual ~DtAsyncConnectionMgr(); 00070 00076 virtual int init( DtRIDParameters* params ); 00077 00079 virtual void setFederateMgr( DtFederateMgr* fedMgrPtr ); 00080 00082 virtual bool isAsynchronous(); 00083 00084 virtual void disconnectFederation(); 00085 virtual void connectFederation( 00086 #ifdef DtIFSPEC1516 00087 rti1516::FederateAmbassador* fedAmb, 00088 #elif defined(DtIFSPEC13) 00089 RTI::FederateAmbassador* fedAmb, 00090 #endif 00091 DtLogicalTimeFactory* logicalTimeFactoryPtr, 00092 MAKRti::DtString fedExName, 00093 DtFederateHandle fedHandle, 00094 int fedExHandle ); 00095 00098 virtual void queueMsg( DtRtiMsg* msg, 00099 MAKRti::DtTransportType transport, 00100 const MAKRti::DtInetAddr& addr = MAKRti::DtInetAddr::inaddrAny() ); 00101 00103 virtual int send( const DtRtiMsg& msg, 00104 MAKRti::DtTransportType transport, 00105 const MAKRti::DtInetAddr& addr = MAKRti::DtInetAddr::inaddrAny() ); 00106 00109 virtual int sendAndDelete( DtRtiMsg* msg, 00110 MAKRti::DtTransportType transport, 00111 const MAKRti::DtInetAddr& addr = MAKRti::DtInetAddr::inaddrAny() ); 00112 00114 virtual bool tick(); 00115 00120 virtual bool processConnections(); 00121 00124 virtual DtRtiMsg* getMessage(); 00125 00127 virtual DtNetReadStatus handleMsg( DtRtiMsg& msg ); 00128 00133 virtual bool flush(); 00134 00136 virtual void workerThread(); 00137 00140 virtual bool wait( MAKRti::DtTime periodInSeconds, bool unlockWhileWaiting = false ); 00141 00150 #ifdef DtIFSPEC1516 00151 virtual int readFileDescriptor(rti1516::TransportationType transport); 00152 #elif defined(DtIFSPEC1516E) 00153 virtual int readFileDescriptor(rti1516e::TransportationType transport); 00154 #else 00155 virtual int readFileDescriptor(RTI::TransportType transport); 00156 #endif 00157 00158 #ifdef _WIN32 00159 00160 virtual HANDLE waitEvent(); 00163 #ifdef DtIFSPEC1516 00164 virtual WSAEVENT readFileEvent(rti1516::TransportationType transport); 00165 #elif defined(DtIFSPEC1516E) 00166 virtual WSAEVENT readFileEvent(rti1516e::TransportationType transport); 00167 #else 00168 virtual WSAEVENT readFileEvent(RTI::TransportType transport); 00169 #endif 00170 #else 00171 00172 virtual int waitEvent(); 00173 #endif 00174 00177 virtual void signalReceiveEvent(); 00178 00181 virtual void clearReceiveEvent(); 00182 00185 virtual void signalSendEvent(); 00186 00189 virtual void clearSendEvent(); 00190 00192 virtual void yield(); 00193 00194 protected: 00195 00197 virtual bool doWait(MAKRti::DtTime period); 00198 00200 virtual void processCallbackMsg(const DtFedAmbCallbackMsg& callbackMsg); 00201 00204 virtual DtQueuePacket* getPacket(); 00205 00210 virtual bool sendPackets(); 00211 00217 virtual DtNetReadStatus receivePacket(DtRtiConnection* conn, 00218 MAKRti::DtTransportType transportType, unsigned int& receivedPacketCount); 00219 00224 virtual bool receivePackets(); 00225 00229 virtual DtNetReadStatus processMsgQueueCallbacks(DtRtiMsg& msg, 00230 unsigned int& receivedPacketCount); 00231 00234 virtual void processPendingMsgQueueCallbacks(); 00235 00237 virtual void processPendingMsgMakeCallbacks(); 00238 00240 virtual void setMessageTracking(DtRtiMsg& msg); 00241 00243 #ifdef _WIN32 00244 virtual void waitOnIO(); 00245 #else 00246 virtual void waitOnIO(DtSelectParamWithWrite& params); 00247 #endif 00248 00251 virtual void destroyPackets(); 00252 00254 virtual void destroyRelConn(); 00255 00257 virtual void destroyAncillaryRelConn(DtRtiConnection* conn); 00258 00260 virtual void destroyAncillaryRelConns(); 00261 00262 public: 00263 00265 static DtConnectionMgr* create( DtRIDParameters* p, bool isFederate = false, 00266 DtBoost::shared_ptr<DtRtiAssistantLrcClient> assistantClient = 00267 DtBoost::shared_ptr<DtRtiAssistantLrcClient>() ); 00268 00270 #ifdef _WIN32 00271 static unsigned long run( void* usr ); 00272 #else 00273 static void* run( void* usr ); 00274 #endif 00275 00276 protected: 00277 00279 static void processCallbackMsg(const DtFedAmbCallbackMsg& callbackMsg, void* usr); 00280 00281 protected: 00282 bool myTimeToQuit; 00283 bool myThreadActivated; 00284 bool myAsynchronous; 00285 bool myAsynchronousCallbacks; 00286 bool myAsynchronousProcessMsg; 00287 bool myReserved; 00288 bool myMoreToFlush; 00289 00290 DtMutex* mySendLock; 00291 DtMutex* myReceiveLock; 00292 00293 #ifdef _WIN32 00294 HANDLE myThreadHandle; 00295 HANDLE myEvent; 00296 HANDLE* myWaitEvents; 00297 unsigned int myNumWaitEvents; 00298 #else 00299 pthread_t myThreadHandle; 00300 int mySendEvent[2]; 00301 int myRecvEvent[2]; 00302 #endif 00303 00304 float myIoPeriod; 00305 float myTickWaitPeriod; 00306 unsigned int myMaxQueue; 00307 unsigned int myMaxCount; 00308 unsigned int myLockQueue; 00309 00311 long myReceivedBufferCurrent; 00312 long myReceivedBufferCount; 00313 DtQueuePacket** myReceivedBuffer; 00314 00316 unsigned int myCurrentSendPacket; 00317 unsigned int myPacketsToSendCount; 00318 std::vector<DtQueuePacket*> mySendPacketBuffer; 00319 std::vector<DtQueuePacket*> myRecvPacketBuffer; 00320 00322 unsigned int myReadPacketCount; 00323 00325 MAKRti::DtClock myBestEffortRetryTimer; 00326 unsigned int myBestEffortRetryAttempts; 00327 MAKRti::DtTime myBestEffortTimeToRetry; 00328 00333 MAKRti::DtList* mySendQueue; 00334 MAKRti::DtList* myReceiveQueue; 00335 00337 DtCallbackQueue* myCallbackQueue; 00338 00339 DtThreadSafe<bool> myAsynchronousConnectionIsOk; 00340 00344 unsigned int myNextReliableConnToRead; 00345 00346 00347 }; 00348 00349 #endif //! DtAsyncConnectionMgr_H_ 00350 00351 #endif //! VXWORKS 00352