From 1e433bf5a49ba39a13ff868ed117dd0e03bb14d2 Mon Sep 17 00:00:00 2001 From: 2hwk <15316958+2hwk@users.noreply.github.com> Date: Mon, 22 Apr 2024 02:54:45 +0800 Subject: [PATCH] refactor(efb): check simbrief a/c type against build (#8629) * feat: check simbrief a/c type against build * refactor: warning instead of stopping import * fix: only show sucess or warning toast when importing * fix: a380 fuel page for working notif * fix: en localisation files --------- Co-authored-by: Benjamin Dupont <4503241+Benjozork@users.noreply.github.com> --- .github/CHANGELOG.md | 1 + .../EFB/Apis/Simbrief/simbriefInterface.ts | 1 + .../src/EFB/Apis/Simbrief/simbriefParser.ts | 1 + .../EFB/Dashboard/Widgets/FlightWidget.tsx | 7 ++++- .../Ground/Pages/Fuel/A380_842/A380Fuel.tsx | 26 +++++++++++++------ .../src/EFB/Localization/data/en.json | 3 ++- .../src/EFB/Store/features/simBrief.ts | 3 +++ 7 files changed, 32 insertions(+), 10 deletions(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index d560f4d3a42..b99fbcce54a 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -146,6 +146,7 @@ 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) 1. [ATSU] Fix ATIS Auto Update LSK6L to ATIS page instead of ATC MENU - @BravoMike99 (bruno_pt99) +1. [EFB] Added warning for not compatible aircraft type to simbrief import - @2hwk (2Cas) ## 0.10.0 diff --git a/fbw-common/src/systems/instruments/src/EFB/Apis/Simbrief/simbriefInterface.ts b/fbw-common/src/systems/instruments/src/EFB/Apis/Simbrief/simbriefInterface.ts index aad682959d1..fe2dacdca30 100644 --- a/fbw-common/src/systems/instruments/src/EFB/Apis/Simbrief/simbriefInterface.ts +++ b/fbw-common/src/systems/instruments/src/EFB/Apis/Simbrief/simbriefInterface.ts @@ -7,6 +7,7 @@ export interface ISimbriefData { airline: string, flightNumber: string, aircraftReg: string, + aircraftIcao: string, cruiseAltitude: number, costIndex: string, route: string, diff --git a/fbw-common/src/systems/instruments/src/EFB/Apis/Simbrief/simbriefParser.ts b/fbw-common/src/systems/instruments/src/EFB/Apis/Simbrief/simbriefParser.ts index bcc619c17fb..0ed285387c7 100644 --- a/fbw-common/src/systems/instruments/src/EFB/Apis/Simbrief/simbriefParser.ts +++ b/fbw-common/src/systems/instruments/src/EFB/Apis/Simbrief/simbriefParser.ts @@ -64,6 +64,7 @@ const simbriefDataParser = (simbriefJson: any): ISimbriefData => { airline: general.icao_airline, flightNumber: general.flight_number, aircraftReg: aircraft.reg, + aircraftIcao: aircraft.icaocode, cruiseAltitude: general.initial_altitude, costIndex: general.costindex, route: general.route, diff --git a/fbw-common/src/systems/instruments/src/EFB/Dashboard/Widgets/FlightWidget.tsx b/fbw-common/src/systems/instruments/src/EFB/Dashboard/Widgets/FlightWidget.tsx index 2263ca4d222..2ef977b26a1 100644 --- a/fbw-common/src/systems/instruments/src/EFB/Dashboard/Widgets/FlightWidget.tsx +++ b/fbw-common/src/systems/instruments/src/EFB/Dashboard/Widgets/FlightWidget.tsx @@ -28,6 +28,7 @@ const InformationEntry = ({ title, info }: InformationEntryProps) => ( export const FlightWidget = () => { const { data } = useAppSelector((state) => state.simbrief); const simbriefDataPending = useAppSelector((state) => state.simbrief.simbriefDataPending); + const aircraftIcao = useAppSelector((state) => state.simbrief.data.aircraftIcao); const [navigraphUsername] = usePersistentProperty('NAVIGRAPH_USERNAME'); const [overrideSimBriefUserID] = usePersistentProperty('CONFIG_OVERRIDE_SIMBRIEF_USERID'); const [autoSimbriefImport] = usePersistentProperty('CONFIG_AUTO_SIMBRIEF_IMPORT'); @@ -111,7 +112,11 @@ export const FlightWidget = () => { useEffect(() => { if (!simbriefDataPending && (navigraphUsername || overrideSimBriefUserID) && !toastPresented && fuelImported && payloadImported) { - toast.success(t('Dashboard.YourFlight.ToastFuelPayloadImported')); + if (aircraftIcao !== airframeInfo.icao) { + toast.error(t('Dashboard.YourFlight.ToastWrongAircraftType')); + } else { + toast.success(t('Dashboard.YourFlight.ToastFuelPayloadImported')); + } dispatch(setToastPresented(true)); } }, [fuelImported, payloadImported, simbriefDataPending]); diff --git a/fbw-common/src/systems/instruments/src/EFB/Ground/Pages/Fuel/A380_842/A380Fuel.tsx b/fbw-common/src/systems/instruments/src/EFB/Ground/Pages/Fuel/A380_842/A380Fuel.tsx index 1513317a1bf..f7315b8f96e 100644 --- a/fbw-common/src/systems/instruments/src/EFB/Ground/Pages/Fuel/A380_842/A380Fuel.tsx +++ b/fbw-common/src/systems/instruments/src/EFB/Ground/Pages/Fuel/A380_842/A380Fuel.tsx @@ -7,7 +7,7 @@ import { round } from 'lodash'; import { CloudArrowDown, PlayFill, StopCircleFill } from 'react-bootstrap-icons'; import { useSimVar, usePersistentNumberProperty, usePersistentProperty, Units } from '@flybywiresim/fbw-sdk'; import Slider from 'rc-slider'; -import { Card, A380FuelOutline, t, TooltipWrapper, SimpleInput, SelectGroup, SelectItem, ProgressBar } from '@flybywiresim/flypad'; +import { Card, A380FuelOutline, t, TooltipWrapper, SimpleInput, SelectGroup, SelectItem, ProgressBar, useAppSelector, setFuelImported, useAppDispatch } from '@flybywiresim/flypad'; // Page is very WIP, needs to be cleaned up and refactored @@ -27,7 +27,7 @@ const ValueSimbriefInput: React.FC = ({ min, max, value
= ({ min, max, value && (
@@ -141,6 +141,16 @@ export const A380Fuel: React.FC = ({ const [gsxFuelSyncEnabled] = usePersistentNumberProperty('GSX_FUEL_SYNC', 0); const [gsxFuelHoseConnected] = useSimVar('L:FSDT_GSX_FUELHOSE_CONNECTED', 'Number'); + const dispatch = useAppDispatch(); + const fuelImported = useAppSelector((state) => state.simbrief.fuelImported); + + useEffect(() => { + if (simbriefDataLoaded === true && fuelImported === false) { + handleSimbriefFuelSync(); + dispatch(setFuelImported(true)); + } + }, []); + useEffect(() => { // GSX if (gsxFuelSyncEnabled === 1) { @@ -271,7 +281,7 @@ export const A380Fuel: React.FC = ({ return (
-
+
@@ -528,7 +538,7 @@ export const A380Fuel: React.FC = ({ {' '} {' '} = ({ -
+

{t('Ground.Fuel.RefuelTime')}

setRefuelRate('2')}>{t('Settings.Instant')} diff --git a/fbw-common/src/systems/instruments/src/EFB/Localization/data/en.json b/fbw-common/src/systems/instruments/src/EFB/Localization/data/en.json index 86b7e1a4d4d..83c9a58ab37 100644 --- a/fbw-common/src/systems/instruments/src/EFB/Localization/data/en.json +++ b/fbw-common/src/systems/instruments/src/EFB/Localization/data/en.json @@ -86,7 +86,8 @@ "SimBriefDataNotYetLoaded": "SimBrief data not yet loaded.", "Title": "Your Flight", "ZFW": "ZFW", - "NoImportDueToBoardingOrRefuel": "No import possible due to boarding or refuel in progress!" + "NoImportDueToBoardingOrRefuel": "No import possible due to boarding or refuel in progress!", + "ToastWrongAircraftType": "SimBrief - Invalid aircraft type detected. Check that aircraft type in SimBrief OFP is correct." } }, "Dispatch": { diff --git a/fbw-common/src/systems/instruments/src/EFB/Store/features/simBrief.ts b/fbw-common/src/systems/instruments/src/EFB/Store/features/simBrief.ts index 9b0453af20c..e14174764db 100644 --- a/fbw-common/src/systems/instruments/src/EFB/Store/features/simBrief.ts +++ b/fbw-common/src/systems/instruments/src/EFB/Store/features/simBrief.ts @@ -44,6 +44,7 @@ export interface SimbriefData { airline: string; flightNum: string; aircraftReg: string; + aircraftIcao: string; route: string; loadsheet: string; costInd: string; @@ -67,6 +68,7 @@ export const initialState: {data: SimbriefData, simbriefDataPending: boolean, pa arrivingPosLat: 0, arrivingPosLong: 0, arrivingMetar: '', + aircraftIcao: '', aircraftReg: '', flightDistance: '', route: '', @@ -167,6 +169,7 @@ export async function fetchSimbriefDataAction(navigraphUsername: string, overrid arrivingPosLong: returnedSimbriefData.destination.posLong, arrivingMetar: returnedSimbriefData.destination.metar, aircraftReg: returnedSimbriefData.aircraftReg, + aircraftIcao: returnedSimbriefData.aircraftIcao, flightDistance: returnedSimbriefData.distance, flightETAInSeconds: returnedSimbriefData.flightETAInSeconds, cruiseAltitude: returnedSimbriefData.cruiseAltitude,