Skip to content

Commit

Permalink
fix(a380x): Various fixes pt.2: MFD, pitch trim switch, EFIS sync for…
Browse files Browse the repository at this point in the history
… LS button (flybywiresim#8926)

* check for valid xpdr code in MFD SURV

* fix ILS back course on POSITION/NAVAID

* systems-host: enable lint (no functional changes)

* disable back course

* fix deselect navaid

* add PITCH TRIM switch

* fix LS EFIS sync

* remove debug messages

* Revert "systems-host: enable lint (no functional changes)"

This reverts commit bc1258d.

* Update fbw-a380x/src/systems/instruments/src/MFD/pages/FMS/POSITION/MfdFmsPositionNavaids.tsx

Co-authored-by: Michael Corcoran <tracer@outlook.co.nz>

* don't use min/max for squawk code

* pass only positive courses to MMR

---------

Co-authored-by: Michael Corcoran <tracer@outlook.co.nz>
  • Loading branch information
flogross89 and tracernz authored Sep 18, 2024
1 parent 61cb427 commit 99f96a9
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 156 deletions.
8 changes: 4 additions & 4 deletions fbw-a32nx/src/systems/fmgc/src/navigation/NavaidTuner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,12 +621,12 @@ export class NavaidTuner {
return this.adfTuningStatus.map((adfStatus) => adfStatus.facility).filter((fac) => fac !== undefined);
}

deselectNavaid(icao: string): void {
this.navaidSelectionManager.deselectNavaid(icao);
deselectNavaid(databaseId: string): void {
this.navaidSelectionManager.deselectNavaid(databaseId);
}

reselectNavaid(icao: string): void {
this.navaidSelectionManager.reselectNavaid(icao);
reselectNavaid(databaseId: string): void {
this.navaidSelectionManager.reselectNavaid(databaseId);
}

get deselectedNavaids(): string[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@
(L:A32NX_EFIS_L_ND_MODE) (&gt;L:A380X_EFIS_L_ND_MODE)
(L:A32NX_EFIS_R_ND_MODE) (&gt;L:A380X_EFIS_R_ND_MODE)

(L:A380X_EFIS_L_LS_BUTTON_IS_ON) (&gt;L:BTN_LS_1_FILTER_ACTIVE)
(L:A380X_EFIS_R_LS_BUTTON_IS_ON) (&gt;L:BTN_LS_2_FILTER_ACTIVE)

0

(L:A380X_EFIS_L_ACTIVE_FILTER) 1 == if{
Expand Down Expand Up @@ -514,12 +511,6 @@
<EMISSIVE_CODE>(L:A32NX_ELEC_DC_1_BUS_IS_POWERED, Bool)</EMISSIVE_CODE>
</UseTemplate>

<UseTemplate Name="ASOBO_LIGHTING_Panel_Emissive_Template">
<NODE_ID>LEVER_ELEVATORTRIM_DECAL</NODE_ID>
<POTENTIOMETER>85</POTENTIOMETER>
<EMISSIVE_CODE>(L:A32NX_ELEC_DC_1_BUS_IS_POWERED, Bool)</EMISSIVE_CODE>
</UseTemplate>

<UseTemplate Name="ASOBO_LIGHTING_Panel_Emissive_Template">
<NODE_ID>pedestal_cables</NODE_ID>
<POTENTIOMETER>85</POTENTIOMETER>
Expand Down Expand Up @@ -899,28 +890,6 @@
<NODE_ID>PUSH_THROTTLE_2</NODE_ID>
</UseTemplate>

<UseTemplate Name="FBW_HANDLING_Wheel_ElevatorTrim_Template">
<ANIM_NAME>lever_trimtab_elevator_key_pct</ANIM_NAME>
<NODE_ID>LEVER_ELEVATORTRIM_1</NODE_ID>
<NODE_ID2>LEVER_ELEVATORTRIM_2</NODE_ID2>
<REPEAT_ANIM>5</REPEAT_ANIM>
<DRAG_AXIS_SCALE>20</DRAG_AXIS_SCALE>
<DRAG_MIN_VALUE>-4854</DRAG_MIN_VALUE> <!-- Limit to -4.5 deg -->
</UseTemplate>

<UseTemplate Name="ASOBO_HANDLING_Indicator_ElevatorTrim_Template">
<ANIM_NAME>LEVER_ELEVATORTRIM_DECAL</ANIM_NAME>
<MIN_DISPLAYABLE>-4</MIN_DISPLAYABLE>
<MAX_DISPLAYABLE>13.5</MAX_DISPLAYABLE>
<REF_VALUE_0>-4</REF_VALUE_0>
<ANIM_VALUE_0>0</ANIM_VALUE_0>
<REF_VALUE_1>13</REF_VALUE_1>
<ANIM_VALUE_1>94</ANIM_VALUE_1>
<REF_VALUE_2>13.5</REF_VALUE_2>
<ANIM_VALUE_2>100</ANIM_VALUE_2>
<MAX_POINT_INDEX>2</MAX_POINT_INDEX>
</UseTemplate>

<UseTemplate Name="ASOBO_GT_Component_Emissive_Gauge">
<NODE_ID>DECAL_THROTTLE_01</NODE_ID>
<POTENTIOMETER>85</POTENTIOMETER>
Expand Down Expand Up @@ -1036,8 +1005,8 @@
<AIRBUS_TYPE />
<ANIM_NAME>KNOB_RUDDERTRIM</ANIM_NAME>
<NODE_ID>KNOB_RUDDERTRIM</NODE_ID>
<RESET_PUSH_ANIM_NAME>PUSH_RUDDERTRIM_RESET</RESET_PUSH_ANIM_NAME>
<RESET_PUSH_NODE_ID>PUSH_RUDDERTRIM_RESET</RESET_PUSH_NODE_ID>
<RESET_PUSH_ANIM_NAME>PUSH_TRIM_RESET</RESET_PUSH_ANIM_NAME>
<RESET_PUSH_NODE_ID>PUSH_TRIM_RESET</RESET_PUSH_NODE_ID>
</UseTemplate>

<UseTemplate Name="FBW_HANDLING_Lever_With_Button_Flaps_Template">
Expand Down Expand Up @@ -1082,6 +1051,12 @@
<TYPE>AIRLINER</TYPE>
<TOOLTIPID>TT:COCKPIT.TOOLTIPS.SPEEDBRAKE_LEVER</TOOLTIPID>
</UseTemplate>

<UseTemplate Name="A380X_SWITCH_PITCH_TRIM">
<NODE_ID>SWITCH_TRIM_PITCH</NODE_ID>
<ANIM_NAME>SWITCH_TRIM_PITCH</ANIM_NAME>
<INVERT_ANIM>1</INVERT_ANIM>
</UseTemplate>
</Component>

<Component ID="WeatherRadar">
Expand Down Expand Up @@ -4543,12 +4518,12 @@

<Component ID="Right_Pedestal_Misc">
<UseTemplate Name="FBW_Push_Held">
<NODE_ID>PUSH_PANELCS_AIDS</NODE_ID>
<HOLD_SIMVAR>L:A32NX_AIDS_PRINT_ON</HOLD_SIMVAR>
<TOOLTIP>Print data</TOOLTIP>
<NODE_ID>PUSH_ACMS_TRIGGER</NODE_ID>
<HOLD_SIMVAR>L:A32NX_ACMS_TRIGGER_ON</HOLD_SIMVAR>
<TOOLTIP>ACMS trigger (Inop.)</TOOLTIP>
</UseTemplate>
<UseTemplate Name="FBW_Push_Held">
<NODE_ID>PUSH_PANELCS_DFDR</NODE_ID>
<NODE_ID>PUSH_DFDR_EVENT</NODE_ID>
<HOLD_SIMVAR>L:A32NX_DFDR_EVENT_ON</HOLD_SIMVAR>
<TOOLTIP>Print data (Inop.)</TOOLTIP>
</UseTemplate>
Expand Down Expand Up @@ -5179,15 +5154,15 @@

<Component ID="DOOR_PANEL">
<UseTemplate Name="A32NX_SWITCH_DOORPANEL_LOCK">
<NODE_ID>SWITCH_DOORPANEL_LOCK</NODE_ID>
<ANIM_NAME>SWITCH_DOORPANEL_LOCK</ANIM_NAME>
<NODE_ID>LOCK_DOOR_LCKG_SYS</NODE_ID>
<ANIM_NAME>LOCK_DOOR_LCKG_SYS</ANIM_NAME>
<INVERT_ANIM>1</INVERT_ANIM>
</UseTemplate>
<UseTemplate Name="A32NX_PUSH_DOORPANEL_OPEN">
<NODE_ID>PUSH_DOORPANEL_OPEN</NODE_ID>
<ANIM_NAME>PUSH_DOORPANEL_OPEN</ANIM_NAME>
<SEQ1_POWERED>(L:A32NX_ELEC_AC_2_BUS_IS_POWERED, Bool)</SEQ1_POWERED>
<SEQ2_POWERED>(L:A32NX_ELEC_AC_2_BUS_IS_POWERED, Bool)</SEQ2_POWERED>
<NODE_ID>PUSH_DOOR_LCKG_SYS</NODE_ID>
<ANIM_NAME>PUSH_DOOR_LCKG_SYS</ANIM_NAME>
<SEQ1_POWERED>(L:A32NX_ELEC_DC_1_BUS_IS_POWERED, Bool)</SEQ1_POWERED>
<SEQ2_POWERED>(L:A32NX_ELEC_DC_1_BUS_IS_POWERED, Bool)</SEQ2_POWERED>
</UseTemplate>
</Component>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,21 @@
</Extend>
</Presets>
</InputEvent>

<Template Name="A380X_SWITCH_PITCH_TRIM">
<Component ID="#NODE_ID#" Node="#NODE_ID#">
<UseTemplate Name="ASOBO_GT_Switch_3States">
<ANIM_NAME>#NODE_ID#</ANIM_NAME>
<PART_ID>#NODE_ID#</PART_ID>
<SWITCH_DIRECTION>Vertical</SWITCH_DIRECTION>
<WWISE_EVENT>clds</WWISE_EVENT>
<CODE_POS_0>(&gt;K:ELEV_TRIM_DN)</CODE_POS_0>
<CODE_POS_2>(&gt;K:ELEV_TRIM_UP)</CODE_POS_2>
<STATE_MAX_TIMER>0.01</STATE_MAX_TIMER>
<STATE0_TIMER>0.01</STATE0_TIMER>
<MOMENTARY_SWITCH>True</MOMENTARY_SWITCH>
<MOMENTARY_REPEAT_FREQUENCY>75</MOMENTARY_REPEAT_FREQUENCY>
</UseTemplate>
</Component>
</Template>
</ModelBehaviors>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ClockEvents, FSComponent, Subject, VNode } from '@microsoft/msfs-sdk';

import './MfdFmsPositionNavaids.scss';
import { NavaidSubsectionCode } from '@flybywiresim/fbw-sdk';
import { AbstractMfdPageProps } from 'instruments/src/MFD/MFD';
import { Footer } from 'instruments/src/MFD/pages/common/Footer';

Expand Down Expand Up @@ -137,7 +138,9 @@ export class MfdFmsPositionNavaids extends FmsPage<MfdFmsPositionNavaidsProps> {

this.deselectedNavaids.forEach((v, i) => {
if (this.props.fmcService.master?.navaidTuner.deselectedNavaids[i]) {
v.set(this.props.fmcService.master.navaidTuner.deselectedNavaids[i]);
// FIXME pass full navaid objects to deselected navaids so we can get the ident.
// Taking it from the databaseId is not safe but all we can do for now.
v.set(this.props.fmcService.master.navaidTuner.deselectedNavaids[i].substring(7).trim());
} else {
v.set(null);
}
Expand All @@ -150,6 +153,14 @@ export class MfdFmsPositionNavaids extends FmsPage<MfdFmsPositionNavaidsProps> {
this.thirdRowIdentRef.instance.style.visibility = mmr.ident ? 'visible' : 'hidden';
}

private async parseNavaid(navaid: string, onlyVor = false) {
const navaids = await (onlyVor
? NavigationDatabaseService.activeDatabase.searchVor(navaid)
: NavigationDatabaseService.activeDatabase.searchAllNavaid(navaid));

return this.props.mfd.deduplicateFacilities(navaids);
}

private deselectGlide() {
// TODO
}
Expand All @@ -163,21 +174,21 @@ export class MfdFmsPositionNavaids extends FmsPage<MfdFmsPositionNavaidsProps> {
this.props.fmcService.master?.addMessageToQueue(NXSystemMessages.notAllowed, undefined, undefined);
}
} else {
const navaids = await NavigationDatabaseService.activeDatabase.searchVor(ident);
// FIXME need to handle duplicate navaids and pilot navaid page if no result
if (navaids.length > 0) {
const navaid = await this.parseNavaid(ident, true);

if (navaid && navaid.subSectionCode === NavaidSubsectionCode.VhfNavaid) {
if (
this.props.fmcService.master?.navaidTuner.deselectedNavaids.find(
(databaseId) => databaseId === navaids[0].databaseId,
(databaseId) => databaseId === navaid.databaseId,
)
) {
this.props.fmcService.master.addMessageToQueue(
NXSystemMessages.xxxIsDeselected.getModifiedMessage(navaids[0].ident),
NXSystemMessages.xxxIsDeselected.getModifiedMessage(navaid.ident),
undefined,
undefined,
);
} else {
this.props.fmcService.master?.navaidTuner.setManualVor(index, navaids[0]);
this.props.fmcService.master?.navaidTuner.setManualVor(index, navaid);
}
}
}
Expand Down Expand Up @@ -212,9 +223,9 @@ export class MfdFmsPositionNavaids extends FmsPage<MfdFmsPositionNavaidsProps> {
}
} else {
const ils = await NavigationDatabaseService.activeDatabase.backendDatabase.getILSs([ident]);
// FIXME need to handle duplicate navaids and pilot navaid page if no result
if (ils.length > 0) {
await this.props.fmcService.master?.navaidTuner.setManualIls(ils[0]);
const deduplicatedIls = await this.props.mfd.deduplicateFacilities(ils);
if (deduplicatedIls) {
await this.props.fmcService.master?.navaidTuner.setManualIls(deduplicatedIls);
}
}
this.onNewData();
Expand All @@ -234,6 +245,21 @@ export class MfdFmsPositionNavaids extends FmsPage<MfdFmsPositionNavaidsProps> {
this.onNewData();
}

async deselectionHandler(nV: string | null, oV: string | null | undefined) {
if (nV) {
const navaid = await this.parseNavaid(nV);
if (navaid) {
this.props.fmcService.master?.navaidTuner.deselectNavaid(navaid.databaseId);
}
} else if (oV) {
const navaid = await this.parseNavaid(oV);
if (navaid) {
this.props.fmcService.master?.navaidTuner.reselectNavaid(navaid.databaseId);
}
}
this.onNewData();
}

public onAfterRender(node: VNode): void {
super.onAfterRender(node);

Expand Down Expand Up @@ -424,17 +450,8 @@ export class MfdFmsPositionNavaids extends FmsPage<MfdFmsPositionNavaidsProps> {
<div style="width: 45%; display: flex; justify-content: space-between; margin-bottom: 10px;">
<div>
<InputField<string>
// FIXME all these need to handle duplicate names, and actually validate the navaid exists
dataEntryFormat={new NavaidIdentFormat('-')}
dataHandlerDuringValidation={async (nV, oV) => {
// FIXME these functions require a databaseId to uniquely id the navaid, not an ident
if (nV) {
this.props.fmcService.master?.navaidTuner.deselectNavaid(nV);
} else if (oV) {
this.props.fmcService.master?.navaidTuner.reselectNavaid(oV);
}
this.onNewData();
}}
dataHandlerDuringValidation={this.deselectionHandler.bind(this)}
value={this.deselectedNavaids[0]}
alignText="center"
errorHandler={(e) => this.props.fmcService.master?.showFmsErrorMessage(e)}
Expand All @@ -445,15 +462,7 @@ export class MfdFmsPositionNavaids extends FmsPage<MfdFmsPositionNavaidsProps> {
<div>
<InputField<string>
dataEntryFormat={new NavaidIdentFormat('-')}
dataHandlerDuringValidation={async (nV, oV) => {
// FIXME these functions require a databaseId to uniquely id the navaid, not an ident
if (nV) {
this.props.fmcService.master?.navaidTuner.deselectNavaid(nV);
} else if (oV) {
this.props.fmcService.master?.navaidTuner.reselectNavaid(oV);
}
this.onNewData();
}}
dataHandlerDuringValidation={this.deselectionHandler.bind(this)}
value={this.deselectedNavaids[1]}
alignText="center"
disabled={this.deselectedNavaids[0].map((it) => it === null)}
Expand All @@ -465,15 +474,7 @@ export class MfdFmsPositionNavaids extends FmsPage<MfdFmsPositionNavaidsProps> {
<div>
<InputField<string>
dataEntryFormat={new NavaidIdentFormat('-')}
dataHandlerDuringValidation={async (nV, oV) => {
// FIXME these functions require a databaseId to uniquely id the navaid, not an ident
if (nV) {
this.props.fmcService.master?.navaidTuner.deselectNavaid(nV);
} else if (oV) {
this.props.fmcService.master?.navaidTuner.reselectNavaid(oV);
}
this.onNewData();
}}
dataHandlerDuringValidation={this.deselectionHandler.bind(this)}
value={this.deselectedNavaids[2]}
alignText="center"
disabled={this.deselectedNavaids[1].map((it) => it === null)}
Expand All @@ -487,15 +488,7 @@ export class MfdFmsPositionNavaids extends FmsPage<MfdFmsPositionNavaidsProps> {
<div>
<InputField<string>
dataEntryFormat={new NavaidIdentFormat('-')}
dataHandlerDuringValidation={async (nV, oV) => {
// FIXME these functions require a databaseId to uniquely id the navaid, not an ident
if (nV) {
this.props.fmcService.master?.navaidTuner.deselectNavaid(nV);
} else if (oV) {
this.props.fmcService.master?.navaidTuner.reselectNavaid(oV);
}
this.onNewData();
}}
dataHandlerDuringValidation={this.deselectionHandler.bind(this)}
value={this.deselectedNavaids[3]}
alignText="center"
disabled={this.deselectedNavaids[2].map((it) => it === null)}
Expand All @@ -507,15 +500,7 @@ export class MfdFmsPositionNavaids extends FmsPage<MfdFmsPositionNavaidsProps> {
<div>
<InputField<string>
dataEntryFormat={new NavaidIdentFormat('-')}
dataHandlerDuringValidation={async (nV, oV) => {
// FIXME these functions require a databaseId to uniquely id the navaid, not an ident
if (nV) {
this.props.fmcService.master?.navaidTuner.deselectNavaid(nV);
} else if (oV) {
this.props.fmcService.master?.navaidTuner.reselectNavaid(oV);
}
this.onNewData();
}}
dataHandlerDuringValidation={this.deselectionHandler.bind(this)}
value={this.deselectedNavaids[4]}
alignText="center"
disabled={this.deselectedNavaids[3].map((it) => it === null)}
Expand All @@ -527,15 +512,7 @@ export class MfdFmsPositionNavaids extends FmsPage<MfdFmsPositionNavaidsProps> {
<div>
<InputField<string>
dataEntryFormat={new NavaidIdentFormat('-')}
dataHandlerDuringValidation={async (nV, oV) => {
// FIXME these functions require a databaseId to uniquely id the navaid, not an ident
if (nV) {
this.props.fmcService.master?.navaidTuner.deselectNavaid(nV);
} else if (oV) {
this.props.fmcService.master?.navaidTuner.reselectNavaid(oV);
}
this.onNewData();
}}
dataHandlerDuringValidation={this.deselectionHandler.bind(this)}
value={this.deselectedNavaids[5]}
alignText="center"
disabled={this.deselectedNavaids[4].map((it) => it === null)}
Expand Down Expand Up @@ -590,7 +567,10 @@ export class MfdFmsPositionNavaids extends FmsPage<MfdFmsPositionNavaidsProps> {
<InputField<number>
dataEntryFormat={new LsCourseFormat()}
dataHandlerDuringValidation={async (v) => {
this.props.fmcService.master?.navaidTuner.setIlsCourse(v || null);
this.props.fmcService.master?.navaidTuner.setIlsCourse(
v !== null ? Math.abs(v) : null,
v && v < 0 ? true : false,
);
}}
mandatory={Subject.create(false)}
enteredByPilot={this.lsCourseEnteredByPilot}
Expand Down
Loading

0 comments on commit 99f96a9

Please sign in to comment.