From fef8a0217fac628459609611ae1645ec92d36c5e Mon Sep 17 00:00:00 2001 From: "sushi.at" Date: Sat, 23 Dec 2023 16:52:31 +0000 Subject: [PATCH] Auto reg disable added Added delays to start tracking dialogs --- OpenSky.Agent.Simulator/OpenAPIs/swagger.cs | 181 +++++++++++++++++- OpenSky.Agent.Simulator/OpenAPIs/swagger.json | 121 +++++++++++- OpenSky.Agent/Controls/OpenSkyWindow.cs | 4 +- .../Views/Models/FlightTrackingViewModel.cs | 24 ++- changelog.txt | 3 + 5 files changed, 328 insertions(+), 5 deletions(-) diff --git a/OpenSky.Agent.Simulator/OpenAPIs/swagger.cs b/OpenSky.Agent.Simulator/OpenAPIs/swagger.cs index b7f0331..0712ae3 100644 --- a/OpenSky.Agent.Simulator/OpenAPIs/swagger.cs +++ b/OpenSky.Agent.Simulator/OpenAPIs/swagger.cs @@ -7132,6 +7132,98 @@ public virtual async System.Threading.Tasks.Task + /// Get the flight trail for the specified flight on the world map. + /// + /// + /// sushi.at, 23/12/2023. + /// + /// Identifier for the flight. + /// Success + /// A server side error occurred. + public virtual System.Threading.Tasks.Task GetWorldMapFlightTrailAsync(System.Guid flightID) + { + return GetWorldMapFlightTrailAsync(flightID, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Get the flight trail for the specified flight on the world map. + /// + /// + /// sushi.at, 23/12/2023. + /// + /// Identifier for the flight. + /// Success + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task GetWorldMapFlightTrailAsync(System.Guid flightID, System.Threading.CancellationToken cancellationToken) + { + if (flightID == null) + throw new System.ArgumentNullException("flightID"); + + var urlBuilder_ = new System.Text.StringBuilder(); + urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/Flight/worldMap/trail/{flightID}"); + urlBuilder_.Replace("{flightID}", System.Uri.EscapeDataString(ConvertToString(flightID, System.Globalization.CultureInfo.InvariantCulture))); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = await CreateHttpRequestMessageAsync(cancellationToken).ConfigureAwait(false)) + { + request_.Method = new System.Net.Http.HttpMethod("GET"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain")); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value); + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + { + var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + /// /// Pause the flight with the specified ID, does not save position or save file - upload these ///
before calling pause if they should be preserved. @@ -9993,6 +10085,12 @@ public partial class AircraftType [Newtonsoft.Json.JsonProperty("detailedChecksDisabled", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public bool DetailedChecksDisabled { get; set; } + /// + /// Gets or sets a value indicating whether the automatic registry setting in the simulator is disabled. + /// + [Newtonsoft.Json.JsonProperty("disableAutoRegistry", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public bool DisableAutoRegistry { get; set; } + /// /// Gets or sets the empty weight in pounds. /// @@ -15018,7 +15116,7 @@ public partial class WorldMapFlight public double Altitude { get; set; } /// - /// Gets or sets the Destination for the. + /// Gets or sets the destination. /// [Newtonsoft.Json.JsonProperty("destination", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Destination { get; set; } @@ -15044,6 +15142,12 @@ public partial class WorldMapFlight [Newtonsoft.Json.JsonProperty("heading", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public double Heading { get; set; } + /// + /// Gets or sets the identifier of the flight. + /// + [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Guid Id { get; set; } + /// /// Gets or sets a value indicating whether this flight is paused. /// @@ -15126,6 +15230,81 @@ public partial class WorldMapFlightIEnumerableApiResponse } + /// + /// World map flight position report model (part of the trail) + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v11.0.0.0))")] + public partial class WorldMapFlightPositionReport + { + /// + /// Gets or sets the altitude. + /// + [Newtonsoft.Json.JsonProperty("altitude", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public double Altitude { get; set; } + + /// + /// Gets or sets the latitude. + /// + [Newtonsoft.Json.JsonProperty("latitude", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public double Latitude { get; set; } + + /// + /// Gets or sets the longitude. + /// + [Newtonsoft.Json.JsonProperty("longitude", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public double Longitude { get; set; } + + } + + /// + /// World map flight trail model. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v11.0.0.0))")] + public partial class WorldMapFlightTrail + { + /// + /// Gets or sets the position reports. + /// + [Newtonsoft.Json.JsonProperty("positionReports", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Collections.Generic.ICollection PositionReports { get; set; } + + } + + /// + /// API standard response model. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v11.0.0.0))")] + public partial class WorldMapFlightTrailApiResponse + { + [Newtonsoft.Json.JsonProperty("data", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public WorldMapFlightTrail Data { get; set; } + + /// + /// Gets or sets the error details (NULL if no error). + /// + [Newtonsoft.Json.JsonProperty("errorDetails", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string ErrorDetails { get; set; } + + /// + /// Gets or sets a value indicating whether this response is reporting an error. + /// + [Newtonsoft.Json.JsonProperty("isError", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public bool IsError { get; set; } + + /// + /// Gets or sets the message. + /// + [Newtonsoft.Json.JsonProperty("message", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Message { get; set; } + + /// + /// Gets or sets the status. + /// + [Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Status { get; set; } + + } + /// /// World statistics overview model. /// diff --git a/OpenSky.Agent.Simulator/OpenAPIs/swagger.json b/OpenSky.Agent.Simulator/OpenAPIs/swagger.json index 8f7a4f5..8cd0999 100644 --- a/OpenSky.Agent.Simulator/OpenAPIs/swagger.json +++ b/OpenSky.Agent.Simulator/OpenAPIs/swagger.json @@ -3344,6 +3344,50 @@ } } }, + "/Flight/worldMap/trail/{flightID}": { + "get": { + "tags": [ + "Flight" + ], + "summary": "Get the flight trail for the specified flight on the world map.", + "description": "sushi.at, 23/12/2023.", + "operationId": "GetWorldMapFlightTrail", + "parameters": [ + { + "name": "flightID", + "in": "path", + "description": "Identifier for the flight.", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "200": { + "description": "Success", + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/WorldMapFlightTrailApiResponse" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/WorldMapFlightTrailApiResponse" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/WorldMapFlightTrailApiResponse" + } + } + } + } + } + } + }, "/Flight/pause/{flightID}": { "post": { "tags": [ @@ -5005,6 +5049,10 @@ "type": "boolean", "description": "Gets or sets a value indicating whether the detailed checks are TEMPORARILY disabled - only\r\nuse this on patch days until a new version of the plane can be added." }, + "disableAutoRegistry": { + "type": "boolean", + "description": "Gets or sets a value indicating whether the automatic registry setting in the simulator is disabled." + }, "emptyWeight": { "type": "number", "description": "Gets or sets the empty weight in pounds.", @@ -9998,7 +10046,7 @@ }, "destination": { "type": "string", - "description": "Gets or sets the Destination for the.", + "description": "Gets or sets the destination.", "nullable": true }, "flightPhase": { @@ -10019,6 +10067,11 @@ "description": "The magnetic heading.", "format": "double" }, + "id": { + "type": "string", + "description": "Gets or sets the identifier of the flight.", + "format": "uuid" + }, "isPaused": { "type": "boolean", "description": "Gets or sets a value indicating whether this flight is paused." @@ -10090,6 +10143,72 @@ "additionalProperties": false, "description": "API standard response model." }, + "WorldMapFlightPositionReport": { + "type": "object", + "properties": { + "altitude": { + "type": "number", + "description": "Gets or sets the altitude.", + "format": "double" + }, + "latitude": { + "type": "number", + "description": "Gets or sets the latitude.", + "format": "double" + }, + "longitude": { + "type": "number", + "description": "Gets or sets the longitude.", + "format": "double" + } + }, + "additionalProperties": false, + "description": "World map flight position report model (part of the trail)" + }, + "WorldMapFlightTrail": { + "type": "object", + "properties": { + "positionReports": { + "type": "array", + "items": { + "$ref": "#/components/schemas/WorldMapFlightPositionReport" + }, + "description": "Gets or sets the position reports.", + "nullable": true + } + }, + "additionalProperties": false, + "description": "World map flight trail model." + }, + "WorldMapFlightTrailApiResponse": { + "type": "object", + "properties": { + "data": { + "$ref": "#/components/schemas/WorldMapFlightTrail" + }, + "errorDetails": { + "type": "string", + "description": "Gets or sets the error details (NULL if no error).", + "nullable": true + }, + "isError": { + "type": "boolean", + "description": "Gets or sets a value indicating whether this response is reporting an error." + }, + "message": { + "type": "string", + "description": "Gets or sets the message.", + "nullable": true + }, + "status": { + "type": "string", + "description": "Gets or sets the status.", + "nullable": true + } + }, + "additionalProperties": false, + "description": "API standard response model." + }, "WorldStatisticsOverview": { "type": "object", "properties": { diff --git a/OpenSky.Agent/Controls/OpenSkyWindow.cs b/OpenSky.Agent/Controls/OpenSkyWindow.cs index 1d1b592..04a5b30 100644 --- a/OpenSky.Agent/Controls/OpenSkyWindow.cs +++ b/OpenSky.Agent/Controls/OpenSkyWindow.cs @@ -552,8 +552,8 @@ private void MessageBoxClosed(object sender, EventArgs args) { try { - // Wait 500 milliseconds before removing the message box, so the fade out animation has time to run - Thread.Sleep(500); + // Wait 750 milliseconds before removing the message box, so the fade out animation has time to run + Thread.Sleep(750); UpdateGUIDelegate removeNotification = () => { lock (this.messageBoxContainer) diff --git a/OpenSky.Agent/Views/Models/FlightTrackingViewModel.cs b/OpenSky.Agent/Views/Models/FlightTrackingViewModel.cs index 41c0eb2..918a960 100644 --- a/OpenSky.Agent/Views/Models/FlightTrackingViewModel.cs +++ b/OpenSky.Agent/Views/Models/FlightTrackingViewModel.cs @@ -994,7 +994,14 @@ private void StartTracking() } // Set the plane registration - this.Simulator.SetAircraftRegistry(this.Simulator.Flight?.Aircraft.Registry.RemoveSimPrefix()); + if (this.Simulator.Flight?.Aircraft.Type.DisableAutoRegistry != true) + { + var reg = this.Simulator.Flight?.Aircraft.Registry.RemoveSimPrefix(); + if (!string.IsNullOrEmpty(reg)) + { + this.Simulator.SetAircraftRegistry(reg); + } + } // Wait a bit to make sure all structs have updated, especially time in sim Thread.Sleep(this.Simulator.SampleRates[Requests.Secondary] + 1000); @@ -1036,6 +1043,9 @@ private void StartTracking() this.StartTrackingCommand.ReportProgress(() => this.StartTrackingCommand.CanExecute = true); return; } + + // Make sure we wait a bit before the next message box + Thread.Sleep(500); } else if (this.Simulator.WeightAndBalance.FuelTotalQuantity > (this.Simulator.Flight.FuelGallons ?? 0) + 1) { @@ -1119,6 +1129,9 @@ private void StartTracking() this.StartTrackingCommand.ReportProgress(() => this.StartTrackingCommand.CanExecute = true); return; } + + // Make sure we wait a bit before the next message box + Thread.Sleep(500); } if (Math.Abs(this.Simulator.WeightAndBalance.CgPercentLateral) > 0.01) @@ -1155,6 +1168,9 @@ private void StartTracking() this.StartTrackingCommand.ReportProgress(() => this.StartTrackingCommand.CanExecute = true); return; } + + // Make sure we wait a bit before the next message box + Thread.Sleep(500); } if (this.Simulator.WeightAndBalance.PayloadWeight > this.Simulator.WeightAndBalance.MaxPayloadWeight) @@ -1191,6 +1207,9 @@ private void StartTracking() this.StartTrackingCommand.ReportProgress(() => this.StartTrackingCommand.CanExecute = true); return; } + + // Make sure we wait a bit before the next message box + Thread.Sleep(500); } if (this.Simulator.WeightAndBalance.TotalWeight > this.Simulator.WeightAndBalance.MaxGrossWeight) @@ -1226,6 +1245,9 @@ private void StartTracking() this.StartTrackingCommand.ReportProgress(() => this.StartTrackingCommand.CanExecute = true); return; } + + // Make sure we wait a bit before the next message box + Thread.Sleep(500); } if (!this.Simulator.GroundHandlingComplete && this.Simulator.SecondaryTracking.EngineRunning) diff --git a/changelog.txt b/changelog.txt index 68510a3..e46b65f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -7,6 +7,9 @@ Version 0.5.12 (ALPHA5) -------------------------------------------------------------------------------------- - Fixed default AvGas override for new aircraft - Map view now using OSM, bing maps key no longer necessary, removed from settings +- Fixed and expanded sound packs folder scanning logic, custom sound packs support + added in directory %localappdata%\OpenSky\SoundPacks +- Further improvement of tracking start questions -------------------------------------------------------------------------------------- Version 0.5.11 (ALPHA5)