Skip to content

Commit

Permalink
fix(oans): use IRS position & display correct flags when it's not ava…
Browse files Browse the repository at this point in the history
…ilable ♻️ (#9487)

* fix(oanc): use IR position

* fix(nd): display correct OANS db dates

* fix(oanc): hide stand indiciator when not at stand on start

* feat(oans+nd): refactor and display correct flags

* Merge remote-tracking branch 'upstream/master' into fix/oans-ir-position

* fix(nd): oans display

* refactor: move GenericAdirsEvents to fbw-sdk

* refactor: use Arinc429LocalVarConsumerSubject

* chore: add changelog entry

---------

Co-authored-by: alepouna <98479040+alepouna@users.noreply.github.com>
  • Loading branch information
Nufflee and alepouna authored Nov 22, 2024
1 parent 1d42acd commit 1cd2ca7
Show file tree
Hide file tree
Showing 25 changed files with 414 additions and 353 deletions.
1 change: 1 addition & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
1. [A380X/WING_FLEX] Reduced stiffness of wings for more tip up bend - @Crocket63 (crocket)
1. [A380X/FWS] Add V1 callout - @flogross89 (floridude)
1. [FMS] Fix existing T-P moving when inserting temporary flight plan - @Benjozork (Benjamin Dupont)
1. [OANS] Display correct flags when IRS position is not available - @Nufflee (nufflee)
1. [FMS] Use station declination for PBX/PBD waypoints - @BlueberryKing (BlueberryKing)
1. [RA] Add direct coupling and interrupted antenna cable failures to RAs - @beheh (Benedict Etzel)
1. [A32NX/TELEX] Keep flight number set even if already taken - @BenJuan26 (BenJuan26)
Expand Down
6 changes: 0 additions & 6 deletions fbw-a32nx/src/systems/instruments/src/OANC/instrument.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ class A32NX_OANC extends BaseInstrument {

private readonly controlPanelVisible = Subject.create(false);

private readonly oansMessageScreenRef = FSComponent.createRef<HTMLDivElement>();

constructor() {
super();
this.efisSide = getDisplayIndex() === 1 ? 'L' : 'R';
Expand Down Expand Up @@ -122,9 +120,6 @@ class A32NX_OANC extends BaseInstrument {
class="oanc-container"
style={`width: ${OANC_RENDER_WIDTH}px; height: ${OANC_RENDER_HEIGHT}px; overflow: hidden`}
>
<div ref={this.oansMessageScreenRef} class="oanc-message-screen">
PLEASE WAIT
</div>
<Oanc
bus={this.bus}
side={this.efisSide}
Expand All @@ -133,7 +128,6 @@ class A32NX_OANC extends BaseInstrument {
contextMenuItems={this.contextMenuItems}
contextMenuX={this.contextMenuX}
contextMenuY={this.contextMenuY}
messageScreenRef={this.oansMessageScreenRef}
zoomValues={a320EfisZoomRangeSettings}
/>
<ControlPanel
Expand Down
16 changes: 9 additions & 7 deletions fbw-a32nx/src/systems/instruments/src/OANC/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
.oanc-container {
width: 768px;
height: 768px;
overflow: hidden;

background-color: $display-background;

font-family: "Ecam", monospace !important;
}

.oanc-message-screen {
.oanc-flag-container {
position: absolute;

width: 768px;
Expand All @@ -30,15 +31,10 @@
justify-content: center;
align-items: center;

font-size: 24px;

background-color: $display-background;
color: $display-white;

z-index: 9999;
}

.oanc-message-screen.amber {
.oanc-flag-container.amber {
color: $display-amber;
}

Expand Down Expand Up @@ -131,6 +127,12 @@
font-size: 24px;
}

.oanc-bottom-flag {
padding: 1px;
padding-left: 2px;
color: $display-amber;
}

.oanc-speed-info {
position: absolute;
top: 0;
Expand Down
45 changes: 19 additions & 26 deletions fbw-a380x/src/systems/instruments/src/ND/OansControlPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
import {
AmdbAirportSearchResult,
Arinc429LocalVarConsumerSubject,
Arinc429RegisterSubject,
BtvData,
EfisSide,
FeatureType,
Expand Down Expand Up @@ -123,16 +122,23 @@ export class OansControlPanel extends DisplayComponent<OansProps> {

private manualAirportSelection = false;

private readonly pposLatWord = Arinc429RegisterSubject.createEmpty();
// TODO: Should be using GPS position interpolated with IRS velocity data
private readonly pposLatWord = Arinc429LocalVarConsumerSubject.create(this.sub.on('latitude'));

private readonly pposLonWord = Arinc429RegisterSubject.createEmpty();
private readonly pposLongWord = Arinc429LocalVarConsumerSubject.create(this.sub.on('longitude'));

private presentPos = MappedSubject.create(
([lat, lon]) => {
return { lat: lat.value, long: lon.value } as Coordinates;
},
this.pposLatWord,
this.pposLonWord,
this.pposLongWord,
);

private presentPosNotAvailable = MappedSubject.create(
([lat, long]) => !lat.isNormalOperation() || !long.isNormalOperation(),
this.pposLatWord,
this.pposLongWord,
);

private readonly fmsDataStore = new FmsDataStore(this.props.bus);
Expand Down Expand Up @@ -208,13 +214,13 @@ export class OansControlPanel extends DisplayComponent<OansProps> {
NavigationDatabaseService.activeDatabase.getDatabaseIdent().then((db) => {
const from = new Date(db.effectiveFrom);
const to = new Date(db.effectiveTo);
this.activeDatabase.set(`${from.getDay()}${months[from.getMonth()]}-${to.getDay()}${months[to.getMonth()]}`);
this.activeDatabase.set(`${from.getDate()}${months[from.getMonth()]}-${to.getDate()}${months[to.getMonth()]}`);
});

NXDataStore.getAndSubscribe('NAVIGRAPH_ACCESS_TOKEN', () => this.loadOansDb());

this.subs.push(
this.props.isVisible.sub((it) => this.style.setValue('visibility', it ? 'visible' : 'hidden'), true),
this.props.isVisible.sub((it) => this.style.setValue('visibility', it ? 'inherit' : 'hidden'), true),
);

this.subs.push(
Expand Down Expand Up @@ -246,20 +252,6 @@ export class OansControlPanel extends DisplayComponent<OansProps> {
}, true),
);

this.sub
.on('latitude')
.whenChanged()
.handle((value) => {
this.pposLatWord.setWord(value);
});

this.sub
.on('longitude')
.whenChanged()
.handle((value) => {
this.pposLonWord.setWord(value);
});

this.fmsDataStore.landingRunway.sub(async (it) => {
// Set control panel display
if (it) {
Expand Down Expand Up @@ -301,12 +293,8 @@ export class OansControlPanel extends DisplayComponent<OansProps> {
.on('realTime')
.atFrequency(5)
.handle((_) => {
const ppos: Coordinates = { lat: 0, long: 0 };
ppos.lat = SimVar.GetSimVarValue('PLANE LATITUDE', 'Degrees');
ppos.long = SimVar.GetSimVarValue('PLANE LONGITUDE', 'Degrees');

if (this.arpCoordinates && ppos.lat && this.navigraphAvailable.get() === false) {
globalToAirportCoordinates(this.arpCoordinates, ppos, this.localPpos);
if (this.arpCoordinates && this.navigraphAvailable.get() === false) {
globalToAirportCoordinates(this.arpCoordinates, this.presentPos.get(), this.localPpos);
this.props.bus.getPublisher<FmsOansData>().pub('oansAirportLocalCoordinates', this.localPpos, true);
}
});
Expand Down Expand Up @@ -411,6 +399,11 @@ export class OansControlPanel extends DisplayComponent<OansProps> {
};

private autoLoadAirport() {
// If we don't have ppos, do not try to auto load
if (this.presentPosNotAvailable.get()) {
return;
}

// If airport has been manually selected, do not auto load.
if (
this.manualAirportSelection === true ||
Expand Down
76 changes: 44 additions & 32 deletions fbw-a380x/src/systems/instruments/src/ND/instrument.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import {
Clock,
ConsumerSubject,
FsBaseInstrument,
FSComponent,
FsInstrument,
Expand All @@ -29,8 +30,6 @@ import {
a380EfisZoomRangeSettings,
A380EfisZoomRangeValue,
Oanc,
OANC_RENDER_HEIGHT,
OANC_RENDER_WIDTH,
OansControlEvents,
ZOOM_TRANSITION_TIME_MS,
} from '@flybywiresim/oanc';
Expand Down Expand Up @@ -115,8 +114,6 @@ class NDInstrument implements FsInstrument {

private readonly controlPanelVisible = Subject.create(false);

private readonly oansMessageScreenRef = FSComponent.createRef<HTMLDivElement>();

private oansContextMenuItems: Subscribable<ContextMenuElement[]> = Subject.create([
{
name: 'ADD CROSS',
Expand Down Expand Up @@ -184,11 +181,11 @@ class NDInstrument implements FsInstrument {

private oansRef = FSComponent.createRef<Oanc<A380EfisZoomRangeValue>>();

private oansContainerRef = FSComponent.createRef<HTMLDivElement>();
private cursorVisible = Subject.create<boolean>(true);

private oansControlPanelContainerRef = FSComponent.createRef<HTMLDivElement>();
private readonly oansNotAvailable = ConsumerSubject.create(null, true);

private cursorVisible = Subject.create<boolean>(true);
private readonly oansShown = Subject.create(false);

constructor() {
const side: EfisSide = getDisplayIndex() === 1 ? 'L' : 'R';
Expand Down Expand Up @@ -252,23 +249,36 @@ class NDInstrument implements FsInstrument {
failed={Subject.create(false)}
>
<div
ref={this.oansContainerRef}
class="oanc-container"
style={`width: ${OANC_RENDER_WIDTH}px; height: ${OANC_RENDER_HEIGHT}px; overflow: hidden`}
style={{
display: this.oansShown.map((v) => (v ? 'block' : 'none')),
}}
>
<div ref={this.oansMessageScreenRef} class="oanc-message-screen" style="visibility: hidden;">
PLEASE WAIT
{/* This flag is rendered by the CDS so it lives here instead of in the OANC */}
<div
class="oanc-flag-container amber FontLarge"
style={{
visibility: this.oansNotAvailable.map((v) => (v ? 'inherit' : 'hidden')),
}}
>
NOT AVAIL
</div>

<div
style={{
display: this.oansNotAvailable.map((v) => (v ? 'none' : 'block')),
}}
>
<Oanc
bus={this.bus}
side={this.efisSide}
ref={this.oansRef}
contextMenuVisible={this.contextMenuVisible}
contextMenuX={this.contextMenuX}
contextMenuY={this.contextMenuY}
zoomValues={a380EfisZoomRangeSettings}
/>
</div>
<Oanc
bus={this.bus}
side={this.efisSide}
ref={this.oansRef}
messageScreenRef={this.oansMessageScreenRef}
contextMenuVisible={this.contextMenuVisible}
contextMenuX={this.contextMenuX}
contextMenuY={this.contextMenuY}
zoomValues={a380EfisZoomRangeSettings}
/>
</div>
<NDComponent bus={this.bus} side={this.efisSide} rangeValues={a380EfisRangeSettings} />
<ContextMenu
Expand All @@ -277,7 +287,11 @@ class NDInstrument implements FsInstrument {
idPrefix="contextMenu"
values={this.oansContextMenuItems}
/>
<div ref={this.oansControlPanelContainerRef}>
<div
style={{
display: this.oansShown.map((v) => (v ? 'block' : 'none')),
}}
>
<OansControlPanel
ref={this.controlPanelRef}
bus={this.bus}
Expand Down Expand Up @@ -328,6 +342,8 @@ class NDInstrument implements FsInstrument {

const sub = this.bus.getSubscriber<FcuSimVars & OansControlEvents>();

this.oansNotAvailable.setConsumer(sub.on('oansNotAvail'));

sub
.on('ndMode')
.whenChanged()
Expand All @@ -346,16 +362,12 @@ class NDInstrument implements FsInstrument {
}

private updateNdOansVisibility() {
if (this.oansContainerRef.getOrDefault()) {
if (this.efisCpRange === -1 && [EfisNdMode.PLAN, EfisNdMode.ARC, EfisNdMode.ROSE_NAV].includes(this.efisNdMode)) {
this.bus.getPublisher<OansControlEvents>().pub('ndShowOans', true);
this.oansContainerRef.instance.style.display = 'block';
this.oansControlPanelContainerRef.instance.style.display = 'block';
} else {
this.bus.getPublisher<OansControlEvents>().pub('ndShowOans', false);
this.oansContainerRef.instance.style.display = 'none';
this.oansControlPanelContainerRef.instance.style.display = 'none';
}
if (this.efisCpRange === -1 && [EfisNdMode.PLAN, EfisNdMode.ARC, EfisNdMode.ROSE_NAV].includes(this.efisNdMode)) {
this.bus.getPublisher<OansControlEvents>().pub('ndShowOans', true);
this.oansShown.set(true);
} else {
this.bus.getPublisher<OansControlEvents>().pub('ndShowOans', false);
this.oansShown.set(false);
}
}

Expand Down
17 changes: 10 additions & 7 deletions fbw-a380x/src/systems/instruments/src/ND/oans-style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
.oanc-container {
width: 768px;
height: 768px;
overflow: hidden;

background-color: $display-background;

font-family: "Ecam", monospace !important;
}

.oanc-message-screen {
.oanc-flag-container {
position: absolute;

width: 768px;
Expand All @@ -37,14 +38,10 @@
justify-content: center;
align-items: center;

font-size: 24px;

background-color: $display-background;
color: $display-white;

z-index: 9999;
}
.oanc-message-screen.amber {

.oanc-flag-container.amber {
color: $display-amber;
}

Expand Down Expand Up @@ -241,6 +238,12 @@
font-size: 24px;
}

.oanc-bottom-flag {
padding: 1px;
padding-left: 2px;
color: $display-amber;
}

.oanc-speed-info {
position: absolute;
top: 0;
Expand Down
3 changes: 2 additions & 1 deletion fbw-common/src/systems/instruments/src/ND/ND.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
VNode,
} from '@microsoft/msfs-sdk';

import { GenericAdirsEvents } from '@flybywiresim/fbw-sdk';

import { clampAngle } from 'msfs-geo';
import { BtvRunwayInfo } from './shared/BtvRunwayInfo';
import { RwyAheadAdvisory } from './shared/RwyAheadAdvisory';
Expand All @@ -23,7 +25,6 @@ import { LnavStatus } from './shared/LnavStatus';
import { CrossTrackError } from './shared/CrossTrackError';
import { RadioNeedle } from './shared/RadioNeedle';
import { GenericFmsEvents } from './types/GenericFmsEvents';
import { GenericAdirsEvents } from './types/GenericAdirsEvents';
import { NDSimvars } from './NDSimvarPublisher';
import { ArcModePage } from './pages/arc';
import { Layer } from '../MsfsAvionicsCommon/Layer';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GenericAdirsEvents } from './types/GenericAdirsEvents';
import { GenericAdirsEvents } from '@flybywiresim/fbw-sdk';
import { GenericSwitchingPanelEvents } from './types/GenericSwitchingPanelEvents';

export type NDSimvars = GenericAdirsEvents &
Expand Down
Loading

0 comments on commit 1cd2ca7

Please sign in to comment.