From f58dcbbf6153153477d1d3f68d10396531817bca Mon Sep 17 00:00:00 2001 From: "sushi.at" Date: Thu, 14 Dec 2023 16:10:50 +0000 Subject: [PATCH 1/5] Added gsx pushback detection --- .../Structs/SecondaryTracking.cs | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/OpenSky.Agent.SimConnectMSFS/Structs/SecondaryTracking.cs b/OpenSky.Agent.SimConnectMSFS/Structs/SecondaryTracking.cs index 50b5aab..8fed785 100644 --- a/OpenSky.Agent.SimConnectMSFS/Structs/SecondaryTracking.cs +++ b/OpenSky.Agent.SimConnectMSFS/Structs/SecondaryTracking.cs @@ -190,7 +190,7 @@ public struct SecondaryTracking /// ------------------------------------------------------------------------------------------------- /// - /// Is the auto pilot engaged? + /// Is the auto-pilot engaged? /// /// ------------------------------------------------------------------------------------------------- public bool AutoPilot { get; set; } @@ -222,6 +222,14 @@ public struct SecondaryTracking /// /// ------------------------------------------------------------------------------------------------- public bool NoSmokingSign { get; set; } + + /// ------------------------------------------------------------------------------------------------- + /// + /// Gets or sets a value indicating whether the aircraft has "latitude longitude freeze" on, GSX + /// sets this during pushback. + /// + /// ------------------------------------------------------------------------------------------------- + public bool IsLatitudeLongitudeFreezeOn { get; set; } } /// ------------------------------------------------------------------------------------------------- @@ -250,6 +258,13 @@ public static class SecondaryTrackingConverter /// ------------------------------------------------------------------------------------------------- public static Simulator.Models.SecondaryTracking Convert(this SecondaryTracking secondary) { + // Detect GSX pushback + var pushBack = secondary.Pushback; + if (pushBack == Pushback.NoPushback && secondary.IsLatitudeLongitudeFreezeOn) + { + pushBack = Pushback.Straight; + } + return new Simulator.Models.SecondaryTracking { UtcTime = secondary.UtcTime, @@ -264,7 +279,7 @@ public static Simulator.Models.SecondaryTracking Convert(this SecondaryTracking EngineCombustion2 = secondary.EngineCombustion2, EngineCombustion3 = secondary.EngineCombustion3, EngineCombustion4 = secondary.EngineCombustion4, - Pushback = secondary.Pushback, + Pushback = pushBack, ApuRunning = secondary.ApuRunning, LightBeacon = secondary.LightBeacon, LightNav = secondary.LightNav, @@ -329,7 +344,8 @@ public static class SecondaryTrackingDefinition new SimVar("BRAKE PARKING INDICATOR", "Bool", SIMCONNECT_DATATYPE.INT32), new SimVar("SPOILERS ARMED", "Bool", SIMCONNECT_DATATYPE.INT32), new SimVar("CABIN SEATBELTS ALERT SWITCH", "Bool", SIMCONNECT_DATATYPE.INT32), - new SimVar("CABIN NO SMOKING ALERT SWITCH", "Bool", SIMCONNECT_DATATYPE.INT32) + new SimVar("CABIN NO SMOKING ALERT SWITCH", "Bool", SIMCONNECT_DATATYPE.INT32), + new SimVar("IS LATITUDE LONGITUDE FREEZE ON", "Bool", SIMCONNECT_DATATYPE.INT32) }; } } \ No newline at end of file From 783abdf44a04f8e1672c1322fb4c104ea824e4e8 Mon Sep 17 00:00:00 2001 From: "sushi.at" Date: Thu, 14 Dec 2023 16:54:03 +0000 Subject: [PATCH 2/5] Fix for complete flight button shown to early Added change log --- OpenSky.Agent.Simulator/Simulator.Flight.cs | 2 ++ OpenSky.Agent.Simulator/Simulator.Process.FlightPhases.cs | 1 + OpenSky.Agent.Simulator/Simulator.Process.Systems.cs | 5 ++--- changelog.txt | 6 ++++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/OpenSky.Agent.Simulator/Simulator.Flight.cs b/OpenSky.Agent.Simulator/Simulator.Flight.cs index e3d4d73..8686db1 100644 --- a/OpenSky.Agent.Simulator/Simulator.Flight.cs +++ b/OpenSky.Agent.Simulator/Simulator.Flight.cs @@ -230,6 +230,7 @@ public Flight Flight this.flight = value; this.OnPropertyChanged(); + this.OnPropertyChanged(nameof(this.CanFinishTracking)); this.FlightChanged?.Invoke(this, value); if (value != null) @@ -444,6 +445,7 @@ protected set this.trackingStatus = value; this.OnPropertyChanged(); + this.OnPropertyChanged(nameof(this.CanFinishTracking)); this.TrackingStatusChanged?.Invoke(this, value); // Reduce the loading and fuel sample rates while preparing to make it easier for the user to adjust them for manual aircraft diff --git a/OpenSky.Agent.Simulator/Simulator.Process.FlightPhases.cs b/OpenSky.Agent.Simulator/Simulator.Process.FlightPhases.cs index eadb390..1d0de7d 100644 --- a/OpenSky.Agent.Simulator/Simulator.Process.FlightPhases.cs +++ b/OpenSky.Agent.Simulator/Simulator.Process.FlightPhases.cs @@ -156,6 +156,7 @@ private set this.wasAirborne = value; this.OnPropertyChanged(); + this.OnPropertyChanged(nameof(this.CanFinishTracking)); } } diff --git a/OpenSky.Agent.Simulator/Simulator.Process.Systems.cs b/OpenSky.Agent.Simulator/Simulator.Process.Systems.cs index 887184d..7aaedfb 100644 --- a/OpenSky.Agent.Simulator/Simulator.Process.Systems.cs +++ b/OpenSky.Agent.Simulator/Simulator.Process.Systems.cs @@ -7,7 +7,6 @@ namespace OpenSky.Agent.Simulator { using System; - using System.ComponentModel; using System.Diagnostics; using System.Media; using System.Reflection; @@ -151,6 +150,8 @@ private void MonitorSecondarySystems(ProcessSecondaryTracking pst) // Was the engine turned off/on? if (pst.Old.EngineRunning != pst.New.EngineRunning) { + this.OnPropertyChanged(nameof(this.CanFinishTracking)); + if ((DateTime.UtcNow - this.lastEngineRunningChange).TotalSeconds > 5) { this.lastEngineRunningChange = DateTime.UtcNow; @@ -198,8 +199,6 @@ private void MonitorSecondarySystems(ProcessSecondaryTracking pst) // Was the engine turned off on the ground, not moving, while tracking? -> Report that we can now finish up tracking if (!pst.New.EngineRunning && this.PrimaryTracking.OnGround && this.PrimaryTracking.GroundSpeed < 1 && this.TrackingStatus == TrackingStatus.Tracking && this.WasAirborne) { - this.PropertyChanged(this, new PropertyChangedEventArgs(nameof(this.CanFinishTracking))); - // Show landing report notification now? this.LandingReported?.Invoke(this, LandingReportNotification.AfterTurningEnginesOff); } diff --git a/changelog.txt b/changelog.txt index f4e1283..bb9f149 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,12 @@ OpenSky Flight Tracking Agent Changelog ====================================================================================== +-------------------------------------------------------------------------------------- +Version 0.5.10 (ALPHA5) +-------------------------------------------------------------------------------------- +- Added support for GSX pushback +- Fixed "Complete Flight" button shown when it shouldn't + -------------------------------------------------------------------------------------- Version 0.5.9 (ALPHA5) -------------------------------------------------------------------------------------- From 7e9fa5f407f7ea3b78badf379c46ac4267e5dad0 Mon Sep 17 00:00:00 2001 From: "sushi.at" Date: Thu, 14 Dec 2023 22:12:24 +0000 Subject: [PATCH 3/5] Improved vatsim flight tracking Now supports VFR flights without flight plan Improved handling of tracking start questions, code cleaned, 15 sec timeout added --- OpenSky.Agent.Simulator/OpenAPIs/swagger.cs | 32 +++++- OpenSky.Agent.Simulator/OpenAPIs/swagger.json | 42 +++++++- OpenSky.Agent.Simulator/Simulator.Flight.cs | 11 ++- .../Simulator.Process.Systems.cs | 2 +- OpenSky.Agent.Simulator/Simulator.Vatsim.cs | 44 +++++++-- OpenSky.Agent.Simulator/Simulator.cs | 2 +- .../Views/Models/FlightTrackingViewModel.cs | 98 ++++++++++++++----- changelog.txt | 2 + 8 files changed, 187 insertions(+), 46 deletions(-) diff --git a/OpenSky.Agent.Simulator/OpenAPIs/swagger.cs b/OpenSky.Agent.Simulator/OpenAPIs/swagger.cs index 7d158e9..25ca80b 100644 --- a/OpenSky.Agent.Simulator/OpenAPIs/swagger.cs +++ b/OpenSky.Agent.Simulator/OpenAPIs/swagger.cs @@ -8941,7 +8941,7 @@ public partial class Aircraft /// [Newtonsoft.Json.JsonProperty("registry", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] - [System.ComponentModel.DataAnnotations.StringLength(12, MinimumLength = 7)] + [System.ComponentModel.DataAnnotations.StringLength(12, MinimumLength = 6)] public string Registry { get; set; } /// @@ -11200,7 +11200,7 @@ public partial class FinancialRecord /// Gets or sets the aircraft registry (optional, if record relates to an aircraft). /// [Newtonsoft.Json.JsonProperty("aircraftRegistry", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - [System.ComponentModel.DataAnnotations.StringLength(10, MinimumLength = 5)] + [System.ComponentModel.DataAnnotations.StringLength(12, MinimumLength = 6)] public string AircraftRegistry { get; set; } [Newtonsoft.Json.JsonProperty("category", Required = Newtonsoft.Json.Required.Always)] @@ -11322,6 +11322,9 @@ public partial class Flight [Newtonsoft.Json.JsonProperty("flightPhase", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public FlightPhase FlightPhase { get; set; } + [Newtonsoft.Json.JsonProperty("flightRule", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public FlightRule FlightRule { get; set; } + /// /// Gets or sets the fuel in gallons. /// @@ -11660,6 +11663,9 @@ public partial class FlightLog [Newtonsoft.Json.JsonProperty("atcCallsign", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string AtcCallsign { get; set; } + [Newtonsoft.Json.JsonProperty("category", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public AircraftTypeCategory Category { get; set; } + /// /// Gets or sets the Date/Time of when the flight was completed. /// @@ -12026,6 +12032,9 @@ public enum FlightPhase [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v11.0.0.0))")] public partial class FlightPlan { + [Newtonsoft.Json.JsonProperty("flightRule", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public FlightRule FlightRule { get; set; } + [Newtonsoft.Json.JsonProperty("aircraft", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public Aircraft Aircraft { get; set; } @@ -12185,6 +12194,23 @@ public partial class FlightPlanIEnumerableApiResponse } + /// + /// Flight rules. 0 = IFR, 1 = VFR, 2 = IFRtoVFR, 3 = VFRtoIFR + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v11.0.0.0))")] + public enum FlightRule + { + + IFR = 0, + + VFR = 1, + + IFRtoVFR = 2, + + VFRtoIFR = 3, + + } + /// /// Forgot password model. /// @@ -12710,7 +12736,7 @@ public partial class Payload /// Gets or sets the aircraft registry the payload is currently loaded on, or NULL if stored at an airport. /// [Newtonsoft.Json.JsonProperty("aircraftRegistry", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - [System.ComponentModel.DataAnnotations.StringLength(10, MinimumLength = 5)] + [System.ComponentModel.DataAnnotations.StringLength(12, MinimumLength = 6)] public string AircraftRegistry { get; set; } /// diff --git a/OpenSky.Agent.Simulator/OpenAPIs/swagger.json b/OpenSky.Agent.Simulator/OpenAPIs/swagger.json index f4883d2..ba29dc5 100644 --- a/OpenSky.Agent.Simulator/OpenAPIs/swagger.json +++ b/OpenSky.Agent.Simulator/OpenAPIs/swagger.json @@ -4333,7 +4333,7 @@ }, "registry": { "maxLength": 12, - "minLength": 7, + "minLength": 6, "type": "string", "description": "Gets or sets the aircraft registration." }, @@ -6729,8 +6729,8 @@ "type": "object", "properties": { "aircraftRegistry": { - "maxLength": 10, - "minLength": 5, + "maxLength": 12, + "minLength": 6, "type": "string", "description": "Gets or sets the aircraft registry (optional, if record relates to an aircraft).", "nullable": true @@ -6851,6 +6851,9 @@ "flightPhase": { "$ref": "#/components/schemas/FlightPhase" }, + "flightRule": { + "$ref": "#/components/schemas/FlightRule" + }, "fuelGallons": { "type": "number", "description": "Gets or sets the fuel in gallons.", @@ -7161,6 +7164,9 @@ "description": "Gets or sets the atc callsign.", "nullable": true }, + "category": { + "$ref": "#/components/schemas/AircraftTypeCategory" + }, "completed": { "type": "string", "description": "Gets or sets the Date/Time of when the flight was completed.", @@ -7501,6 +7507,9 @@ ], "type": "object", "properties": { + "flightRule": { + "$ref": "#/components/schemas/FlightRule" + }, "aircraft": { "$ref": "#/components/schemas/Aircraft" }, @@ -7649,6 +7658,29 @@ "additionalProperties": false, "description": "API standard response model." }, + "FlightRule": { + "enum": [ + 0, + 1, + 2, + 3 + ], + "type": "integer", + "description": "Flight rules. 0 = IFR, 1 = VFR, 2 = IFRtoVFR, 3 = VFRtoIFR", + "format": "int32", + "x-enumNames": [ + "IFR", + "VFR", + "IFRtoVFR", + "VFRtoIFR" + ], + "x-enum-varnames": [ + "IFR", + "VFR", + "IFRtoVFR", + "VFRtoIFR" + ] + }, "ForgotPassword": { "required": [ "email" @@ -8150,8 +8182,8 @@ "type": "object", "properties": { "aircraftRegistry": { - "maxLength": 10, - "minLength": 5, + "maxLength": 12, + "minLength": 6, "type": "string", "description": "Gets or sets the aircraft registry the payload is currently loaded on, or NULL if stored at an airport.", "nullable": true diff --git a/OpenSky.Agent.Simulator/Simulator.Flight.cs b/OpenSky.Agent.Simulator/Simulator.Flight.cs index 8686db1..16a13d3 100644 --- a/OpenSky.Agent.Simulator/Simulator.Flight.cs +++ b/OpenSky.Agent.Simulator/Simulator.Flight.cs @@ -302,7 +302,16 @@ public Flight Flight { this.TrackingConditions[(int)Models.TrackingConditions.Vatsim].Enabled = true; this.TrackingConditions[(int)Models.TrackingConditions.Vatsim].Current = "Unknown"; - this.TrackingConditions[(int)Models.TrackingConditions.Vatsim].Expected = $"True, Callsign: {value.AtcCallsign}, Flight plan: {value.Origin.Icao}-{value.Destination.Icao}, Location: <50 km"; + + // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression + if (value.FlightRule != FlightRule.VFR) + { + this.TrackingConditions[(int)Models.TrackingConditions.Vatsim].Expected = $"True, Callsign: {value.AtcCallsign}, Flight plan: {value.Origin.Icao}-{value.Destination.Icao}, Location: <50 km"; + } + else + { + this.TrackingConditions[(int)Models.TrackingConditions.Vatsim].Expected = $"True, Callsign: {value.AtcCallsign}, Location: <50 km"; + } } else { diff --git a/OpenSky.Agent.Simulator/Simulator.Process.Systems.cs b/OpenSky.Agent.Simulator/Simulator.Process.Systems.cs index 7aaedfb..3c536b7 100644 --- a/OpenSky.Agent.Simulator/Simulator.Process.Systems.cs +++ b/OpenSky.Agent.Simulator/Simulator.Process.Systems.cs @@ -193,7 +193,7 @@ private void MonitorSecondarySystems(ProcessSecondaryTracking pst) pst.New, FlightTrackingEventType.TaxiLandingLightsEngine, OpenSkyColors.OpenSkyRed, - $"OpenSky Warning: Taxi and/or Landing light on when engine was turned {(pst.New.EngineRunning ? "on" : "off")}"); + $"Taxi and/or Landing light on when engine was turned {(pst.New.EngineRunning ? "on" : "off")}"); } // Was the engine turned off on the ground, not moving, while tracking? -> Report that we can now finish up tracking diff --git a/OpenSky.Agent.Simulator/Simulator.Vatsim.cs b/OpenSky.Agent.Simulator/Simulator.Vatsim.cs index d943833..d503b47 100644 --- a/OpenSky.Agent.Simulator/Simulator.Vatsim.cs +++ b/OpenSky.Agent.Simulator/Simulator.Vatsim.cs @@ -117,9 +117,6 @@ private void MonitorVatsimFlight() this.VatsimClientConnection.Departure = string.Empty; this.VatsimClientConnection.Arrival = string.Empty; } - - - this.OnlineNetworkConnectionStarted ??= DateTime.UtcNow; } } } @@ -154,13 +151,40 @@ private void MonitorVatsimFlight() // Update tracking condition var locationDiffKm = this.PrimaryTracking.GeoCoordinate.GetDistanceTo(new GeoCoordinate(this.VatsimClientConnection?.Latitude ?? 0, this.VatsimClientConnection?.Longitude ?? 0, 0.3048 * this.VatsimClientConnection?.Altitude ?? 0)) / 1000; - this.TrackingConditions[(int)Models.TrackingConditions.Vatsim].Current = $"{this.VatsimClientConnection != null}, Callsign: {this.VatsimClientConnection?.Callsign ?? "none"}, Flight plan: {this.VatsimClientConnection?.Departure ?? "??"}-{this.VatsimClientConnection?.Arrival ?? "??"}, Location: {locationDiffKm:N1} km"; - this.TrackingConditions[(int)Models.TrackingConditions.Vatsim].ConditionMet = - this.VatsimClientConnection != null && - locationDiffKm < 50 && - this.VatsimClientConnection.Callsign.Equals(this.Flight.AtcCallsign, StringComparison.InvariantCultureIgnoreCase) && - this.VatsimClientConnection.Departure.Equals(this.Flight.Origin.Icao, StringComparison.InvariantCultureIgnoreCase) && - this.VatsimClientConnection.Arrival.Equals(this.Flight.Destination.Icao, StringComparison.InvariantCultureIgnoreCase); + + if (this.Flight.FlightRule != FlightRule.VFR) + { + this.TrackingConditions[(int)Models.TrackingConditions.Vatsim].Current = $"{this.VatsimClientConnection != null}, Callsign: {this.VatsimClientConnection?.Callsign ?? "none"}, Flight plan: {this.VatsimClientConnection?.Departure ?? "??"}-{this.VatsimClientConnection?.Arrival ?? "??"}, Location: {locationDiffKm:N1} km"; + this.TrackingConditions[(int)Models.TrackingConditions.Vatsim].ConditionMet = + this.VatsimClientConnection != null && + locationDiffKm < 50 && + this.VatsimClientConnection.Callsign.Equals(this.Flight.AtcCallsign, StringComparison.InvariantCultureIgnoreCase) && + this.VatsimClientConnection.Departure.Equals(this.Flight.Origin.Icao, StringComparison.InvariantCultureIgnoreCase) && + this.VatsimClientConnection.Arrival.Equals(this.Flight.Destination.Icao, StringComparison.InvariantCultureIgnoreCase); + } + else + { + this.TrackingConditions[(int)Models.TrackingConditions.Vatsim].Current = $"{this.VatsimClientConnection != null}, Callsign: {this.VatsimClientConnection?.Callsign ?? "none"}, Location: {locationDiffKm:N1} km"; + this.TrackingConditions[(int)Models.TrackingConditions.Vatsim].ConditionMet = + this.VatsimClientConnection != null && + locationDiffKm < 50 && + this.VatsimClientConnection.Callsign.Equals(this.Flight.AtcCallsign, StringComparison.InvariantCultureIgnoreCase); + } + + + if (this.TrackingConditions[(int)Models.TrackingConditions.Vatsim].ConditionMet) + { + this.OnlineNetworkConnectionStarted ??= DateTime.UtcNow; + } + else + { + if (this.OnlineNetworkConnectionStarted.HasValue) + { + this.OnlineNetworkConnectionDuration += (DateTime.UtcNow - this.OnlineNetworkConnectionStarted.Value); + this.OnlineNetworkConnectionStarted = null; + } + } + SleepScheduler.SleepFor(TimeSpan.FromSeconds(this.VatsimClientConnection == null ? 15 : 60)); } diff --git a/OpenSky.Agent.Simulator/Simulator.cs b/OpenSky.Agent.Simulator/Simulator.cs index ae17403..f435427 100644 --- a/OpenSky.Agent.Simulator/Simulator.cs +++ b/OpenSky.Agent.Simulator/Simulator.cs @@ -139,7 +139,7 @@ protected Simulator(OpenSkyService openSkyServiceInstance) this.TrackingConditions = new Dictionary { - { (int)Models.TrackingConditions.DateTime, new TrackingCondition { AutoSet = true } }, + { (int)Models.TrackingConditions.DateTime, new TrackingCondition() }, { (int)Models.TrackingConditions.Fuel, new TrackingCondition { AutoSet = true } }, { (int)Models.TrackingConditions.Payload, new TrackingCondition { AutoSet = true } }, { (int)Models.TrackingConditions.PlaneModel, new TrackingCondition() }, diff --git a/OpenSky.Agent/Views/Models/FlightTrackingViewModel.cs b/OpenSky.Agent/Views/Models/FlightTrackingViewModel.cs index b6cace9..41c0eb2 100644 --- a/OpenSky.Agent/Views/Models/FlightTrackingViewModel.cs +++ b/OpenSky.Agent/Views/Models/FlightTrackingViewModel.cs @@ -1005,7 +1005,7 @@ private void StartTracking() if (this.Simulator.WeightAndBalance.FuelTotalQuantity < (this.Simulator.Flight.FuelGallons ?? 0) && ((this.Simulator.Flight.FuelGallons ?? 0) - this.Simulator.WeightAndBalance.FuelTotalQuantity) > 0.2) { Debug.WriteLine("Fuel below flight plan, double checking with user..."); - ExtendedMessageBoxResult? answer = null; + ExtendedMessageBoxResult? fuelAnswer = null; this.StartTrackingCommand.ReportProgress( () => { @@ -1015,15 +1015,23 @@ private void StartTracking() MessageBoxButton.YesNo, ExtendedMessageBoxImage.Warning); messageBox.SetWarningColorStyle(); - messageBox.Closed += (_, _) => { answer = messageBox.Result; }; + messageBox.Closed += (_, _) => { fuelAnswer = messageBox.Result; }; this.ViewReference.ShowMessageBox(messageBox); }); - while (answer == null && !SleepScheduler.IsShutdownInProgress) + var waited = 0; + while (fuelAnswer == null && !SleepScheduler.IsShutdownInProgress) { Thread.Sleep(500); + waited += 500; + + if (waited > 15000) + { + Debug.WriteLine("Start tracking message box timeout for FUEL"); + fuelAnswer = ExtendedMessageBoxResult.None; + } } - if (answer != ExtendedMessageBoxResult.Yes) + if (fuelAnswer != ExtendedMessageBoxResult.Yes) { this.StartTrackingCommand.ReportProgress(() => this.StartTrackingCommand.CanExecute = true); return; @@ -1080,7 +1088,7 @@ private void StartTracking() if (this.Simulator.WeightAndBalance.CgPercent < this.Simulator.WeightAndBalance.CgFwdLimit || this.Simulator.WeightAndBalance.CgPercent > this.Simulator.WeightAndBalance.CgAftLimit) { Debug.WriteLine("CG outside limits, double checking with user..."); - ExtendedMessageBoxResult? answer = null; + ExtendedMessageBoxResult? cgAnswer = null; this.StartTrackingCommand.ReportProgress( () => { @@ -1090,15 +1098,23 @@ private void StartTracking() MessageBoxButton.YesNo, ExtendedMessageBoxImage.Warning); messageBox.SetWarningColorStyle(); - messageBox.Closed += (_, _) => { answer = messageBox.Result; }; + messageBox.Closed += (_, _) => { cgAnswer = messageBox.Result; }; this.ViewReference.ShowMessageBox(messageBox); }); - while (answer == null && !SleepScheduler.IsShutdownInProgress) + var waited = 0; + while (cgAnswer == null && !SleepScheduler.IsShutdownInProgress) { Thread.Sleep(500); + waited += 500; + + if (waited > 15000) + { + Debug.WriteLine("Start tracking message box timeout for CG"); + cgAnswer = ExtendedMessageBoxResult.None; + } } - if (answer != ExtendedMessageBoxResult.Yes) + if (cgAnswer != ExtendedMessageBoxResult.Yes) { this.StartTrackingCommand.ReportProgress(() => this.StartTrackingCommand.CanExecute = true); return; @@ -1108,7 +1124,7 @@ private void StartTracking() if (Math.Abs(this.Simulator.WeightAndBalance.CgPercentLateral) > 0.01) { Debug.WriteLine("Lateral CG outside limits, double checking with user..."); - ExtendedMessageBoxResult? answer = null; + ExtendedMessageBoxResult? latCgAnswer = null; this.StartTrackingCommand.ReportProgress( () => { @@ -1118,15 +1134,23 @@ private void StartTracking() MessageBoxButton.YesNo, ExtendedMessageBoxImage.Warning); messageBox.SetWarningColorStyle(); - messageBox.Closed += (_, _) => { answer = messageBox.Result; }; + messageBox.Closed += (_, _) => { latCgAnswer = messageBox.Result; }; this.ViewReference.ShowMessageBox(messageBox); }); - while (answer == null && !SleepScheduler.IsShutdownInProgress) + var waited = 0; + while (latCgAnswer == null && !SleepScheduler.IsShutdownInProgress) { Thread.Sleep(500); + waited += 500; + + if (waited > 15000) + { + Debug.WriteLine("Start tracking message box timeout for LAT CG"); + latCgAnswer = ExtendedMessageBoxResult.None; + } } - if (answer != ExtendedMessageBoxResult.Yes) + if (latCgAnswer != ExtendedMessageBoxResult.Yes) { this.StartTrackingCommand.ReportProgress(() => this.StartTrackingCommand.CanExecute = true); return; @@ -1136,7 +1160,7 @@ private void StartTracking() if (this.Simulator.WeightAndBalance.PayloadWeight > this.Simulator.WeightAndBalance.MaxPayloadWeight) { Debug.WriteLine("Payload weight outside limits, double checking with user..."); - ExtendedMessageBoxResult? answer = null; + ExtendedMessageBoxResult? payloadAnswer = null; this.StartTrackingCommand.ReportProgress( () => { @@ -1146,15 +1170,23 @@ private void StartTracking() MessageBoxButton.YesNo, ExtendedMessageBoxImage.Warning); messageBox.SetWarningColorStyle(); - messageBox.Closed += (_, _) => { answer = messageBox.Result; }; + messageBox.Closed += (_, _) => { payloadAnswer = messageBox.Result; }; this.ViewReference.ShowMessageBox(messageBox); }); - while (answer == null && !SleepScheduler.IsShutdownInProgress) + var waited = 0; + while (payloadAnswer == null && !SleepScheduler.IsShutdownInProgress) { Thread.Sleep(500); + waited += 500; + + if (waited > 15000) + { + Debug.WriteLine("Start tracking message box timeout for PAYLOAD"); + payloadAnswer = ExtendedMessageBoxResult.None; + } } - if (answer != ExtendedMessageBoxResult.Yes) + if (payloadAnswer != ExtendedMessageBoxResult.Yes) { this.StartTrackingCommand.ReportProgress(() => this.StartTrackingCommand.CanExecute = true); return; @@ -1164,7 +1196,7 @@ private void StartTracking() if (this.Simulator.WeightAndBalance.TotalWeight > this.Simulator.WeightAndBalance.MaxGrossWeight) { Debug.WriteLine("Total weight outside limits, double checking with user..."); - ExtendedMessageBoxResult? answer = null; + ExtendedMessageBoxResult? totalWeightAnswer = null; this.StartTrackingCommand.ReportProgress( () => { @@ -1173,15 +1205,23 @@ private void StartTracking() "The total weight exceeds the limits specified for this aircraft, are you sure you want to continue?", MessageBoxButton.YesNo, ExtendedMessageBoxImage.Question); - messageBox.Closed += (_, _) => { answer = messageBox.Result; }; + messageBox.Closed += (_, _) => { totalWeightAnswer = messageBox.Result; }; this.ViewReference.ShowMessageBox(messageBox); }); - while (answer == null && !SleepScheduler.IsShutdownInProgress) + var waited = 0; + while (totalWeightAnswer == null && !SleepScheduler.IsShutdownInProgress) { Thread.Sleep(500); + waited += 500; + + if (waited > 15000) + { + Debug.WriteLine("Start tracking message box timeout for TOTAL WEIGHT"); + totalWeightAnswer = ExtendedMessageBoxResult.None; + } } - if (answer != ExtendedMessageBoxResult.Yes) + if (totalWeightAnswer != ExtendedMessageBoxResult.Yes) { this.StartTrackingCommand.ReportProgress(() => this.StartTrackingCommand.CanExecute = true); return; @@ -1191,7 +1231,7 @@ private void StartTracking() if (!this.Simulator.GroundHandlingComplete && this.Simulator.SecondaryTracking.EngineRunning) { Debug.WriteLine("Ground handling not complete, ask the user about skipping..."); - ExtendedMessageBoxResult? answer = null; + ExtendedMessageBoxResult? groundHandlingAnswer = null; this.StartTrackingCommand.ReportProgress( () => { @@ -1200,15 +1240,23 @@ private void StartTracking() "Ground handling not yet completed, do you want to skip it?", MessageBoxButton.YesNo, ExtendedMessageBoxImage.Question); - messageBox.Closed += (_, _) => { answer = messageBox.Result; }; + messageBox.Closed += (_, _) => { groundHandlingAnswer = messageBox.Result; }; this.ViewReference.ShowMessageBox(messageBox); }); - while (answer == null && !SleepScheduler.IsShutdownInProgress) + var waited = 0; + while (groundHandlingAnswer == null && !SleepScheduler.IsShutdownInProgress) { Thread.Sleep(500); + waited += 500; + + if (waited > 15000) + { + Debug.WriteLine("Start tracking message box timeout for GROUND HANDLING"); + groundHandlingAnswer = ExtendedMessageBoxResult.None; + } } - if (answer != ExtendedMessageBoxResult.Yes) + if (groundHandlingAnswer != ExtendedMessageBoxResult.Yes) { this.StartTrackingCommand.ReportProgress(() => this.StartTrackingCommand.CanExecute = true); return; @@ -1254,7 +1302,7 @@ private void StartTracking() // Set the plane registration this.Simulator.SetAircraftRegistry(this.Simulator.Flight?.Aircraft.Registry.RemoveSimPrefix()); - // Start five second countdown? + // Start five-second countdown? if (this.Simulator.PrimaryTracking.SlewActive) { Debug.WriteLine("Starting 5 second resume timer..."); diff --git a/changelog.txt b/changelog.txt index bb9f149..a72218c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -7,6 +7,8 @@ Version 0.5.10 (ALPHA5) -------------------------------------------------------------------------------------- - Added support for GSX pushback - Fixed "Complete Flight" button shown when it shouldn't +- Improved vatsim flight tracking, now supports VFR flights without flight plan +- Improved handling of tracking start questions, code cleaned, 15 sec timeout added -------------------------------------------------------------------------------------- Version 0.5.9 (ALPHA5) From ad4e0f9b324cfa2a9def93c8e68d573286c7f604 Mon Sep 17 00:00:00 2001 From: "sushi.at" Date: Thu, 14 Dec 2023 23:32:52 +0000 Subject: [PATCH 4/5] api update --- OpenSky.Agent.Simulator/OpenAPIs/swagger.cs | 6 +----- OpenSky.Agent.Simulator/OpenAPIs/swagger.json | 14 ++++---------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/OpenSky.Agent.Simulator/OpenAPIs/swagger.cs b/OpenSky.Agent.Simulator/OpenAPIs/swagger.cs index 25ca80b..ad448bb 100644 --- a/OpenSky.Agent.Simulator/OpenAPIs/swagger.cs +++ b/OpenSky.Agent.Simulator/OpenAPIs/swagger.cs @@ -12195,7 +12195,7 @@ public partial class FlightPlanIEnumerableApiResponse } /// - /// Flight rules. 0 = IFR, 1 = VFR, 2 = IFRtoVFR, 3 = VFRtoIFR + /// Flight rules. 0 = IFR, 1 = VFR /// [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v11.0.0.0))")] public enum FlightRule @@ -12205,10 +12205,6 @@ public enum FlightRule VFR = 1, - IFRtoVFR = 2, - - VFRtoIFR = 3, - } /// diff --git a/OpenSky.Agent.Simulator/OpenAPIs/swagger.json b/OpenSky.Agent.Simulator/OpenAPIs/swagger.json index ba29dc5..235b6c9 100644 --- a/OpenSky.Agent.Simulator/OpenAPIs/swagger.json +++ b/OpenSky.Agent.Simulator/OpenAPIs/swagger.json @@ -7661,24 +7661,18 @@ "FlightRule": { "enum": [ 0, - 1, - 2, - 3 + 1 ], "type": "integer", - "description": "Flight rules. 0 = IFR, 1 = VFR, 2 = IFRtoVFR, 3 = VFRtoIFR", + "description": "Flight rules. 0 = IFR, 1 = VFR", "format": "int32", "x-enumNames": [ "IFR", - "VFR", - "IFRtoVFR", - "VFRtoIFR" + "VFR" ], "x-enum-varnames": [ "IFR", - "VFR", - "IFRtoVFR", - "VFRtoIFR" + "VFR" ] }, "ForgotPassword": { From 7e4259603645a12ffa5c55721be332727ee180c4 Mon Sep 17 00:00:00 2001 From: "sushi.at" Date: Thu, 14 Dec 2023 23:33:37 +0000 Subject: [PATCH 5/5] Bumped version --- OpenSky.Agent.SimConnectMSFS/Properties/AssemblyInfo.cs | 4 ++-- OpenSky.Agent.Simulator/Properties/AssemblyInfo.cs | 4 ++-- OpenSky.Agent.UdpXPlane11/Properties/AssemblyInfo.cs | 4 ++-- OpenSky.Agent/Properties/AssemblyInfo.cs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/OpenSky.Agent.SimConnectMSFS/Properties/AssemblyInfo.cs b/OpenSky.Agent.SimConnectMSFS/Properties/AssemblyInfo.cs index e174d8d..77e9a3c 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.5.9")] -[assembly: AssemblyFileVersion("0.5.9")] +[assembly: AssemblyVersion("0.5.10")] +[assembly: AssemblyFileVersion("0.5.10")] diff --git a/OpenSky.Agent.Simulator/Properties/AssemblyInfo.cs b/OpenSky.Agent.Simulator/Properties/AssemblyInfo.cs index ae20885..da1b1cd 100644 --- a/OpenSky.Agent.Simulator/Properties/AssemblyInfo.cs +++ b/OpenSky.Agent.Simulator/Properties/AssemblyInfo.cs @@ -18,6 +18,6 @@ [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: Guid("30c467e8-2eee-41e5-be01-0142a61ba171")] -[assembly: AssemblyVersion("0.5.9")] -[assembly: AssemblyFileVersion("0.5.9")] +[assembly: AssemblyVersion("0.5.10")] +[assembly: AssemblyFileVersion("0.5.10")] [assembly: InternalsVisibleTo("OpenSky.Agent")] diff --git a/OpenSky.Agent.UdpXPlane11/Properties/AssemblyInfo.cs b/OpenSky.Agent.UdpXPlane11/Properties/AssemblyInfo.cs index 9238ad5..5b54ffe 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.5.9")] -[assembly: AssemblyFileVersion("0.5.9")] +[assembly: AssemblyVersion("0.5.10")] +[assembly: AssemblyFileVersion("0.5.10")] diff --git a/OpenSky.Agent/Properties/AssemblyInfo.cs b/OpenSky.Agent/Properties/AssemblyInfo.cs index 2612f64..2e37f1b 100644 --- a/OpenSky.Agent/Properties/AssemblyInfo.cs +++ b/OpenSky.Agent/Properties/AssemblyInfo.cs @@ -21,8 +21,8 @@ [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] -[assembly: AssemblyVersion("0.5.9")] -[assembly: AssemblyFileVersion("0.5.9")] +[assembly: AssemblyVersion("0.5.10")] +[assembly: AssemblyFileVersion("0.5.10")] // This allows us to detect debug mode in XAML #if DEBUG