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

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)