Skip to content

Commit

Permalink
fix ILS back course on POSITION/NAVAID
Browse files Browse the repository at this point in the history
  • Loading branch information
flogross89 committed Sep 15, 2024
1 parent e5cb22b commit 1e87657
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ export class MfdFmsPositionNavaids extends FmsPage<MfdFmsPositionNavaidsProps> {
<InputField<number>
dataEntryFormat={new LsCourseFormat()}
dataHandlerDuringValidation={async (v) => {
this.props.fmcService.master?.navaidTuner.setIlsCourse(v || null);
this.props.fmcService.master?.navaidTuner.setIlsCourse(v || null, v && v < 0 ? true : false);
}}
mandatory={Subject.create(false)}
enteredByPilot={this.lsCourseEnteredByPilot}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1349,20 +1349,21 @@ export class FrequencyADFFormat implements DataEntryFormat<number> {
}

// Still need to find a way to store whether course is true or magnetic
/** Negative number indicates back course */
export class LsCourseFormat implements DataEntryFormat<number> {
public placeholder = '----';

public maxDigits = 4;

private minValue = 0;
private minValue = -360;

private maxValue = 360.0;

public format(value: number) {
if (value === null || value === undefined) {
return [this.placeholder, null, '°'] as FieldFormatTuple;
}
return [`F${value.toFixed(0).padStart(3, '0')}`, null, '°'] as FieldFormatTuple;
return [`${value < 0 ? 'B' : 'F'}${Math.abs(value).toFixed(0).padStart(3, '0')}`, null, '°'] as FieldFormatTuple;
}

public async parse(input: string) {
Expand All @@ -1371,16 +1372,18 @@ export class LsCourseFormat implements DataEntryFormat<number> {
}

let numberPart = input;
let sign = +1;
if (input.length === 4) {
if (input[0] === 'F' || input[0] === 'B') {
numberPart = input.substring(1, 3);
sign = input[0] === 'B' ? -1 : +1;
numberPart = input.substring(1, 4);
} else {
numberPart = input.substring(0, 2);
numberPart = input.substring(0, 3);
}
}
const nbr = Number(numberPart);
if (!Number.isNaN(nbr) && nbr <= this.maxValue && nbr >= this.minValue) {
return nbr;
return sign * nbr;
}
if (nbr > this.maxValue || nbr < this.minValue) {
throw new FmsError(FmsErrorType.EntryOutOfRange);
Expand Down

0 comments on commit 1e87657

Please sign in to comment.