MAK RTIspy API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
netStatsMonitor.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2012 MaK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 #ifndef netStatsMonitor_h__
6 #define netStatsMonitor_h__
7 
8 
9 #include "netStats.h"
10 #include <vlutil/vlFilename.h>
11 #include <vlutil/vlFedTarget.h>
12 
13 // Forward References
14 class DtRtiMsg;
15 class DtRtiAmbassadorImplementor;
16 class DtNetStatsFedAmbWrapper;
17 class DtConnectionMgr;
18 class QtGui;
21 class DtFomClassMgr;
22 class DtObjectClassInfo;
24 
25 //
26 // The DtNetStatsMonitor class records statistics on RTI network
27 // utilization through callbacks from it's connection manager.
28 // It is intended to compliment the LRC console GUI.
29 //
31 {
32 public:
33 
34  // Constructor
35  DtNetStatsMonitor( DtRtiAmbassadorImplementor* rtiAmb, DtNetStatsFedAmbWrapper* fedAmb, DtRtiAssistantLrcClient* assistantClient );
36 
37  // Destructor
38  virtual ~DtNetStatsMonitor();
39 
40  // Sets local Federate ID after successful join
41  virtual void postJoinInit( const DtFederateHandle& fedId );
42 
43  // Get a copy of the current statistics
44  virtual const DtTrafficStats& getNetworkStats() const;
45 
46  // Reset the network statistics
47  virtual void reset();
48 
49  // Print the current state of the statistics
50  // - prints in tab-separated values form
51  virtual void printStats( bool withHeader = false ) const;
52 
53  // Record stats for sent / received message called directly when
54  // not using callback method
55  // NOTE: - if callbacks are enabled, and this method is used,
56  // it will result in msg duplication!
57  virtual void recordSentMsgStats( const DtRtiMsg& msg, double sendTime );
58  virtual void recordSentMsgStats(unsigned int fedId, DtRtiMsgKind msgKind, unsigned int msgSize, double time);
59  virtual void recordSentMsgStats(unsigned int fedId, DtRtiMsgKind msgKind, unsigned int msgSize, double time,
60  DtObjectClassHandle* classHandle, DtObjectInstanceHandle* instanceHandle);
61  virtual void recordSentMsgStats(unsigned int fedId, DtRtiMsgKind msgKind, unsigned int msgSize, double time,
62  DtInteractionClassHandle* classHandle);
63 
64  virtual void recordRecvdMsgStats( const DtRtiMsg& msg, double sendTime, bool joined );
65 
66  // Record stats for RTI Ambassador and Federate Ambassador API calls and
67  // callbacks
68  virtual void recordApiStats( const DtRtiAmbAPIType callName, double callTime );
69  virtual void recordFedAmbStats( const DtFedAmbAPIType callName, double callTime );
70 
71  // Add newly Registered or Discovered objects to the list
72  virtual void addRegisteredObject( DtObjectInstanceHandle objHandle,
73  DtObjectClassHandle theClass, const char* theObject);
74  virtual void addDiscoveredObject( DtObjectInstanceHandle objHandle,
75  DtObjectClassHandle theClass, const char* theObject);
76 
77  // Add subscribed or published sent and received interactions to the list
78  virtual void addSentInteraction( DtInteractionClassHandle theInteraction );
79  virtual void addRecvdInteraction( DtInteractionClassHandle theInteraction );
80 
81  // Record stats for individual objects and interactions
82  virtual void recordObjectStats( bool isSent, unsigned int msgKind,
83  unsigned int msgSize, double time, const DtRtiMsg& msg );
84  virtual void recordObjectStats(DtObjectInstanceHandle* objectInstanceHandle, DtObjectClassHandle* objectClassHandle,
85  bool isSent, unsigned int msgSize, double time);
86 
87  virtual void recordInteractionStats( bool isSent, unsigned int msgKind,
88  unsigned int msgSize, double time, const DtRtiMsg& msg );
89  virtual void recordInteractionStats(DtInteractionClassHandle* handle, bool isSent, unsigned int msgSize, double time);
90 
91  // Adds object class handles to set if publish, subscribe, transport, or order changes.
92  virtual void changedPubSubTransOrder(DtObjectClassHandle classHandle);
93 
94  // Adds object class handles to set if publish, subscribe, transport, or order changes.
96 
97  // Callback function for generic DtRtiMsgs: records traffic statistics
98  static void processMsg( const DtRtiMsg& msg, void* thisMonitor );
99 
100  // Calback for posttick in FedMgr
101  static void netStatsPostTick(void* instance);
102 
103  // Have the stats changed since the last test? (resets flag)
104  virtual bool isChanged();
105 
106 protected:
107 
108  // Instance local version of the processMsg callback
109  virtual void processMsg( const DtRtiMsg& msg );
110 
111  // Instance local version of the netStatsPostTick callback
112  virtual void netStatsPostTick();
113 
114  static void processNetStatsObserveReqMsg( const DtAssistantNetStatsObserveReqMsg& msg, void* usr );
116 
117  virtual void gatherClassDataAndSend(DtFomClassMgr * fomMgr, DtRtiAssistantLrcClient* rtiAstntLrcClient);
118 
119  virtual void gatherInstanceDataAndSend(DtRtiAssistantLrcClient* rtiAstntLrcClient);
120 
121  virtual void createSerializedTreesAndSend();
122 
123  virtual void recursivelyAddObjects(MAKRti::DtList* objectClasses, MAKRti::DtU32 parentHandle,
124  std::vector<MAKRti::DtU32>& objectClassHandles, std::vector<MAKRti::DtU32>& parentObjectClassHandles,
125  std::vector<MAKRti::DtString>& objectClassNames);
126  void recursivelyAddInteractions(MAKRti::DtList* interactionClasses, MAKRti::DtU32 parentHandle,
127  std::vector<MAKRti::DtU32>& interactionClassHandles, std::vector<MAKRti::DtU32>& parentInteractionClassHandles,
128  std::vector<MAKRti::DtString>& interactionClassNames);
129 
131  void sendAttributeNames();
132  void recursivelyAddAttributes(MAKRti::DtList* objectClasses,
133  std::vector<MAKRti::DtU32>& objectClassHandles, std::vector<MAKRti::DtU32>& attributeHandles,
134  std::vector<MAKRti::DtString>& attributeNames, std::vector<bool>& attributePub,
135  std::vector<bool>& attributeSub, std::vector<DtTransportType>& attributeTransport,
136  std::vector<DtOrderType>& attributeOrder);
137  void recursivelyAddAttributesNames(MAKRti::DtList* objectClasses,
138  std::vector<MAKRti::DtU32>& objectClassHandles, std::vector<MAKRti::DtU32>& attributeHandles,
139  std::vector<MAKRti::DtString>& attributeNames, std::vector<MAKRti::DtU32>& parentClassHandles,
140  std::set<MAKRti::DtString> parentAttributeNames, MAKRti::DtU32 parentClassHandle,
141  std::vector<MAKRti::DtU32>& totalObjectHandles);
142  void sendParameterNames();
143  void recursivelyAddParametersNames(MAKRti::DtList* interactionClasses,
144  std::vector<MAKRti::DtU32>& interactionClassHandles, std::vector<MAKRti::DtU32>& parameterHandles,
145  std::vector<MAKRti::DtString>& parameterNames, std::vector<MAKRti::DtU32>& parentInterHandles,
146  std::set<MAKRti::DtString> parentParametersNames, MAKRti::DtU32 parentInterHandle,
147  std::vector<MAKRti::DtU32>& totalInterHandles);
148  void sendInitAttrState();
149  void recursivelyAddAttrInitState(MAKRti::DtList* objectClasses,
150  std::vector<MAKRti::DtU32>& objectClassHandles, std::vector<MAKRti::DtU32>& attributeHandles,
151  std::vector<bool>& attributePub, std::vector<bool>& attributeSub,
152  std::vector<DtTransportType>& attributeTransport, std::vector<DtOrderType>& attributeOrder,
153  std::vector<bool>& objectPub, std::vector<bool>& objectSub, std::vector<MAKRti::DtU32>& objPubSubHandles);
154 
155  void recursivelyAddParamInitState(MAKRti::DtList* objectClasses,
156  std::vector<MAKRti::DtU32>& objectClassHandles,
157  std::vector<MAKRti::DtU32>& attributeHandles, std::vector<bool>& attributePub,
158  std::vector<bool>& attributeSub, std::vector<DtTransportType>& attributeTransport,
159  std::vector<DtOrderType>& attributeOrder, std::vector<bool>& objectPub,
160  std::vector<bool>& objectSub, std::vector<MAKRti::DtU32>& objPubSubHandles);
161  void sendInitParamState();
163  void sendAttributeState();
164  void sendParameterState();
165 private:
166 
167  // Default ctor, Copy ctor, and Assignment Operator are undefined
169  DtNetStatsMonitor( const DtNetStatsMonitor& orig );
171  MAKRti::DtString getNameFromObject(DtObjectClassInfo * object);
172  MAKRti::DtString getNameFromInteraction(DtInteractionClassInfo * interaction);
173 protected:
174 
175  // LRC's Federate Handle
177 
178  // LRC's RTI Ambassador Implementor
179  DtRtiAmbassadorImplementor* myRtiAmb;
180 
181  // LRC's Fed Amb wrapper which handles stats gathering
182  DtNetStatsFedAmbWrapper* myFedAmbWrap;
183 
184  // LRC's connection manager
186 
187  // Structure to hold all gathered statistics
189 
190  // Has there been an update since the last test?
191  bool myChanged;
192 
193  // Whether or not this is observed
196 
200 
201  // Minimum interval between sending updates (if observed)
202  MAKRti::DtTime interval;
203  MAKRti::DtTime fomInterval;
204 
205  MAKRti::DtClock intervalTimer;
206  MAKRti::DtClock fomIntervalTimer;
207 
208  // LRC's assistant client
210 
213 
214  public:
215 
216  bool isJoined;
217 };
218 
219 
221 {
222  return myNetStats;
223 }
224 #endif // netStatsMonitor_h__
225 

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)