WSF
WsfRouteMover.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// Updated by Infoscitex, a DCS Company.
13// ****************************************************************************
14
15#ifndef WSFROUTEMOVER_HPP
16#define WSFROUTEMOVER_HPP
17
18#include "wsf_export.h"
19
20#include "WsfEvent.hpp"
21#include "WsfMover.hpp"
22class WsfPathFinder;
23#include "WsfRandomVariable.hpp"
24#include "WsfRoute.hpp"
26#include "WsfWaypoint.hpp"
28
29namespace wsf
30{
31class Terrain;
32}
33
43{
44public:
51
52 WsfRouteMover() = delete;
53 WsfRouteMover(const WsfScenario& aScenario);
54 WsfRouteMover(const WsfRouteMover& aSrc);
56 ~WsfRouteMover() override;
57
58 bool Initialize(double aSimTime) override;
59 bool Initialize2(double aSimTime) override;
60 void Update(double aSimTime) override;
61 bool ProcessInput(UtInput& aInput) override;
62
63 void TurnOff(double aSimTime) override;
64 void TurnOn(double aSimTime) override;
65
66 const WsfRoute* GetRoute() const override { return &mRoute; }
67
68 const WsfRoute* GetDefaultRoute() const override { return &mDefaultRoute; }
69
70 int RoutePointIndex() const override { return mTargetIndex; }
71
72 bool SetRoute(double aSimTime, const WsfRoute& aRoute) override { return SetRoutePoint(aSimTime, aRoute, 0); }
73
74 bool GoToLabel(double aSimTime, WsfStringId aLabelId) override;
75
76 bool GoToWaypoint(double aSimTime, unsigned int aDestination) override;
77
78 bool GoToClosestPoint(double aSimTime) override;
79
80 bool FindAndSetPath(double aSimTime, WsfGeoPoint* aStartPtr, WsfGeoPoint* aEndPtr) override;
81
82 bool GoToLocation(double aSimTime, double aLatitude, double aLongitude, double aAltitude) override;
83
85 virtual void Pause(double aSimTime, double aUnpauseTime) = 0;
86
87 virtual bool Unpause(double aSimTime, bool aInterrupt);
88
89 bool UpdateRoute(double aSimTime, const WsfRoute& aRoute) override;
90
91 bool UpdateDefaultRoute() override;
92
93 virtual bool SetRoutePoint(double aSimTime, const WsfRoute& aRoute, int aTargetPoint);
94
95 bool ReturnToRoute(double aSimTime) override;
96
98 bool IsPaused() const override;
99
100 WsfRouteComputer* GetRouteComputer() const { return mRouteComputerPtr; }
101 void SetRouteComputer(WsfRouteComputer* aRouteComputerPtr);
102
104 void SetEndOfPath(WsfPath::EndPath aEndOfPathOption) { mEndOfPath = aEndOfPathOption; }
105
107 int GetTargetIndex() const { return mTargetIndex; }
108 void SetTargetIndex(int aIndex) { mTargetIndex = aIndex; }
110 int GetCurrentIndex() const { return mCurrentIndex; }
111
112 bool GoToSpeed(double aSimTime, double aSpeed, double aLinearAccel, bool aKeepRoute) override;
113
116 WsfPath::Switch GetSwitch() const { return mSwitch; }
117 virtual const WsfPathConstraints* GetMoverConstraints() const;
118
119 class UnpauseEvent : public WsfEvent
120 {
121 public:
122 UnpauseEvent(WsfRouteMover* aMoverPtr, double aUnpauseTime)
123 : WsfEvent(aUnpauseTime)
124 , mMoverPtr(aMoverPtr)
125 , mEnabled(true)
126 {
127 }
128
129 // If this event is deleted
130 ~UnpauseEvent() override
131 {
132 if (mEnabled)
133 {
134 mMoverPtr->mUnpauseEventPtr = nullptr;
135 }
136 }
137
139 {
140 if (mEnabled)
141 {
142 mEnabled = false;
143 mMoverPtr->TriggerUnpause(GetTime());
144 }
145 return cDELETE;
146 }
147
148 void Disable() { mEnabled = false; }
149
150 private:
151 WsfRouteMover* mMoverPtr;
152 bool mEnabled;
153 };
154
155protected:
156 void TriggerUnpause(double aSimTime);
157
158 void SetAltRef(WsfPath::AltRef aAltRef) { mAltRef = aAltRef; }
159 WsfPath::AltRef GetAltRef() const { return mAltRef; }
160
161 // bool RouteIsValid(double aSimTime,
162 // const WsfRoute& aRoute);
163
166 virtual void SetGuidanceFrom(const WsfWaypoint& aPreviousWaypoint) = 0;
167
170 virtual void SetGuidanceTo(const WsfWaypoint& aNextWaypoint) = 0;
171
177 virtual void AdvanceToNextWaypoint(double aSimTime, const WsfWaypoint& aTarget, const WsfWaypoint* aNextPointPtr) = 0;
178
179 virtual void UpdatePosition(double aSimTime) = 0;
180
181 virtual void WaypointReached(double aSimTime);
182
183 void RouteChanged();
184
185 bool IsSwitchingPoints() { return mProcessPointStage != -1; }
186
187 void AddUnpauseEventFor(WsfRouteMover* aMoverPtr, double aUnpauseTime);
188 void DisableAndClearUnpause();
189
194
200 mutable double mUnpauseTime;
201
204
205private:
206 void InitializeUnpauseTime() const;
207
208 void NormalizeRoute(WsfRoute& aRoute, bool aIsInitialRoute);
209
210 void DoAdvanceToNextWaypoint(double aSimTime);
211
212 int GetNextWaypointIndex(int aPointIndex);
213
214 bool ProcessNextPoint(double aSimTime);
215
216 bool ProcessNextPointStage(double aSimTime);
217
218 bool ExecuteTriggers(double aSimTime, unsigned int aPointIndex) override;
219
220 void ExecuteEndOfPath(double aSimTime, const WsfWaypoint& aEndPoint);
221
222 void DrawDebugRoute();
223
225 bool mIsInitialized;
227 bool mUpdating;
229 bool mDisableTerrain;
231 bool mPrintRoutes;
233 bool mDrawRoutes;
235 int mProcessPointStage;
237 int mCurrentIndex;
240 int mTargetIndex;
242 WsfRoute mRoute;
244 WsfPath::Switch mSwitch;
246 WsfStringId mStartLabelId;
247
248 WsfRoute mDefaultRoute;
250 int mLastRouteTargetIndex;
252 WsfPath::EndPath mEndOfPath;
253
254 WsfRouteComputer* mRouteComputerPtr;
255
257 UnpauseEvent* mUnpauseEventPtr;
258
260 WsfPath::AltRef mAltRef;
261
263 mutable WsfRandomVariable mStartTime;
264};
265
266#endif
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
double GetTime() const
Definition WsfEvent.hpp:71
WsfEvent()=default
EventDisposition
Definition WsfEvent.hpp:37
@ cDELETE
Delete the event from the event queue.
Definition WsfEvent.hpp:38
Definition WsfGeoPoint.hpp:29
virtual bool FindAndSetPath(double aSimTime, WsfGeoPoint *aStartPtr, WsfGeoPoint *aEndPtr)
Definition WsfMover.cpp:519
virtual bool ExecuteTriggers(double aSimTime, unsigned int aPointIndex)
Definition WsfMover.cpp:360
virtual bool GoToLabel(double aSimTime, WsfStringId aLabelId)
Definition WsfMover.cpp:414
bool ProcessInput(UtInput &aInput) override
Definition WsfMover.cpp:138
virtual bool UpdateDefaultRoute()
Definition WsfMover.cpp:501
void TurnOff(double aSimTime) override
Definition WsfMover.cpp:247
bool Initialize(double aSimTime) override
Definition WsfMover.cpp:108
bool Initialize2(double aSimTime) override
Definition WsfPlatformPart.cpp:291
virtual bool ReturnToRoute(double aSimTime)
Definition WsfMover.cpp:393
virtual bool GoToSpeed(double aSimTime, double aSpeed, double aLinearAccel, bool aKeepRoute)
Definition WsfMover.cpp:441
virtual bool GoToClosestPoint(double aSimTime)
Definition WsfMover.cpp:403
WsfMover()=delete
virtual bool GoToWaypoint(double aSimTime, unsigned int aDestination)
Definition WsfMover.cpp:512
virtual bool GoToLocation(double aSimTime, double aLatitude, double aLongitude, double aAltitude)
Definition WsfMover.cpp:428
void TurnOn(double aSimTime) override
Definition WsfMover.cpp:255
virtual bool IsPaused() const
Definition WsfMover.cpp:561
void Update(double aSimTime) override
Definition WsfMover.cpp:310
virtual bool UpdateRoute(double aSimTime, const WsfRoute &aRoute)
Definition WsfMover.cpp:492
Definition WsfPathFinder.hpp:109
Definition WsfRandomVariable.hpp:33
Definition WsfRouteComputer.hpp:26
Definition WsfRouteMover.hpp:120
void Disable()
Definition WsfRouteMover.hpp:148
UnpauseEvent(WsfRouteMover *aMoverPtr, double aUnpauseTime)
Definition WsfRouteMover.hpp:122
~UnpauseEvent() override
Definition WsfRouteMover.hpp:130
EventDisposition Execute() override
Definition WsfRouteMover.hpp:138
Definition WsfRouteMover.hpp:43
virtual bool Unpause(double aSimTime, bool aInterrupt)
Definition WsfRouteMover.cpp:1451
int RoutePointIndex() const override
Definition WsfRouteMover.hpp:70
MissTurnOption GetTurnFailOption() const
Definition WsfRouteMover.hpp:114
WsfRouteComputer * GetRouteComputer() const
Definition WsfRouteMover.hpp:100
WsfRouteMover & operator=(const WsfRouteMover &)=delete
double GetTurnFailThreshold() const
Definition WsfRouteMover.hpp:115
virtual void WaypointReached(double aSimTime)
Called when waypoint is reached.
Definition WsfRouteMover.cpp:465
virtual bool SetRoutePoint(double aSimTime, const WsfRoute &aRoute, int aTargetPoint)
Definition WsfRouteMover.cpp:623
bool SetRoute(double aSimTime, const WsfRoute &aRoute) override
Definition WsfRouteMover.hpp:72
double mAltitudeOffset
Altitude offset of the parent platform's center of gravity / mass (CG).
Definition WsfRouteMover.hpp:203
void SetTargetIndex(int aIndex)
Definition WsfRouteMover.hpp:108
WsfRouteMover()=delete
virtual void UpdatePosition(double aSimTime)=0
const WsfRoute * GetRoute() const override
Definition WsfRouteMover.hpp:66
virtual void SetGuidanceFrom(const WsfWaypoint &aPreviousWaypoint)=0
double mUnpauseTime
Simulation time at which the mover will unpause.
Definition WsfRouteMover.hpp:200
int GetCurrentIndex() const
Return current waypoint index.
Definition WsfRouteMover.hpp:110
bool IsSwitchingPoints()
Definition WsfRouteMover.hpp:185
MissTurnOption
Definition WsfRouteMover.hpp:46
@ cREVERSE_TURN
Definition WsfRouteMover.hpp:48
@ cSKIP_POINT
Definition WsfRouteMover.hpp:49
@ cCLOSEST_POINT
Definition WsfRouteMover.hpp:47
wsf::Terrain * mTerrainPtr
Definition WsfRouteMover.hpp:190
virtual void AdvanceToNextWaypoint(double aSimTime, const WsfWaypoint &aTarget, const WsfWaypoint *aNextPointPtr)=0
WsfPath::AltRef GetAltRef() const
Definition WsfRouteMover.hpp:159
void SetEndOfPath(WsfPath::EndPath aEndOfPathOption)
Sets the default end-of-path option for the mover.
Definition WsfRouteMover.hpp:104
MissTurnOption mTurnFailOption
If true, the mover will ensure it passes each point.
Definition WsfRouteMover.hpp:196
int GetTargetIndex() const
Return next waypoint index.
Definition WsfRouteMover.hpp:107
virtual void SetGuidanceTo(const WsfWaypoint &aNextWaypoint)=0
WsfPath::Switch GetSwitch() const
Definition WsfRouteMover.hpp:116
void SetAltRef(WsfPath::AltRef aAltRef)
Definition WsfRouteMover.hpp:158
double mTurnFailureThreshold
Threshold of turn failure as percentage of turn radius.
Definition WsfRouteMover.hpp:198
bool mForceUpdates
Definition WsfRouteMover.hpp:193
virtual void Pause(double aSimTime, double aUnpauseTime)=0
Sets the mover to a paused state.
const WsfRoute * GetDefaultRoute() const override
Definition WsfRouteMover.hpp:68
void RouteChanged()
Called when the route is changed to reset processing of current point.
Definition WsfRouteMover.cpp:1089
A collection of WsfWaypoint objects that represent a path to be followed.
Definition WsfRoute.hpp:40
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
Definition WsfWaypoint.hpp:57
Definition WsfTerrain.hpp:336
AltRef
Altitude reference option.
Definition WsfPath.hpp:52
Switch
Option setting when to react as a WsfWaypoint is approached.
Definition WsfPath.hpp:76
EndPath
End of-path option.
Definition WsfPath.hpp:67
Function definitions for those who need run-time access to the version.
Definition WsfComm.cpp:32
Contains constraints used for computing a path in WsfPathComputer.
Definition WsfPathConstraints.hpp:24
Copyrights Multiple, All Rights Reserved