MAK RTIspy API Documentation for HLA Evolved
exec.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 1998 MaK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: exec.h,v $ $Revision: 1.27 $ $State: Exp $
7 *******************************************************************************/
8 
11 
12 #ifndef VXWORKS
13 
14 #ifndef DtRtiExec_H_
15 #define DtRtiExec_H_
16 
17 #include "rtiMsConfig.h"
18 #include <map>
19 #include <string>
20 #include <list>
21 #include <vlThreadedObject.h>
22 #include <vlutil/vlTime.h>
23 #include <vlutil/vlList.h>
24 #include <vlutil/vlUtil.h>
25 #include <vlutil/vlPrint.h>
26 #include <vlutil/vlInetAddr.h>
27 
28 #include <creRespMsg.h>
29 #include <desRespMsg.h>
30 #include <joinRespMsg.h>
31 #include <execHandshakeMsg.h>
32 #include <rtiUtil.h>
34 
35 
39 class DtCreateMsg;
40 class DtDestroyMsg;
42 class DtJoinMsg;
43 class DtDisconnectMsg;
44 class DtReconnectMsg;
46 class DtFedExec;
47 class DtRIDParameters;
50 
52 typedef DtBoost::shared_ptr<DtExtendedRtiMsgForwarder> DtRtiMsgForwarderSP;
53 
54 
57 
58 class DtRtiExec;
59 
61 typedef DtRtiExec* (*DtRtiExecCreator)(DtRIDParameters* p,
62  DtBoost::shared_ptr<DtFilePrinter> logPrinter,
63  bool autoExit, const DtRtiConnectionInfoDataPair& connInfo );
64 
66 typedef void (*DtFedExCbFn)(DtFedExec* exec, void* usr);
67 
69 typedef void (*DtTickCbFn)(void* usr);
70 typedef void (*DtTickWithExecCbFn)(const DtRtiExec& exec, void* usr);
71 
73 typedef void (*DtLogFileNameCbFn)(const DtFilename& file, void* usr);
74 
77 {
78 public:
79  DtFedExCallbackInfo(DtFedExCbFn fn, void* data) :
80  myData(data), myFn(fn) {}
81 
82  void* myData;
84 };
85 
88 {
89 public:
90  DtTickCallbackInfo(DtTickCbFn fn, void* data, DtTime interval) :
91  myData(data), myFn(fn), myInterval(interval), myNextExecutionTime(0) {}
92 
93  bool operator<(const DtTickCallbackInfo& other) const
94  {
95  return ( myData < other.myData ||
96  myData == other.myData && myFn < other.myFn );
97  }
98 
99  void* myData;
101  DtTime myInterval;
103 };
104 
107 {
108 public:
110  myData(data), myFn(fn), myInterval(interval), myNextExecutionTime(0) {}
111 
112  bool operator<(const DtTickWithExecCallbackInfo& other) const
113  {
114  return ( myData < other.myData ||
115  myData == other.myData && myFn < other.myFn );
116  }
117 
118  void* myData;
120  DtTime myInterval;
122 };
123 
126 {
127 public:
129  myData(data), myFn(fn) {}
130 
131  bool operator<(const DtLogFileNameCallbackInfo& other) const
132  {
133  return ( myData < other.myData ||
134  myData == other.myData && myFn < other.myFn );
135  }
136 
137  void* myData;
139 };
140 
142 {
143 protected:
144 
147  DtBoost::shared_ptr<DtFilePrinter> logPrinter,
148  bool autoExit,
149  const DtRtiConnectionInfoDataPair& connInfo );
150 
151 public:
152 
154  virtual ~DtRtiExec();
155 
156  virtual void shutdownForwarderIfCreated();
157 
159  virtual void checkVersion(const DtString& version) const;
160 
162  virtual void processCreate(const DtCreateMsg& msg);
163 
165  virtual void processDestroy(const DtDestroyMsg& msg);
166 
168  virtual void processListFederations(const DtListFederationsMsg& msg);
169 
171  virtual void processJoin(const DtJoinMsg& msg);
172 
175  virtual void processDisconnect(const DtDisconnectMsg& msg);
176 
178  virtual void processQueueFull( const DtQueueFullMsg& msg );
179 
182  virtual void processReconnect(const DtReconnectMsg& msg);
183 
187  virtual DtFedExec* createFedEx(
188  DtConnectionMgr* connMgr, const std::vector<unsigned int> & crcs, const char* fedExName,
189  std::string const & timeImplName, MAKRti::DtFomType fedType,
190  const std::vector<DtString>& fedFileName, const DtString& momModuleName,
191  int fedExHandle, DtRIDParameters* params, unsigned int momModuleCrc);
192 
195  DtConnectionMgr* connectMgr();
196 
198  virtual bool exists(const DtString& fedExName);
199 
200 
205  virtual void destroyFederationByName( const DtString& fullFedexName,
206  bool sendDestroyResponse = true,
207  bool forceDestroy = false );
208 
209 
214  int processQuit();
215 
217  virtual void listFederates();
218 
220  virtual void parseDeleteCommand( const DtString& command,
221  unsigned int& handle,
222  DtString& federationName ) const;
223 
224  virtual int deleteFederate( unsigned int handle,
225  const DtString& federationName );
226 
228  virtual void processUpdateNotifyLevel( DtNotifyLevelType level );
229 
231  virtual void exit();
232 
234  virtual void enableLogging();
235 
238  DtFedExec* fedExec(const DtString& fedExName);
239  const DtFedExec* fedExec(const DtString& fedExName) const;
240 
242  const std::map<DtString, DtFedExec*>& fedExecs() const;
243 
245  const DtRIDParameters& params() const;
246 
248  virtual void run();
249 
254  virtual bool tick( bool noCallbacks = false );
255 
257  virtual void wait(DtTime intervalInSeconds);
258 
261  virtual void addFedExCreatedCallback(DtFedExCbFn fn, void* usr);
262  virtual void removeFedExCreatedCallback(DtFedExCbFn fn, void* usr);
263 
266  virtual void addFedExDestroyedCallback(DtFedExCbFn fn, void* usr);
267  virtual void removeFedExDestroyedCallback(DtFedExCbFn fn, void* usr);
268 
271  virtual void addLogFileNameUpdatedCallback(DtLogFileNameCbFn fn, void* usr);
272  virtual void removeLogFileNameUpdatedCallback(DtLogFileNameCbFn fn, void* usr);
273 
276  virtual void addTickCallback(DtTickCbFn fn, void* usr, DtTime interval );
277  virtual void removeTickCallback(DtTickCbFn fn, void* usr );
278 
282  virtual void addTickCallback(DtTickWithExecCbFn fn, void* usr, DtTime interval );
283  virtual void removeTickCallback(DtTickWithExecCbFn fn, void* usr );
284 
286  virtual void sendCreateResponseMsg(const unsigned long destinationID,
287  DtCreateResponseFlag flag, MAKRti::DtString const & errorString);
288  virtual void sendDestroyResponseMsg(
289  const char* fedExName, DtDestroyResponseFlag flag);
290  virtual void sendReportFederationsMsg(unsigned long destId,
291  const std::vector<DtString>& federationNames,
292  const std::vector<DtString>& timeImplNames);
293  virtual void sendJoinResponseMsg(
294  unsigned long destinationIDValue,unsigned short requestID, unsigned int crc,
295  DtFederateHandle handle, const char* fedName, int fedExHandle, const char* fedExName,
296  const DtString& momModule, const std::vector<DtString>& fedFileName,
297  unsigned long flags, bool allowNetworkTesting,
298  MAKRti::DtString const & errorString,
300 
305  virtual void ridRequestCb( const DtRidTestRequestMsg& msg);
306 
307 public:
308 
310  static DtRtiExec* create(DtRIDParameters* p,
311  DtBoost::shared_ptr<DtFilePrinter> logPrinter,
312  bool autoExit = false,
314 
318  static void setCreatorFunction(DtRtiExecCreator fn);
319 
321  static void processRtiExecHandshakeMsg(const DtRtiExecHandshakeMsg& msg,
322  void* usr);
323 
325  static void processCreate(const DtCreateMsg& msg,
326  void *usr);
327 
329  static void processDestroy(const DtDestroyMsg& msg,
330  void* usr);
331 
333  static void processListFederations(const DtListFederationsMsg& msg,
334  void* usr);
335 
337  static void processJoin(const DtJoinMsg& msg,
338  void* usr);
339 
341  static void processDisconnect(const DtDisconnectMsg& msg,
342  void* usr);
343 
345  static void processQueueFull( const DtQueueFullMsg& msg,
346  void* usr);
347 
349  static void processReconnect(const DtReconnectMsg& msg,
350  void* usr);
351 
353  static void ridRequestCb( const DtRidTestRequestMsg& msg, void* usr );
354  static bool shutdownSignalCaught();
355  static void caughtShutdownSignal();
356 
357 protected:
358 
361  void cleanupConstructorException();
362 
365  virtual void rtiExecToForwarderHandshake();
366 
368  virtual void sendRtiExecHandshakeMsg( DtHandle destId, DtRtiExecHandshakeMsg::DtHandshakeStatus status );
369 
371  virtual void processRtiExecHandshakeMsg( const DtRtiExecHandshakeMsg& msg );
372 
374  virtual void performMulticastDiscovery( bool reliableTransportDisabled );
375 
377  virtual void removeDroppedFederateConnections();
378 
380  {
383  ForwarderStartupFailed
384  };
387  virtual DtStartRtiForwarderResult startRtiForwarder(const DtRIDParameters* params);
388 
389 protected:
390 
391  typedef std::map< unsigned long, DtTime > DtConnIdToTimeMap;
393 
395  std::map<DtString, DtFedExec*> myExecByName;
396  std::map<DtFederationHandle, DtFedExec*> myExecByHandle;
397  DtString lineOfInput;
398 
402  unsigned int myHandleForDelete;
403 
410 
412  std::list<DtTickCallbackInfo> myTickCallbacks;
413 
415  std::list<DtTickWithExecCallbackInfo> myTickWithExecCallbacks;
416 
418  std::list<DtLogFileNameCallbackInfo> myLogFileNameCallbacks;
419 
420  DtClock myClock;
423 
426 
428 
433 
436 
439 
441  DtBoost::shared_ptr<DtFilePrinter> myLogPrinter;
442 
444 
445 
446 protected:
447 
449 };
450 
452 {
453  return myConnectionMgr;
454 }
455 
456 inline const DtRIDParameters& DtRtiExec::params() const
457 {
458  return *myParams;
459 }
460 
461 #endif
462 
463 #endif
464 

Document ID: Generated on Fri Mar 14 19:08:55 EDT 2014 from SVN revision 137085
Copyright © 2005-2014 VT MÄK Inc. All Rights Reserved (www.mak.com)