Skip to content

Commit

Permalink
Merge branch 'master' into fix/oans-ir-position
Browse files Browse the repository at this point in the history
  • Loading branch information
alepouna authored Nov 12, 2024
2 parents aed9345 + 305d6af commit 11dc812
Show file tree
Hide file tree
Showing 57 changed files with 632 additions and 149 deletions.
1 change: 1 addition & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
1. [A380X/ENG] Improve oil pressure lookup table - @tracernz (Mike)
1. [A380/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)

## 0.12.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2555,11 +2555,16 @@ class FMCMainDisplay extends BaseAirliners {
insertTemporaryFlightPlan(callback = EmptyCallback.Void) {
if (this.flightPlanService.hasTemporary) {
const oldCostIndex = this.costIndex;
const oldDestination = this.currFlightPlanService.active.destinationAirport.ident;
const oldDestination = this.currFlightPlanService.active.destinationAirport
? this.currFlightPlanService.active.destinationAirport.ident
: undefined;
const oldCruiseLevel = this.cruiseLevel;
this.flightPlanService.temporaryInsert();
this.checkCostIndex(oldCostIndex);
this.checkDestination(oldDestination);
// FIXME I don't know if it is actually possible to insert TMPY with no FROM/TO, but we should not crash here, so check this for now
if (oldDestination !== undefined) {
this.checkDestination(oldDestination);
}
this.checkCruiseLevel(oldCruiseLevel);

SimVar.SetSimVarValue("L:FMC_FLIGHT_PLAN_IS_TEMPORARY", "number", 0);
Expand Down
35 changes: 29 additions & 6 deletions fbw-a32nx/src/systems/fmgc/src/flightplanning/FlightPlanService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { FlightPlanLeg, FlightPlanLegFlags } from '@fmgc/flightplanning/legs/Fli
import { Fix, NXDataStore, Waypoint } from '@flybywiresim/fbw-sdk';
import { NavigationDatabase } from '@fmgc/NavigationDatabase';
import { Coordinates, Degrees } from 'msfs-geo';
import { EventBus } from '@microsoft/msfs-sdk';
import { BitFlags, EventBus } from '@microsoft/msfs-sdk';
import { FixInfoEntry } from '@fmgc/flightplanning/plans/FixInfo';
import { HoldData } from '@fmgc/flightplanning/data/flightplan';
import { FlightPlanLegDefinition } from '@fmgc/flightplanning/legs/FlightPlanLegDefinition';
Expand Down Expand Up @@ -121,13 +121,36 @@ export class FlightPlanService<P extends FlightPlanPerformanceData = FlightPlanP
temporaryPlan.alternateFlightPlan.pendingAirways.finalize();
}

const fromLeg = temporaryPlan.maybeElementAt(temporaryPlan.activeLegIndex - 1);
const tmpyFromLeg = temporaryPlan.maybeElementAt(temporaryPlan.activeLegIndex - 1);

const directToInTmpy =
tmpyFromLeg?.isDiscontinuity === false && tmpyFromLeg.flags & FlightPlanLegFlags.DirectToTurningPoint;

const directToBeingInserted =
directToInTmpy && BitFlags.isAny(tmpyFromLeg.flags, FlightPlanLegFlags.PendingDirectToTurningPoint);

// Update T-P
if (fromLeg?.isDiscontinuity === false && fromLeg.flags & FlightPlanLegFlags.DirectToTurningPoint) {
// TODO fm pos
fromLeg.definition.waypoint.location.lat = SimVar.GetSimVarValue('PLANE LATITUDE', 'Degrees');
fromLeg.definition.waypoint.location.long = SimVar.GetSimVarValue('PLANE LONGITUDE', 'Degrees');
if (directToBeingInserted) {
temporaryPlan.editLegFlags(
temporaryPlan.activeLegIndex - 1,
(tmpyFromLeg.flags &= ~FlightPlanLegFlags.PendingDirectToTurningPoint),
);

const magneticCourse: number = SimVar.GetSimVarValue('GPS GROUND MAGNETIC TRACK', 'Degrees');
const lat: number = SimVar.GetSimVarValue('PLANE LATITUDE', 'Degrees');
const long: number = SimVar.GetSimVarValue('PLANE LONGITUDE', 'Degrees');

temporaryPlan.editLegDefinition(temporaryPlan.activeLegIndex - 1, {
magneticCourse,
waypoint: {
...tmpyFromLeg.definition.waypoint,
location: {
// TODO fm pos
lat,
long,
},
},
});
}

this.flightPlanManager.copy(FlightPlanIndex.Temporary, FlightPlanIndex.Active, CopyOptions.IncludeFixInfos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { EnrouteSegment } from '@fmgc/flightplanning/segments/EnrouteSegment';
import { HoldData } from '@fmgc/flightplanning/data/flightplan';
import { CruiseStepEntry } from '@fmgc/flightplanning/CruiseStep';
import { WaypointConstraintType, AltitudeConstraint, SpeedConstraint } from '@fmgc/flightplanning/data/constraint';
import { MagVar } from '@microsoft/msfs-sdk';
import { HoldUtils } from '@fmgc/flightplanning/data/hold';
import { OriginSegment } from '@fmgc/flightplanning/segments/OriginSegment';
import { ReadonlyFlightPlanLeg } from '@fmgc/flightplanning/legs/ReadonlyFlightPlanLeg';
Expand All @@ -47,7 +46,8 @@ export interface SerializedFlightPlanLeg {

export enum FlightPlanLegFlags {
DirectToTurningPoint = 1 << 0,
Origin = 1 << 1,
PendingDirectToTurningPoint = 1 << 1,
Origin = 1 << 2,
}

export interface LegCalculations {
Expand Down Expand Up @@ -330,25 +330,6 @@ export class FlightPlanLeg implements ReadonlyFlightPlanLeg {
);
}

static directToTurnStart(segment: EnrouteSegment, location: Coordinates, bearing: DegreesTrue): FlightPlanLeg {
const magVar = MagVar.get(location.lat, location.long);

return new FlightPlanLeg(
segment,
{
procedureIdent: '',
type: LegType.FC,
overfly: false,
waypoint: WaypointFactory.fromPlaceBearingDistance('T-P', location, 0.1, bearing),
magneticCourse: A32NX_Util.trueToMagnetic(bearing, magVar),
length: 0.1,
},
'',
'',
undefined,
);
}

static directToTurnEnd(segment: EnrouteSegment, waypoint: Fix): FlightPlanLeg {
return new FlightPlanLeg(
segment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
PerformanceDataFlightPlanSyncEvents,
SyncFlightPlanEvents,
} from '@fmgc/flightplanning/sync/FlightPlanEvents';
import { EventBus, Publisher, Subscription } from '@microsoft/msfs-sdk';
import { BitFlags, EventBus, Publisher, Subscription } from '@microsoft/msfs-sdk';
import { FlightPlan } from '@fmgc/flightplanning/plans/FlightPlan';
import { AlternateFlightPlan } from '@fmgc/flightplanning/plans/AlternateFlightPlan';
import { FixInfoEntry } from '@fmgc/flightplanning/plans/FixInfo';
Expand Down Expand Up @@ -124,6 +124,24 @@ export abstract class BaseFlightPlan<P extends FlightPlanPerformanceData = Fligh
}),
);

this.subscriptions.push(
subs.on('SYNC_flightPlan.legFlagsEdit').handle((event) => {
if (!this.ignoreSync) {
if (event.planIndex !== this.index || isAlternatePlan !== event.forAlternate) {
return;
}

const element = this.legElementAt(event.atIndex);

element.flags = event.newFlags;

this.incrementVersion();

flightPlanEventsPub.pub('flightPlan.legFlagsEdit', event);
}
}),
);

this.subscriptions.push(
subs.on('SYNC_flightPlan.legDefinitionEdit').handle((event) => {
if (!this.ignoreSync) {
Expand Down Expand Up @@ -452,6 +470,19 @@ export abstract class BaseFlightPlan<P extends FlightPlanPerformanceData = Fligh
this.sendEvent('flightPlan.setSegmentLegs', { planIndex: this.index, forAlternate: false, segmentIndex, legs });
}

syncLegFlagsChange(atIndex: number) {
const leg = this.elementAt(atIndex);

if (leg.isDiscontinuity === false) {
this.sendEvent('flightPlan.legFlagsEdit', {
planIndex: this.index,
atIndex,
forAlternate: this instanceof AlternateFlightPlan,
newFlags: leg.flags,
});
}
}

syncLegDefinitionChange(atIndex: number) {
const leg = this.elementAt(atIndex);

Expand Down Expand Up @@ -1380,6 +1411,16 @@ export abstract class BaseFlightPlan<P extends FlightPlanPerformanceData = Fligh
this.incrementVersion();
}

editLegFlags(index: number, flags: number, notify = true): void {
const leg = this.legElementAt(index);

leg.flags = flags;

if (notify) {
this.syncLegFlagsChange(index);
}
}

editLegDefinition(index: number, changes: Partial<FlightPlanLegDefinition>, notify = true): void {
const leg = this.legElementAt(index);

Expand Down Expand Up @@ -2295,6 +2336,7 @@ export abstract class BaseFlightPlan<P extends FlightPlanPerformanceData = Fligh
continue;
}

// TODO sync
if (element.definition.type === LegType.IF && element.ident !== 'T-P') {
element.type = LegType.TF;
} else {
Expand All @@ -2304,7 +2346,11 @@ export abstract class BaseFlightPlan<P extends FlightPlanPerformanceData = Fligh

// XX -> IF if no element, or discontinuity before, or 0th leg
if (element && element.isDiscontinuity === false && element.type !== LegType.IF) {
if (!prevElement || (prevElement && prevElement.isDiscontinuity === true) || i === 0) {
// T-P legs need to always be CF so they can create a direct-to-fix transition outbound of them
const isLegTurningPoint = BitFlags.isAny(element.flags, FlightPlanLegFlags.DirectToTurningPoint);

// TODO sync
if (!isLegTurningPoint && (!prevElement || (prevElement && prevElement.isDiscontinuity === true) || i === 0)) {
element.type = LegType.IF;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
FlightPlanPerformanceDataProperties,
} from '@fmgc/flightplanning/plans/performance/FlightPlanPerformanceData';
import { BaseFlightPlan, FlightPlanQueuedOperation, SerializedFlightPlan } from './BaseFlightPlan';
import { FlightPlanIndex } from '@fmgc/flightplanning/FlightPlanManager';

export class FlightPlan<P extends FlightPlanPerformanceData = FlightPlanPerformanceData> extends BaseFlightPlan<P> {
static empty<P extends FlightPlanPerformanceData>(
Expand Down Expand Up @@ -148,6 +149,9 @@ export class FlightPlan<P extends FlightPlanPerformanceData = FlightPlanPerforma
const turnEnd = FlightPlanLeg.directToTurnEnd(this.enrouteSegment, targetLeg.terminationWaypoint());

turningPoint.flags |= FlightPlanLegFlags.DirectToTurningPoint;
if (this.index === FlightPlanIndex.Temporary) {
turningPoint.flags |= FlightPlanLegFlags.PendingDirectToTurningPoint;
}
turnEnd.withDefinitionFrom(targetLeg).withPilotEnteredDataFrom(targetLeg);
// If we don't do this, the turn end will have the termination waypoint's ident which may not be the leg ident (for runway legs for example)
turnEnd.ident = targetLeg.ident;
Expand Down Expand Up @@ -186,6 +190,9 @@ export class FlightPlan<P extends FlightPlanPerformanceData = FlightPlanPerforma
const turnEnd = FlightPlanLeg.directToTurnEnd(this.enrouteSegment, waypoint);

turningPoint.flags |= FlightPlanLegFlags.DirectToTurningPoint;
if (this.index === FlightPlanIndex.Temporary) {
turningPoint.flags |= FlightPlanLegFlags.PendingDirectToTurningPoint;
}

// Move all legs before active one to the enroute segment
let indexInEnrouteSegment = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class OriginSegment extends FlightPlanSegment {
}

private resetOriginLegFlag() {
// TODO this needs to be synced
this.allLegs.forEach((leg) => {
if (leg.isDiscontinuity === false) {
leg.flags &= ~FlightPlanLegFlags.Origin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export interface FlightPlanSetSegmentLegsEvent extends FlightPlanEditSyncEvent {
legs: (SerializedFlightPlanLeg | Discontinuity)[];
}

export interface FlightPlanLegFlagsEditEvent extends FlightPlanEditSyncEvent {
atIndex: number;
newFlags: number;
}

export interface FlightPlanLegDefinitionEditEvent extends FlightPlanEditSyncEvent {
atIndex: number;
newDefinition: FlightPlanLegDefinition;
Expand Down Expand Up @@ -81,6 +86,7 @@ export interface FlightPlanEvents {

'flightPlan.setActiveLegIndex': FlightPlanSetActiveLegIndexEvent;
'flightPlan.setSegmentLegs': FlightPlanSetSegmentLegsEvent;
'flightPlan.legFlagsEdit': FlightPlanLegFlagsEditEvent;
'flightPlan.legDefinitionEdit': FlightPlanLegDefinitionEditEvent;
'flightPlan.setLegCruiseStep': FlightPlanLegCruiseStepEditEvent;
'flightPlan.setFixInfoEntry': FlightPlanSetFixInfoEntryEvent;
Expand Down
1 change: 1 addition & 0 deletions fbw-a380x/mach.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = {
typecheckingPlugin(),
],
instruments: [
msfsAvionicsInstrument('AtcMailbox'),
msfsAvionicsInstrument('Clock'),
msfsAvionicsInstrument('EWD'),
msfsAvionicsInstrument('FCU', 'FcuBaseInstrument.ts'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pixel_size=768,1024
texture=$SCREEN_DU_SD

htmlgauge00=A380X/SD/sd.html?duID=7, 0,0,768,1024
htmlgauge01=A380X/AtcMailbox/atcmailbox.html?duID=7, 0,0,768,1024

[VCockpit05]
size_mm=768,1024
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@
</Requires>
</Sound>

<!-- ROP/ROW warnings =====================================================================-->
<!-- V1 callout ===================================================================== -->
<Sound WwiseEvent="V1" WwiseData="true" NodeName="Wiper_Base_l" LocalVar="A32NX_AUDIO_V1_CALLOUT" Continuous="false">
<Range LowerBound="1"/>
<Requires SimVar="ELECTRICAL MAIN BUS VOLTAGE" Units="VOLTS" Index="1">
Expand Down
15 changes: 15 additions & 0 deletions fbw-a380x/src/systems/instruments/src/AtcMailbox/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

module.exports = {
extends: ['../../../../../../.eslintrc.js', 'plugin:jsdoc/recommended-typescript-error'],

plugins: ['eslint-plugin-jsdoc'],

// overrides airbnb, use sparingly
rules: {
'react/no-unknown-property': 'off',
'react/style-prop-object': 'off',
'arrow-body-style': 'off',
camelcase: 'off',
},
};
61 changes: 61 additions & 0 deletions fbw-a380x/src/systems/instruments/src/AtcMailbox/AtcMailbox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright (c) 2024 FlyByWire Simulations
// SPDX-License-Identifier: GPL-3.0

import { DisplayComponent, EventBus, FSComponent, Subject, VNode } from '@microsoft/msfs-sdk';
import { Button } from 'instruments/src/MFD/pages/common/Button';
import { MouseCursor } from 'instruments/src/MFD/pages/common/MouseCursor';
import { CdsDisplayUnit, DisplayUnitID } from '../MsfsAvionicsCommon/CdsDisplayUnit';

import './style.scss';

export interface AtcMailboxProps {
readonly bus: EventBus;
}

export class AtcMailbox extends DisplayComponent<AtcMailboxProps> {
private readonly topRef = FSComponent.createRef<HTMLDivElement>();

private readonly mouseCursorRef = FSComponent.createRef<MouseCursor>();

private onMouseMove(ev: MouseEvent) {
this.mouseCursorRef.getOrDefault()?.updatePosition(ev.clientX, ev.clientY - 768);
}

private onMouseMoveHandler = this.onMouseMove.bind(this);

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

this.topRef.instance.addEventListener('mousemove', this.onMouseMoveHandler);
}

destroy(): void {
this.topRef.getOrDefault()?.removeEventListener('mousemove', this.onMouseMoveHandler);

super.destroy();
}

render(): VNode | null {
return (
<CdsDisplayUnit bus={this.props.bus} displayUnitId={DisplayUnitID.Sd}>
<div ref={this.topRef} class="atc-mailbox-top-layout">
<div class="atc-mailbox-left-layout">
<Button label="RECALL" onClick={() => {}} buttonStyle="height: 50px;"></Button>
</div>
<div class="atc-mailbox-center-layout">
<div class="atc-mailbox-center-top"></div>
<div class="atc-mailbox-center-bottom">
<div class="atc-mailbox-cb-1" />
<div class="atc-mailbox-cb-2" />
</div>
</div>
<div class="atc-mailbox-right-layout">
<Button label="CLOSE" onClick={() => {}} buttonStyle="height: 50px; justify-content: flex-end;"></Button>
<Button label="PRINT" onClick={() => {}} buttonStyle="height: 50px; justify-content: flex-end;"></Button>
</div>
<MouseCursor side={Subject.create('CAPT')} ref={this.mouseCursorRef} />
</div>
</CdsDisplayUnit>
);
}
}
5 changes: 5 additions & 0 deletions fbw-a380x/src/systems/instruments/src/AtcMailbox/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"index": "./instrument.tsx",
"name": "AtcMailbox",
"isInteractive": true
}
Loading

0 comments on commit 11dc812

Please sign in to comment.