Skip to content

Commit

Permalink
Merge pull request #67 from #65-cg-slider
Browse files Browse the repository at this point in the history
Agent#65 cg slider
  • Loading branch information
sushiat authored Nov 21, 2023
2 parents 853b12a + b9c0b9a commit 41f72e7
Show file tree
Hide file tree
Showing 108 changed files with 687 additions and 265 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.4.5")]
[assembly: AssemblyFileVersion("0.4.5")]
[assembly: AssemblyVersion("0.5.0")]
[assembly: AssemblyFileVersion("0.5.0")]
4 changes: 2 additions & 2 deletions OpenSky.Agent.SimConnectMSFS/SimConnect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
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.4.5")]
[assembly: AssemblyFileVersion("0.4.5")]
[assembly: AssemblyVersion("0.5.0")]
[assembly: AssemblyFileVersion("0.5.0")]
4 changes: 2 additions & 2 deletions OpenSky.Agent.Simulator/Simulator.Flight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
Expand All @@ -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 = () =>
Expand Down
12 changes: 6 additions & 6 deletions OpenSky.Agent.Simulator/Simulator.Process.FlightPhases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down
5 changes: 4 additions & 1 deletion OpenSky.Agent.Simulator/Simulator.Process.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ private void ProcessLandingAnalysis()
}
}

private DateTime lastLocationUpdate=DateTime.MinValue;

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// Process the primary tracking data (old vs new).
Expand All @@ -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;
}

Expand Down
8 changes: 8 additions & 0 deletions OpenSky.Agent.Simulator/Simulator.simBrief.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ public partial class Simulator
/// -------------------------------------------------------------------------------------------------
private bool simbriefOfpLoaded;

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// Occurs when simbrief ofp loaded property changed.
/// </summary>
/// -------------------------------------------------------------------------------------------------
public event EventHandler<bool> SimbriefOfpLoadedChanged;

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// Occurs when SimConnect adds a new simbrief waypoint marker.
Expand All @@ -64,6 +71,7 @@ private set

this.simbriefOfpLoaded = value;
this.OnPropertyChanged();
this.SimbriefOfpLoadedChanged?.Invoke(this, value);
}
}

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.4.5")]
[assembly: AssemblyFileVersion("0.4.5")]
[assembly: AssemblyVersion("0.5.0")]
[assembly: AssemblyFileVersion("0.5.0")]
4 changes: 2 additions & 2 deletions OpenSky.Agent.UdpXPlane11/UdpXPlane11.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion OpenSky.Agent/App.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--
====================================================================================================================
<copyright file="Startup.xaml" company="OpenSky">
OpenSky project 2021-2022
OpenSky project 2021-2023
</copyright>
<summary>
OpenSky agent main wpf application configuration
Expand Down
6 changes: 3 additions & 3 deletions OpenSky.Agent/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="App.xaml.cs" company="OpenSky">
// OpenSky project 2021-2022
// OpenSky project 2021-2023
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -301,13 +301,13 @@ private static void AppDispatcherUnhandledException(
crashReport += "\r\n\r\n";

Debug.WriteLine(crashReport);
var filePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\OpenSky.Agent.Crash.txt";
var filePath = Environment.ExpandEnvironmentVariables("%localappdata%\\OpenSky\\agent_crash.log");

try
{
File.AppendAllText(filePath, crashReport);
ModernWpf.MessageBox.Show(
e.Exception.Message + "\r\n\r\nPlease check OpenSky.Agent.Crash.txt for details!",
e.Exception.Message + "\r\n\r\nPlease check agent_crash.log for details!",
"Unexpected error!",
MessageBoxButton.OK,
MessageBoxImage.Error);
Expand Down
2 changes: 1 addition & 1 deletion OpenSky.Agent/Controls/CustomModules/A32NX.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--
====================================================================================================================
<copyright file="A32NX.xaml" company="OpenSky">
OpenSky project 2021-2022
OpenSky project 2021-2023
</copyright>
<summary>
A32NX custom module control
Expand Down
2 changes: 1 addition & 1 deletion OpenSky.Agent/Controls/CustomModules/A32NX.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="A32NX.xaml.cs" company="OpenSky">
// OpenSky project 2021-2022
// OpenSky project 2021-2023
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions OpenSky.Agent/Controls/FuelTankControl.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--
====================================================================================================================
<copyright file="FuelTankControl.xaml" company="OpenSky">
OpenSky project 2021-2022
OpenSky project 2021-2023
</copyright>
<summary>
Fuel tank custom control
Expand Down Expand Up @@ -29,7 +29,7 @@
<Rectangle Grid.Row="0" Grid.RowSpan="2" Grid.Column="0" Grid.ColumnSpan="3" Fill="#404040" Stroke="Gray" RadiusX="1.5" RadiusY="1.5" />
<TextBlock Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" VerticalAlignment="Center" Margin="5,0" Text="{Binding ElementName=FuelTank, Path=FuelTankName, Mode=OneWay}" />
<Slider Grid.Row="0" Grid.Column="1" MinWidth="100" Margin="10,5,10,0" TickFrequency="0.5" IsSnapToTickEnabled="True" Value="{Binding ElementName=FuelTank, Path=FuelTankQuantity, Mode=TwoWay}" Maximum="{Binding ElementName=FuelTank, Path=FuelTankCapacity, Mode=OneWay}" />
<TextBox Grid.Row="0" Grid.Column="2" Margin="0,5,5,0" Text="{Binding ElementName=FuelTank, Path=FuelTankQuantity, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<TextBox Grid.Row="0" Grid.Column="2" Margin="0,5,5,0" Text="{Binding ElementName=FuelTank, Path=FuelTankQuantity, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, StringFormat=N1}" />
<TextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Margin="0,2,5,5" FontSize="10" HorizontalAlignment="Right" Text="{Binding ElementName=FuelTank, Path=FuelTankInfo, Mode=OneWay}" />
</Grid>
</UserControl>
10 changes: 5 additions & 5 deletions OpenSky.Agent/Controls/FuelTankControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="FuelTankControl.xaml.cs" company="OpenSky">
// OpenSky project 2021-2022
// OpenSky project 2021-2023
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand All @@ -21,28 +21,28 @@ public partial class FuelTankControl
/// The fuel tangent capacity property.
/// </summary>
/// -------------------------------------------------------------------------------------------------
public static readonly DependencyProperty FuelTankCapacityProperty = DependencyProperty.Register("FuelTankCapacity", typeof(double), typeof(FuelTankControl), new UIPropertyMetadata(0.0));
public static readonly DependencyProperty FuelTankCapacityProperty = DependencyProperty.Register(nameof(FuelTankCapacity), typeof(double), typeof(FuelTankControl), new UIPropertyMetadata(0.0));

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// The fuel tank name property.
/// </summary>
/// -------------------------------------------------------------------------------------------------
public static readonly DependencyProperty FuelTankNameProperty = DependencyProperty.Register("FuelTankName", typeof(string), typeof(FuelTankControl), new UIPropertyMetadata("Unknown tank"));
public static readonly DependencyProperty FuelTankNameProperty = DependencyProperty.Register(nameof(FuelTankName), typeof(string), typeof(FuelTankControl), new UIPropertyMetadata("Unknown tank"));

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// The fuel tank info property.
/// </summary>
/// -------------------------------------------------------------------------------------------------
public static readonly DependencyProperty FuelTankInfoProperty = DependencyProperty.Register("FuelTankInfo", typeof(string), typeof(FuelTankControl), new UIPropertyMetadata("??"));
public static readonly DependencyProperty FuelTankInfoProperty = DependencyProperty.Register(nameof(FuelTankInfo), typeof(string), typeof(FuelTankControl), new UIPropertyMetadata("??"));

/// -------------------------------------------------------------------------------------------------
/// <summary>
/// The fuel tank quantity property.
/// </summary>
/// -------------------------------------------------------------------------------------------------
public static readonly DependencyProperty FuelTankQuantityProperty = DependencyProperty.Register("FuelTankQuantity", typeof(double), typeof(FuelTankControl), new UIPropertyMetadata(0.0));
public static readonly DependencyProperty FuelTankQuantityProperty = DependencyProperty.Register(nameof(FuelTankQuantity), typeof(double), typeof(FuelTankControl), new UIPropertyMetadata(0.0));

/// -------------------------------------------------------------------------------------------------
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion OpenSky.Agent/Controls/Models/ErrorDetails.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ErrorDetails.cs" company="OpenSky">
// OpenSky project 2021-2022
// OpenSky project 2021-2023
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion OpenSky.Agent/Controls/Models/ExtendedMessageBoxImage.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ExtendedMessageBoxImage.cs" company="OpenSky">
// OpenSky project 2021-2022
// OpenSky project 2021-2023
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion OpenSky.Agent/Controls/Models/ExtendedMessageBoxResult.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ExtendedMessageBoxResult.cs" company="OpenSky">
// OpenSky project 2021-2022
// OpenSky project 2021-2023
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion OpenSky.Agent/Controls/OpenSkyMessageBox.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--
====================================================================================================================
<copyright file="OpenSkyMessageBox.xaml" company="OpenSky">
OpenSky project 2021-2022
OpenSky project 2021-2023
</copyright>
<summary>
OpenSky message box control
Expand Down
2 changes: 1 addition & 1 deletion OpenSky.Agent/Controls/OpenSkyMessageBox.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="OpenSkyMessageBox.xaml.cs" company="OpenSky">
// OpenSky project 2021-2022
// OpenSky project 2021-2023
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion OpenSky.Agent/Controls/OpenSkyNotification.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--
====================================================================================================================
<copyright file="OpenSkyNotification.xaml" company="OpenSky">
OpenSky project 2021-2022
OpenSky project 2021-2023
</copyright>
<summary>
OpenSky notification control
Expand Down
2 changes: 1 addition & 1 deletion OpenSky.Agent/Controls/OpenSkyNotification.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="OpenSkyNotification.xaml.cs" company="OpenSky">
// OpenSky project 2021-2022
// OpenSky project 2021-2023
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

Expand Down
Loading

0 comments on commit 41f72e7

Please sign in to comment.