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;
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  const DtUUID hostId() const;
136 
137  const bool& publish() const;
138  void setPublish(const bool&);
139 
140  const bool hullMaskerOn() const;
141  void setHullMaskerOn(const bool&);
142 
143  const int& passiveParameterIndex() const;
144  void setPassiveParameterIndex(const int&);
145 
146  const unsigned int propulsionPlantConfiguration() const;
147  void setPropulsionPlantConfiguration(const unsigned int&);
148 
150  void setShaftData(const DtUnderwaterAcousticsStateComponentData::ShaftData&);
151 
153  virtual void makeWritable();
154 
156  virtual void makeReadOnly();
157 
158  protected:
160  LOM::WritePropulsionNoiseRepository myWritePropulsionNoiseRepository;
162  };
163 
166  {
167  public:
170 
172  const DtUnderwaterAcousticsStateComponentData& frameState() const { return myData; };
173 
174  const DtUUID hostId() const;
175  const bool& publish() const;
176  const bool hullMaskerOn() const;
178  const int& passiveParameterIndex() const;
179  const unsigned int propulsionPlantConfiguration() const;
180  bool readComponentValid() const;
181 
182  bool findReadComponent();
183 
184  protected:
185  void handleDataUpdated();
186 
189  {
190  myData = data;
191  }
192 
193  protected:
195  LOM::ReadPropulsionNoiseRepository myReadPropulsionNoiseRepository;
197  unsigned int myCallbackHandle;
198  };
199 
203  {
204  public:
206 
207  bool isDoubleBuffered() { return true; };
208  const DtFrameStateInterface* currentFrameState() const { return &myCurrentFrameState; }
209  virtual DtFrameStateInterface* nextFrameState() { return &myNextFrameState; };
210  virtual const DtFrameStateInterface* nextFrameState() const { return &myNextFrameState; };
211 
213  {
214  if (myNextFrameState.isWritable())
215  {
216  myCurrentFrameState.advanceFrame(myNextFrameState.frameState());
217  }
218 
219  myCurrentFrameState.emitComponentUpdated();
220  }
221 
223  {
224  myCurrentFrameState.updateStateData(sd);
225  myNextFrameState.updateStateData(sd);
226  }
227 
228  virtual void aboutToBeDeleted() override
229  {
231  myCurrentFrameState.aboutToBeDeleted();
232  myNextFrameState.aboutToBeDeleted();
233  }
234 
236  virtual bool forceAdvance();
237 
239  virtual void firstFrameAdvance() override;
240 
241  protected:
245  };
246 
250 }
UUID is a unique ID wrapper class.
Definition: uuid.h:59
const DtFrameStateInterface * currentFrameState() const
Definition: underwaterAcousticsStateComponent.h:208
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:202
std::vector< UnderwaterAcousticShaftSpeed > ShaftData
Definition: underwaterAcousticsStateComponent.h:91
DtUnderwaterAcousticsStateComponentData myData
Definition: underwaterAcousticsStateComponent.h:194
LOM::WritePropulsionNoiseRepository myWritePropulsionNoiseRepository
Definition: underwaterAcousticsStateComponent.h:160
virtual const DtFrameStateInterface * nextFrameState() const
Definition: underwaterAcousticsStateComponent.h:210
3) Define the current frame class. This will be used for read access.
Definition: underwaterAcousticsStateComponent.h:165
DtUnderwaterAcousticsStateComponentData myData
Definition: underwaterAcousticsStateComponent.h:159
LOM::ReadPropulsionNoiseRepository myReadPropulsionNoiseRepository
Definition: underwaterAcousticsStateComponent.h:195
Definition: stateComponent.h:266
UnderwaterAcousticShaftSpeed()
Definition: underwaterAcousticsStateComponent.h:24
DtUnderwaterAcousticsStateComponentData(const DtUnderwaterAcousticsStateComponentData &orig)
Definition: underwaterAcousticsStateComponent.h:75
DtUnderwaterAcousticsStateComponentNextFrame myNextFrameState
Definition: underwaterAcousticsStateComponent.h:243
DtStateData * myStateData
Definition: underwaterAcousticsStateComponent.h:161
DtUnderwaterAcousticsStateComponentCurrentFrame myCurrentFrameState
Definition: underwaterAcousticsStateComponent.h:242
#define UNDEFINED_RETURNVALUE_ACCESSOR(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:31
void updateStateData(DtStateData *sd)
Implement to update data storage to the new state data.
Definition: underwaterAcousticsStateComponent.h:222
Contains the DtUUID class declaration.
virtual void aboutToBeDeleted() override
Definition: underwaterAcousticsStateComponent.h:228
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:339
unsigned short myShaftRPM_RateOfChange
Definition: underwaterAcousticsStateComponent.h:66
int myPassiveParameterIndex
Definition: underwaterAcousticsStateComponent.h:101
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:228
void advanceFrame(const DtUnderwaterAcousticsStateComponentData &data)
Definition: underwaterAcousticsStateComponent.h:188
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:379
bool isDoubleBuffered()
Definition: underwaterAcousticsStateComponent.h:207
#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:197
bool myFoundComponent
Definition: underwaterAcousticsStateComponent.h:244
virtual DtFrameStateInterface * nextFrameState()
Definition: underwaterAcousticsStateComponent.h:209
#define UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:57
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Definition: doubleBufferedDataStorage.h:23
unsigned short myCurrentShaftRPM
Definition: underwaterAcousticsStateComponent.h:64
void updateDataStorage()
Implement to update data storage. Called from advanceFrame.
Definition: underwaterAcousticsStateComponent.h:212
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
#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
const DtUnderwaterAcousticsStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: underwaterAcousticsStateComponent.h:172
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:249
Definition: underwaterAcousticsStateComponent.h:20
Contains the DtStateComponent class declaration.
DtStateData * myStateData
Definition: underwaterAcousticsStateComponent.h:196
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:291
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 Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)