Skip to content

Commit

Permalink
feat(efb): Add estimated boarding time (#7583)
Browse files Browse the repository at this point in the history
Co-authored-by: Frank Kopp <[email protected]>
Fixes #7418
  • Loading branch information
ChristianLutzCL authored Jan 2, 2023
1 parent ca06c90 commit 2b2721a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
1. [RMP] RMPs navigation backup - Julian Sebline (Julian Sebline#8476 on Discord)
1. [SEC] Fix GND SPLR logic, add missing GND SPLR partial extension condition - @lukecologne (luke)
1. [FMGC] Improved importing flight plans from MSFS World Map - @frankkopp (Frank Kopp)
1. [EFB] Added boarding time indication to Payload page - @ChristianLutzCL (Christian Lutz) @frankkopp (Frank Kopp)

## 0.9.0

Expand Down Expand Up @@ -1155,3 +1156,4 @@
1. [DCDU] Fixed MSG- and MSG+ button labels - @tyler58546 (tyler58546)
1. [ISIS] Fixed issue where ISIS was allowing a bug to be set while in the OFF state - Patrick Macken (@Pat M on
Discord)
1. [EFB] Added estimated boarding time to Payload screen - @ChristianLutzCL (Christian Lutz)
43 changes: 38 additions & 5 deletions src/instruments/src/EFB/Ground/Pages/Payload/Payload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useBitFlags } from '@instruments/common/bitFlags';
import { round } from 'lodash';
import { CargoWidget } from './Seating/CargoWidget';
import { ChartWidget } from './Chart/ChartWidget';
import { PaxStationInfo, CargoStationInfo } from './Seating/Constants';
import { CargoStationInfo, PaxStationInfo } from './Seating/Constants';
import { t } from '../../../translation';
import { TooltipWrapper } from '../../../UtilComponents/TooltipWrapper';
import { SimpleInput } from '../../../UtilComponents/Form/SimpleInput/SimpleInput';
Expand Down Expand Up @@ -356,6 +356,27 @@ export const Payload = () => {
setBoardingStarted(false);
};

const calculateBoardingTime = useMemo(() => {
// factors taken from flybywire-aircraft-a320-neo/html_ui/Pages/A32NX_Core/A32NX_Boarding.js line 175+
let boardingRateMultiplier = 0;
if (boardingRate === 'REAL') {
boardingRateMultiplier = 5;
} else if (boardingRate === 'FAST') {
boardingRateMultiplier = 1;
}

// value taken from flybywire-aircraft-a320-neo/html_ui/Pages/A32NX_Core/A32NX_Boarding.js line 210
const cargoWeightPerWeightStep = 60;

const differentialPax = Math.abs(totalPaxDesired - totalPax);
const differentialCargo = Math.abs(totalCargoDesired - totalCargo);

const estimatedPaxBoardingSeconds = differentialPax * boardingRateMultiplier;
const estimatedCargoLoadingSeconds = (differentialCargo / cargoWeightPerWeightStep) * boardingRateMultiplier;

return Math.max(estimatedPaxBoardingSeconds, estimatedCargoLoadingSeconds);
}, [totalPaxDesired, totalPax, totalCargoDesired, totalCargo, boardingRate]);

const boardingStatusClass = useMemo(() => {
if (!boardingStarted) {
return 'text-theme-highlight';
Expand Down Expand Up @@ -575,6 +596,13 @@ export const Payload = () => {
emptyWeight,
]);

const remainingTimeString = () => {
const minutes = Math.round(calculateBoardingTime / 60);
const seconds = calculateBoardingTime % 60;
const padding = seconds < 10 ? '0' : '';
return `${minutes}:${padding}${seconds.toFixed(0)} ${t('Ground.Payload.EstimatedDurationUnit')}`;
};

return (
<div>
<div className="relative h-content-section-reduced">
Expand Down Expand Up @@ -753,7 +781,7 @@ export const Payload = () => {
<TooltipWrapper text={t('Ground.Payload.TT.StartBoarding')}>
<button
type="button"
className={`flex justify-center rounded-lg items-center ml-auto w-24 h-12
className={`flex justify-center rounded-lg items-center ml-auto w-24 h-12
${boardingStatusClass} bg-current`}
onClick={() => setBoardingStarted(!boardingStarted)}
>
Expand All @@ -767,7 +795,7 @@ export const Payload = () => {
<TooltipWrapper text={t('Ground.Payload.TT.StartDeboarding')}>
<button
type="button"
className={`flex justify-center items-center ml-1 w-16 h-12 text-theme-highlight bg-current rounded-lg
className={`flex justify-center items-center ml-1 w-16 h-12 text-theme-highlight bg-current rounded-lg
${totalPax === 0 && totalCargo === 0 && 'opacity-20 pointer-events-none'}`}
onClick={() => handleDeboarding()}
>
Expand All @@ -789,8 +817,8 @@ export const Payload = () => {
&& (
<TooltipWrapper text={t('Ground.Payload.TT.FillPayloadFromSimbrief')}>
<div
className={`flex justify-center items-center px-2 h-auto text-theme-body
hover:text-theme-highlight bg-theme-highlight hover:bg-theme-body
className={`flex justify-center items-center px-2 h-auto text-theme-body
hover:text-theme-highlight bg-theme-highlight hover:bg-theme-body
rounded-md rounded-l-none border-2 border-theme-highlight transition duration-100`}
onClick={setSimBriefValues}
>
Expand All @@ -805,6 +833,11 @@ export const Payload = () => {
<div className="flex flex-row justify-between items-center">
<div className="flex font-medium">
{t('Ground.Payload.BoardingTime')}
<span className="flex relative flex-row items-center ml-2 text-sm font-light">
(
{remainingTimeString()}
)
</span>
</div>

<SelectGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/instruments/src/EFB/Localization/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
},
"Payload": {
"BoardingTime": "Boarding-Dauer",
"EstimatedDurationUnit": "minuten",
"Cargo": "Fracht",
"Current": "Aktuell",
"DeboardConfirmationBody": "Bitte bestätigen Sie das Aussteigen aller Passagiere",
Expand Down Expand Up @@ -618,4 +619,4 @@
"Tue": "Di",
"Wed": "Mi"
}
}
}

0 comments on commit 2b2721a

Please sign in to comment.