Skip to content

Commit

Permalink
refactor(efb): check simbrief a/c type against build (flybywiresim#8629)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
2hwk and Benjozork authored Apr 21, 2024
1 parent e3e8a53 commit 1e433bf
Show file tree
Hide file tree
Showing 7 changed files with 32 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 @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface ISimbriefData {
airline: string,
flightNumber: string,
aircraftReg: string,
aircraftIcao: string,
cruiseAltitude: number,
costIndex: string,
route: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -27,7 +27,7 @@ const ValueSimbriefInput: React.FC<ValueSimbriefInputProps> = ({ min, max, value
<div className="flex flex-row">
<div className="relative">
<SimpleInput
className={`${showSimbriefButton && 'rounded-r-none'} my-2 w-full font-mono ${(disabled ? 'cursor-not-allowed text-theme-body placeholder:text-theme-body' : '')}`}
className={`${showSimbriefButton && 'rounded-r-none'} my-2 w-full font-mono ${(disabled ? 'text-theme-body placeholder:text-theme-body cursor-not-allowed' : '')}`}
fontSizeClassName="text-2xl"
number
min={min}
Expand All @@ -41,9 +41,9 @@ const ValueSimbriefInput: React.FC<ValueSimbriefInputProps> = ({ min, max, value
&& (
<TooltipWrapper text={t('Ground.Payload.TT.FillPayloadFromSimbrief')}>
<div
className={`my-2 flex h-auto items-center justify-center rounded-md rounded-l-none
border-2 border-theme-highlight bg-theme-highlight
px-2 text-theme-body transition duration-100 hover:bg-theme-body hover:text-theme-highlight`}
className={`border-theme-highlight bg-theme-highlight text-theme-body hover:bg-theme-body hover:text-theme-highlight my-2 flex
h-auto items-center justify-center
rounded-md rounded-l-none border-2 px-2 transition duration-100`}
onClick={onClickSync}
>
<CloudArrowDown size={26} />
Expand Down Expand Up @@ -141,6 +141,16 @@ export const A380Fuel: React.FC<FuelProps> = ({
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) {
Expand Down Expand Up @@ -271,7 +281,7 @@ export const A380Fuel: React.FC<FuelProps> = ({

return (
<div className="relative flex flex-col justify-center">
<div className="relative flex h-content-section-reduced w-full flex-row justify-between">
<div className="h-content-section-reduced relative flex w-full flex-row justify-between">
<Card className="absolute left-0 top-6 flex w-fit" childrenContainerClassName={`w-full ${simbriefDataLoaded ? 'rounded-r-none' : ''}`}>
<table className="table-fixed">
<tbody>
Expand Down Expand Up @@ -528,7 +538,7 @@ export const A380Fuel: React.FC<FuelProps> = ({
{' '}
{' '}
<A380FuelOutline
className="absolute inset-x-0 right-4 top-20 mx-auto flex h-full w-full text-theme-text"
className="text-theme-text absolute inset-x-0 right-4 top-20 mx-auto flex h-full w-full"
feed1Percent={(Math.max(feedThreeGal * FUEL_GALLONS_TO_KG, 0) / OUTER_FEED_MAX_KG) * 100}
feed2Percent={(Math.max(feedThreeGal * FUEL_GALLONS_TO_KG, 0) / INNER_FEED_MAX_KG) * 100}
feed3Percent={(Math.max(feedThreeGal * FUEL_GALLONS_TO_KG, 0) / INNER_FEED_MAX_KG) * 100}
Expand Down Expand Up @@ -619,7 +629,7 @@ export const A380Fuel: React.FC<FuelProps> = ({
</div>
</div>

<div className="absolute bottom-0 right-6 flex flex-col items-center justify-center space-y-2 overflow-x-hidden rounded-2xl border border-theme-accent px-6 py-3">
<div className="border-theme-accent absolute bottom-0 right-6 flex flex-col items-center justify-center space-y-2 overflow-x-hidden rounded-2xl border px-6 py-3">
<h2 className="flex font-medium">{t('Ground.Fuel.RefuelTime')}</h2>
<SelectGroup>
<SelectItem selected={canRefuel() ? refuelRate === '2' : !canRefuel()} onSelect={() => setRefuelRate('2')}>{t('Settings.Instant')}</SelectItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface SimbriefData {
airline: string;
flightNum: string;
aircraftReg: string;
aircraftIcao: string;
route: string;
loadsheet: string;
costInd: string;
Expand All @@ -67,6 +68,7 @@ export const initialState: {data: SimbriefData, simbriefDataPending: boolean, pa
arrivingPosLat: 0,
arrivingPosLong: 0,
arrivingMetar: '',
aircraftIcao: '',
aircraftReg: '',
flightDistance: '',
route: '',
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1e433bf

Please sign in to comment.