WSF
WsfSensor.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef WSFSENSOR_HPP
13#define WSFSENSOR_HPP
14
15#include "wsf_export.h"
16
17#include <memory>
18#include <vector>
19
20class UtInput;
21#include "UtQuaternion.hpp"
22#include "UtRandom.hpp"
24#include "WsfCategoryList.hpp"
25#include "WsfComponentList.hpp"
26class WsfEM_Rcvr;
27class WsfEM_Xmtr;
28#include "WsfEvent.hpp"
29#include "WsfMeasurement.hpp"
30class WsfMessage;
31class WsfPlatform;
32class WsfSensor;
34class WsfSensorMode;
36class WsfSensorResult;
40class WsfTrack;
41class WsfTrackId;
42#include "WsfTrackListFwd.hpp"
44
92{
93public:
97
104 enum
105 {
107
109 cACTIVE = 0x00000001,
111 cSEMI_ACTIVE = 0x00000002,
114 cPASSIVE = 0x00000004,
115
117
118 cRADIO = 0x00000010,
119 cINFRARED = 0x00000020,
120 cVISUAL = 0x00000040,
121 cACOUSTIC = 0x00000080,
123
125
126 cIMAGING = 0x00001000
128 };
129
133 {
134 public:
136 : mModeIndex(0)
137 , mRequiredPd(0.0)
138 , mLockonTime(-1.0)
139 {
140 }
141
145
162
171 };
172
173 WsfSensor(const WsfScenario& aScenario);
174 ~WsfSensor() override;
175
178
180 ComponentList& GetComponents() { return mComponents; }
181 const ComponentList& GetComponents() const { return mComponents; }
183
185
186 WsfComponent* CloneComponent() const override { return Clone(); }
187 const int* GetComponentRoles() const override;
188 void* QueryInterface(int aRole) override;
191
192 bool AllowDetectionChancesFor(WsfPlatform* aPlatformPtr);
193 void AddIgnoredCategory(const std::string& aCategory);
194
195 virtual bool AttemptToDetect(double aSimTime, WsfPlatform* aTargetPtr, Settings& aSettings, WsfSensorResult& aResult);
196
198
199 const char* GetScriptClassName() const override;
202 WsfSensor* Clone() const override = 0;
203 bool PreInitialize(double aSimTime) override;
204 bool Initialize(double aSimTime) override;
205 bool Initialize2(double aSimTime) override;
206 void PlatformAdded(double aSimTime, WsfPlatform* aPlatformPtr) override;
207 void PlatformDeleted(WsfPlatform* aPlatformPtr) override;
208 void PreInput() override;
209 bool ProcessInput(UtInput& aInput) override;
210 void Update(double aSimTime) override;
211 void UpdatePosition(double aSimTime) override;
212 virtual void PerformScheduledDetections(double aSimTime);
214
216
217
218 bool ThreadSafe() const { return mThreadSafe; }
219 void SetThreadSafe() { mThreadSafe = true; }
220 void SetNotThreadSafe() { mThreadSafe = false; }
222
224
225
226 bool ShowCalibrationData() const { return mShowCalibrationData; }
227 void SetShowCalibrationData(bool aShowCalibrationData) { mShowCalibrationData = aShowCalibrationData; }
229
232
233 void AttachObserver(WsfSingleSensorObserver* aObserverPtr);
234 void DetachObserver(WsfSingleSensorObserver* aObserverPtr);
235 void NotifyDeleted();
236 void NotifyTrackInitiated(double aSimTime, const WsfTrack& aTrack);
237 void NotifyTrackUpdated(double aSimTime, const WsfTrack& aTrack);
238 void NotifyTrackDropped(double aSimTime, const WsfTrack& aTrack);
239 void NotifyTargetUpdated(double aSimTime, WsfPlatform* aTargetPtr, WsfSensorResult& aResult);
240 void NotifyTurnedOff(double aSimTime);
241 void NotifyTurnedOn(double aSimTime);
242
243 virtual void NotifySensorDetectionAttempted(double aSimTime, WsfPlatform* aTargetPtr, WsfSensorResult& aResult);
245
248
249
251 int GetClass() const { return mClass; }
252
254 bool IsClassActive() const { return (mClass & cACTIVE) != 0; }
255
257 bool IsClassPassive() const { return (mClass & cPASSIVE) != 0; }
258
260 bool IsClassSemiActive() const { return (mClass & cSEMI_ACTIVE) != 0; }
261
263 bool IsClassAcoustic() const { return (mClass & cACOUSTIC) != 0; }
264
266 bool IsClassInfrared() const { return (mClass & cINFRARED) != 0; }
267
269 bool IsClassRadio() const { return (mClass & cRADIO) != 0; }
270
272 bool IsClassVisual() const { return (mClass & cVISUAL) != 0; }
273
275 bool IsClassImaging() const { return (mClass & cIMAGING) != 0; }
276
278
280
281 void TurnOff(double aSimTime) override;
282 void TurnOn(double aSimTime) override;
283 void SetNonOperational(double aSimTime) override;
284 void SetOperational(double aSimTime) override;
285 void PartBroken(double aSimTime) override;
287
290 double GetUpdateInterval() const override { return mUpdateInterval; }
291
294
295 virtual size_t GetEM_RcvrCount() const;
296 virtual WsfEM_Rcvr& GetEM_Rcvr(size_t aIndex) const;
297 virtual size_t GetEM_RcvrCount(size_t aModeIndex) const;
298 virtual WsfEM_Rcvr& GetEM_Rcvr(size_t aModeIndex, size_t aIndex) const;
299 virtual size_t GetEM_XmtrCount() const;
300 virtual WsfEM_Xmtr& GetEM_Xmtr(size_t aIndex) const;
301 virtual size_t GetEM_XmtrCount(size_t aModeIndex) const;
302 virtual WsfEM_Xmtr& GetEM_Xmtr(size_t aModeIndex, size_t aIndex) const;
304
307
308 virtual bool WithinFieldOfView(double aSimTime, WsfPlatform* aPlatformPtr);
309 virtual bool WithinFieldOfView(double aSimTime, WsfTrack* aTrackPtr);
311
315
316 virtual WsfStringId GetCurrentModeName() const;
317 virtual WsfSensorMode* GetCurrentMode() const;
318 virtual size_t GetModeCount() const;
319 virtual WsfSensorMode* GetModeEntry(size_t aModeIndex) const;
320 virtual size_t GetModeIndex(WsfStringId aModeNameId) const;
321 virtual WsfStringId GetModeName(size_t aModeIndex) const;
322 virtual void DeselectMode(double aSimTime, WsfStringId aModeNameId);
323 virtual void SelectMode(double aSimTime, WsfStringId aModeNameId);
324 virtual void ScheduleModeChange(double aSimTime, bool aSelectModeFlag, WsfStringId aModeNameId);
325 virtual bool IsModeChangeScheduled() const;
326 virtual double GetModeSelectDelay() const;
327
332
333 WsfSensorModeList* GetModeList() const { return mModeListPtr.get(); }
335
338
339 virtual int GetActiveRequestCount() const;
340 virtual int GetActiveRequestCount(WsfStringId aModeNameId) const;
341 virtual int GetMaximumRequestCount() const;
342 virtual int GetMaximumRequestCount(WsfStringId aModeNameId) const;
343 virtual bool HaveRequestFor(const WsfTrackId& aTrackId) const;
344 virtual bool StartTracking(double aSimTime, const WsfTrack& aTrack, WsfStringId aModeNameId);
345 virtual bool StopTracking(double aSimTime, const WsfTrackId& aRequestId);
347
351
352 virtual int GetActiveTrackCount() const;
353
354 virtual void GetActiveTrackList(WsfTrackList& aActiveTrackList) const;
355
356 virtual int GetMaximumTrackCount() const;
357
358 virtual void SendTrackCoastMessage(double aSimTime, const WsfTrack* aTrackPtr);
359
360 virtual void SendTrackDropMessage(double aSimTime, const WsfTrack* aTrackPtr);
361
362 virtual void SendTrackUpdateMessage(double aSimTime, const WsfTrack* aTrackPtr);
363
364 virtual void SetMessageParameters(WsfStringId aModeNameId, WsfMessage& aMessage);
365
366 virtual void TrackCoasted(double aSimTime, WsfTrack* aTrackPtr);
367
368 virtual void TrackDropped(double aSimTime, WsfTrack* aTrackPtr);
369
370 virtual void TrackUpdated(double aSimTime, WsfTrack* aTrackPtr);
372
374
375
388 static double GetRequiredPd(const WsfSensorMode* aModePtr);
389
393
394
395 bool IsSlave() const { return mIsSlave; }
396
397 void SetIsSlave(double aSimTime, bool aIsSlave);
399
403
404
407
408 void SetScheduler(std::unique_ptr<WsfSensorScheduler> aSchedulerPtr);
409 std::unique_ptr<WsfSensorScheduler> SwapScheduler(std::unique_ptr<WsfSensorScheduler> aSchedulerPtr);
410
413 WsfSensorTracker* GetTracker() const { return mTrackerPtr.get(); }
414
415 void SetTracker(std::unique_ptr<WsfSensorTracker> aTrackerPtr);
416 std::unique_ptr<WsfSensorTracker> SwapTracker(std::unique_ptr<WsfSensorTracker> aTrackerPtr);
418
422 //{@
427 void SetUpdateInterval(double aUpdateInterval) override { mUpdateInterval = aUpdateInterval; }
428
431 unsigned int GetUpdateEventEpoch() const { return mUpdateEventEpoch; }
432
435 void IncrementUpdateEventEpoch() { ++mUpdateEventEpoch; }
436
438 bool UpdateEventActive() const { return mUpdateEventActive; }
439
441 void SetUpdateEventActive(bool aUpdateEventActive) { mUpdateEventActive = aUpdateEventActive; }
442
443 void AdjustNextUpdateTime(double aNextUpdateTime);
444
447 double GetNextUpdateTime() const { return mNextUpdateTime; }
448
449 void SetNextUpdateTime(double aSimTime, double aNextUpdateTime);
450
452
454 void GetMessageParameters(int& aMessageLength, int& aMessagePriority) const
455 {
456 aMessageLength = mMessageLength;
457 aMessagePriority = mMessagePriority;
458 }
459
462
464 bool SendDis() { return mSendDis; }
465
467 ut::Random& GetRandom() { return mRandom; }
468
469 virtual bool GetFilteredDoppler() const { return true; }
470
472 bool ScriptAllowDetection(double aSimTime, WsfPlatform* aTargetPtr, WsfSensorResult& aResult);
473
477 {
478 public:
484
486 ModeChangeEvent(double aSimTime, EventType aEventType, WsfSensor* aSensorPtr, WsfStringId aModeNameId);
487
488 EventDisposition Execute() override;
489
490 private:
491 size_t mPlatformIndex;
492 EventType mEventType;
493 WsfSensor* mSensorPtr;
494 WsfStringId mModeNameId;
495 };
496
497protected:
498 WsfSensor(const WsfSensor& aSrc);
499 WsfSensor& operator=(const WsfSensor& aSrc) = delete;
500
501 void SetClass(int aClass);
502 void SetModeList(std::unique_ptr<WsfSensorModeList> aModeListPtr);
503
504 UtScriptContext* GetScriptAccessibleContext() const override;
505 void SetPlatform(WsfPlatform* aPlatformPtr) override;
506
510
511 std::unique_ptr<WsfSensorModeList> mModeListPtr;
512 std::unique_ptr<WsfSensorScheduler> mSchedulerPtr;
513 std::unique_ptr<WsfSensorTracker> mTrackerPtr;
514
517
520
523
526
529
531 std::vector<WsfStringId> mIgnoredSides;
532
534 unsigned int mIgnoredDomains;
535
538
539private:
540 ComponentList mComponents;
541
543 std::vector<WsfSensorMode*> mSensorModeList;
544
546 int mClass;
547
552 double mUpdateInterval;
553
556 unsigned int mUpdateEventEpoch;
557
559 bool mUpdateEventActive;
560
562 bool mIsSlave;
563
565 bool mShowCalibrationData;
566
568 bool mSendDis;
569
570 ut::Random mRandom;
571
573 WsfScriptContext mContext;
574 UtScript* mOnDetectionScriptPtr{nullptr};
575
576 std::vector<WsfSingleSensorObserver*> mObservers;
577};
578
580
581#endif
@ cWSF_INITIALIZE_ORDER_SENSOR
Definition WsfComponentRoles.hpp:178
#define WSF_DECLARE_COMPONENT_ROLE_TYPE(TYPE, ROLE)
Definition WsfComponentRoles.hpp:44
@ cWSF_COMPONENT_SENSOR
A 'sensor' component (WsfSensor).
Definition WsfComponentRoles.hpp:105
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
WsfTrackListT< WsfTrack > WsfTrackList
Definition WsfTrackList.hpp:88
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
bool ProcessInput(UtInput &aInput) override
Definition WsfArticulatedPart.cpp:205
bool Initialize(double aSimTime) override
Definition WsfArticulatedPart.cpp:170
void * QueryInterface(int aRole) override
Definition WsfArticulatedPart.cpp:159
virtual void UpdatePosition(double aSimTime)
Definition WsfArticulatedPart.cpp:442
WsfArticulatedPart(const WsfScenario &aScenario, int aPartType)
Definition WsfArticulatedPart.cpp:29
const char * GetScriptClassName() const override
Definition WsfArticulatedPart.cpp:1074
const int * GetComponentRoles() const override
Definition WsfArticulatedPart.cpp:153
void SetPlatform(WsfPlatform *aPlatformPtr) override
Definition WsfArticulatedPart.cpp:332
Contains the 'categories' to which an object belongs.
Definition WsfCategoryList.hpp:34
A component list that stores only components of a specified type.
Definition WsfComponentList.hpp:343
Definition WsfComponent.hpp:39
virtual bool PreInitialize(double aSimTime)
Definition WsfComponent.cpp:24
virtual void PreInput()
Definition WsfComponent.cpp:86
Definition WsfEM_Rcvr.hpp:68
Definition WsfEM_Xmtr.hpp:55
WsfEvent()=default
A base class for messages sent among simulation communication objects, processors and sensors.
Definition WsfMessage.hpp:33
virtual WsfObject * Clone() const =0
virtual void Update(double aSimTime)
Definition WsfPlatformPart.cpp:322
virtual void SetOperational(double aSimTime)
Definition WsfPlatformPart.cpp:661
virtual void PartBroken(double aSimTime)
Definition WsfPlatformPart.cpp:232
bool Initialize2(double aSimTime) override
Definition WsfPlatformPart.cpp:291
virtual void TurnOff(double aSimTime)
Definition WsfPlatformPart.cpp:606
virtual void TurnOn(double aSimTime)
Definition WsfPlatformPart.cpp:622
virtual void PlatformDeleted(WsfPlatform *aPlatformPtr)
Definition WsfPlatformPart.cpp:343
virtual void PlatformAdded(double aSimTime, WsfPlatform *aPlatformPtr)
Definition WsfPlatformPart.cpp:333
virtual void SetNonOperational(double aSimTime)
Definition WsfPlatformPart.cpp:642
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
Definition WsfScriptContext.hpp:71
Definition WsfSensorModeList.hpp:26
Definition WsfSensorMode.hpp:36
Definition WsfSensorResult.hpp:27
Definition WsfSensorScheduler.hpp:29
Definition WsfSensorTracker.hpp:75
Definition WsfSensor.hpp:477
EventType
Definition WsfSensor.hpp:480
@ cSELECT
Definition WsfSensor.hpp:481
@ cDESELECT
Definition WsfSensor.hpp:482
ModeChangeEvent()
Definition WsfSensor.cpp:1693
double mRequiredPd
Definition WsfSensor.hpp:161
Settings()
Definition WsfSensor.hpp:135
size_t mModeIndex
Definition WsfSensor.hpp:144
double mLockonTime
Definition WsfSensor.hpp:170
Definition WsfSensor.hpp:92
int GetComponentInitializationOrder() const override
Definition WsfSensor.hpp:189
bool IsClassRadio() const
Is this a 'radio frequency' sensor?
Definition WsfSensor.hpp:269
WsfSensor(const WsfScenario &aScenario)
Definition WsfSensor.cpp:52
bool IsClassSemiActive() const
Is the sensor a 'semi-active' sensor.
Definition WsfSensor.hpp:260
void SetClass(int aClass)
Set the 'classification' of the sensor.
Definition WsfSensor.cpp:1478
WsfSensorResult Result
Definition WsfSensor.hpp:96
bool mThreadSafe
Definition WsfSensor.hpp:509
void SetThreadSafe()
Definition WsfSensor.hpp:219
double GetNextUpdateTime() const
Definition WsfSensor.hpp:447
void IncrementUpdateEventEpoch()
Definition WsfSensor.hpp:435
WsfSensorScheduler * GetScheduler() const
Definition WsfSensor.hpp:406
bool IsClassVisual() const
Is this a 'visual' sensor?
Definition WsfSensor.hpp:272
bool ShowCalibrationData() const
Returns true if the sensor calibration should be output.
Definition WsfSensor.hpp:226
void SetUpdateEventActive(bool aUpdateEventActive)
Indicate if the 'Update' event is active.
Definition WsfSensor.hpp:441
ComponentList & GetComponents()
Definition WsfSensor.hpp:180
std::unique_ptr< WsfSensorModeList > mModeListPtr
Definition WsfSensor.hpp:511
int mMessageLength
The logical length (in bits) of report messages that originate from this sensor.
Definition WsfSensor.hpp:519
WsfStringId mZoneAttenuationModifier
If non-zero, the name of ID of the category to be used for zone-based attenuation.
Definition WsfSensor.hpp:525
WsfCategoryList mIgnoredCategories
Categories which this sensor should ignore.
Definition WsfSensor.hpp:528
WsfComponentListT< WsfSensorComponent > ComponentList
Definition WsfSensor.hpp:179
bool IsClassImaging() const
Does this sensor produce an image?
Definition WsfSensor.hpp:275
bool IsClassInfrared() const
Is this an 'infrared' sensor?
Definition WsfSensor.hpp:266
bool ThreadSafe() const
Returns true if the sensor update is thread safe.
Definition WsfSensor.hpp:218
double GetUpdateInterval() const override
Definition WsfSensor.hpp:290
int mMessagePriority
The priority of report messages that originate from this sensor.
Definition WsfSensor.hpp:522
void SetNotThreadSafe()
Definition WsfSensor.hpp:220
bool mIgnoreSameSide
'true' if the sensor should not detect platforms on the same side.
Definition WsfSensor.hpp:537
WsfSensor * Clone() const override=0
int GetClass() const
Returns the sensor class information.
Definition WsfSensor.hpp:251
WsfStringId GetZoneAttenuationModifier() const
Get the zone attenuation modifier.
Definition WsfSensor.hpp:461
bool IsClassPassive() const
Is the sensor a 'passive' sensor?
Definition WsfSensor.hpp:257
ut::Random & GetRandom()
Get the sensor's random number generator.
Definition WsfSensor.hpp:467
void SetUpdateInterval(double aUpdateInterval) override
Definition WsfSensor.hpp:427
std::unique_ptr< WsfSensorTracker > mTrackerPtr
Definition WsfSensor.hpp:513
double mNextUpdateTime
The time when the next call to Update() SHOULD occur.
Definition WsfSensor.hpp:516
virtual bool GetFilteredDoppler() const
Definition WsfSensor.hpp:469
bool SendDis()
Return mSendDis flag.
Definition WsfSensor.hpp:464
bool IsSlave() const
Get the current 'slave' status of a sensor.
Definition WsfSensor.hpp:395
WsfSensor & operator=(const WsfSensor &aSrc)=delete
@ cIMAGING
The sensor produces an image.
Definition WsfSensor.hpp:126
@ cPASSIVE
Definition WsfSensor.hpp:114
@ cACTIVE
The sensor detects reflected signals that originate from this sensor.
Definition WsfSensor.hpp:109
@ cACOUSTIC
The sensor operates in the acoustic frequency spectrum.
Definition WsfSensor.hpp:121
@ cRADIO
The sensor operates in the radio frequency spectrum.
Definition WsfSensor.hpp:118
@ cINFRARED
The sensor operates in the infrared frequency spectrum.
Definition WsfSensor.hpp:119
@ cSEMI_ACTIVE
The sensor detects reflected signals that originate from another transmitter.
Definition WsfSensor.hpp:111
@ cVISUAL
The sensor operates in the visual frequency spectrum.
Definition WsfSensor.hpp:120
bool IsClassActive() const
Is the sensor an 'active' sensor?
Definition WsfSensor.hpp:254
virtual void PerformScheduledDetections(double aSimTime)
Definition WsfSensor.cpp:1415
unsigned int mIgnoredDomains
A bit mask of ignored domains.
Definition WsfSensor.hpp:534
void GetMessageParameters(int &aMessageLength, int &aMessagePriority) const
Get the base level message parameters (may get overridden by the mode).
Definition WsfSensor.hpp:454
UtScriptContext * GetScriptAccessibleContext() const override
Return the context from the script.
Definition WsfSensor.cpp:1521
bool IsClassAcoustic() const
Is this an 'acoustic' sensor?
Definition WsfSensor.hpp:263
WsfComponent * CloneComponent() const override
Definition WsfSensor.hpp:186
WsfSensorTracker * GetTracker() const
Definition WsfSensor.hpp:413
void SetModeList(std::unique_ptr< WsfSensorModeList > aModeListPtr)
Definition WsfSensor.cpp:1488
bool UpdateEventActive() const
Is an 'Update' event active?
Definition WsfSensor.hpp:438
unsigned int GetUpdateEventEpoch() const
Definition WsfSensor.hpp:431
WsfSensorModeList * GetModeList() const
Definition WsfSensor.hpp:333
void SetShowCalibrationData(bool aShowCalibrationData)
Definition WsfSensor.hpp:227
std::unique_ptr< WsfSensorScheduler > mSchedulerPtr
Definition WsfSensor.hpp:512
const ComponentList & GetComponents() const
Definition WsfSensor.hpp:181
std::vector< WsfStringId > mIgnoredSides
The sides (teams) which this sensor should ignore.
Definition WsfSensor.hpp:531
Definition WsfSingleSensorObserver.hpp:33
Definition WsfTrackId.hpp:33
An object that represents an 'track' (perception) of something.
Definition WsfTrack.hpp:120
Copyrights Multiple, All Rights Reserved