Skip to content

Commit

Permalink
SU14 SDK update.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattnischan committed Dec 8, 2023
1 parent a17ea5c commit 8a8240f
Show file tree
Hide file tree
Showing 459 changed files with 26,814 additions and 5,442 deletions.
38 changes: 31 additions & 7 deletions src/garminsdk/autopilot/GarminAPConfig.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {
APAltCapDirector, APAltDirector, APBackCourseDirector, APConfig, APFLCDirector, APGPDirector, APGSDirector, APHdgDirector, APLateralModes, APLvlDirector,
APNavDirector, APPitchDirector, APRollDirector, APTogaPitchDirector, APValues, APVerticalModes, APVNavPathDirector, APVSDirector, EventBus,
FlightPlanner, LNavDirector, LNavDirectorOptions, NavMath, PlaneDirector, UnitType, VNavManager, VNavPathCalculator
APAltCapDirector, APAltDirector, APBackCourseDirector, APFLCDirector, APGPDirector, APGSDirector, APHdgDirector, APLateralModes, APLvlDirector, APNavDirector,
APPitchDirector, APPitchLvlDirector, APRollDirector, APTogaPitchDirector, APValues, APVerticalModes, APVNavPathDirector, APVSDirector, AutopilotDriverOptions,
EventBus, FlightPlanner, LNavDirector, LNavDirectorOptions, NavMath, PlaneDirector, UnitType, VNavManager, VNavPathCalculator
} from '@microsoft/msfs-sdk';

import { GarminObsDirector } from './directors';
import { GarminAPConfigInterface } from './GarminAPConfigInterface';
import { GarminNavToNavManager } from './GarminNavToNavManager';
import { GarminVNavGuidanceOptions, GarminVNavManager2 } from './GarminVNavManager2';
import { AutopilotDriverOptions } from '@microsoft/msfs-sdk/autopilot/AutopilotDriver';

/**
* Options for configuring a Garmin LNAV director.
Expand Down Expand Up @@ -65,10 +65,21 @@ export type GarminAPConfigDirectorOptions = {
hdgTurnReversalThreshold?: number;
};

/**
* Options for configuring Garmin autopilots.
*/
export type GarminAPConfigOptions = GarminAPConfigDirectorOptions & {
/**
* Whether the autopilot should use mach number calculated from the impact pressure derived from indicated airspeed
* and ambient pressure instead of the true mach number. Defaults to `false`.
*/
useIndicatedMach?: boolean;
}

/**
* A Garmin Autopilot Configuration.
*/
export class GarminAPConfig implements APConfig {
export class GarminAPConfig implements GarminAPConfigInterface {
/** The default commanded pitch angle rate, in degrees per second. */
public static readonly DEFAULT_PITCH_RATE = 5;

Expand All @@ -93,6 +104,12 @@ export class GarminAPConfig implements APConfig {

public autopilotDriverOptions: AutopilotDriverOptions;

/**
* Whether the autopilot should use mach number calculated from the impact pressure derived from indicated airspeed
* and ambient pressure instead of the true mach number.
*/
public readonly useIndicatedMach: boolean;

/** Options for the LNAV director. */
private readonly lnavOptions: Partial<Readonly<GarminLNavDirectorOptions>>;

Expand Down Expand Up @@ -120,13 +137,15 @@ export class GarminAPConfig implements APConfig {
private readonly bus: EventBus,
private readonly flightPlanner: FlightPlanner,
private readonly verticalPathCalculator: VNavPathCalculator,
options?: Readonly<GarminAPConfigDirectorOptions>
options?: Readonly<GarminAPConfigOptions>
) {
this.autopilotDriverOptions = {
pitchServoRate: options?.defaultPitchRate ?? GarminAPConfig.DEFAULT_PITCH_RATE,
bankServoRate: options?.defaultBankRate ?? GarminAPConfig.DEFAULT_BANK_RATE
};

this.useIndicatedMach = options?.useIndicatedMach ?? false;

this.lnavOptions = { ...options?.lnavOptions };
this.vnavOptions = { ...options?.vnavOptions };
this.rollMinBankAngle = options?.rollMinBankAngle ?? GarminAPConfig.DEFAULT_ROLL_MIN_BANK_ANGLE;
Expand Down Expand Up @@ -157,6 +176,11 @@ export class GarminAPConfig implements APConfig {
return new APLvlDirector(this.bus, apValues);
}

/** @inheritdoc */
public createPitchLevelerDirector(apValues: APValues): APPitchLvlDirector {
return new APPitchLvlDirector(apValues);
}

/** @inheritdoc */
public createGpssDirector(apValues: APValues): LNavDirector {
const maxBankAngle = (): number => apValues.maxBankId.get() === 1 ? Math.min(this.lnavMaxBankAngle, this.lowBankAngle) : this.lnavMaxBankAngle;
Expand Down Expand Up @@ -214,7 +238,7 @@ export class GarminAPConfig implements APConfig {

/** @inheritdoc */
public createFlcDirector(apValues: APValues): APFLCDirector {
return new APFLCDirector(apValues);
return new APFLCDirector(apValues, { useIndicatedMach: this.useIndicatedMach });
}

/** @inheritdoc */
Expand Down
12 changes: 12 additions & 0 deletions src/garminsdk/autopilot/GarminAPConfigInterface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { APConfig } from '@microsoft/msfs-sdk';

/**
* A Garmin Autopilot Configuration.
*/
export interface GarminAPConfigInterface extends APConfig {
/**
* Whether the autopilot should use mach number calculated from the impact pressure derived from indicated airspeed
* and ambient pressure instead of the true mach number.
*/
readonly useIndicatedMach: boolean;
}
9 changes: 9 additions & 0 deletions src/garminsdk/autopilot/GarminAPStateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ export class GarminAPStateManager extends APStateManager {
case 'AP_WING_LEVELER_OFF':
this.sendApModeEvent(APModeType.LATERAL, APLateralModes.LEVEL, false);
break;
case 'AP_PITCH_LEVELER':
this.sendApModeEvent(APModeType.VERTICAL, APVerticalModes.LEVEL);
break;
case 'AP_PITCH_LEVELER_ON':
this.sendApModeEvent(APModeType.VERTICAL, APVerticalModes.LEVEL, true);
break;
case 'AP_PITCH_LEVELER_OFF':
this.sendApModeEvent(APModeType.VERTICAL, APVerticalModes.LEVEL, false);
break;
case 'AP_PANEL_VS_HOLD':
case 'AP_VS_HOLD':
this.sendApModeEvent(APModeType.VERTICAL, APVerticalModes.VS);
Expand Down
16 changes: 9 additions & 7 deletions src/garminsdk/autopilot/GarminAutopilot.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import {
AdcEvents, AltitudeSelectManager, AltitudeSelectManagerOptions, APAltitudeModes, APConfig, APEvents, APLateralModes, APStateManager,
APVerticalModes, Autopilot, ConsumerSubject, ConsumerValue, DirectorState, EventBus, FlightPlanner, MappedSubject, MetricAltitudeSettingsManager,
MinimumsMode, ObjectSubject, SetSubject, SimVarValueType, UnitType, VNavAltCaptureType, VNavState
AdcEvents, AltitudeSelectManager, AltitudeSelectManagerOptions, APAltitudeModes, APEvents, APLateralModes, APStateManager,
APVerticalModes, Autopilot, ConsumerSubject, ConsumerValue, DirectorState, EventBus, FlightPlanner, MappedSubject,
MetricAltitudeSettingsManager, MinimumsMode, ObjectSubject, SetSubject, SimVarValueType, UnitType, VNavAltCaptureType,
VNavState
} from '@microsoft/msfs-sdk';

import { FmaData, FmaDataEvents, FmaVNavState } from './FmaData';
import { MinimumsDataProvider } from '../minimums/MinimumsDataProvider';
import { FmaData, FmaDataEvents, FmaVNavState } from './FmaData';
import { GarminAPConfigInterface } from './GarminAPConfigInterface';
import { GarminVNavManager2 } from './GarminVNavManager2';

/**
Expand Down Expand Up @@ -50,7 +52,7 @@ export type GarminAutopilotOptions = {
/**
* A Garmin autopilot.
*/
export class GarminAutopilot extends Autopilot {
export class GarminAutopilot extends Autopilot<GarminAPConfigInterface> {
protected static readonly ALT_SELECT_OPTIONS_DEFAULT: AltitudeSelectManagerOptions = {
supportMetric: true,
minValue: UnitType.FOOT.createNumber(-1000),
Expand Down Expand Up @@ -101,7 +103,7 @@ export class GarminAutopilot extends Autopilot {
constructor(
bus: EventBus,
flightPlanner: FlightPlanner,
config: APConfig,
config: GarminAPConfigInterface,
stateManager: APStateManager,
options?: Readonly<GarminAutopilotOptions>
) {
Expand Down Expand Up @@ -169,7 +171,7 @@ export class GarminAutopilot extends Autopilot {
// Whenever we switch between mach and IAS hold and we are in manual speed mode, we need to set the value to which
// we are switching to be equal to the value we are switching from.

this.machToKias.setConsumer(sub.on('mach_to_kias_factor_1'));
this.machToKias.setConsumer(sub.on(this.config.useIndicatedMach ? 'indicated_mach_to_kias_factor_1' : 'mach_to_kias_factor_1'));
this.selSpeedIsMach.setConsumer(sub.on('ap_selected_speed_is_mach'));

const speedIsMachSub = this.selSpeedIsMach.sub(isMach => {
Expand Down
3 changes: 2 additions & 1 deletion src/garminsdk/autopilot/GarminNavToNavManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export class GarminNavToNavManager implements NavToNavManager {
rnavTypeFlags: RnavTypeFlags.None,
isCircling: false,
isVtf: false,
referenceFacility: null
referenceFacility: null,
runway: null
};

private nav1Frequency = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/garminsdk/autopilot/GarminVNavManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export class GarminVNavManager implements VNavManager {
rnavTypeFlags: RnavTypeFlags.None,
isCircling: false,
isVtf: false,
referenceFacility: null
referenceFacility: null,
runway: null
}, FmsUtils.approachDetailsEquals);
private readonly gpAvailable = ConsumerSubject.create(null, false);

Expand Down
3 changes: 2 additions & 1 deletion src/garminsdk/autopilot/GarminVNavManager2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ export class GarminVNavManager2 implements VNavManager {
rnavTypeFlags: RnavTypeFlags.None,
isCircling: false,
isVtf: false,
referenceFacility: null
referenceFacility: null,
runway: null
}, FmsUtils.approachDetailsEquals);
private readonly isApproachLoc = this.approachDetails.map(details => {
switch (details.type) {
Expand Down
1 change: 1 addition & 0 deletions src/garminsdk/autopilot/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './FmaData';
export * from './GarminAPConfig';
export * from './GarminAPConfigInterface';
export * from './GarminAPStateManager';
export * from './GarminAutopilot';
export * from './GarminGoAroundManager';
Expand Down
30 changes: 20 additions & 10 deletions src/garminsdk/components/cas/CAS.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,11 @@ export class CASDisplay<T extends CASProps> extends DisplayComponent<T> {
private handleMessageChanged(idx: number, type: SubscribableArrayEventType.Added | SubscribableArrayEventType.Removed, item: CasActiveMessage): void {
switch (type) {
case SubscribableArrayEventType.Added:
this.addAnnunciation(idx, item); break;
this.addAnnunciation(idx, item);
break;
case SubscribableArrayEventType.Removed:
this.removeAnnunciation(idx, item); break;
this.removeAnnunciation(idx, item);
break;
}
}

Expand All @@ -183,13 +185,17 @@ export class CASDisplay<T extends CASProps> extends DisplayComponent<T> {
if (this.props.alertCounts !== undefined) {
switch (item.priority) {
case AnnunciationType.Warning:
this.props.alertCounts.set('numWarning', this.props.alertCounts.get().numWarning + 1); break;
this.props.alertCounts.set('numWarning', this.props.alertCounts.get().numWarning + 1);
break;
case AnnunciationType.Caution:
this.props.alertCounts.set('numCaution', this.props.alertCounts.get().numCaution + 1); break;
this.props.alertCounts.set('numCaution', this.props.alertCounts.get().numCaution + 1);
break;
case AnnunciationType.Advisory:
this.props.alertCounts.set('numAdvisory', this.props.alertCounts.get().numAdvisory + 1); break;
this.props.alertCounts.set('numAdvisory', this.props.alertCounts.get().numAdvisory + 1);
break;
case AnnunciationType.SafeOp:
this.props.alertCounts.set('numSafeOp', this.props.alertCounts.get().numSafeOp + 1); break;
this.props.alertCounts.set('numSafeOp', this.props.alertCounts.get().numSafeOp + 1);
break;
}
this.updateAlertCounts();
}
Expand Down Expand Up @@ -217,13 +223,17 @@ export class CASDisplay<T extends CASProps> extends DisplayComponent<T> {
if (this.props.alertCounts !== undefined) {
switch (item.priority) {
case AnnunciationType.Warning:
this.props.alertCounts.set('numWarning', this.props.alertCounts.get().numWarning - 1); break;
this.props.alertCounts.set('numWarning', this.props.alertCounts.get().numWarning - 1);
break;
case AnnunciationType.Caution:
this.props.alertCounts.set('numCaution', this.props.alertCounts.get().numCaution - 1); break;
this.props.alertCounts.set('numCaution', this.props.alertCounts.get().numCaution - 1);
break;
case AnnunciationType.Advisory:
this.props.alertCounts.set('numAdvisory', this.props.alertCounts.get().numAdvisory - 1); break;
this.props.alertCounts.set('numAdvisory', this.props.alertCounts.get().numAdvisory - 1);
break;
case AnnunciationType.SafeOp:
this.props.alertCounts.set('numSafeOp', this.props.alertCounts.get().numSafeOp - 1); break;
this.props.alertCounts.set('numSafeOp', this.props.alertCounts.get().numSafeOp - 1);
break;
}
this.updateAlertCounts();
}
Expand Down
Loading

0 comments on commit 8a8240f

Please sign in to comment.