Skip to content

Commit

Permalink
[OANS] various small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
flogross89 committed Apr 16, 2024
1 parent 476e9da commit d815cd1
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 21 deletions.
5 changes: 2 additions & 3 deletions fbw-a380x/src/systems/instruments/src/ND/OansControlPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export class OansControlPanel extends DisplayComponent<OansProps> {
}
});

sub.on('realTime').atFrequency(0.2).handle((_) => this.autoLoadAirport());
sub.on('realTime').atFrequency(1).handle((_) => this.autoLoadAirport());

sub.on('realTime').atFrequency(5).handle((_) => {
const ppos: Coordinates = { lat: 0, long: 0 };
Expand Down Expand Up @@ -321,8 +321,7 @@ export class OansControlPanel extends DisplayComponent<OansProps> {
return;
}
// If on ground, and no airport is loaded, find current airport.
const fwcFlightPhase = SimVar.GetSimVarValue('L:A32NX_FWC_FLIGHT_PHASE', SimVarValueType.Enum);
if (fwcFlightPhase < 7) {
if (![5, 6, 7].includes(SimVar.GetSimVarValue('L:A32NX_FWC_FLIGHT_PHASE', SimVarValueType.Number))) {
// Go through all airports, load if distance <20NM
const nearestAirports = this.store.airports.getArray().filter((ap) => distanceTo(this.presentPos.get(), { lat: ap.coordinates.lat, long: ap.coordinates.lon }) < 20);
const sortedAirports = nearestAirports.sort((a, b) => distanceTo(this.presentPos.get(), { lat: a.coordinates.lat, long: a.coordinates.lon }) - distanceTo(this.presentPos.get(), { lat: b.coordinates.lat, long: b.coordinates.lon }));
Expand Down
4 changes: 2 additions & 2 deletions fbw-a380x/src/systems/instruments/src/ND/instrument.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class NDInstrument implements FsInstrument {

private readonly contextMenuY = Subject.create(0);

private readonly controlPanelVisible = Subject.create(true);
private readonly controlPanelVisible = Subject.create(false);

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

Expand Down Expand Up @@ -217,7 +217,7 @@ class NDInstrument implements FsInstrument {
<div ref={this.topRef}>
<CdsDisplayUnit bus={this.bus} displayUnitId={DisplayUnitID.CaptNd} test={Subject.create(-1)} failed={Subject.create(false)}>
<div ref={this.oansContainerRef} class="oanc-container" style={`width: ${OANC_RENDER_WIDTH}px; height: ${OANC_RENDER_HEIGHT}px; overflow: hidden`}>
<div ref={this.waitScreenRef} class="oanc-waiting-screen">
<div ref={this.waitScreenRef} class="oanc-waiting-screen" style="visibility: hidden;">
PLEASE WAIT
</div>
<Oanc
Expand Down
8 changes: 6 additions & 2 deletions fbw-a380x/src/systems/instruments/src/ND/oans-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
}

.oanc-label-style-runway-end:hover {
outline: 3px solid $display-cyan;
pointer-events: auto;
outline-offset: 0px !important;
}

Expand All @@ -126,7 +128,8 @@
}

.oanc-label-style-runway-end-fms-selected {
font-size: 0px;
font-size: 0.1px;
color: transparent;
width: 0px;
height: 0px;
background-color: transparent;
Expand All @@ -140,7 +143,8 @@
}

.oanc-label-style-runway-arrow-btv-selected {
font-size: 0px;
font-size: 0.1px;
color: transparent;
width: 50px;
height: 35px;
background-color: transparent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { FSComponent, DisplayComponent, Subject, VNode, MappedSubject, ConsumerSubject } from '@microsoft/msfs-sdk';

import { FmsOansData, FmsOansDataArinc429 } from 'instruments/src/OANC';
import { BtvDataArinc429, FmsOansData, FmsOansDataArinc429 } from 'instruments/src/OANC';
import { Arinc429Word, ArincEventBus } from '@shared/index';
import { Layer } from '../../MsfsAvionicsCommon/Layer';

Expand Down Expand Up @@ -55,7 +55,7 @@ export class BtvRunwayInfo extends DisplayComponent<{ bus: ArincEventBus }> {
onAfterRender(node: VNode) {
super.onAfterRender(node);

const sub = this.props.bus.getArincSubscriber<FmsOansDataArinc429 & FmsOansData>();
const sub = this.props.bus.getArincSubscriber<FmsOansDataArinc429 & FmsOansData & BtvDataArinc429>();

this.fmsRwyIdent.setConsumer(sub.on('fmsLandingRunway'));
this.runwayIdent.setConsumer(sub.on('oansSelectedLandingRunway'));
Expand All @@ -81,7 +81,7 @@ export class BtvRunwayInfo extends DisplayComponent<{ bus: ArincEventBus }> {
<text x={50} y={0} class="Green FontSmallest">{this.runwayInfoString}</text>
<text x={205} y={0} class="Cyan FontSmallest">M</text>
<text x={225} y={0} class="White FontSmallest">-</text>
<text x={245} y={0} class="Green FontSmallest">{this.runwayBearing.map((it) => it?.value.toFixed(0))}</text>
<text x={245} y={0} class="Green FontSmallest">{this.runwayBearing.map((it) => (it.isNormalOperation() ? it.value.toFixed(0).padStart(3, '0') : ''))}</text>
<text x={283} y={0} class="Cyan FontSmallest">°</text>
</Layer>
</g>
Expand Down
2 changes: 2 additions & 0 deletions fbw-common/src/systems/instruments/src/OANC/Oanc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ export class Oanc<T extends number> extends DisplayComponent<OancProps<T>> {
this.fmsDataStore.departureRunway.get(),
this.fmsDataStore.landingRunway.get(),
this.btvUtils.btvRunway.get(),
this.btvUtils.btvExit.get(),
);
});

Expand Down Expand Up @@ -897,6 +898,7 @@ export class Oanc<T extends number> extends DisplayComponent<OancProps<T>> {
this.fmsDataStore.departureRunway.get(),
this.fmsDataStore.landingRunway.get(),
this.btvUtils.btvRunway.get(),
this.btvUtils.btvExit.get(),
);

return;
Expand Down
16 changes: 11 additions & 5 deletions fbw-common/src/systems/instruments/src/OANC/OancLabelFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@ export interface MajorLabelFilter extends BaseOancLabelFilter {
export type OancLabelFilter = RunwayBtvSelectionLabelFilter | NoneLabelFilter | NullLabelFilter | MajorLabelFilter

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function filterLabel(label: Label, filter: OancLabelFilter, fmsDepRunway?: string, fmsLdgRunway?: string, btvSelectedRunway?: string): boolean {
export function filterLabel(label: Label, filter: OancLabelFilter, fmsDepRunway?: string, fmsLdgRunway?: string, btvSelectedRunway?: string, btvSelectedExit?: string): boolean {
if (label.style === LabelStyle.FmsSelectedRunwayEnd && label.text) {
return label.text.includes(fmsDepRunway?.substring(2)) || label.text.includes(fmsLdgRunway?.substring(2));
} if (label.style === LabelStyle.BtvSelectedRunwayArrow && label.text) {
return label.text.includes(btvSelectedRunway?.substring(2));
}
if (btvSelectedRunway && label.associatedFeature?.properties.feattype === FeatureType.Centerline && label.text.includes(btvSelectedRunway?.substring(2))) {
return true;
}
if (btvSelectedExit && label.style === LabelStyle.BtvSelectedExit) {
return true;
}
if ([LabelStyle.BtvStopLineMagenta, LabelStyle.BtvStopLineAmber, LabelStyle.BtvStopLineRed, LabelStyle.BtvStopLineGreen].includes(label.style)) {
return true;
}
Expand All @@ -44,10 +50,10 @@ export function filterLabel(label: Label, filter: OancLabelFilter, fmsDepRunway?
case 'null':
return label.associatedFeature?.properties.feattype !== FeatureType.ExitLine;
case 'major':
return label.text.length < 2 && label.associatedFeature?.properties.feattype !== FeatureType.ExitLine;
return label.associatedFeature?.properties.feattype === FeatureType.Centerline || (label.text.length < 2 && label.associatedFeature?.properties.feattype !== FeatureType.ExitLine);
case 'runwayBtvSelection':
return (label.associatedFeature?.properties.feattype === FeatureType.Centerline
|| label.associatedFeature?.properties.feattype === FeatureType.ExitLine || filter.showAdjacent); // TODO lower opacity if associated rwy not selected
|| label.associatedFeature?.properties.feattype === FeatureType.ExitLine || filter.showAdjacent); // FIXME lower opacity if associated rwy not selected
}
}

Expand All @@ -58,8 +64,8 @@ export function labelStyle(label: Label, fmsDataStore: FmsDataStore, isFmsOrigin
const isSelectedRunway = (isFmsOrigin && label.text.includes(fmsDataStore.departureRunway.get()?.substring(2)))
|| (isFmsDestination && label.text.includes(fmsDataStore.landingRunway.get()?.substring(2)));
return isSelectedRunway ? LabelStyle.FmsSelectedRunwayAxis : LabelStyle.RunwayAxis;
} if (label.style === LabelStyle.Taxiway || label.style === LabelStyle.BtvSelectedExit) {
return label.text === btvSelectedExit ? LabelStyle.BtvSelectedExit : LabelStyle.Taxiway;
} if (label.style === LabelStyle.ExitLine || label.style === LabelStyle.BtvSelectedExit) {
return label.text === btvSelectedExit ? LabelStyle.BtvSelectedExit : LabelStyle.ExitLine;
}
return label.style;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class OancLabelManager<T extends number> {

public visibleLabelElements = new Map<Label, HTMLDivElement>();

public reflowLabels(fmsDepRunway?: string, fmsLdgRunway?: string, btvSelectedRunway?: string) {
public reflowLabels(fmsDepRunway?: string, fmsLdgRunway?: string, btvSelectedRunway?: string, btvSelectedExit?: string) {
// eslint-disable-next-line prefer-const
let [offsetX, offsetY] = this.oanc.arpReferencedMapParams.coordinatesToXYy(this.oanc.referencePos);

Expand All @@ -48,7 +48,7 @@ export class OancLabelManager<T extends number> {
continue;
}

const labelVisible = filterLabel(label, this.currentFilter, fmsDepRunway, fmsLdgRunway, btvSelectedRunway);
const labelVisible = filterLabel(label, this.currentFilter, fmsDepRunway, fmsLdgRunway, btvSelectedRunway, btvSelectedExit);

if (!labelVisible) {
element.style.visibility = 'hidden';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export class OancPositionComputer<T extends number> {
return feature.properties.idlin;
case FeatureType.RunwayElement:
case FeatureType.Stopway:
case FeatureType.RunwayDisplacedArea:
return feature.properties?.idrwy.replace('.', '-');
return feature.properties.idrwy.replace('.', '-');
case FeatureType.Blastpad:
case FeatureType.RunwayDisplacedArea:
return feature.properties.idthr;
default:
return feature.properties.ident;
Expand Down
8 changes: 6 additions & 2 deletions fbw-common/src/systems/instruments/src/OANC/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
}

.oanc-label-style-runway-end:hover {
outline: 3px solid $display-cyan;
pointer-events: auto;
outline-offset: 0px !important;
}

Expand All @@ -126,7 +128,8 @@
}

.oanc-label-style-runway-end-fms-selected {
font-size: 0px;
font-size: 0.1px;
color: transparent;
width: 0px;
height: 0px;
background-color: transparent;
Expand All @@ -140,7 +143,8 @@
}

.oanc-label-style-runway-arrow-btv-selected {
font-size: 0px;
font-size: 0.1px;
color: transparent;
width: 50px;
height: 35px;
background-color: transparent;
Expand Down

0 comments on commit d815cd1

Please sign in to comment.