This commit is contained in:
2025-02-15 22:40:11 +01:00
commit d1512bea2f
36 changed files with 70182 additions and 0 deletions
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
+31
View File
@@ -0,0 +1,31 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34330.188
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MD11 Localizer Capture", "MD11 Localizer Capture\MD11 Localizer Capture.csproj", "{15FF4626-9F2C-4C1D-88F3-DA6A08F1D96C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{15FF4626-9F2C-4C1D-88F3-DA6A08F1D96C}.Debug|x64.ActiveCfg = Debug|x64
{15FF4626-9F2C-4C1D-88F3-DA6A08F1D96C}.Debug|x64.Build.0 = Debug|x64
{15FF4626-9F2C-4C1D-88F3-DA6A08F1D96C}.Debug|x86.ActiveCfg = Debug|x86
{15FF4626-9F2C-4C1D-88F3-DA6A08F1D96C}.Debug|x86.Build.0 = Debug|x86
{15FF4626-9F2C-4C1D-88F3-DA6A08F1D96C}.Release|x64.ActiveCfg = Release|x64
{15FF4626-9F2C-4C1D-88F3-DA6A08F1D96C}.Release|x64.Build.0 = Release|x64
{15FF4626-9F2C-4C1D-88F3-DA6A08F1D96C}.Release|x86.ActiveCfg = Release|x86
{15FF4626-9F2C-4C1D-88F3-DA6A08F1D96C}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {52F0F5CF-E2F2-404C-8259-35FA43F87388}
EndGlobalSection
EndGlobal
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>
</startup>
</configuration>
+9
View File
@@ -0,0 +1,9 @@
<Application x:Class="MD11_Localizer_Capture.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MD11_Localizer_Capture"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
+11
View File
@@ -0,0 +1,11 @@
using System.Windows;
namespace MD11_Localizer_Capture
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{15FF4626-9F2C-4C1D-88F3-DA6A08F1D96C}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>MD11_Localizer_Capture</RootNamespace>
<AssemblyName>MD11 Localizer Capture</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>9.0</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>9.0</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.FlightSimulator.SimConnect, Version=10.0.62615.0, Culture=neutral, PublicKeyToken=5f523ae7e6e1b389, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>F:\SteamLibrary\steamapps\common\FSX\SDK\Core Utilities Kit\SimConnect SDK\lib\managed\Microsoft.FlightSimulator.SimConnect.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="SimConnect.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
+31
View File
@@ -0,0 +1,31 @@
<Window x:Class="MD11_Localizer_Capture.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MD11_Localizer_Capture"
mc:Ignorable="d"
Title="MainWindow" SizeToContent="WidthAndHeight">
<Grid>
<Button x:Name="buttonConnection" Content="Connect" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="90"
Height="30" Click="ButtonConnection_Click"/>
<Label x:Name="NAV1Freq" Content="Label" HorizontalAlignment="Left" Margin="10,45,0,0" VerticalAlignment="Top" Width="520"/>
<Label x:Name="NAV1Crs" Content="Label" HorizontalAlignment="Left" Margin="10,76,0,0" VerticalAlignment="Top" Width="520"/>
<Label x:Name="NAV1Dev" Content="Label" HorizontalAlignment="Left" Margin="10,107,0,0" VerticalAlignment="Top" Width="520"/>
<Label x:Name="GSPD" Content="Label" HorizontalAlignment="Left" Margin="10,138,0,0" VerticalAlignment="Top" Width="520"/>
<Label x:Name="TRK" Content="Label" HorizontalAlignment="Left" Margin="10,169,0,0" VerticalAlignment="Top" Width="520"/>
<Label x:Name="DispRate" Content="Label" HorizontalAlignment="Left" Margin="10,200,0,0" VerticalAlignment="Top" Width="520"/>
<Label x:Name="Disp" Content="Label" HorizontalAlignment="Left" Margin="10,231,0,0" VerticalAlignment="Top" Width="520"/>
<Label x:Name="Capture" Content="Label" HorizontalAlignment="Left" Margin="10,262,0,0" VerticalAlignment="Top" Width="520"/>
<Label x:Name="DeltaDev" Content="Label" HorizontalAlignment="Left" Margin="10,293,0,0" VerticalAlignment="Top" Width="520"/>
<Label x:Name="TimeToCenter" Content="Label" HorizontalAlignment="Left" Margin="10,324,0,0" VerticalAlignment="Top" Width="520"/>
<Label x:Name="DeltaT" Content="Label" HorizontalAlignment="Left" Margin="10,386,0,0" VerticalAlignment="Top" Width="520"/>
<Slider x:Name="Gain" HorizontalAlignment="Left" Margin="55,359,0,0" VerticalAlignment="Top" Width="120" Minimum="1" Maximum="4" Value="2.5" TickFrequency="0.1" IsSnapToTickEnabled="True" TickPlacement="TopLeft"/>
<Label Content="Gain" HorizontalAlignment="Left" Margin="10,355,0,0" VerticalAlignment="Top"/>
<Label Content="{Binding ElementName=Gain,Path=Value}" HorizontalAlignment="Left" Margin="180,355,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="BlueValues" HorizontalAlignment="Left" Height="123" Margin="535,10,10,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="400"/>
<TextBox x:Name="ExpValues" HorizontalAlignment="Left" Height="136" Margin="535,266,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="400"/>
<TextBox x:Name="BlueValuesFake" HorizontalAlignment="Left" Height="123" Margin="535,138,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="400"/>
</Grid>
</Window>
@@ -0,0 +1,408 @@
using Microsoft.FlightSimulator.SimConnect;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
namespace MD11_Localizer_Capture
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
// User-defined win32 event
private const int WM_USER_SIMCONNECT = 0x0402;
private const double EarthRadiusInFeet = 20902230;
private readonly IntPtr Handle;
private readonly HwndSource HandleSource;
// Declare a SimConnect object
private SimConnect SimConnect = null;
private readonly Stopwatch stopWatch = new();
private Struct1? lastFrame = null;
private double lastCalcDispTrue = 0;
private bool paused;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
struct Struct1
{
public double nav1freq;
public double nav1crs;
public double nav1cdi;
public double gspeed;
public double velWorldX;
public double velWorldZ;
public double magVar;
public SIMCONNECT_DATA_LATLONALT navPos;
public SIMCONNECT_DATA_LATLONALT pos;
public int code;
public double navMagVar;
public double locCrs;
};
enum DEFINITIONS
{
Struct1,
}
enum REQUESTS
{
Struct1,
VOR,
}
enum EVENTS
{
Pause,
AP_NAV1_HOLD_ON,
AP_NAV_SELECT_SET,
}
enum GROUPS
{
Highest = 1,
}
public MainWindow()
{
InitializeComponent();
Handle = new WindowInteropHelper(this).EnsureHandle(); // Get handle of main WPF Window
HandleSource = HwndSource.FromHwnd(Handle); // Get source of handle in order to add event handlers to it
HandleSource.AddHook(HandleSimConnectEvents);
}
~MainWindow()
{
HandleSource?.RemoveHook(HandleSimConnectEvents);
}
/// <summary>
/// Connects / Disconnect from FS
/// </summary>
/// <param name="sender">Sender object</param>
/// <param name="e">Event arguments</param>
private void ButtonConnection_Click(object sender, RoutedEventArgs e)
{
if (SimConnect != null)
{
SimConnect.Dispose();
SimConnect = null;
lastFrame = null;
NAV1Freq.Content = "";
NAV1Crs.Content = "";
NAV1Dev.Content = "";
GSPD.Content = "";
TRK.Content = "";
DeltaT.Content = "";
BlueValues.Text = "";
DispRate.Content = "";
Disp.Content = "";
Capture.Content = "";
DeltaDev.Content = "";
TimeToCenter.Content = "";
BlueValues.Text = "";
BlueValuesFake.Text = "";
ExpValues.Text = "";
buttonConnection.Content = "Connect";
return;
}
try
{
SimConnect = new SimConnect("MD11 Localizer Capture", Handle, WM_USER_SIMCONNECT, null, 0);
SimConnect.OnRecvSimobjectData += OnRecvSimobjectData;
SimConnect.OnRecvEvent += OnRecvEvent;
SimConnect.OnRecvVorList += OnRecvVorList;
SimConnect.SubscribeToSystemEvent(EVENTS.Pause, "PAUSE");
SimConnect.MapClientEventToSimEvent(EVENTS.AP_NAV1_HOLD_ON, "AP_NAV1_HOLD_ON");
SimConnect.MapClientEventToSimEvent(EVENTS.AP_NAV_SELECT_SET, "AP_NAV_SELECT_SET");
SimConnect.AddClientEventToNotificationGroup(GROUPS.Highest, EVENTS.AP_NAV1_HOLD_ON, false);
SimConnect.AddClientEventToNotificationGroup(GROUPS.Highest, EVENTS.AP_NAV_SELECT_SET, false);
SimConnect.SetNotificationGroupPriority(GROUPS.Highest, SimConnect.SIMCONNECT_GROUP_PRIORITY_HIGHEST);
SimConnect.AddToDataDefinition(DEFINITIONS.Struct1, "NAV ACTIVE FREQUENCY:1", "MHz", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
SimConnect.AddToDataDefinition(DEFINITIONS.Struct1, "NAV OBS:1", "Degrees", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
SimConnect.AddToDataDefinition(DEFINITIONS.Struct1, "NAV CDI:1", "Number", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
SimConnect.AddToDataDefinition(DEFINITIONS.Struct1, "GROUND VELOCITY", "Feet/Second", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
SimConnect.AddToDataDefinition(DEFINITIONS.Struct1, "VELOCITY WORLD X", "Radians", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
SimConnect.AddToDataDefinition(DEFINITIONS.Struct1, "VELOCITY WORLD Z", "Radians", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
SimConnect.AddToDataDefinition(DEFINITIONS.Struct1, "MAGVAR", "Degrees", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
// for just sim based data
SimConnect.AddToDataDefinition(DEFINITIONS.Struct1, "NAV VOR LATLONALT:1", null, SIMCONNECT_DATATYPE.LATLONALT, 0, SimConnect.SIMCONNECT_UNUSED);
SimConnect.AddToDataDefinition(DEFINITIONS.Struct1, "STRUCT LATLONALT", null, SIMCONNECT_DATATYPE.LATLONALT, 0, SimConnect.SIMCONNECT_UNUSED);
SimConnect.AddToDataDefinition(DEFINITIONS.Struct1, "NAV CODES:1", null, SIMCONNECT_DATATYPE.INT32, 0, SimConnect.SIMCONNECT_UNUSED);
SimConnect.AddToDataDefinition(DEFINITIONS.Struct1, "NAV MAGVAR:1", "Degrees", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
SimConnect.AddToDataDefinition(DEFINITIONS.Struct1, "NAV LOCALIZER:1", "Degrees", SIMCONNECT_DATATYPE.FLOAT64, 0, SimConnect.SIMCONNECT_UNUSED);
// for navigraph
// SimConnect.AddToDataDefinition(DEFINITIONS.Struct1, "STRUCT LATLONALT", null, SIMCONNECT_DATATYPE.LATLONALT, 0, SimConnect.SIMCONNECT_UNUSED);
SimConnect.RegisterDataDefineStruct<Struct1>(DEFINITIONS.Struct1);
// Calculation using actual sim deviation only works if set to once every second
SimConnect.RequestDataOnSimObject(REQUESTS.Struct1, DEFINITIONS.Struct1, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD.SIM_FRAME, SIMCONNECT_DATA_REQUEST_FLAG.DEFAULT, 0, 0, 0);
//SimConnect.RequestDataOnSimObject(REQUESTS.Struct1, DEFINITIONS.Struct1, SimConnect.SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD.SECOND, SIMCONNECT_DATA_REQUEST_FLAG.DEFAULT, 0, 0, 0);
stopWatch.Start();
SimConnect.SubscribeToFacilities(SIMCONNECT_FACILITY_LIST_TYPE.VOR, REQUESTS.VOR);
buttonConnection.Content = "Disconnect";
}
catch (COMException ex)
{
// A connection to the SimConnect server could not be established
SimConnect = null;
MessageBox.Show(ex.ToString());
}
}
private void OnRecvVorList(SimConnect sender, SIMCONNECT_RECV_VOR_LIST data)
{
switch ((REQUESTS)data.dwRequestID)
{
case REQUESTS.VOR:
{
foreach (SIMCONNECT_DATA_FACILITY_VOR vor in data.rgData)
{
var v = vor;
}
break;
}
default: break;
}
}
/// <summary>
/// Win32 Message Pump equivalent
/// </summary>
/// <param name="hWnd">Window Handel</param>
/// <param name="message">Message ID</param>
/// <param name="wParam">Parameters</param>
/// <param name="lParam">Parameters</param>
/// <param name="isHandled">WFlag indicating application handeled messag or not</param>
/// <returns></returns>
private IntPtr HandleSimConnectEvents(IntPtr hWnd, int message, IntPtr wParam, IntPtr lParam, ref bool isHandled)
{
isHandled = false;
switch (message)
{
case WM_USER_SIMCONNECT:
{
if (SimConnect != null)
{
SimConnect.ReceiveMessage();
isHandled = true;
}
}
break;
default:
break;
}
return IntPtr.Zero;
}
private void OnRecvSimobjectData(SimConnect sender, SIMCONNECT_RECV_SIMOBJECT_DATA data)
{
switch ((REQUESTS)data.dwRequestID)
{
case REQUESTS.Struct1:
{
double deltaT = stopWatch.ElapsedMilliseconds;
stopWatch.Restart();
if (paused) return;
Struct1 d = (Struct1)data.dwData[0];
// Actual:
double dev = Math.Abs(d.nav1cdi) * (155.0 / 127.0);
double _trk = ToDegrees(Math.Atan2(d.velWorldX, d.velWorldZ));
double trk = (_trk < 0 ? _trk + 360 : _trk) - d.magVar;
double deltaTrk = d.nav1crs - trk;
//Faked:
double distToLoc = CalculateDistance(d.pos.Latitude, d.pos.Longitude, d.navPos.Latitude, d.navPos.Longitude);
double magVar = d.navMagVar > 180 ? d.navMagVar - 360 : d.navMagVar;
double brgToLoc = CalculateBearing(d.pos.Latitude, d.pos.Longitude, d.navPos.Latitude, d.navPos.Longitude);
double calcDisp = distToLoc * Math.Sin(ToRadians(Math.Abs(d.nav1crs - (brgToLoc + magVar))));
double calcDispTrue = distToLoc * Math.Sin(ToRadians(Math.Abs(d.locCrs - brgToLoc)));
if (lastFrame.HasValue)
{
// Faked cont.
double calcDispRate = ((calcDispTrue - lastCalcDispTrue) < 0 ? -1 : 1) * d.gspeed * Math.Sin(ToRadians(Math.Abs(d.locCrs - trk)));
ExpValues.Text = $"Dist to LOC: {distToLoc} ft\n" +
$"True BRG to LOC: {brgToLoc}°\n" +
$"Calced Disp Rate: {calcDispRate} ft/s\n" +
$"TRU LOC CRS: {d.locCrs}°\n" +
$"Calced Disp User CRS: {calcDisp} ft\n" +
$"Calced Disp True CRS: {calcDispTrue} ft\n";
// Actual cont.
double lastDev = Math.Abs(lastFrame.Value.nav1cdi) * (155.0 / 127.0);
double deltaDev = (dev - lastDev) * (1000 / deltaT);
// Requires a deviation rate != 0 to calculate properly
double timeToCenter = Math.Abs(dev / deltaDev);
double dispRate = (deltaDev < 0 ? -1 : 1) * d.gspeed * Math.Sin(ToRadians(Math.Abs(deltaTrk)));
// Requires dispRate > 0 to calculate properlys
double disp = timeToCenter * Math.Abs(dispRate);
bool blueCaptureOG = BlueCheck(deltaTrk, dispRate, disp);
bool redCaptureOG = RedCheck(dispRate, disp);
bool blueCaptureFK = BlueCheck(deltaTrk, calcDispRate, calcDispTrue, true);
bool redCaptureFK = RedCheck(calcDispRate, calcDispTrue);
// Check for Full course, Half course and Quarter course nominal widths at ILS reference point
bool dispValid = !(double.IsInfinity(disp) ||
double.IsNaN(disp) ||
(dev >= 155 && disp < 350) ||
(dev >= 77.5 && disp < 175) ||
(dev >= 38.75 && disp < 87.5));
if (deltaDev != 0)
{
DispRate.Content = $"Disp. rate: {calcDispRate} ft/s";
Disp.Content = $"Disp.: {calcDispTrue} ft, VALID OG: {dispValid}";
Capture.Content = $"Capture criteria: BLUE OG: {blueCaptureOG}, BLUE FK: {blueCaptureFK}, RED OG: {redCaptureOG}, RED FK: {redCaptureFK}";
DeltaDev.Content = $"Deltas: Dev: {deltaDev} DDM/s, TRK: {deltaTrk}";
TimeToCenter.Content = $"Time to Center: {timeToCenter} s";
}
// Use faked values cause they are more accurate
if (blueCaptureFK || redCaptureFK)
{
SimConnect.TransmitClientEvent(SimConnect.SIMCONNECT_OBJECT_ID_USER, EVENTS.AP_NAV_SELECT_SET, 1, GROUPS.Highest, SIMCONNECT_EVENT_FLAG.DEFAULT);
SimConnect.TransmitClientEvent(SimConnect.SIMCONNECT_OBJECT_ID_USER, EVENTS.AP_NAV1_HOLD_ON, 0, GROUPS.Highest, SIMCONNECT_EVENT_FLAG.DEFAULT);
}
}
lastFrame = d;
lastCalcDispTrue = calcDispTrue;
NAV1Freq.Content = $"NAV1 Freq: {d.nav1freq} MHz";
NAV1Crs.Content = $"NAV1 Crs: {d.nav1crs}°";
NAV1Dev.Content = $"NAV1 DDM: {dev} DDM";
GSPD.Content = $"GRND SPD: {d.gspeed} ft/s";
TRK.Content = $"TRK MAG: {trk}°";
DeltaT.Content = $"Delta t: {deltaT} ms";
break;
}
default: break;
}
}
private void OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
{
switch ((EVENTS)data.uEventID)
{
case EVENTS.Pause:
{
paused = data.dwData == 1;
if (data.dwData == 0) stopWatch.Start();
else stopWatch.Stop();
break;
}
default: break;
}
}
#region Capture Criteria
private bool BlueCheck(double deltaTrk, double dispRate, double disp, bool fake = false)
{
double normDeltaTrack = (Math.Abs(Math.Max(Math.Min(deltaTrk, 90), -90)) * 0.2) / 90;
double gainedNormDeltaTrack = normDeltaTrack + (Gain.Value * 0.8);
double dispRateMulGainedNormDeltaTrack = gainedNormDeltaTrack * dispRate;
double rescaledDisp = disp * 0.065;
double preValue = rescaledDisp + dispRateMulGainedNormDeltaTrack;
double value = preValue * disp;
if (fake)
{
BlueValuesFake.Text = $"Norm Delta TRK: {normDeltaTrack}\n" +
$"Gained Norm Delta TRK: {gainedNormDeltaTrack}\n" +
$"Disp rate Mul Gained Norm Delta TRK: {dispRateMulGainedNormDeltaTrack}\n" +
$"Rescaled Displacement: {rescaledDisp}\n" +
$"Pre value: {preValue}\n" +
$"Value: {value}";
}
else
{
BlueValues.Text = $"Norm Delta TRK: {normDeltaTrack}\n" +
$"Gained Norm Delta TRK: {gainedNormDeltaTrack}\n" +
$"Disp rate Mul Gained Norm Delta TRK: {dispRateMulGainedNormDeltaTrack}\n" +
$"Rescaled Displacement: {rescaledDisp}\n" +
$"Pre value: {preValue}\n" +
$"Value: {value}";
}
return value < 0;
}
private bool RedCheck(double dispRate, double disp)
{
return Math.Abs(dispRate) < 25 && disp < 500;
}
#endregion
#region Helpers
private double CalculateDistance(double lat1, double lon1, double lat2, double lon2)
{
double dLat = ToRadians(lat2 - lat1);
double dLon = ToRadians(lon2 - lon1);
double lat1Rad = ToRadians(lat1);
double lat2Rad = ToRadians(lat2);
double sinDLat = Math.Sin(dLat / 2);
double sinDLon = Math.Sin(dLon / 2);
double a = sinDLat * sinDLat + sinDLon * sinDLon * Math.Cos(lat1Rad) * Math.Cos(lat2Rad);
double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
return EarthRadiusInFeet * c;
}
private double CalculateBearing(double lat1, double lon1, double lat2, double lon2)
{
double dLon = ToRadians(lon2 - lon1);
double lat1Rad = ToRadians(lat1);
double lat2Rad = ToRadians(lat2);
double y = Math.Sin(dLon) * Math.Cos(lat2Rad);
double x = Math.Cos(lat1Rad) * Math.Sin(lat2Rad) - Math.Sin(lat1Rad) * Math.Cos(lat2Rad) * Math.Cos(dLon);
double bearing = Math.Atan2(y, x);
// Convert bearing from radians to degrees
bearing *= (180 / Math.PI);
// Normalize bearing to range from 0 to 360 degrees
return (bearing + 360) % 360;
}
private double ToRadians(double degrees) => (Math.PI / 180) * degrees;
private double ToDegrees(double radians) => (180/ Math.PI) * radians;
#endregion
}
}
@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MD11_Localizer_Capture")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MD11_Localizer_Capture")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MD11_Localizer_Capture.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MD11_Localizer_Capture.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MD11_Localizer_Capture.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.8.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
Binary file not shown.
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 357 KiB