VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
radioTransmitterStateComponent.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 <legionStandardOM/sets/readRadioTransmitterRepository.hpp>
13 #include <legionStandardOM/sets/writeRadioTransmitterRepository.hpp>
14 #include <matrix/vlVector.h>
15 #include <vlpi/entityType.h>
16 
17 namespace makVrf
18 {
22  {
25  {
35  Intercom
36  };
37 
40  : myAntennaPatternType(0)
41  , myPseudoNoiseInUse(false)
42  , myTimeHopInUse(false)
43  , myModulationParams(nullptr)
44  , myModulationParamsSize(0)
45  , myRadioId(0)
46  {
47  }
48 
51  : myWorldAntennaLoc(orig.myWorldAntennaLoc)
52  , myRelativeAntennaLoc(orig.myRelativeAntennaLoc)
53  , myAntennaPatternType(orig.myAntennaPatternType)
54  , myPseudoNoiseInUse(orig.myPseudoNoiseInUse)
55  , myTimeHopInUse(orig.myTimeHopInUse)
56  , myModulationParams(nullptr)
57  , myModulationParamsSize(0)
58  , myRadioId(orig.myRadioId)
59  {
60  if (orig.myModulationParams)
61  {
62  myModulationParams = (char*)malloc(orig.myModulationParamsSize);
63  memcpy(myModulationParams, orig.myModulationParams, orig.myModulationParamsSize);
64  myModulationParamsSize = orig.myModulationParamsSize;
65  }
66  }
67 
70  {
71  if (myModulationParams)
72  {
73  free(myModulationParams);
74  }
75  }
76 
79  {
80  myRelativeAntennaLoc = orig.myRelativeAntennaLoc;
81  myWorldAntennaLoc = orig.myWorldAntennaLoc;
82  myRadioId = orig.myRadioId;
83  myAntennaPatternType = orig.myAntennaPatternType;
84  myPseudoNoiseInUse = orig.myPseudoNoiseInUse;
85  myTimeHopInUse = orig.myTimeHopInUse;
86 
87  if (myModulationParams)
88  {
89  free(myModulationParams);
90  myModulationParams = nullptr;
91  myModulationParamsSize = 0;
92  }
93 
94  if (orig.myModulationParams)
95  {
96  myModulationParams = (char*)malloc(orig.myModulationParamsSize);
97  memcpy(myModulationParams, orig.myModulationParams, orig.myModulationParamsSize);
98  myModulationParamsSize = orig.myModulationParamsSize;
99  }
100 
101  return *this;
102  }
103 
104  DEFINE_ACCESSOR_MUTATOR(DtVector, worldAntennaLoc, WorldAntennaLoc)
105  DEFINE_ACCESSOR_MUTATOR(DtVector, relativeAntennaLoc, RelativeAntennaLoc)
106  DEFINE_ACCESSOR_MUTATOR(unsigned int, antennaPatternType, AntennaPatternType)
107  DEFINE_ACCESSOR_MUTATOR(UInt64, radioId, RadioId)
108  DEFINE_ACCESSOR_MUTATOR(bool, pseudoNoiseInUse, PseudoNoiseInUse)
109  DEFINE_ACCESSOR_MUTATOR(bool, timeHopInUse, TimeHopInUse)
110 
112  const char* modulationParams() const { return myModulationParams; };
114  const unsigned char& modulationParamsSize() const { return myModulationParamsSize; };
115 
119  void setModulationParams(const char* p, unsigned char l)
120  {
121  if (myModulationParams)
122  {
123  free(myModulationParams);
124  myModulationParamsSize = 0;
125  myModulationParams = nullptr;
126  }
127 
128  if (p && l)
129  {
130  myModulationParams = (char*)malloc(l);
131  memcpy(myModulationParams, p, l);
132  myModulationParamsSize = l;
133  }
134  }
135 
136  protected:
140  unsigned char myModulationParamsSize;
141 
147  unsigned int myAntennaPatternType;
148 
153 
156  };
157 
161  {
162  public:
164 
165 
167  : DtFrameStateInterface(storage)
168  {
169  }
170 
172  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(unsigned int, transmitState, TransmitState)
173  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(DtRadioEntityType, radioEntityType, RadioEntityType)
174  virtual const unsigned long long frequency() const { throw DtUnimplementedMethod("The const frequency() method is unimplemented"); };
175  virtual void setFrequency(unsigned long long) { throw DtUnimplementedMethod("The const setFrquency(unsigned long long) method is unimplemented"); };
176  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(float, power, Power)
177  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtVector, relativeAntennaLoc, RelativeAntennaLoc)
178  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(DtVector, relativePosition, RelativePosition)
179  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtVector, worldAntennaLoc, WorldAntennaLoc)
180  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(unsigned int, inputSource, InputSource)
181  UNDEFINED_RETURNVALUE_ACCESSOR(unsigned long, streamTagUpper)
182  UNDEFINED_RETURNVALUE_ACCESSOR(unsigned long, streamTagLower)
183  virtual const unsigned long long streamTag() const { throw DtUnimplementedMethod("The const streamTag() method is unimplemented"); };
184  virtual void setStreamTag(unsigned long u, unsigned long l) { throw DtUnimplementedMethod("The const setStreamTag() method is unimplemented"); };
185  virtual void setStreamTag(unsigned long long) { throw DtUnimplementedMethod("The const setStreamTag(unsigned long long) method is unimplemented"); };
186  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(unsigned int, antennaPatternType, AntennaPatternType)
188  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(unsigned int, cryptoKey, CryptoKey)
189  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(unsigned int, cryptoMode, CryptoMode)
190  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(unsigned int, cryptoSystem, CryptoSystem)
191  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(unsigned int, detailedModulationType, DetailedModulationType)
192  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(float, frequencyBandwidth, FrequencyBandwidth)
193  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, frequencyHopInUse, FrequencyHopInUse)
194  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(bool, pseudoNoiseInUse, PseudoNoiseInUse)
195  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(bool, timeHopInUse, TimeHopInUse)
196  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(unsigned int, majorModulationType, MajorModulationType)
197  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(unsigned int, modulationSystemType, ModulationSystemType)
198  UNDEFINED_RETURNVALUE_ACCESSOR(char*, modulationParams)
199  UNDEFINED_RETURNREF_ACCESSOR(unsigned char, modulationParamsSize)
200  virtual void setModulationParams(const char* params, unsigned char length) { throw DtUnimplementedMethod("The const setModulationParams() method is unimplemented"); };
201  };
202 
205  {
206  public:
209 
211  virtual ~DtRadioTransmitterStateComponentNextFrame() override;
212 
214  const DtRadioTransmitterStateComponentData& frameState() const { return myData; };
216 
217  virtual const DtUUID hostId() const override;
218 
219  virtual const unsigned int transmitState() const override;
220  virtual void setTransmitState(const unsigned int&) override;
221 
222  virtual const unsigned int& antennaPatternType() const override;
223  virtual void setAntennaPatternType(const unsigned int&) override;
224 
225  virtual const UInt64 radioId() const override;
226  virtual void setRadioId(const UInt64&) override;
227 
228  virtual const DtRadioEntityType radioEntityType() const override;
229  virtual void setRadioEntityType(const DtRadioEntityType&) override;
230 
231  virtual const unsigned long long frequency() const override;
232  virtual void setFrequency(unsigned long long) override;
233 
234  virtual const unsigned long streamTagUpper() const override;
235  virtual const unsigned long streamTagLower() const override;
236  virtual const unsigned long long streamTag() const override;
237  virtual void setStreamTag(unsigned long u, unsigned long l) override;
238  virtual void setStreamTag(unsigned long long tag) override;
239 
240  virtual const float power() const override;
241  virtual void setPower(const float&) override;
242 
243  virtual const char* modulationParams() const override;
244  virtual const unsigned char& modulationParamsSize() const override;
245  virtual void setModulationParams(const char* params, unsigned char length) override;
246 
247  virtual const DtVector& relativeAntennaLoc() const override;
248  virtual void setRelativeAntennaLoc(const DtVector&) override;
249 
250  virtual const DtVector& worldAntennaLoc() const override;
251  virtual void setWorldAntennaLoc(const DtVector&) override;
252 
253  virtual const DtVector relativePosition() const override;
254  virtual void setRelativePosition(const DtVector&) override;
255 
256  virtual const unsigned int inputSource() const override;
257  virtual void setInputSource(const unsigned int&) override;
258 
259  virtual const unsigned int cryptoKey() const override;
260  virtual void setCryptoKey(const unsigned int&) override;
261 
262  virtual const unsigned int cryptoMode() const override;
263  virtual void setCryptoMode(const unsigned int&) override;
264 
265  virtual const unsigned int cryptoSystem() const override;
266  virtual void setCryptoSystem(const unsigned int&) override;
267 
268  virtual const unsigned int majorModulationType() const override;
269  virtual void setMajorModulationType(const unsigned int&) override;
270 
271  virtual const unsigned int modulationSystemType() const override;
272  virtual void setModulationSystemType(const unsigned int&) override;
273 
274  virtual const unsigned int detailedModulationType() const override;
275  virtual void setDetailedModulationType(const unsigned int&) override;
276 
277  virtual const float frequencyBandwidth() const override;
278  virtual void setFrequencyBandwidth(const float&) override;
279 
280  virtual const bool frequencyHopInUse() const override;
281  virtual void setFrequencyHopInUse(const bool&) override;
282 
283  virtual const bool& pseudoNoiseInUse() const override;
284  virtual void setPseudoNoiseInUse(const bool&) override;
285 
286  virtual const bool& timeHopInUse() const override;
287  virtual void setTimeHopInUse(const bool&) override;
288 
290  virtual void makeWritable() override;
291 
293  virtual void makeReadOnly() override;
294 
296  UInt64 globalId() const;
297 
299  virtual Legion::WriteStateInstance writeStateInstance() override;
301  virtual void updateStateData(DtStateData*) override;
302 
304  void cleanupWriteState();
305 
308  void setPublishingOnLegionNetwork(bool b);
309 
310  protected:
314  LOM::WriteRadioTransmitterRepository myWriteRadioTransmitterRepository;
317  };
318 
321  {
322  public:
325 
327  const DtRadioTransmitterStateComponentData& frameState() const { return myData; };
328 
329  virtual const DtUUID hostId() const override;
330  virtual const unsigned int transmitState() const override;
331  virtual const DtRadioEntityType radioEntityType() const override;
332  virtual const unsigned long long frequency() const override;
333  virtual const unsigned long long streamTag() const override;
334  virtual const unsigned long streamTagUpper() const override;
335  virtual const unsigned long streamTagLower() const override;
336  virtual const float power() const override;
337  virtual const DtVector& worldAntennaLoc() const override;
338  virtual const DtVector& relativeAntennaLoc() const override;
339  virtual const DtVector relativePosition() const override;
340  virtual const unsigned int inputSource() const override;
341  virtual const unsigned int& antennaPatternType() const override;
342  virtual const UInt64 radioId() const override;
343  virtual const unsigned int cryptoKey() const override;
344  virtual const unsigned int cryptoMode() const override;
345  virtual const unsigned int cryptoSystem() const override;
346  virtual const unsigned int detailedModulationType() const override;
347  virtual const float frequencyBandwidth() const override;
348  virtual const bool frequencyHopInUse() const override;
349  virtual const bool& pseudoNoiseInUse() const override;
350  virtual const bool& timeHopInUse() const override;
351  virtual const unsigned int majorModulationType() const override;
352  virtual const unsigned int modulationSystemType() const override;
353  virtual const char* modulationParams() const override;
354  virtual const unsigned char& modulationParamsSize() const override;
355 
357  bool readComponentValid() const;
359  bool findReadComponent();
361  virtual Legion::ReadStateInstance readStateInstance() const override;
362 
364  UInt64 globalId() const;
366  virtual void updateStateData(DtStateData*) override;
367 
368  protected:
373  {
374  myData = data;
375  }
376 
377  protected:
379  LOM::ReadRadioTransmitterRepository myReadRadioTransmitterRepository;
382  };
383 
387  {
388  public:
391 
393  bool isDoubleBuffered() { return true; };
395  virtual const DtFrameStateInterface* currentFrameState() const override { return &myCurrentFrameState; }
397  virtual DtFrameStateInterface* nextFrameState() override { return &myNextFrameState; };
399  virtual const DtFrameStateInterface* nextFrameState() const override { return &myNextFrameState; };
400 
402  virtual void updateDataStorage() override
403  {
404  if (!myFoundComponent)
405  {
406  myFoundComponent = myCurrentFrameState.findReadComponent();
407  }
408 
409  if (myNextFrameState.isWritable())
410  {
411  myCurrentFrameState.advanceFrame(myNextFrameState.frameState());
412  }
413 
414  myCurrentFrameState.emitComponentUpdated();
415  }
416 
418  virtual void updateStateData(DtStateData* sd) override
419  {
420  myCurrentFrameState.updateStateData(sd);
421  myNextFrameState.updateStateData(sd);
422  }
423 
425  virtual bool forceAdvance() override;
426 
428  virtual void firstFrameAdvance() override;
429 
430  virtual void aboutToBeDeleted() override
431  {
433  myCurrentFrameState.aboutToBeDeleted();
434  myNextFrameState.aboutToBeDeleted();
435  }
436 
437  virtual void completeSetup() override;
438  virtual void removeAdditionalStateComponents() override;
439  virtual void setPublishingOnLegionNetwork(bool b) override;
440 
441  protected:
448  };
449 
453 }
Definition: radioTransmitterStateComponent.h:30
UUID is a unique ID wrapper class.
Definition: uuid.h:59
DtRadioTransmitterStateComponentCurrentFrame myCurrentFrameState
Current-frame (read-only) radio transmitter state accessor.
Definition: radioTransmitterStateComponent.h:443
Definition: radioTransmitterStateComponent.h:27
Exception thrown when a required method has not been implemented.
Definition: stateDataTypes.h:30
virtual void aboutToBeDeleted() override
Called when the component is about to be deleted; emits signal_stateComponentAboutToBeDeleted.
Definition: radioTransmitterStateComponent.h:430
3) Define the current frame class. This will be used for read access.
Definition: radioTransmitterStateComponent.h:320
bool isDoubleBuffered()
Definition: radioTransmitterStateComponent.h:393
double length(const dvec3 &theVec)
Definition: DtVecUtils.h:20
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: radioTransmitterStateComponent.h:160
CryptoSystem
Definition: radioStateTypes.h:18
DtRadioTransmitterStateComponentData & frameState()
Definition: radioTransmitterStateComponent.h:215
Data container for radio transmitter state, including antenna location, modulation parameters...
Definition: radioTransmitterStateComponent.h:21
virtual void setFrequency(unsigned long long)
Definition: radioTransmitterStateComponent.h:175
const DtRadioTransmitterStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: radioTransmitterStateComponent.h:327
virtual void setStreamTag(unsigned long long)
Definition: radioTransmitterStateComponent.h:185
Default creator implementation for a state component type. T_StateComponent is the concrete component...
Definition: stateComponent.h:326
Definition: radioTransmitterStateComponent.h:33
ModulationSystemType
Definition: radioStateTypes.h:29
Definition: radioTransmitterStateComponent.h:34
virtual DtFrameStateInterface * nextFrameState() override
Definition: radioTransmitterStateComponent.h:397
#define UNDEFINED_RETURNVALUE_ACCESSOR(ReturnType, Member)
Defines a virtual const accessor that throws DtUnimplementedMethod, marking the method as requiring a...
Definition: doubleBufferedDataStorage.h:53
TransmitState
Definition: radioStateTypes.h:34
DtRadioTransmitterStateComponentNextFrame myNextFrameState
Next-frame (writable) radio transmitter state accessor.
Definition: radioTransmitterStateComponent.h:445
Contains the DtUUID class declaration.
unsigned long long UInt64
64-bit unsigned integer type.
Definition: stateDataTypes.h:19
#define UNDEFINED_RETURNREF_ACCESSOR(ReturnType, Member)
Defines a virtual const reference accessor that throws DtUnimplementedMethod, marking the method as r...
Definition: doubleBufferedDataStorage.h:60
unsigned int myAntennaPatternType
DIS antenna pattern type code.
Definition: radioTransmitterStateComponent.h:147
InputSource
Definition: radioStateTypes.h:20
2) Define the next frame class. This will be used for write access.
Definition: radioTransmitterStateComponent.h:204
char * myModulationParams
Heap-allocated raw modulation parameters buffer; null if not set.
Definition: radioTransmitterStateComponent.h:138
virtual void updateStateData(DtStateData *sd) override
Propagates a state data pointer update to both current-frame and next-frame states.
Definition: radioTransmitterStateComponent.h:418
Definition: radioTransmitterStateComponent.h:28
Definition: radioTransmitterStateComponent.h:26
UInt64 myRadioId
Unique radio identifier.
Definition: radioTransmitterStateComponent.h:155
LOM::WriteRadioTransmitterRepository myWriteRadioTransmitterRepository
Legion write repository handle for publishing radio transmitter state.
Definition: radioTransmitterStateComponent.h:314
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:513
#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
const unsigned char & modulationParamsSize() const
Returns the size in bytes of the modulation parameters buffer.
Definition: radioTransmitterStateComponent.h:114
CryptoMode
Definition: radioStateTypes.h:17
bool myPseudoNoiseInUse
True if pseudo-noise spread-spectrum is in use.
Definition: radioTransmitterStateComponent.h:150
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:489
void setModulationParams(const char *p, unsigned char l)
Sets the modulation parameters by copying l bytes from p into a heap-allocated buffer.
Definition: radioTransmitterStateComponent.h:119
#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
DtVector myRelativeAntennaLoc
Antenna position relative to the entity body frame.
Definition: radioTransmitterStateComponent.h:145
unsigned char myModulationParamsSize
Size in bytes of myModulationParams; zero when the buffer is null.
Definition: radioTransmitterStateComponent.h:140
virtual void aboutToBeDeleted()
Called when the component is about to be deleted; emits signal_stateComponentAboutToBeDeleted.
virtual ~DtRadioTransmitterStateComponentData()
Destructor; frees the heap-allocated modulation parameters buffer.
Definition: radioTransmitterStateComponent.h:69
DtStateComponentCreator< DtRadioTransmitterStateComponentImplementation > DtRadioTransmitterStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: radioTransmitterStateComponent.h:452
DtVector myWorldAntennaLoc
Antenna position in world coordinates.
Definition: radioTransmitterStateComponent.h:143
#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
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Defines a const reference accessor and an inline setter for a member variable.
Definition: doubleBufferedDataStorage.h:37
DtRadioTransmitterStateComponentData()
Constructs a default-initialized radio transmitter state data object.
Definition: radioTransmitterStateComponent.h:39
bool myFoundComponent
True once the Legion read component has been successfully found and bound.
Definition: radioTransmitterStateComponent.h:447
RadioInputSource
Source of radio input as defined by the DIS standard enumeration.
Definition: radioTransmitterStateComponent.h:24
bool myPublishingOnLegionNetwork
True when this component is actively publishing state on the Legion network.
Definition: radioTransmitterStateComponent.h:312
Definition: radioTransmitterStateComponent.h:31
DtRadioTransmitterStateComponentData & operator=(const DtRadioTransmitterStateComponentData &orig)
Assignment operator; performs a deep copy of the modulation parameters buffer.
Definition: radioTransmitterStateComponent.h:78
virtual const DtFrameStateInterface * currentFrameState() const override
Definition: radioTransmitterStateComponent.h:395
virtual void setStreamTag(unsigned long u, unsigned long l)
Definition: radioTransmitterStateComponent.h:184
virtual void updateDataStorage() override
Advances the current frame from next-frame data and triggers the component-updated notification...
Definition: radioTransmitterStateComponent.h:402
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: radioTransmitterStateComponent.h:386
virtual const DtFrameStateInterface * nextFrameState() const override
Definition: radioTransmitterStateComponent.h:399
DtRadioTransmitterStateComponentData(const DtRadioTransmitterStateComponentData &orig)
Copy constructor; performs a deep copy of the modulation parameters buffer.
Definition: radioTransmitterStateComponent.h:50
void advanceFrame(const DtRadioTransmitterStateComponentData &data)
Copies the given state data snapshot into the current frame buffer.
Definition: radioTransmitterStateComponent.h:372
#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
DtRadioTransmitterStateComponentData myData
Local snapshot of radio transmitter state data for the current frame.
Definition: radioTransmitterStateComponent.h:381
DtRadioTransmitterStateComponentData myData
Local copy of radio transmitter state data for the next frame.
Definition: radioTransmitterStateComponent.h:316
Definition: radioTransmitterStateComponent.h:32
AntennaPatternType
Definition: radioStateTypes.h:15
Definition: radioTransmitterStateComponent.h:29
Contains the DtStateComponent class declaration.
const DtRadioTransmitterStateComponentData & frameState() const
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: radioTransmitterStateComponent.h:214
bool myTimeHopInUse
True if time-hop spread-spectrum is in use.
Definition: radioTransmitterStateComponent.h:152
Base interface for accessing current or next frame state in a double-buffered state component...
Definition: stateComponent.h:354
LOM::ReadRadioTransmitterRepository myReadRadioTransmitterRepository
Legion read repository handle for receiving radio transmitter state updates.
Definition: radioTransmitterStateComponent.h:379

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)