Skip to content

Commit

Permalink
before touchdown, transmit BTV remaining distances from threshold loc…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
flogross89 committed Apr 1, 2024
1 parent 0e03a7e commit 482d25e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,10 @@ export class OansControlPanel extends DisplayComponent<OansProps> {
this.runwayLda.set(this.landingRunwayNavdata.length.toFixed(0));
this.runwayTora.set(this.landingRunwayNavdata.length.toFixed(0));
const oppositeThreshold = placeBearingDistance(this.landingRunwayNavdata.thresholdLocation, this.landingRunwayNavdata.bearing, this.landingRunwayNavdata.length / MathUtils.METRES_TO_NAUTICAL_MILES);
const localThr = globalToAirportCoordinates(this.arpCoordinates, this.landingRunwayNavdata.thresholdLocation);
const localOppThr = globalToAirportCoordinates(this.arpCoordinates, oppositeThreshold);

this.btvUtils.selectRunwayFromNavdata(it, this.landingRunwayNavdata.length, this.landingRunwayNavdata.bearing, localOppThr);
this.btvUtils.selectRunwayFromNavdata(it, this.landingRunwayNavdata.length, this.landingRunwayNavdata.bearing, localThr, localOppThr);
}
}
});
Expand Down
63 changes: 43 additions & 20 deletions fbw-common/src/systems/instruments/src/OANC/BrakeToVacateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export class BrakeToVacateUtils {
/** Selected threshold, used for exit distance calculation */
private btvThresholdFeature: Feature<Geometry, AmdbProperties>;

/** Threshold, used for runway end distance calculation */
private btvThresholdPosition: Position;

/** Opposite threshold, used for runway end distance calculation */
private btvOppositeThresholdPosition: Position;

Expand Down Expand Up @@ -75,6 +78,7 @@ export class BrakeToVacateUtils {

// Select opposite threshold location
const thrLoc = thresholdFeature.geometry.coordinates as Position;
this.btvThresholdPosition = thrLoc;
const firstEl = centerlineFeature.geometry.coordinates[0] as Position;
const dist1 = pointDistance(thrLoc[0], thrLoc[1], firstEl[0], firstEl[1]);
const lastEl = centerlineFeature.geometry.coordinates[centerlineFeature.geometry.coordinates.length - 1] as Position;
Expand Down Expand Up @@ -143,9 +147,10 @@ export class BrakeToVacateUtils {
this.btvExit.set(exit);
}

selectRunwayFromNavdata(runway: string, lda: number, heading: number, btvOppositeThresholdPosition: Position) {
selectRunwayFromNavdata(runway: string, lda: number, heading: number, btvThresholdPosition: Position, btvOppositeThresholdPosition: Position) {
this.clearSelection();

this.btvThresholdPosition = btvThresholdPosition;
this.btvOppositeThresholdPosition = btvOppositeThresholdPosition;
this.btvRunwayLda.set(lda);
this.btvRunwayHeading.set(heading);
Expand All @@ -172,6 +177,8 @@ export class BrakeToVacateUtils {

clearSelection() {
this.btvThresholdFeature = undefined;
this.btvThresholdPosition = [];
this.btvOppositeThresholdPosition = [];
this.btvRunwayLda.set(null);
this.btvRunwayHeading.set(null);
this.btvRunway.set(null);
Expand All @@ -198,26 +205,42 @@ export class BrakeToVacateUtils {
}

updateRemainingDistances(pos: Position) {
if (this.btvOppositeThresholdPosition && this.btvOppositeThresholdPosition.length > 0) {
const rwyEndDistance = pointDistance(
pos[0],
pos[1],
this.btvOppositeThresholdPosition[0],
this.btvOppositeThresholdPosition[1],
);

this.remaininingDistToRwyEnd.set(MathUtils.round(rwyEndDistance, 0.1));
}

if (this.btvExitPosition && this.btvExitPosition.length > 0) {
const exitDistance = pointDistance(
pos[0],
pos[1],
this.btvExitPosition[0],
this.btvExitPosition[1],
);
if (this.btvThresholdPosition && this.btvThresholdPosition.length > 0) {
if (this.btvOppositeThresholdPosition && this.btvOppositeThresholdPosition.length > 0) {
const rwyEndDistanceFromThreshold = pointDistance(
this.btvThresholdPosition[0],
this.btvThresholdPosition[1],
this.btvOppositeThresholdPosition[0],
this.btvOppositeThresholdPosition[1],
);

const rwyEndDistance = pointDistance(
pos[0],
pos[1],
this.btvOppositeThresholdPosition[0],
this.btvOppositeThresholdPosition[1],
);

this.remaininingDistToRwyEnd.set(MathUtils.round(Math.min(rwyEndDistanceFromThreshold, rwyEndDistance), 0.1));
}

this.remaininingDistToExit.set(MathUtils.round(exitDistance, 0.1));
if (this.btvExitPosition && this.btvExitPosition.length > 0) {
const exitDistanceFromThreshold = pointDistance(
this.btvThresholdPosition[0],
this.btvThresholdPosition[1],
this.btvExitPosition[0],
this.btvExitPosition[1],
);

const exitDistance = pointDistance(
pos[0],
pos[1],
this.btvExitPosition[0],
this.btvExitPosition[1],
);

this.remaininingDistToExit.set(MathUtils.round(Math.min(exitDistanceFromThreshold, exitDistance), 0.1));
}
}
}
}

0 comments on commit 482d25e

Please sign in to comment.