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

Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)