Skip to content

Commit 0534863

Browse files
committed
FP check on Turn-Around directly and every 1m / FP check based on RequestID / Fix GSX L-Vars for Turn-Around / Reload SimBrief in GSX on Turn-Around (new FP)
1 parent d190235 commit 0534863

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
- Call GSX Refuel to fuel the Aircraft to the planned SimBrief Figures. Start the APU only after Refuel was completed.
3434
- Call GSX Boarding to board Passengers and load Cargo/Bag as planned in SimBrief
3535
- When arrived, call GSX Deboarding to unload the Plane
36-
- When Deboarding was finished, SimBrief will be checked for new FlightPlan after 5 Minutes (every 60 Seconds thereafter). If a new FlightPlan is found, you can call Refueling/Boarding again.
36+
- When Deboarding was finished, SimBrief will be checked for new FlightPlan. If none is found, it will re-check every 60 Seconds. If a new FlightPlan is found, you can call Refueling/Boarding again.
3737

3838
<br/>
3939

WorkingTitle2GSX-latest.zip

222 Bytes
Binary file not shown.

WorkingTitle2GSX/FlightPlan.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace WorkingTitle2GSX
99
public class FlightPlan
1010
{
1111
public string Flight { get; set; } = "";
12+
public string FlightPlanID { get; set; } = "";
1213
public string Origin { get; set; }
1314
public string Destination { get; set; }
1415
public string Units { get; set; }
@@ -72,8 +73,9 @@ protected XmlNode LoadOFP()
7273
public bool Load()
7374
{
7475
XmlNode sbOFP = LoadOFP();
75-
string lastFlight = Flight;
76+
string lastID = FlightPlanID;
7677
Flight = sbOFP["general"]["icao_airline"].InnerText + sbOFP["general"]["flight_number"].InnerText;
78+
FlightPlanID = sbOFP["params"]["request_id"].InnerText;
7779
Origin = sbOFP["origin"]["icao_code"].InnerText;
7880
Destination = sbOFP["destination"]["icao_code"].InnerText;
7981
Units = sbOFP["params"]["units"].InnerText;
@@ -92,12 +94,12 @@ public bool Load()
9294
WeightPax = Convert.ToDouble(sbOFP["weights"]["pax_weight"].InnerText, new RealInvariantFormat(sbOFP["weights"]["pax_weight"].InnerText));
9395
WeightBag = Convert.ToDouble(sbOFP["weights"]["bag_weight"].InnerText, new RealInvariantFormat(sbOFP["weights"]["bag_weight"].InnerText));
9496

95-
if (lastFlight != Flight && Model.AcIndentified == sbOFP["aircraft"]["name"].InnerText)
97+
if (lastID != FlightPlanID && Model.AcIndentified == sbOFP["aircraft"]["name"].InnerText)
9698
{
9799
Logger.Log(LogLevel.Information, "FlightPlan:Load", $"New OFP for Flight {Flight} loaded. ({Origin} -> {Destination})");
98100
}
99101

100-
return lastFlight != Flight;
102+
return lastID != FlightPlanID;
101103
}
102104

103105
public void SetPassengersGSX()

WorkingTitle2GSX/ServiceController.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ protected void ServiceLoop()
244244
{
245245
state = 4;
246246
sleep = 10000;
247+
ResetGsxVars();
247248
flightPlan.SetPassengersGSX();
248249

249250
Logger.Log(LogLevel.Information, "ServiceController:ServiceLoop", "Current State: Taxi In");
@@ -278,10 +279,8 @@ protected void ServiceLoop()
278279
{
279280
deboarding = false;
280281
aircraft.StopDeboarding();
281-
Logger.Log(LogLevel.Information, "ServiceController:ServiceLoop", "Current State: Turn-Around - Check for new OFP in 5 Minutes.");
282+
Logger.Log(LogLevel.Information, "ServiceController:ServiceLoop", "Current State: Turn-Around - Waiting for new OFP");
282283
state = 6;
283-
Thread.Sleep(240000);
284-
sleep = 60000;
285284
continue;
286285
}
287286
}
@@ -292,6 +291,13 @@ protected void ServiceLoop()
292291
{
293292
if (flightPlan.Load())
294293
{
294+
Logger.Log(LogLevel.Debug, "ServiceController:ServiceLoop", "Resetting GSX Vars");
295+
ResetGsxVars();
296+
Logger.Log(LogLevel.Debug, "ServiceController:ServiceLoop", "Import SimBrief to GSX");
297+
FSUIPCConnection.WriteLVar("FSDT_GSX_MENU_OPEN", 1);
298+
Thread.Sleep(2000);
299+
FSUIPCConnection.WriteLVar("FSDT_GSX_MENU_CHOICE", 14);
300+
Thread.Sleep(2000);
295301
flightPlan.SetPassengersGSX();
296302
aircraft.SetPayload(flightPlan);
297303
state = 1;
@@ -300,7 +306,10 @@ protected void ServiceLoop()
300306
continue;
301307
}
302308
else
309+
{
310+
sleep = 60000;
303311
Logger.Log(LogLevel.Information, "ServiceController:ServiceLoop", "No new OFP found - Retry in 60s.");
312+
}
304313
}
305314
}
306315
catch (Exception ex)
@@ -311,5 +320,13 @@ protected void ServiceLoop()
311320

312321
Logger.Log(LogLevel.Information, "ServiceController:ServiceLoop", "ServiceLoop ended");
313322
}
323+
324+
protected void ResetGsxVars()
325+
{
326+
FSUIPCConnection.WriteLVar("FSDT_GSX_NUMPASSENGERS_BOARDING_TOTAL", 0);
327+
FSUIPCConnection.WriteLVar("FSDT_GSX_NUMPASSENGERS_DEBOARDING_TOTAL", 0);
328+
FSUIPCConnection.WriteLVar("FSDT_GSX_BOARDING_CARGO_PERCENT", 0);
329+
FSUIPCConnection.WriteLVar("FSDT_GSX_DEBOARDING_CARGO_PERCENT", 0);
330+
}
314331
}
315332
}

WorkingTitle2GSX/WorkingTitle2GSX.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageIcon>logo.png</PackageIcon>
1515
<RepositoryUrl>https://github.com/Fragtality/WorkingTitle2GSX</RepositoryUrl>
1616
<PackageProjectUrl>https://github.com/Fragtality/WorkingTitle2GSX</PackageProjectUrl>
17-
<Version>0.2.0</Version>
17+
<Version>0.2.2</Version>
1818
<StartupObject>WorkingTitle2GSX.App</StartupObject>
1919
</PropertyGroup>
2020

0 commit comments

Comments
 (0)