MAK RTIspy API Documentation for HLA 1516
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 recordRecvdMsgStats( const DtRtiMsg& msg, double sendTime );
59 
60  // Record stats for RTI Ambassador and Federate Ambassador API calls and
61  // callbacks
62  virtual void recordApiStats( const DtRtiAmbAPIType callName, double callTime );
63  virtual void recordFedAmbStats( const DtFedAmbAPIType callName, double callTime );
64 
65  // Add newly Registered or Discovered objects to the list
66  virtual void addRegisteredObject( DtObjectInstanceHandle objHandle,
67  DtObjectClassHandle theClass, const char* theObject);
68  virtual void addDiscoveredObject( DtObjectInstanceHandle objHandle,
69  DtObjectClassHandle theClass, const char* theObject);
70 
71  // Add subscribed or published sent and received interactions to the list
72  virtual void addSentInteraction( DtInteractionClassHandle theInteraction );
73  virtual void addRecvdInteraction( DtInteractionClassHandle theInteraction );
74 
75  // Record stats for individual objects and interactions
76  virtual void recordObjectStats( bool isSent, unsigned int msgKind,
77  unsigned int msgSize, double time, const DtRtiMsg& msg );
78  virtual void recordInteractionStats( bool isSent, unsigned int msgKind,
79  unsigned int msgSize, double time, const DtRtiMsg& msg );
80 
81  // Adds object class handles to set if publish, subscribe, transport, or order changes.
82  virtual void changedPubSubTransOrder(DtObjectClassHandle classHandle);
83 
84  // Adds object class handles to set if publish, subscribe, transport, or order changes.
86 
87  // Callback function for generic DtRtiMsgs: records traffic statistics
88  static void processMsg( const DtRtiMsg& msg, void* thisMonitor );
89 
90  // Calback for posttick in FedMgr
91  static void netStatsPostTick(void* instance);
92 
93  // Have the stats changed since the last test? (resets flag)
94  virtual bool isChanged();
95 
96 protected:
97 
98  // Instance local version of the processMsg callback
99  virtual void processMsg( const DtRtiMsg& msg );
100 
101  // Instance local version of the netStatsPostTick callback
102  virtual void netStatsPostTick();
103 
104  static void processNetStatsObserveReqMsg( const DtAssistantNetStatsObserveReqMsg& msg, void* usr );
106 
107  virtual void gatherClassDataAndSend(DtFomClassMgr * fomMgr, DtRtiAssistantLrcClient* rtiAstntLrcClient);
108 
109  virtual void gatherInstanceDataAndSend(DtRtiAssistantLrcClient* rtiAstntLrcClient);
110 
111  virtual void createSerializedTreesAndSend();
112 
113  virtual void recursivelyAddObjects(MAKRti::DtList* objectClasses, MAKRti::DtU32 parentHandle,
114  std::vector<MAKRti::DtU32>& objectClassHandles, std::vector<MAKRti::DtU32>& parentObjectClassHandles,
115  std::vector<MAKRti::DtString>& objectClassNames);
116  void recursivelyAddInteractions(MAKRti::DtList* interactionClasses, MAKRti::DtU32 parentHandle,
117  std::vector<MAKRti::DtU32>& interactionClassHandles, std::vector<MAKRti::DtU32>& parentInteractionClassHandles,
118  std::vector<MAKRti::DtString>& interactionClassNames);
119 
121  void sendAttributeNames();
122  void recursivelyAddAttributes(MAKRti::DtList* objectClasses,
123  std::vector<MAKRti::DtU32>& objectClassHandles, std::vector<MAKRti::DtU32>& attributeHandles,
124  std::vector<MAKRti::DtString>& attributeNames, std::vector<bool>& attributePub,
125  std::vector<bool>& attributeSub, std::vector<DtTransportType>& attributeTransport,
126  std::vector<DtOrderType>& attributeOrder);
127  void recursivelyAddAttributesNames(MAKRti::DtList* objectClasses,
128  std::vector<MAKRti::DtU32>& objectClassHandles, std::vector<MAKRti::DtU32>& attributeHandles,
129  std::vector<MAKRti::DtString>& attributeNames, std::vector<MAKRti::DtU32>& parentClassHandles,
130  std::set<MAKRti::DtString> parentAttributeNames, MAKRti::DtU32 parentClassHandle,
131  std::vector<MAKRti::DtU32>& totalObjectHandles);
132  void sendParameterNames();
133  void recursivelyAddParametersNames(MAKRti::DtList* interactionClasses,
134  std::vector<MAKRti::DtU32>& interactionClassHandles, std::vector<MAKRti::DtU32>& parameterHandles,
135  std::vector<MAKRti::DtString>& parameterNames, std::vector<MAKRti::DtU32>& parentInterHandles,
136  std::set<MAKRti::DtString> parentParametersNames, MAKRti::DtU32 parentInterHandle,
137  std::vector<MAKRti::DtU32>& totalInterHandles);
138  void sendInitAttrState();
139  void recursivelyAddAttrInitState(MAKRti::DtList* objectClasses,
140  std::vector<MAKRti::DtU32>& objectClassHandles, std::vector<MAKRti::DtU32>& attributeHandles,
141  std::vector<bool>& attributePub, std::vector<bool>& attributeSub,
142  std::vector<DtTransportType>& attributeTransport, std::vector<DtOrderType>& attributeOrder,
143  std::vector<bool>& objectPub, std::vector<bool>& objectSub, std::vector<MAKRti::DtU32>& objPubSubHandles);
144 
145  void recursivelyAddParamInitState(MAKRti::DtList* objectClasses,
146  std::vector<MAKRti::DtU32>& objectClassHandles,
147  std::vector<MAKRti::DtU32>& attributeHandles, std::vector<bool>& attributePub,
148  std::vector<bool>& attributeSub, std::vector<DtTransportType>& attributeTransport,
149  std::vector<DtOrderType>& attributeOrder, std::vector<bool>& objectPub,
150  std::vector<bool>& objectSub, std::vector<MAKRti::DtU32>& objPubSubHandles);
151  void sendInitParamState();
153  void sendAttributeState();
154  void sendParameterState();
155 private:
156 
157  // Default ctor, Copy ctor, and Assignment Operator are undefined
159  DtNetStatsMonitor( const DtNetStatsMonitor& orig );
161  MAKRti::DtString getNameFromObject(DtObjectClassInfo * object);
162  MAKRti::DtString getNameFromInteraction(DtInteractionClassInfo * interaction);
163 protected:
164 
165  // LRC's Federate Handle
167 
168  // LRC's RTI Ambassador Implementor
169  DtRtiAmbassadorImplementor* myRtiAmb;
170 
171  // LRC's Fed Amb wrapper which handles stats gathering
172  DtNetStatsFedAmbWrapper* myFedAmbWrap;
173 
174  // LRC's connection manager
176 
177  // Structure to hold all gathered statistics
179 
180  // Has there been an update since the last test?
181  bool myChanged;
182 
183  // Whether or not this is observed
186 
190 
191  // Minimum interval between sending updates (if observed)
192  MAKRti::DtTime interval;
193  MAKRti::DtTime fomInterval;
194 
195  MAKRti::DtClock intervalTimer;
196  MAKRti::DtClock fomIntervalTimer;
197 
198  // LRC's assistant client
200 
203 
204  public:
205 
206  bool isJoined;
207 };
208 
209 
211 {
212  return myNetStats;
213 }
214 #endif // netStatsMonitor_h__
215 

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)