-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move auto baro unit to extras host and enable on a380x (#9654)
* refactor: move auto baro to extras host * feat(a380x): auto baro unit selection * fix(efb): match default with others * docs: changelog
- Loading branch information
Showing
11 changed files
with
69 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
...a32nx/src/base/flybywire-aircraft-a320-neo/html_ui/Pages/A32NX_Core/A32NX_BaroSelector.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
fbw-common/src/systems/shared/src/extras/BaroUnitSelector.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { NXDataStore } from '@flybywiresim/fbw-sdk'; | ||
import { GameStateProvider, Wait } from '@microsoft/msfs-sdk'; | ||
import { NearestSearchType } from '../../../navdata/client/backends/Msfs/FsTypes'; | ||
|
||
export class BaroUnitSelector { | ||
private static readonly IN_HG_REGIONS = ['K', 'C', 'M', 'P', 'RJ', 'RO', 'TI', 'TJ']; | ||
|
||
private facilityListener?: ViewListener.ViewListener; | ||
|
||
constructor(private readonly setBaroSelector: (isHpa: boolean) => void) {} | ||
|
||
public performSelection(): void { | ||
const configInitBaroUnit = NXDataStore.get('CONFIG_INIT_BARO_UNIT', 'AUTO'); | ||
if (configInitBaroUnit !== 'AUTO') { | ||
this.setBaroSelector(configInitBaroUnit == 'HPA'); | ||
} else if (this.facilityListener) { | ||
this.autoSetBaroUnit(); | ||
} else { | ||
RegisterViewListener('JS_LISTENER_FACILITY', () => this.autoSetBaroUnit(), true); | ||
} | ||
} | ||
|
||
/** @private */ | ||
private async autoSetBaroUnit() { | ||
await Wait.awaitSubscribable(GameStateProvider.get(), (v) => v === GameState.ingame, true); | ||
|
||
const sessionId = await Coherent.call('START_NEAREST_SEARCH_SESSION', NearestSearchType.Airport); | ||
const handler = Coherent.on('NearestSearchCompleted', (result: { sessionId: number; added: string[] }) => { | ||
if (result.sessionId === sessionId) { | ||
handler.clear(); | ||
|
||
const useInHg = | ||
result.added.length > 0 && | ||
(BaroUnitSelector.IN_HG_REGIONS.includes(result.added[0].charAt(7)) || | ||
BaroUnitSelector.IN_HG_REGIONS.includes(result.added[0].substring(7, 9))); | ||
|
||
this.setBaroSelector(!useInHg); | ||
} | ||
}); | ||
|
||
const lat = SimVar.GetSimVarValue('PLANE LATITUDE', 'degree latitude'); | ||
const lon = SimVar.GetSimVarValue('PLANE LONGITUDE', 'degree longitude'); | ||
|
||
Coherent.call('SEARCH_NEAREST', sessionId, lat, lon, 50000, 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './BaroUnitSelector'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters