VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
timeAndDateStateComponent.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 #pragma once
7 
10 #include <vlpi/netStructs.h>
11 #include <vlutil/vlString.h>
13 #include "legionDataStore/writeStateInstance.h"
14 #include "legionDataStore/readStateInstance.h"
15 #include "vrfOM/sets/writeSimulationDateTimeRepository.hpp"
16 #include "vrfOM/sets/readSimulationDateTimeRepository.hpp"
17 #include <vrfutil/rwUUID.h>
18 
19 namespace makVrf
20 {
22  static DtUUID DtGlobalWeatherObjectUUID("VRF_UUID:73666f77-63d6-e041-a002-f2690e990574");
23 
27  {
30  {
31  myUpdateWhenTimeChangedBy = 60.;
32  myDateAndTimeOfDay = 43200.0;
33  myNetworkDateAndTimeOfDay = 0.;
34  }
35 
39  {
40  myUpdateWhenTimeChangedBy = orig.myUpdateWhenTimeChangedBy;
41  myDateAndTimeOfDay = orig.myDateAndTimeOfDay;
42  myNetworkDateAndTimeOfDay = orig.myNetworkDateAndTimeOfDay;
43  }
44 
49  {
50  myUpdateWhenTimeChangedBy = rhs.myUpdateWhenTimeChangedBy;
51  myDateAndTimeOfDay = rhs.myDateAndTimeOfDay;
52  myNetworkDateAndTimeOfDay = rhs.myNetworkDateAndTimeOfDay;
53  return *this;
54  }
55 
58  {
59  return (myDateAndTimeOfDay != 43200.0);
60  }
61 
62  DEFINE_ACCESSOR_MUTATOR(double, updateWhenTimeChangedBy, UpdateWhenTimeChangedBy)
63  DEFINE_ACCESSOR_MUTATOR(double, dateAndTimeOfDay, DateAndTimeOfDay)
64  DEFINE_ACCESSOR_MUTATOR(double, networkDateAndTimeOfDay, NetworkDateAndTimeOfDay)
65 
66  protected:
68  double myUpdateWhenTimeChangedBy;
70  double myDateAndTimeOfDay;
72  double myNetworkDateAndTimeOfDay;
73  };
74 
78  {
79  public:
81 
82 
85  : DtFrameStateInterface(storage)
86  {
87  }
88 
90  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, updateWhenTimeChangedBy, UpdateWhenTimeChangedBy)
92  UNDEFINED_RETURNVALUE_ACCESSOR(double, dateAndTimeOfDay)
94  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, networkDateAndTimeOfDay, NetworkDateAndTimeOfDay)
96  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, timeOfDayAdvancementSpeed, TimeOfDayAdvancementSpeed)
98  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, useDayNightIlluminationModel, UseDayNightIlluminationModel)
99 
100 
101  virtual void setDateAndTimeOfDay(const double&, bool markModified = false) { throw DtUnimplementedMethod("void setDateAndTimeOfDay(double, bool markModified = false) is not implemented for this class."); };
103 
105  UNDEFINED_RETURNVALUE_ACCESSOR(DtString, timeOfDayString)
107  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, userModifiedTime, UserModifiedTime)
109  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, timeToLocalOnFirstPlacement, TimeToLocalOnFirstPlacement)
111  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, alreadySetTimePlacement, AlreadySetTimePlacement)
113  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, canSetScenarioPreStartTime, CanSetScenarioPreStartTime)
114 
115 
116  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, timeOfDay, TimeOfDay)
117  };
118 
121  {
122  public:
126 
128  const DtTimeAndDateStateComponentData& frameState() const { return myData; };
130 
132  virtual const double dateAndTimeOfDay() const override;
135  virtual void setDateAndTimeOfDay(const double&, bool markModified = false) override;
136 
138  virtual const double networkDateAndTimeOfDay() const override;
140  virtual void setNetworkDateAndTimeOfDay(const double&) override;
141 
143  virtual const double updateWhenTimeChangedBy() const override;
145  virtual void setUpdateWhenTimeChangedBy(const double&) override;
146 
148  virtual const double timeOfDayAdvancementSpeed() const override;
150  virtual void setTimeOfDayAdvancementSpeed(const double&) override;
151 
153  virtual const bool useDayNightIlluminationModel() const override;
155  virtual void setUseDayNightIlluminationModel(const bool&) override;
156 
158  virtual void setTimeToLocalOnFirstPlacement(const bool&) override;
159  virtual const bool timeToLocalOnFirstPlacement() const override;
160 
162  virtual void setUserModifiedTime(const bool&) override;
163  virtual const bool userModifiedTime() const override;
164 
166  virtual void setAlreadySetTimePlacement(const bool&) override;
167  virtual const bool alreadySetTimePlacement() const override;
168 
170  virtual void setCanSetScenarioPreStartTime(const bool&) override;
171  virtual const bool canSetScenarioPreStartTime() const override;
172 
174  virtual const DtString timeOfDayString() const override;
177  virtual void setTimeOfDay(const double& value) override;
178 
180  virtual const double timeOfDay() const override;
181 
183  virtual void makeWritable() override;
184 
186  virtual void makeReadOnly() override;
187 
188  protected:
190  VRF::WriteSimulationDateTimeRepository myWriteSimulationDateTimeRepository;
193  };
194 
197  {
198  public:
203  virtual ~DtTimeAndDateStateComponentCurrentFrame() override;
204 
206  const DtTimeAndDateStateComponentData& frameState() const { return myData; };
207 
209  bool readComponentValid() const;
212  bool findReadComponent();
213 
214  virtual const double updateWhenTimeChangedBy() const override;
215  virtual const double dateAndTimeOfDay() const override;
216  virtual const double networkDateAndTimeOfDay() const override;
217  virtual const double timeOfDayAdvancementSpeed() const override;
218  virtual const bool useDayNightIlluminationModel() const override;
219  virtual const DtString timeOfDayString() const override;
220  virtual const bool timeToLocalOnFirstPlacement() const override;
221  virtual const bool userModifiedTime() const override;
222 
224  virtual const bool alreadySetTimePlacement() const override;
225 
226  virtual const bool canSetScenarioPreStartTime() const override;
227  virtual const double timeOfDay() const override;
228 
229  protected:
231  void dateAndTimeOfDayChanged();
232 
237  {
238  myData = data;
239  }
240 
241  protected:
243  VRF::ReadSimulationDateTimeRepository myReadSimulationDateTimeRepository;
245  unsigned int myCallbackHandle;
248  };
249 
253  {
254  public:
258 
260  bool isDoubleBuffered() { return true; };
262  virtual const DtFrameStateInterface* currentFrameState() const override { return &myCurrentFrameState; }
264  virtual DtFrameStateInterface* nextFrameState() override { return &myNextFrameState; };
266  virtual const DtFrameStateInterface* nextFrameState() const override { return &myNextFrameState; };
267 
269  virtual void updateDataStorage() override;
270 
273  virtual void updateStateData(DtStateData* sd) override
274  {
275  myCurrentFrameState.updateStateData(sd);
276  myNextFrameState.updateStateData(sd);
277  }
278 
280  virtual bool forceAdvance() override;
281 
283  virtual void firstFrameAdvance() override;
284 
287  virtual void initializeFromParameters(const DtVrfObjectParameters*) override;
288 
290  virtual void aboutToBeDeleted() override
291  {
293  myCurrentFrameState.aboutToBeDeleted();
294  myNextFrameState.aboutToBeDeleted();
295  }
296 
297  protected:
304  };
305 
309 }
UUID is a unique ID wrapper class.
Definition: uuid.h:59
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:64
bool dateAndTimeOfDayHasBeenSet() const
Definition: timeAndDateStateComponent.h:57
Exception thrown when a required method has not been implemented.
Definition: stateDataTypes.h:30
DtTimeAndDateStateComponentData myData
Current-frame data storage for this component.
Definition: timeAndDateStateComponent.h:247
bool myFoundComponent
True once the Legion read repository component has been successfully located.
Definition: timeAndDateStateComponent.h:303
DtTimeAndDateStateComponentData(const DtTimeAndDateStateComponentData &orig)
Copy constructor.
Definition: timeAndDateStateComponent.h:38
2) Define the next frame class. This will be used for write access.
Definition: timeAndDateStateComponent.h:120
DtTimeAndDateStateComponentData & operator=(const DtTimeAndDateStateComponentData &rhs)
Assignment operator.
Definition: timeAndDateStateComponent.h:48
Default creator implementation for a state component type. T_StateComponent is the concrete component...
Definition: stateComponent.h:326
virtual void aboutToBeDeleted() override
Notifies both frame sub-components that the owning object is about to be destroyed.
Definition: timeAndDateStateComponent.h:290
unsigned int myCallbackHandle
Handle for the registered date/time update callback; 0 if not registered.
Definition: timeAndDateStateComponent.h:245
3) Define the current frame class. This will be used for read access.
Definition: timeAndDateStateComponent.h:196
void advanceFrame(const DtTimeAndDateStateComponentData &data)
Commits the given next-frame state data into the current frame buffer.
Definition: timeAndDateStateComponent.h:236
DtTimeAndDateStateComponentData()
Default constructor; initializes date/time to noon (43200s since epoch) with a 60-second network upda...
Definition: timeAndDateStateComponent.h:29
#define UNDEFINED_RETURNVALUE_ACCESSOR(ReturnType, Member)
Defines a virtual const accessor that throws DtUnimplementedMethod, marking the method as requiring a...
Definition: doubleBufferedDataStorage.h:53
Contains the DtUUID class declaration.
double myUpdateWhenTimeChangedBy
Minimum elapsed time in seconds before broadcasting a date/time update to the network.
Definition: timeAndDateStateComponent.h:68
virtual DtFrameStateInterface * nextFrameState() override
Definition: timeAndDateStateComponent.h:264
DtStateComponentCreator< DtTimeAndDateStateComponentImplementation > DtTimeAndDateStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: timeAndDateStateComponent.h:308
const DtTimeAndDateStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: timeAndDateStateComponent.h:206
double myDateAndTimeOfDay
Current dead-reckoned date and time of day, in seconds since epoch.
Definition: timeAndDateStateComponent.h:70
1) Define the interface class that will be used to represent the next and curent frames. The UNDEFINED_ macros are convenience macros that will define methods that throw exceptions (until they are implemented)
Definition: timeAndDateStateComponent.h:77
DtTimeAndDateStateComponentNextFrame myNextFrameState
Next-frame (writable) sub-component for time and date state.
Definition: timeAndDateStateComponent.h:301
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:513
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Macro to define all required static and virtual state component type methods. Place in the public sec...
Definition: stateComponent.h:272
Contains the enums for cloud layers.
DtTimeAndDateStateComponentData & frameState()
Definition: timeAndDateStateComponent.h:129
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:489
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Defines an undefined virtual by-value accessor and an undefined virtual setter, both throwing DtUnimp...
Definition: doubleBufferedDataStorage.h:103
double myNetworkDateAndTimeOfDay
Exact date and time of day as last received from the network; 0 if no network value is present...
Definition: timeAndDateStateComponent.h:72
virtual void aboutToBeDeleted()
Called when the component is about to be deleted; emits signal_stateComponentAboutToBeDeleted.
virtual const DtFrameStateInterface * nextFrameState() const override
Definition: timeAndDateStateComponent.h:266
virtual void updateStateData(DtStateData *sd) override
Updates the owning DtStateData pointer in both current and next frame sub-components.
Definition: timeAndDateStateComponent.h:273
DtTimeAndDateStateComponentCurrentFrame myCurrentFrameState
Current-frame (read-only) sub-component for time and date state.
Definition: timeAndDateStateComponent.h:299
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Defines a const reference accessor and an inline setter for a member variable.
Definition: doubleBufferedDataStorage.h:37
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: timeAndDateStateComponent.h:252
VRF::WriteSimulationDateTimeRepository myWriteSimulationDateTimeRepository
Write-access Legion repository for publishing simulation date/time updates.
Definition: timeAndDateStateComponent.h:190
DtTimeAndDateStateComponentData myData
Next-frame data storage for this component.
Definition: timeAndDateStateComponent.h:192
virtual const DtFrameStateInterface * currentFrameState() const override
Definition: timeAndDateStateComponent.h:262
static DtUUID DtGlobalWeatherObjectUUID("VRF_UUID:73666f77-63d6-e041-a002-f2690e990574")
UUID identifying the global weather object used as a shared reference across VRF simulation objects...
#define DT_DLL_vrfStateData
This file is used to determine how to build Disable inconsistent dll linkage warning Visual Studio 6...
Definition: vrfStateDataDefines.h:29
VRF::ReadSimulationDateTimeRepository myReadSimulationDateTimeRepository
Read-access Legion repository for receiving simulation date/time updates.
Definition: timeAndDateStateComponent.h:243
dateAndTimeOfDay is a possible dead reckoned date and time of day. networkDateAndTimeOfDay is the exa...
Definition: timeAndDateStateComponent.h:26
Contains the DtStateComponent class declaration.
bool isDoubleBuffered()
Definition: timeAndDateStateComponent.h:260
Base interface for accessing current or next frame state in a double-buffered state component...
Definition: stateComponent.h:354
const DtTimeAndDateStateComponentData & frameState() const
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: timeAndDateStateComponent.h:128

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)