Exemplo n.º 1
0
            public static void Update()
            {
                Vessel vessel = FlightGlobals.ActiveVessel;

                if (vessel == null)
                {
                    return;
                }

                if (destinationAirfield == null)
                {
                    return;
                }

                distanceToAirfield = NavUtils.DistanceToAirfield(vessel, destinationAirfield);
                bearingToAirfield  = NavUtils.InitialBearingToAirfield(vessel, destinationAirfield);

                // do this not to often and not in an airfield
                if (landingRunway == null || distanceToAirfield > 2000 || !InBeam)
                {
                    landingRunway = destinationAirfield.GetLandingRunwayForBearing(bearingToAirfield);
                    ILS           = landingRunway.HasILS;
                }

                if (landingRunway != null)
                {
                    // Bearing to runway
                    bearingToRunway = NavUtils.InitialBearingToRunway(vessel, landingRunway);
                    if (bearingToRunway < 0)
                    {
                        bearingToRunway = 360 - bearingToRunway;
                    }
                    //
                    // distance to runway
                    distanceToRunway = NavUtils.DistanceToRunway(vessel, landingRunway);
                    //
                    // glide slope
                    horizontalGlideslopeDeviation = NavUtils.HorizontalGlideSlopeDeviation(bearingToRunway, landingRunway);
                    verticalGlideslopeDeviation   = NavUtils.VerticalGlideSlopeDeviation(vessel, landingRunway);
                    //
                    // check if we are inside the ILS cone
                    bool insideHorizontalBeam = NavUtils.InsideCone(bearingToRunway, landingRunway.To, landingRunway.ILSCone);
                    bool insideVerticalBeam   = NavUtils.InsideCone(verticalGlideslopeDeviation, 0.0, landingRunway.ILSCone);
                    InBeam = insideHorizontalBeam && insideVerticalBeam && distanceToRunway <= landingRunway.ILSRange;
                }
                else
                {
                    bearingToRunway  = 0.0;
                    distanceToRunway = double.MaxValue;
                    InBeam           = false;
                    horizontalGlideslopeDeviation = double.MaxValue;
                    verticalGlideslopeDeviation   = double.MaxValue;
                }
            }
Exemplo n.º 2
0
            protected override void AjustValues()
            {
                base.AjustValues();
                Vessel vessel = FlightGlobals.ActiveVessel;

                if (NavGlobals.InBeam || IsOff() || NavGlobals.destinationAirfield == null)
                {
                    InLimits();
                }
                else
                {
                    NotInLimits();
                }

                if (IsOn() && vessel != null)
                {
                    if (NavGlobals.landingRunway != null)
                    {
                        // we have a runway
                        //
                        if (IsInLimits())
                        {
                            // on glide slope
                            yellowNeedle.degrees = (float)(-NavGlobals.verticalGlideslopeDeviation * 50.0);
                        }
                        else
                        {
                            // not on glide slope
                            yellowNeedle.degrees = -200.0f;
                        }
                        //
                        // DME
                        double d = NavUtils.DistanceToRunway(vessel, NavGlobals.landingRunway);
                        SetDme(d);
                    }
                    else
                    {
                        // no runway
                        //
                        DmeDisplay.SetValue(99);
                        yellowNeedle.degrees = -200.0f;
                    }
                }
                else
                {
                    // gaue is off or no vessel
                    DmeDisplay.SetValue(99);
                    yellowNeedle.degrees = -200.0f;
                }
            }