VR-Forces 5.0.3 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 
141  void setAlgorithm(const DtDeadReckonTypes& alg);
142  const DtDeadReckonTypes algorithm() const;
143  const DtDeadReckonTypes deadReckoningAlgorithm() const { return algorithm(); };
144 
145  const bool frozen() const;
146  void setFrozen(const bool&);
147 
151  const DtVector location() const;
152  void setLocation(const DtVector&);
153 
154  const DtVector velocity() const;
155  void setVelocity(const DtVector&);
156 
157  const DtVector acceleration() const;
158  void setAcceleration(const DtVector&);
159 
160  const DtTaitBryan orientation() const;
161  void setOrientation(const DtTaitBryan&);
163 
164  const DtVector& rotationalVelocity() const;
165  void setRotationalVelocity(const DtVector&);
166 
167  const bool locationChanged() const;
168 
169  const DtVector& worldPosition() const;
170  const DtVector& relativePosition() const;
171  const DtVector& parentPosition() const;
172  const DtStationName parentStationName() const;
173  const DtVector& localPosition() const;
174  const DtVector& worldVelocity() const;
175  const DtVector& localVelocity() const;
176  const DtVector& worldAcceleration() const;
177  const DtVector& localAcceleration() const;
178  const DtTaitBryan& worldOrientation() const;
179  const DtTaitBryan& topographicOrientation() const;
180  const DtTaitBryan& parentOrientation() const;
181  const DtTaitBryan& localOrientation() const;
182  const DtDcm& worldOrientationMatrix() const;
183  const bool localPositionIsValid() const;
184 
185  const bool spatiallyFrozen() const;
186  void setSpatiallyFrozen(const bool&);
187 
188  const DtThresholder& thresholder() const;
189  DtThresholder& thresholder();
190 
191  const double heading() const;
192  const double pitch() const;
193  const double roll() const;
194 
195  const double localSpeed() const;
196 
197  const double worldSpeed() const;
198 
199  const DtDcm& parentOrientationMatrix() const;
200  void setLocalOrientationMatrix(const DtDcm&);
201  void setLocalOrientation(const DtTaitBryan&);
202  void setLocalOrientationWrtDatabase(const DtTaitBryan&);
203 
204  const DtDcm& localOrientationMatrix() const;
205  const DtTaitBryan& localOrientationWrtDatabase() const;
206 
207  void setRelativeVelocity(const DtVector&);
208  void setRelativeAcceleration(const DtVector&);
209  void setParentVelocity(const DtVector&);
210  void setParentAcceleration(const DtVector&);
211  void setLocalVelocity(const DtVector&);
212  void setLocalAcceleration(const DtVector&);
213  void setLocalPosition(const DtVector&);
214  void setWorldPosition(const DtVector&);
215  void setWorldVelocity(const DtVector&);
216  void setWorldAcceleration(const DtVector&);
217  void setWorldOrientation(const DtTaitBryan&);
218  void setParentOrientation(const DtTaitBryan&);
219  void setParentPosition(const DtVector&);
220  void setParentStationName(DtStationName);
221  void setWorldOrientationMatrix(const DtDcm&);
222  void setLocalSpeed(double);
223  const DtRwVrfKinematicState& kinematicState() const;
224 
225  const DtVector& relativeVelocity() const;
226  const DtVector& relativeAcceleration() const;
227  const DtVector& parentVelocity() const;
228  const DtVector& parentAcceleration() const;
229  const DtVector bodyVelocity() const;
230 
231  void setCoordinateSystem(const Coordinate_System* cs);
232  void setKinematicState(const DtRwVrfKinematicState&);
233 
234  virtual void refreshKinematicState(const DtEntityLocationStateComponent&);
235 
237  virtual void makeWritable();
238 
240  virtual void makeReadOnly();
241  void slot_hostDestroyed();
242 
243  bool needsEmbarkCheck();
244  void clearNeedsEmbarkCheck();
245 
246  protected:
247  LOM::WriteEntityRepository myWriteEntityStateRepository;
251 
252  mutable tbb::spin_rw_mutex myWriteStateMutex;
254  boost::signals2::scoped_connection myHostDeletedConnection;
256  };
257 
260  {
261  public:
264 
266  const DtEntityLocationStateComponentData& frameState() const { return myData; };
267 
268  const DtUUID& hostGlobalId() const;
269 
270  const DtRwVrfKinematicState& kinematicState() const;
271  const bool frozen() const;
272  const bool localPositionIsValid() const;
273 
277  const DtVector location() const;
278  const DtVector velocity() const;
279  const DtVector acceleration() const;
280  const DtTaitBryan orientation() const;
282 
283  const DtVector& rotationalVelocity() const;
284  const double heading() const;
285  const double pitch() const;
286  const double roll() const;
287  const double localSpeed() const;
288  const double worldSpeed() const;
289 
290  const DtDeadReckonTypes algorithm() const;
291  const DtDeadReckonTypes deadReckoningAlgorithm() const { return algorithm(); };
292  const bool spatiallyFrozen() const;
293  const DtThresholder& thresholder() const;
294 
295  const DtVector& worldPosition() const;
296  const DtVector& worldVelocity() const;
297  const DtVector& worldAcceleration() const;
298  const DtVector& relativePosition() const;
299  const DtVector& parentPosition() const;
300  const DtStationName parentStationName() const;
301  const DtVector& relativeVelocity() const;
302  const DtVector& relativeAcceleration() const;
303  const DtVector& parentVelocity() const;
304  const DtVector& parentAcceleration() const;
305  const DtVector bodyVelocity() const;
306  const DtTaitBryan& worldOrientation() const;
307  const DtTaitBryan& topographicOrientation() const;
308  const DtTaitBryan& parentOrientation() const;
309 
310  const DtDcm& parentOrientationMatrix() const;
311 
312  const DtVector& localPosition() const;
313  const DtVector& localVelocity() const;
314  const DtVector& localAcceleration() const;
315  const DtTaitBryan& localOrientation() const;
316 
317  const DtDcm& worldOrientationMatrix() const;
318  const DtDcm& localOrientationMatrix() const;
319  const DtTaitBryan& localOrientationWrtDatabase() const;
320 
321  const bool locationChanged() const;
322 
323  void setCoordinateSystem(const Coordinate_System* cs);
324  void refreshKinematicState() const;
325 
326  protected:
328 
329  void setLocationChanged(bool);
330  virtual void needsKinematicStateRefresh();
331  virtual void needsEmbarkedCheck();
333  {
334  myData = data;
335  }
336 
337  protected:
338  void handleDataUpdated(const std::vector<UInt32>& attributesUpdated);
339  virtual void updateSpatial();
340  const DtVector _rotationalVelocity() const;
341 
342  protected:
343  LOM::ReadEntityRepository myReadEntityStateRepository;
346 
347  mutable tbb::mutex myKinematicStateMutex;
351  unsigned int myCallbackHandle;
355  };
356 
360  {
361  public:
363 
364  bool isDoubleBuffered() { return true; };
365  const DtFrameStateInterface* currentFrameState() const { return &myCurrentFrameState; }
366  virtual DtFrameStateInterface* nextFrameState() { return &myNextFrameState; };
367  virtual const DtFrameStateInterface* nextFrameState() const { return &myNextFrameState; };
368 
370  virtual void setCoordinateSystem(const Coordinate_System*);
371 
373  virtual bool forceAdvance();
374 
375  void updateDataStorage();
376 
378  {
379  myCurrentFrameState.updateStateData(sd);
380  myNextFrameState.updateStateData(sd);
381  }
382 
383  virtual void aboutToBeDeleted() override
384  {
386  myCurrentFrameState.aboutToBeDeleted();
387  myNextFrameState.aboutToBeDeleted();
388  }
389 
390  virtual void initializeFromParameters(const DtVrfObjectParameters* params);
391 
392  protected:
393  virtual void hostWasDeleted();
394 
395  protected:
400  boost::signals2::scoped_connection myHostWasDeletedConnection;
401  };
402 
406 }
407 
UUID is a unique ID wrapper class.
Definition: rwUUID.h:229
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:247
DtEntityLocationStateComponentCurrentFrame myCurrentFrameState
Definition: entityLocationStateComponent.h:396
DtRwVrfKinematicState * myKinematicState
Definition: entityLocationStateComponent.h:249
The DtLocationStateComponent interface contains the interface that all DtLocationStateComponents can ...
Definition: locationStateComponent.h:25
const DtDeadReckonTypes deadReckoningAlgorithm() const
Definition: entityLocationStateComponent.h:143
bool myFirstVelocitySet
Definition: entityLocationStateComponent.h:255
virtual void aboutToBeDeleted() override
Definition: entityLocationStateComponent.h:383
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:347
Definition: stateComponent.h:257
DtEntityLocationStateComponentData & operator=(const DtEntityLocationStateComponentData &rhs)
Definition: entityLocationStateComponent.h:46
DtEntityLocationStateComponentData myData
Definition: entityLocationStateComponent.h:352
unsigned int myCallbackHandle
Definition: entityLocationStateComponent.h:351
DtEntityLocationStateComponentData()
Definition: entityLocationStateComponent.h:30
DtEntityLocationStateComponentData myData
Definition: entityLocationStateComponent.h:253
#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:405
#define UNDEFINED_RETURNREF_ACCESSOR(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:34
DtStateDataManager * myStateDataManager
Definition: entityLocationStateComponent.h:345
DtEntityLocationStateComponentData(const DtEntityLocationStateComponentData &orig)
Definition: entityLocationStateComponent.h:37
DtStateData * myStateData
Definition: entityLocationStateComponent.h:248
bool myNeedsEmbarkedCheck
Definition: entityLocationStateComponent.h:354
const DtFrameStateInterface * currentFrameState() const
Definition: entityLocationStateComponent.h:365
void updateStateData(DtStateData *sd)
Implement to update data storage to the new state data.
Definition: entityLocationStateComponent.h:377
3) Define the current frame class. This will be used for read access.
Definition: entityLocationStateComponent.h:259
LOM::ReadEntityRepository myReadEntityStateRepository
Definition: entityLocationStateComponent.h:343
bool mySpatiallyFrozen
Definition: entityLocationStateComponent.h:65
boost::signals2::scoped_connection myHostDeletedConnection
Definition: entityLocationStateComponent.h:254
DtStateDataManager * myStateDataManager
Definition: entityLocationStateComponent.h:250
DtRwVrfKinematicState * myKinematicState
Definition: entityLocationStateComponent.h:349
Definition: coordSystem.h:54
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:336
bool isDoubleBuffered()
Definition: entityLocationStateComponent.h:364
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:219
const DtEntityLocationStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: entityLocationStateComponent.h:266
const DtDeadReckonTypes deadReckoningAlgorithm() const
Definition: entityLocationStateComponent.h:291
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:370
DtEntityLocationStateComponentInterface(DtStateData *storage)
Definition: entityLocationStateComponent.h:74
DtThresholder myThresholder
Definition: entityLocationStateComponent.h:66
bool myNeedsKinematicStateRefresh
Definition: entityLocationStateComponent.h:348
virtual const DtFrameStateInterface * nextFrameState() const
Definition: entityLocationStateComponent.h:367
tbb::spin_rw_mutex myWriteStateMutex
Definition: entityLocationStateComponent.h:252
#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:399
boost::signals2::scoped_connection myHostWasDeletedConnection
Definition: entityLocationStateComponent.h:400
DtEntityLocationStateComponent * myLastAttachedToLocationStateComponent
Definition: entityLocationStateComponent.h:398
#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:332
DtStateData * myStateData
Definition: entityLocationStateComponent.h:350
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:344
DtUUID myHostGlobalId
Definition: entityLocationStateComponent.h:64
unsigned int myEmbarkedCallbackHandle
Definition: entityLocationStateComponent.h:353
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:282
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: entityLocationStateComponent.h:359
DtEntityLocationStateComponentNextFrame myNextFrameState
Definition: entityLocationStateComponent.h:397
virtual DtFrameStateInterface * nextFrameState()
Definition: entityLocationStateComponent.h:366
This class holds the state data that represents each simulation object in the system.
Definition: stateDataManager.h:71

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)