Skip to content

Commit c029955

Browse files
committed
Jetway-Check improved, considers moving Jetway / Configurable Volume Control for VHF1 added
1 parent aaa1f8f commit c029955

File tree

7 files changed

+109
-35
lines changed

7 files changed

+109
-35
lines changed

Fenix2GSX/App.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<add key="testArrival" value="false" />
88
<add key="waitForConnect" value="true" />
99
<add key="gsxVolumeControl" value="true" />
10+
<add key="vhf1VolumeApp" value="vPilot" />
1011
<add key="disableCrew" value="true" />
1112
<add key="repositionPlane" value="true" />
1213
<add key="repositionDelay" value="3" />

Fenix2GSX/Fenix2GSX.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<ApplicationIcon>phoenix.ico</ApplicationIcon>
1010
<PlatformTarget>x64</PlatformTarget>
1111
<Title>Fenix2GSX</Title>
12-
<Version>0.2.6</Version>
12+
<Version>0.2.7</Version>
1313
<Authors>Fragtality</Authors>
1414
<Copyright>Copyright © 2023</Copyright>
1515
<Description>GSX Integration and Automation for the Fenix A320</Description>
@@ -32,7 +32,7 @@
3232
</ItemGroup>
3333

3434
<ItemGroup>
35-
<PackageReference Include="CefSharp.OffScreen.NETCore" Version="111.2.70" />
35+
<PackageReference Include="CefSharp.OffScreen.NETCore" Version="112.2.70" />
3636
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
3737
<PackageReference Include="CoreAudio" Version="1.27.0" />
3838
<PackageReference Include="H.NotifyIcon.Wpf" Version="2.0.108" />
@@ -57,15 +57,15 @@
5757
</ItemGroup>
5858

5959
<ItemGroup>
60-
<PackageReference Update="chromiumembeddedframework.runtime.win-arm64" Version="111.2.7" />
60+
<PackageReference Update="chromiumembeddedframework.runtime.win-arm64" Version="112.2.7" />
6161
</ItemGroup>
6262

6363
<ItemGroup>
64-
<PackageReference Update="chromiumembeddedframework.runtime.win-x64" Version="111.2.7" />
64+
<PackageReference Update="chromiumembeddedframework.runtime.win-x64" Version="112.2.7" />
6565
</ItemGroup>
6666

6767
<ItemGroup>
68-
<PackageReference Update="chromiumembeddedframework.runtime.win-x86" Version="111.2.7" />
68+
<PackageReference Update="chromiumembeddedframework.runtime.win-x86" Version="112.2.7" />
6969
</ItemGroup>
7070

7171
</Project>

Fenix2GSX/FenixController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ public void RefuelStart()
125125
{
126126
if (fuelCurrent > fuelPlanned)
127127
{
128-
Interface.FenixPost(FenixInterface.MsgMutation("float", "aircraft.fuel.total.amount.kg", 2500.0f));
129-
fuelCurrent = 2500;
128+
Interface.FenixPost(FenixInterface.MsgMutation("float", "aircraft.fuel.total.amount.kg", 3000.0f));
129+
fuelCurrent = 3000;
130130
}
131131
}
132132

Fenix2GSX/GsxController.cs

Lines changed: 82 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using CoreAudio;
22
using Microsoft.Win32;
33
using System;
4-
using System.IO;
54
using System.Diagnostics;
5+
using System.IO;
66
using System.Linq;
77
using System.Threading;
88

@@ -55,6 +55,9 @@ public class GsxController
5555
private AudioSessionControl2 gsxAudioSession = null;
5656
private float gsxAudioVolume = -1;
5757
private int gsxAudioMute = -1;
58+
private AudioSessionControl2 vhf1AudioSession = null;
59+
private float vhf1AudioVolume = -1;
60+
private int vhf1AudioMute = -1;
5861

5962
public int Interval { get; set; } = 1000;
6063

@@ -81,21 +84,23 @@ public GsxController(ServiceModel model)
8184
SimConnect.SubscribeLvar("FSDT_VAR_EnginesStopped");
8285
SimConnect.SubscribeLvar("FSDT_GSX_COUATL_STARTED");
8386
SimConnect.SubscribeLvar("FSDT_GSX_JETWAY");
87+
SimConnect.SubscribeLvar("FSDT_GSX_OPERATEJETWAYS_STATE");
8488
SimConnect.SubscribeLvar("FSDT_GSX_STAIRS");
89+
SimConnect.SubscribeLvar("FSDT_GSX_OPERATESTAIRS_STATE");
8590
SimConnect.SubscribeLvar("S_MIP_PARKING_BRAKE");
8691
SimConnect.SubscribeLvar("S_OH_EXT_LT_BEACON");
8792
SimConnect.SubscribeLvar("I_OH_ELEC_EXT_PWR_L");
8893
SimConnect.SubscribeLvar("I_OH_ELEC_APU_START_U");
8994
SimConnect.SubscribeLvar("S_OH_PNEUMATIC_APU_BLEED");
95+
SimConnect.SubscribeLvar("I_FCU_TRACK_FPA_MODE");
96+
SimConnect.SubscribeLvar("I_FCU_HEADING_VS_MODE");
9097

9198
FenixController = new(Model);
9299

93100
if (Model.GsxVolumeControl)
94101
{
95102
SimConnect.SubscribeLvar("I_ASP_INT_REC");
96103
SimConnect.SubscribeLvar("A_ASP_INT_VOLUME");
97-
SimConnect.SubscribeLvar("I_FCU_TRACK_FPA_MODE");
98-
SimConnect.SubscribeLvar("I_FCU_HEADING_VS_MODE");
99104

100105
MMDeviceEnumerator deviceEnumerator = new(Guid.NewGuid());
101106
var devices = deviceEnumerator.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active);
@@ -117,6 +122,31 @@ public GsxController(ServiceModel model)
117122
}
118123
}
119124

125+
if (!string.IsNullOrEmpty(Model.Vhf1VolumeApp))
126+
{
127+
SimConnect.SubscribeLvar("I_ASP_VHF_1_REC");
128+
SimConnect.SubscribeLvar("A_ASP_VHF_1_VOLUME");
129+
130+
MMDeviceEnumerator deviceEnumerator = new(Guid.NewGuid());
131+
var devices = deviceEnumerator.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active);
132+
133+
foreach (var device in devices)
134+
{
135+
foreach (var session in device.AudioSessionManager2.Sessions)
136+
{
137+
Process p = Process.GetProcessById((int)session.ProcessID);
138+
if (p.ProcessName == Model.Vhf1VolumeApp)
139+
{
140+
vhf1AudioSession = session;
141+
break;
142+
}
143+
}
144+
145+
if (vhf1AudioSession != null)
146+
break;
147+
}
148+
}
149+
120150
string regPath = (string)Registry.GetValue(registryPath, registryValue, null) + pathMenuFile;
121151
if (Path.Exists(regPath))
122152
menuFile = regPath;
@@ -132,31 +162,60 @@ public void ResetAudio()
132162
gsxAudioSession.SimpleAudioVolume.MasterVolume = 1.0f;
133163
gsxAudioSession.SimpleAudioVolume.Mute = false;
134164
}
165+
166+
if (vhf1AudioSession != null)
167+
{
168+
vhf1AudioSession.SimpleAudioVolume.MasterVolume = 1.0f;
169+
vhf1AudioSession.SimpleAudioVolume.Mute = false;
170+
}
135171
}
136172

137173
public void ControlAudio()
138174
{
139-
if (!Model.GsxVolumeControl || gsxAudioSession == null)
140-
return;
141-
142-
if (!(SimConnect.ReadLvar("I_FCU_TRACK_FPA_MODE") == 1 || SimConnect.ReadLvar("I_FCU_HEADING_VS_MODE") == 1))
175+
if (Model.GsxVolumeControl && gsxAudioSession != null)
143176
{
144-
ResetAudio();
145-
return;
146-
}
177+
if (!(SimConnect.ReadLvar("I_FCU_TRACK_FPA_MODE") == 1 || SimConnect.ReadLvar("I_FCU_HEADING_VS_MODE") == 1))
178+
{
179+
ResetAudio();
180+
return;
181+
}
147182

148-
float volume = SimConnect.ReadLvar("A_ASP_INT_VOLUME");
149-
int muted = (int)SimConnect.ReadLvar("I_ASP_INT_REC");
150-
if (volume >= 0 && volume != gsxAudioVolume)
151-
{
152-
gsxAudioSession.SimpleAudioVolume.MasterVolume = volume;
153-
gsxAudioVolume = volume;
183+
float volume = SimConnect.ReadLvar("A_ASP_INT_VOLUME");
184+
int muted = (int)SimConnect.ReadLvar("I_ASP_INT_REC");
185+
if (volume >= 0 && volume != gsxAudioVolume)
186+
{
187+
gsxAudioSession.SimpleAudioVolume.MasterVolume = volume;
188+
gsxAudioVolume = volume;
189+
}
190+
191+
if (muted >= 0 && muted != gsxAudioMute)
192+
{
193+
gsxAudioSession.SimpleAudioVolume.Mute = muted == 0;
194+
gsxAudioMute = muted;
195+
}
154196
}
155197

156-
if (muted >= 0 && muted != gsxAudioMute)
198+
if (!string.IsNullOrEmpty(Model.Vhf1VolumeApp) && vhf1AudioSession != null)
157199
{
158-
gsxAudioSession.SimpleAudioVolume.Mute = muted == 0;
159-
gsxAudioMute = muted;
200+
if (!Model.GsxVolumeControl && (!(SimConnect.ReadLvar("I_FCU_TRACK_FPA_MODE") == 1 || SimConnect.ReadLvar("I_FCU_HEADING_VS_MODE") == 1)))
201+
{
202+
ResetAudio();
203+
return;
204+
}
205+
206+
float volume = SimConnect.ReadLvar("A_ASP_VHF_1_VOLUME");
207+
int muted = (int)SimConnect.ReadLvar("I_ASP_VHF_1_REC");
208+
if (volume >= 0 && volume != vhf1AudioVolume)
209+
{
210+
vhf1AudioSession.SimpleAudioVolume.MasterVolume = volume;
211+
vhf1AudioVolume = volume;
212+
}
213+
214+
if (muted >= 0 && muted != vhf1AudioMute)
215+
{
216+
vhf1AudioSession.SimpleAudioVolume.Mute = muted == 0;
217+
vhf1AudioMute = muted;
218+
}
160219
}
161220
}
162221

@@ -402,7 +461,7 @@ public void RunServices()
402461
{
403462
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Preparing for Pushback - removing Equipment");
404463
int departState = (int)SimConnect.ReadLvar("FSDT_GSX_DEPARTURE_STATE");
405-
if (SimConnect.ReadLvar("FSDT_GSX_JETWAY") != 2 && departState < 4)
464+
if (departState < 4 && SimConnect.ReadLvar("FSDT_GSX_JETWAY") != 2 && SimConnect.ReadLvar("FSDT_GSX_JETWAY") == 5 && SimConnect.ReadLvar("FSDT_GSX_OPERATEJETWAYS_STATE") < 3)
406465
{
407466
MenuOpen();
408467
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Removing Jetway");
@@ -595,21 +654,21 @@ private void CallJetwayStairs()
595654
{
596655
MenuOpen();
597656

598-
if (SimConnect.ReadLvar("FSDT_GSX_JETWAY") != 2)
657+
if (SimConnect.ReadLvar("FSDT_GSX_JETWAY") != 2 && SimConnect.ReadLvar("FSDT_GSX_JETWAY") != 5 && SimConnect.ReadLvar("FSDT_GSX_OPERATEJETWAYS_STATE") < 3)
599658
{
600659
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Calling Jetway");
601660
MenuItem(6);
602661
OperatorSelection();
603662

604-
if (SimConnect.ReadLvar("FSDT_GSX_STAIRS") != 2)
663+
if (SimConnect.ReadLvar("FSDT_GSX_STAIRS") != 2 && SimConnect.ReadLvar("FSDT_GSX_STAIRS") != 5 && SimConnect.ReadLvar("FSDT_GSX_OPERATESTAIRS_STATE") < 3)
605664
{
606665
Thread.Sleep(1500);
607666
MenuOpen();
608667
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Calling Stairs");
609668
MenuItem(7);
610669
}
611670
}
612-
else
671+
else if (SimConnect.ReadLvar("FSDT_GSX_STAIRS") != 5 && SimConnect.ReadLvar("FSDT_GSX_OPERATESTAIRS_STATE") < 3)
613672
{
614673
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Calling Stairs");
615674
MenuItem(7);

Fenix2GSX/MainWindow.xaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
66
xmlns:local="clr-namespace:Fenix2GSX"
77
mc:Ignorable="d"
8-
Title="Fenix2GSX" Height="577" Width="486" ResizeMode="NoResize" IsVisibleChanged="Window_IsVisibleChanged" Closing="Window_Closing">
8+
Title="Fenix2GSX" Height="600" Width="516" ResizeMode="NoResize" IsVisibleChanged="Window_IsVisibleChanged" Closing="Window_Closing">
99
<Grid>
1010
<Grid.RowDefinitions>
1111
<RowDefinition Height="64"/>
12-
<RowDefinition Height="352" />
12+
<RowDefinition Height="384" />
1313
<RowDefinition Height="*" />
1414
</Grid.RowDefinitions>
1515

@@ -37,15 +37,20 @@
3737
<CheckBox Name="chkAutoDeboard" Margin="8,8,8,0" VerticalContentAlignment="Center" Click="chkAutoDeboard_Click">Automatically start Deboarding on Arrival</CheckBox>
3838
<StackPanel Orientation="Horizontal" Margin="5,8,8,8" VerticalAlignment="Center" Height="26">
3939
<Label VerticalContentAlignment="Center" HorizontalContentAlignment="Center">Reposition Delay</Label>
40-
<TextBox Name="txtRepositionDelay" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Width="64" LostFocus="txtRepositionDelay_LostFocus"></TextBox>
40+
<TextBox Name="txtRepositionDelay" Margin="2,0,0,0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Width="64" LostFocus="txtRepositionDelay_LostFocus"></TextBox>
4141
<Label VerticalContentAlignment="Center" HorizontalContentAlignment="Center">s</Label>
4242
</StackPanel>
4343
<StackPanel Orientation="Horizontal" Margin="5,0,8,8" VerticalAlignment="Center" Height="26">
4444
<Label VerticalContentAlignment="Center" HorizontalContentAlignment="Center">Refuel Rate</Label>
45-
<TextBox Name="txtRefuelRate" Margin="29,0,0,0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Width="64" LostFocus="txtRefuelRate_LostFocus"></TextBox>
45+
<TextBox Name="txtRefuelRate" Margin="31,0,0,0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Width="64" LostFocus="txtRefuelRate_LostFocus"></TextBox>
4646
<RadioButton Name="unitKGS" Margin="5,0,0,0" VerticalAlignment="Center" VerticalContentAlignment="Center" Click="units_Click">kg/s</RadioButton>
4747
<RadioButton Name="unitLBS" Margin="8,0,0,0" VerticalAlignment="Center" VerticalContentAlignment="Center" Click="units_Click">lbs/s</RadioButton>
4848
</StackPanel>
49+
<StackPanel Orientation="Horizontal" Margin="5,0,8,8" VerticalAlignment="Center" Height="26">
50+
<Label VerticalContentAlignment="Center" HorizontalContentAlignment="Center">VHF1 App Name</Label>
51+
<TextBox Name="txtVhf1VolumeApp" Margin="2,0,0,0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Width="64" LostFocus="txtVhf1VolumeApp_LostFocus"></TextBox>
52+
<Label VerticalContentAlignment="Center" HorizontalContentAlignment="Center"> (Volume controlled via VHF1 on ACP1. Needs Restart.)</Label>
53+
</StackPanel>
4954
</StackPanel>
5055
</Border>
5156
<Border Grid.Row="2" BorderBrush="DarkGray" BorderThickness="1" Margin="10,8,10,10" Grid.ColumnSpan="2">

Fenix2GSX/MainWindow.xaml.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,15 @@ protected void LoadSettings()
5151
unitKGS.IsChecked = false;
5252
unitLBS.IsChecked = true;
5353
}
54+
txtVhf1VolumeApp.Text = serviceModel.Vhf1VolumeApp;
5455
}
5556

5657
protected void UpdateLogArea()
5758
{
5859
while (Logger.MessageQueue.Count > 0)
5960
{
6061

61-
if (lineCounter > 3)
62+
if (lineCounter > 4)
6263
txtLogMessages.Text = txtLogMessages.Text[(txtLogMessages.Text.IndexOf('\n') + 1)..];
6364
txtLogMessages.Text += Logger.MessageQueue.Dequeue().ToString() + "\n";
6465
lineCounter++;
@@ -182,6 +183,12 @@ private void txtRefuelRate_LostFocus(object sender, RoutedEventArgs e)
182183
serviceModel.SetSetting("refuelRate", Convert.ToString(txtRefuelRate.Text, CultureInfo.InvariantCulture));
183184
}
184185

186+
private void txtVhf1VolumeApp_LostFocus(object sender, RoutedEventArgs e)
187+
{
188+
if (!string.IsNullOrEmpty(txtVhf1VolumeApp.Text))
189+
serviceModel.SetSetting("vhf1VolumeApp", txtVhf1VolumeApp.Text);
190+
}
191+
185192
private void units_Click(object sender, RoutedEventArgs e)
186193
{
187194
if (!float.TryParse(txtRefuelRate.Text, CultureInfo.InvariantCulture, out float fuelRate))

Fenix2GSX/ServiceModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class ServiceModel
1717
public bool WaitForConnect { get; set; }
1818
public bool TestArrival { get; set; }
1919
public bool GsxVolumeControl { get; set; }
20+
public string Vhf1VolumeApp { get; set; }
2021
public bool DisableCrew { get; set; }
2122
public bool RepositionPlane { get; set; }
2223
public float RepositionDelay { get; set; }
@@ -47,6 +48,7 @@ protected void LoadConfiguration()
4748
WaitForConnect = Convert.ToBoolean(settings["waitForConnect"].Value);
4849
TestArrival = Convert.ToBoolean(settings["testArrival"].Value);
4950
GsxVolumeControl = Convert.ToBoolean(settings["gsxVolumeControl"].Value);
51+
Vhf1VolumeApp = Convert.ToString(settings["vhf1VolumeApp"].Value);
5052
DisableCrew = Convert.ToBoolean(settings["disableCrew"].Value);
5153
RepositionPlane = Convert.ToBoolean(settings["repositionPlane"].Value);
5254
RepositionDelay = Convert.ToSingle(settings["repositionDelay"].Value, CultureInfo.InvariantCulture);

0 commit comments

Comments
 (0)