Exemple #1
0
        /// <summary>
        /// Repositions the FSX aircraft to match the location, speed and attitude of a real aircraft.
        /// </summary>
        private void MoveAircraft()
        {
            var selectedAircraft = _View.SelectedRealAircraft;

            if (_View.RidingAircraft && selectedAircraft != null)
            {
                long trash1, trash2;
                var  aircraft = BaseStationAircraftList.TakeSnapshot(out trash1, out trash2).Where(a => a.UniqueId == selectedAircraft.UniqueId).FirstOrDefault();
                if (aircraft != null)
                {
                    var speedLimit = (float)_MaximumAirspeed - 30f;

                    var writeAircraftInformation = new WriteAircraftInformation();
                    writeAircraftInformation.AirspeedIndicated = aircraft.GroundSpeed > speedLimit ? speedLimit : aircraft.GroundSpeed.GetValueOrDefault();
                    aircraft.GroundSpeed.GetValueOrDefault();
                    writeAircraftInformation.Altitude     = aircraft.Altitude.GetValueOrDefault();
                    writeAircraftInformation.Operator     = aircraft.Operator;
                    writeAircraftInformation.Registration = aircraft.Registration;
                    //writeAircraftInformation.Type = aircraft.Type;
                    //writeAircraftInformation.Model = aircraft.Model;
                    writeAircraftInformation.Latitude      = aircraft.Latitude.GetValueOrDefault();
                    writeAircraftInformation.Longitude     = aircraft.Longitude.GetValueOrDefault();
                    writeAircraftInformation.TrueHeading   = aircraft.Track.GetValueOrDefault();
                    writeAircraftInformation.VerticalSpeed = aircraft.VerticalRate.GetValueOrDefault();
                    writeAircraftInformation.Bank          = ApproximateBank(_MovedAircraft, aircraft);

                    _MovedAircraft = aircraft;

                    _FlightSimulatorX.MoveAircraft(writeAircraftInformation);
                }
            }
        }
Exemple #2
0
        private void BackgroundThread_UpdateRealAircraftDisplay()
        {
            if (_View.CanBeRefreshed)
            {
                long trash1, trash2;
                var  aircraftList = BaseStationAircraftList.TakeSnapshot(out trash1, out trash2);
                _View.UpdateRealAircraftListDisplay(aircraftList);

                Provider.TimedInvokeOnBackgroundThread(BackgroundThread_UpdateRealAircraftDisplay, 1000);
            }
        }
Exemple #3
0
        /// <summary>
        /// See interface docs.
        /// </summary>
        /// <param name="view"></param>
        public void Initialise(IFlightSimulatorXView view)
        {
            LoadConfiguration();

            if (BaseStationAircraftList == null)
            {
                throw new InvalidOperationException("The BaseStation aircraft list must be set before calling Initialise");
            }
            if (FlightSimulatorAircraftList == null)
            {
                throw new InvalidOperationException("The FSX aircraft list must be set before calling Initialise");
            }
            if (WebServer == null)
            {
                throw new InvalidOperationException("The web server must be set before calling Initialise");
            }

            _View = view;
            _View.CloseClicked   += View_CloseClicked;
            _View.ConnectClicked += View_ConnectClicked;
            _View.RefreshFlightSimulatorXInformation += View_RefreshFlightSimulatorXInformation;
            _View.RideAircraftClicked             += View_RideAircraftClicked;
            _View.StopRidingAircraftClicked       += View_StopRidingAircraftClicked;
            _View.ConnectionStatus                 = _FlightSimulatorX.IsInstalled ? Strings.Disconnected : Strings.FlightSimulatorXIsNotInstalled;
            _View.ConnectToFlightSimulatorXEnabled = _FlightSimulatorX.IsInstalled;
            _View.FlightSimulatorPageAddress       = String.Format("{0}/FlightSim.htm", WebServer.LocalAddress);
            _View.RideStatus          = "-";
            _View.RideAircraftEnabled = false;
            if (_FlightSimulatorX.IsInstalled)
            {
                _View.UseSlewMode = true;
            }

            _FlightSimulatorX.AircraftInformationReceived     += FlightSimulatorX_AircraftInformationReceived;
            _FlightSimulatorX.ConnectionStatusChanged         += FlightSimulatorX_ConnectionStatusChanged;
            _FlightSimulatorX.FlightSimulatorXExceptionRaised += FlightSimulatorX_FlightSimulatorXExceptionRaised;
            _FlightSimulatorX.SlewToggled += FlightSimulatorX_SlewToggled;

            long trash1, trash2;
            var  aircraftList = BaseStationAircraftList.TakeSnapshot(out trash1, out trash2);

            _View.InitialiseRealAircraftListDisplay(aircraftList);

            Provider.TimedInvokeOnBackgroundThread(BackgroundThread_UpdateRealAircraftDisplay, 1000);
        }