VR-Forces 4.1 Class Documentation
hTimeMgmtControl.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2006 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: hTimeMgmtControl.h,v $ $Revision: 1.5 $ $State: Exp $
7 *******************************************************************************/
8 
9 // \file hTimeMgmtControl.h
10 // \brief DtHlaTimeManagementControl provides controls for enabling/disabling
11 // HLA time constrained/time regulating mode, and the means to advance federate
12 // (logical) time.
13 
14 #ifndef hTimeMgmtControl_H_
15 #define hTimeMgmtControl_H_
16 
17 #if DtHLA
18 
19 #if !DtHLA_1516
20 #include "fedtime.hh"
21 #include <vl/vrlRtiAmb13.h>
22 #else
23 #if DtHLA_1516_EVOLVED
24  #include "RTI/LogicalTime.h"
25  #include "RTI/LogicalTimeInterval.h"
26  #include "RTI/RTIambassador.h"
27 #else
28  #include "RTI/LogicalTime.h"
29  #include "RTI/logicalTimeImpl.h"
30  #include "RTI/logicalTimeIntervalImpl.h"
31  #include "RTI/RTIambassador.h"
32 #endif
33 #endif
34 #include <vl/hExerciseConn.h>
35 #include <vl/vrlFedAmb.h>
37 #include <list>
38 
40 
41 // Signature for time advance grant callback functions.
43  void* usr);
44 
46 {
48  void* usr;
50 
51 
52 // DtHlaTimeManagementControl provides controls for enabling/disabling
53 // the HLA Time Management time-constrained mode for a federate.
55 {
56 public:
57 
58  // constructor
59  DtHlaTimeManagementControl(DtExerciseConn& exConn);
60 
61  // destructor
62  virtual ~DtHlaTimeManagementControl();
63 
64  // -------------------------------------------------------------------------
65  // Time Constrained Interface-----------------------------------------------
66  // -------------------------------------------------------------------------
67 
68  // Enables HLA time constrained mode for the federate. You must call
69  // this before making any calls to advanceFedTime(). This call will repeatedly
70  // call drainInput on the exConn until time constrained status is granted.
71  virtual bool enableTimeConstrained();
72 
73  // Disable HLA time constrained mode. Federate is free to advance time
74  // indepenedent of the federation. This call will repeatedly
75  // call drainInput on the exConn until time constrained status is disabled.
76  virtual bool disableTimeConstrained();
77 
78  // Is federate currently time constrained?
79  virtual bool isTimeConstrained() const;
80 
81  // -------------------------------------------------------------------------
82  // Time Regulating Interface------------------------------------------------
83  // -------------------------------------------------------------------------
84 
85  // Enable time regulating mode.
86  // \param exerciseConn
87  // \param lookaheadInterval Time interval when added to current logical
88  // time represents the earliest time the federate will send out any
89  // TSO (time stamp ordered) events.
90 #if !DtHLA_1516
91  virtual bool enableTimeRegulation(
92  const RTI::FedTime& requestedFederationTime,
93  const RTI::FedTime& lookahead,
94  RTI::FedTime& federationTime);
95 #else
96  virtual bool enableTimeRegulation(
97  const RTI::LogicalTime& requestedFederationTime,
98  const RTI::LogicalTimeInterval& lookahead,
99  RTI::LogicalTime& federationTime);
100 #endif
101 
102  // Set new value for lookahead (assuming time regulating mode is already
103  // enabled) and returns true. Otherwise prints warning and returns false.
104 #if !DtHLA_1516
105  virtual bool modifyLookahead(
106  const RTI::FedTime& lookahead);
107 #else
108  virtual bool modifyLookahead(
109  const RTI::LogicalTimeInterval& lookahead);
110 #endif
111 
112  // Disable time regulating mode.
113  virtual bool disableTimeRegulation();
114 
115  // \return Is this federate in time regulating mode?
116  virtual bool isTimeRegulating() const;
117 
118  // -------------------------------------------------------------------------
119  // Advancing Time-----------------------------------------------------------
120  // -------------------------------------------------------------------------
121 
122  // \param Request an advance to given federation time. Federation time
123  // may be different than requested time following this call, even if
124  // blockUntilAdvanceIsGranted is true (federation time may exceed requested
125  // time).
126  // If blockUntilAdvanceIsGranted is true, call will not return until
127  // actualTime exceeds requestedTime.
128  // \param requestedFederationTime Desired federation time to advance to.
129  // \param blockUntilAdvanceIsGranted Indicates whether this function should
130  // wait until request is granted.
131 #if !DtHLA_1516
132  virtual bool timeAdvanceRequest(
133  const RTI::FedTime& requestedFederateTime,
134  bool blockUntilAdvanceIsGranted = true);
135 #else
136  virtual bool timeAdvanceRequest(
137  const RTI::LogicalTime& requestedFederateTime,
138  bool blockUntilAdvanceIsGranted = true);
139 #endif
140 
141  // Add/remove callbacks to be executed immediately following a time advance
142  // request grant.
143  virtual void addTimeAdvanceGrantedCallback(DtTimeAdvanceGrantedCb cb, void *usr);
144  virtual void removeTimeAdvanceGrantedCallback(DtTimeAdvanceGrantedCb cb, void *usr);
145 
146  // -------------------------------------------------------------------------
147  // Querying Time------------------------------------------------------------
148  // -------------------------------------------------------------------------
149 
150  // Get the lower bound time stamp (LBTS)
151  // \param Returns current LBTS for the federate
152  // \return true if call is successful, false otherwise
153 #if !DtHLA_1516
154  virtual bool queryLBTS(RTI::FedTime& federateTime) const;
155 #else
156  virtual bool queryLBTS(RTI::LogicalTime& federateTime) const;
157 #endif
158 
159  // Get the current federation (logical) time
160  // \param Returns current federation time for the federate
161  // \return true if call is successful, false otherwise
162 #if !DtHLA_1516
163  virtual bool queryFederateTime(RTI::FedTime& federateTime) const;
164 #else
165  virtual bool queryFederateTime(RTI::LogicalTime& federateTime) const;
166 #endif
167 
168 public:
169 
170  // Callbacks registered with federate ambassador to advance federation time,
171  // enable time constrained mode, and enable time regulating mode.
172  // timeAdvanceRequestCb calls processTimeAdvanceRequest to actually perform
173  // the work in the callback.
174 #if !DtHLA_1516
175  static void timeAdvanceRequestCb( const RTI::FedTime&, void* );
176  static void timeConstrainedEnableCb( const RTI::FedTime&, void* );
177  static void timeRegulationEnableCb( const RTI::FedTime&, void* );
178 #else
179  static void timeAdvanceRequestCb( const RTI::LogicalTime&, void* );
180  static void timeConstrainedEnableCb( const RTI::LogicalTime&, void* );
181  static void timeRegulationEnableCb( const RTI::LogicalTime&, void* );
182 #endif
183 
184 protected:
185 
186  // \return The exercise connection this class has been handed in to use.
187  virtual DtExerciseConn& exerciseConn() const;
188 
189  // \return New instance of a federation time object.
190 #if !DtHLA_1516
191  virtual RTI::FedTime* createFederationTime() const;
192 #else
193  virtual RTI::LogicalTime* createFederationTime() const;
194 #endif
195 
196  // Sets myFederationTime to the new time given by the RTI and sets
197  // myTimeAdvanceGrantPending to false.
198 #if !DtHLA_1516
199  virtual void processTimeAdvanceRequest( const RTI::FedTime& fTime );
200 #else
201  virtual void processTimeAdvanceRequest( const RTI::LogicalTime& fTime );
202 #endif
203 
204  virtual void invokeTimeAdvanceGrantedCallbacks();
205 
206  void removeAllTimeAdvanceGrantedCallbacks();
207 
208 private:
209 
210  // copy constructor - not implemented
212 
213  // assignment operator - not implemented
215 
216 protected:
217 
218  DtExerciseConn& myExerciseConn;
219 
220  // Used in callback functions
225 
226 #if !DtHLA_1516
227  RTI::FedTime* myFederationTime;
228 #else
229  RTI::LogicalTime* myFederationTime;
230 #endif
231 
232  std::list<DtTimeAdvanceGrantedCbData> myTimeAdvanceGrantedCbs;
233 };
234 
235 #endif // DtHLA
236 
237 #endif

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)