Skip to content

Commit

Permalink
FP check on Turn-Around directly and every 1m / FP check based on Req…
Browse files Browse the repository at this point in the history
…uestID / Fix GSX L-Vars for Turn-Around / Reload SimBrief in GSX on Turn-Around (new FP)
  • Loading branch information
Fragtality committed Oct 10, 2023
1 parent d190235 commit 0534863
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
- Call GSX Refuel to fuel the Aircraft to the planned SimBrief Figures. Start the APU only after Refuel was completed.
- Call GSX Boarding to board Passengers and load Cargo/Bag as planned in SimBrief
- When arrived, call GSX Deboarding to unload the Plane
- 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.
- 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.

<br/>

Expand Down
Binary file modified WorkingTitle2GSX-latest.zip
Binary file not shown.
8 changes: 5 additions & 3 deletions WorkingTitle2GSX/FlightPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace WorkingTitle2GSX
public class FlightPlan
{
public string Flight { get; set; } = "";
public string FlightPlanID { get; set; } = "";
public string Origin { get; set; }
public string Destination { get; set; }
public string Units { get; set; }
Expand Down Expand Up @@ -72,8 +73,9 @@ protected XmlNode LoadOFP()
public bool Load()
{
XmlNode sbOFP = LoadOFP();
string lastFlight = Flight;
string lastID = FlightPlanID;
Flight = sbOFP["general"]["icao_airline"].InnerText + sbOFP["general"]["flight_number"].InnerText;
FlightPlanID = sbOFP["params"]["request_id"].InnerText;
Origin = sbOFP["origin"]["icao_code"].InnerText;
Destination = sbOFP["destination"]["icao_code"].InnerText;
Units = sbOFP["params"]["units"].InnerText;
Expand All @@ -92,12 +94,12 @@ public bool Load()
WeightPax = Convert.ToDouble(sbOFP["weights"]["pax_weight"].InnerText, new RealInvariantFormat(sbOFP["weights"]["pax_weight"].InnerText));
WeightBag = Convert.ToDouble(sbOFP["weights"]["bag_weight"].InnerText, new RealInvariantFormat(sbOFP["weights"]["bag_weight"].InnerText));

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

return lastFlight != Flight;
return lastID != FlightPlanID;
}

public void SetPassengersGSX()
Expand Down
23 changes: 20 additions & 3 deletions WorkingTitle2GSX/ServiceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ protected void ServiceLoop()
{
state = 4;
sleep = 10000;
ResetGsxVars();
flightPlan.SetPassengersGSX();

Logger.Log(LogLevel.Information, "ServiceController:ServiceLoop", "Current State: Taxi In");
Expand Down Expand Up @@ -278,10 +279,8 @@ protected void ServiceLoop()
{
deboarding = false;
aircraft.StopDeboarding();
Logger.Log(LogLevel.Information, "ServiceController:ServiceLoop", "Current State: Turn-Around - Check for new OFP in 5 Minutes.");
Logger.Log(LogLevel.Information, "ServiceController:ServiceLoop", "Current State: Turn-Around - Waiting for new OFP");
state = 6;
Thread.Sleep(240000);
sleep = 60000;
continue;
}
}
Expand All @@ -292,6 +291,13 @@ protected void ServiceLoop()
{
if (flightPlan.Load())
{
Logger.Log(LogLevel.Debug, "ServiceController:ServiceLoop", "Resetting GSX Vars");
ResetGsxVars();
Logger.Log(LogLevel.Debug, "ServiceController:ServiceLoop", "Import SimBrief to GSX");
FSUIPCConnection.WriteLVar("FSDT_GSX_MENU_OPEN", 1);
Thread.Sleep(2000);
FSUIPCConnection.WriteLVar("FSDT_GSX_MENU_CHOICE", 14);
Thread.Sleep(2000);
flightPlan.SetPassengersGSX();
aircraft.SetPayload(flightPlan);
state = 1;
Expand All @@ -300,7 +306,10 @@ protected void ServiceLoop()
continue;
}
else
{
sleep = 60000;
Logger.Log(LogLevel.Information, "ServiceController:ServiceLoop", "No new OFP found - Retry in 60s.");
}
}
}
catch (Exception ex)
Expand All @@ -311,5 +320,13 @@ protected void ServiceLoop()

Logger.Log(LogLevel.Information, "ServiceController:ServiceLoop", "ServiceLoop ended");
}

protected void ResetGsxVars()
{
FSUIPCConnection.WriteLVar("FSDT_GSX_NUMPASSENGERS_BOARDING_TOTAL", 0);
FSUIPCConnection.WriteLVar("FSDT_GSX_NUMPASSENGERS_DEBOARDING_TOTAL", 0);
FSUIPCConnection.WriteLVar("FSDT_GSX_BOARDING_CARGO_PERCENT", 0);
FSUIPCConnection.WriteLVar("FSDT_GSX_DEBOARDING_CARGO_PERCENT", 0);
}
}
}
2 changes: 1 addition & 1 deletion WorkingTitle2GSX/WorkingTitle2GSX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageIcon>logo.png</PackageIcon>
<RepositoryUrl>https://github.com/Fragtality/WorkingTitle2GSX</RepositoryUrl>
<PackageProjectUrl>https://github.com/Fragtality/WorkingTitle2GSX</PackageProjectUrl>
<Version>0.2.0</Version>
<Version>0.2.2</Version>
<StartupObject>WorkingTitle2GSX.App</StartupObject>
</PropertyGroup>

Expand Down

0 comments on commit 0534863

Please sign in to comment.