VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
underwaterAcousticsStateComponent.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 
11 #include <legionStandardOM/sets/readPropulsionNoiseRepository.hpp>
12 #include <legionStandardOM/sets/writePropulsionNoiseRepository.hpp>
13 #include <vrfutil/rwUUID.h>
14 
15 #include <vlutil/vlString.h>
16 #include <matrix/vlVector.h>
17 
18 namespace makVrf
19 {
22  {
25  {
27  : myCurrentShaftRPM(0.)
28  , myOrderedShaftRPM(0.)
29  , myShaftRPM_RateOfChange(0.)
30  {
31  }
32 
34  : myCurrentShaftRPM(orig.myCurrentShaftRPM)
35  , myOrderedShaftRPM(orig.myOrderedShaftRPM)
36  , myShaftRPM_RateOfChange(orig.myShaftRPM_RateOfChange)
37  {
38  }
39 
41  {
42  myCurrentShaftRPM = rhs.myCurrentShaftRPM;
43  myOrderedShaftRPM = rhs.myOrderedShaftRPM;
44  myShaftRPM_RateOfChange = rhs.myShaftRPM_RateOfChange;
45 
46  return *this;
47  }
48 
50  {
51  return ((myCurrentShaftRPM == rhs.myCurrentShaftRPM) &&
52  (myOrderedShaftRPM == rhs.myOrderedShaftRPM) &&
53  (myShaftRPM_RateOfChange == rhs.myShaftRPM_RateOfChange));
54  }
55 
57  {
58  return !(*this == rhs);
59  }
60 
61  DEFINE_ACCESSOR_MUTATOR(unsigned short, currentShaftRPM, CurrentShaftRPM)
62  DEFINE_ACCESSOR_MUTATOR(unsigned short, orderedShaftRPM, OrderedShaftRPM)
63  DEFINE_ACCESSOR_MUTATOR(unsigned short, shaftRPM_RateOfChange, ShaftRPM_RateOfChange)
64 
65  protected:
67  unsigned short myCurrentShaftRPM;
69  unsigned short myOrderedShaftRPM;
71  unsigned short myShaftRPM_RateOfChange;
72  };
73 
75  : myPublish(true)
76  , myPassiveParameterIndex(1)
77  {
78  }
79 
81  : myPublish(orig.myPublish)
82  , myShaftData(orig.myShaftData)
83  , myPassiveParameterIndex(orig.myPassiveParameterIndex)
84  {
85  }
86 
88  {
89  myPublish = rhs.myPublish;
90  myShaftData = rhs.myShaftData;
91  myPassiveParameterIndex = rhs.myPassiveParameterIndex;
92 
93  return *this;
94  }
95 
96  typedef std::vector<UnderwaterAcousticShaftSpeed> ShaftData;
97 
98  DEFINE_ACCESSOR_MUTATOR(bool, publish, Publish)
99  DEFINE_ACCESSOR_MUTATOR(ShaftData, shaftData, ShaftData)
100  DEFINE_ACCESSOR_MUTATOR(int, passiveParameterIndex, PassiveParameterIndex)
101  ShaftData& shaftData() { return myShaftData; };
102 
103  protected:
105  bool myPublish;
107  ShaftData myShaftData{};
110  };
111 
115  {
116  public:
118 
120  : DtFrameStateInterface(storage)
121  {
122  }
123 
125  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(bool, publish, Publish)
126  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, hullMaskerOn, HullMaskerOn)
127  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(int, passiveParameterIndex, PassiveParameterIndex)
128  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(unsigned int, propulsionPlantConfiguration, PropulsionPlantConfiguration)
130  };
131 
134  {
135  public:
140 
142  const DtUnderwaterAcousticsStateComponentData& frameState() const { return myData; };
144 
147  virtual const DtUUID hostId() const override;
148 
151  virtual const bool& publish() const override;
154  virtual void setPublish(const bool&) override;
155 
158  virtual const bool hullMaskerOn() const override;
161  virtual void setHullMaskerOn(const bool&) override;
162 
165  virtual const int& passiveParameterIndex() const override;
168  virtual void setPassiveParameterIndex(const int&) override;
169 
172  virtual const unsigned int propulsionPlantConfiguration() const override;
175  virtual void setPropulsionPlantConfiguration(const unsigned int&) override;
176 
179  virtual const DtUnderwaterAcousticsStateComponentData::ShaftData& shaftData() const override;
182  virtual void setShaftData(const DtUnderwaterAcousticsStateComponentData::ShaftData&) override;
183 
185  virtual void makeWritable() override;
186 
188  virtual void makeReadOnly() override;
189 
190  protected:
194  LOM::WritePropulsionNoiseRepository myWritePropulsionNoiseRepository;
195  };
196 
199  {
200  public:
205 
207  const DtUnderwaterAcousticsStateComponentData& frameState() const { return myData; };
208 
211  virtual const DtUUID hostId() const override;
214  virtual const bool& publish() const override;
217  virtual const bool hullMaskerOn() const override;
220  virtual const DtUnderwaterAcousticsStateComponentData::ShaftData& shaftData() const override;
223  virtual const int& passiveParameterIndex() const override;
226  virtual const unsigned int propulsionPlantConfiguration() const override;
229  bool readComponentValid() const;
230 
233  bool findReadComponent();
234 
235  protected:
237  void handleDataUpdated();
238 
243  {
244  myData = data;
245  }
246 
247  protected:
251  LOM::ReadPropulsionNoiseRepository myReadPropulsionNoiseRepository;
253  unsigned int myCallbackHandle;
254  };
255 
259  {
260  public:
264 
266  bool isDoubleBuffered() { return true; };
269  virtual const DtFrameStateInterface* currentFrameState() const override { return &myCurrentFrameState; }
272  virtual DtFrameStateInterface* nextFrameState() override { return &myNextFrameState; };
275  virtual const DtFrameStateInterface* nextFrameState() const override { return &myNextFrameState; };
276 
278  virtual void updateDataStorage() override
279  {
280  if (myNextFrameState.isWritable())
281  {
282  myCurrentFrameState.advanceFrame(myNextFrameState.frameState());
283  }
284 
285  myCurrentFrameState.emitComponentUpdated();
286  }
287 
290  virtual void updateStateData(DtStateData* sd) override
291  {
292  myCurrentFrameState.updateStateData(sd);
293  myNextFrameState.updateStateData(sd);
294  }
295 
297  virtual void aboutToBeDeleted() override
298  {
300  myCurrentFrameState.aboutToBeDeleted();
301  myNextFrameState.aboutToBeDeleted();
302  }
303 
305  virtual bool forceAdvance() override;
306 
308  virtual void firstFrameAdvance() override;
309 
310  protected:
317  };
318 
322 }
UUID is a unique ID wrapper class.
Definition: uuid.h:59
bool myPublish
Whether this component&#39;s data should be published to the network.
Definition: underwaterAcousticsStateComponent.h:101
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: underwaterAcousticsStateComponent.h:258
std::vector< UnderwaterAcousticShaftSpeed > ShaftData
Definition: underwaterAcousticsStateComponent.h:96
DtUnderwaterAcousticsStateComponentData myData
Current frame data storage for this component.
Definition: underwaterAcousticsStateComponent.h:249
LOM::WritePropulsionNoiseRepository myWritePropulsionNoiseRepository
Legion write interface for propulsion noise data.
Definition: underwaterAcousticsStateComponent.h:194
virtual void updateDataStorage() override
Advances the current frame data from the next frame and emits an update notification.
Definition: underwaterAcousticsStateComponent.h:278
3) Define the current frame class. This will be used for read access.
Definition: underwaterAcousticsStateComponent.h:198
DtUnderwaterAcousticsStateComponentData myData
Next frame data storage for this component.
Definition: underwaterAcousticsStateComponent.h:192
LOM::ReadPropulsionNoiseRepository myReadPropulsionNoiseRepository
Legion read interface for propulsion noise data.
Definition: underwaterAcousticsStateComponent.h:251
Default creator implementation for a state component type. T_StateComponent is the concrete component...
Definition: stateComponent.h:326
UnderwaterAcousticShaftSpeed()
Definition: underwaterAcousticsStateComponent.h:26
DtUnderwaterAcousticsStateComponentData(const DtUnderwaterAcousticsStateComponentData &orig)
Definition: underwaterAcousticsStateComponent.h:80
DtUnderwaterAcousticsStateComponentNextFrame myNextFrameState
Next (writable) frame state for this component.
Definition: underwaterAcousticsStateComponent.h:314
DtUnderwaterAcousticsStateComponentCurrentFrame myCurrentFrameState
Current (read-only) frame state for this component.
Definition: underwaterAcousticsStateComponent.h:312
#define UNDEFINED_RETURNVALUE_ACCESSOR(ReturnType, Member)
Defines a virtual const accessor that throws DtUnimplementedMethod, marking the method as requiring a...
Definition: doubleBufferedDataStorage.h:53
Contains the DtUUID class declaration.
virtual void aboutToBeDeleted() override
Cleans up both frame states before this component is deleted.
Definition: underwaterAcousticsStateComponent.h:297
UnderwaterAcousticShaftSpeed(const UnderwaterAcousticShaftSpeed &orig)
Definition: underwaterAcousticsStateComponent.h:33
ShaftData myShaftData
Per-shaft speed data for all propeller shafts.
Definition: underwaterAcousticsStateComponent.h:107
const DtUnderwaterAcousticsStateComponentData & frameState() const
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: underwaterAcousticsStateComponent.h:142
bool operator==(const UnderwaterAcousticShaftSpeed &rhs) const
Definition: underwaterAcousticsStateComponent.h:49
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:513
unsigned short myShaftRPM_RateOfChange
Rate of change of shaft RPM.
Definition: underwaterAcousticsStateComponent.h:71
int myPassiveParameterIndex
Index into the passive acoustic parameter set.
Definition: underwaterAcousticsStateComponent.h:109
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Macro to define all required static and virtual state component type methods. Place in the public sec...
Definition: stateComponent.h:272
void advanceFrame(const DtUnderwaterAcousticsStateComponentData &data)
Advances the current frame to the given data snapshot.
Definition: underwaterAcousticsStateComponent.h:242
virtual const DtFrameStateInterface * currentFrameState() const override
Returns the current (read) frame state interface.
Definition: underwaterAcousticsStateComponent.h:269
UnderwaterAcousticShaftSpeed & operator=(const UnderwaterAcousticShaftSpeed &rhs)
Definition: underwaterAcousticsStateComponent.h:40
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:489
bool isDoubleBuffered()
Returns true; this component uses double-buffered data storage.
Definition: underwaterAcousticsStateComponent.h:266
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Defines an undefined virtual by-value accessor and an undefined virtual setter, both throwing DtUnimp...
Definition: doubleBufferedDataStorage.h:103
DtUnderwaterAcousticsStateComponentData & operator=(const DtUnderwaterAcousticsStateComponentData &rhs)
Definition: underwaterAcousticsStateComponent.h:87
virtual void aboutToBeDeleted()
Called when the component is about to be deleted; emits signal_stateComponentAboutToBeDeleted.
unsigned int myCallbackHandle
Handle for the legion instance-updated callback.
Definition: underwaterAcousticsStateComponent.h:253
bool myFoundComponent
Tracks whether the legion read component has been successfully found.
Definition: underwaterAcousticsStateComponent.h:316
#define UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(Type, Member, Set)
Defines an undefined virtual const-reference accessor and an undefined virtual setter, both throwing DtUnimplementedMethod and requiring overrides in a derived class.
Definition: doubleBufferedDataStorage.h:112
virtual DtFrameStateInterface * nextFrameState() override
Returns the next (write) frame state interface.
Definition: underwaterAcousticsStateComponent.h:272
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Defines a const reference accessor and an inline setter for a member variable.
Definition: doubleBufferedDataStorage.h:37
unsigned short myCurrentShaftRPM
Current measured shaft rotation rate in RPM.
Definition: underwaterAcousticsStateComponent.h:67
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: underwaterAcousticsStateComponent.h:114
virtual const DtFrameStateInterface * nextFrameState() const override
Returns the next (write) frame state interface (const overload).
Definition: underwaterAcousticsStateComponent.h:275
#define DT_DLL_vrfStateData
This file is used to determine how to build Disable inconsistent dll linkage warning Visual Studio 6...
Definition: vrfStateDataDefines.h:29
Shaft speed record for a single propeller shaft.
Definition: underwaterAcousticsStateComponent.h:24
virtual void updateStateData(DtStateData *sd) override
Updates both frame states to reference the new state data storage.
Definition: underwaterAcousticsStateComponent.h:290
const DtUnderwaterAcousticsStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: underwaterAcousticsStateComponent.h:207
2) Define the next frame class. This will be used for write access.
Definition: underwaterAcousticsStateComponent.h:133
DtStateComponentCreator< DtUnderwaterAcousticsStateComponentImplementation > DtUnderwaterAcousticsStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: underwaterAcousticsStateComponent.h:321
Data container for the underwater acoustics state component, holding shaft speed and acoustic paramet...
Definition: underwaterAcousticsStateComponent.h:21
Contains the DtStateComponent class declaration.
Base interface for accessing current or next frame state in a double-buffered state component...
Definition: stateComponent.h:354
bool operator!=(const UnderwaterAcousticShaftSpeed &rhs) const
Definition: underwaterAcousticsStateComponent.h:56
unsigned short myOrderedShaftRPM
Ordered (commanded) shaft rotation rate in RPM.
Definition: underwaterAcousticsStateComponent.h:69
DtUnderwaterAcousticsStateComponentData & frameState()
Definition: underwaterAcousticsStateComponent.h:143

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)