VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
environmentConditionRemoteNetInterface.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2023 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
10 
11 #pragma once
12 
18 #include <vrfStateData/stateData.h>
19 #include <vlpi/metocEnums.h>
20 #include <tbb/spin_mutex.h>
21 
22 //#include <vl/reflectedWeatherHLA.h>
23 
28 class DtEnvironmentConditionStateRepository;
29 
30 namespace makVrf
31 {
32 
33  class DtTroposphereStateComponent;
34  class DtSubsurfaceStateComponent;
35  class DtLandSurfaceStateComponent;
36  class DtWaterSurfaceStateComponent;
37  class DtSubsurfaceStateComponent;
38 
40  {
51  };
53  {
54 
55  private:
57 
63  public:
64 
67  DtStateData* vrfObject, DtVrlinkNetworkInterface*, bool publishObject = true);
68 
71 
72 
73  virtual void onTick() override;
74 
75 
76 #if DtHLA
77  virtual RTI::ObjectClassHandle objectClassHandle() const override;
78 
79 #endif
80 
81  virtual DtString type() const override;
82 
83  static DtSimObjectNetInterface* creator(
84  DtStateData* vrfObject, DtVrlinkNetworkInterface*, bool publishObject);
85 
86  template<typename T, typename V>
87  void setReflectedObject(T* ro)
88  {
89  if (myObject != ro)
90  {
92  removeBaseUpdateCallback();
93  myObject = ro;
94  setEnvironmentConditionTypeFromObject(ro);
95  //setup
96  myObject->baseAddPostUpdateCallback(reflectedObjectUpdateCallbackFunction, this);
97  setUpdateReceived(true);
98  setupFromNetworkRepository<V>();
99 
100  }
101  };
102 
103  virtual void clearReflectedObject(bool shouldRemoveStateComponent = true);
104  static void reflectedObjectUpdateCallbackFunction(DtReflectedObject* obj, void* userData);
105 
106  protected:
107  template<typename T>
109  {
110  return nextFrameVrfObject()->nextFrameState()->getStateComponent<T>();
111  };
112 
113  template<typename T>
115  {
116  return nextFrameVrfObject()->hasStateComponent<T>();
117  };
118 
119  template<typename T>
121  {
122  return nextFrameVrfObject()->addStateComponent<T>(mySimObject->isLocal(), !mySimObject->isLocal());
123  };
124  template<typename T>
126  {
127  return !nextFrameVrfObject()->hasStateComponent<T>() ? createVrfStateComponent<T>() : getVrfStateComponent<T>();
128  };
129 
130  void removeStateComponent();
131 
132  template<typename T>
134  {
138  initializeRemoteStateComponents<T>();
139  updateFromReflectedObject();
140  };
141 
142  template<typename T>
144  {
145  switch (myEnvironmentConditionType)
146  {
151  getOrCreateVrfStateComponent<DtEnvironmentalLocationStateComponent>();
152  getOrCreateVrfStateComponent<DtVrfGeometryStateComponent>();
153  break;
154  }
155  myStateComponent = getOrCreateVrfStateComponent<T>();
156  };
157 
158  virtual void updateFromReflectedObject();
159  virtual int mapMetocCloudTypeToVrvCloudType(DtCloudTypeEnum32) const;
160  virtual int mapHazeTypeToObscurant(DtHazeTypeEnum32 type) const;
161  virtual DtVrfWeatherPrecipitationType mapMetocPrecipitationTypeToVrfPrecipitationType(DtPrecipitationTypeEnum32) const;
162  virtual makVrf::DtTroposphereStateComponent* updateTroposphere(const DtTroposphereLayerStateRepository* stateRep, bool shouldSetDefaultsForMakExtensions = true);
163  virtual void updateMAKTroposphere(const DtTroposphereLayerStateRepository* stateRep);
164  virtual void updateFromMetocGeoreference(const DtEnvironmentConditionStateRepository* stateRep);
165  virtual makVrf::DtSubsurfaceStateComponent* updateSubsurface(const DtSubsurfaceLayerStateRepository* stateRep, bool shouldSetDefaultsForMakExtensions = true);
166  virtual void updateMAKSubsurface(const DtSubsurfaceLayerStateRepository* stateRep);
167  virtual makVrf::DtLandSurfaceStateComponent* updateLandSurface(const DtLandSurfaceStateRepository* stateRep, bool shouldSetDefaultsForMakExtensions = true);
168  virtual void updateMAKLandSurface(const DtLandSurfaceStateRepository* stateRep);
169  virtual makVrf::DtWaterSurfaceStateComponent* updateWaterSurface(const DtWaterSurfaceStateRepository* stateRep, bool shouldSetDefaultsForMakExtensions=true);
170  virtual void updateMAKWaterSurface(const DtWaterSurfaceStateRepository* stateRep);
171  virtual void removeBaseUpdateCallback();
172  virtual DtReflectedObject* reflectedObject() const;
173 
174  virtual void setEnvironmentConditionType(DtEnvironmentConditionType type);
175  virtual DtEnvironmentConditionType environmentConditionType() const;
176 
177  virtual void setEnvironmentConditionTypeFromObject(DtReflectedObject* obj);
178  protected:
185  static std::unordered_map<std::string, DtEnvironmentConditionType> theHLAClassNameToEnvironmentConditionTypeMap;
186 
187  typedef std::map<DtVrlUuid, double> DtAltitudeByUuidMapType;
191 public:
192 
193  static const int DtGlobalWeatherPriority;
194  static const int DtDefaultWeatherPriority;
195 
197  };
198 
199 
200 
201 
202 }
DtVrfWeatherPrecipitationType
Definition: vrfWeatherStateEnums.h:13
Definition: environmentConditionRemoteNetInterface.h:42
Definition: environmentConditionRemoteNetInterface.h:45
DtFrameStateInterface * myStateComponent
Definition: environmentConditionRemoteNetInterface.h:184
Definition: environmentConditionRemoteNetInterface.h:48
static const int DtDefaultWeatherPriority
Definition: environmentConditionRemoteNetInterface.h:194
DtEnvironmentConditionType myEnvironmentConditionType
This is important since the interface is generic, but it can be instantiated by any environment condi...
Definition: environmentConditionRemoteNetInterface.h:183
Definition: environmentConditionRemoteNetInterface.h:50
Definition: environmentConditionRemoteNetInterface.h:41
Definition: environmentConditionRemoteNetInterface.h:49
Definition: simRemoteEnvironmentalNetInterface.h:38
DtEnvironmentConditionType
Definition: environmentConditionRemoteNetInterface.h:39
Definition: environmentConditionRemoteNetInterface.h:44
Definition: environmentConditionRemoteNetInterface.h:46
void setReflectedObject(T *ro)
Definition: environmentConditionRemoteNetInterface.h:87
1) Define the interface class that will be used to represent the next and current frames...
Definition: waterSurfaceStateComponent.h:76
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:339
Definition: environmentConditionRemoteNetInterface.h:52
Class Description: DtSimObjectNetInterface.
Definition: simObjectNetInterface.h:50
tbb::spin_mutex myTroposphereLayerAltitudeByUuidMapMutex
Definition: environmentConditionRemoteNetInterface.h:196
T * createVrfStateComponent()
Definition: environmentConditionRemoteNetInterface.h:120
1) Define the interface class that will be used to represent the next and current frames...
Definition: subsurfaceStateComponent.h:103
static const int DtGlobalWeatherPriority
Definition: environmentConditionRemoteNetInterface.h:193
DtReflectedObject * myObject
Note that this is a reflected object because this class, while weather, also covers subsurface layers...
Definition: environmentConditionRemoteNetInterface.h:181
std::map< DtVrlUuid, double > DtAltitudeByUuidMapType
Definition: environmentConditionRemoteNetInterface.h:187
Definition: subsurfaceStateComponent.h:20
1) Define the interface class that will be used to represent the next and current frames...
Definition: landSurfaceStateComponent.h:86
Definition: environmentConditionRemoteNetInterface.h:43
T * getOrCreateVrfStateComponent()
Definition: environmentConditionRemoteNetInterface.h:125
T * getVrfStateComponent()
Definition: environmentConditionRemoteNetInterface.h:108
static std::unordered_map< std::string, DtEnvironmentConditionType > theHLAClassNameToEnvironmentConditionTypeMap
Definition: environmentConditionRemoteNetInterface.h:185
DtAltitudeByUuidMapType myTroposphereLayerAltitudeByUuidMap
TODO consider replacing this with just &quot;myLastReceivedAltitude&quot; since this class is not shared betwee...
Definition: environmentConditionRemoteNetInterface.h:189
bool hasStateComponent()
Definition: environmentConditionRemoteNetInterface.h:114
void setupFromNetworkRepository()
initializes parts of the local repository from the network state rep. This needs to be done after the...
Definition: environmentConditionRemoteNetInterface.h:133
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:291
1) Define the interface class that will be used to represent the next and current frames...
Definition: troposphereStateComponent.h:46
DtVrfSubsurfaceLayer myLastSubsurfaceLayer
Definition: environmentConditionRemoteNetInterface.h:190
void initializeRemoteStateComponents()
Definition: environmentConditionRemoteNetInterface.h:143
Definition: environmentConditionRemoteNetInterface.h:47

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)