![]() |
MAK RTIspy API Documentation for HLA 1.3
|
00001 /********************************************************************* 00002 ** Copyright (c) 1998 MaK Technologies, Inc. 00003 ** All rights reserved. 00004 *********************************************************************/ 00005 /********************************************************************* 00006 ** $RCSfile: execFedMgr.h,v $ $Revision: 1.58 $ $State: Exp $ 00007 *********************************************************************/ 00008 00009 #ifndef execFedMgr_H_ 00010 #define execFedMgr_H_ 00011 00014 00015 00016 #include "rtiMsConfig.h" 00017 #include "fedMgr.h" 00018 #include "syncPointMsg.h" 00019 #include "resBegMsg.h" 00020 #include "creRespMsg.h" 00021 #include "desRespMsg.h" 00022 #include "joinRespMsg.h" 00023 #include "joinConfMsg.h" 00024 #include "savRespMsg.h" 00025 #include "fomModuleRequestMsg.h" 00026 #include "synchronousFileDistributor.h" 00027 #include "ridFileTester.h" 00028 #include "fileDistributor.h" 00029 #include <vector> 00030 00031 #include "mtl/fedReader13.h" 00032 #include "mtl/fedReader1516.h" 00033 #include "mtl/fedReader1516e.h" 00034 00035 class DtSyncPointMsg; 00036 class DtDesignatedFederateMsg; 00037 class DtSaveStatusMsg; 00038 class DtRestoreStatusMsg; 00039 class DtSaveFinishedMsg; 00040 class DtSaveInitiateMsg; 00041 class DtRestoreReplyMsg; 00042 class DtRestoreEndMsg; 00043 class DtRestoreInitiateMsg; 00044 class DtRestoreMsg; 00045 class DtReportFederationsMsg; 00046 namespace vrlmod 00047 { 00048 class DtThreadedObject; 00049 } 00050 00061 class DT_DLL_LRC DtRtiExecFederateMgr : public DtFederateMgr 00062 { 00063 public: 00064 00066 DtRtiExecFederateMgr(DtRIDParameters* params, 00067 DtRtiAmbassadorBaseImplementor* ambImplPtr, 00068 DtConnectionMgr* connMgr, 00069 DtBoost::shared_ptr<DtRtiAssistantLrcClient> assistantClient); 00070 00072 virtual ~DtRtiExecFederateMgr(); 00073 00074 private: 00075 00077 DtRtiExecFederateMgr(DtFederateMgr const& ); 00078 00080 DtRtiExecFederateMgr& operator= (DtRtiExecFederateMgr const& ); 00081 00082 public: 00083 00086 00087 00089 virtual void createFederationExecution( 00090 const char* executionName, const char* timeImplName, 00091 #ifdef DtIFSPEC1516E 00092 const std::vector<DtString>& fomModules, 00093 const char* mimModule); 00094 #else 00095 const char* fed); 00096 #endif 00097 00099 virtual void destroyFederationExecution( 00100 const char* executionName); 00101 00102 #ifdef DtIFSPEC1516E 00103 00104 virtual void listFederationExecutions(); 00105 #endif 00106 00108 #ifdef DtIFSPEC1516 00109 virtual rti1516::FederateHandle joinFederationExecution ( 00110 const char* yourName, 00111 const char* executionName, 00112 rti1516::FederateAmbassador* federateAmbassadorReference, 00113 unsigned long flags); 00114 #elif defined(DtIFSPEC1516E) 00115 virtual rti1516e::FederateHandle joinFederationExecution ( 00116 const char* federateName, 00117 const char* yourName, 00118 const char* executionName, 00119 const std::vector<DtString>& fomModules, 00120 unsigned long flags); 00121 #else 00122 00123 virtual RTI::FederateHandle joinFederationExecution ( 00124 const char* yourName, 00125 const char* executionName, 00126 RTI::FederateAmbassador* federateAmbassadorReference, 00127 unsigned long flags); 00128 #endif 00129 00130 00132 #ifdef DtIFSPEC1516 00133 virtual void resignFederationExecution( 00134 rti1516::ResignAction theAction); 00135 #elif defined(DtIFSPEC1516E) 00136 virtual void resignFederationExecution( 00137 rti1516e::ResignAction theAction); 00138 #else 00139 virtual void resignFederationExecution( 00140 RTI::ResignAction theAction); 00141 #endif 00142 00143 00146 00147 00149 #ifdef DtIFSPEC1516 00150 virtual void registerFederationSynchronizationPoint( 00151 char const * label, 00152 rti1516::VariableLengthData const & theTag); 00153 #elif defined(DtIFSPEC1516E) 00154 virtual void registerFederationSynchronizationPoint( 00155 char const * label, 00156 rti1516e::VariableLengthData const & theTag); 00157 #else 00158 virtual void registerFederationSynchronizationPoint( 00159 char const * label, 00160 char const * theTag); 00161 #endif 00162 00164 #ifdef DtIFSPEC1516 00165 virtual void registerFederationSynchronizationPoint( 00166 char const * label, 00167 rti1516::VariableLengthData const & theTag, 00168 DtFederateHandleSet const & syncSet); 00169 #elif defined(DtIFSPEC1516E) 00170 virtual void registerFederationSynchronizationPoint( 00171 char const * label, 00172 rti1516e::VariableLengthData const & theTag, 00173 DtFederateHandleSet const & syncSet); 00174 #else 00175 virtual void registerFederationSynchronizationPoint( 00176 char const * label, 00177 char const * theTag, 00178 DtFederateHandleSet const & syncSet); 00179 #endif 00180 00181 00183 virtual void synchronizationPointAchieved(char const * label, bool successfully=true); 00185 00188 00189 00190 #ifdef DtIFSPEC1516 00191 00192 virtual void requestFederationSave (char const * label, 00193 rti1516::LogicalTime const * time=NULL); 00194 00196 virtual void queryFederationSaveStatus(); 00197 00199 virtual void queryFederationRestoreStatus(); 00200 #elif defined(DtIFSPEC1516E) 00201 00202 virtual void requestFederationSave (char const * label, 00203 rti1516e::LogicalTime const * time=NULL); 00204 00206 virtual void queryFederationSaveStatus(); 00207 00209 virtual void queryFederationRestoreStatus(); 00210 00212 virtual void abortFederationSave(); 00213 00215 virtual void abortFederationRestore(); 00216 #else 00217 00219 virtual void requestFederationSave (char const * label, 00220 RTI::FedTime const * time=NULL); 00221 #endif 00222 00224 virtual void federateSaveBegun (); 00225 00227 virtual void federateSaveComplete (); 00228 00230 virtual void federateSaveNotComplete (); 00231 00233 virtual void requestFederationRestore ( const char *label); 00234 00236 virtual void federateRestoreComplete (); 00237 00239 virtual void federateRestoreNotComplete (); 00241 00243 std::map<DtString, DtSynchronousFileDistributor*> distributors(); 00244 std::map<DtString, DtSynchronousFileDistributor*> distributors() const; 00245 DtSynchronousFileDistributor* joinDistributor(); 00246 DtSynchronousFileDistributor* joinDistributor() const; 00247 00249 virtual void init(); 00250 00251 protected: 00252 00254 virtual void initRidTester(); 00255 00257 virtual void initializeDistributor( const char* executionName ); 00258 00260 virtual void waitForJoinResponse( const char* executionName, 00261 std::vector<MAKRti::DtString> &joinModules ); 00262 00264 void checkJoinResponse(); 00265 00267 virtual void initializeTimeFactory(); 00268 00270 virtual void initializeFOM( const char* executionName ); 00271 00272 00275 virtual void postJoinInit( 00276 const char* yourName, 00277 const char* executionName, 00278 const char* federateName 00279 #ifdef DtIFSPEC1516 00280 , rti1516::FederateAmbassador* federateAmbassadorReference); 00281 #elif defined(DtIFSPEC1516E) 00282 ); 00283 #else 00284 , RTI::FederateAmbassador* federateAmbassadorReference); 00285 #endif 00286 00288 virtual void handleFailedJoin(unsigned long sourceID, 00289 DtJoinConfirmMsg::errorCodes code); 00290 00292 virtual void setDesignatedFederate(bool isDesignated); 00293 virtual bool isDesignatedFederate(); 00294 00297 void appendFomModule(std::vector<MAKRti::DtString>& target, 00298 MAKRti::DtString const& source); 00299 00302 void appendFomModules(std::vector<MAKRti::DtString>& target, 00303 std::vector<MAKRti::DtString> const& source); 00304 00306 virtual bool findFedFileNameFromMapping( const MAKRti::DtString execName, 00307 const std::vector<MAKRti::DtString>& orig, 00308 std::vector<MAKRti::DtString>& namesToUse) const; 00309 00311 void testReadFomModules(const DtRIDParameters::DtStringList&, 00312 MAKRti::DtString executionName, bool isMim = false); 00313 00315 virtual void mergeFomModules(const std::vector<MAKRti::DtString>* fomModules); 00316 00320 00321 00323 virtual void processSyncPointMsg(const DtSyncPointMsg& msg); 00324 00326 virtual void processDesignatedFederateMsg(const DtDesignatedFederateMsg& msg); 00327 00329 virtual void processFomModuleFileRequestMsg(const DtFomModuleRequestMsg& msg); 00330 00332 virtual void processCreateResponseMsg(const DtCreateResponseMsg& msg); 00333 00334 #ifdef DtIFSPEC1516E 00335 00336 virtual void processReportFederationsMsg(const DtReportFederationsMsg& msg); 00337 #endif 00338 00340 virtual void processJoinResponseMsg(const DtJoinResponseMsg& msg); 00341 00343 virtual void processDestroyResponseMsg(const DtDestroyResponseMsg& msg); 00344 00346 virtual void processSaveInitiate(const DtSaveInitiateMsg& msg); 00347 00349 virtual void processSaveInitiate(const char* label); 00350 00352 virtual void requestImmediateSave(const char *label); 00353 00355 virtual void processSaveResponse(const DtSaveResponseMsg& msg); 00356 00358 virtual void processSaveFinished(const DtSaveFinishedMsg& msg); 00359 00361 virtual void processRestoreReply(const DtRestoreReplyMsg& msg); 00362 00364 virtual void processRestoreEnd(const DtRestoreEndMsg& msg); 00365 00367 virtual void processRestoreInitiate(const DtRestoreInitiateMsg& msg); 00368 00370 virtual void processRestore(const DtRestoreMsg& msg); 00371 00372 #if defined(DtIFSPEC1516) || defined(DtIFSPEC1516E) 00373 00374 virtual void processSaveStatusMsg(const DtSaveStatusMsg& msg); 00375 00377 virtual void processRestoreStatusMsg(const DtRestoreStatusMsg& msg); 00378 #endif 00379 00380 00382 virtual void testSaveProgress(); 00383 00385 virtual void applyRidParameters(); 00386 00387 00388 00391 00392 00394 virtual void sendCreateMsg(MAKRti::DtString const & fedExNameVal, 00395 MAKRti::DtString const & timeImplName, const std::vector<unsigned int> & moduleCrcs, 00396 MAKRti::DtFomType fedType, MAKRti::DtString const &momModuleName, 00397 const std::vector<MAKRti::DtString>& fomModules, unsigned int momModuleCrc); 00398 00400 virtual void sendDestroyMsg(const char* name); 00401 00403 virtual void sendJoinMsg( 00404 unsigned long sourceID, unsigned short requestID, const char* fedType, 00405 const char* fedExName, const char* fedName, 00406 const std::vector<MAKRti::DtString>& fomModules, 00407 const unsigned long flags, const std::vector<unsigned int>& joinModulesCrcs); 00408 00410 virtual void sendJoinConfirmMsg( 00411 unsigned long sourceID, DtJoinConfirmMsg::errorCodes errorCode); 00412 00413 #ifdef DtIFSPEC1516 00414 00415 virtual void sendSyncPointMsg(DtSyncMsgType kind, DtFederateHandle& id, 00416 char const * name, 00417 rti1516::VariableLengthData const* tag = NULL, 00418 DtFederateHandleSet const * set = NULL); 00419 #ifdef DtTIME 00420 00422 virtual void sendSaveRequestTsoMsg(char const * label, 00423 rti1516::LogicalTime const * time); 00424 #endif 00425 #elif defined(DtIFSPEC1516E) 00426 00427 virtual void sendSyncPointMsg(DtSyncMsgType kind, DtFederateHandle& id, 00428 char const * name, 00429 rti1516e::VariableLengthData const* tag = NULL, 00430 DtFederateHandleSet const * set = NULL); 00431 #ifdef DtTIME 00432 00434 virtual void sendSaveRequestTsoMsg(char const * label, 00435 rti1516e::LogicalTime const * time); 00436 #endif 00437 #else 00438 00439 virtual void sendSyncPointMsg(DtSyncMsgType kind, DtFederateHandle& id, 00440 char const * name, 00441 char const * tag = NULL, 00442 DtFederateHandleSet const * set = NULL); 00443 #ifdef DtTIME 00444 00445 virtual void sendSaveRequestTsoMsg(char const * label, 00446 RTI::FedTime const * time); 00447 #endif 00448 #endif 00449 00451 virtual void sendSaveRequestMsg(unsigned long requestID, const char *label); 00452 00454 virtual void sendSaveBegunMsg(); 00455 00457 virtual void sendSaveCompleteMsg(const char *label, bool success); 00458 00460 virtual void sendRestoreRequestMsg(const char *label); 00461 00463 virtual void sendRestoreBegunMsg(const char *label, DtResponseFlag response); 00464 00466 virtual void sendRestoreCompleteMsg(const char *label, bool success); 00468 00471 00472 00475 virtual void initiateSave(); 00476 00479 #ifdef DtIFSPEC1516 00480 virtual void initiateTimedSave(rti1516::LogicalTime const& saveTime); 00481 #elif defined(DtIFSPEC1516E) 00482 virtual void initiateTimedSave(rti1516e::LogicalTime const& saveTime); 00483 #else 00484 virtual void initiateTimedSave(RTI::FedTime const& saveTime); 00485 #endif 00486 00489 virtual bool saveLRC(DtRtiSaveFile& saveFile); 00490 00492 virtual bool save(DtRtiSaveFile& file); 00493 00496 virtual void prepareToRestoreLRC(); 00497 00500 virtual bool restoreLRC(DtRtiSaveFile& saveFile); 00501 00503 virtual void prepareToRestore(); 00504 00506 virtual bool restore( DtRtiSaveFile& file ); 00508 00510 virtual void posttick(); 00511 00512 public: 00513 00516 00517 00519 static void processSyncPointMsg(const DtSyncPointMsg& msg, void* usr); 00520 00522 static void processDesignatedFederateMsg(const DtDesignatedFederateMsg& msg, void* usr); 00523 00525 static void processFomModuleFileRequestMsg( const DtFomModuleRequestMsg& msg, void* usr); 00526 00528 static void processCreateResponseMsg(const DtCreateResponseMsg& msg, void* usr); 00529 00530 #ifdef DtIFSPEC1516E 00531 00532 static void processReportFederationsMsg(const DtReportFederationsMsg& msg, void* usr); 00533 #endif 00534 00536 static void processJoinResponseMsg(const DtJoinResponseMsg& msg, void* usr); 00537 00539 static void processDestroyResponseMsg(const DtDestroyResponseMsg& msg, void* usr); 00540 00541 #if defined(DtIFSPEC1516) || defined(DtIFSPEC1516E) 00542 00543 static void processSaveStatusMsg(const DtSaveStatusMsg& msg, void* usr); 00544 00546 static void processRestoreStatusMsg(const DtRestoreStatusMsg& msg, void* usr); 00547 #endif 00548 00549 00550 00552 static DtFederateMgr* create(DtRIDParameters* params, 00553 DtRtiAmbassadorBaseImplementor* ambImplPtr, 00554 DtConnectionMgr* connMgr, 00555 DtBoost::shared_ptr<DtRtiAssistantLrcClient> assistantClient); 00556 00557 protected: 00558 00560 std::map<DtString, DtSynchronousFileDistributor*> myDistributors; 00561 00563 DtSynchronousFileDistributor* myJoinDistributor; 00564 00566 DtCreateResponseFlag myCreateResponse; 00567 00569 MAKRti:: DtString myCreateResponseErrorString; 00570 00572 DtDestroyResponseFlag myDestroyResponse; 00573 00575 DtJoinResponseMsg* myJoinResponse; 00576 00578 DtJoinConfirmMsg::errorCodes myJoinConfirmResponse; 00579 00581 MAKRti::DtString myDestroyExecutionName; 00582 00584 bool myFedFileRequest; 00585 00587 std::vector<MAKRti::DtString> myFomModuleRequests; 00588 00590 unsigned short myJoinRequestID; 00591 00593 unsigned long mySaveRequestID; 00594 00596 DtSaveResponseFlag mySaveResponse; 00597 00602 MAKRti::DtHashList mySyncPoints; 00603 00605 #if defined(DtIFSPEC1516) || defined(DtIFSPEC1516E) 00606 std::wstring* myFailedSyncPointLabel; 00607 #else 00608 std::string* myFailedSyncPointLabel; 00609 #endif 00610 00614 DtFederateHandle myOldFedHandle; 00615 00618 bool myIsDesignatedFederate; 00619 00620 00622 vrlmod::DtThreadedObject* myDistributorThread; 00623 bool myAsynchronousDistributor; 00624 00625 //When files are received from distributor, store them here 00627 std::map<MAKRti::DtString, DtFileInformation*> myTakenFiles; 00628 00629 00630 DtFedReader13 * myFedReader13; 00631 DtFedReader1516 * myFedReader1516; 00632 DtFedReader1516e * myFedReader1516e; 00633 DtFedReader * getReader( DtFomType theFomType ); 00634 00635 MAKRti::DtFilename myStandardMimPath; 00636 00637 void populateWithUnknownFoms(std::vector<DtString> & mods, std::vector<DtString> & requestedMods); 00638 bool isFomAvailable(const DtString & fomName); 00639 void getCrcsOfFoms( std::vector<unsigned int> & moduleCrcs, const std::vector<MAKRti::DtString> & creationFomModuleNames ); 00640 bool myFullFedFileDistribution; 00641 MAKRti::DtFilename & getStandardMimPath(); 00642 }; 00643 00644 #endif 00645 00646 00647