diff --git a/OpenSky.Agent.SimConnectMSFS/Properties/AssemblyInfo.cs b/OpenSky.Agent.SimConnectMSFS/Properties/AssemblyInfo.cs index 2fc881d..57463c6 100644 --- a/OpenSky.Agent.SimConnectMSFS/Properties/AssemblyInfo.cs +++ b/OpenSky.Agent.SimConnectMSFS/Properties/AssemblyInfo.cs @@ -17,5 +17,5 @@ [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("1f9cbede-669d-4510-bca2-e6ad29d6a498")] -[assembly: AssemblyVersion("0.4.5")] -[assembly: AssemblyFileVersion("0.4.5")] \ No newline at end of file +[assembly: AssemblyVersion("0.5.0")] +[assembly: AssemblyFileVersion("0.5.0")] \ No newline at end of file diff --git a/OpenSky.Agent.SimConnectMSFS/SimConnect.cs b/OpenSky.Agent.SimConnectMSFS/SimConnect.cs index a97d3a4..5885d97 100644 --- a/OpenSky.Agent.SimConnectMSFS/SimConnect.cs +++ b/OpenSky.Agent.SimConnectMSFS/SimConnect.cs @@ -633,10 +633,10 @@ private void ReadFromSimconnect() foreach (Requests request in Enum.GetValues(typeof(Requests))) { - if (this.SampleRates.ContainsKey(request)) + if (this.SampleRates.TryGetValue(request, out var rate)) { var lastTime = this.LastReceivedTimes[request]; - if (request != Requests.Primary && (!lastTime.HasValue || (DateTime.UtcNow - lastTime.Value).TotalMilliseconds > this.SampleRates[request])) + if (request != Requests.Primary && (!lastTime.HasValue || (DateTime.UtcNow - lastTime.Value).TotalMilliseconds > rate)) { this.fsConnect.RequestData(request, request); } diff --git a/OpenSky.Agent.Simulator/OpenAPIs/ModelExtensions/AircraftType.cs b/OpenSky.Agent.Simulator/OpenAPIs/ModelExtensions/AircraftType.cs index 00600cd..f1510b1 100644 --- a/OpenSky.Agent.Simulator/OpenAPIs/ModelExtensions/AircraftType.cs +++ b/OpenSky.Agent.Simulator/OpenAPIs/ModelExtensions/AircraftType.cs @@ -217,17 +217,17 @@ public bool MatchesAircraftInSimulator() // Skip these checks if detailed checks are TEMPORARILY disabled if (!this.DetailedChecksDisabled) { - if (Math.Abs(OpenSky.Agent.Simulator.Simulator.Instance.WeightAndBalance.EmptyWeight - this.EmptyWeight) > 0.5) + if (Math.Abs(OpenSky.Agent.Simulator.Simulator.Instance.WeightAndBalance.EmptyWeight - this.EmptyWeight) > 0.05 * this.EmptyWeight) { return false; } - if (Math.Abs(OpenSky.Agent.Simulator.Simulator.Instance.WeightAndBalance.FuelTotalCapacity - this.FuelTotalCapacity) > 0.5) + if (Math.Abs(OpenSky.Agent.Simulator.Simulator.Instance.WeightAndBalance.FuelTotalCapacity - this.FuelTotalCapacity) > 0.05 * this.FuelTotalCapacity) { return false; } - if (Math.Abs(OpenSky.Agent.Simulator.Simulator.Instance.WeightAndBalance.MaxGrossWeight - this.MaxGrossWeight) > 0.5) + if (Math.Abs(OpenSky.Agent.Simulator.Simulator.Instance.WeightAndBalance.MaxGrossWeight - this.MaxGrossWeight) > 0.05 * this.MaxGrossWeight) { return false; } diff --git a/OpenSky.Agent.Simulator/Properties/AssemblyInfo.cs b/OpenSky.Agent.Simulator/Properties/AssemblyInfo.cs index d347c4c..0c0dc14 100644 --- a/OpenSky.Agent.Simulator/Properties/AssemblyInfo.cs +++ b/OpenSky.Agent.Simulator/Properties/AssemblyInfo.cs @@ -17,5 +17,5 @@ [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("30c467e8-2eee-41e5-be01-0142a61ba171")] -[assembly: AssemblyVersion("0.4.5")] -[assembly: AssemblyFileVersion("0.4.5")] \ No newline at end of file +[assembly: AssemblyVersion("0.5.0")] +[assembly: AssemblyFileVersion("0.5.0")] \ No newline at end of file diff --git a/OpenSky.Agent.Simulator/Simulator.Flight.cs b/OpenSky.Agent.Simulator/Simulator.Flight.cs index 5885ad9..1befc4b 100644 --- a/OpenSky.Agent.Simulator/Simulator.Flight.cs +++ b/OpenSky.Agent.Simulator/Simulator.Flight.cs @@ -197,7 +197,7 @@ public Flight Flight return; } - Debug.WriteLine("SimConnect flight changing..."); + Debug.WriteLine("Simulator flight changing..."); if (value != null && this.TrackingStatus != TrackingStatus.NotTracking) { Debug.WriteLine("Throwing error: You need to abort the current flight before changing to a new one!"); @@ -211,7 +211,7 @@ public Flight Flight if (value != null) { // Start the ground handling thread for this flight - new Thread(this.DoGroundHandling) { Name = "OpenSky.SimConnect.GroundHandling" }.Start(); + new Thread(this.DoGroundHandling) { Name = "OpenSky.Simulator.GroundHandling" }.Start(); // Add airport markers to map (do this in both new and restore, save file doesn't contain these cause the data would just be redundant) UpdateGUIDelegate addAirports = () => diff --git a/OpenSky.Agent.Simulator/Simulator.Process.FlightPhases.cs b/OpenSky.Agent.Simulator/Simulator.Process.FlightPhases.cs index c01ba76..72af551 100644 --- a/OpenSky.Agent.Simulator/Simulator.Process.FlightPhases.cs +++ b/OpenSky.Agent.Simulator/Simulator.Process.FlightPhases.cs @@ -271,7 +271,8 @@ private void TransitionFlightPhase() } // Departure - if (distanceToDepartureAirport < 10 && this.VerticalProfile == VerticalProfile.Climbing && !this.PrimaryTracking.OnGround) + var approachDepartureDistance = this.AircraftIdentity.EngineType is EngineType.Jet or EngineType.Turboprop ? 40 : 10; + if (distanceToDepartureAirport < approachDepartureDistance && this.VerticalProfile == VerticalProfile.Climbing && !this.PrimaryTracking.OnGround) { if (unknownFlightPhase) { @@ -286,8 +287,7 @@ private void TransitionFlightPhase() } // Climb - var approachDistance = this.AircraftIdentity.EngineType is EngineType.Jet or EngineType.Turboprop ? 40 : 10; - if (distanceToDepartureAirport >= approachDistance && this.VerticalProfile == VerticalProfile.Climbing && !this.PrimaryTracking.OnGround) + if (distanceToDepartureAirport >= approachDepartureDistance && this.VerticalProfile == VerticalProfile.Climbing && !this.PrimaryTracking.OnGround) { if (unknownFlightPhase) { @@ -302,7 +302,7 @@ private void TransitionFlightPhase() } // Cruise - if (distanceToDestinationAirport >= approachDistance && distanceToAlternateAirport >= approachDistance && this.VerticalProfile == VerticalProfile.Level && !this.PrimaryTracking.OnGround) + if (distanceToDestinationAirport >= approachDepartureDistance && distanceToAlternateAirport >= approachDepartureDistance && this.VerticalProfile == VerticalProfile.Level && !this.PrimaryTracking.OnGround) { if (unknownFlightPhase) { @@ -317,7 +317,7 @@ private void TransitionFlightPhase() } // Descent - if (distanceToDestinationAirport >= approachDistance && distanceToAlternateAirport >= approachDistance && this.VerticalProfile == VerticalProfile.Descending && !this.PrimaryTracking.OnGround) + if (distanceToDestinationAirport >= approachDepartureDistance && distanceToAlternateAirport >= approachDepartureDistance && this.VerticalProfile == VerticalProfile.Descending && !this.PrimaryTracking.OnGround) { if (unknownFlightPhase) { @@ -332,7 +332,7 @@ private void TransitionFlightPhase() } // Approach - if ((distanceToDestinationAirport < approachDistance || distanceToAlternateAirport < approachDistance) && !this.PrimaryTracking.OnGround && this.PrimaryTracking.RadioHeight > 500) + if ((distanceToDestinationAirport < approachDepartureDistance || distanceToAlternateAirport < approachDepartureDistance) && !this.PrimaryTracking.OnGround && this.PrimaryTracking.RadioHeight > 500) { if (unknownFlightPhase) { diff --git a/OpenSky.Agent.Simulator/Simulator.Process.cs b/OpenSky.Agent.Simulator/Simulator.Process.cs index 0f472d7..f58c156 100644 --- a/OpenSky.Agent.Simulator/Simulator.Process.cs +++ b/OpenSky.Agent.Simulator/Simulator.Process.cs @@ -337,6 +337,8 @@ private void ProcessLandingAnalysis() } } + private DateTime lastLocationUpdate=DateTime.MinValue; + /// ------------------------------------------------------------------------------------------------- /// /// Process the primary tracking data (old vs new). @@ -362,8 +364,9 @@ private void ProcessPrimaryTracking() this.TrackFlight(ppt); // Fire the location changed event? - if (!ppt.Old.MapLocation.Equals(ppt.New.MapLocation)) + if (!ppt.Old.MapLocation.Equals(ppt.New.MapLocation) || (DateTime.Now-this.lastLocationUpdate).TotalSeconds>5) { + this.lastLocationUpdate = DateTime.Now; newLocation = ppt.New.MapLocation; } diff --git a/OpenSky.Agent.Simulator/Simulator.simBrief.cs b/OpenSky.Agent.Simulator/Simulator.simBrief.cs index 9ceb7fb..8ff975c 100644 --- a/OpenSky.Agent.Simulator/Simulator.simBrief.cs +++ b/OpenSky.Agent.Simulator/Simulator.simBrief.cs @@ -39,6 +39,13 @@ public partial class Simulator /// ------------------------------------------------------------------------------------------------- private bool simbriefOfpLoaded; + /// ------------------------------------------------------------------------------------------------- + /// + /// Occurs when simbrief ofp loaded property changed. + /// + /// ------------------------------------------------------------------------------------------------- + public event EventHandler SimbriefOfpLoadedChanged; + /// ------------------------------------------------------------------------------------------------- /// /// Occurs when SimConnect adds a new simbrief waypoint marker. @@ -64,6 +71,7 @@ private set this.simbriefOfpLoaded = value; this.OnPropertyChanged(); + this.SimbriefOfpLoadedChanged?.Invoke(this, value); } } diff --git a/OpenSky.Agent.UdpXPlane11/Properties/AssemblyInfo.cs b/OpenSky.Agent.UdpXPlane11/Properties/AssemblyInfo.cs index fdb3420..1772465 100644 --- a/OpenSky.Agent.UdpXPlane11/Properties/AssemblyInfo.cs +++ b/OpenSky.Agent.UdpXPlane11/Properties/AssemblyInfo.cs @@ -17,5 +17,5 @@ [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("dfbda2b8-5775-4766-be86-d729fcf20de1")] -[assembly: AssemblyVersion("0.4.5")] -[assembly: AssemblyFileVersion("0.4.5")] \ No newline at end of file +[assembly: AssemblyVersion("0.5.0")] +[assembly: AssemblyFileVersion("0.5.0")] \ No newline at end of file diff --git a/OpenSky.Agent.UdpXPlane11/UdpXPlane11.cs b/OpenSky.Agent.UdpXPlane11/UdpXPlane11.cs index c2c13c4..b18dad7 100644 --- a/OpenSky.Agent.UdpXPlane11/UdpXPlane11.cs +++ b/OpenSky.Agent.UdpXPlane11/UdpXPlane11.cs @@ -446,10 +446,10 @@ private void ReadFromXPlane() } foreach (Requests request in Enum.GetValues(typeof(Requests))) { - if (this.SampleRates.ContainsKey(request)) + if (this.SampleRates.TryGetValue(request, out var rate)) { var lastTime = this.LastReceivedTimes[request]; - if (request != Requests.Primary && (!lastTime.HasValue || (DateTime.UtcNow - lastTime.Value).TotalMilliseconds > this.SampleRates[request])) + if (request != Requests.Primary && (!lastTime.HasValue || (DateTime.UtcNow - lastTime.Value).TotalMilliseconds > rate)) { if (request == Requests.Secondary) { diff --git a/OpenSky.Agent/App.xaml b/OpenSky.Agent/App.xaml index f65c113..81d5a91 100644 --- a/OpenSky.Agent/App.xaml +++ b/OpenSky.Agent/App.xaml @@ -1,7 +1,7 @@