Skip to content

Commit

Permalink
Added support for Vatsim flights
Browse files Browse the repository at this point in the history
Vatsim data collection working
Tracking condition implemented
Time connected logic still missing
Mostly working PMDG 737 gear handle logic, needs tuning
  • Loading branch information
sushiat committed Dec 4, 2023
1 parent 4a63fde commit 0586786
Show file tree
Hide file tree
Showing 19 changed files with 434 additions and 50 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.6")]
[assembly: AssemblyFileVersion("0.5.6")]
[assembly: AssemblyVersion("0.5.7")]
[assembly: AssemblyFileVersion("0.5.7")]
7 changes: 6 additions & 1 deletion OpenSky.Agent.Simulator/Models/TrackingConditions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public enum TrackingConditions
/// <summary>
/// Location condition.
/// </summary>
Location = 5
Location = 5,

/// <summary>
/// Vatsim option.
/// </summary>
Vatsim = 6
}
}
77 changes: 77 additions & 0 deletions OpenSky.Agent.Simulator/Models/VatsimClientConnection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="VatsimClientConnection.cs" company="OpenSky">
// OpenSky project 2021-2023
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace OpenSky.Agent.Simulator.Models
{
using System;

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// Vatsim client connection model.
/// </summary>
/// <remarks>
/// sushi.at, 03/12/2023.
/// </remarks>
/// -------------------------------------------------------------------------------------------------
public class VatsimClientConnection
{
/// -------------------------------------------------------------------------------------------------
/// <summary>
/// Gets or sets the arrival.
/// </summary>
/// -------------------------------------------------------------------------------------------------
public string Arrival { get; set; }

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// Gets or sets the call sign.
/// </summary>
/// -------------------------------------------------------------------------------------------------
public string Callsign { get; set; }

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// Gets or sets the CID.
/// </summary>
/// -------------------------------------------------------------------------------------------------
public string CID { get; set; }

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// Gets or sets the departure.
/// </summary>
/// -------------------------------------------------------------------------------------------------
public string Departure { get; set; }

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// Gets or sets the last updated timestamp.
/// </summary>
/// -------------------------------------------------------------------------------------------------
public DateTime LastUpdated { get; set; }

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// Gets or sets the latitude.
/// </summary>
/// -------------------------------------------------------------------------------------------------
public double Latitude { get; set; }

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// Gets or sets the logon time.
/// </summary>
/// -------------------------------------------------------------------------------------------------
public DateTime LogonTime { get; set; }

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// Gets or sets the longitude.
/// </summary>
/// -------------------------------------------------------------------------------------------------
public double Longitude { get; set; }
}
}
56 changes: 50 additions & 6 deletions OpenSky.Agent.Simulator/OpenAPIs/swagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11266,6 +11266,12 @@ public partial class Flight
[Newtonsoft.Json.JsonProperty("altitude", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public double? Altitude { get; set; }

/// <summary>
/// Gets or sets the atc call sign for the flight - important for online flying.
/// </summary>
[Newtonsoft.Json.JsonProperty("atcCallsign", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string AtcCallsign { get; set; }

/// <summary>
/// The bank angle in degrees.
/// </summary>
Expand Down Expand Up @@ -11453,6 +11459,16 @@ public partial class Flight
[Newtonsoft.Json.JsonProperty("onGround", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public bool OnGround { get; set; }

[Newtonsoft.Json.JsonProperty("onlineNetwork", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public OnlineNetwork OnlineNetwork { get; set; }

/// <summary>
/// Gets or sets the minutes the player was connected to the online network for, used to
/// <br/>calculate 80% online requirement.
/// </summary>
[Newtonsoft.Json.JsonProperty("onlineNetworkConnectedMinutes", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public double OnlineNetworkConnectedMinutes { get; set; }

/// <summary>
/// Gets the name of the flight operator.
/// </summary>
Expand Down Expand Up @@ -11995,6 +12011,12 @@ public partial class FlightPlan
[Newtonsoft.Json.JsonProperty("alternateRoute", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string AlternateRoute { get; set; }

/// <summary>
/// Gets or sets the atc call sign.
/// </summary>
[Newtonsoft.Json.JsonProperty("atcCallsign", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string AtcCallsign { get; set; }

/// <summary>
/// Gets or sets destination airport ICAO code.
/// </summary>
Expand Down Expand Up @@ -12058,25 +12080,28 @@ public partial class FlightPlan
[Newtonsoft.Json.JsonProperty("navlogFixes", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.Collections.Generic.ICollection<FlightNavlogFix> NavlogFixes { get; set; }

/// <summary>
/// Gets or sets the payloads.
/// </summary>
[Newtonsoft.Json.JsonProperty("payloads", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.Collections.Generic.ICollection<FlightPayload> Payloads { get; set; }

/// <summary>
/// Gets or sets the OFP HTML (most likely from simBrief).
/// </summary>
[Newtonsoft.Json.JsonProperty("ofpHtml", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string OfpHtml { get; set; }

[Newtonsoft.Json.JsonProperty("onlineNetwork", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public OnlineNetwork OnlineNetwork { get; set; }

/// <summary>
/// Gets or sets the origin airport ICAO code.
/// </summary>
[Newtonsoft.Json.JsonProperty("originICAO", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
[System.ComponentModel.DataAnnotations.StringLength(5, MinimumLength = 3)]
public string OriginICAO { get; set; }

/// <summary>
/// Gets or sets the payloads.
/// </summary>
[Newtonsoft.Json.JsonProperty("payloads", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public System.Collections.Generic.ICollection<FlightPayload> Payloads { get; set; }

/// <summary>
/// Gets or sets the planned departure time.
/// </summary>
Expand Down Expand Up @@ -12445,6 +12470,12 @@ public partial class LinkedAccounts
[Newtonsoft.Json.JsonProperty("simbriefUsername", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string SimbriefUsername { get; set; }

/// <summary>
/// Gets or sets the Vatsim user ID.
/// </summary>
[Newtonsoft.Json.JsonProperty("vatsimID", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public string VatsimID { get; set; }

}

/// <summary>
Expand Down Expand Up @@ -12625,6 +12656,19 @@ public enum NewAircraftDeliveryOption

}

/// <summary>
/// Online aviation networks. 0 = Offline, 1 = Vatsim
/// </summary>
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v11.0.0.0))")]
public enum OnlineNetwork
{

Offline = 0,

Vatsim = 1,

}

/// <summary>
/// Payload model.
/// </summary>
Expand Down
59 changes: 51 additions & 8 deletions OpenSky.Agent.Simulator/OpenAPIs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -6792,6 +6792,11 @@
"format": "double",
"nullable": true
},
"atcCallsign": {
"type": "string",
"description": "Gets or sets the atc call sign for the flight - important for online flying.",
"nullable": true
},
"bankAngle": {
"type": "number",
"description": "The bank angle in degrees.",
Expand Down Expand Up @@ -6974,6 +6979,14 @@
"type": "boolean",
"description": "Is the plane on the ground?"
},
"onlineNetwork": {
"$ref": "#/components/schemas/OnlineNetwork"
},
"onlineNetworkConnectedMinutes": {
"type": "number",
"description": "Gets or sets the minutes the player was connected to the online network for, used to\r\ncalculate 80% online requirement.",
"format": "double"
},
"operatorName": {
"type": "string",
"description": "Gets the name of the flight operator.",
Expand Down Expand Up @@ -7469,6 +7482,11 @@
"description": "Gets or sets the alternate route.",
"nullable": true
},
"atcCallsign": {
"type": "string",
"description": "Gets or sets the atc call sign.",
"nullable": true
},
"destinationICAO": {
"maxLength": 5,
"minLength": 3,
Expand Down Expand Up @@ -7526,26 +7544,29 @@
"description": "Gets or sets the navlog fixes.",
"nullable": true
},
"payloads": {
"type": "array",
"items": {
"$ref": "#/components/schemas/FlightPayload"
},
"description": "Gets or sets the payloads.",
"nullable": true
},
"ofpHtml": {
"type": "string",
"description": "Gets or sets the OFP HTML (most likely from simBrief).",
"nullable": true
},
"onlineNetwork": {
"$ref": "#/components/schemas/OnlineNetwork"
},
"originICAO": {
"maxLength": 5,
"minLength": 3,
"type": "string",
"description": "Gets or sets the origin airport ICAO code.",
"nullable": true
},
"payloads": {
"type": "array",
"items": {
"$ref": "#/components/schemas/FlightPayload"
},
"description": "Gets or sets the payloads.",
"nullable": true
},
"plannedDepartureTime": {
"type": "string",
"description": "Gets or sets the planned departure time.",
Expand Down Expand Up @@ -7900,6 +7921,11 @@
"type": "string",
"description": "Gets or sets the Simbrief username.",
"nullable": true
},
"vatsimID": {
"type": "string",
"description": "Gets or sets the Vatsim user ID.",
"nullable": true
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -8064,6 +8090,23 @@
"OutsourceFerry"
]
},
"OnlineNetwork": {
"enum": [
0,
1
],
"type": "integer",
"description": "Online aviation networks. 0 = Offline, 1 = Vatsim",
"format": "int32",
"x-enumNames": [
"Offline",
"Vatsim"
],
"x-enum-varnames": [
"Offline",
"Vatsim"
]
},
"Payload": {
"required": [
"description",
Expand Down
2 changes: 2 additions & 0 deletions OpenSky.Agent.Simulator/OpenSky.Agent.Simulator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<Compile Include="Models\TrackingEventLogEntry.cs" />
<Compile Include="Enums\TrackingStatus.cs" />
<Compile Include="Models\TrackingEventMarker.cs" />
<Compile Include="Models\VatsimClientConnection.cs" />
<Compile Include="Models\VerticalProfile.cs" />
<Compile Include="Models\WeightAndBalance.cs" />
<Compile Include="OpenAPIs\ModelExtensions\AircraftType.cs" />
Expand All @@ -128,6 +129,7 @@
<Compile Include="Simulator.Process.Systems.cs" />
<Compile Include="Simulator.SaveLoadXML.cs" />
<Compile Include="Simulator.simBrief.cs" />
<Compile Include="Simulator.Vatsim.cs" />
<Compile Include="SpeechSoundPacks.cs" />
<Compile Include="Tools\AircraftRegistryExtensions.cs" />
<Compile Include="Tools\ColorExtensions.cs" />
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 @@ -17,5 +17,5 @@
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("30c467e8-2eee-41e5-be01-0142a61ba171")]
[assembly: AssemblyVersion("0.5.6")]
[assembly: AssemblyFileVersion("0.5.6")]
[assembly: AssemblyVersion("0.5.7")]
[assembly: AssemblyFileVersion("0.5.7")]
11 changes: 11 additions & 0 deletions OpenSky.Agent.Simulator/Simulator.Flight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,17 @@ public Flight Flight
this.TrackingConditions[(int)Models.TrackingConditions.Fuel].AutoSet = !value.Aircraft.Type.RequiresManualFuelling;
this.TrackingConditions[(int)Models.TrackingConditions.Payload].AutoSet = !value.Aircraft.Type.RequiresManualLoading;

if (value.OnlineNetwork == OnlineNetwork.Vatsim)
{
this.TrackingConditions[(int)Models.TrackingConditions.Vatsim].Enabled = true;
this.TrackingConditions[(int)Models.TrackingConditions.Vatsim].Current = "Unknown";
this.TrackingConditions[(int)Models.TrackingConditions.Vatsim].Expected = $"Connected: True, Callsign: {value.AtcCallsign}, Flight plan: {value.Origin.Icao}-{value.Destination.Icao}";
}
else
{
this.TrackingConditions[(int)Models.TrackingConditions.Vatsim].Enabled = false;
}

if (!value.Resume)
{
Debug.WriteLine("Preparing to track new flight");
Expand Down
Loading

0 comments on commit 0586786

Please sign in to comment.