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 {
21  {
23  {
25  : myCurrentShaftRPM(0.)
26  , myOrderedShaftRPM(0.)
27  , myShaftRPM_RateOfChange(0.)
28  {
29  }
30 
32  : myCurrentShaftRPM(orig.myCurrentShaftRPM)
33  , myOrderedShaftRPM(orig.myOrderedShaftRPM)
34  , myShaftRPM_RateOfChange(orig.myShaftRPM_RateOfChange)
35  {
36  }
37 
39  {
40  myCurrentShaftRPM = rhs.myCurrentShaftRPM;
41  myOrderedShaftRPM = rhs.myOrderedShaftRPM;
42  myShaftRPM_RateOfChange = rhs.myShaftRPM_RateOfChange;
43 
44  return *this;
45  }
46 
48  {
49  return ((myCurrentShaftRPM == rhs.myCurrentShaftRPM) &&
50  (myOrderedShaftRPM == rhs.myOrderedShaftRPM) &&
51  (myShaftRPM_RateOfChange == rhs.myShaftRPM_RateOfChange));
52  }
53 
55  {
56  return !(*this == rhs);
57  }
58 
59  DEFINE_ACCESSOR_MUTATOR(unsigned short, currentShaftRPM, CurrentShaftRPM)
60  DEFINE_ACCESSOR_MUTATOR(unsigned short, orderedShaftRPM, OrderedShaftRPM)
61  DEFINE_ACCESSOR_MUTATOR(unsigned short, shaftRPM_RateOfChange, ShaftRPM_RateOfChange)
62 
63  protected:
64  unsigned short myCurrentShaftRPM;
65  unsigned short myOrderedShaftRPM;
66  unsigned short myShaftRPM_RateOfChange;
67  };
68 
70  : myPublish(true)
71  , myPassiveParameterIndex(1)
72  {
73  }
74 
76  : myPublish(orig.myPublish)
77  , myShaftData(orig.myShaftData)
78  , myPassiveParameterIndex(orig.myPassiveParameterIndex)
79  {
80  }
81 
83  {
84  myPublish = rhs.myPublish;
85  myShaftData = rhs.myShaftData;
86  myPassiveParameterIndex = rhs.myPassiveParameterIndex;
87 
88  return *this;
89  }
90 
91  typedef std::vector<UnderwaterAcousticShaftSpeed> ShaftData;
92 
93  DEFINE_ACCESSOR_MUTATOR(bool, publish, Publish)
94  DEFINE_ACCESSOR_MUTATOR(ShaftData, shaftData, ShaftData)
95  DEFINE_ACCESSOR_MUTATOR(int, passiveParameterIndex, PassiveParameterIndex)
96  ShaftData& shaftData() { return myShaftData; };
97 
98  protected:
99  bool myPublish;
100  ShaftData myShaftData{};
102  };
103 
107  {
108  public:
110 
112  : DtFrameStateInterface(storage)
113  {
114  }
115 
117  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(bool, publish, Publish)
118  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, hullMaskerOn, HullMaskerOn)
119  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(int, passiveParameterIndex, PassiveParameterIndex)
120  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(unsigned int, propulsionPlantConfiguration, PropulsionPlantConfiguration)
122  };
123 
126  {
127  public:
130 
132  const DtUnderwaterAcousticsStateComponentData& frameState() const { return myData; };
134 
135  virtual const DtUUID hostId() const override;
136 
137  virtual const bool& publish() const override;
138  virtual void setPublish(const bool&) override;
139 
140  virtual const bool hullMaskerOn() const override;
141  virtual void setHullMaskerOn(const bool&) override;
142 
143  virtual const int& passiveParameterIndex() const override;
144  virtual void setPassiveParameterIndex(const int&) override;
145 
146  virtual const unsigned int propulsionPlantConfiguration() const override;
147  virtual void setPropulsionPlantConfiguration(const unsigned int&) override;
148 
149  virtual const DtUnderwaterAcousticsStateComponentData::ShaftData& shaftData() const override;
150  virtual void setShaftData(const DtUnderwaterAcousticsStateComponentData::ShaftData&) override;
151 
153  virtual void makeWritable() override;
154 
156  virtual void makeReadOnly() override;
157 
158  protected:
160  LOM::WritePropulsionNoiseRepository myWritePropulsionNoiseRepository;
161  };
162 
165  {
166  public:
169 
171  const DtUnderwaterAcousticsStateComponentData& frameState() const { return myData; };
172 
173  virtual const DtUUID hostId() const override;
174  virtual const bool& publish() const override;
175  virtual const bool hullMaskerOn() const override;
176  virtual const DtUnderwaterAcousticsStateComponentData::ShaftData& shaftData() const override;
177  virtual const int& passiveParameterIndex() const override;
178  virtual const unsigned int propulsionPlantConfiguration() const override;
179  bool readComponentValid() const;
180 
181  bool findReadComponent();
182 
183  protected:
184  void handleDataUpdated();
185 
188  {
189  myData = data;
190  }
191 
192  protected:
194  LOM::ReadPropulsionNoiseRepository myReadPropulsionNoiseRepository;
195  unsigned int myCallbackHandle;
196  };
197 
201  {
202  public:
204 
205  bool isDoubleBuffered() { return true; };
206  virtual const DtFrameStateInterface* currentFrameState() const override { return &myCurrentFrameState; }
207  virtual DtFrameStateInterface* nextFrameState() override { return &myNextFrameState; };
208  virtual const DtFrameStateInterface* nextFrameState() const override { return &myNextFrameState; };
209 
210  virtual void updateDataStorage() override
211  {
212  if (myNextFrameState.isWritable())
213  {
214  myCurrentFrameState.advanceFrame(myNextFrameState.frameState());
215  }
216 
217  myCurrentFrameState.emitComponentUpdated();
218  }
219 
220  virtual void updateStateData(DtStateData* sd) override
221  {
222  myCurrentFrameState.updateStateData(sd);
223  myNextFrameState.updateStateData(sd);
224  }
225 
226  virtual void aboutToBeDeleted() override
227  {
229  myCurrentFrameState.aboutToBeDeleted();
230  myNextFrameState.aboutToBeDeleted();
231  }
232 
234  virtual bool forceAdvance() override;
235 
237  virtual void firstFrameAdvance() override;
238 
239  protected:
243  };
244 
248 }
UUID is a unique ID wrapper class.
Definition: uuid.h:59
bool myPublish
Definition: underwaterAcousticsStateComponent.h:96
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: underwaterAcousticsStateComponent.h:200
std::vector< UnderwaterAcousticShaftSpeed > ShaftData
Definition: underwaterAcousticsStateComponent.h:91
DtUnderwaterAcousticsStateComponentData myData
Definition: underwaterAcousticsStateComponent.h:193
LOM::WritePropulsionNoiseRepository myWritePropulsionNoiseRepository
Definition: underwaterAcousticsStateComponent.h:160
virtual void updateDataStorage() override
Implement to update data storage. Called from advanceFrame.
Definition: underwaterAcousticsStateComponent.h:210
3) Define the current frame class. This will be used for read access.
Definition: underwaterAcousticsStateComponent.h:164
DtUnderwaterAcousticsStateComponentData myData
Definition: underwaterAcousticsStateComponent.h:159
LOM::ReadPropulsionNoiseRepository myReadPropulsionNoiseRepository
Definition: underwaterAcousticsStateComponent.h:194
Definition: stateComponent.h:269
UnderwaterAcousticShaftSpeed()
Definition: underwaterAcousticsStateComponent.h:24
DtUnderwaterAcousticsStateComponentData(const DtUnderwaterAcousticsStateComponentData &orig)
Definition: underwaterAcousticsStateComponent.h:75
DtUnderwaterAcousticsStateComponentNextFrame myNextFrameState
Definition: underwaterAcousticsStateComponent.h:241
DtUnderwaterAcousticsStateComponentCurrentFrame myCurrentFrameState
Definition: underwaterAcousticsStateComponent.h:240
#define UNDEFINED_RETURNVALUE_ACCESSOR(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:31
Contains the DtUUID class declaration.
virtual void aboutToBeDeleted() override
Definition: underwaterAcousticsStateComponent.h:226
UnderwaterAcousticShaftSpeed(const UnderwaterAcousticShaftSpeed &orig)
Definition: underwaterAcousticsStateComponent.h:31
ShaftData myShaftData
Definition: underwaterAcousticsStateComponent.h:100
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:132
bool operator==(const UnderwaterAcousticShaftSpeed &rhs) const
Definition: underwaterAcousticsStateComponent.h:47
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:398
unsigned short myShaftRPM_RateOfChange
Definition: underwaterAcousticsStateComponent.h:66
int myPassiveParameterIndex
Definition: underwaterAcousticsStateComponent.h:101
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:231
void advanceFrame(const DtUnderwaterAcousticsStateComponentData &data)
Definition: underwaterAcousticsStateComponent.h:187
virtual const DtFrameStateInterface * currentFrameState() const override
Definition: underwaterAcousticsStateComponent.h:206
UnderwaterAcousticShaftSpeed & operator=(const UnderwaterAcousticShaftSpeed &rhs)
Definition: underwaterAcousticsStateComponent.h:38
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:384
bool isDoubleBuffered()
Definition: underwaterAcousticsStateComponent.h:205
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:53
DtUnderwaterAcousticsStateComponentData & operator=(const DtUnderwaterAcousticsStateComponentData &rhs)
Definition: underwaterAcousticsStateComponent.h:82
virtual void aboutToBeDeleted()
unsigned int myCallbackHandle
Definition: underwaterAcousticsStateComponent.h:195
bool myFoundComponent
Definition: underwaterAcousticsStateComponent.h:242
#define UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:57
virtual DtFrameStateInterface * nextFrameState() override
Definition: underwaterAcousticsStateComponent.h:207
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Definition: doubleBufferedDataStorage.h:23
unsigned short myCurrentShaftRPM
Definition: underwaterAcousticsStateComponent.h:64
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:106
virtual const DtFrameStateInterface * nextFrameState() const override
Definition: underwaterAcousticsStateComponent.h:208
#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
virtual void updateStateData(DtStateData *sd) override
Implement to update data storage to the new state data.
Definition: underwaterAcousticsStateComponent.h:220
const DtUnderwaterAcousticsStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: underwaterAcousticsStateComponent.h:171
2) Define the next frame class. This will be used for write access.
Definition: underwaterAcousticsStateComponent.h:125
DtStateComponentCreator< DtUnderwaterAcousticsStateComponentImplementation > DtUnderwaterAcousticsStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: underwaterAcousticsStateComponent.h:247
Definition: underwaterAcousticsStateComponent.h:20
Contains the DtStateComponent class declaration.
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:294
bool operator!=(const UnderwaterAcousticShaftSpeed &rhs) const
Definition: underwaterAcousticsStateComponent.h:54
unsigned short myOrderedShaftRPM
Definition: underwaterAcousticsStateComponent.h:65
DtUnderwaterAcousticsStateComponentData & frameState()
Definition: underwaterAcousticsStateComponent.h:133

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)