Skip to content

Commit bc8e2b4

Browse files
committed
Reposition Delay configurable / Deboarding fixed (finally?!)
1 parent 97b2990 commit bc8e2b4

File tree

8 files changed

+73
-58
lines changed

8 files changed

+73
-58
lines changed

Fenix2GSX/App.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<add key="gsxVolumeControl" value="true" />
1010
<add key="disableCrew" value="true" />
1111
<add key="repositionPlane" value="true" />
12+
<add key="repositionDelay" value="3" />
1213
<add key="autoConnect" value="true" />
1314
<add key="operatorDelay" value="10" />
1415
<add key="connectPCA" value="true" />

Fenix2GSX/Fenix2GSX.csproj

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
</ItemGroup>
3333

3434
<ItemGroup>
35-
<PackageReference Include="CefSharp.OffScreen.NETCore" Version="111.2.20" />
35+
<PackageReference Include="CefSharp.OffScreen.NETCore" Version="111.2.70" />
3636
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
3737
<PackageReference Include="CoreAudio" Version="1.27.0" />
38-
<PackageReference Include="H.NotifyIcon.Wpf" Version="2.0.104" />
38+
<PackageReference Include="H.NotifyIcon.Wpf" Version="2.0.108" />
3939
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
4040
<PackageReference Include="Serilog" Version="2.12.0" />
4141
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
@@ -56,4 +56,16 @@
5656
</None>
5757
</ItemGroup>
5858

59+
<ItemGroup>
60+
<PackageReference Update="chromiumembeddedframework.runtime.win-arm64" Version="111.2.7" />
61+
</ItemGroup>
62+
63+
<ItemGroup>
64+
<PackageReference Update="chromiumembeddedframework.runtime.win-x64" Version="111.2.7" />
65+
</ItemGroup>
66+
67+
<ItemGroup>
68+
<PackageReference Update="chromiumembeddedframework.runtime.win-x86" Version="111.2.7" />
69+
</ItemGroup>
70+
5971
</Project>

Fenix2GSX/FenixController.cs

Lines changed: 36 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -173,40 +173,29 @@ public bool Boarding(int paxCurrent, int cargoCurrent)
173173

174174
private void BoardPassengers(int num)
175175
{
176-
if (num <= 0)
176+
if (num < 0)
177177
{
178-
Logger.Log(LogLevel.Warning, "FenixContoller:BoardPassengers", $"Passenger Num was below 0!");
178+
Logger.Log(LogLevel.Debug, "FenixContoller:BoardPassengers", $"Passenger Num was below 0!");
179179
return;
180180
}
181181

182-
//if (onboard)
183-
//{
184-
for (int i = paxLast; i < paxLast + num && i < GetPaxPlanned(); i++)
185-
{
186-
paxCurrent[paxSeats[i]] = true;
187-
}
188-
//}
189-
//else
190-
//{
191-
// int n = GetPaxPlanned() - paxLast;
192-
// Logger.Log(LogLevel.Debug, "FenixContoller:ChangePassengers", $"(n {n})");
193-
// for (int i = n; i < n + num; i++)
194-
// {
195-
// Logger.Log(LogLevel.Debug, "FenixContoller:ChangePassengers", $"(i {i}) (seatslen {paxSeats.Length}) (curlen {paxCurrent.Length}) (num {num}) (paxlast {paxLast}) (planned {GetPaxPlanned()})");
196-
// if (i < paxSeats.Length && paxSeats[i] < paxCurrent.Length)
197-
// paxCurrent[paxSeats[i]] = onboard;
198-
// else
199-
// Logger.Log(LogLevel.Debug, "FenixContoller:ChangePassengers", $"invalid index (i {i}) (seatslen {paxSeats.Length}) (curlen {paxCurrent.Length}) (num {num}) (paxlast {paxLast}) (planned {GetPaxPlanned()})");
200-
// }
201-
//}
202-
203-
SendSeatString();
182+
for (int i = paxLast; i < paxLast + num && i < GetPaxPlanned(); i++)
183+
{
184+
paxCurrent[paxSeats[i]] = true;
185+
}
186+
187+
if (num > 0)
188+
SendSeatString();
204189
}
205190

206-
private void SendSeatString()
191+
private void SendSeatString(bool force = false)
207192
{
208193
string seatString = "";
209194
bool first = true;
195+
196+
if (GetPaxCurrent() == 0 && !force)
197+
return;
198+
210199
foreach (var pax in paxCurrent)
211200
{
212201
if (first)
@@ -248,43 +237,40 @@ public void BoardingStop()
248237

249238
public void DeboardingStart()
250239
{
240+
Logger.Log(LogLevel.Debug, "FenixContoller:DeboardingStart", $"(planned {GetPaxPlanned()}) (current {GetPaxCurrent()})");
251241
paxLast = GetPaxPlanned();
252-
cargoLast = 100;
253-
paxSeats = new int[paxLast];
254-
int n = 0;
255-
for (int i = 0; i < paxPlanned.Length; i++)
256-
{
257-
if (paxPlanned[i])
258-
{
259-
paxSeats[n] = i;
260-
n++;
261-
}
262-
}
242+
if (GetPaxCurrent() != GetPaxPlanned())
243+
paxCurrent = paxPlanned;
244+
cargoLast = 100;
263245
}
264246

265247
private void DeboardPassengers(int num)
266248
{
267-
if (num <= 0)
249+
if (num < 0)
268250
{
269-
Logger.Log(LogLevel.Warning, "FenixContoller:DeboardPassengers", $"Passenger Num was below 0!");
251+
Logger.Log(LogLevel.Debug, "FenixContoller:DeboardPassengers", $"Passenger Num was below 0!");
270252
return;
271253
}
254+
else if (num > 15)
255+
{
256+
Logger.Log(LogLevel.Debug, "FenixContoller:DeboardPassengers", $"Passenger Num was above 15!");
257+
return;
258+
}
259+
else
260+
Logger.Log(LogLevel.Debug, "FenixContoller:DeboardPassengers", $"(num {num}) (current {GetPaxCurrent()}) (planned ({GetPaxPlanned()}))");
272261

273262
int n = 0;
274-
while (n < num)
263+
for (int i = 0; i < paxCurrent.Length && n < num; i++)
275264
{
276-
for (int i = 0; i < paxCurrent.Length; i++)
265+
if (paxCurrent[i])
277266
{
278-
if (paxCurrent[i])
279-
{
280-
paxCurrent[i] = false;
281-
break;
282-
}
267+
paxCurrent[i] = false;
268+
n++;
283269
}
284-
n++;
285270
}
286271

287-
SendSeatString();
272+
if (n > 0)
273+
SendSeatString();
288274
}
289275

290276
public bool Deboarding(int paxCurrent, int cargoCurrent)
@@ -304,7 +290,9 @@ public void DeboardingStop()
304290
ChangeCargo(0);
305291
for (int i = 0; i < paxCurrent.Length; i++)
306292
paxCurrent[i] = false;
307-
SendSeatString();
293+
Logger.Log(LogLevel.Debug, "FenixController:DeboardingStop", "Sending SeatString");
294+
SendSeatString(true);
295+
paxCurrent = new bool[162];
308296
paxSeats = null;
309297
}
310298
}

Fenix2GSX/GsxController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ public void RunServices()
185185

186186
if (Model.RepositionPlane && !planePositioned)
187187
{
188-
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Waiting 5s before Repositioning ...");
188+
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Waiting {Model.RepositionDelay}s before Repositioning ...");
189189
FenixController.SetServiceChocks(true);
190-
Thread.Sleep(5000);
190+
Thread.Sleep((int)(Model.RepositionDelay * 1000.0f));
191191
Logger.Log(LogLevel.Information, "GsxController:RunServices", $"Repositioning Plane");
192192
MenuOpen();
193193
MenuItem(10);

Fenix2GSX/Logger.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public static void Log(LogLevel level, string context, string message)
4343
Serilog.Log.Logger.Debug(entry);
4444
break;
4545
}
46-
MessageQueue.Enqueue(message);
46+
if (level != LogLevel.Debug)
47+
MessageQueue.Enqueue(message);
4748
}
4849
}
4950
}

Fenix2GSX/MainWindow.xaml

Lines changed: 8 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="532" Width="486" ResizeMode="NoResize" IsVisibleChanged="Window_IsVisibleChanged" Closing="Window_Closing">
8+
Title="Fenix2GSX" Height="577" Width="486" ResizeMode="NoResize" IsVisibleChanged="Window_IsVisibleChanged" Closing="Window_Closing">
99
<Grid>
1010
<Grid.RowDefinitions>
1111
<RowDefinition Height="64"/>
12-
<RowDefinition Height="316" />
12+
<RowDefinition Height="352" />
1313
<RowDefinition Height="*" />
1414
</Grid.RowDefinitions>
1515

@@ -36,11 +36,15 @@
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>
3838
<StackPanel Orientation="Horizontal" Margin="5,8,8,8" VerticalAlignment="Center" Height="26">
39+
<Label VerticalContentAlignment="Center" HorizontalContentAlignment="Center">Reposition Delay</Label>
40+
<TextBox Name="txtRepositionDelay" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Width="64" LostFocus="txtRepositionDelay_LostFocus"></TextBox>
41+
<Label VerticalContentAlignment="Center" HorizontalContentAlignment="Center">s</Label>
42+
</StackPanel>
43+
<StackPanel Orientation="Horizontal" Margin="5,0,8,8" VerticalAlignment="Center" Height="26">
3944
<Label VerticalContentAlignment="Center" HorizontalContentAlignment="Center">Refuel Rate</Label>
40-
<TextBox Name="txtRefuelRate" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Width="64" LostFocus="txtRefuelRate_LostFocus"></TextBox>
45+
<TextBox Name="txtRefuelRate" Margin="29,0,0,0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Width="64" LostFocus="txtRefuelRate_LostFocus"></TextBox>
4146
<RadioButton Name="unitKGS" Margin="5,0,0,0" VerticalAlignment="Center" VerticalContentAlignment="Center" Click="units_Click">kg/s</RadioButton>
4247
<RadioButton Name="unitLBS" Margin="8,0,0,0" VerticalAlignment="Center" VerticalContentAlignment="Center" Click="units_Click">lbs/s</RadioButton>
43-
<!--<Label VerticalContentAlignment="Center" HorizontalContentAlignment="Center">kg/s</Label>-->
4448
</StackPanel>
4549
</StackPanel>
4650
</Border>

Fenix2GSX/MainWindow.xaml.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ protected void LoadSettings()
3939
chkCallCatering.IsChecked = serviceModel.CallCatering;
4040
chkAutoBoard.IsChecked = serviceModel.AutoBoarding;
4141
chkAutoDeboard.IsChecked = serviceModel.AutoDeboarding;
42+
txtRepositionDelay.Text = serviceModel.RepositionDelay.ToString(CultureInfo.InvariantCulture);
4243
txtRefuelRate.Text = serviceModel.RefuelRate.ToString(CultureInfo.InvariantCulture);
4344
if (serviceModel.RefuelUnit == "KGS")
4445
{
@@ -71,7 +72,7 @@ protected void UpdateStatus()
7172
else
7273
lblConnStatMSFS.Foreground = new SolidColorBrush(Colors.Red);
7374

74-
if (IPCManager.SimConnect.IsReady)
75+
if (IPCManager.SimConnect != null && IPCManager.SimConnect.IsReady)
7576
lblConnStatSimConnect.Foreground = new SolidColorBrush(Colors.DarkGreen);
7677
else
7778
lblConnStatSimConnect.Foreground = new SolidColorBrush(Colors.Red);
@@ -169,6 +170,12 @@ private void chkAutoDeboard_Click(object sender, RoutedEventArgs e)
169170
serviceModel.SetSetting("autoDeboarding", chkAutoDeboard.IsChecked.ToString().ToLower());
170171
}
171172

173+
private void txtRepositionDelay_LostFocus(object sender, RoutedEventArgs e)
174+
{
175+
if (float.TryParse(txtRepositionDelay.Text, CultureInfo.InvariantCulture, out _))
176+
serviceModel.SetSetting("repositionDelay", Convert.ToString(txtRepositionDelay.Text, CultureInfo.InvariantCulture));
177+
}
178+
172179
private void txtRefuelRate_LostFocus(object sender, RoutedEventArgs e)
173180
{
174181
if (float.TryParse(txtRefuelRate.Text, CultureInfo.InvariantCulture, out _))

Fenix2GSX/ServiceModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class ServiceModel
1919
public bool GsxVolumeControl { get; set; }
2020
public bool DisableCrew { get; set; }
2121
public bool RepositionPlane { get; set; }
22+
public float RepositionDelay { get; set; }
2223
public bool AutoConnect { get; set; }
2324
public float OperatorDelay { get; set; }
2425
public bool ConnectPCA { get; set; }
@@ -48,6 +49,7 @@ protected void LoadConfiguration()
4849
GsxVolumeControl = Convert.ToBoolean(settings["gsxVolumeControl"].Value);
4950
DisableCrew = Convert.ToBoolean(settings["disableCrew"].Value);
5051
RepositionPlane = Convert.ToBoolean(settings["repositionPlane"].Value);
52+
RepositionDelay = Convert.ToSingle(settings["repositionDelay"].Value, CultureInfo.InvariantCulture);
5153
AutoConnect = Convert.ToBoolean(settings["autoConnect"].Value);
5254
OperatorDelay = Convert.ToSingle(settings["operatorDelay"].Value, CultureInfo.InvariantCulture);
5355
ConnectPCA = Convert.ToBoolean(settings["connectPCA"].Value);

0 commit comments

Comments
 (0)