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 
70  virtual ~DtEnvironmentConditionRemoteNetInterface() override;
71 
72 
73  virtual void onTick() override;
74 
75 #if DtHLA
76  virtual RTI::ObjectClassHandle objectClassHandle() const override;
77 
78 #endif
79 
80  virtual DtString type() const override;
81 
82  static DtSimObjectNetInterface* creator(
83  DtStateData* vrfObject, DtVrlinkNetworkInterface*, bool publishObject);
84 
85  template<typename T, typename V>
86  void setReflectedObject(T* ro)
87  {
88  if (myObject != ro)
89  {
91  removeBaseUpdateCallback();
92  myObject = ro;
93  setEnvironmentConditionTypeFromObject(ro);
94  //setup
95  myObject->baseAddPostUpdateCallback(reflectedObjectUpdateCallbackFunction, this);
96  setUpdateReceived(true);
97  setupFromNetworkRepository<V>();
98 
99  }
100  };
101 
102  virtual void clearReflectedObject(bool shouldRemoveStateComponent = true);
103  static void reflectedObjectUpdateCallbackFunction(DtReflectedObject* obj, void* userData);
104 
105  protected:
106  template<typename T>
108  {
109  return nextFrameVrfObject()->nextFrameState()->getStateComponent<T>();
110  };
111 
112  template<typename T>
114  {
115  return nextFrameVrfObject()->hasStateComponent<T>();
116  };
117 
118  template<typename T>
120  {
121  return nextFrameVrfObject()->addStateComponent<T>(mySimObject->isLocal(), !mySimObject->isLocal());
122  };
123  template<typename T>
125  {
126  return !nextFrameVrfObject()->hasStateComponent<T>() ? createVrfStateComponent<T>() : getVrfStateComponent<T>();
127  };
128 
129  void removeStateComponent();
130 
131  template<typename T>
133  {
137  initializeRemoteStateComponents<T>();
138  updateFromReflectedObject();
139  };
140 
141  template<typename T>
143  {
144  switch (myEnvironmentConditionType)
145  {
150  getOrCreateVrfStateComponent<DtEnvironmentalLocationStateComponent>();
151  getOrCreateVrfStateComponent<DtVrfGeometryStateComponent>();
152  break;
153  }
154  myStateComponent = getOrCreateVrfStateComponent<T>();
155 
156  if (!myStateComponentDeletedConnection.connected())
157  {
158  myStateComponentDeletedConnection = myStateComponent->signal_stateComponentAboutToBeDeleted.connect(
160  }
161  };
162 
163  virtual void slot_stateComponentToBeDeleted();
164 
165  virtual void updateFromReflectedObject() override;
166  virtual int mapMetocCloudTypeToVrvCloudType(DtCloudTypeEnum32) const;
167  virtual int mapHazeTypeToObscurant(DtHazeTypeEnum32 type) const;
168  virtual DtVrfWeatherPrecipitationType mapMetocPrecipitationTypeToVrfPrecipitationType(DtPrecipitationTypeEnum32) const;
169  virtual makVrf::DtTroposphereStateComponent* updateTroposphere(const DtTroposphereLayerStateRepository* stateRep, bool shouldSetDefaultsForMakExtensions = true);
170  virtual void updateMAKTroposphere(const DtTroposphereLayerStateRepository* stateRep);
171  virtual void updateFromMetocGeoreference(const DtEnvironmentConditionStateRepository* stateRep);
172  virtual makVrf::DtSubsurfaceStateComponent* updateSubsurface(const DtSubsurfaceLayerStateRepository* stateRep, bool shouldSetDefaultsForMakExtensions = true);
173  virtual void updateMAKSubsurface(const DtSubsurfaceLayerStateRepository* stateRep);
174  virtual makVrf::DtLandSurfaceStateComponent* updateLandSurface(const DtLandSurfaceStateRepository* stateRep, bool shouldSetDefaultsForMakExtensions = true);
175  virtual void updateMAKLandSurface(const DtLandSurfaceStateRepository* stateRep);
176  virtual makVrf::DtWaterSurfaceStateComponent* updateWaterSurface(const DtWaterSurfaceStateRepository* stateRep, bool shouldSetDefaultsForMakExtensions=true);
177  virtual void updateMAKWaterSurface(const DtWaterSurfaceStateRepository* stateRep);
178  virtual void removeBaseUpdateCallback();
179  virtual DtReflectedObject* reflectedObject() const override;
180 
181  virtual void setEnvironmentConditionType(DtEnvironmentConditionType type);
182  virtual DtEnvironmentConditionType environmentConditionType() const;
183 
184  virtual void setEnvironmentConditionTypeFromObject(DtReflectedObject* obj);
185  protected:
191  DtFrameStateInterface* myStateComponent = nullptr;
192  static std::unordered_map<std::string, DtEnvironmentConditionType> theHLAClassNameToEnvironmentConditionTypeMap;
193 
194  typedef std::map<DtVrlUuid, double> DtAltitudeByUuidMapType;
197 
198 public:
199 
200  static const int DtGlobalWeatherPriority;
201  static const int DtDefaultWeatherPriority;
202 
204  boost::signals2::connection myStateComponentDeletedConnection;
205  };
206 
207 
208 
209 
210 }
DtVrfWeatherPrecipitationType
Definition: vrfWeatherStateEnums.h:13
Definition: environmentConditionRemoteNetInterface.h:42
Definition: environmentConditionRemoteNetInterface.h:45
Definition: environmentConditionRemoteNetInterface.h:48
static const int DtDefaultWeatherPriority
Definition: environmentConditionRemoteNetInterface.h:201
DtEnvironmentConditionType myEnvironmentConditionType
This is important since the interface is generic, but it can be instantiated by any environment condi...
Definition: environmentConditionRemoteNetInterface.h:190
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
boost::signals2::connection myStateComponentDeletedConnection
Definition: environmentConditionRemoteNetInterface.h:204
Definition: environmentConditionRemoteNetInterface.h:46
void setReflectedObject(T *ro)
Definition: environmentConditionRemoteNetInterface.h:86
1) Define the interface class that will be used to represent the next and current frames...
Definition: waterSurfaceStateComponent.h:102
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:513
Definition: environmentConditionRemoteNetInterface.h:52
Class Description: DtSimObjectNetInterface.
Definition: simObjectNetInterface.h:50
tbb::spin_mutex myTroposphereLayerAltitudeByUuidMapMutex
Definition: environmentConditionRemoteNetInterface.h:203
T * createVrfStateComponent()
Definition: environmentConditionRemoteNetInterface.h:119
1) Define the interface class that will be used to represent the next and current frames...
Definition: subsurfaceStateComponent.h:139
static const int DtGlobalWeatherPriority
Definition: environmentConditionRemoteNetInterface.h:200
DtReflectedObject * myObject
Note that this is a reflected object because this class, while weather, also covers subsurface layers...
Definition: environmentConditionRemoteNetInterface.h:188
std::map< DtVrlUuid, double > DtAltitudeByUuidMapType
Definition: environmentConditionRemoteNetInterface.h:194
Abstract interface for the land surface state component, representing both the next and current frame...
Definition: landSurfaceStateComponent.h:90
Definition: environmentConditionRemoteNetInterface.h:43
T * getOrCreateVrfStateComponent()
Definition: environmentConditionRemoteNetInterface.h:124
T * getVrfStateComponent()
Definition: environmentConditionRemoteNetInterface.h:107
static std::unordered_map< std::string, DtEnvironmentConditionType > theHLAClassNameToEnvironmentConditionTypeMap
Definition: environmentConditionRemoteNetInterface.h:192
DtAltitudeByUuidMapType myTroposphereLayerAltitudeByUuidMap
TODO consider replacing this with just &quot;myLastReceivedAltitude&quot; since this class is not shared betwee...
Definition: environmentConditionRemoteNetInterface.h:196
bool hasStateComponent()
Definition: environmentConditionRemoteNetInterface.h:113
void setupFromNetworkRepository()
initializes parts of the local repository from the network state rep. This needs to be done after the...
Definition: environmentConditionRemoteNetInterface.h:132
Base interface for accessing current or next frame state in a double-buffered state component...
Definition: stateComponent.h:354
1) Define the interface class that will be used to represent the next and current frames...
Definition: troposphereStateComponent.h:48
void initializeRemoteStateComponents()
Definition: environmentConditionRemoteNetInterface.h:142
Definition: environmentConditionRemoteNetInterface.h:47

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)