MAK RTIspy API Documentation for HLA 1516
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 
76 typedef void (*DtWebServerCbFn)(const DtInetAddr& webSpyIpAddr, int webSpyPort, void* usr);
77 
80 {
81 public:
82  DtFedExCallbackInfo(DtFedExCbFn fn, void* data) :
83  myData(data), myFn(fn) {}
84 
85  void* myData;
87 };
88 
91 {
92 public:
93  DtTickCallbackInfo(DtTickCbFn fn, void* data, DtTime interval) :
94  myData(data), myFn(fn), myInterval(interval), myNextExecutionTime(0) {}
95 
96  bool operator<(const DtTickCallbackInfo& other) const
97  {
98  return ( myData < other.myData ||
99  myData == other.myData && myFn < other.myFn );
100  }
101 
102  void* myData;
104  DtTime myInterval;
106 };
107 
110 {
111 public:
113  myData(data), myFn(fn), myInterval(interval), myNextExecutionTime(0) {}
114 
115  bool operator<(const DtTickWithExecCallbackInfo& other) const
116  {
117  return ( myData < other.myData ||
118  myData == other.myData && myFn < other.myFn );
119  }
120 
121  void* myData;
123  DtTime myInterval;
125 };
126 
129 {
130 public:
132  myData(data), myFn(fn) {}
133 
134  bool operator<(const DtLogFileNameCallbackInfo& other) const
135  {
136  return ( myData < other.myData ||
137  myData == other.myData && myFn < other.myFn );
138  }
139 
140  void* myData;
142 };
143 
146 {
147 public:
149  myData(data), myFn(fn) {}
150 
151  bool operator<(const DtWebServerCallbackInfo& other) const
152  {
153  return ( myData < other.myData ||
154  myData == other.myData && myFn < other.myFn );
155  }
156 
157  void* myData;
159 };
160 
162 {
163 protected:
164 
167  DtBoost::shared_ptr<DtFilePrinter> logPrinter,
168  bool autoExit,
169  const DtRtiConnectionInfoDataPair& connInfo );
170 
171 public:
172 
174  virtual ~DtRtiExec();
175 
176  virtual void shutdownForwarderIfCreated();
177 
179  virtual void checkVersion(const DtString& version) const;
180 
182  virtual void processCreate(const DtCreateMsg& msg);
183 
185  virtual void processDestroy(const DtDestroyMsg& msg);
186 
188  virtual void processListFederations(const DtListFederationsMsg& msg);
189 
191  virtual void processJoin(const DtJoinMsg& msg);
192 
195  virtual void processDisconnect(const DtDisconnectMsg& msg);
196 
198  virtual void processQueueFull( const DtQueueFullMsg& msg );
199 
202  virtual void processReconnect(const DtReconnectMsg& msg);
203 
207  virtual DtFedExec* createFedEx(
208  DtConnectionMgr* connMgr, const std::vector<unsigned int> & crcs, const char* fedExName,
209  std::string const & timeImplName, MAKRti::DtFomType fedType,
210  const std::vector<DtString>& fedFileName, const DtString& momModuleName,
211  int fedExHandle, DtRIDParameters* params, unsigned int momModuleCrc);
212 
215  DtConnectionMgr* connectMgr();
216 
218  virtual bool exists(const DtString& fedExName);
219 
220 
225  virtual void destroyFederationByName( const DtString& fullFedexName,
226  bool sendDestroyResponse = true,
227  bool forceDestroy = false );
228 
229 
234  int processQuit();
235 
237  virtual void listFederates();
238 
240  virtual void parseDeleteCommand( const DtString& command,
241  unsigned int& handle,
242  DtString& federationName ) const;
243 
244  virtual int deleteFederate( unsigned int handle,
245  const DtString& federationName );
246 
248  virtual void processUpdateNotifyLevel( DtNotifyLevelType level );
249 
251  virtual void exit();
252 
254  virtual void enableLogging();
255 
257  virtual void enableWebSpy( const DtInetAddr& webSpyIpAddr, int webSpyPort );
258 
259 
262  DtFedExec* fedExec(const DtString& fedExName);
263  const DtFedExec* fedExec(const DtString& fedExName) const;
264 
266  const std::map<DtString, DtFedExec*>& fedExecs() const;
267 
269  const DtRIDParameters& params() const;
270 
272  virtual void run();
273 
278  virtual bool tick( bool noCallbacks = false );
279 
281  virtual void wait(DtTime intervalInSeconds);
282 
285  virtual void addFedExCreatedCallback(DtFedExCbFn fn, void* usr);
286  virtual void removeFedExCreatedCallback(DtFedExCbFn fn, void* usr);
287 
290  virtual void addFedExDestroyedCallback(DtFedExCbFn fn, void* usr);
291  virtual void removeFedExDestroyedCallback(DtFedExCbFn fn, void* usr);
292 
295  virtual void addLogFileNameUpdatedCallback(DtLogFileNameCbFn fn, void* usr);
296  virtual void removeLogFileNameUpdatedCallback(DtLogFileNameCbFn fn, void* usr);
297 
300  virtual void addWebServerUpdatedCallback(DtWebServerCbFn fn, void* usr);
301  virtual void removeWebServerUpdatedCallback(DtWebServerCbFn fn, void* usr);
302 
305  virtual void addTickCallback(DtTickCbFn fn, void* usr, DtTime interval );
306  virtual void removeTickCallback(DtTickCbFn fn, void* usr );
307 
311  virtual void addTickCallback(DtTickWithExecCbFn fn, void* usr, DtTime interval );
312  virtual void removeTickCallback(DtTickWithExecCbFn fn, void* usr );
313 
315  virtual void sendCreateResponseMsg(const unsigned long destinationID,
316  DtCreateResponseFlag flag, MAKRti::DtString const & errorString);
317  virtual void sendDestroyResponseMsg(
318  const char* fedExName, DtDestroyResponseFlag flag);
319  virtual void sendReportFederationsMsg(unsigned long destId,
320  const std::vector<DtString>& federationNames,
321  const std::vector<DtString>& timeImplNames);
322  virtual void sendJoinResponseMsg(
323  unsigned long destinationIDValue,unsigned short requestID, unsigned int crc,
324  DtFederateHandle handle, const char* fedName, int fedExHandle, const char* fedExName,
325  const DtString& momModule, const std::vector<DtString>& fedFileName,
326  unsigned long flags, bool allowNetworkTesting,
327  MAKRti::DtString const & errorString,
329 
334  virtual void ridRequestCb( const DtRidTestRequestMsg& msg);
335 
336 public:
337 
339  static DtRtiExec* create(DtRIDParameters* p,
340  DtBoost::shared_ptr<DtFilePrinter> logPrinter,
341  bool autoExit = false,
343 
347  static void setCreatorFunction(DtRtiExecCreator fn);
348 
350  static void processRtiExecHandshakeMsg(const DtRtiExecHandshakeMsg& msg,
351  void* usr);
352 
354  static void processCreate(const DtCreateMsg& msg,
355  void *usr);
356 
358  static void processDestroy(const DtDestroyMsg& msg,
359  void* usr);
360 
362  static void processListFederations(const DtListFederationsMsg& msg,
363  void* usr);
364 
366  static void processJoin(const DtJoinMsg& msg,
367  void* usr);
368 
370  static void processDisconnect(const DtDisconnectMsg& msg,
371  void* usr);
372 
374  static void processQueueFull( const DtQueueFullMsg& msg,
375  void* usr);
376 
378  static void processReconnect(const DtReconnectMsg& msg,
379  void* usr);
380 
382  static void ridRequestCb( const DtRidTestRequestMsg& msg, void* usr );
383  static bool shutdownSignalCaught();
384  static void caughtShutdownSignal();
385 
386 protected:
387 
390  void cleanupConstructorException();
391 
394  virtual void rtiExecToForwarderHandshake();
395 
397  virtual void sendRtiExecHandshakeMsg( DtHandle destId, DtRtiExecHandshakeMsg::DtHandshakeStatus status );
398 
400  virtual void processRtiExecHandshakeMsg( const DtRtiExecHandshakeMsg& msg );
401 
403  virtual void performMulticastDiscovery( bool reliableTransportDisabled );
404 
406  virtual void removeDroppedFederateConnections();
407 
409  {
412  ForwarderStartupFailed
413  };
416  virtual DtStartRtiForwarderResult startRtiForwarder(const DtRIDParameters* params);
417 
418 protected:
419 
420  typedef std::map< unsigned long, DtTime > DtConnIdToTimeMap;
422 
424  std::map<DtString, DtFedExec*> myExecByName;
425  std::map<DtFederationHandle, DtFedExec*> myExecByHandle;
426  DtString lineOfInput;
427 
431  unsigned int myHandleForDelete;
432 
439 
441  std::list<DtTickCallbackInfo> myTickCallbacks;
442 
444  std::list<DtTickWithExecCallbackInfo> myTickWithExecCallbacks;
445 
447  std::list<DtLogFileNameCallbackInfo> myLogFileNameCallbacks;
448 
450  std::list<DtWebServerCallbackInfo> myWebServerCallbacks;
451 
452  DtClock myClock;
455 
458 
460 
465 
468 
471 
473  DtBoost::shared_ptr<DtFilePrinter> myLogPrinter;
474 
476 
477 
478 protected:
479 
481 };
482 
484 {
485  return myConnectionMgr;
486 }
487 
488 inline const DtRIDParameters& DtRtiExec::params() const
489 {
490  return *myParams;
491 }
492 
493 #endif
494 
495 #endif
496 

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)