MAK RTIspy API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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( double 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( DtNotifyLevelType notifyLevel, int compId,
137  const DtAssistantInfo& destination );
138 
141  virtual void sendObserveRtiForwarderMsg( const DtRtiConnectionInfo& conn,
142  bool observe, const DtAssistantInfo& assistant, int compId );
143 
146  virtual void sendFederationStateMsg( const DtRtiConnectionInfoDataPair& conn,
147  const DtAssistantFederationInfo& federation, bool isRemoval );
148 
151  virtual void sendNoFederationMsg( const DtRtiConnectionInfoDataPair& conn );
152 
155  virtual void sendFederateResignMsg( const DtAssistantInfo& assistant,
156  int compId, int federationHdl, int federateHdl );
157 
160  virtual void sendFederationDestroyMsg( const DtAssistantInfo& assistant,
161  int compId, int federationHdl );
162 
165  virtual void sendRidParamsRequestMsg( const DtAssistantInfo& assistant,
166  int compId );
167 
171  virtual void sendLogRequestMsg( const DtAssistantInfo& assistant,
172  int compId, unsigned maxLogSize );
173 
176  virtual bool sendLatencyTestRequestMsg( const DtAssistantInfo& assistant,
177  int compId, int federationHdl, int federateHdl, bool runTest,
178  bool continuous, bool shouldHalt, bool observing,
179  unsigned int interactionPeriod, unsigned int numInteractions,
180  unsigned int payloadBytes );
181 
184  virtual void sendNetworkTestEnableMsg( const DtAssistantInfo& assistant,
185  int compId, int federationHdl, bool enable );
186 
189  virtual void sendRtiexecExitMsg( const DtAssistantInfo& assistant,
190  int compId );
191 
194  virtual void sendNotifyObserveMsg(bool isObserving);
195 
197  virtual void sendNotifyMsg(const MAKRti::DtString& text,
198  DtNotifyLevelType notifyLevel, const MAKRti::DtString& sourceName );
199 
202  virtual void sendRemovalMsg();
203 
207  virtual void sendFederateInfoReqMsg(const DtAssistantInfo& astnt,
208  const DtRtiConnectionInfo& conn,
209  const MAKRti::DtString& federation = MAKRti::DtString::nullString(),
210  unsigned federateHandle = 0 );
211 
214  virtual void sendFederateInfoRespMsg(const DtRtiConnectionInfo& conn,
215  std::vector<const DtAssistantFederateInfo*> federates);
216 
217 
220  virtual void sendNetStatsObservationRequestMsg(const DtAssistantInfo& astnt, DtAssistantObservationType observationType,
221  int compId, bool observe = false, unsigned int interval = 0);
222 
223  virtual void sendNetStatsObservationResponseMsg(const DtAssistantInfo& astnt, DtAssistantObservationType observationType,
224  int compId, bool observe);
225 
226  virtual void sendNetStatsStringUpdateReqMsg(const DtAssistantInfo& assistant, int compId,
227  DtAssistantHandleType handletype, const std::set<DtU32>& handles);
228 
229  virtual void sendNetStatsStringUpdate(const DtAssistantInfo& assistant, int compId,
230  DtAssistantHandleType handletype, const std::vector<DtU32>& objectInstanceHandles,
231  const std::vector<MAKRti::DtString>& objectInstanceNames);
232 
233  virtual void forwardNetStatsUpdate(const DtAssistantMsg &msg, const std::set<DtAssistantInfo>& observers);
234 
235  virtual void sendFedDisconnectNetStatsObsRespMsg(DtAssistantObservationType observationType,
236  int compId, const std::set<DtAssistantInfo>& observers);
237 
238  virtual void sendNetStatsInitStateRequestMsg(const DtAssistantInfo& astnt,
239  DtAssistantObservationType observationType, int compId);
240 
241  virtual void sendFomTreeData(const DtAssistantInfo& astnt,
242  int compId, const std::vector<MAKRti::DtU32>& objectClassHandles,
243  const std::vector<MAKRti::DtU32>& parentObjectClassHandles,
244  const std::vector<MAKRti::DtString>& objectClassNames,
245  const std::vector<MAKRti::DtU32>& interactionClassHandles,
246  const std::vector<MAKRti::DtU32>& parentInteractionClassHandles,
247  const std::vector<MAKRti::DtString>& interactionClassNames);
248 
249  virtual void sendNetStatsAttrStringUpdate(const DtAssistantInfo& astnt,
250  int compId, const std::vector<MAKRti::DtU32>& objectClassHandles,
251  const std::vector<MAKRti::DtU32>& attributeHandles,
252  const std::vector<MAKRti::DtString>& attributeNames,
253  const std::vector<MAKRti::DtU32>& parentClassHandles,
254  const std::vector<MAKRti::DtU32>& totalObjHandles);
255  virtual void sendNetStatsParamStringUpdate(const DtAssistantInfo& astnt,
256  int compId, const std::vector<MAKRti::DtU32>& interClassHandles,
257  const std::vector<MAKRti::DtU32>& parameterHandles,
258  const std::vector<MAKRti::DtString>& parameterNames,
259  const std::vector<MAKRti::DtU32>& parentInterHandles,
260  const std::vector<MAKRti::DtU32>& totalInterHandles);
261  virtual void sendNetStatsAttrParamStringUpdate(const DtAssistantInfo& astnt,
262  int compId, const std::vector<MAKRti::DtU32>& objectClassHandles,
263  const std::vector<MAKRti::DtU32>& attributeHandles,
264  const std::vector<MAKRti::DtString>& attributeNames,
265  const std::vector<MAKRti::DtU32>& parentClassHandles,
266  const std::vector<MAKRti::DtU32>& totalObjHandles,
267  DtAssistantHandleType objInterType, DtAssistantHandleType attrParamType,
268  DtAssistantHandleType parentClassType );
269  virtual void sendNetStatsFomAttrParamUpdate(const DtAssistantInfo& astnt,
270  int compId, DtAssistantHandleType handleType, bool isInit,
271  const std::vector<MAKRti::DtU32>& objectClassHandles,
272  const std::vector<MAKRti::DtU32>& attributeHandles,
273  const std::vector<bool>& attributePub,
274  const std::vector<bool>& attributeSub,
275  const std::vector<DtTransportType>& attributeTransport,
276  const std::vector<DtOrderType>& attributeOrder,
277  const std::vector<bool>& objectPub, const std::vector<bool>& objectSub,
278  const std::vector<MAKRti::DtU32>& objPubSubHandles );
279 
284  virtual void forwardMsg( const DtAssistantMsg& msg, int astntCompId,
285  const DtAssistantInfo& dest = DtAssistantInfo() );
286 
288  virtual int port() const;
289 
292  virtual MAKRti::DtInetAddr ipv4Address() const;
293 
296  virtual MAKRti::DtInetAddr ipv6Address() const;
297 
299  virtual int id() const;
300 
303  virtual const MAKRti::DtInetAddr& currentNetworkInterfaceAddr() const;
304 
306  virtual void getMsgStats( unsigned& totalRecv, double& recvPerSecOverall,
307  double& recvPerSecCurr, unsigned& totalProc, double& procPerSecOverall,
308  double& procPerSecCurr, unsigned& totalSent, double& sentPerSecOverall,
309  double& sentPerSecCurr );
310 
312  virtual DtU32 maxMsgSize() const;
313 
315  void sendMsgToAssistant( const DtAssistantInfo& ifAddr,
316  DtAssistantMsg& msg );
317 
318 #ifdef DtDIAGNOSTIC
319 
320  void enableMsgDiagnostics( bool enable );
321 
322 #endif
323 
324 protected:
325 
329  bool needsProcessing( const DtAssistantMsg& msg );
330 
333  bool addSocketsForInterfaces();
334 
336  bool readAndProcess( DtTime maxTime );
337 
339  void calculateMsgStatistics();
340 
343  void sendMsgOnInterface( const MAKRti::DtInetAddr& ifAddr,
344  DtAssistantMsg& msg );
345 
347  void sendMsg( std::map< MAKRti::DtInetAddr, DtUdpMsgSocket*>::iterator sockIter, DtAssistantMsg& msg );
348 
350  void sendMsgToAll( DtAssistantMsg& msg );
351 
353  std::auto_ptr<DtAssistantMsg> netRead( DtUdpMsgSocket* sock, int *retCode ) const;
354 public:
355 
357 
358 protected:
359 
361  int myPort;
362 
364  MAKRti::DtInetAddr myIpv4Addr;
365 
367  MAKRti::DtInetAddr myIpv6Addr;
368 
370  int myTtl;
371 
374  int myId;
375 
378  std::map< MAKRti::DtInetAddr, DtUdpMsgSocket*> mySockets;
379 
382  std::map< MAKRti::DtInetAddr, DtUdpMsgSocket*>::iterator mySocketIter;
383 
386  MAKRti::DtInetAddr myCurrNetworkInterfaceAddr;
387 
390 
392  DtAssistantMessageFactory* myMessageFactory;
393 
395  DtAssistantDfltMsgFactory myDefaultMessageFactory;
396 
398  DtClock myClock;
399 
401  DtTime myNextCheckInterfacesTime;
402 
404  DtTime myCheckInterfacesInterval;
405 
407  DtTime myBeginProcessingTime;
408 
410  DtTime myNextStatsTime;
411 
413  DtTime myLastStatsTime;
414 
416  {
417  DtPeerMsgStats() :
418  numMsgsCurrPeriod(0), numMsgsTotal(0),
419  msgsPerSecLastPeriod(0), msgsPerSecOverall(0) {}
420 
422  unsigned numMsgsTotal;
425  };
426 
429 
432 
435 
437  std::list<DtInterfaceFoundCbInfo> myInterfaceFoundCallbacks;
438 
440  static const DtTime theStatisticsInterval;
441 
444 
447 
448 #ifdef DtDIAGNOSTIC
449  bool myDiagnosticsEnabled;
450 #endif
451 };
452 
453 
454 #endif // rtiAssistantPeer_H_

Document ID: Generated on Mon Mar 21 09:41:37 EDT 2016 from SVN revision 163228
Copyright © 2005-2015 VT MÄK Inc. All Rights Reserved (www.mak.com)