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 {
21  static DtUUID DtGlobalWeatherObjectUUID("VRF_UUID:73666f77-63d6-e041-a002-f2690e990574");
22 
26  {
28  {
29  myScenarioStartTimeAtLocalOnFirstObjectCreationToTime = 36000;
30  myUpdateWhenTimeChangedBy = 60.;
31  myDateAndTimeOfDay = 43200.0;
32  myNetworkDateAndTimeOfDay = 0.;
33  myScenarioStartTimeIsLocal = true;
34  }
35 
37  {
38  myScenarioStartTimeAtLocalOnFirstObjectCreationToTime = orig.myScenarioStartTimeAtLocalOnFirstObjectCreationToTime;
39  myUpdateWhenTimeChangedBy = orig.myUpdateWhenTimeChangedBy;
40  myDateAndTimeOfDay = orig.myDateAndTimeOfDay;
41  myNetworkDateAndTimeOfDay = orig.myNetworkDateAndTimeOfDay;
42  myScenarioStartTimeIsLocal = orig.myScenarioStartTimeIsLocal;
43  }
44 
46  {
47  myScenarioStartTimeAtLocalOnFirstObjectCreationToTime = rhs.myScenarioStartTimeAtLocalOnFirstObjectCreationToTime;
48  myUpdateWhenTimeChangedBy = rhs.myUpdateWhenTimeChangedBy;
49  myDateAndTimeOfDay = rhs.myDateAndTimeOfDay;
50  myNetworkDateAndTimeOfDay = rhs.myNetworkDateAndTimeOfDay;
51  myScenarioStartTimeIsLocal = rhs.myScenarioStartTimeIsLocal;
52  return *this;
53  }
54 
56  {
57  return (myDateAndTimeOfDay != 43200.0);
58  }
59 
60  DEFINE_ACCESSOR_MUTATOR(double, updateWhenTimeChangedBy, UpdateWhenTimeChangedBy)
61  DEFINE_ACCESSOR_MUTATOR(double, dateAndTimeOfDay, DateAndTimeOfDay)
62  DEFINE_ACCESSOR_MUTATOR(double, networkDateAndTimeOfDay, NetworkDateAndTimeOfDay)
63  DEFINE_ACCESSOR_MUTATOR(int, scenarioStartTimeAtLocalOnFirstObjectCreationToTime, ScenarioStartTimeAtLocalOnFirstObjectCreationToTime)
64  DEFINE_ACCESSOR_MUTATOR(bool, scenarioStartTimeIsLocal, ScenarioStartTimeIsLocal)
65 
66  protected:
67  int myScenarioStartTimeAtLocalOnFirstObjectCreationToTime;
68  double myUpdateWhenTimeChangedBy;
69  double myDateAndTimeOfDay;
70  double myNetworkDateAndTimeOfDay;
71 
74  bool myScenarioStartTimeIsLocal;
75  };
76 
80  {
81  public:
83 
85  : DtFrameStateInterface(storage)
86  {
87  }
88 
89  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, updateWhenTimeChangedBy, UpdateWhenTimeChangedBy)
90  UNDEFINED_RETURNVALUE_ACCESSOR(double, dateAndTimeOfDay)
91  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, networkDateAndTimeOfDay, NetworkDateAndTimeOfDay)
92  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, timeOfDayAdvancementSpeed, TimeOfDayAdvancementSpeed)
93  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, useDayNightIlluminationModel, UseDayNightIlluminationModel)
94  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(int, scenarioStartTimeAtLocalOnFirstObjectCreationToTime, ScenarioStartTimeAtLocalOnFirstObjectCreationToTime)
95  virtual void setDateAndTimeOfDay(const double&, bool markModified = false) { throw DtUnimplementedMethod("void setDateAndTimeOfDay(double, bool markModified = false) is not implemented for this class."); };
96 
99  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, userModifiedTime, UserModifiedTime)
100  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, timeToLocalOnFirstPlacement, TimeToLocalOnFirstPlacement)
101  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, alreadySetTimePlacement, AlreadySetTimePlacement)
102  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, canSetScenarioPreStartTime, CanSetScenarioPreStartTime)
103  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, scenarioStartTimeIsLocal, ScenarioStartTimeIsLocal)
104  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, timeOfDay, TimeOfDay)
105  };
106 
109  {
110  public:
112 
114  const DtTimeAndDateStateComponentData& frameState() const { return myData; };
116 
117  virtual const double dateAndTimeOfDay() const override;
118  virtual void setDateAndTimeOfDay(const double&, bool markModified = false) override;
119 
120  virtual const double networkDateAndTimeOfDay() const override;
121  virtual void setNetworkDateAndTimeOfDay(const double&) override;
122 
123  virtual const double updateWhenTimeChangedBy() const override;
124  virtual void setUpdateWhenTimeChangedBy(const double&) override;
125 
126  virtual const double timeOfDayAdvancementSpeed() const override;
127  virtual void setTimeOfDayAdvancementSpeed(const double&) override;
128 
129  virtual const bool useDayNightIlluminationModel() const override;
130  virtual void setUseDayNightIlluminationModel(const bool&) override;
131 
132  virtual const int scenarioStartTimeAtLocalOnFirstObjectCreationToTime() const override;
133  virtual void setScenarioStartTimeAtLocalOnFirstObjectCreationToTime(const int&) override;
134 
136  virtual void setTimeToLocalOnFirstPlacement(const bool&) override;
137  virtual const bool timeToLocalOnFirstPlacement() const override;
138 
140  virtual void setUserModifiedTime(const bool&) override;
141  virtual const bool userModifiedTime() const override;
142 
144  virtual void setAlreadySetTimePlacement(const bool&) override;
145  virtual const bool alreadySetTimePlacement() const override;
146 
148  virtual void setCanSetScenarioPreStartTime(const bool&) override;
149  virtual const bool canSetScenarioPreStartTime() const override;
150 
153  virtual void setScenarioStartTimeIsLocal(const bool&) override;
154  virtual const bool scenarioStartTimeIsLocal() const override;
155 
156  virtual const DtString timeOfDayString() const override;
159  virtual void setTimeOfDay(const double& value) override;
160 
162  virtual const double timeOfDay() const override;
163 
165  virtual void makeWritable() override;
166 
168  virtual void makeReadOnly() override;
169 
170  protected:
171  VRF::WriteSimulationDateTimeRepository myWriteSimulationDateTimeRepository;
173  };
174 
177  {
178  public:
180  virtual ~DtTimeAndDateStateComponentCurrentFrame() override;
181 
183  const DtTimeAndDateStateComponentData& frameState() const { return myData; };
184 
185  bool readComponentValid() const;
186  bool findReadComponent();
187 
188  virtual const double updateWhenTimeChangedBy() const override;
189  virtual const double dateAndTimeOfDay() const override;
190  virtual const double networkDateAndTimeOfDay() const override;
191  virtual const double timeOfDayAdvancementSpeed() const override;
192  virtual const bool useDayNightIlluminationModel() const override;
193  virtual const int scenarioStartTimeAtLocalOnFirstObjectCreationToTime() const override;
194  virtual const DtString timeOfDayString() const override;
195  virtual const bool timeToLocalOnFirstPlacement() const override;
196  virtual const bool userModifiedTime() const override;
197  virtual const bool scenarioStartTimeIsLocal() const override;
198 
200  virtual const bool alreadySetTimePlacement() const override;
201 
202  virtual const bool canSetScenarioPreStartTime() const override;
203  virtual const double timeOfDay() const override;
204 
205  protected:
206  void dateAndTimeOfDayChanged();
207 
210  {
211  myData = data;
212  }
213 
214  protected:
215  VRF::ReadSimulationDateTimeRepository myReadSimulationDateTimeRepository;
216  unsigned int myCallbackHandle;
218  };
219 
223  {
224  public:
226 
227  bool isDoubleBuffered() { return true; };
228  virtual const DtFrameStateInterface* currentFrameState() const override { return &myCurrentFrameState; }
229  virtual DtFrameStateInterface* nextFrameState() override { return &myNextFrameState; };
230  virtual const DtFrameStateInterface* nextFrameState() const override { return &myNextFrameState; };
231 
232  virtual void updateDataStorage() override;
233 
234  virtual void updateStateData(DtStateData* sd) override
235  {
236  myCurrentFrameState.updateStateData(sd);
237  myNextFrameState.updateStateData(sd);
238  }
239 
241  virtual bool forceAdvance() override;
242 
244  virtual void firstFrameAdvance() override;
245 
246  virtual void initializeFromParameters(const DtVrfObjectParameters*) override;
247 
248  virtual void aboutToBeDeleted() override
249  {
251  myCurrentFrameState.aboutToBeDeleted();
252  myNextFrameState.aboutToBeDeleted();
253  }
254 
255  protected:
259  };
260 
264 }
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:55
Definition: stateDataTypes.h:23
DtTimeAndDateStateComponentData myData
Definition: timeAndDateStateComponent.h:217
bool myFoundComponent
Definition: timeAndDateStateComponent.h:258
DtTimeAndDateStateComponentData(const DtTimeAndDateStateComponentData &orig)
Definition: timeAndDateStateComponent.h:36
2) Define the next frame class. This will be used for write access.
Definition: timeAndDateStateComponent.h:108
DtTimeAndDateStateComponentData & operator=(const DtTimeAndDateStateComponentData &rhs)
Definition: timeAndDateStateComponent.h:45
Definition: stateComponent.h:269
int myScenarioStartTimeAtLocalOnFirstObjectCreationToTime
Definition: timeAndDateStateComponent.h:67
virtual void aboutToBeDeleted() override
Definition: timeAndDateStateComponent.h:248
unsigned int myCallbackHandle
Definition: timeAndDateStateComponent.h:216
3) Define the current frame class. This will be used for read access.
Definition: timeAndDateStateComponent.h:176
void advanceFrame(const DtTimeAndDateStateComponentData &data)
Definition: timeAndDateStateComponent.h:209
DtTimeAndDateStateComponentData()
Definition: timeAndDateStateComponent.h:27
#define UNDEFINED_RETURNVALUE_ACCESSOR(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:31
Contains the DtUUID class declaration.
double myUpdateWhenTimeChangedBy
Definition: timeAndDateStateComponent.h:68
virtual DtFrameStateInterface * nextFrameState() override
Definition: timeAndDateStateComponent.h:229
DtStateComponentCreator< DtTimeAndDateStateComponentImplementation > DtTimeAndDateStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: timeAndDateStateComponent.h:263
const DtTimeAndDateStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: timeAndDateStateComponent.h:183
double myDateAndTimeOfDay
Definition: timeAndDateStateComponent.h:69
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:79
DtTimeAndDateStateComponentNextFrame myNextFrameState
Definition: timeAndDateStateComponent.h:257
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:398
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:231
Contains the enums for cloud layers.
DtTimeAndDateStateComponentData & frameState()
Definition: timeAndDateStateComponent.h:115
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:384
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:53
bool myScenarioStartTimeIsLocal
If this is true (default) the time of day is to be considered a local time. If false, UTC time and this will be considered adjusted for local time.
Definition: timeAndDateStateComponent.h:74
double myNetworkDateAndTimeOfDay
Definition: timeAndDateStateComponent.h:70
virtual void aboutToBeDeleted()
virtual const DtFrameStateInterface * nextFrameState() const override
Definition: timeAndDateStateComponent.h:230
virtual void updateStateData(DtStateData *sd) override
Implement to update data storage to the new state data.
Definition: timeAndDateStateComponent.h:234
DtTimeAndDateStateComponentCurrentFrame myCurrentFrameState
Definition: timeAndDateStateComponent.h:256
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Definition: doubleBufferedDataStorage.h:23
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: timeAndDateStateComponent.h:222
VRF::WriteSimulationDateTimeRepository myWriteSimulationDateTimeRepository
Definition: timeAndDateStateComponent.h:171
DtTimeAndDateStateComponentData myData
Definition: timeAndDateStateComponent.h:172
virtual const DtFrameStateInterface * currentFrameState() const override
Definition: timeAndDateStateComponent.h:228
static DtUUID DtGlobalWeatherObjectUUID("VRF_UUID:73666f77-63d6-e041-a002-f2690e990574")
#define DT_DLL_vrfStateData
This file is used to determine how to build Disable inconsistent dll linkage warning Visual Studio 6...
Definition: vrfStateDataDefines.h:26
VRF::ReadSimulationDateTimeRepository myReadSimulationDateTimeRepository
Definition: timeAndDateStateComponent.h:215
dateAndTimeOfDay is a possible dead reckoned date and time of day. networkDateAndTimeOfDay is the exa...
Definition: timeAndDateStateComponent.h:25
Contains the DtStateComponent class declaration.
bool isDoubleBuffered()
Definition: timeAndDateStateComponent.h:227
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:294
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:114

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)