Skip to content

Commit

Permalink
fix(a380x/SD): Hook up door SD page to door status (flybywiresim#9077)
Browse files Browse the repository at this point in the history
* hookup door page to door status

* fix cargo door & beacon light check

* fix engine running condition

* fix(door sd): do not use conditional react hook
  • Loading branch information
BravoMike99 authored Oct 20, 2024
1 parent 6724c87 commit 444d8c0
Show file tree
Hide file tree
Showing 5 changed files with 210 additions and 28 deletions.
3 changes: 3 additions & 0 deletions fbw-a380x/src/systems/instruments/src/Common/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ export type EGTProps = {

export type CabinDoorProps = {
doorNumber: number;
interactivePoint: number;
slideArmed: boolean;
side: 'L' | 'R';
engineRunning: boolean;
mainOrUpper: 'MAIN' | 'UPPER';
};

export type CargoDoorProps = {
label: 'AFT' | 'FWD' | 'BULK' | 'AVNCS' | 'FWD CARGO' | 'AFT CARGO';
closed: boolean;
width: number;
height: number;
engineRunning: boolean;
Expand Down
210 changes: 189 additions & 21 deletions fbw-a380x/src/systems/instruments/src/SD/Pages/Doors/DoorPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ import CargoDoor from './elements/CargoDoor';
export const DoorPage = () => {
const [windowLeft] = useSimVar('L:CPT_SLIDING_WINDOW', 'number');
const [windowRight] = useSimVar('L:FO_SLIDING_WINDOW', 'number');
const engineRunning = true;
// TODO replace once proper slide implementation & fadec
const [beaconOn] = useSimVar('LIGHT BEACON ON', 'bool', 1000);
const [engine1State] = useSimVar('L:A32NX_ENGINE_STATE:1', 'enum', 1000);
const [engine2State] = useSimVar('L:A32NX_ENGINE_STATE:2', 'enum', 1000);
const [engine3State] = useSimVar('L:A32NX_ENGINE_STATE:3', 'enum', 1000);
const [engine4State] = useSimVar('L:A32NX_ENGINE_STATE:4', 'enum', 1000);
const engineRunning = engine1State === 1 || engine2State === 1 || engine3State === 1 || engine4State === 1;
const sdacActive = true;
const onGround = true;
const [fwdCargoClosed] = useSimVar('L:A32NX_FWD_DOOR_CARGO_LOCKED', 'bool', 1000);
const [aftCargoClosed] = useSimVar('L:A32NX_AFT_DOOR_CARGO_LOCKED', 'bool', 1000);

return (
<>
Expand All @@ -36,31 +44,191 @@ export const DoorPage = () => {
</text>

{/* Cabin Doors */}
<CabinDoor x={183} y={201} side="L" mainOrUpper="MAIN" doorNumber={1} engineRunning={engineRunning} />
<CabinDoor x={183} y={314} side="L" mainOrUpper="MAIN" doorNumber={2} engineRunning={engineRunning} />
<CabinDoor x={183} y={402} side="L" mainOrUpper="MAIN" doorNumber={3} engineRunning={engineRunning} />
<CabinDoor x={183} y={477} side="L" mainOrUpper="MAIN" doorNumber={4} engineRunning={engineRunning} />
<CabinDoor x={183} y={621} side="L" mainOrUpper="MAIN" doorNumber={5} engineRunning={engineRunning} />
<CabinDoor
x={183}
y={201}
side="L"
mainOrUpper="MAIN"
doorNumber={1}
engineRunning={engineRunning}
interactivePoint={0}
slideArmed={beaconOn}
/>
<CabinDoor
x={183}
y={314}
side="L"
mainOrUpper="MAIN"
doorNumber={2}
engineRunning={engineRunning}
interactivePoint={2}
slideArmed={beaconOn}
/>
<CabinDoor
x={183}
y={402}
side="L"
mainOrUpper="MAIN"
doorNumber={3}
engineRunning={engineRunning}
interactivePoint={4}
slideArmed={beaconOn}
/>
<CabinDoor
x={183}
y={477}
side="L"
mainOrUpper="MAIN"
doorNumber={4}
engineRunning={engineRunning}
interactivePoint={6}
slideArmed={beaconOn}
/>
<CabinDoor
x={183}
y={621}
side="L"
mainOrUpper="MAIN"
doorNumber={5}
engineRunning={engineRunning}
interactivePoint={8}
slideArmed={beaconOn}
/>

<CabinDoor x={368} y={201} side="R" mainOrUpper="MAIN" doorNumber={1} engineRunning={engineRunning} />
<CabinDoor x={368} y={314} side="R" mainOrUpper="MAIN" doorNumber={2} engineRunning={engineRunning} />
<CabinDoor x={368} y={402} side="R" mainOrUpper="MAIN" doorNumber={3} engineRunning={engineRunning} />
<CabinDoor x={368} y={477} side="R" mainOrUpper="MAIN" doorNumber={4} engineRunning={engineRunning} />
<CabinDoor x={368} y={621} side="R" mainOrUpper="MAIN" doorNumber={5} engineRunning={engineRunning} />
<CabinDoor
x={368}
y={201}
side="R"
mainOrUpper="MAIN"
doorNumber={1}
engineRunning={engineRunning}
interactivePoint={1}
slideArmed={beaconOn}
/>
<CabinDoor
x={368}
y={314}
side="R"
mainOrUpper="MAIN"
doorNumber={2}
engineRunning={engineRunning}
interactivePoint={3}
slideArmed={beaconOn}
/>
<CabinDoor
x={368}
y={402}
side="R"
mainOrUpper="MAIN"
doorNumber={3}
engineRunning={engineRunning}
interactivePoint={5}
slideArmed={beaconOn}
/>
<CabinDoor
x={368}
y={477}
side="R"
mainOrUpper="MAIN"
doorNumber={4}
engineRunning={engineRunning}
interactivePoint={7}
slideArmed={beaconOn}
/>
<CabinDoor
x={368}
y={621}
side="R"
mainOrUpper="MAIN"
doorNumber={5}
engineRunning={engineRunning}
interactivePoint={9}
slideArmed={beaconOn}
/>

<CabinDoor x={239} y={350} side="L" mainOrUpper="UPPER" doorNumber={1} engineRunning={engineRunning} />
<CabinDoor x={239} y={440} side="L" mainOrUpper="UPPER" doorNumber={2} engineRunning={engineRunning} />
<CabinDoor x={239} y={556} side="L" mainOrUpper="UPPER" doorNumber={3} engineRunning={engineRunning} />
<CabinDoor
x={239}
y={350}
side="L"
mainOrUpper="UPPER"
doorNumber={1}
engineRunning={engineRunning}
interactivePoint={10}
slideArmed={beaconOn}
/>
<CabinDoor
x={239}
y={440}
side="L"
mainOrUpper="UPPER"
doorNumber={2}
engineRunning={engineRunning}
interactivePoint={12}
slideArmed={beaconOn}
/>
<CabinDoor
x={239}
y={556}
side="L"
mainOrUpper="UPPER"
doorNumber={3}
engineRunning={engineRunning}
interactivePoint={14}
slideArmed={beaconOn}
/>

<CabinDoor x={310} y={350} side="R" mainOrUpper="UPPER" doorNumber={1} engineRunning={engineRunning} />
<CabinDoor x={310} y={440} side="R" mainOrUpper="UPPER" doorNumber={2} engineRunning={engineRunning} />
<CabinDoor x={310} y={556} side="R" mainOrUpper="UPPER" doorNumber={3} engineRunning={engineRunning} />
<CabinDoor
x={310}
y={350}
side="R"
mainOrUpper="UPPER"
doorNumber={1}
engineRunning={engineRunning}
interactivePoint={11}
slideArmed={beaconOn}
/>
<CabinDoor
x={310}
y={440}
side="R"
mainOrUpper="UPPER"
doorNumber={2}
engineRunning={engineRunning}
interactivePoint={13}
slideArmed={beaconOn}
/>
<CabinDoor
x={310}
y={556}
side="R"
mainOrUpper="UPPER"
doorNumber={3}
engineRunning={engineRunning}
interactivePoint={15}
slideArmed={beaconOn}
/>

{/* Cargo Doors */}
<CargoDoor x={222} y={165} label="AVNCS" width={27} height={20} engineRunning={engineRunning} />
<CargoDoor x={359} y={250} label="FWD CARGO" width={26} height={46} engineRunning={engineRunning} />
<CargoDoor x={359} y={515} label="AFT CARGO" width={26} height={42} engineRunning={engineRunning} />
<CargoDoor x={359} y={590} label="BULK" width={26} height={26} engineRunning={engineRunning} />
<CargoDoor x={222} y={165} label="AVNCS" width={27} height={20} engineRunning={engineRunning} closed={true} />
<CargoDoor
x={359}
y={250}
label="FWD CARGO"
width={26}
height={46}
engineRunning={engineRunning}
closed={fwdCargoClosed}
/>
<CargoDoor
x={359}
y={515}
label="AFT CARGO"
width={26}
height={42}
engineRunning={engineRunning}
closed={aftCargoClosed}
/>
<CargoDoor x={359} y={590} label="BULK" width={26} height={26} engineRunning={engineRunning} closed={true} />
</>
);
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import { useSimVar } from '@flybywiresim/fbw-sdk';
import { Position, CabinDoorProps } from '@instruments/common/types';
import React from 'react';

const CabinDoor: React.FC<Position & CabinDoorProps> = ({ x, y, doorNumber, side, mainOrUpper, engineRunning }) => {
const doorOpen = false;
const armed = true;
const CabinDoor: React.FC<Position & CabinDoorProps> = ({
x,
y,
doorNumber,
interactivePoint,
side,
mainOrUpper,
engineRunning,
slideArmed,
}) => {
const [openPercentage] = useSimVar(`INTERACTIVE POINT OPEN:${interactivePoint}`, 'percent', 1000);
const doorOpen = openPercentage > 20;
const armed = !doorOpen && slideArmed;
const validSDAC = true;

let slide = '';
Expand Down Expand Up @@ -54,7 +65,7 @@ const CabinDoor: React.FC<Position & CabinDoorProps> = ({ x, y, doorNumber, side
<text x={3} y={21} className={`${doorNumberCss} F22`}>
{!validSDAC ? 'X' : doorNumber}
</text>
<text x={xpos} y={-5} className={`${!validSDAC ? 'White' : 'AmberFill'} F22`}>
<text x={xpos} y={12} className={`${!validSDAC ? 'White' : 'AmberFill'} F22`}>
{cabinDoorMessage}
</text>
<text x={side === 'L' ? -6 : 23} y={38} className={`${slideCss} F30`}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Position, CargoDoorProps } from '@instruments/common/types';
import React from 'react';

const CargoDoor: React.FC<Position & CargoDoorProps> = ({ x, y, label, width, height, engineRunning }) => {
const doorOpen = false;
const CargoDoor: React.FC<Position & CargoDoorProps> = ({ x, y, label, closed, width, height, engineRunning }) => {
const doorOpen = !closed;
const validSDAC = true;

let cargoDoorMessage = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const EngPage = () => {
const [engine2State] = useSimVar('L:A32NX_ENGINE_STATE:2', 'enum', 500); // TODO: Update with correct SimVars
const [engine3State] = useSimVar('L:A32NX_ENGINE_STATE:3', 'enum', 500); // TODO: Update with correct SimVars
const [engine4State] = useSimVar('L:A32NX_ENGINE_STATE:4', 'enum', 500); // TODO: Update with correct SimVars
const engineState = [engine1State, engine2State, engine3State, engine3State, engine4State];
const engineState = [engine1State, engine2State, engine3State, engine4State];
const engineRunning = engineState.some((value) => value > 0); // TODO Implement FADEC SimVars once available

return (
Expand Down

0 comments on commit 444d8c0

Please sign in to comment.