From 2b2721a36a3e021db354f487a8222f00d4caaca5 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 2 Jan 2023 12:35:17 +0100 Subject: [PATCH] feat(efb): Add estimated boarding time (#7583) Co-authored-by: Frank Kopp Fixes https://github.com/flybywiresim/a32nx/issues/7418 --- .github/CHANGELOG.md | 2 + .../src/EFB/Ground/Pages/Payload/Payload.tsx | 43 ++++++++++++++++--- src/instruments/src/EFB/Localization/de.json | 3 +- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index 3c28bcd6e7c..e923ee90f94 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -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 @@ -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) \ No newline at end of file diff --git a/src/instruments/src/EFB/Ground/Pages/Payload/Payload.tsx b/src/instruments/src/EFB/Ground/Pages/Payload/Payload.tsx index 97d1f23ac69..c4edd54850d 100644 --- a/src/instruments/src/EFB/Ground/Pages/Payload/Payload.tsx +++ b/src/instruments/src/EFB/Ground/Pages/Payload/Payload.tsx @@ -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'; @@ -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'; @@ -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 (
@@ -753,7 +781,7 @@ export const Payload = () => {