VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
activeSonarStateComponent.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 <vrfutil/rwUUID.h>
12 #include <matrix/vlVector.h>
13 
14 namespace makVrf
15 {
18  {
20  : mySystemId(0)
21  , myBeamId(0)
22  , myAzimuthCenter(0.)
23  , myAzimuthBeamWidth(0.)
24  , myElevationCenter(0.)
25  , myElevationBeamWidth(0.)
26  , myActiveEmissionParameterIndex(0)
27  , myScanPattern(0)
28  {
29  }
30 
32  : mySystemId(orig.mySystemId)
33  , myBeamId(orig.myBeamId)
34  , myAzimuthCenter(orig.myAzimuthCenter)
35  , myAzimuthBeamWidth(orig.myAzimuthBeamWidth)
36  , myElevationCenter(orig.myElevationCenter)
37  , myElevationBeamWidth(orig.myElevationBeamWidth)
38  , myActiveEmissionParameterIndex(orig.myActiveEmissionParameterIndex)
39  , myScanPattern(orig.myScanPattern)
40  {
41  }
42 
44  {
45  mySystemId = rhs.mySystemId;
46  myBeamId = rhs.myBeamId;
47  myAzimuthCenter = rhs.myAzimuthCenter;
48  myAzimuthBeamWidth = rhs.myAzimuthBeamWidth;
49  myElevationCenter = rhs.myElevationCenter;
50  myElevationBeamWidth = rhs.myElevationBeamWidth;
51  myActiveEmissionParameterIndex = rhs.myActiveEmissionParameterIndex;
52  myScanPattern = rhs.myScanPattern;
53 
54  return *this;
55  }
56 
57  DEFINE_ACCESSOR_MUTATOR(unsigned int, beamId, BeamId)
58  DEFINE_ACCESSOR_MUTATOR(unsigned int, systemId, SystemId)
59  DEFINE_ACCESSOR_MUTATOR(unsigned int, activeEmissionParameterIndex, ActiveEmissionParameterIndex)
60  DEFINE_ACCESSOR_MUTATOR(unsigned int, scanPattern, ScanPattern)
61  DEFINE_ACCESSOR_MUTATOR(double, azimuthCenter, AzimuthCenter)
62  DEFINE_ACCESSOR_MUTATOR(double, azimuthBeamWidth, AzimuthBeamWidth)
63  DEFINE_ACCESSOR_MUTATOR(double, elevationCenter, ElevationCenter)
64  DEFINE_ACCESSOR_MUTATOR(double, elevationBeamWidth, ElevationBeamWidth)
65 
66  protected:
67  unsigned int myBeamId;
68  unsigned int mySystemId;
69  double myAzimuthCenter;
70  double myAzimuthBeamWidth;
71  double myElevationCenter;
72  double myElevationBeamWidth;
73  unsigned int myActiveEmissionParameterIndex;
74  unsigned int myScanPattern;
75  };
76 
78  {
80  {
81  public:
83  : nextId(0)
84  {};
85 
87  : beams(orig.beams)
88  {
89  };
90 
92  {
93  beams = rhs.beams;
94 
95  return *this;
96  }
97 
98  int size() const
99  {
100  return beams.size();
101  }
102 
103  DtActiveSonarBeamStateData* operator[](unsigned short beamId)
104  {
105  std::vector<DtActiveSonarBeamStateData>::iterator iter = beams.begin();
106  std::vector<DtActiveSonarBeamStateData>::iterator end = beams.end();
107  while (iter != end)
108  {
109  if (iter->beamId() == beamId)
110  {
111  return &(*iter);
112  }
113 
114  ++iter;
115  }
116 
117  return nullptr;
118  }
119 
120  const DtActiveSonarBeamStateData* operator[](unsigned short beamId) const
121  {
122  std::vector<DtActiveSonarBeamStateData>::const_iterator iter = beams.begin();
123  std::vector<DtActiveSonarBeamStateData>::const_iterator end = beams.end();
124  while (iter != end)
125  {
126  if (iter->beamId() == beamId)
127  {
128  return &(*iter);
129  }
130 
131  ++iter;
132  }
133 
134  return nullptr;
135  }
136 
137  void removeBeam(unsigned short beamId)
138  {
139  std::vector<DtActiveSonarBeamStateData>::iterator iter = beams.begin();
140  std::vector<DtActiveSonarBeamStateData>::iterator end = beams.end();
141  while (iter != end)
142  {
143  if (iter->beamId() == beamId)
144  {
145  beams.erase(iter);
146  break;
147  }
148 
149  ++iter;
150  }
151  }
152 
153  DtActiveSonarBeamStateData* beamByBeamId(unsigned short beamId)
154  {
155  return (*this)[beamId];
156  }
157 
158  const DtActiveSonarBeamStateData* beamByBeamId(unsigned short beamId) const
159  {
160  return (*this)[beamId];
161  }
162 
164  {
165  if (index < beams.size())
166  {
167  return &beams[index];
168  }
169 
170  return nullptr;
171  }
172 
173  const DtActiveSonarBeamStateData* beamByBeamIndex(unsigned short index) const
174  {
175  if (index < beams.size())
176  {
177  return &beams[index];
178  }
179 
180  return nullptr;
181  }
182 
184  {
185  unsigned short id = nextBeamId();
186 
188  data.setBeamId(id);
189 
190  beams.push_back(data);
191 
192  return &beams[beams.size() - 1];
193  }
194 
195  unsigned short nextBeamId()
196  {
197  return ++nextId;
198  }
199 
201  {
202  nextId = 0;
203  beams.clear();
204  }
205 
206  std::vector<DtActiveSonarBeamStateData> beams{};
207  unsigned short nextId{ 0 };
208  };
209 
211  : myPublish(true)
212  , mySystemName(0)
213  , mySystemFunction(0)
214  , mySystemId(0)
215  {
216  }
217 
218  DtActiveSonarStateComponentData(const DtActiveSonarStateComponentData& orig)
219  : myPublish(orig.myPublish)
220  , mySystemName(orig.mySystemName)
221  , mySystemFunction(orig.mySystemFunction)
222  , myMountLocation(orig.myMountLocation)
223  , myBeamsList(orig.myBeamsList)
224  , mySystemId(orig.mySystemId)
225  {
226  }
227 
228  DtActiveSonarStateComponentData& operator=(const DtActiveSonarStateComponentData& rhs)
229  {
230  myPublish = rhs.myPublish;
231  mySystemName = rhs.mySystemName;
232  mySystemFunction = rhs.mySystemFunction;
233  myMountLocation = rhs.myMountLocation;
234  myBeamsList = rhs.myBeamsList;
235  mySystemId = rhs.mySystemId;
236 
237  return *this;
238  }
239 
240  DtActiveSonarBeamStateData* beamByBeamId(unsigned short beamId)
241  {
242  return myBeamsList.beamByBeamId(beamId);
243  }
244 
245  const DtActiveSonarBeamStateData* beamByBeamId(unsigned short beamId) const
246  {
247  return myBeamsList.beamByBeamId(beamId);
248  }
249 
251  {
252  return myBeamsList.beamByBeamIndex(beamId);
253  }
254 
255  const DtActiveSonarBeamStateData* beamByBeamIndex(unsigned short beamId) const
256  {
257  return myBeamsList.beamByBeamIndex(beamId);
258  }
259 
260  unsigned int numBeams() const { return myBeamsList.size(); };
261  DtActiveSonarBeamStateData* addBeam() { return myBeamsList.addBeam(); };
262  DtActiveSonarBeams& beams() { return myBeamsList; };
263  const DtActiveSonarBeams& beams() const { return myBeamsList; };
264  const std::vector<DtActiveSonarBeamStateData>& rawBeams() const { return myBeamsList.beams; };
265  std::vector<DtActiveSonarBeamStateData>& rawBeams() { return myBeamsList.beams; };
266  void removeAllBeams() { myBeamsList.removeAllBeams(); };
267  void removeBeam(unsigned short beamId) { myBeamsList.removeBeam(beamId); };
268 
269  DEFINE_ACCESSOR_MUTATOR(bool, publish, Publish)
270  DEFINE_ACCESSOR_MUTATOR(unsigned int, systemId, SystemId)
271  DEFINE_ACCESSOR_MUTATOR(unsigned int, systemName, SystemName)
272  DEFINE_ACCESSOR_MUTATOR(unsigned int, systemFunction, SystemFunction)
273  DEFINE_ACCESSOR_MUTATOR(DtVector, mountLocation, MountLocation)
274 
275  protected:
276  bool myPublish;
277  unsigned int mySystemId;
278  unsigned int mySystemName;
279  unsigned int mySystemFunction;
280  DtVector myMountLocation;
281  DtActiveSonarBeams myBeamsList;
282  };
283 
287  {
288  public:
290 
292  : DtFrameStateInterface(storage)
293  {
294  }
295 
297  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(unsigned int, systemName, SystemName)
298  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(unsigned int, systemFunction, SystemFunction)
299  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(bool, publish, Publish)
300  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtVector, mountLocation, MountLocation)
301  UNDEFINED_METHOD(void, removeAllBeams)
302  UNDEFINED_METHOD(void, removeBeam, unsigned short beamId)
303  UNDEFINED_RETURNVALUE_ACCESSOR(unsigned int, numBeams)
305  virtual const DtActiveSonarBeamStateData* beamByBeamIndex(unsigned short beamIndex) const { throw DtUnimplementedMethod("The const beamByBeamIndex() const method is unimplemented"); };
306  virtual const DtActiveSonarBeamStateData* beamByBeamId(unsigned short beamId) const { throw DtUnimplementedMethod("The const beamByBeamId() const method is unimplemented"); };
307  virtual DtActiveSonarBeamStateData* beamByBeamIndex(unsigned short beamIndex) { throw DtUnimplementedMethod("The beamByBeamIndex() method is unimplemented"); };
308  virtual DtActiveSonarBeamStateData* beamByBeamId(unsigned short beamId) { throw DtUnimplementedMethod("The beamByBeamId() method is unimplemented"); };
309  virtual const DtActiveSonarStateComponentData& frameState() const { throw DtUnimplementedMethod("The const DtActiveSonarStateComponentData& const frameState() method is unimplemented"); };
310  UNDEFINED_RETURNREF_ACCESSORS(std::vector<DtActiveSonarBeamStateData>, beams)
311  };
312 
315  {
316  public:
318 
320  virtual const DtActiveSonarStateComponentData& frameState() const override { return myData; };
322  virtual const std::vector<DtActiveSonarBeamStateData>& beams() const override;
323  virtual std::vector<DtActiveSonarBeamStateData>& beams() override;
324 
325  virtual const DtUUID hostId() const override;
326 
327  virtual const unsigned int& systemName() const override;
328  virtual void setSystemName(const unsigned int&) override;
329 
330  virtual const unsigned int& systemFunction() const override;
331  virtual void setSystemFunction(const unsigned int&) override;
332 
333  virtual const bool& publish() const override;
334  virtual void setPublish(const bool&) override;
335 
336  virtual const DtVector& mountLocation() const override;
337  virtual void setMountLocation(const DtVector&) override;
338 
339  virtual const unsigned int numBeams() const override;
340 
341  virtual const DtActiveSonarBeamStateData* beamByBeamIndex(unsigned short beamIndex) const override;
342  virtual DtActiveSonarBeamStateData* beamByBeamIndex(unsigned short beamIndex) override;
343 
344  virtual const DtActiveSonarBeamStateData* beamByBeamId(unsigned short beamId) const override;
345  virtual DtActiveSonarBeamStateData* beamByBeamId(unsigned short beamId) override;
346 
347  virtual void removeAllBeams() override;
348  virtual void removeBeam(unsigned short beamId) override;
349  virtual DtActiveSonarBeamStateData* addBeam() override;
350 
352  virtual void makeWritable() override {};
353 
355  virtual void makeReadOnly() override {};
356 
357  protected:
358  unsigned short myNextBeamId;
360  };
361 
364  {
365  public:
367 
369  virtual const DtActiveSonarStateComponentData& frameState() const override { return myData; };
370  virtual const std::vector<DtActiveSonarBeamStateData>& beams() const override;
371  virtual const DtUUID hostId() const override;
372  virtual const unsigned int& systemName() const override;
373  virtual const unsigned int& systemFunction() const override;
374  virtual const bool& publish() const override;
375  virtual const DtVector& mountLocation() const override;
376  virtual const unsigned int numBeams() const override;
377  virtual const DtActiveSonarBeamStateData* beamByBeamIndex(unsigned short beamIndex) const override;
378  virtual const DtActiveSonarBeamStateData* beamByBeamId(unsigned short beamId) const override;
379 
380  protected:
383  {
384  myData = data;
385  }
386 
387  protected:
389  };
390 
394  {
395  public:
397 
398  bool isDoubleBuffered() { return true; };
399  virtual const DtFrameStateInterface* currentFrameState() const override { return &myCurrentFrameState; }
400  virtual DtFrameStateInterface* nextFrameState() override { return &myNextFrameState; };
401  virtual const DtFrameStateInterface* nextFrameState() const override { return &myNextFrameState; };
402 
403  virtual void updateDataStorage() override
404  {
405  if (myNextFrameState.isWritable())
406  {
407  myCurrentFrameState.advanceFrame(myNextFrameState.frameState());
408  }
409 
410  myCurrentFrameState.emitComponentUpdated();
411  }
412 
413  virtual void updateStateData(DtStateData* sd) override
414  {
415  myCurrentFrameState.updateStateData(sd);
416  myNextFrameState.updateStateData(sd);
417  }
418 
419  virtual void aboutToBeDeleted() override
420  {
422  myCurrentFrameState.aboutToBeDeleted();
423  myNextFrameState.aboutToBeDeleted();
424  }
425 
426  protected:
429  };
430 
434 }
UUID is a unique ID wrapper class.
Definition: uuid.h:59
double myAzimuthBeamWidth
Definition: activeSonarStateComponent.h:70
Definition: activeSonarStateComponent.h:79
void removeAllBeams()
Definition: activeSonarStateComponent.h:266
unsigned int myActiveEmissionParameterIndex
Definition: activeSonarStateComponent.h:73
Definition: stateDataTypes.h:23
unsigned int numBeams() const
Definition: activeSonarStateComponent.h:260
DtVector myMountLocation
Definition: activeSonarStateComponent.h:280
The DtActiveSonarStateComponentList is a collection of emitter systems and the beams they represent...
Definition: activeSonarStateComponent.h:17
DtActiveSonarBeamStateData * operator[](unsigned short beamId)
Definition: activeSonarStateComponent.h:103
virtual DtActiveSonarBeamStateData * beamByBeamId(unsigned short beamId)
Definition: activeSonarStateComponent.h:308
#define UNDEFINED_METHOD(Type, Method,...)
Definition: doubleBufferedDataStorage.h:68
unsigned int myScanPattern
Definition: activeSonarStateComponent.h:74
unsigned int mySystemId
Definition: activeSonarStateComponent.h:68
DtActiveSonarBeamStateData * beamByBeamIndex(unsigned short beamId)
Definition: activeSonarStateComponent.h:250
const DtActiveSonarBeamStateData * beamByBeamId(unsigned short beamId) const
Definition: activeSonarStateComponent.h:158
const DtActiveSonarBeamStateData * operator[](unsigned short beamId) const
Definition: activeSonarStateComponent.h:120
const DtActiveSonarBeamStateData * beamByBeamId(unsigned short beamId) const
Definition: activeSonarStateComponent.h:245
virtual void aboutToBeDeleted() override
Definition: activeSonarStateComponent.h:419
Definition: stateComponent.h:269
DtActiveSonarStateComponentData & frameState()
Definition: activeSonarStateComponent.h:321
virtual DtFrameStateInterface * nextFrameState() override
Definition: activeSonarStateComponent.h:400
virtual DtActiveSonarBeamStateData * beamByBeamIndex(unsigned short beamIndex)
Definition: activeSonarStateComponent.h:307
unsigned int mySystemId
Definition: activeSonarStateComponent.h:277
#define UNDEFINED_RETURNREF_ACCESSORS(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:40
unsigned int mySystemFunction
Definition: activeSonarStateComponent.h:279
#define UNDEFINED_RETURNVALUE_ACCESSOR(ReturnType, Member)
Definition: doubleBufferedDataStorage.h:31
Contains the DtUUID class declaration.
const std::vector< DtActiveSonarBeamStateData > & rawBeams() const
Definition: activeSonarStateComponent.h:264
void advanceFrame(const DtActiveSonarStateComponentData &data)
Definition: activeSonarStateComponent.h:382
unsigned int myBeamId
Definition: activeSonarStateComponent.h:67
std::vector< DtActiveSonarBeamStateData > & rawBeams()
Definition: activeSonarStateComponent.h:265
unsigned int mySystemName
Definition: activeSonarStateComponent.h:278
virtual void updateStateData(DtStateData *sd) override
Implement to update data storage to the new state data.
Definition: activeSonarStateComponent.h:413
const DtActiveSonarBeams & beams() const
Definition: activeSonarStateComponent.h:263
DtActiveSonarBeamStateData(const DtActiveSonarBeamStateData &orig)
Definition: activeSonarStateComponent.h:31
DtActiveSonarStateComponentNextFrame myNextFrameState
Definition: activeSonarStateComponent.h:428
double myElevationCenter
Definition: activeSonarStateComponent.h:71
virtual const DtActiveSonarStateComponentData & frameState() const override
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: activeSonarStateComponent.h:369
virtual const DtActiveSonarBeamStateData * beamByBeamId(unsigned short beamId) const
Definition: activeSonarStateComponent.h:306
double myElevationBeamWidth
Definition: activeSonarStateComponent.h:72
DtActiveSonarBeamStateData * beamByBeamId(unsigned short beamId)
Definition: activeSonarStateComponent.h:240
virtual void updateDataStorage() override
Implement to update data storage. Called from advanceFrame.
Definition: activeSonarStateComponent.h:403
void removeBeam(unsigned short beamId)
Definition: activeSonarStateComponent.h:267
const DtActiveSonarBeamStateData * beamByBeamIndex(unsigned short beamId) const
Definition: activeSonarStateComponent.h:255
Definition: activeSonarStateComponent.h:77
DtActiveSonarBeamStateData * beamByBeamId(unsigned short beamId)
Definition: activeSonarStateComponent.h:153
DtActiveSonarStateComponentData myData
Definition: activeSonarStateComponent.h:388
3) Define the current frame class. This will be used for read access.
Definition: activeSonarStateComponent.h:363
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:398
DtActiveSonarBeamStateData()
Definition: activeSonarStateComponent.h:19
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Definition: stateComponent.h:231
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: activeSonarStateComponent.h:286
DtActiveSonarStateComponentData(const DtActiveSonarStateComponentData &orig)
Definition: activeSonarStateComponent.h:218
void removeBeam(unsigned short beamId)
Definition: activeSonarStateComponent.h:137
DtActiveSonarBeams(const DtActiveSonarBeams &orig)
Definition: activeSonarStateComponent.h:86
DtActiveSonarBeamStateData * addBeam()
Definition: activeSonarStateComponent.h:183
DtActiveSonarStateComponentData & operator=(const DtActiveSonarStateComponentData &rhs)
Definition: activeSonarStateComponent.h:228
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:384
DtActiveSonarBeamStateData & operator=(const DtActiveSonarBeamStateData &rhs)
Definition: activeSonarStateComponent.h:43
virtual void aboutToBeDeleted()
bool myPublish
Definition: activeSonarStateComponent.h:267
DtActiveSonarBeams()
Definition: activeSonarStateComponent.h:82
2) Define the next frame class. This will be used for write access.
Definition: activeSonarStateComponent.h:314
virtual void makeWritable() override
Override to make component writable.
Definition: activeSonarStateComponent.h:352
int size() const
Definition: activeSonarStateComponent.h:98
std::vector< DtActiveSonarBeamStateData > beams
Definition: activeSonarStateComponent.h:206
#define UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(Type, Member, Set)
Definition: doubleBufferedDataStorage.h:57
DtActiveSonarBeams & beams()
Definition: activeSonarStateComponent.h:262
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Definition: doubleBufferedDataStorage.h:23
static const char * SystemName
Definition: vrfXmlTypes.h:46
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: activeSonarStateComponent.h:393
DtActiveSonarBeamStateData * beamByBeamIndex(unsigned short index)
Definition: activeSonarStateComponent.h:163
DtActiveSonarStateComponentData()
Definition: activeSonarStateComponent.h:210
#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 isDoubleBuffered()
Definition: activeSonarStateComponent.h:398
DtStateComponentCreator< DtActiveSonarStateComponentImplementation > DtActiveSonarStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: activeSonarStateComponent.h:433
virtual const DtFrameStateInterface * nextFrameState() const override
Definition: activeSonarStateComponent.h:401
virtual const DtActiveSonarStateComponentData & frameState() const override
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: activeSonarStateComponent.h:320
Contains the DtStateComponent class declaration.
const DtActiveSonarBeamStateData * beamByBeamIndex(unsigned short index) const
Definition: activeSonarStateComponent.h:173
unsigned short nextBeamId()
Definition: activeSonarStateComponent.h:195
DtActiveSonarBeams & operator=(const DtActiveSonarBeams &rhs)
Definition: activeSonarStateComponent.h:91
void removeAllBeams()
Definition: activeSonarStateComponent.h:200
DtActiveSonarStateComponentData myData
Definition: activeSonarStateComponent.h:359
DtActiveSonarBeamStateData * addBeam()
Definition: activeSonarStateComponent.h:261
double myAzimuthCenter
Definition: activeSonarStateComponent.h:69
virtual const DtActiveSonarStateComponentData & frameState() const
Definition: activeSonarStateComponent.h:309
DtActiveSonarStateComponentCurrentFrame myCurrentFrameState
Definition: activeSonarStateComponent.h:427
This is a simple base class that will be used to return a pointer to current or next frame state...
Definition: stateComponent.h:294
virtual const DtFrameStateInterface * currentFrameState() const override
Definition: activeSonarStateComponent.h:399
DtActiveSonarBeams myBeamsList
Definition: activeSonarStateComponent.h:281

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)