Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjozork committed Nov 9, 2024
1 parent 03e4028 commit 1e8811a
Show file tree
Hide file tree
Showing 16 changed files with 593 additions and 54 deletions.
4 changes: 2 additions & 2 deletions fbw-a32nx/src/systems/fmgc/src/efis/EfisSymbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,8 @@ export class EfisSymbols<T extends number> {
ident: fixInfo.fix.ident,
location: fixInfo.fix.location,
type: NdSymbolTypeFlags.FixInfo,
radials: fixInfo.radials.map((it) => it.trueBearing),
radii: fixInfo.radii.map((it) => it.radius),
radials: fixInfo?.radials.map((it) => it.trueBearing),
radii: fixInfo?.radii.map((it) => it.radius),
});
}
}
Expand Down
12 changes: 6 additions & 6 deletions fbw-a32nx/src/systems/fmgc/src/flightplanning/plans/FixInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// SPDX-License-Identifier: GPL-3.0

import { NdbNavaid, VhfNavaid, Waypoint } from '@flybywiresim/fbw-sdk';
import { AnyFix } from '@flybywiresim/fbw-sdk';

export interface FixInfoRadial {
trueBearing: DegreesTrue;
Expand All @@ -25,15 +25,15 @@ export interface FixInfoRadius {
*/
export class FixInfoEntry implements FixInfoData {
/** The fix concerned by the fix info */
public readonly fix: Waypoint | VhfNavaid | NdbNavaid;
public fix: AnyFix;

/** The radii contained in the fix info */
public readonly radii?: FixInfoRadius[];
public radii?: FixInfoRadius[];

/** The radials contained in the fix ino */
public readonly radials?: FixInfoRadial[];
public radials?: FixInfoRadial[];

constructor(fix: Waypoint | VhfNavaid | NdbNavaid, radii?: FixInfoRadius[], radials?: FixInfoRadial[]) {
constructor(fix: AnyFix, radii?: FixInfoRadius[], radials?: FixInfoRadial[]) {
this.fix = fix;
this.radii = radii;
this.radials = radials;
Expand All @@ -50,7 +50,7 @@ export class FixInfoEntry implements FixInfoData {

export interface FixInfoData {
/** The fix concerned by the fix info */
fix: Waypoint | VhfNavaid | NdbNavaid;
fix: AnyFix;

/** The radii contained in the fix info */
radii?: FixInfoRadius[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export class FlightPlan<P extends FlightPlanPerformanceData = FlightPlanPerforma
setFixInfoEntry(index: 1 | 2 | 3 | 4, fixInfo: FixInfoData | null, notify = true): void {
const planFixInfo = this.fixInfos as FixInfoEntry[];

planFixInfo[index] = fixInfo ? new FixInfoEntry(fixInfo.fix, fixInfo.radii, fixInfo.radials) : undefined;
planFixInfo[index] = fixInfo ? new FixInfoEntry(fixInfo.fix, fixInfo?.radii, fixInfo?.radials) : undefined;

if (notify) {
this.sendEvent('flightPlan.setFixInfoEntry', { planIndex: this.index, forAlternate: false, index, fixInfo });
Expand All @@ -330,7 +330,12 @@ export class FlightPlan<P extends FlightPlanPerformanceData = FlightPlanPerforma
}

if (notify) {
this.sendEvent('flightPlan.setFixInfoEntry', { planIndex: this.index, forAlternate: false, index, fixInfo: res });
this.sendEvent('flightPlan.setFixInfoEntry', {
planIndex: this.index,
forAlternate: false,
index,
fixInfo: res.clone(),
});
}

this.incrementVersion();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { EventBus, Subject, Subscribable, Subscription } from '@microsoft/msfs-sdk';

import { BaseFlightPlan } from './BaseFlightPlan';
import { FlightPlanInterface } from '../FlightPlanInterface';
import { FixInfoData } from './FixInfo';
import { FlightPlan } from './FlightPlan';
import { FlightPlanEvents } from '@fmgc/flightplanning/sync/FlightPlanEvents';

export class ObservableFlightPlan {
private readonly subscriptions: Subscription[] = [];

private readonly flightPlanEventsSubscriber = this.bus.getSubscriber<FlightPlanEvents>();

constructor(
private readonly bus: EventBus,
private readonly flightPlanInterface: FlightPlanInterface,
private readonly index: number,
) {
const plan = flightPlanInterface.get(index);

this.initializeFromPlan(plan);
}

public destroy(): void {
for (const subscription of this.subscriptions) {
subscription.destroy();
}
}

private initializeFromPlan(plan: BaseFlightPlan): void {
if (plan instanceof FlightPlan) {
for (let i = 0; i < plan.fixInfos.length; i++) {
const fix = plan.fixInfos[i];

this._fixInfos[i + 1].set(fix);
}
}

this.subscriptions.push(
this.flightPlanEventsSubscriber.on('flightPlan.setFixInfoEntry').handle((event) => {
if (event.planIndex !== plan.index) {
return;
}

const subject = this._fixInfos[event.index];

subject.set(event.fixInfo);
}),
);
}

private readonly _fixInfos: Record<1 | 2 | 3 | 4, Subject<FixInfoData | null>> = {
1: this.createFixInfoSubject(),
2: this.createFixInfoSubject(),
3: this.createFixInfoSubject(),
4: this.createFixInfoSubject(),
} as const;
public readonly fixInfos: Record<1 | 2 | 3 | 4, Subscribable<FixInfoData | null>> = this._fixInfos;

private createFixInfoSubject(): Subject<FixInfoData | null> {
const equalityFunc = (a: FixInfoData | null, b: FixInfoData | null): boolean => {
if ((a === null) !== (b === null)) {
return false;
}

if (a.fix.databaseId !== b.fix.databaseId) {
return false;
}

for (let i = 0; i < a.radials.length; i++) {
const aRadial = a.radials[i];
const bRadial = b.radials[i];

if (aRadial !== bRadial) {
return false;
}
}

for (let i = 0; i < a.radii.length; i++) {
const aRadius = a.radii[i];
const bRadius = b.radii[i];

if (aRadius !== bRadius) {
return false;
}
}

return true;
};

return Subject.create<FixInfoData | null>(null, equalityFunc);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ export interface ReadonlyFlightPlan {

get version(): number;

get originLeg(): ReadonlyFlightPlanElement;
get originLeg(): ReadonlyFlightPlanElement | undefined;

get originLegIndex(): number;

get destinationLeg(): ReadonlyFlightPlanElement;
get destinationLeg(): ReadonlyFlightPlanElement | undefined;

get destinationLegIndex(): number;

Expand All @@ -58,11 +58,14 @@ export interface ReadonlyFlightPlan {

get arrivalEnrouteTransition(): ProcedureTransition | undefined;

get arrival(): Arrival | undefined;
/**
* The arrival procedure. If it's `undefined`, it means that no arrival is set. If it's `null`, it means that the "NO STAR" is explicitly selected.
*/
get arrival(): Arrival | undefined | null;

get arrivalRunwayTransition(): ProcedureTransition | undefined;

get approachVia(): ProcedureTransition | undefined;
get approachVia(): ProcedureTransition | undefined | null;

get approach(): Approach | undefined;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { MfdDisplayInterface } from 'instruments/src/MFD/MFD';
import { MfdUiService } from 'instruments/src/MFD/pages/common/MfdUiService';
import { MfdFmsDataDebug } from 'instruments/src/MFD/pages/FMS/DATA/MfdFmsDataDebug';
import { MfdSurvControls } from 'instruments/src/MFD/pages/SURV/MfdSurvControls';
import { MfdFmsFplnFixInfo } from './pages/FMS/F-PLN/MfdFmsFplnFixInfo';

export function pageForUrl(
url: string,
Expand Down Expand Up @@ -82,6 +83,8 @@ export function pageForUrl(
case 'fms/sec2/f-pln-hold':
case 'fms/sec3/f-pln-hold':
return <MfdFmsFplnHold pageTitle="F-PLN/HOLD" bus={bus} mfd={mfd} fmcService={fmcService} />;
case 'fms/active/f-pln-fix-info':
return <MfdFmsFplnFixInfo pageTitle="F/PLN/FIX INFO" bus={bus} mfd={mfd} fmcService={fmcService} />;
case 'fms/position/irs':
return <MfdFmsPositionIrs pageTitle="IRS" bus={bus} mfd={mfd} fmcService={fmcService} />;
case 'fms/position/navaids':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ export class MfdFmsFpln extends FmsPage<MfdFmsFplnProps> {
componentIfFalse={<></>}
/>
<Button
disabled={Subject.create(true)}
disabled={false}
label="F-PLN INFO"
onClick={() => {}}
idPrefix={`${this.props.mfd.uiService.captOrFo}_MFD_f-pln-infoBtn`}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
@import "../../../../MsfsAvionicsCommon/definitions";

.mfd-fms-fpln-fix-info-header {
height: .90rem;
}

.mfd-fms-fpln-fix-info-ref-ident {
margin-top: 1.5em;
margin-left: 2.4em;

.mfd-fms-fpln-fix-info-ref-ident-label {
font-size: 20px;
margin-right: 0.95em;
}
}

.mfd-fms-fpln-fix-info-table {
width: 98%;

display: flex;
flex-direction: column;

margin-top: 2.75rem;

.mfd-fms-fpln-fix-info-table-row-1 {
height: 5.5rem;

border-bottom: 2px solid $display-dark-grey;
}

.mfd-fms-fpln-fix-info-table-row-2 {
height: 11.5rem;

border-bottom: 2px solid $display-dark-grey;
}

.mfd-fms-fpln-fix-info-table-row-3 {
height: 7rem;

border-bottom: 2px solid $display-dark-grey;
}

.mfd-fms-fpln-fix-info-table-row-4 {
height: 11.5rem;
}

.mfd-fms-fpln-fix-info-table-col-left {
width: 23%;

border-right: 2px solid $display-dark-grey;
}

.mfd-fms-fpln-fix-info-table-col-center {
width: 57%;
}

.mfd-fms-fpln-fix-info-table-col-right {
width: 20%;
}

/* Individual cells */

.mfd-fms-fpln-fix-info-fpl-intercept-header {
font-size: 20px;

display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr;
justify-items: center;
align-content: center;
grid-column-gap: 2rem;

span:first-child {
grid-column: span 3;
}
}

.mfd-fms-fpln-fix-info-radial-header {
font-size: 20px;
margin-left: 1.45rem;
margin-top: .6rem;
margin-bottom: .9rem;
}

.mfd-fms-fpln-fix-info-radial-1 {
margin-left: 1.5rem;
margin-bottom: 1rem;
}

.mfd-fms-fpln-fix-info-radial-2 {
margin-left: 1.5rem;
margin-top: 1.25rem;
margin-bottom: 1rem;
}
}

.mfd-fms-fpln-fix-info-radius-header {
font-size: 20px;
margin-left: 1.45rem;
margin-top: .75rem;
margin-bottom: .9rem;
}

.mfd-fms-fpln-fix-info-radius-1 {
width: 6rem;

margin-left: 1.5rem;
margin-bottom: 1rem;
}
Loading

0 comments on commit 1e8811a

Please sign in to comment.