1 // gps.hxx - distance-measuring equipment.
2 // Written by David Megginson, started 2003.
4 // This file is in the Public Domain and comes with no warranty.
7 #ifndef __INSTRUMENTS_GPS_HXX
8 #define __INSTRUMENTS_GPS_HXX 1
10 #include <simgear/props/props.hxx>
11 #include <simgear/structure/subsystem_mgr.hxx>
12 #include <simgear/math/SGMath.hxx>
24 void init(SGPropertyNode* base, const char* lonStr, const char* latStr, const char* altStr = NULL);
25 void init(const char* lonStr, const char* latStr, const char* altStr = NULL);
27 void operator=(const SGGeod& geod);
30 SGPropertyNode_ptr _lon, _lat, _alt;
38 * /position/longitude-deg
39 * /position/latitude-deg
40 * /position/altitude-ft
41 * /environment/magnetic-variation-deg
42 * /systems/electrical/outputs/gps
43 * /instrumentation/gps/serviceable
45 * /instrumentation/gps/wp-longitude-deg
46 * /instrumentation/gps/wp-latitude-deg
47 * /instrumentation/gps/wp-altitude-ft
48 * /instrumentation/gps/wp-ID
49 * /instrumentation/gps/wp-name
50 * /instrumentation/gps/desired-course-deg
51 * /instrumentation/gps/get-nearest-airport
52 * /instrumentation/gps/waypoint-type
53 * /instrumentation/gps/tracking-bug
57 * /instrumentation/gps/indicated-longitude-deg
58 * /instrumentation/gps/indicated-latitude-deg
59 * /instrumentation/gps/indicated-altitude-ft
60 * /instrumentation/gps/indicated-vertical-speed-fpm
61 * /instrumentation/gps/indicated-track-true-deg
62 * /instrumentation/gps/indicated-track-magnetic-deg
63 * /instrumentation/gps/indicated-ground-speed-kt
65 * /instrumentation/gps/wp-distance-nm
66 * /instrumentation/gps/wp-bearing-deg
67 * /instrumentation/gps/wp-bearing-mag-deg
68 * /instrumentation/gps/TTW
69 * /instrumentation/gps/course-deviation-deg
70 * /instrumentation/gps/course-error-nm
71 * /instrumentation/gps/to-flag
72 * /instrumentation/gps/odometer
73 * /instrumentation/gps/trip-odometer
74 * /instrumentation/gps/true-bug-error-deg
75 * /instrumentation/gps/magnetic-bug-error-deg
76 * /instrumentation/gps/true-bearing-error-deg
77 * /instrumentation/gps/magnetic-bearing-error-deg
79 class GPS : public SGSubsystem
84 GPS (SGPropertyNode *node);
89 virtual void update (double delta_time_sec);
97 bool waypoint_changed;
103 double wp0_course_deg;
104 double wp0_bearing_deg;
106 double wp1_course_deg;
107 double wp1_bearing_deg;
110 void search (double frequency, const SGGeod& pos);
113 * reset all output properties to default / non-service values
117 void updateWithValid(UpdateContext& ctx);
119 void updateNearestAirport(UpdateContext& ctx);
120 void updateWaypoint0(UpdateContext& ctx);
121 void updateWaypoint1(UpdateContext& ctx);
123 void updateLegCourse(UpdateContext& ctx);
124 void updateWaypoint0Course(UpdateContext& ctx);
125 void updateWaypoint1Course(UpdateContext& ctx);
127 void waypointChanged(UpdateContext& ctx);
128 void updateTTWNode(UpdateContext& ctx, double distance_m, SGPropertyNode_ptr node);
129 void updateTrackingBug(UpdateContext& ctx);
131 SGPropertyNode_ptr _magvar_node;
132 SGPropertyNode_ptr _serviceable_node;
133 SGPropertyNode_ptr _electrical_node;
134 SGPropertyNode_ptr _wp0_ID_node;
135 SGPropertyNode_ptr _wp0_name_node;
136 SGPropertyNode_ptr _wp0_course_node;
137 SGPropertyNode_ptr _get_nearest_airport_node;
138 SGPropertyNode_ptr _wp1_ID_node;
139 SGPropertyNode_ptr _wp1_name_node;
140 SGPropertyNode_ptr _wp1_course_node;
141 SGPropertyNode_ptr _tracking_bug_node;
143 SGPropertyNode_ptr _raim_node;
144 SGPropertyNode_ptr _indicated_vertical_speed_node;
145 SGPropertyNode_ptr _true_track_node;
146 SGPropertyNode_ptr _magnetic_track_node;
147 SGPropertyNode_ptr _speed_node;
148 SGPropertyNode_ptr _wp0_distance_node;
149 SGPropertyNode_ptr _wp0_ttw_node;
150 SGPropertyNode_ptr _wp0_bearing_node;
151 SGPropertyNode_ptr _wp0_mag_bearing_node;
152 SGPropertyNode_ptr _wp0_course_deviation_node;
153 SGPropertyNode_ptr _wp0_course_error_nm_node;
154 SGPropertyNode_ptr _wp0_to_flag_node;
155 SGPropertyNode_ptr _wp1_distance_node;
156 SGPropertyNode_ptr _wp1_ttw_node;
157 SGPropertyNode_ptr _wp1_bearing_node;
158 SGPropertyNode_ptr _wp1_mag_bearing_node;
159 SGPropertyNode_ptr _wp1_course_deviation_node;
160 SGPropertyNode_ptr _wp1_course_error_nm_node;
161 SGPropertyNode_ptr _wp1_to_flag_node;
162 SGPropertyNode_ptr _odometer_node;
163 SGPropertyNode_ptr _trip_odometer_node;
164 SGPropertyNode_ptr _true_bug_error_node;
165 SGPropertyNode_ptr _magnetic_bug_error_node;
166 SGPropertyNode_ptr _true_wp0_bearing_error_node;
167 SGPropertyNode_ptr _magnetic_wp0_bearing_error_node;
168 SGPropertyNode_ptr _true_wp1_bearing_error_node;
169 SGPropertyNode_ptr _magnetic_wp1_bearing_error_node;
170 SGPropertyNode_ptr _leg_distance_node;
171 SGPropertyNode_ptr _leg_course_node;
172 SGPropertyNode_ptr _leg_magnetic_course_node;
173 SGPropertyNode_ptr _alt_dist_ratio_node;
174 SGPropertyNode_ptr _leg_course_deviation_node;
175 SGPropertyNode_ptr _leg_course_error_nm_node;
176 SGPropertyNode_ptr _leg_to_flag_node;
177 SGPropertyNode_ptr _alt_deviation_node;
181 double _last_speed_kts;
183 std::string _last_wp0_ID;
184 std::string _last_wp1_ID;
186 double _alt_dist_ratio;
192 double _azimuth_error;
194 double _elapsed_time;
199 SGGeodProperty _position;
200 SGGeodProperty _wp0_position;
201 SGGeodProperty _wp1_position;
202 SGGeodProperty _indicated_pos;
206 #endif // __INSTRUMENTS_GPS_HXX