예제 #1
0
        private void updateLandingRoll(APIAircraftState state)
        {
            if (_pLastState == null)
            {
                _pLastState = state;
            }
            else if (!state.IsOnGround)
            {
                _pLastState                    = state;
                _pLastLandingRoll              = 0.0;
                _pLandingLocation              = null;
                _txtLandingRoll.IsVisible      = false;
                _txtLandingRollLabel.IsVisible = false;
                //btnViewLandingStats.Visibility = Visibility.Hidden;
            }
            else if (!_pLastState.IsLanded && state.IsLanded
                     ) //Just transitioned to "landed" state, so start the roll accumulation
            {
                _pLandingLocation          = state.Location;
                _pStateJustBeforeTouchdown = _pLastState;
                _pStateJustAfterTouchdown  = state;
                _pLastState = state;
            }
            else if (state.IsLanded && _pLandingLocation != null) //We are in landed state. Calc the roll length.
            {
                var currentPosition = state.Location;
                var R    = 3959; // Radius of the earth in miles
                var dLat = (currentPosition.Latitude - _pLandingLocation.Latitude) * (Math.PI / 180);
                var dLon = (currentPosition.Longitude - _pLandingLocation.Longitude) * (Math.PI / 180);
                var a    =
                    Math.Sin(dLat / 2) * Math.Sin(dLat / 2) +
                    Math.Cos(currentPosition.Latitude * (Math.PI / 180)) *
                    Math.Cos(_pLandingLocation.Latitude * (Math.PI / 180)) *
                    Math.Sin(dLon / 2) * Math.Sin(dLon / 2)
                ;
                var c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
                var d = R * c; // Distance in miles
                d *= 5280;     //Distance in ft
                _txtLandingRoll.Text           = string.Format("{0:0.00}", d) + " ft";
                _txtLandingRoll.IsVisible      = true;
                _txtLandingRollLabel.IsVisible = true;
                _pLastState = state;
                _landingDetails.updateLandingStats(_pLandingLocation, _pAircraftState.Location,
                                                   _pStateJustBeforeTouchdown, _pStateJustAfterTouchdown, "");
            }

            if (_pLandingLocation != null && state.IsLanded && state.IsOnGround && state.GroundSpeedKts < 10)
            {
                _pLandingStatDlg = new LandingStats();
                _pLandingStatDlg.updateLandingStats(_pLandingLocation, _pAircraftState.Location,
                                                    _pStateJustBeforeTouchdown, _pStateJustAfterTouchdown, "");
                _landingDetails.updateLandingStats(_pLandingLocation, _pAircraftState.Location,
                                                   _pStateJustBeforeTouchdown, _pStateJustAfterTouchdown, "");
                //btnViewLandingStats.Visibility = Visibility.Visible;
            }
        }
예제 #2
0
 private void InitializeUiElements()
 {
     _airplaneStateGrid    = this.FindControl <Grid>("airplaneStateGrid");
     _overlayGrid          = this.FindControl <Grid>("overlayGrid");
     _atcMessagesDataGrid  = this.FindControl <DataGrid>("atcMessagesDataGrid");
     _ipLabel              = this.FindControl <TextBlock>("ipLabel");
     _txtLandingRoll       = this.FindControl <TextBlock>("txtLandingRoll");
     _txtLandingRollLabel  = this.FindControl <TextBlock>("txtLandingRollLabel");
     _mainTabControl       = this.FindControl <TabControl>("mainTabControl");
     _expander             = this.FindControl <Expander>("expander");
     _TabItem_ATC          = this.FindControl <TabItem>("TabItem_ATC");
     _landingDetails       = this.FindControl <LandingStats>("landingDetails");
     _FMSControl           = this.FindControl <FMS>("FMSControl");
     _AttitudeIndicator    = this.FindControl <AttitudeIndicator>("AttitudeIndicator");
     _AircraftStateControl = this.FindControl <AircraftStatus>("AircraftStateControl");
     _FpdControl           = this.FindControl <FlightPlanDb>("FpdControl");
 }