Skip to content

Commit 7da91b4

Browse files
committed
Workarounds removed / Further optimisations
1 parent b72d0b2 commit 7da91b4

10 files changed

+86
-70
lines changed

Fenix2GSX/App.xaml.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ protected override void OnStartup(StartupEventArgs e)
3030
Controller = new(Model);
3131
Task.Run(Controller.Run);
3232

33-
var timer = new DispatcherTimer();
34-
timer.Interval = TimeSpan.FromSeconds(1);
33+
var timer = new DispatcherTimer
34+
{
35+
Interval = TimeSpan.FromSeconds(1)
36+
};
3537
timer.Tick += OnTick;
3638
timer.Start();
3739

@@ -91,10 +93,8 @@ protected void InitCef()
9193

9294
public Icon GetIcon(string filename)
9395
{
94-
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"Fenix2GSX.{filename}"))
95-
{
96-
return new Icon(stream);
97-
}
96+
using var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"Fenix2GSX.{filename}");
97+
return new Icon(stream);
9898
}
9999
}
100100
}

Fenix2GSX/Fenix2GSX.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>WinExe</OutputType>
5-
<TargetFramework>net7.0-windows</TargetFramework>
5+
<TargetFramework>net7.0-windows10.0.17763.0</TargetFramework>
66
<Nullable>disable</Nullable>
77
<UseWPF>true</UseWPF>
88
<StartupObject>Fenix2GSX.App</StartupObject>

Fenix2GSX/FenixController.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void Update(bool forceCurrent)
4545

4646
string str = Interface.FenixGetVariable("fenix.efb.loadingStatus");
4747
if (!string.IsNullOrWhiteSpace(str))
48-
int.TryParse(str.Substring(1), out cargoPlanned);
48+
int.TryParse(str[1..], out cargoPlanned);
4949

5050
JObject result = JObject.Parse(Interface.FenixGet(FenixInterface.MsgQuery("fenix.efb.passengers.booked", "queryResult")));
5151
paxPlanned = result["data"]["dataRef"]["queryResult"]["value"].ToObject<bool[]>();
@@ -136,10 +136,10 @@ public bool Refuel()
136136
return fuelCurrent == fuelPlanned;
137137
}
138138

139-
public void RefuelStop()
140-
{
139+
//public void RefuelStop()
140+
//{
141141

142-
}
142+
//}
143143

144144
public void BoardingStart()
145145
{

Fenix2GSX/GlobalSuppressions.cs

+4
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@
88
[assembly: SuppressMessage("Style", "IDE1006:Benennungsstile")]
99
[assembly: SuppressMessage("Style", "IDE0044:Modifizierer \"readonly\" hinzufügen")]
1010
[assembly: SuppressMessage("Performance", "CA1822:Member als statisch markieren", Justification = "<Ausstehend>", Scope = "member", Target = "~M:Fenix2GSX.NotifyIconViewModel.ExitApplication")]
11+
[assembly: SuppressMessage("Performance", "CA1822:Member als statisch markieren", Justification = "<Ausstehend>", Scope = "member", Target = "~M:Fenix2GSX.MobiSimConnect.SimConnect_OnException(Microsoft.FlightSimulator.SimConnect.SimConnect,Microsoft.FlightSimulator.SimConnect.SIMCONNECT_RECV_EXCEPTION)")]
12+
[assembly: SuppressMessage("Performance", "CA1822:Member als statisch markieren", Justification = "<Ausstehend>", Scope = "member", Target = "~M:Fenix2GSX.App.InitCef")]
13+
[assembly: SuppressMessage("Performance", "CA1822:Member als statisch markieren", Justification = "<Ausstehend>", Scope = "member", Target = "~M:Fenix2GSX.App.GetIcon(System.String)~System.Drawing.Icon")]
14+
[assembly: SuppressMessage("Performance", "CA1806:Methodenergebnisse nicht ignorieren")]

Fenix2GSX/GsxController.cs

+53-43
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ public void RunServices()
176176
if (Model.RepositionPlane && !planePositioned)
177177
{
178178
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Waiting 5s before Repositioning ...");
179+
FenixController.SetServiceChocks(true);
179180
Thread.Sleep(5000);
180181
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Repositioning Plane");
181182
MenuOpen();
@@ -276,6 +277,7 @@ public void RunServices()
276277
else
277278
{
278279
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Calling Boarding Service");
280+
SetPassengers(FenixController.GetPaxPlanned());
279281
MenuOpen();
280282
MenuItem(4);
281283
delayCounter = 0;
@@ -307,7 +309,7 @@ public void RunServices()
307309
refueling = false;
308310
refuelFinished = true;
309311
refuelPaused = false;
310-
FenixController.RefuelStop();
312+
//FenixController.RefuelStop();
311313
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Refuel completed");
312314
}
313315
}
@@ -329,7 +331,7 @@ public void RunServices()
329331
}
330332
else if (boarding)
331333
{
332-
if (FenixController.Boarding((int)SimConnect.ReadLvar("FSDT_GSX_NUMPASSENGERS_BOARDING_TOTAL"), (int)SimConnect.ReadLvar("FSDT_GSX_BOARDING_CARGO_PERCENT")))
334+
if (FenixController.Boarding((int)SimConnect.ReadLvar("FSDT_GSX_NUMPASSENGERS_BOARDING_TOTAL"), (int)SimConnect.ReadLvar("FSDT_GSX_BOARDING_CARGO_PERCENT")) || SimConnect.ReadLvar("FSDT_GSX_BOARDING_STATE") == 6)
333335
{
334336
boarding = false;
335337
boardFinished = true;
@@ -372,12 +374,12 @@ public void RunServices()
372374
{
373375
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Preparing for Pushback - removing Equipment");
374376
//WORKAROUND
375-
//if (SimConnect.ReadLvar("FSDT_GSX_JETWAY") != 2)
376-
//{
377+
if (SimConnect.ReadLvar("FSDT_GSX_JETWAY") != 2)
378+
{
377379
MenuOpen();
378380
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Removing Jetway");
379381
MenuItem(6);
380-
//}
382+
}
381383
FenixController.SetServiceChocks(false);
382384
FenixController.SetServicePCA(false);
383385
FenixController.SetServiceGPU(false);
@@ -467,6 +469,7 @@ public void RunServices()
467469
if (Model.AutoDeboarding && deboard_state < 4)
468470
{
469471
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Calling Deboarding Service");
472+
SetPassengers(FenixController.GetPaxPlanned());
470473
MenuOpen();
471474
MenuItem(1);
472475
if (!Model.AutoConnect)
@@ -538,52 +541,59 @@ private void SetPassengers(int numPax)
538541
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Passenger Count set to {numPax}");
539542
if (Model.DisableCrew)
540543
{
544+
SimConnect.WriteLvar("FSDT_GSX_CREW_NOT_DEBOARDING", 1);
545+
SimConnect.WriteLvar("FSDT_GSX_CREW_NOT_BOARDING", 1);
546+
SimConnect.WriteLvar("FSDT_GSX_PILOTS_NOT_DEBOARDING", 1);
547+
SimConnect.WriteLvar("FSDT_GSX_PILOTS_NOT_BOARDING", 1);
548+
SimConnect.WriteLvar("FSDT_GSX_NUMCREW", 0);
549+
SimConnect.WriteLvar("FSDT_GSX_NUMPILOTS", 0);
550+
SimConnect.WriteLvar("FSDT_GSX_CREW_ON_BOARD", 1);
541551
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Crew Boarding disabled");
542552
}
543553
}
544554

545-
//private void CallJetwayStairs()
546-
//{
547-
// MenuOpen();
548-
549-
// if (SimConnect.ReadLvar("FSDT_GSX_JETWAY") != 2)
550-
// {
551-
// Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Calling Jetway");
552-
// MenuItem(6);
553-
// OperatorSelection();
554-
// //if (useDelay)
555-
// // OperatorDelay();
556-
557-
// if (SimConnect.ReadLvar("FSDT_GSX_STAIRS") != 2)
558-
// {
559-
// Thread.Sleep(1500);
560-
// MenuOpen();
561-
// Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Calling Stairs");
562-
// MenuItem(7);
563-
// }
564-
// }
565-
// else
566-
// {
567-
// Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Calling Stairs");
568-
// MenuItem(7);
569-
// OperatorSelection();
570-
// //if (useDelay)
571-
// // OperatorDelay();
572-
// }
573-
//}
574-
//WORKAROUND
575555
private void CallJetwayStairs()
576556
{
577-
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Calling Jetway");
578-
MenuOpen();
579-
MenuItem(6);
580-
OperatorSelection();
581-
Thread.Sleep(3000);
582-
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Calling Stairs");
583557
MenuOpen();
584-
MenuItem(7);
585-
OperatorSelection();
558+
559+
if (SimConnect.ReadLvar("FSDT_GSX_JETWAY") != 2)
560+
{
561+
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Calling Jetway");
562+
MenuItem(6);
563+
OperatorSelection();
564+
//if (useDelay)
565+
// OperatorDelay();
566+
567+
if (SimConnect.ReadLvar("FSDT_GSX_STAIRS") != 2)
568+
{
569+
Thread.Sleep(1500);
570+
MenuOpen();
571+
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Calling Stairs");
572+
MenuItem(7);
573+
}
574+
}
575+
else
576+
{
577+
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Calling Stairs");
578+
MenuItem(7);
579+
OperatorSelection();
580+
//if (useDelay)
581+
// OperatorDelay();
582+
}
586583
}
584+
//WORKAROUND
585+
//private void CallJetwayStairs()
586+
//{
587+
// Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Calling Jetway");
588+
// MenuOpen();
589+
// MenuItem(6);
590+
// OperatorSelection();
591+
// Thread.Sleep(3000);
592+
// Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Calling Stairs");
593+
// MenuOpen();
594+
// MenuItem(7);
595+
// OperatorSelection();
596+
//}
587597

588598
private void OperatorSelection()
589599
{

Fenix2GSX/IPCManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static bool WaitForConnection(ServiceModel model)
7171
}
7272
else
7373
{
74-
Logger.Log(LogLevel.Information, "IPCManager:WaitForConnection", $"{model.FenixExecutable} is running");
74+
Logger.Log(LogLevel.Information, "IPCManager:WaitForConnection", $"SimConnect is opened");
7575
return true;
7676
}
7777
}

Fenix2GSX/MainWindow.xaml

+4-4
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="548" Width="486" ShowInTaskbar="False" ResizeMode="NoResize" IsVisibleChanged="Window_IsVisibleChanged" Closing="Window_Closing">
8+
Title="Fenix2GSX" Height="532" Width="486" ShowInTaskbar="False" ResizeMode="NoResize" IsVisibleChanged="Window_IsVisibleChanged" Closing="Window_Closing">
99
<Grid>
1010
<Grid.RowDefinitions>
1111
<RowDefinition Height="64"/>
12-
<RowDefinition Height="348" />
12+
<RowDefinition Height="316" />
1313
<RowDefinition Height="*" />
1414
</Grid.RowDefinitions>
1515

@@ -35,11 +35,11 @@
3535
<CheckBox Name="chkCallCatering" Margin="8,8,8,0" VerticalContentAlignment="Center" Click="chkCallCatering_Click">Call Catering Service with Refuel Service</CheckBox>
3636
<CheckBox Name="chkAutoBoard" Margin="8,8,8,0" VerticalContentAlignment="Center" Click="chkAutoBoard_Click">Automatically start Boarding when Refuel and Catering are finished</CheckBox>
3737
<CheckBox Name="chkAutoDeboard" Margin="8,8,8,0" VerticalContentAlignment="Center" Click="chkAutoDeboard_Click">Automatically start Deboarding on Arrival</CheckBox>
38-
<StackPanel Orientation="Horizontal" Margin="5,8,8,0" VerticalAlignment="Center" Height="26">
38+
<!--<StackPanel Orientation="Horizontal" Margin="5,8,8,0" VerticalAlignment="Center" Height="26">
3939
<Label VerticalContentAlignment="Center" HorizontalContentAlignment="Center">Operator Delay</Label>
4040
<TextBox Name="txtOperatorDelay" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Width="64" LostFocus="txtOperatorDelay_LostFocus"></TextBox>
4141
<Label VerticalContentAlignment="Center" HorizontalContentAlignment="Center">s</Label>
42-
</StackPanel>
42+
</StackPanel>-->
4343
<StackPanel Orientation="Horizontal" Margin="5,8,8,8" VerticalAlignment="Center" Height="26">
4444
<Label VerticalContentAlignment="Center" HorizontalContentAlignment="Center">Refuel Rate</Label>
4545
<TextBox Name="txtRefuelRate" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Width="64" LostFocus="txtRefuelRate_LostFocus"></TextBox>

Fenix2GSX/MainWindow.xaml.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected void LoadSettings()
3333
chkDisableCrewBoarding.IsChecked = serviceModel.DisableCrew;
3434
chkAutoReposition.IsChecked = serviceModel.RepositionPlane;
3535
chkAutoConnect.IsChecked = serviceModel.AutoConnect;
36-
txtOperatorDelay.Text = Convert.ToString(serviceModel.OperatorDelay, CultureInfo.InvariantCulture);
36+
//txtOperatorDelay.Text = Convert.ToString(serviceModel.OperatorDelay, CultureInfo.InvariantCulture);
3737
chkConnectPCA.IsChecked = serviceModel.ConnectPCA;
3838
chkPcaOnlyJetway.IsChecked = serviceModel.PcaOnlyJetways;
3939
chkAutoRefuel.IsChecked = serviceModel.AutoRefuel;
@@ -160,11 +160,11 @@ private void chkAutoDeboard_Click(object sender, RoutedEventArgs e)
160160
serviceModel.SetSetting("autoDeboarding", chkAutoDeboard.IsChecked.ToString().ToLower());
161161
}
162162

163-
private void txtOperatorDelay_LostFocus(object sender, RoutedEventArgs e)
164-
{
165-
if (float.TryParse(txtOperatorDelay.Text, CultureInfo.InvariantCulture, out _))
166-
serviceModel.SetSetting("operatorDelay", Convert.ToString(txtOperatorDelay.Text, CultureInfo.InvariantCulture));
167-
}
163+
//private void txtOperatorDelay_LostFocus(object sender, RoutedEventArgs e)
164+
//{
165+
// if (float.TryParse(txtOperatorDelay.Text, CultureInfo.InvariantCulture, out _))
166+
// serviceModel.SetSetting("operatorDelay", Convert.ToString(txtOperatorDelay.Text, CultureInfo.InvariantCulture));
167+
//}
168168

169169
private void txtRefuelRate_LostFocus(object sender, RoutedEventArgs e)
170170
{

Fenix2GSX/NotifyIconResources.xaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
<tb:TaskbarIcon
2828
x:Key="NotifyIcon"
29-
ToolTipText="Left-click to show window, right-click for menu"
29+
ToolTipText="Left-click to show Window, Right-click for Menu"
3030
LeftClickCommand="{Binding ShowWindowCommand}"
3131
NoLeftClickDelay="True"
3232
ContextMenu="{StaticResource SysTrayMenu}">

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Full GSX Integration and Automation for the Fenix A320!
33
<br/><br/>
44

55
## Requirements
6+
- Windows 10/11
67
- [.NET 7](https://dotnet.microsoft.com/en-us/download/dotnet/7.0) x64 Runtime (Core + Desktop) installed & updated
78
- MobiFlight [WASM Module](https://github.com/MobiFlight/MobiFlight-WASM-Module/releases) installed
89
- MSFS, Fenix, GSX Pro :wink:
@@ -21,8 +22,8 @@ It may be blocked by Windows Security or your AV-Scanner, try if unblocking and/
2122
* **disableCrew** - Disable Crew boarding and deboarding.
2223
* **repositionPlane** - The Plane will be repositioned via GSX when you start your Session.
2324
* **autoConnect** - Automatically connect Jetway/Stairs on Startup and on Arrival.
24-
* **operatorDelay** - The Delay in Seconds the Tool will wait for the Ground Operator Selection
2525
* **connectPCA**" - The Preconditioned Air will be connected (and disconnected) on Startup and on Arrival.
26+
* **pcaOnlyJetway**" - The Preconditioned Air only connected on Jetways.
2627
* **autoRefuel** - Call Refueling automatically as soon as an Flightplan was imported on the EFB.
2728
* **callCatering** - Catering will be called when Refueling is called.
2829
* **autoBoarding**" - Automatically start Boarding when Refueling and Catering (if configured) are finished.
@@ -38,6 +39,7 @@ It may be blocked by Windows Security or your AV-Scanner, try if unblocking and/
3839
5) When Parking Brake is set, External Power disconnected (on the Overhead) and Beacon Light is On, the Tool will remove all Ground-Equipment: Jetway is disconnected, GPU and PCA (if configured) are removed, Chocks are removed.
3940
6) Happy Flight!
4041
7) When you arrive (on your preselected Gate), the Jetway/Stairs will automatically connect when the Engines are Off and the Parking Brake is set (if configured).
41-
8) When the Beacon Light is off, the other Ground-Equipment will placed: GPU, PCA (if configured) and Chocks. If configured, Deboarding will be called.
42-
9) It works with Turn-Arounds! As soon as you import a new Flightplan it will start over.
43-
42+
8) When the Beacon Light is off, the other Ground-Equipment will placed: GPU, PCA (if configured) and Chocks. If configured, Deboarding will be called. Calling Deboarding in the EFB is not required, you can dismiss it if you want.
43+
9) It works with Turn-Arounds! As soon as you (re)import a new Flightplan it will start over.
44+
<br/>
45+
If you set every Option for automatic Service Calls, you can also disable GSX in the Toolbar. The Services are still called, but you won't see the Menu. You should open it for Pushback though :sweat_smile:

0 commit comments

Comments
 (0)