VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
entityLocationStateComponent.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 
9 #include <legionStandardOM/sets/readEntityRepository.hpp>
10 #include <legionStandardOM/sets/writeEntityRepository.hpp>
11 #include <legionStandardOM/sets/readEmbarkedEntityRepository.hpp>
12 #include <legionStandardOM/sets/writeEmbarkedEntityRepository.hpp>
13 
14 #include <tbb/mutex.h>
15 #include <tbb/spin_rw_mutex.h>
16 #include <boost/signals2.hpp>
17 
18 namespace LOM
19 {
20  class ReadEntityRepository;
21 }
22 
23 class Coordinate_System;
24 
25 namespace makVrf
26 {
27  class DtStateDataManager;
29  {
31  : mySpatiallyFrozen(false)
32  , myHostGlobalId(DtUUID::nullUUID())
33  , myStationName(DtStationName::DtOnStation_XYZ)
34  , myNeedsEmbarkCheck(false)
35  {};
36 
43  {
44  }
45 
47  {
53 
54  return *this;
55  }
56 
57  DEFINE_ACCESSOR_MUTATOR(DtUUID, hostGlobalId, HostGlobalId)
58  DEFINE_ACCESSOR_MUTATOR(bool, spatiallyFrozen, SpatiallyFrozen)
59  DEFINE_REF_ACCESSORS(DtThresholder, thresholder, Thresholder)
60  DEFINE_ACCESSOR_MUTATOR(DtStationName, stationName, StationName)
61  DEFINE_ACCESSOR_MUTATOR(bool, needsEmbarkCheck, NeedsEmbarkCheck)
62 
63  protected:
66  DtThresholder myThresholder;
67  DtStationName myStationName;
69  };
70 
72  {
73  public:
75  : DtLocationStateComponent(storage)
76  {
77  }
78 
79  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, spatiallyFrozen, SpatiallyFrozen)
80  UNDEFINED_RETURNREF_ACCESSORS(DtThresholder, thresholder)
82  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(DtVector, acceleration, Acceleration)
83  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtVector, rotationalVelocity, RotationalVelocity)
84  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(DtDeadReckonTypes, algorithm, Algorithm)
85  UNDEFINED_RETURNVALUE_ACCESSOR(DtDeadReckonTypes, deadReckoningAlgorithm)
86 
87  UNDEFINED_RETURNREF_ACCESSOR(DtVector, worldVelocity)
88  UNDEFINED_RETURNREF_ACCESSOR(DtVector, worldAcceleration)
89  UNDEFINED_RETURNVALUE_ACCESSOR(double, worldSpeed)
90 
91  UNDEFINED_RETURNREF_ACCESSOR(DtVector, localVelocity)
92  UNDEFINED_RETURNREF_ACCESSOR(DtVector, localAcceleration)
93  UNDEFINED_RETURNVALUE_ACCESSOR(double, localSpeed)
94 
95  UNDEFINED_RETURNREF_ACCESSOR(DtVector, relativeVelocity)
96  UNDEFINED_RETURNREF_ACCESSOR(DtVector, relativeAcceleration)
97  UNDEFINED_RETURNVALUE_ACCESSOR(DtVector, bodyVelocity)
98  UNDEFINED_RETURNREF_ACCESSOR(DtVector, parentVelocity)
99  UNDEFINED_RETURNREF_ACCESSOR(DtVector, parentAcceleration)
100  UNDEFINED_RETURNVALUE_ACCESSOR(DtStationName, parentStationName)
101 
102  UNDEFINED_METHOD(void, setRelativeVelocity, const DtVector&)
103  UNDEFINED_METHOD(void, setParentAcceleration, const DtVector&)
104  UNDEFINED_METHOD(void, setParentVelocity, const DtVector&)
105  UNDEFINED_METHOD(void, setParentStationName, DtStationName)
106  UNDEFINED_METHOD(void, setRelativeAcceleration, const DtVector&)
107  UNDEFINED_METHOD(void, setLocalVelocity, const DtVector&)
108  UNDEFINED_METHOD(void, setLocalAcceleration, const DtVector&)
109  UNDEFINED_METHOD(void, setLocalSpeed, double)
110  UNDEFINED_METHOD(void, setWorldVelocity, const DtVector&)
111  UNDEFINED_METHOD(void, setWorldAcceleration, const DtVector&)
112  };
113 
117  {
118  public:
120 
122  : DtEntityLocationStateComponentInterface(storage)
123  {
124  }
125  };
126 
129  {
130  public:
133 
135  const DtEntityLocationStateComponentData& frameState() const { return myData; };
137 
138  const DtUUID& hostGlobalId() const;
139  void setHostGlobalId( const DtUUID& id);
140  const int objectAttachMode() const;
141 
142  void setAlgorithm(const DtDeadReckonTypes& alg);
143  const DtDeadReckonTypes algorithm() const;
144  const DtDeadReckonTypes deadReckoningAlgorithm() const { return algorithm(); };
145 
146  const bool frozen() const;
147  void setFrozen(const bool&);
148 
152  const DtVector location() const;
153  void setLocation(const DtVector&);
154 
155  const DtVector velocity() const;
156  void setVelocity(const DtVector&);
157 
158  const DtVector acceleration() const;
159  void setAcceleration(const DtVector&);
160 
161  const DtTaitBryan orientation() const;
162  void setOrientation(const DtTaitBryan&);
164 
165  const DtVector& rotationalVelocity() const;
166  void setRotationalVelocity(const DtVector&);
167 
168  const bool locationChanged() const;
169 
170  const DtVector& worldPosition() const;
171  const DtVector& relativePosition() const;
172  const DtVector& parentPosition() const;
173  const DtStationName parentStationName() const;
174  const DtVector& localPosition() const;
175  const DtVector& worldVelocity() const;
176  const DtVector& localVelocity() const;
177  const DtVector& worldAcceleration() const;
178  const DtVector& localAcceleration() const;
179  const DtTaitBryan& worldOrientation() const;
180  const DtTaitBryan& topographicOrientation() const;
181  const DtTaitBryan& parentOrientation() const;
182  const DtTaitBryan& localOrientation() const;
183  const DtDcm& worldOrientationMatrix() const;
184  const bool localPositionIsValid() const;
185 
186  const bool spatiallyFrozen() const;
187  void setSpatiallyFrozen(const bool&);
188 
189  const DtThresholder& thresholder() const;
190  DtThresholder& thresholder();
191 
192  const double heading() const;
193  const double pitch() const;
194  const double roll() const;
195 
196  const double localSpeed() const;
197 
198  const double worldSpeed() const;
199 
200  const DtDcm& parentOrientationMatrix() const;
201  void setLocalOrientationMatrix(const DtDcm&);
202  void setLocalOrientation(const DtTaitBryan&);
203  void setLocalOrientationWrtDatabase(const DtTaitBryan&);
204 
205  const DtDcm& localOrientationMatrix() const;
206  const DtTaitBryan& localOrientationWrtDatabase() const;
207 
208  void setRelativeVelocity(const DtVector&);
209  void setRelativeAcceleration(const DtVector&);
210  void setParentVelocity(const DtVector&);
211  void setParentAcceleration(const DtVector&);
212  void setLocalVelocity(const DtVector&);
213  void setLocalAcceleration(const DtVector&);
214  void setLocalPosition(const DtVector&);
215  void setWorldPosition(const DtVector&);
216  void setWorldVelocity(const DtVector&);
217  void setWorldAcceleration(const DtVector&);
218  void setWorldOrientation(const DtTaitBryan&);
219  void setParentOrientation(const DtTaitBryan&);
220  void setParentPosition(const DtVector&);
221  void setParentStationName(DtStationName);
222  void setWorldOrientationMatrix(const DtDcm&);
223  void setLocalSpeed(double);
224  const DtRwVrfKinematicState& kinematicState() const;
225 
226  const DtVector& relativeVelocity() const;
227  const DtVector& relativeAcceleration() const;
228  const DtVector& parentVelocity() const;
229  const DtVector& parentAcceleration() const;
230  const DtVector bodyVelocity() const;
231 
232  void setCoordinateSystem(const Coordinate_System* cs);
233  void setKinematicState(const DtRwVrfKinematicState&);
234 
235  virtual void refreshKinematicState(const DtEntityLocationStateComponent&);
236 
238  virtual void makeWritable();
239 
241  virtual void makeReadOnly();
242  void slot_hostDestroyed();
243 
244  bool needsEmbarkCheck();
245  void clearNeedsEmbarkCheck();
246 
247  protected:
248  LOM::WriteEntityRepository myWriteEntityStateRepository;
252 
253  mutable tbb::spin_rw_mutex myWriteStateMutex;
255  boost::signals2::scoped_connection myHostDeletedConnection;
257  };
258 
261  {
262  public:
265 
267  const DtEntityLocationStateComponentData& frameState() const { return myData; };
268 
269  const DtUUID& hostGlobalId() const;
270  const int objectAttachMode() const;
271 
272  const DtRwVrfKinematicState& kinematicState() const;
273  const bool frozen() const;
274  const bool localPositionIsValid() const;
275 
279  const DtVector location() const;
280  const DtVector velocity() const;
281  const DtVector acceleration() const;
282  const DtTaitBryan orientation() const;
284 
285  const DtVector& rotationalVelocity() const;
286  const double heading() const;
287  const double pitch() const;
288  const double roll() const;
289  const double localSpeed() const;
290  const double worldSpeed() const;
291 
292  const DtDeadReckonTypes algorithm() const;
293  const DtDeadReckonTypes deadReckoningAlgorithm() const { return algorithm(); };
294  const bool spatiallyFrozen() const;
295  const DtThresholder& thresholder() const;
296 
297  const DtVector& worldPosition() const;
298  const DtVector& worldVelocity() const;
299  const DtVector& worldAcceleration() const;
300  const DtVector& relativePosition() const;
301  const DtVector& parentPosition() const;
302  const DtStationName parentStationName() const;
303  const DtVector& relativeVelocity() const;
304  const DtVector& relativeAcceleration() const;
305  const DtVector& parentVelocity() const;
306  const DtVector& parentAcceleration() const;
307  const DtVector bodyVelocity() const;
308  const DtTaitBryan& worldOrientation() const;
309  const DtTaitBryan& topographicOrientation() const;
310  const DtTaitBryan& parentOrientation() const;
311 
312  const DtDcm& parentOrientationMatrix() const;
313 
314  const DtVector& localPosition() const;
315  const DtVector& localVelocity() const;
316  const DtVector& localAcceleration() const;
317  const DtTaitBryan& localOrientation() const;
318 
319  const DtDcm& worldOrientationMatrix() const;
320  const DtDcm& localOrientationMatrix() const;
321  const DtTaitBryan& localOrientationWrtDatabase() const;
322 
323  const bool locationChanged() const;
324 
325  void setCoordinateSystem(const Coordinate_System* cs);
326  void refreshKinematicState() const;
327 
328  protected:
330 
331  void setLocationChanged(bool);
332  virtual void needsKinematicStateRefresh();
333  virtual void needsEmbarkedCheck();
335  {
336  myData = data;
337  }
338 
339  protected:
340  void handleDataUpdated(const std::vector<UInt32>& attributesUpdated);
341  virtual void updateSpatial();
342  const DtVector _rotationalVelocity() const;
343 
344  protected:
345  LOM::ReadEntityRepository myReadEntityStateRepository;
348 
349  mutable tbb::mutex myKinematicStateMutex;
353  unsigned int myCallbackHandle;
357  };
358 
362  {
363  public:
365 
366  bool isDoubleBuffered() { return true; };
367  const DtFrameStateInterface* currentFrameState() const { return &myCurrentFrameState; }
368  virtual DtFrameStateInterface* nextFrameState() { return &myNextFrameState; };
369  virtual const DtFrameStateInterface* nextFrameState() const { return &myNextFrameState; };
370 
372  virtual void setCoordinateSystem(const Coordinate_System*);
373 
375  virtual bool forceAdvance();
376 
377  void updateDataStorage();
378 
380  {
381  myCurrentFrameState.updateStateData(sd);
382  myNextFrameState.updateStateData(sd);
383  }
384 
385  virtual void aboutToBeDeleted() override
386  {
388  myCurrentFrameState.aboutToBeDeleted();
389  myNextFrameState.aboutToBeDeleted();
390  }
391 
392  virtual void initializeFromParameters(const DtVrfObjectParameters* params);
393 
394  protected:
395  virtual void hostWasDeleted();
396 
397  protected:
402  boost::signals2::scoped_connection myHostWasDeletedConnection;
403  };
404 
408 }
409 
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:63
#define UNDEFINED_METHOD(Type, Method,...)
Definition: doubleBufferedDataStorage.h:68
LOM::WriteEntityRepository myWriteEntityStateRepository
Definition: entityLocationStateComponent.h:248
DtEntityLocationStateComponentCurrentFrame myCurrentFrameState
Definition: entityLocationStateComponent.h:398
DtRwVrfKinematicState * myKinematicState
Definition: entityLocationStateComponent.h:250
The DtLocationStateComponent interface contains the interface that all DtLocationStateComponents can ...
Definition: locationStateComponent.h:25
const DtDeadReckonTypes deadReckoningAlgorithm() const
Definition: entityLocationStateComponent.h:144
bool myFirstVelocitySet
Definition: entityLocationStateComponent.h:256
virtual void aboutToBeDeleted() override
Definition: entityLocationStateComponent.h:385
2) 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: entityLocationStateComponent.h:116
tbb::mutex myKinematicStateMutex
Definition: entityLocationStateComponent.h:349
Definition: stateComponent.h:266
DtEntityLocationStateComponentData & operator=(const DtEntityLocationStateComponentData &rhs)
Definition: entityLocationStateComponent.h:46
DtEntityLocationStateComponentData myData
Definition: entityLocationStateComponent.h:354
unsigned int myCallbackHandle
Definition: entityLocationStateComponent.h:353
DtEntityLocationStateComponentData()
Definition: entityLocationStateComponent.h:30
DtEntityLocationStateComponentData myData
Definition: entityLocationStateComponent.h:254
#define UNDEFINED_RETURNREF_ACCESSORS(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:40
#define UNDEFINED_RETURNVALUE_ACCESSOR(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:31
DtStateComponentCreator< DtEntityLocationStateComponentImplementation > DtEntityLocationStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: entityLocationStateComponent.h:407
#define UNDEFINED_RETURNREF_ACCESSOR(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:34
DtStateDataManager * myStateDataManager
Definition: entityLocationStateComponent.h:347
DtEntityLocationStateComponentData(const DtEntityLocationStateComponentData &orig)
Definition: entityLocationStateComponent.h:37
DtStateData * myStateData
Definition: entityLocationStateComponent.h:249
bool myNeedsEmbarkedCheck
Definition: entityLocationStateComponent.h:356
const DtFrameStateInterface * currentFrameState() const
Definition: entityLocationStateComponent.h:367
void updateStateData(DtStateData *sd)
Implement to update data storage to the new state data.
Definition: entityLocationStateComponent.h:379
3) Define the current frame class. This will be used for read access.
Definition: entityLocationStateComponent.h:260
LOM::ReadEntityRepository myReadEntityStateRepository
Definition: entityLocationStateComponent.h:345
bool mySpatiallyFrozen
Definition: entityLocationStateComponent.h:65
boost::signals2::scoped_connection myHostDeletedConnection
Definition: entityLocationStateComponent.h:255
DtStateDataManager * myStateDataManager
Definition: entityLocationStateComponent.h:251
DtRwVrfKinematicState * myKinematicState
Definition: entityLocationStateComponent.h:351
Definition: coordSystem.h:54
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:339
bool isDoubleBuffered()
Definition: entityLocationStateComponent.h:366
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:228
const DtEntityLocationStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: entityLocationStateComponent.h:267
const DtDeadReckonTypes deadReckoningAlgorithm() const
Definition: entityLocationStateComponent.h:293
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:379
DtEntityLocationStateComponentInterface(DtStateData *storage)
Definition: entityLocationStateComponent.h:74
DtThresholder myThresholder
Definition: entityLocationStateComponent.h:66
bool myNeedsKinematicStateRefresh
Definition: entityLocationStateComponent.h:350
virtual const DtFrameStateInterface * nextFrameState() const
Definition: entityLocationStateComponent.h:369
tbb::spin_rw_mutex myWriteStateMutex
Definition: entityLocationStateComponent.h:253
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:53
virtual void aboutToBeDeleted()
const DtEntityLocationStateComponentData & frameState() const
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: entityLocationStateComponent.h:135
2) Define the next frame class. This will be used for write access.
Definition: entityLocationStateComponent.h:128
DtStateData * myLastAttachedTo
Definition: entityLocationStateComponent.h:401
boost::signals2::scoped_connection myHostWasDeletedConnection
Definition: entityLocationStateComponent.h:402
DtEntityLocationStateComponent * myLastAttachedToLocationStateComponent
Definition: entityLocationStateComponent.h:400
#define UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:57
#define DEFINE_REF_ACCESSORS(ReturnType, Method, Member)
Definition: doubleBufferedDataStorage.h:13
Definition: entityLocationStateComponent.h:71
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Definition: doubleBufferedDataStorage.h:23
bool myNeedsEmbarkCheck
Definition: entityLocationStateComponent.h:68
DtEntityLocationStateComponentData & frameState()
Definition: entityLocationStateComponent.h:136
void advanceFrame(const DtEntityLocationStateComponentData &data)
Definition: entityLocationStateComponent.h:334
DtStateData * myStateData
Definition: entityLocationStateComponent.h:352
Definition: entityLocationStateComponent.h:28
DtStationName myStationName
Definition: entityLocationStateComponent.h:67
Definition: rwVrfKinematicState.h:25
#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
bool myLocationChanged
Definition: entityLocationStateComponent.h:346
DtUUID myHostGlobalId
Definition: entityLocationStateComponent.h:64
unsigned int myEmbarkedCallbackHandle
Definition: entityLocationStateComponent.h:355
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:291
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: entityLocationStateComponent.h:361
DtEntityLocationStateComponentNextFrame myNextFrameState
Definition: entityLocationStateComponent.h:399
virtual DtFrameStateInterface * nextFrameState()
Definition: entityLocationStateComponent.h:368
This class holds the state data that represents each simulation object in the system.
Definition: stateDataManager.h:73

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)