MAK RTIspy API Documentation for HLA Evolved
rtiAssistantPeer.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2008 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: rtiAssistantPeer.h,v $ $Revision: 1.51 $ $State: Exp $
7 *********************************************************************/
8 
9 #ifndef rtiAssistantPeer_H_
10 #define rtiAssistantPeer_H_
11 
14 
15 #include <rtiUtil.h>
16 #include <rtiVersion.h>
17 #include <vlutil/vlUtil.h>
18 #include <vlutil/vlTime.h>
19 #include <vlutil/vlPrint.h>
20 #include <vlutil/vlSmartPointers.h>
21 
23 #include "assistantMsgCbMgr.h"
24 #include "assistantLicServerInfo.h"
26 #include "assistantConnMsg.h"
28 #include "rtiAssistantClient.h"
29 #include "assistantInfo.h"
30 #include "assistantInfoMsg.h"
32 #include "assistantNetStatsEnums.h"
33 
35 class DtAssistantInfoMsg;
38 class DtAssistantConfig;
41 class DtUdpMsgSocket;
43 
44 typedef void (*DtInterfaceFoundCb)( void* );
45 
46 #define DtCbInfoStruct( cbType ) \
47 struct cbType##Info \
48 { \
49  cbType##Info( cbType cb, void* usr ) : \
50  myCb(cb), \
51  myUsr(usr) \
52  { }; \
53  cbType myCb; \
54  void* myUsr; \
55 };
56 
57 
61 {
62 public:
64  DtRtiAssistantPeer( int id, int port = DtASSISTANT_DEFAULT_PORT,
65  const MAKRti::DtInetAddr& ipv4Addr = DtASSISTANT_DEFAULT_IPV4_ADDR,
66  const MAKRti::DtInetAddr& ipv6Addr = DtASSISTANT_DEFAULT_IPV6_ADDR,
67  int ttl = DtASSISTANT_DEFAULT_TTL );
68 
70  virtual ~DtRtiAssistantPeer();
71 
74  virtual bool tick( unsigned int timeout = 0 );
75 
77  virtual void setMsgFactory(DtAssistantMessageFactory* fact);
78 
80  virtual DtAssistantMessageFactory* msgFactory() const;
81 
83 
84 
85  virtual void addMsgCallback(DtAssistantMsgKind msgKind, DtAssistantMsgCbMgr::DtCallbackFcn fcn,
86  void *usr );
87  virtual void removeMsgCallback(DtAssistantMsgKind msgKind, DtAssistantMsgCbMgr::DtCallbackFcn fcn,
88  void *usr );
89 
92  virtual void addInterfaceFoundCallback( DtInterfaceFoundCb cb,
93  void* usr );
94  virtual void removeInterfaceFoundCallback( DtInterfaceFoundCb cb,
95  void* usr );
96 
98 
100  virtual void sendQueryMsg();
101 
104  virtual void sendInfoMsg( const DtRtiConnectionAndConfiguration& connsAndConfigs,
105  unsigned memoryPeriod, bool acceptRemoteCommands, bool removal);
106 
109  virtual void sendLightweightInfoMsg( const DtRtiConnectionAndConfiguration& connsAndConfigs,
110  unsigned memoryPeriod);
111 
114  virtual void sendLicServerInfoMsg( const DtLicServerSet& licServers,
115  bool removal);
116 
119  virtual void sendStartRtiexecMsg( const DtRtiConnectionInfoDataPair& conn,
120  const DtRtiConnectionConfigurationInfo& config );
121 
125  virtual void sendObserveFederationsMsg( const DtRtiConnectionInfo& conn,
126  bool observe, const DtAssistantInfo& assistant = DtAssistantInfo(),
127  int compId = -1 );
128 
131  virtual void sendObserveRtiExecLogMsg( const DtAssistantInfo& assistant,
132  int compId, bool observe );
133 
136  virtual void sendObserveRtiexecRspMsg( const MAKRti::DtInetAddr& webSpyAddr,
137  int webSpyPort, DtNotifyLevelType notifyLevel, int compId,
138  const DtAssistantInfo& destination );
139 
142  virtual void sendObserveRtiForwarderMsg( const DtRtiConnectionInfo& conn,
143  bool observe, const DtAssistantInfo& assistant, int compId );
144 
147  virtual void sendFederationStateMsg( const DtRtiConnectionInfoDataPair& conn,
148  const DtAssistantFederationInfo& federation, bool isRemoval );
149 
152  virtual void sendNoFederationMsg( const DtRtiConnectionInfoDataPair& conn );
153 
156  virtual void sendFederateResignMsg( const DtAssistantInfo& assistant,
157  int compId, int federationHdl, int federateHdl );
158 
161  virtual void sendFederationDestroyMsg( const DtAssistantInfo& assistant,
162  int compId, int federationHdl );
163 
166  virtual void sendRidParamsRequestMsg( const DtAssistantInfo& assistant,
167  int compId );
168 
172  virtual void sendLogRequestMsg( const DtAssistantInfo& assistant,
173  int compId, unsigned maxLogSize );
174 
177  virtual bool sendLatencyTestRequestMsg( const DtAssistantInfo& assistant,
178  int compId, int federationHdl, int federateHdl, bool runTest,
179  bool continuous, bool shouldHalt, bool observing,
180  unsigned int interactionPeriod, unsigned int numInteractions,
181  unsigned int payloadBytes );
182 
185  virtual void sendNetworkTestEnableMsg( const DtAssistantInfo& assistant,
186  int compId, int federationHdl, bool enable );
187 
190  virtual void sendRtiexecExitMsg( const DtAssistantInfo& assistant,
191  int compId );
192 
195  virtual void sendNotifyObserveMsg(bool isObserving);
196 
198  virtual void sendNotifyMsg(const MAKRti::DtString& text,
199  DtNotifyLevelType notifyLevel, const MAKRti::DtString& sourceName );
200 
203  virtual void sendRemovalMsg();
204 
208  virtual void sendFederateInfoReqMsg(const DtAssistantInfo& astnt,
209  const DtRtiConnectionInfo& conn,
210  const MAKRti::DtString& federation = MAKRti::DtString::nullString(),
211  unsigned federateHandle = 0 );
212 
215  virtual void sendFederateInfoRespMsg(const DtRtiConnectionInfo& conn,
216  std::vector<const DtAssistantFederateInfo*> federates);
217 
218 
221  virtual void sendNetStatsObservationRequestMsg(const DtAssistantInfo& astnt, DtAssistantObservationType observationType,
222  int compId, bool observe = false, unsigned int interval = 0);
223 
224  virtual void sendNetStatsObservationResponseMsg(const DtAssistantInfo& astnt, DtAssistantObservationType observationType,
225  int compId, bool observe);
226 
227  virtual void sendNetStatsStringUpdateReqMsg(const DtAssistantInfo& assistant, int compId,
228  DtAssistantHandleType handletype, const std::set<DtU32>& handles);
229 
230  virtual void sendNetStatsStringUpdate(const DtAssistantInfo& assistant, int compId,
231  DtAssistantHandleType handletype, const std::vector<DtU32>& objectInstanceHandles,
232  const std::vector<MAKRti::DtString>& objectInstanceNames);
233 
234  virtual void forwardNetStatsUpdate(const DtAssistantMsg &msg, const std::set<DtAssistantInfo>& observers);
235 
236  virtual void sendFedDisconnectNetStatsObsRespMsg(DtAssistantObservationType observationType,
237  int compId, const std::set<DtAssistantInfo>& observers);
238 
239  virtual void sendNetStatsInitStateRequestMsg(const DtAssistantInfo& astnt,
240  DtAssistantObservationType observationType, int compId);
241 
242  virtual void sendFomTreeData(const DtAssistantInfo& astnt,
243  int compId, const std::vector<MAKRti::DtU32>& objectClassHandles,
244  const std::vector<MAKRti::DtU32>& parentObjectClassHandles,
245  const std::vector<MAKRti::DtString>& objectClassNames,
246  const std::vector<MAKRti::DtU32>& interactionClassHandles,
247  const std::vector<MAKRti::DtU32>& parentInteractionClassHandles,
248  const std::vector<MAKRti::DtString>& interactionClassNames);
249 
250  virtual void sendNetStatsAttrStringUpdate(const DtAssistantInfo& astnt,
251  int compId, const std::vector<MAKRti::DtU32>& objectClassHandles,
252  const std::vector<MAKRti::DtU32>& attributeHandles,
253  const std::vector<MAKRti::DtString>& attributeNames,
254  const std::vector<MAKRti::DtU32>& parentClassHandles,
255  const std::vector<MAKRti::DtU32>& totalObjHandles);
256  virtual void sendNetStatsParamStringUpdate(const DtAssistantInfo& astnt,
257  int compId, const std::vector<MAKRti::DtU32>& interClassHandles,
258  const std::vector<MAKRti::DtU32>& parameterHandles,
259  const std::vector<MAKRti::DtString>& parameterNames,
260  const std::vector<MAKRti::DtU32>& parentInterHandles,
261  const std::vector<MAKRti::DtU32>& totalInterHandles);
262  virtual void sendNetStatsAttrParamStringUpdate(const DtAssistantInfo& astnt,
263  int compId, const std::vector<MAKRti::DtU32>& objectClassHandles,
264  const std::vector<MAKRti::DtU32>& attributeHandles,
265  const std::vector<MAKRti::DtString>& attributeNames,
266  const std::vector<MAKRti::DtU32>& parentClassHandles,
267  const std::vector<MAKRti::DtU32>& totalObjHandles,
268  DtAssistantHandleType objInterType, DtAssistantHandleType attrParamType,
269  DtAssistantHandleType parentClassType );
270  virtual void sendNetStatsFomAttrParamUpdate(const DtAssistantInfo& astnt,
271  int compId, DtAssistantHandleType handleType, bool isInit,
272  const std::vector<MAKRti::DtU32>& objectClassHandles,
273  const std::vector<MAKRti::DtU32>& attributeHandles,
274  const std::vector<bool>& attributePub,
275  const std::vector<bool>& attributeSub,
276  const std::vector<DtTransportType>& attributeTransport,
277  const std::vector<DtOrderType>& attributeOrder,
278  const std::vector<bool>& objectPub, const std::vector<bool>& objectSub,
279  const std::vector<MAKRti::DtU32>& objPubSubHandles );
280 
285  virtual void forwardMsg( const DtAssistantMsg& msg, int astntCompId,
286  const DtAssistantInfo& dest = DtAssistantInfo() );
287 
289  virtual int port() const;
290 
293  virtual MAKRti::DtInetAddr ipv4Address() const;
294 
297  virtual MAKRti::DtInetAddr ipv6Address() const;
298 
300  virtual int id() const;
301 
304  virtual const MAKRti::DtInetAddr& currentNetworkInterfaceAddr() const;
305 
307  virtual void getMsgStats( unsigned& totalRecv, double& recvPerSecOverall,
308  double& recvPerSecCurr, unsigned& totalProc, double& procPerSecOverall,
309  double& procPerSecCurr, unsigned& totalSent, double& sentPerSecOverall,
310  double& sentPerSecCurr );
311 
313  virtual DtU32 maxMsgSize() const;
314 
316  void sendMsgToAssistant( const DtAssistantInfo& ifAddr,
317  DtAssistantMsg& msg );
318 
319 #ifdef DtDIAGNOSTIC
320 
321  void enableMsgDiagnostics( bool enable );
322 
323 #endif
324 
325 protected:
326 
330  bool needsProcessing( const DtAssistantMsg& msg );
331 
334  bool addSocketsForInterfaces();
335 
337  bool readAndProcess( DtTime maxTime );
338 
340  void calculateMsgStatistics();
341 
344  void sendMsgOnInterface( const MAKRti::DtInetAddr& ifAddr,
345  DtAssistantMsg& msg );
346 
348  void sendMsg( std::map< MAKRti::DtInetAddr, DtUdpMsgSocket*>::iterator sockIter, DtAssistantMsg& msg );
349 
351  void sendMsgToAll( DtAssistantMsg& msg );
352 
354  std::auto_ptr<DtAssistantMsg> netRead( DtUdpMsgSocket* sock, int *retCode ) const;
355 public:
356 
358 
359 protected:
360 
362  int myPort;
363 
365  MAKRti::DtInetAddr myIpv4Addr;
366 
368  MAKRti::DtInetAddr myIpv6Addr;
369 
371  int myTtl;
372 
375  int myId;
376 
379  std::map< MAKRti::DtInetAddr, DtUdpMsgSocket*> mySockets;
380 
383  std::map< MAKRti::DtInetAddr, DtUdpMsgSocket*>::iterator mySocketIter;
384 
387  MAKRti::DtInetAddr myCurrNetworkInterfaceAddr;
388 
391 
393  DtAssistantMessageFactory* myMessageFactory;
394 
396  DtAssistantDfltMsgFactory myDefaultMessageFactory;
397 
399  DtClock myClock;
400 
402  DtTime myNextCheckInterfacesTime;
403 
405  DtTime myCheckInterfacesInterval;
406 
408  DtTime myBeginProcessingTime;
409 
411  DtTime myNextStatsTime;
412 
414  DtTime myLastStatsTime;
415 
417  {
418  DtPeerMsgStats() :
419  numMsgsCurrPeriod(0), numMsgsTotal(0),
420  msgsPerSecLastPeriod(0), msgsPerSecOverall(0) {}
421 
423  unsigned numMsgsTotal;
426  };
427 
430 
433 
436 
438  std::list<DtInterfaceFoundCbInfo> myInterfaceFoundCallbacks;
439 
441  static const DtTime theStatisticsInterval;
442 
445 
448 
449 #ifdef DtDIAGNOSTIC
450  bool myDiagnosticsEnabled;
451 #endif
452 };
453 
454 
455 #endif // rtiAssistantPeer_H_

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)