Skip to content

Commit

Permalink
fix(apu): Added xfeed APU capabilities (#8216)
Browse files Browse the repository at this point in the history
* fix(apu): Added xfeed APU capabilities

* fix: Updated APU fuel burn for cross-feed

* Update EngineControl.h
  • Loading branch information
Taz5150 authored Oct 20, 2023
1 parent 638b15e commit 817cc8c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
1. [COND] Fixed Temp-Indication on CRZ page showing cockpit temperature for fwd and aft cabin - @cptnuss-ops (Lukas)
1. [FMS] Show ILS ident and frequency on ARRIVAL page - @tracernz (Mike)
1. [EFB/ATSU] Use MSFS METAR data rather than FSX cloud data from FBW API - @tracernz (Mike)
1. [APU] Added xfeed APU fuel capabilities - @Taz5150 (TazX [Z+1]#0405)

## 0.10.0

Expand Down
35 changes: 25 additions & 10 deletions fbw-a32nx/src/wasm/fadec_a320/src/EngineControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,8 @@ class EngineControl {
double b = 0;
double fuelBurn1 = 0;
double fuelBurn2 = 0;
double apuBurn1 = 0;
double apuBurn2 = 0;

double refuelRate = simVars->getRefuelRate();
double refuelStartedByUser = simVars->getRefuelStartedByUser();
Expand Down Expand Up @@ -816,17 +818,20 @@ class EngineControl {
}
//-----------------------------------------------------------
// Cross-feed Logic
// isTankClosed = 0, both tanks can supply fuel
// isTankClosed = 0, x-feed valve closed
// isTankClosed = 1, left tank does not supply fuel
// isTankClosed = 2, right tank does not supply fuel
// isTankClosed = 3, left & right tanks do not supply fuel
// isTankClosed = 4, both tanks supply fuel
if (xFeedValve > 0.0) {
if (leftPump1 == 0 && leftPump2 == 0)
isTankClosed = 1;
if (rightPump1 == 0 && rightPump2 == 0)
isTankClosed = 2;
if (leftPump1 == 0 && leftPump2 == 0 && rightPump1 == 0 && rightPump2 == 0)
isTankClosed = 3;
else if (leftPump1 == 0 && leftPump2 == 0)
isTankClosed = 1;
else if (rightPump1 == 0 && rightPump2 == 0)
isTankClosed = 2;
else
isTankClosed = 4;
}

//--------------------------------------------
Expand Down Expand Up @@ -864,6 +869,11 @@ class EngineControl {
fuelRightPre = 0;
}

/// apu fuel consumption for this frame in pounds
double apuFuelConsumption = simVars->getLineFlow(18) * fuelWeightGallon * deltaTime;
apuBurn1 = apuFuelConsumption;
apuBurn2 = 0;

//--------------------------------------------
// Fuel used accumulators
fuelUsedLeft += fuelBurn1;
Expand All @@ -877,6 +887,8 @@ class EngineControl {
case 1:
fuelBurn2 = fuelBurn1 + fuelBurn2;
fuelBurn1 = 0;
apuBurn1 = 0;
apuBurn2 = apuFuelConsumption;
break;
case 2:
fuelBurn1 = fuelBurn1 + fuelBurn2;
Expand All @@ -885,6 +897,12 @@ class EngineControl {
case 3:
fuelBurn1 = 0;
fuelBurn2 = 0;
apuBurn1 = apuFuelConsumption * 0.5;
apuBurn2 = apuFuelConsumption * 0.5;
break;
case 4:
apuBurn1 = apuFuelConsumption*0.5;
apuBurn2 = apuFuelConsumption*0.5;
break;
default:
break;
Expand All @@ -905,13 +923,10 @@ class EngineControl {
else if (xfrValveCenterRightOpen)
xfrCenterToRight = fuelCenterPre - centerQuantity;

/// apu fuel consumption for this frame in pounds
double apuFuelConsumption = simVars->getLineFlow(18) * fuelWeightGallon * deltaTime;

//--------------------------------------------
// Final Fuel levels for left and right inner tanks
fuelLeft = (fuelLeftPre - (fuelBurn1 * KGS_TO_LBS)) + xfrAuxLeft + xfrCenterToLeft - apuFuelConsumption; // LBS
fuelRight = (fuelRightPre - (fuelBurn2 * KGS_TO_LBS)) + xfrAuxRight + xfrCenterToRight; // LBS
fuelLeft = (fuelLeftPre - (fuelBurn1 * KGS_TO_LBS)) + xfrAuxLeft + xfrCenterToLeft - apuBurn1; // LBS
fuelRight = (fuelRightPre - (fuelBurn2 * KGS_TO_LBS)) + xfrAuxRight + xfrCenterToRight - apuBurn2; // LBS

//--------------------------------------------
// Setting new pre-cycle conditions
Expand Down

0 comments on commit 817cc8c

Please sign in to comment.