@@ -127,50 +127,58 @@ public static bool isINSMode() {
127
127
128
128
public static void updateNavigationData ( )
129
129
{
130
-
131
- selectedGlideSlope = gsList [ gsIdx ] ;
132
- selectedRwy = rwyList [ rwyIdx ] ;
133
-
134
- //Since there seems to be no callback methods to determine whether waypoint has been set or changed, we have to refresh INS data on every update
135
- NavWaypoint navpoint = FinePrint . WaypointManager . navWaypoint ;
136
- if ( FinePrint . WaypointManager . navIsActive ( ) && ( navpoint != null ) ) {
137
- //Trying to find the FinePrint waypoint that navigation is set for:
138
- Waypoint waypoint = null ;
139
-
140
- foreach ( Waypoint wp in FinePrint . WaypointManager . Instance ( ) . Waypoints ) {
141
- if ( navpoint . latitude == wp . latitude && navpoint . longitude == wp . longitude ) {
142
- waypoint = wp ;
143
- break ;
144
- }
145
- }
146
- if ( waypoint != null ) {
147
- //If waypoint is fine then generate fake target runway every time
148
- Runway insTarget = new Runway ( ) ;
149
- insTarget . isINSTarget = true ;
150
- insTarget . ident = waypoint . name ;
151
- insTarget . hdg = selectedRwy != null ? selectedRwy . hdg : 0 ;
152
- insTarget . altMSL = ( float ) ( waypoint . height + waypoint . altitude ) ;
153
- insTarget . locLatitude = ( float ) navpoint . latitude ;
154
- insTarget . locLongitude = ( float ) navpoint . longitude ;
155
- insTarget . gsLatitude = ( float ) navpoint . latitude ;
156
- insTarget . gsLongitude = ( float ) navpoint . longitude ;
157
- selectedRwy = insTarget ;
158
- }
159
- }
160
-
161
- currentVessel = FlightGlobals . ActiveVessel ;
162
-
163
- bearing = NavUtilLib . Utils . CalcBearingToBeacon ( currentVessel , selectedRwy ) ;
164
- dme = NavUtilLib . Utils . CalcDistanceToBeacon ( currentVessel , selectedRwy ) ;
165
- elevationAngle = NavUtilLib . Utils . CalcElevationAngle ( currentVessel , selectedRwy ) ;
166
- //locDeviation = NavUtilLib.Utils.CalcLocalizerDeviation(bearing, selectedRwy);
167
- locDeviation = ( float ) NavUtilLib . Utils . CalcLocalizerDeviation ( currentVessel , selectedRwy ) ;
168
- gsDeviation = NavUtilLib . Utils . CalcGlideslopeDeviation ( elevationAngle , selectedGlideSlope ) ;
169
-
170
- //
171
- runwayHeading = ( float ) NavUtilLib . Utils . CalcProjectedRunwayHeading ( currentVessel , selectedRwy ) ;
172
-
173
- SetLastNavUpdateUT ( ) ;
130
+ //see if information is current
131
+ if ( GetLastNavUpdateUT ( ) != Planetarium . GetUniversalTime ( ) )
132
+ {
133
+
134
+ selectedGlideSlope = gsList [ gsIdx ] ;
135
+ selectedRwy = rwyList [ rwyIdx ] ;
136
+
137
+ //Since there seems to be no callback methods to determine whether waypoint has been set or changed, we have to refresh INS data on every update
138
+ NavWaypoint navpoint = FinePrint . WaypointManager . navWaypoint ;
139
+ if ( FinePrint . WaypointManager . navIsActive ( ) && ( navpoint != null ) )
140
+ {
141
+ //Trying to find the FinePrint waypoint that navigation is set for:
142
+ Waypoint waypoint = null ;
143
+
144
+ foreach ( Waypoint wp in FinePrint . WaypointManager . Instance ( ) . Waypoints )
145
+ {
146
+ if ( navpoint . latitude == wp . latitude && navpoint . longitude == wp . longitude )
147
+ {
148
+ waypoint = wp ;
149
+ break ;
150
+ }
151
+ }
152
+ if ( waypoint != null )
153
+ {
154
+ //If waypoint is fine then generate fake target runway every time
155
+ Runway insTarget = new Runway ( ) ;
156
+ insTarget . isINSTarget = true ;
157
+ insTarget . ident = waypoint . name ;
158
+ insTarget . hdg = selectedRwy != null ? selectedRwy . hdg : 0 ;
159
+ insTarget . altMSL = ( float ) ( waypoint . height + waypoint . altitude ) ;
160
+ insTarget . locLatitude = ( float ) navpoint . latitude ;
161
+ insTarget . locLongitude = ( float ) navpoint . longitude ;
162
+ insTarget . gsLatitude = ( float ) navpoint . latitude ;
163
+ insTarget . gsLongitude = ( float ) navpoint . longitude ;
164
+ selectedRwy = insTarget ;
165
+ }
166
+ }
167
+
168
+ currentVessel = FlightGlobals . ActiveVessel ;
169
+
170
+ bearing = NavUtilLib . Utils . CalcBearingToBeacon ( currentVessel , selectedRwy ) ;
171
+ dme = NavUtilLib . Utils . CalcDistanceToBeacon ( currentVessel , selectedRwy ) ;
172
+ elevationAngle = NavUtilLib . Utils . CalcElevationAngle ( currentVessel , selectedRwy ) ;
173
+ //locDeviation = NavUtilLib.Utils.CalcLocalizerDeviation(bearing, selectedRwy);
174
+ locDeviation = ( float ) NavUtilLib . Utils . CalcLocalizerDeviation ( currentVessel , selectedRwy ) ;
175
+ gsDeviation = NavUtilLib . Utils . CalcGlideslopeDeviation ( elevationAngle , selectedGlideSlope ) ;
176
+
177
+ //
178
+ runwayHeading = ( float ) NavUtilLib . Utils . CalcProjectedRunwayHeading ( currentVessel , selectedRwy ) ;
179
+
180
+ SetLastNavUpdateUT ( ) ;
181
+ }
174
182
}
175
183
}
176
184
0 commit comments