60class GPS :
public SGSubsystem,
65 GPS (SGPropertyNode *node,
bool defaultGPSMode =
false);
74 void update (
double delta_time_sec)
override;
99 friend class SearchFilter;
101 void setFlyByMaxTurnAngle(
double maxAngle);
111 void bind(
GPS* aOwner, SGPropertyNode* aCfg);
113 bool turnAnticipationEnabled()
const {
return _enableTurnAnticipation; }
119 double turnRateDegSec()
const {
return _turnRate; }
124 double overflightDistanceNm()
const {
return _overflightDistance; }
130 double overflightArmDistanceNm()
const {
return _overflightArmDistance; }
134 double overflightArmAngleDeg()
const {
return _overflightArmAngle; }
139 double waypointAlertTime()
const {
return _waypointAlertTime; }
141 bool requireHardSurface()
const {
return _requireHardSurface; }
143 bool cdiDeflectionIsAngular()
const {
return (_cdiMaxDeflectionNm <= 0.0); }
145 double cdiDeflectionLinearPeg()
const
147 assert(_cdiMaxDeflectionNm > 0.0);
148 return _cdiMaxDeflectionNm;
151 bool driveAutopilot()
const {
return _driveAutopilot; }
153 bool courseSelectable()
const {
return _courseSelectable; }
162 bool followLegTrackToFix()
const {
return _followLegTrackToFix; }
165 bool delegateDoesSequencing()
const {
return _delegateSequencing; }
167 double maxFlyByTurnAngleDeg()
const {
return _maxFlyByTurnAngle; }
169 void setMaxFlyByTurnAngle(
double deg)
171 _maxFlyByTurnAngle = deg;
175 bool _enableTurnAnticipation;
181 double _overflightDistance;
184 double _overflightArmDistance;
187 double _overflightArmAngle;
191 double _waypointAlertTime;
194 bool _requireHardSurface;
196 double _cdiMaxDeflectionNm;
199 bool _driveAutopilot;
202 bool _courseSelectable;
205 bool _followLegTrackToFix;
209 bool _delegateSequencing =
false;
211 double _maxFlyByTurnAngle = 90.0;
214 class SearchFilter :
public FGPositioned::Filter
217 virtual bool pass(FGPositioned* aPos)
const;
226 void updateBasicData(
double dt);
228 void updateTrackingBug();
229 void updateRouteData();
230 void driveAutopilot();
239 bool isScratchPositionValid()
const;
243 void setScratchFromPositioned(FGPositioned* aPos,
int aIndex);
244 void setScratchFromCachedSearchResult();
245 void setScratchFromRouteWaypoint(
int aIndex);
248 void addAirportToScratch(FGAirport* aAirport);
253 void performSearch();
256 void loadRouteWaypoint();
260 void previousResult();
261 void defineWaypoint();
262 void insertWaypointAtIndex(
int aIndex);
263 void removeWaypointAtIndex(
int aIndex);
264 void commandExitHold();
267 double getScratchDistance()
const;
268 double getScratchMagBearing()
const;
269 double getScratchTrueBearing()
const;
270 bool getScratchHasNext()
const;
275 void selectLegMode();
276 void selectOBSMode(flightgear::Waypt* waypt);
280 void setCommand(
const char* aCmd);
281 const char* getCommand()
const {
return ""; }
283 const char* getMode()
const {
return _mode.c_str(); }
284 bool getScratchValid()
const {
return _scratchValid; }
286 double getSelectedCourse()
const {
return _selectedCourse; }
287 void setSelectedCourse(
double crs);
288 double getDesiredCourse()
const {
return _desiredCourse; }
290 double getCDIDeflection()
const;
292 double getLegDistance()
const;
293 double getLegCourse()
const;
294 double getLegMagCourse()
const;
296 double getTrueTrack()
const {
return _last_true_track; }
297 double getMagTrack()
const;
298 double getGroundspeedKts()
const {
return _last_speed_kts; }
299 double getVerticalSpeed()
const {
return _last_vertical_speed; }
301 const char* getWP0Ident()
const;
302 const char* getWP0Name()
const;
304 bool getWP1IValid()
const;
305 const char* getWP1Ident()
const;
306 const char* getWP1Name()
const;
308 double getWP1Distance()
const;
309 double getWP1TTW()
const;
310 const char* getWP1TTWString()
const;
311 double getWP1Bearing()
const;
312 double getWP1MagBearing()
const;
313 double getWP1CourseDeviation()
const;
314 double getWP1CourseErrorNm()
const;
315 bool getWP1ToFlag()
const;
316 bool getWP1FromFlag()
const;
320 double computeTurnRadiusNm(
double aGroundSpeedKts)
const;
325 template <
typename T>
326 void tie(SGPropertyNode* aNode,
const char* aRelPath,
const SGRawValue<T>& aRawValue)
328 _tiedProperties.Tie(aNode->getNode(aRelPath,
true), aRawValue);
332 void tieSGGeod(SGPropertyNode* aNode, SGGeod& aRef,
333 const char* lonStr,
const char* latStr,
const char* altStr);
336 void tieSGGeodReadOnly(SGPropertyNode* aNode, SGGeod& aRef,
337 const char* lonStr,
const char* latStr,
const char* altStr);
339 void updateCurrentWpNode(
const SGGeod&
p);
342 void currentWaypointChanged()
override;
343 void waypointsChanged()
override;
344 void cleared()
override;
345 void endOfFlightPlan()
override;
348 void routeManagerFlightPlanChanged(SGPropertyNode*);
349 void routeActivated(SGPropertyNode*);
352 SGPropertyNode_ptr _gpsNode;
353 SGPropertyNode_ptr _currentWayptNode;
354 SGPropertyNode_ptr _currentWpLatNode,
355 _currentWpLonNode, _currentWpAltNode;
357 SGPropertyNode_ptr _magvar_node;
358 SGPropertyNode_ptr _serviceable_node;
359 SGPropertyNode_ptr _electrical_node;
360 SGPropertyNode_ptr _tracking_bug_node;
361 SGPropertyNode_ptr _raim_node;
363 SGPropertyNode_ptr _odometer_node;
364 SGPropertyNode_ptr _trip_odometer_node;
365 SGPropertyNode_ptr _true_bug_error_node;
366 SGPropertyNode_ptr _magnetic_bug_error_node;
367 SGPropertyNode_ptr _eastWestVelocity;
368 SGPropertyNode_ptr _northSouthVelocity;
371 SGPropertyNode_ptr _route_current_wp_node;
372 SGPropertyNode_ptr _routeDistanceNm;
373 SGPropertyNode_ptr _routeETE;
374 SGPropertyNode_ptr _desiredCourseNode;
376 double _selectedCourse;
377 double _desiredCourse;
382 double _last_speed_kts;
383 double _last_true_track;
384 double _last_vertical_speed;
385 double _lastEWVelocity;
386 double _lastNSVelocity;
395 bool _defaultGPSMode;
402 SGGeod _wp0_position;
403 SGGeod _indicated_pos;
404 double _legDistanceNm;
408 SGPropertyNode_ptr _scratchNode;
412 int _searchResultIndex;
413 std::string _searchQuery;
422 std::optional<RNAV::LegData> _wp0Data;
424 std::unique_ptr<flightgear::WayptController> _wayptController;
430 SGPropertyNode_ptr _apDrivingFlag;
431 SGPropertyNode_ptr _apTrueHeading;
433 simgear::TiedPropertyList _tiedProperties;
437 SGPropertyChangeCallback<GPS> _callbackFlightPlanChanged;
438 SGPropertyChangeCallback<GPS> _callbackRouteActivated;