WSF
WsfSectorScanSensorScheduler.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 2016 Infoscitex, a DCS 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 WSFSECTORSCANSENSORSCHEDULER_HPP
13#define WSFSECTORSCANSENSORSCHEDULER_HPP
14
15#include "wsf_export.h"
16
17#include <list>
18#include <queue>
19#include <set>
20
21class UtInput;
23#include "WsfTrack.hpp"
24
31{
32public:
34 ~WsfSectorScanSensorScheduler() override = default;
35
36 static std::unique_ptr<WsfSensorScheduler> ObjectFactory(const std::string& aTypeName);
37
38 WsfSensorScheduler* Clone() const override;
39
40 bool ProcessInput(UtInput& aInput) override;
41 bool Initialize(double aSimTime, WsfSensor* aSensorPtr, WsfSensorTracker* aTrackerPtr) override;
42
43 void TransitionSector(double aSimTime);
44
45 void ModeDeselected(double aSimTime, WsfStringId aModeNameId) override;
46 void ModeSelected(double aSimTime, WsfStringId aModeNameId) override;
47
48 void PlatformAdded(double aSimTime, WsfPlatform* aPlatformPtr) override;
49
50 void RemoveTarget(double aSimTime, size_t aTargetIndex) override;
51
52 bool SelectTarget(double aSimTime,
53 double& aNextSimTime,
54 size_t& aTargetIndex,
55 WsfTrackId& aRequestId,
56 WsfSensor::Settings& aSettings) override;
57
58 void TurnOff(double aSimTime) override;
59 void TurnOn(double aSimTime) override;
60
61private:
64
65 void AdvanceScan(double aSimTime);
66
67 void ResetSearchList();
68
70 std::vector<WsfSensorMode*> mModeList;
71
73 size_t mLastExplicitModeIndex;
74
77 std::vector<size_t> mSearchModeIndex;
78
80 bool mSearchAllowed;
81
82 struct SensorTarget
83 {
84 SensorTarget() = default;
85 SensorTarget(size_t aTargetIndex, size_t aModeIndex, double aDetectTime)
86 : mTargetIndex(aTargetIndex)
87 , mModeIndex(aModeIndex)
88 , mDetectTime(aDetectTime)
89 {
90 }
91
92 // Define operator< so that the priority queue provides results with the smallest time first.
93 bool operator<(const SensorTarget& rhs) const { return mDetectTime > rhs.mDetectTime; }
94
95 size_t mTargetIndex{0};
96 size_t mModeIndex{0};
97 double mDetectTime{0.0};
98 };
99
101 using SensorTargetQueue = std::priority_queue<SensorTarget>;
102 SensorTargetQueue mSensorTargetQueue;
103
105 double mSensorUpdateInterval;
106
110 double mLastUpdateTime;
111
114 class Sector
115 {
116 public:
117 Sector();
118 ~Sector() = default;
119
120 enum Type
121 {
122 cUNDEFINED,
123 cAZ,
124 cEL,
125 cAZEL,
126 };
127
128 bool ProcessInput(UtInput& aInput);
129 bool Initialize(WsfSensor& aSensor);
130
131 bool CheckTransition(double aAz, double aEl);
132
133 Type GetType() const { return mType; }
134 void SetType(Type aType) { mType = aType; }
135 double GetStartAz() const { return mStartAz; }
136 double GetEndAz() const { return mEndAz; }
137 void SetEndAz(double aEndAz) { mEndAz = aEndAz; }
138 void SetStartAz(double aStartAz) { mStartAz = aStartAz; }
139 double GetStartEl() const { return mStartEl; }
140 double GetEndEl() const { return mEndEl; }
141 void SetStartEl(double aStartEl) { mStartEl = aStartEl; }
142 void SetEndEl(double aEndEl) { mEndEl = aEndEl; }
143 double GetAzScanRate() const { return mAzScanRate; }
144 double GetElScanRate() const { return mElScanRate; }
145 void SetAzScanRate(double aRate) { mAzScanRate = aRate; }
146 void SetElScanRate(double aRate) { mElScanRate = aRate; }
147 WsfArticulatedPart::SlewDirection GetAzSlewDirection() const { return mAzScanDir; }
148 WsfArticulatedPart::SlewDirection GetElSlewDirection() const { return mElScanDir; }
149 void SetAzSlewDirection(WsfArticulatedPart::SlewDirection aAzScanDir) { mAzScanDir = aAzScanDir; }
150 double GetScanTime() const { return mScanTime; }
151 bool Validate() const;
152
153 private:
154 static const double cUNINITIALIZED;
155
156 Type mType;
159 double mStartAz;
160 double mEndAz;
161 double mStartEl;
162 double mEndEl;
163 double mAzScanRate;
164 double mElScanRate;
165 double mScanTime;
166 };
167
168 void BeginSlew(double aSimTime, Sector& aSector);
169
170 void SlewToSector(double aSimTime, Sector& aSector);
171
172 double EstimateDetectTime(double aSimTime, WsfPlatform& aTarget);
173
174 void InitializeScan(double aSimTime);
175
176 using Sectors = std::list<Sector>;
177
178 bool mSlewingToNextSector;
179 bool mIsContinuousAz;
180 bool mFrameBasedScheduling;
181 Sector mSlewTransition;
182 Sector* mCurrentSectorPtr;
183 Sectors mSectors;
184 Sectors::iterator mSectorIter;
185 Sectors::iterator mNextSectorIter;
186 std::set<size_t> mTargetsSelectedThisFrame;
187};
188
189#endif
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
SlewDirection
Definition WsfArticulatedPart.hpp:52
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
static std::unique_ptr< WsfSensorScheduler > ObjectFactory(const std::string &aTypeName)
Definition WsfSectorScanSensorScheduler.cpp:89
WsfSectorScanSensorScheduler()
Definition WsfSectorScanSensorScheduler.cpp:42
~WsfSectorScanSensorScheduler() override=default
void TransitionSector(double aSimTime)
Definition WsfSectorScanSensorScheduler.cpp:429
virtual void RemoveTarget(double aSimTime, size_t aTargetIndex)
Definition WsfSensorScheduler.cpp:150
virtual void PlatformAdded(double aSimTime, WsfPlatform *aPlatformPtr)
Definition WsfSensorScheduler.cpp:122
virtual void TurnOff(double aSimTime)
Definition WsfSensorScheduler.cpp:213
virtual bool Initialize(double aSimTime, WsfSensor *aSensorPtr, WsfSensorTracker *aTrackerPtr)
Definition WsfSensorScheduler.cpp:91
virtual bool SelectTarget(double aSimTime, double &aNextSimTime, size_t &aTargetIndex, WsfTrackId &aRequestId, WsfSensor::Settings &aSettings)
Definition WsfSensorScheduler.cpp:176
WsfSensorScheduler()
Definition WsfSensorScheduler.cpp:26
virtual void ModeDeselected(double aSimTime, WsfStringId aModeNameId)
Definition WsfSensorScheduler.cpp:106
virtual void TurnOn(double aSimTime)
Definition WsfSensorScheduler.cpp:219
virtual WsfSensorScheduler * Clone() const
Definition WsfSensorScheduler.cpp:45
WsfSensorScheduler & operator=(const WsfSensorScheduler &aSrc)=delete
virtual void ModeSelected(double aSimTime, WsfStringId aModeNameId)
Definition WsfSensorScheduler.cpp:115
virtual bool ProcessInput(UtInput &aInput)
Definition WsfSensorScheduler.cpp:132
Definition WsfSensorTracker.hpp:75
Definition WsfSensor.hpp:133
Definition WsfSensor.hpp:92
Definition WsfTrackId.hpp:33
Type
Definition P6DofVehicleData.hpp:182
WSF_EXPORT InitializeCallback & Initialize(const WsfSimulation *aSimulationPtr)
Copyrights Multiple, All Rights Reserved