Skip to content

Commit

Permalink
feat(a380x/fws): Automatic normal checklist reset (flybywiresim#9614)
Browse files Browse the repository at this point in the history
* fix fws: no mobile memo visiblity

* feat: fws reset normal checklists on power up.

* cleanup abnormal sensed debug info

* feat (fws): add reset of CL after shutdown & on GA

* fix: remove flightphase inhibit of no mobile

* docs: update changelog

* fix: use departure change id as starting point after GA

* docs: improve changelog wording

* fix fwc phase merge conflicts
  • Loading branch information
BravoMike99 authored Dec 29, 2024
1 parent d028e95 commit 3bf1438
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 68 deletions.
1 change: 1 addition & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
1. [A380X/COND] Fix wasm crash during rapid decompression - @mjuhe (Miquel Juhe)
1. [A32NX/EWD] Corrected fuel flow step to 20kg/40lbs per hour - @BravoMike99 (bruno_pt99)
1. [A380X] Fix EWD avail. thrust fill area & PFD rudder trim visibility on ground - @flogross89 (floridude)
1. [A380X/FWS] Add automatic normal checklists reset on powerup, go around & shutdown - @BravoMike99 (bruno_pt99)
1. [A32NX/PFD] Synchronize flashing/pulsing components across PFD - @lukecologne (luke)
1. [A380X/LIGHTS] Fix function of FCU brightness knobs - @heclak (Heclak)
1. [A380X/FWS] Fix "NO ZFW OR ZFWCG DATA" ECAM alert after landing - @flogross89 (floridude)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
//
// SPDX-License-Identifier: GPL-3.0

import {
AbnormalProcedure,
EcamAbnormalSensedProcedures,
isChecklistAction,
} from '../../../instruments/src/MsfsAvionicsCommon/EcamMessages';
import { EcamAbnormalSensedProcedures } from '../../../instruments/src/MsfsAvionicsCommon/EcamMessages';
import {
MappedSubject,
Subject,
Expand Down Expand Up @@ -88,28 +84,6 @@ export class FwsAbnormalSensed {
}),
);
this.pub.pub('fws_abn_sensed_procedures', flattened, true);
SimVar.SetSimVarValue('L:A32NX_EWD_DEBUG_ABNORMAL', 'string', flattened[0] ? flattened[0].id : '');

console.log('%c------- ABN SENSED PROCEDURES -------', 'font-family:monospace; font-weight: bold');
// Debug output for ABN sensed procedures
this.fws.activeAbnormalSensedList.get().forEach((val, key) => {
const proc = EcamAbnormalSensedProcedures[key] as AbnormalProcedure;
console.log('%c' + proc.title, 'font-family:monospace; font-weight: bold');
proc.items.forEach((it, itemIdx) => {
if (val.itemsToShow[itemIdx]) {
const cpl = isChecklistAction(it)
? val.itemsChecked[itemIdx]
? it.labelNotCompleted
: ` .......... ${it.labelNotCompleted}`
: '';
console.log(
`%c${' '.repeat(it.level ?? 0)} ${val.itemsChecked[itemIdx] ? 'X' : 'O'} ${it.name} ${cpl} ${it.style ? `(${it.style})` : ''}`,
'font-family:monospace; font-weight: bold',
);
}
});
});
console.log('%c------- END -------', 'font-family:monospace; font-weight: bold');
},
true,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class FwsCore {

private readonly startupTimer = new DebounceTimer();

private readonly startupCompleted = Subject.create(false);
public readonly startupCompleted = Subject.create(false);

public readonly soundManager = new FwsSoundManager(this.bus, this.startupCompleted);

Expand Down Expand Up @@ -559,7 +559,6 @@ export class FwsCore {
public readonly engine4Running = Subject.create(false);

public readonly allBatteriesOff = Subject.create(false);

/* 26 - FIRE */

public readonly fduDiscreteWord = Arinc429Register.empty();
Expand Down Expand Up @@ -1082,6 +1081,14 @@ export class FwsCore {

public readonly flightPhaseInhibitOverrideNode = new NXLogicMemoryNode(false);

public readonly manualCheckListReset = Subject.create(false);

private readonly phase12ShutdownMemoryNode = new NXLogicMemoryNode();

private readonly shutDownFor50MinutesClResetConfNode = new NXLogicConfirmNode(3000);

public readonly shutDownFor50MinutesCheckListReset = Subject.create(false);

/** If one of the ADR's CAS is above V1 - 4kts, confirm for 0.3s */
public readonly v1SpeedConfirmNode = new NXLogicConfirmNode(0.3);

Expand Down Expand Up @@ -1642,18 +1649,24 @@ export class FwsCore {
FwsCore.AURAL_SC_INHIBIT_TIME,
);

this.acESSBusPowered.sub((v) => {
if (v) {
this.startupTimer.schedule(() => {
this.startupCompleted.set(true);
console.log('PseudoFWC startup completed.');
}, FwsCore.FWC_STARTUP_TIME);
} else {
this.startupTimer.clear();
this.startupCompleted.set(false);
console.log('PseudoFWC shut down.');
}
});
if (this.fwsNumber === 1) {
this.dcESSBusPowered.sub((v) => this.handlePowerChange(v));
} else {
this.dc2BusPowered.sub((v) => this.handlePowerChange(v));
}
}

private handlePowerChange(powered: boolean) {
if (powered) {
this.startupTimer.schedule(() => {
this.startupCompleted.set(true);
console.log('PseudoFWC startup completed.');
}, FwsCore.FWC_STARTUP_TIME);
} else {
this.startupTimer.clear();
this.startupCompleted.set(false);
console.log('PseudoFWC shut down.');
}
}

private registerKeyEvents() {
Expand Down Expand Up @@ -1850,6 +1863,15 @@ export class FwsCore {
this.phase815MinConfNode.write(this.flightPhase.get() === 8, deltaTime);
this.phase112.set(flightPhase112);

this.phase12ShutdownMemoryNode.write(this.flightPhase.get() == 12, !this.phase112.get());

this.shutDownFor50MinutesCheckListReset.set(
this.shutDownFor50MinutesClResetConfNode.write(
!this.manualCheckListReset.get() && this.phase12ShutdownMemoryNode.read(),
deltaTime,
),
);

// TO CONFIG button
this.toConfigTestRaw = SimVar.GetSimVarValue('L:A32NX_BTN_TOCONFIG', 'bool') > 0;
this.toConfigPulseNode.write(this.toConfigTestRaw, _deltaTime);
Expand Down Expand Up @@ -1898,13 +1920,13 @@ export class FwsCore {
);

/* ELECTRICAL acquisition */
this.dcESSBusPowered.set(SimVar.GetSimVarValue('L:A32NX_ELEC_DC_ESS_BUS_IS_POWERED', 'bool'));
this.dc2BusPowered.set(SimVar.GetSimVarValue('L:A32NX_ELEC_DC_2_BUS_IS_POWERED', 'bool'));
this.ac1BusPowered.set(SimVar.GetSimVarValue('L:A32NX_ELEC_AC_1_BUS_IS_POWERED', 'bool'));
this.ac2BusPowered.set(SimVar.GetSimVarValue('L:A32NX_ELEC_AC_2_BUS_IS_POWERED', 'bool'));
this.ac3BusPowered.set(SimVar.GetSimVarValue('L:A32NX_ELEC_AC_3_BUS_IS_POWERED', 'bool'));
this.ac4BusPowered.set(SimVar.GetSimVarValue('L:A32NX_ELEC_AC_4_BUS_IS_POWERED', 'bool'));
this.acESSBusPowered.set(SimVar.GetSimVarValue('L:A32NX_ELEC_AC_ESS_BUS_IS_POWERED', 'bool'));
this.dcESSBusPowered.set(SimVar.GetSimVarValue('L:A32NX_ELEC_DC_ESS_BUS_IS_POWERED', 'bool') > 0);
this.dc2BusPowered.set(SimVar.GetSimVarValue('L:A32NX_ELEC_DC_2_BUS_IS_POWERED', 'bool') > 0);
this.ac1BusPowered.set(SimVar.GetSimVarValue('L:A32NX_ELEC_AC_1_BUS_IS_POWERED', 'bool') > 0);
this.ac2BusPowered.set(SimVar.GetSimVarValue('L:A32NX_ELEC_AC_2_BUS_IS_POWERED', 'bool') > 0);
this.ac3BusPowered.set(SimVar.GetSimVarValue('L:A32NX_ELEC_AC_3_BUS_IS_POWERED', 'bool') > 0);
this.ac4BusPowered.set(SimVar.GetSimVarValue('L:A32NX_ELEC_AC_4_BUS_IS_POWERED', 'bool') > 0);
this.acESSBusPowered.set(SimVar.GetSimVarValue('L:A32NX_ELEC_AC_ESS_BUS_IS_POWERED', 'bool') > 0);

/* ENGINE AND THROTTLE acquisition */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,11 +500,11 @@ export class FwsMemos {
},
'335000003': {
// NO MOBILE
flightPhaseInhib: [2, 9, 10],
flightPhaseInhib: [],
simVarIsActive: this.fws.noMobileSwitchPosition.map((pos) => pos === 0),
whichCodeToReturn: () => [0],
codesToReturn: ['335000003'],
memoInhibit: () => this.fws.toMemo.get() === 1 || this.fws.ldgMemo.get() === 1,
memoInhibit: () => false,
failure: 0,
sysPage: SdPages.None,
side: 'RIGHT',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
// Copyright (c) 2024 FlyByWire Simulations
// SPDX-License-Identifier: GPL-3.0

import { MapSubject, SimVarValueType, Subject, SubscribableMapEventType } from '@microsoft/msfs-sdk';
import {
MappedSubject,
MapSubject,
SimVarValueType,
Subject,
SubscribableMapEventType,
SubscribableMapFunctions,
} from '@microsoft/msfs-sdk';
import { FwsEwdEvents } from 'instruments/src/MsfsAvionicsCommon/providers/FwsEwdPublisher';
import { FwsCore } from 'systems-host/systems/FlightWarningSystem/FwsCore';
import { EcamNormalProcedures } from 'instruments/src/MsfsAvionicsCommon/EcamMessages/NormalProcedures';
Expand Down Expand Up @@ -58,6 +65,34 @@ export class FwsNormalChecklists {
this.selectedLine.sub((line) => this.pub.pub('fws_active_line', line + 1, true), true); // Start at second line, headline not selectable
this.showFromLine.sub((line) => this.pub.pub('fws_show_from_line', line, true), true);

this.fws.startupCompleted.sub((v) => {
if (v) {
this.reset(null);
}
});

this.fws.shutDownFor50MinutesCheckListReset.sub((v) => {
if (v) {
this.reset(null);
}
});

this.fws.flightPhase.sub((phase) => {
if (phase !== 1) {
this.fws.manualCheckListReset.set(false);
}
});

MappedSubject.create(SubscribableMapFunctions.or(), this.fws.eng1Or2TakeoffPower, this.fws.eng3Or4TakeoffPower).sub(
(v) => {
if (v) {
this.reset(
this.getNormalProceduresKeysSorted().findIndex((i) => i === 1000006), // reset starting at departure change,
);
}
},
);

// Populate checklistState
const keys = this.getNormalProceduresKeysSorted();
keys.forEach((k) => {
Expand Down Expand Up @@ -189,23 +224,7 @@ export class FwsNormalChecklists {

// Reset all following checklists
const fromId = this.getNormalProceduresKeysSorted().findIndex((v) => v === this.checklistId.get());
const ids = this.getNormalProceduresKeysSorted();

if (fromId !== -1) {
for (let id = fromId + 1; id < ids.length; id++) {
const idFollowing = ids[id];
const clFollowing = this.checklistState.getValue(idFollowing);
const procFollowing = EcamNormalProcedures[idFollowing];
const clStateFollowing: ChecklistState = {
id: idFollowing,
checklistCompleted: procFollowing.deferred ? true : false,
itemsCompleted: [...clFollowing.itemsCompleted].map((val, index) =>
procFollowing.items[index].sensed ? val : false,
),
};
this.checklistState.setValue(idFollowing, clStateFollowing);
}
}
this.reset(fromId);
this.checklistState.setValue(this.checklistId.get(), clState);
this.selectFirst();
}
Expand Down Expand Up @@ -280,6 +299,26 @@ export class FwsNormalChecklists {
}
}

private reset(fromId: number | null) {
if (fromId !== -1) {
const ids = this.getNormalProceduresKeysSorted();
this.fws.manualCheckListReset.set(fromId !== null);
for (let id = fromId === null ? 0 : fromId + 1; id < ids.length; id++) {
const idFollowing = ids[id];
const clFollowing = this.checklistState.getValue(idFollowing);
const procFollowing = EcamNormalProcedures[idFollowing];
const clStateFollowing: ChecklistState = {
id: idFollowing,
checklistCompleted: procFollowing.deferred ? true : false,
itemsCompleted: [...clFollowing.itemsCompleted].map((val, index) =>
procFollowing.items[index].sensed ? val : false,
),
};
this.checklistState.setValue(idFollowing, clStateFollowing);
}
}
}

public sensedItems: FwsNormalChecklistsDict = {
1000001: {
whichItemsChecked: () => [null, null, !!this.fws.seatBelt.get(), null],
Expand Down

0 comments on commit 3bf1438

Please sign in to comment.