diff --git a/hdw-a339x/src/systems/instruments/src/SD/Pages/ElecAc/ElecAc.scss b/hdw-a339x/src/systems/instruments/src/SD/Pages/ElecAc/ElecAc.scss new file mode 100644 index 00000000..8054114e --- /dev/null +++ b/hdw-a339x/src/systems/instruments/src/SD/Pages/ElecAc/ElecAc.scss @@ -0,0 +1,77 @@ +@import "../../style"; +@import "../../../Common/definitions"; + +#main-elec-ac { + .Box { + stroke: $display-grey; + fill: none; + stroke-width: 2.5px; + } + + path { + stroke: $display-white; + stroke-width: 2.25px; + stroke-linecap: square; + stroke-linejoin: miter; + + &.Green { + stroke: $display-green; + } + + &.Amber { + stroke: $display-amber; + } + } + + rect.Bus { + fill: $display-grey; + } + + text { + fill: $display-white; + font-size: 19px; + + &.ExtraLarge { + font-size: 26px; + } + + // Seriously, we need to fix this at some point ^^ + &.QuiteLarge { + font-size: 24px; + } + + &.Large { + font-size: 22px; + } + + &.Small { + font-size: 16.875px; + } + + &.ExtraSmall { + font-size: 15px; + } + + &.Middle { + text-anchor: middle; + text-align: middle; + } + + &.Right { + text-anchor: end; + text-align: end; + } + + &.Green { + fill: $display-green; + } + + &.Amber { + fill: $display-amber; + } + + &.Cyan { + fill: $display-cyan; + } + } +} diff --git a/hdw-a339x/src/systems/instruments/src/SD/Pages/ElecAc/ElecAc.tsx b/hdw-a339x/src/systems/instruments/src/SD/Pages/ElecAc/ElecAc.tsx new file mode 100644 index 00000000..daf6997a --- /dev/null +++ b/hdw-a339x/src/systems/instruments/src/SD/Pages/ElecAc/ElecAc.tsx @@ -0,0 +1,591 @@ +// Copyright (c) 2021-2023 FlyByWire Simulations +// +// SPDX-License-Identifier: GPL-3.0 + +import React from 'react'; +import classNames from 'classnames'; +import { useSimVar } from '@flybywiresim/fbw-sdk'; +import { PageTitle } from '../../Common/PageTitle'; +import { EcamPage } from '../../Common/EcamPage'; +import { SvgGroup } from '../../Common/SvgGroup'; + +import './ElecAc.scss'; + +const maxStaleness = 300; + +export const ElecAcPage = () => { + const [ac1IsPowered] = useSimVar('L:A32NX_ELEC_AC_1_BUS_IS_POWERED', 'Bool', maxStaleness); + const [ac2IsPowered] = useSimVar('L:A32NX_ELEC_AC_2_BUS_IS_POWERED', 'Bool', maxStaleness); + const [acEssIsPowered] = useSimVar('L:A32NX_ELEC_AC_ESS_BUS_IS_POWERED', 'Bool', maxStaleness); + const [acEssShedBusIsPowered] = useSimVar('L:A32NX_ELEC_AC_ESS_SHED_BUS_IS_POWERED', 'Bool', maxStaleness); + const [externalPowerAvailable] = useSimVar('L:A32NX_EXT_PWR_AVAIL:1', 'Bool', maxStaleness); + const [staticInverterInUse] = useSimVar('L:A32NX_ELEC_CONTACTOR_15XE2_IS_CLOSED', 'Bool', maxStaleness); + const [galleyIsShed] = useSimVar('L:A32NX_ELEC_GALLEY_IS_SHED', 'Bool', maxStaleness); + const [ac1SuppliesAcEss] = useSimVar('L:A32NX_ELEC_CONTACTOR_3XC1_IS_CLOSED', 'Bool', maxStaleness); + const [ac2SuppliesAcEss] = useSimVar('L:A32NX_ELEC_CONTACTOR_3XC2_IS_CLOSED', 'Bool', maxStaleness); + + const [emergencyGeneratorSupplies] = useSimVar('L:A32NX_ELEC_CONTACTOR_2XE_IS_CLOSED', 'Bool', maxStaleness); + const [acEssBusContactorClosed] = useSimVar('L:A32NX_ELEC_CONTACTOR_15XE1_IS_CLOSED', 'Bool', maxStaleness); + const [trEssSuppliesDcEss] = useSimVar('L:A32NX_ELEC_CONTACTOR_3PE_IS_CLOSED', 'Bool', maxStaleness); + + const [externalPowerContactorClosed] = useSimVar('L:A32NX_ELEC_CONTACTOR_3XG_IS_CLOSED', 'Bool', maxStaleness); + const [apuGeneratorContactorClosed] = useSimVar('L:A32NX_ELEC_CONTACTOR_3XS_IS_CLOSED', 'Bool', maxStaleness); + const [generatorLineContactor1Closed] = useSimVar('L:A32NX_ELEC_CONTACTOR_9XU1_IS_CLOSED', 'Bool', maxStaleness); + const [generatorLineContactor2Closed] = useSimVar('L:A32NX_ELEC_CONTACTOR_9XU2_IS_CLOSED', 'Bool', maxStaleness); + const [busTieContactor1Closed] = useSimVar('L:A32NX_ELEC_CONTACTOR_11XU1_IS_CLOSED', 'Bool', maxStaleness); + const [busTieContactor2Closed] = useSimVar('L:A32NX_ELEC_CONTACTOR_11XU2_IS_CLOSED', 'Bool', maxStaleness); + + const [idg1Connected] = useSimVar('L:A32NX_ELEC_ENG_GEN_1_IDG_IS_CONNECTED', 'Bool', maxStaleness); + const [idg2Connected] = useSimVar('L:A32NX_ELEC_ENG_GEN_2_IDG_IS_CONNECTED', 'Bool', maxStaleness); + + const [masterSwPbOn] = useSimVar('L:A32NX_OVHD_APU_MASTER_SW_PB_IS_ON', 'Bool', maxStaleness); + + return ( + + + {ac1SuppliesAcEss ? : null} + {ac2SuppliesAcEss ? : null} + {acEssBusContactorClosed && !emergencyGeneratorSupplies ? ( + + ) : null} + {trEssSuppliesDcEss ? : null} + + {emergencyGeneratorSupplies ? ( + + ) : null} + + {acEssBusContactorClosed && emergencyGeneratorSupplies ? ( + <> + + + + ) : null} + + {acEssBusContactorClosed && emergencyGeneratorSupplies ? ( + <> + + + + ) : null} + {externalPowerContactorClosed && busTieContactor1Closed && !busTieContactor2Closed ? ( + + ) : null} + {externalPowerContactorClosed && !busTieContactor1Closed && busTieContactor2Closed ? ( + + ) : null} + {externalPowerContactorClosed && busTieContactor1Closed && busTieContactor2Closed ? ( + + ) : null} + {apuGeneratorContactorClosed && busTieContactor1Closed && !busTieContactor2Closed ? ( + + ) : null} + {apuGeneratorContactorClosed && !busTieContactor1Closed && busTieContactor2Closed ? ( + + ) : null} + {apuGeneratorContactorClosed && busTieContactor1Closed && busTieContactor2Closed ? ( + + ) : null} + {generatorLineContactor1Closed && !busTieContactor1Closed ? ( + + ) : null} + {generatorLineContactor1Closed && busTieContactor1Closed && busTieContactor2Closed ? ( + + ) : null} + {generatorLineContactor2Closed && !busTieContactor2Closed ? ( + + ) : null} + {generatorLineContactor2Closed && busTieContactor1Closed && busTieContactor2Closed ? ( + + ) : null} + {generatorLineContactor1Closed || busTieContactor1Closed ? ( + + ) : null} + {generatorLineContactor2Closed || busTieContactor2Closed ? ( + + ) : null} + {externalPowerContactorClosed && (busTieContactor1Closed || busTieContactor2Closed) ? ( + + ) : null} + {ac1SuppliesAcEss ? : null} + {masterSwPbOn ? ( + + ) : null} + + + + + + + + + + {staticInverterInUse ? : null} + {!staticInverterInUse && externalPowerAvailable ? ( + <> + + + + ) : null}{' '} + + + + + + {galleyIsShed ? : null} + + + {!idg1Connected ? : null} + + + {!idg2Connected ? : null} + + ); +}; + +const ElectricalProperty = ({ x, y, value, unit, isWithinNormalRange }) => ( + + {Math.round(value)} + + {unit} + + +); + +const Box = ({ width, height }) => ; + +interface BusProps { + x: number; + y: number; + width: number; + name: string; + number?: number; + isNormal: boolean; + isShed?: boolean; +} + +const Bus = ({ x, y, width, name, number, isNormal, isShed }: BusProps) => { + const busHeight = 26.25; + return ( + + + + {name} + + {number ? ( + + {number} + + ) : null} + {isShed ? ( + + SHED + + ) : null} + + ); +}; + +const EngineGenerator = ({ x, y, number }) => { + const [isOn] = useSimVar(`GENERAL ENG MASTER ALTERNATOR:${number}`, 'Bool', maxStaleness); + + const [load] = useSimVar(`L:A32NX_ELEC_ENG_GEN_${number}_LOAD`, 'Percent', maxStaleness); + const [loadWithinNormalRange] = useSimVar(`L:A32NX_ELEC_ENG_GEN_${number}_LOAD_NORMAL`, 'Bool', maxStaleness); + + const [potential] = useSimVar(`L:A32NX_ELEC_ENG_GEN_${number}_POTENTIAL`, 'Volts', maxStaleness); + const [potentialWithinNormalRange] = useSimVar( + `L:A32NX_ELEC_ENG_GEN_${number}_POTENTIAL_NORMAL`, + 'Bool', + maxStaleness, + ); + + const [frequency] = useSimVar(`L:A32NX_ELEC_ENG_GEN_${number}_FREQUENCY`, 'Hertz', maxStaleness); + const [frequencyWithinNormalRange] = useSimVar( + `L:A32NX_ELEC_ENG_GEN_${number}_FREQUENCY_NORMAL`, + 'Bool', + maxStaleness, + ); + + const allParametersWithinNormalRange = + loadWithinNormalRange && potentialWithinNormalRange && frequencyWithinNormalRange; + return ( + + + + + GEN + + + {number} + + {isOn ? ( + <> + + + + + ) : ( + + OFF + + )} + + ); +}; + +const ApuGenerator = ({ x, y }) => { + const [masterSwPbOn] = useSimVar('L:A32NX_OVHD_APU_MASTER_SW_PB_IS_ON', 'Bool', maxStaleness); + const [genSwitchOn] = useSimVar('APU GENERATOR SWITCH:1', 'Bool', maxStaleness); + + const [load] = useSimVar('L:A32NX_ELEC_APU_GEN_1_LOAD', 'Percent', maxStaleness); + const [loadWithinNormalRange] = useSimVar('L:A32NX_ELEC_APU_GEN_1_LOAD_NORMAL', 'Bool', maxStaleness); + + const [potential] = useSimVar('L:A32NX_ELEC_APU_GEN_1_POTENTIAL', 'Volts', maxStaleness); + const [potentialWithinNormalRange] = useSimVar('L:A32NX_ELEC_APU_GEN_1_POTENTIAL_NORMAL', 'Bool', maxStaleness); + + const [frequency] = useSimVar('L:A32NX_ELEC_APU_GEN_1_FREQUENCY', 'Hertz', maxStaleness); + const [frequencyWithinNormalRange] = useSimVar('L:A32NX_ELEC_APU_GEN_1_FREQUENCY_NORMAL', 'Bool', maxStaleness); + + const allParametersWithinNormalRange = + loadWithinNormalRange && potentialWithinNormalRange && frequencyWithinNormalRange; + + const apuGenTitle = ( + + APU GEN + + ); + + return ( + + {masterSwPbOn ? ( + <> + + {apuGenTitle} + {genSwitchOn ? ( + <> + + + + + ) : ( + + OFF + + )} + + ) : null} + + ); +}; + +const ExternalPower = ({ x, y, number }) => { + const [potential] = useSimVar('L:A32NX_ELEC_EXT_PWR_POTENTIAL', 'Volts', maxStaleness); + const [potentialWithinNormalRange] = useSimVar('L:A32NX_ELEC_EXT_PWR_POTENTIAL_NORMAL', 'Bool', maxStaleness); + + const [frequency] = useSimVar('L:A32NX_ELEC_EXT_PWR_FREQUENCY', 'Hertz', maxStaleness); + const [frequencyWithinNormalRange] = useSimVar('L:A32NX_ELEC_EXT_PWR_FREQUENCY_NORMAL', 'Bool', maxStaleness); + const extPowerTitle = `EXT ${number === 1 ? 'A' : 'B'}`; + + return ( + + ); +}; + +const StaticInverter = ({ x, y }) => { + const [potential] = useSimVar('L:A32NX_ELEC_STAT_INV_POTENTIAL', 'Volts', maxStaleness); + const [potentialWithinNormalRange] = useSimVar('L:A32NX_ELEC_STAT_INV_POTENTIAL_NORMAL', 'Bool', maxStaleness); + + const [frequency] = useSimVar('L:A32NX_ELEC_STAT_INV_FREQUENCY', 'Hertz', maxStaleness); + const [frequencyWithinNormalRange] = useSimVar('L:A32NX_ELEC_STAT_INV_FREQUENCY_NORMAL', 'Bool', maxStaleness); + + return ( + + ); +}; + +const PotentialFrequencyBox = ({ + x, + y, + text, + potential, + potentialWithinNormalRange, + frequency, + frequencyWithinNormalRange, +}) => { + const allParametersWithinNormalRange = potentialWithinNormalRange && frequencyWithinNormalRange; + + return ( + + + 7 ? 'Small' : ''} ${!allParametersWithinNormalRange ? 'Amber' : ''}`} + > + {text} + + + + + ); +}; + +interface TransformerRectifierProps { + x: number; + y: number; + number: number; + titleOnly?: boolean; +} + +const TransformerRectifier = ({ x, y, number, titleOnly }: TransformerRectifierProps) => { + const [potential] = useSimVar(`L:A32NX_ELEC_TR_${number}_POTENTIAL`, 'Volts', maxStaleness); + const [potentialWithinNormalRange] = useSimVar(`L:A32NX_ELEC_TR_${number}_POTENTIAL_NORMAL`, 'Bool', maxStaleness); + + const [current] = useSimVar(`L:A32NX_ELEC_TR_${number}_CURRENT`, 'Ampere', maxStaleness); + const [currentWithinNormalRange] = useSimVar(`L:A32NX_ELEC_TR_${number}_CURRENT_NORMAL`, 'Bool', maxStaleness); + + const allParametersWithinNormalRange = potentialWithinNormalRange && currentWithinNormalRange; + + const title = ( + + {number === 3 ? 'ESS TR' : 'TR'} + + ); + + return ( + + {titleOnly ? ( + title + ) : ( + <> + + {title} + {number !== 3 ? ( + + {number} + + ) : null} + + + + )} + + ); +}; + +const TransformerRectifierTitle = ({ x, y, number }) => ( + + {number === 3 ? APU TR : TR{number}} + +); + +const EmergencyGenerator = ({ x, y, titleOnly }) => { + const [potential] = useSimVar('L:A32NX_ELEC_EMER_GEN_POTENTIAL', 'Volts', maxStaleness); + const [potentialWithinNormalRange] = useSimVar('L:A32NX_ELEC_EMER_GEN_POTENTIAL_NORMAL', 'Bool', maxStaleness); + + const [frequency] = useSimVar('L:A32NX_ELEC_EMER_GEN_FREQUENCY', 'Hertz', maxStaleness); + const [frequencyWithinNormalRange] = useSimVar('L:A32NX_ELEC_EMER_GEN_FREQUENCY_NORMAL', 'Bool', maxStaleness); + + const allParametersWithinNormalRange = potentialWithinNormalRange && frequencyWithinNormalRange; + + return ( + + {titleOnly ? ( + + EMER GEN + + ) : ( + <> + + + + EMER GEN + + + + + )} + + ); +}; + +const GalleyShed = ({ x, y }) => ( + + GALLEY + + SHED + + +); + +const IntegratedDriveGeneratorTitle = ({ x, y, number }) => { + const [connected] = useSimVar(`L:A32NX_ELEC_ENG_GEN_${number}_IDG_IS_CONNECTED`, 'Bool', maxStaleness); + return ( + + IDG + + {number} + + + ); +}; + +const IntegratedDriveGeneratorTemperature = ({ x, y, number }) => { + const [temperature] = useSimVar(`L:A32NX_ELEC_ENG_GEN_${number}_IDG_OIL_OUTLET_TEMPERATURE`, 'Celsius', maxStaleness); + return ( + + {Math.round(temperature)} + + °C + + + ); +}; + +const IntegratedDriveGeneratorDisconnected = ({ x, y }) => ( + + DISC + +); + +interface ArrowProps { + x: number; + y: number; + direction: 'up' | 'down' | 'right' | 'left'; + green?: boolean; + white?: boolean; + amber?: boolean; + description?: string; +} + +const Arrow = ({ x, y, direction, green, amber }: ArrowProps) => { + const classes = classNames({ Green: green }, { Amber: amber }); + switch (direction) { + default: + case 'up': + return ; + case 'down': + return ; + case 'right': + return ; + case 'left': + return ; + } +}; + +const arrowSize = 13.737375; + +interface WireProps { + d: string; + amber?: boolean; + description?: string; +} + +const Wire = ({ d, amber }: WireProps) => { + const classes = classNames({ Green: !amber }, { Amber: amber }); + return ; +}; diff --git a/hdw-a339x/src/systems/instruments/src/SD/Pages/ElecDc/ElecDc.scss b/hdw-a339x/src/systems/instruments/src/SD/Pages/ElecDc/ElecDc.scss new file mode 100644 index 00000000..116e801e --- /dev/null +++ b/hdw-a339x/src/systems/instruments/src/SD/Pages/ElecDc/ElecDc.scss @@ -0,0 +1,77 @@ +@import "../../style"; +@import "../../../Common/definitions"; + +#main-elec-dc { + .Box { + stroke: $display-grey; + fill: none; + stroke-width: 2.5px; + } + + path { + stroke: $display-white; + stroke-width: 2.25px; + stroke-linecap: square; + stroke-linejoin: miter; + + &.Green { + stroke: $display-green; + } + + &.Amber { + stroke: $display-amber; + } + } + + rect.Bus { + fill: $display-grey; + } + + text { + fill: $display-white; + font-size: 19px; + + &.ExtraLarge { + font-size: 26px; + } + + // Seriously, we need to fix this at some point ^^ + &.QuiteLarge { + font-size: 24px; + } + + &.Large { + font-size: 22px; + } + + &.Small { + font-size: 16.875px; + } + + &.ExtraSmall { + font-size: 15px; + } + + &.Middle { + text-anchor: middle; + text-align: middle; + } + + &.Right { + text-anchor: end; + text-align: end; + } + + &.Green { + fill: $display-green; + } + + &.Amber { + fill: $display-amber; + } + + &.Cyan { + fill: $display-cyan; + } + } +} diff --git a/hdw-a339x/src/systems/instruments/src/SD/Pages/ElecDc/ElecDc.tsx b/hdw-a339x/src/systems/instruments/src/SD/Pages/ElecDc/ElecDc.tsx new file mode 100644 index 00000000..8750fb1d --- /dev/null +++ b/hdw-a339x/src/systems/instruments/src/SD/Pages/ElecDc/ElecDc.tsx @@ -0,0 +1,482 @@ +// Copyright (c) 2021-2023 FlyByWire Simulations +// +// SPDX-License-Identifier: GPL-3.0 + +import React from 'react'; +import classNames from 'classnames'; +import { useSimVar } from '@flybywiresim/fbw-sdk'; +import { PageTitle } from '../../Common/PageTitle'; +import { EcamPage } from '../../Common/EcamPage'; +import { SvgGroup } from '../../Common/SvgGroup'; + +import './ElecDc.scss'; + +const maxStaleness = 300; + +export const ElecDcPage = () => { + const [dc1IsPowered] = useSimVar('L:A32NX_ELEC_DC_1_BUS_IS_POWERED', 'Bool', maxStaleness); + const [dc2IsPowered] = useSimVar('L:A32NX_ELEC_DC_2_BUS_IS_POWERED', 'Bool', maxStaleness); + const [dcEssIsPowered] = useSimVar('L:A32NX_ELEC_DC_ESS_BUS_IS_POWERED', 'Bool', maxStaleness); + const [dcEssShedBusIsPowered] = useSimVar('L:A32NX_ELEC_DC_ESS_SHED_BUS_IS_POWERED', 'Bool', maxStaleness); + // const [ac1IsPowered] = useSimVar('L:A32NX_ELEC_AC_1_BUS_IS_POWERED', 'Bool', maxStaleness); + //const [ac2IsPowered] = useSimVar('L:A32NX_ELEC_AC_2_BUS_IS_POWERED', 'Bool', maxStaleness); + const [staticInverterInUse] = useSimVar('L:A32NX_ELEC_CONTACTOR_15XE2_IS_CLOSED', 'Bool', maxStaleness); + //const [galleyIsShed] = useSimVar('L:A32NX_ELEC_GALLEY_IS_SHED', 'Bool', maxStaleness); + //const [tr1SuppliesDc1] = useSimVar('L:A32NX_ELEC_CONTACTOR_5PU1_IS_CLOSED', 'Bool', maxStaleness); + //const [tr2SuppliesDc2] = useSimVar('L:A32NX_ELEC_CONTACTOR_5PU2_IS_CLOSED', 'Bool', maxStaleness); + //const [trEssSuppliesDcEss] = useSimVar('L:A32NX_ELEC_CONTACTOR_5PU1_IS_CLOSED', 'Bool', maxStaleness); //change to correct contactor for ESS + //const [trApuSuppliesDcEss] = useSimVar('L:A32NX_ELEC_CONTACTOR_5PU1_IS_CLOSED', 'Bool', maxStaleness); //change to correct contactor for APU + //const [ac1SuppliesAcEss] = useSimVar('L:A32NX_ELEC_CONTACTOR_3XC1_IS_CLOSED', 'Bool', maxStaleness); + const [ac2SuppliesAcEss] = useSimVar('L:A32NX_ELEC_CONTACTOR_3XC2_IS_CLOSED', 'Bool', maxStaleness); + const [dc1AndDcBatConnected] = useSimVar('L:A32NX_ELEC_CONTACTOR_1PC1_IS_CLOSED', 'Bool', maxStaleness); + //const [dcBatAndDcEssConnected] = useSimVar('L:A32NX_ELEC_CONTACTOR_4PC_IS_CLOSED', 'Bool', maxStaleness); + const [dc2AndDcBatConnected] = useSimVar('L:A32NX_ELEC_CONTACTOR_1PC2_IS_CLOSED', 'Bool', maxStaleness); + + const [emergencyGeneratorSupplies] = useSimVar('L:A32NX_ELEC_CONTACTOR_2XE_IS_CLOSED', 'Bool', maxStaleness); + const [acEssBusContactorClosed] = useSimVar('L:A32NX_ELEC_CONTACTOR_15XE1_IS_CLOSED', 'Bool', maxStaleness); + //const [trEssSuppliesDcEss] = useSimVar('L:A32NX_ELEC_CONTACTOR_3PE_IS_CLOSED', 'Bool', maxStaleness); + + //const [externalPowerContactorClosed] = useSimVar('L:A32NX_ELEC_CONTACTOR_3XG_IS_CLOSED', 'Bool', maxStaleness); + const [apuGeneratorContactorClosed] = useSimVar('L:A32NX_ELEC_CONTACTOR_3XS_IS_CLOSED', 'Bool', maxStaleness); + const [generatorLineContactor1Closed] = useSimVar('L:A32NX_ELEC_CONTACTOR_9XU1_IS_CLOSED', 'Bool', maxStaleness); + const [generatorLineContactor2Closed] = useSimVar('L:A32NX_ELEC_CONTACTOR_9XU2_IS_CLOSED', 'Bool', maxStaleness); + const [busTieContactor1Closed] = useSimVar('L:A32NX_ELEC_CONTACTOR_11XU1_IS_CLOSED', 'Bool', maxStaleness); + const [busTieContactor2Closed] = useSimVar('L:A32NX_ELEC_CONTACTOR_11XU2_IS_CLOSED', 'Bool', maxStaleness); + + return ( + + + + {ac2SuppliesAcEss ? : null} + + {dc1AndDcBatConnected ? : null} + {dc2AndDcBatConnected ? ( + + ) : null} + + {acEssBusContactorClosed && emergencyGeneratorSupplies ? ( + <> + + + + ) : null} + + {apuGeneratorContactorClosed && busTieContactor1Closed && !busTieContactor2Closed ? ( + + ) : null} + {apuGeneratorContactorClosed && !busTieContactor1Closed && busTieContactor2Closed ? ( + + ) : null} + {apuGeneratorContactorClosed && busTieContactor1Closed && busTieContactor2Closed ? ( + + ) : null} + + {generatorLineContactor1Closed && !busTieContactor1Closed ? ( + + ) : null} + {generatorLineContactor1Closed && busTieContactor1Closed && busTieContactor2Closed ? ( + + ) : null} + + {generatorLineContactor1Closed && !busTieContactor1Closed ? ( // ESS TR to DC ESS + + ) : null} + {generatorLineContactor1Closed && busTieContactor1Closed && busTieContactor2Closed ? ( + + ) : null} + + {generatorLineContactor1Closed && !busTieContactor1Closed ? ( // TR 2 to DC 2 + + ) : null} + {generatorLineContactor1Closed && busTieContactor1Closed && busTieContactor2Closed ? ( + + ) : null} + + {generatorLineContactor2Closed && !busTieContactor2Closed ? ( + + ) : null} + {generatorLineContactor2Closed && busTieContactor1Closed && busTieContactor2Closed ? ( + + ) : null} + + + + + + + + + + + + + + + + {staticInverterInUse ? : null} + + + + + + + + + + + ); +}; + +const Battery = ({ x, y, number }) => { + const [isAuto] = useSimVar(`L:A32NX_OVHD_ELEC_BAT_${number}_PB_IS_AUTO`, 'Bool', maxStaleness); + + const [potential] = useSimVar(`L:A32NX_ELEC_BAT_${number}_POTENTIAL`, 'Volts', maxStaleness); + const [potentialWithinNormalRange] = useSimVar(`L:A32NX_ELEC_BAT_${number}_POTENTIAL_NORMAL`, 'Bool', maxStaleness); + + const [current] = useSimVar(`L:A32NX_ELEC_BAT_${number}_CURRENT`, 'Ampere', maxStaleness); + const [currentWithinNormalRange] = useSimVar(`L:A32NX_ELEC_BAT_${number}_CURRENT_NORMAL`, 'Bool', maxStaleness); + + const allParametersWithinNormalRange = potentialWithinNormalRange && currentWithinNormalRange; + + const [staticInverterInUse] = useSimVar('L:A32NX_ELEC_CONTACTOR_15XE2_IS_CLOSED', 'Bool', maxStaleness); + + return ( + + + {number === 3 ? ( + <> + + APU + + + BAT + + + ) : ( + <> + + BAT + + + {number} + + + )} + {isAuto ? ( + <> + + + + ) : ( + + OFF + + )} + {number === 1 && staticInverterInUse ? ( + <> + + + STAT INV + + + ) : null} + + ); +}; + +const BatteryToBatBusWire = ({ x, y, number }) => { + const [contactorClosed] = useSimVar(`L:A32NX_ELEC_CONTACTOR_6PB${number}_IS_CLOSED`, 'Bool', maxStaleness); + const [current] = useSimVar(`L:A32NX_ELEC_BAT_${number}_CURRENT`, 'Ampere', maxStaleness); + const [showArrowWhenContactorClosed] = useSimVar( + `L:A32NX_ELEC_CONTACTOR_6PB${number}_SHOW_ARROW_WHEN_CLOSED`, + 'Bool', + maxStaleness, + ); + + const showArrow = contactorClosed && showArrowWhenContactorClosed; + const isCharging = current > 0; + const isDischarging = current < 0; + + const pointingRight = (number === 2 && isCharging) || (number === 1 && isDischarging); + + if (!contactorClosed) { + return <>; + } + + return ( + + {showArrow ? ( + <> + {pointingRight ? ( + <> + + + + ) : ( + <> + + + + )} + + ) : ( + + )} + + ); +}; + +const ElectricalProperty = ({ x, y, value, unit, isWithinNormalRange }) => ( + + {Math.round(value)} + + {unit} + + +); + +const Box = ({ width, height }) => ; + +interface BusProps { + x: number; + y: number; + width: number; + name: string; + number?: number; + isNormal: boolean; + isShed?: boolean; +} + +const Bus = ({ x, y, width, name, number, isNormal, isShed }: BusProps) => { + const busHeight = 26.25; + return ( + + + + {name} + + {number ? ( + + {number} + + ) : null} + {isShed ? ( + + SHED + + ) : null} + + ); +}; + +const BatteryBus = ({ x, y, width, number }) => { + const [isPowered] = useSimVar('L:A32NX_ELEC_DC_BAT_BUS_IS_POWERED', 'Bool', maxStaleness); + + const [bat1IsAuto] = useSimVar('L:A32NX_OVHD_ELEC_BAT_1_PB_IS_AUTO', 'Bool', maxStaleness); + const [bat2IsAuto] = useSimVar('L:A32NX_OVHD_ELEC_BAT_2_PB_IS_AUTO', 'Bool', maxStaleness); + const atLeastOneBatteryIsAuto = bat1IsAuto || bat2IsAuto; + + const potentialIsWithinNormalRange = useSimVar('L:A32NX_ELEC_DC_BAT_BUS_POTENTIAL_NORMAL', 'Bool', maxStaleness); + + const nameDc = atLeastOneBatteryIsAuto ? 'DC BAT' : 'XX'; + const nameApu = atLeastOneBatteryIsAuto ? 'DC APU' : 'XX'; + return ( + + ); +}; + +const StaticInverter = ({ x, y }) => { + const [potential] = useSimVar('L:A32NX_ELEC_STAT_INV_POTENTIAL', 'Volts', maxStaleness); + const [potentialWithinNormalRange] = useSimVar('L:A32NX_ELEC_STAT_INV_POTENTIAL_NORMAL', 'Bool', maxStaleness); + + const [frequency] = useSimVar('L:A32NX_ELEC_STAT_INV_FREQUENCY', 'Hertz', maxStaleness); + const [frequencyWithinNormalRange] = useSimVar('L:A32NX_ELEC_STAT_INV_FREQUENCY_NORMAL', 'Bool', maxStaleness); + + return ( + + ); +}; + +const PotentialFrequencyBox = ({ + x, + y, + text, + potential, + potentialWithinNormalRange, + frequency, + frequencyWithinNormalRange, +}) => { + const allParametersWithinNormalRange = potentialWithinNormalRange && frequencyWithinNormalRange; + + return ( + + + 7 ? 'Small' : ''} ${!allParametersWithinNormalRange ? 'Amber' : ''}`} + > + {text} + + + + + ); +}; + +interface TransformerRectifierProps { + x: number; + y: number; + number: number; + titleOnly?: boolean; +} + +const TransformerRectifier = ({ x, y, number, titleOnly }: TransformerRectifierProps) => { + const [potential] = useSimVar(`L:A32NX_ELEC_TR_${number}_POTENTIAL`, 'Volts', maxStaleness); + const [potentialWithinNormalRange] = useSimVar(`L:A32NX_ELEC_TR_${number}_POTENTIAL_NORMAL`, 'Bool', maxStaleness); + + const [current] = useSimVar(`L:A32NX_ELEC_TR_${number}_CURRENT`, 'Ampere', maxStaleness); + const [currentWithinNormalRange] = useSimVar(`L:A32NX_ELEC_TR_${number}_CURRENT_NORMAL`, 'Bool', maxStaleness); + + const allParametersWithinNormalRange = potentialWithinNormalRange && currentWithinNormalRange; + + const title = ( + + {number === 3 ? 'ESS TR' : number === 4 ? 'APU TR' : 'TR'} + + ); + + return ( + + {titleOnly ? ( + title + ) : ( + <> + + {title} + {number !== 3 && number !== 4 ? ( + + {number} + + ) : null} + + + + )} + + ); +}; + +const AcBusTitle = ({ x, y, number }) => { + return ( + + AC{number} + + ); +}; + +const StaticInverterTitle = ({ x, y }) => { + return ( + + + + STAT + + + INV + + + + ); +}; + +interface ArrowProps { + x: number; + y: number; + direction: 'up' | 'down' | 'right' | 'left'; + green?: boolean; + amber?: boolean; + description?: string; +} + +const Arrow = ({ x, y, direction, green, amber }: ArrowProps) => { + const classes = classNames({ Green: green }, { Amber: amber }); + switch (direction) { + default: + case 'up': + return ; + case 'down': + return ; + case 'right': + return ; + case 'left': + return ; + } +}; + +const arrowSize = 13.737375; + +interface WireProps { + d: string; + amber?: boolean; + description?: string; +} + +const Wire = ({ d, amber }: WireProps) => { + const classes = classNames({ Green: !amber }, { Amber: amber }); + return ; +}; diff --git a/hdw-a339x/src/systems/instruments/src/SD/PagesContainer.tsx b/hdw-a339x/src/systems/instruments/src/SD/PagesContainer.tsx index 884bee65..d85da89a 100644 --- a/hdw-a339x/src/systems/instruments/src/SD/PagesContainer.tsx +++ b/hdw-a339x/src/systems/instruments/src/SD/PagesContainer.tsx @@ -7,7 +7,8 @@ import { useUpdate, useSimVar, useArinc429Var } from '@flybywiresim/fbw-sdk'; import { EngPage } from './Pages/Eng/Eng'; import { BleedPage } from './Pages/Bleed/Bleed'; import { PressPage } from './Pages/Press/Press'; -import { ElecPage } from './Pages/Elec/Elec'; +import { ElecAcPage } from './Pages/ElecAc/ElecAc'; +import { ElecDcPage } from './Pages/ElecDc/ElecDc'; import { HydPage } from './Pages/Hyd/Hyd'; import { FuelPage } from './Pages/Fuel/Fuel'; import { ApuPage } from './Pages/Apu/Apu'; @@ -271,8 +272,8 @@ export const PagesContainer = () => { 0: , 1: , 2: , - 3: , - 4: , + 3: , + 4: , 5: , 6: , 7: ,