Skip to content

Commit

Permalink
Merge pull request #91 from opensky-to/gsx-pushback
Browse files Browse the repository at this point in the history
Gsx pushback
  • Loading branch information
sushiat authored Dec 14, 2023
2 parents ea8817e + 7e42596 commit 1b3f1ed
Show file tree
Hide file tree
Showing 14 changed files with 215 additions and 60 deletions.
4 changes: 2 additions & 2 deletions OpenSky.Agent.SimConnectMSFS/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
22 changes: 19 additions & 3 deletions OpenSky.Agent.SimConnectMSFS/Structs/SecondaryTracking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public struct SecondaryTracking

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// Is the auto pilot engaged?
/// Is the auto-pilot engaged?
/// </summary>
/// -------------------------------------------------------------------------------------------------
public bool AutoPilot { get; set; }
Expand Down Expand Up @@ -222,6 +222,14 @@ public struct SecondaryTracking
/// </summary>
/// -------------------------------------------------------------------------------------------------
public bool NoSmokingSign { get; set; }

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// Gets or sets a value indicating whether the aircraft has "latitude longitude freeze" on, GSX
/// sets this during pushback.
/// </summary>
/// -------------------------------------------------------------------------------------------------
public bool IsLatitudeLongitudeFreezeOn { get; set; }
}

/// -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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)
};
}
}
28 changes: 25 additions & 3 deletions OpenSky.Agent.Simulator/OpenAPIs/swagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8941,7 +8941,7 @@ public partial class Aircraft
/// </summary>
[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; }

/// <summary>
Expand Down Expand Up @@ -11200,7 +11200,7 @@ public partial class FinancialRecord
/// Gets or sets the aircraft registry (optional, if record relates to an aircraft).
/// </summary>
[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)]
Expand Down Expand Up @@ -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; }

/// <summary>
/// Gets or sets the fuel in gallons.
/// </summary>
Expand Down Expand Up @@ -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; }

/// <summary>
/// Gets or sets the Date/Time of when the flight was completed.
/// </summary>
Expand Down Expand Up @@ -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; }

Expand Down Expand Up @@ -12185,6 +12194,19 @@ public partial class FlightPlanIEnumerableApiResponse

}

/// <summary>
/// Flight rules. 0 = IFR, 1 = VFR
/// </summary>
[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,

}

/// <summary>
/// Forgot password model.
/// </summary>
Expand Down Expand Up @@ -12710,7 +12732,7 @@ public partial class Payload
/// Gets or sets the aircraft registry the payload is currently loaded on, or NULL if stored at an airport.
/// </summary>
[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; }

/// <summary>
Expand Down
36 changes: 31 additions & 5 deletions OpenSky.Agent.Simulator/OpenAPIs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4333,7 +4333,7 @@
},
"registry": {
"maxLength": 12,
"minLength": 7,
"minLength": 6,
"type": "string",
"description": "Gets or sets the aircraft registration."
},
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -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.",
Expand Down Expand Up @@ -7501,6 +7507,9 @@
],
"type": "object",
"properties": {
"flightRule": {
"$ref": "#/components/schemas/FlightRule"
},
"aircraft": {
"$ref": "#/components/schemas/Aircraft"
},
Expand Down Expand Up @@ -7649,6 +7658,23 @@
"additionalProperties": false,
"description": "API standard response model."
},
"FlightRule": {
"enum": [
0,
1
],
"type": "integer",
"description": "Flight rules. 0 = IFR, 1 = VFR",
"format": "int32",
"x-enumNames": [
"IFR",
"VFR"
],
"x-enum-varnames": [
"IFR",
"VFR"
]
},
"ForgotPassword": {
"required": [
"email"
Expand Down Expand Up @@ -8150,8 +8176,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
Expand Down
4 changes: 2 additions & 2 deletions OpenSky.Agent.Simulator/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
13 changes: 12 additions & 1 deletion OpenSky.Agent.Simulator/Simulator.Flight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -301,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
{
Expand Down Expand Up @@ -444,6 +454,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
Expand Down
1 change: 1 addition & 0 deletions OpenSky.Agent.Simulator/Simulator.Process.FlightPhases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ private set

this.wasAirborne = value;
this.OnPropertyChanged();
this.OnPropertyChanged(nameof(this.CanFinishTracking));
}
}

Expand Down
7 changes: 3 additions & 4 deletions OpenSky.Agent.Simulator/Simulator.Process.Systems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
namespace OpenSky.Agent.Simulator
{
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Media;
using System.Reflection;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -192,14 +193,12 @@ 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
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);
}
Expand Down
44 changes: 34 additions & 10 deletions OpenSky.Agent.Simulator/Simulator.Vatsim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ private void MonitorVatsimFlight()
this.VatsimClientConnection.Departure = string.Empty;
this.VatsimClientConnection.Arrival = string.Empty;
}


this.OnlineNetworkConnectionStarted ??= DateTime.UtcNow;
}
}
}
Expand Down Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion OpenSky.Agent.Simulator/Simulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ protected Simulator(OpenSkyService openSkyServiceInstance)

this.TrackingConditions = new Dictionary<int, TrackingCondition>
{
{ (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() },
Expand Down
4 changes: 2 additions & 2 deletions OpenSky.Agent.UdpXPlane11/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Loading

0 comments on commit 1b3f1ed

Please sign in to comment.