Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: aircraft type check #8612

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/a380x-exp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
FBW_PRODUCTION_BUILD: 1
A32NX_INSTRUMENTS_BUILD_WORKERS: 2
BUILD_DIR_NAME: a380x-experimental-a32nx
AIRCRAFT_PROJECT_PREFIX: a32nx
steps:
- name: Checkout source
uses: actions/checkout@v4
Expand All @@ -29,6 +30,7 @@ jobs:
echo CLIENT_SECRET=\"${{ secrets.NAVIGRAPH_CLIENT_SECRET }}\" >> fbw-a32nx/.env
echo CHARTFOX_SECRET=\"${{ secrets.CHARTFOX_SECRET }}\" >> fbw-a32nx/.env
echo SENTRY_DSN=\"${{ secrets.SENTRY_DSN }}\" >> fbw-a32nx/.env
echo AIRCRAFT_PROJECT_PREFIX=${{ env.AIRCRAFT_PREFIX }} >> fbw-a32nx/.env
echo BUILD_DIR_NAME=${{ env.BUILD_DIR_NAME }} >> .env
echo LOCALAZY_READ_KEY=${{ secrets.LOCALAZY_READ_KEY }} >> .env
echo VITE_BUILD=false >> .env
Expand Down Expand Up @@ -66,6 +68,7 @@ jobs:
env:
FBW_PRODUCTION_BUILD: 1
BUILD_DIR_NAME: a380x-experimental-a380x
AIRCRAFT_PREFIX: a380x
steps:
- name: Checkout source
uses: actions/checkout@v4
Expand All @@ -78,6 +81,7 @@ jobs:
echo CLIENT_SECRET=\"${{ secrets.NAVIGRAPH_CLIENT_SECRET_A380X }}\" >> fbw-a380x/.env
echo CHARTFOX_SECRET=\"${{ secrets.CHARTFOX_SECRET }}\" >> fbw-a380x/.env
echo SENTRY_DSN=\"${{ secrets.SENTRY_DSN }}\" >> fbw-a380x/.env
echo AIRCRAFT_PREFIX=${{ env.AIRCRAFT_PREFIX }} >> fbw-a380x/.env
echo BUILD_DIR_NAME=${{ env.BUILD_DIR_NAME }} >> .env
echo LOCALAZY_READ_KEY=${{ secrets.LOCALAZY_READ_KEY }} >> .env
echo VITE_BUILD=false >> .env
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ingamepanels-checklist-fix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
FBW_PRODUCTION_BUILD: 1
MASTER_ZIP_NAME: ingamepanels-checklist-fix-master.zip
BUILD_DIR_NAME: master
AIRCRAFT_PROJECT_PREFIX: a32nx
steps:
- name: Checkout source
uses: actions/checkout@v2
Expand All @@ -33,6 +34,7 @@ jobs:
echo CLIENT_SECRET=${{ secrets.NAVIGRAPH_CLIENT_SECRET }} >> .env
echo CHARTFOX_SECRET=${{ secrets.CHARTFOX_SECRET }} >> .env
echo SENTRY_DSN=${{ secrets.SENTRY_DSN }} >> .env
echo AIRCRAFT_PROJECT_PREFIX=${{ env.AIRCRAFT_PROJECT_PREFIX }} >> .env
echo BUILD_DIR_NAME=${{ env.BUILD_DIR_NAME }} >> .env
echo LOCALAZY_READ_KEY=${{ secrets.LOCALAZY_READ_KEY }} >> .env
- name: Build In-Game Panels Checklist Fix
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
VMASTER_PRE_RELEASE_ID: 32243965
VMASTER_PRE_RELEASE_TAG: vmaster
BUILD_DIR_NAME: master-a32nx
AIRCRAFT_PROJECT_PREFIX: a32nx
steps:
- name: Checkout source
uses: actions/checkout@v4
Expand All @@ -34,6 +35,7 @@ jobs:
echo CLIENT_SECRET=\"${{ secrets.NAVIGRAPH_CLIENT_SECRET }}\" >> fbw-a32nx/.env
echo CHARTFOX_SECRET=\"${{ secrets.CHARTFOX_SECRET }}\" >> fbw-a32nx/.env
echo SENTRY_DSN=\"${{ secrets.SENTRY_DSN }}\" >> fbw-a32nx/.env
echo AIRCRAFT_PROJECT_PREFIX=\"${{ env.AIRCRAFT_PROJECT_PREFIX }}\" >> fbw-a32nx/.env
echo BUILD_DIR_NAME=${{ env.BUILD_DIR_NAME }} >> .env
echo LOCALAZY_READ_KEY=${{ secrets.LOCALAZY_READ_KEY }} >> .env
echo VITE_BUILD=false >> .env
Expand Down Expand Up @@ -100,6 +102,7 @@ jobs:
VMASTER_PRE_RELEASE_ID: 32243965
VMASTER_PRE_RELEASE_TAG: vmaster
BUILD_DIR_NAME: master-a380x
AIRCRAFT_PROJECT_PREFIX: a380x
steps:
- name: Checkout source
uses: actions/checkout@v4
Expand All @@ -112,6 +115,7 @@ jobs:
echo CLIENT_SECRET=\"${{ secrets.NAVIGRAPH_CLIENT_SECRET_A380X }}\" >> fbw-a380x/.env
echo CHARTFOX_SECRET=\"${{ secrets.CHARTFOX_SECRET }}\" >> fbw-a380x/.env
echo SENTRY_DSN=\"${{ secrets.SENTRY_DSN }}\" >> fbw-a380x/.env
echo AIRCRAFT_PROJECT_PREFIX=\"${{ env.AIRCRAFT_PROJECT_PREFIX }}\" >> fbw-a380x/.env
echo BUILD_DIR_NAME=${{ env.BUILD_DIR_NAME }} >> .env
echo LOCALAZY_READ_KEY=${{ secrets.LOCALAZY_READ_KEY }} >> .env
echo VITE_BUILD=false >> .env
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
if: github.event.pull_request.draft == false
env:
FBW_PRODUCTION_BUILD: 1
AIRCRAFT_PROJECT_PREFIX: a32nx
steps:
- name: Checkout source
uses: actions/checkout@v4
Expand All @@ -60,6 +61,7 @@ jobs:
echo CLIENT_SECRET=\"${{ secrets.NAVIGRAPH_CLIENT_SECRET_A380X }}\" >> fbw-a32nx/.env
echo CHARTFOX_SECRET=\"${{ secrets.CHARTFOX_SECRET }}\" >> fbw-a32nx/.env
echo SENTRY_DSN=\"${{ secrets.SENTRY_DSN }}\" >> fbw-a32nx/.env
echo AIRCRAFT_PROJECT_PREFIX=\"${{ env.AIRCRAFT_PROJECT_PREFIX }}\" >> fbw-a32nx/.env
echo LOCALAZY_READ_KEY=${{ secrets.LOCALAZY_READ_KEY }} >> .env
echo VITE_BUILD=false >> .env
cat fbw-a32nx/.env
Expand Down Expand Up @@ -124,4 +126,4 @@ jobs:
if: github.event.pull_request.auto_merge == false
with:
name: flybywire-aircraft-a380-842
path: ./fbw-a380x/out/flybywire-aircraft-a380-842/
path: ./fbw-a380x/out/flybywire-aircraft-a380-842/
2 changes: 2 additions & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
FBW_PRODUCTION_BUILD: 1
RELEASE_ZIP_NAME: A32NX-stable.7z
BUILD_DIR_NAME: stable
AIRCRAFT_PROJECT_PREFIX: a32nx
steps:
- name: Checkout source
uses: actions/checkout@v2
Expand All @@ -23,6 +24,7 @@ jobs:
echo CHARTFOX_SECRET=\"${{ secrets.CHARTFOX_SECRET }}\" >> fbw-a32nx/.env
echo SENTRY_DSN=\"${{ secrets.SENTRY_DSN }}\" >> fbw-a32nx/.env
echo BUILD_DIR_NAME=${{ env.BUILD_DIR_NAME }} >> .env
echo BUILD_DIR_NAME=${{ env.AIRCRAFT_PROJECT_PREFIX }} >> fbw-a32nx/.env
echo LOCALAZY_READ_KEY=${{ secrets.LOCALAZY_READ_KEY }} >> .env
echo VITE_BUILD=false >> .env
- name: Build A32NX
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
STABLE_PRE_RELEASE_TAG: assets/stable
STABLE_ZIP_NAME: A32NX-stable.7z
BUILD_DIR_NAME: stable
AIRCRAFT_PROJECT_PREFIX: a32nx
steps:
- name: Checkout source
uses: actions/checkout@v2
Expand All @@ -25,6 +26,7 @@ jobs:
echo CLIENT_SECRET=\"${{ secrets.NAVIGRAPH_CLIENT_SECRET }}\" >> fbw-a32nx/.env
echo CHARTFOX_SECRET=\"${{ secrets.CHARTFOX_SECRET }}\" >> fbw-a32nx/.env
echo SENTRY_DSN=\"${{ secrets.SENTRY_DSN }}\" >> fbw-a32nx/.env
echo AIRCRAFT_PROJECT_PREFIX=\"${{ secrets.AIRCRAFT_PROJECT_PREFIX }}\" >> fbw-a32nx/.env
echo BUILD_DIR_NAME=${{ env.BUILD_DIR_NAME }} >> .env
echo LOCALAZY_READ_KEY=${{ secrets.LOCALAZY_READ_KEY }} >> .env
echo VITE_BUILD=false >> .env
Expand Down
1 change: 1 addition & 0 deletions fbw-a32nx/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ NODE_ENV=production
CLIENT_SECRET=""
CLIENT_ID=""
SENTRY_DSN=""
AIRCRAFT_PROJECT_PREFIX="a32nx"
29 changes: 19 additions & 10 deletions fbw-a32nx/docs/a320-simvars.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@

## Uncategorized

- A32NX_AIRCRAFT_TYPE
- Enum
- Indicates the aircraft type
Aircraft | Value
--- | ---
Unknown | 0
A320_251N | 1
A380_842 | 2

- A32NX_IS_READY
- Bool
- Indicates that the JavaScript part is ready
Expand All @@ -42,16 +51,16 @@
- A32NX_START_STATE
- Enum
- Indicates the state in which MSFS started
- State | Value
--- | ---
Hangar | 1
Apron | 2
Taxi | 3
Runway | 4
Climb | 5
Cruise | 6
Approach | 7
Final | 8
State | Value
--- | ---
Hangar | 1
Apron | 2
Taxi | 3
Runway | 4
Climb | 5
Cruise | 6
Approach | 7
Final | 8

- A32NX_NO_SMOKING_MEMO
- Boolean that determines whether the NO SMOKING memo should be visible on the upper ECAM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ size_mm = 1430,1000
pixel_size = 1430,1000
texture = $EFB

htmlgauge00 = A32NX/EFB/efb.html?Airframe=A320_251N, 0,0,1430,1000
htmlgauge00 = A32NX/EFB/efb.html, 0,0,1430,1000

[VCockpit17]
size_mm = 0,0
Expand All @@ -149,7 +149,7 @@ pixel_size = 0,0
texture = NO_TEXTURE
background_color = 0,0,0

htmlgauge00 = A32NX/ExtrasHost/extras-host.html,0,0,1,1
htmlgauge00 = A32NX/ExtrasHost/extras-host.html?Airframe=A320_251N,0,0,1,1

[VPainting01]
size_mm = 2048,512
Expand Down
16 changes: 15 additions & 1 deletion fbw-a32nx/src/systems/extras-host/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ExtrasSimVarPublisher } from 'extras-host/modules/common/ExtrasSimVarPu
import { PushbuttonCheck } from 'extras-host/modules/pushbutton_check/PushbuttonCheck';
import { KeyInterceptor } from './modules/key_interceptor/KeyInterceptor';
import { VersionCheck } from './modules/version_check/VersionCheck';
import { AircraftSync } from './modules/aircraft_sync/AircraftSync';

/**
* This is the main class for the extras-host instrument.
Expand Down Expand Up @@ -40,6 +41,10 @@ class ExtrasHost extends BaseInstrument {

private readonly keyInterceptor: KeyInterceptor;

private readonly aircraftSync: AircraftSync;

public readonly xmlConfig: Document;

/**
* "mainmenu" = 0
* "loading" = 1
Expand All @@ -58,8 +63,9 @@ class ExtrasHost extends BaseInstrument {
this.notificationManager = new NotificationManager();

this.pushbuttonCheck = new PushbuttonCheck(this.bus, this.notificationManager);
this.versionCheck = new VersionCheck(this.bus);
this.keyInterceptor = new KeyInterceptor(this.bus, this.notificationManager);
this.versionCheck = new VersionCheck(process.env.AIRCRAFT_PROJECT_PREFIX, this.bus);
this.aircraftSync = new AircraftSync(process.env.AIRCRAFT_PROJECT_PREFIX, this.bus);

console.log('A32NX_EXTRASHOST: Created');
}
Expand All @@ -82,6 +88,12 @@ class ExtrasHost extends BaseInstrument {
this.pushbuttonCheck.connectedCallback();
this.versionCheck.connectedCallback();
this.keyInterceptor.connectedCallback();
this.aircraftSync.connectedCallback();
}

public parseXMLConfig(): void {
super.parseXMLConfig();
this.aircraftSync.parseXMLConfig(this.xmlConfig);
}

public Update(): void {
Expand All @@ -94,6 +106,7 @@ class ExtrasHost extends BaseInstrument {
this.versionCheck.startPublish();
this.keyInterceptor.startPublish();
this.simVarPublisher.startPublish();
this.aircraftSync.startPublish();
}
this.gameState = gs;
} else {
Expand All @@ -102,6 +115,7 @@ class ExtrasHost extends BaseInstrument {

this.versionCheck.update();
this.keyInterceptor.update();
this.aircraftSync.update();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) 2022 FlyByWire Simulations
// SPDX-License-Identifier: GPL-3.0

import { AircraftType } from '@flybywiresim/fbw-sdk';
import { EventBus } from '@microsoft/msfs-sdk';

/**
* This class is used to check the airframe of the aircraft and set the LVar
*/
export class AircraftSync {
public xmlConfig: Document

constructor(private readonly aircraftProjectPrefix: string, private readonly bus: EventBus) {
console.log('AircraftSync: Created');
}

public connectedCallback(): void {
// empty
}

public parseXMLConfig(xmlConfig: Document): void {
this.xmlConfig = xmlConfig;
}

// TODO: Remove this sync when VFS config is done.
// Replace with new function for commbus implementation to sync VFS markup config to WASM
public startPublish(): void {
console.log('AicraftSync: startPublish()');

const airframe = new URL(document.querySelectorAll('vcockpit-panel > *')[0].getAttribute('url')).searchParams.get('Airframe');
let aircraftType: AircraftType;

switch (airframe) {
case 'A380_842':
aircraftType = AircraftType.A380_842;
break;
case 'A320_251N':
default:
aircraftType = AircraftType.A320_251N;
break;
}

SimVar.SetSimVarValue('L:A32NX_AIRCRAFT_TYPE', 'enum', aircraftType);
console.log(`AirframeCheck: set ${aircraftType}`);
}

public update(): void {
// empty
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
// SPDX-License-Identifier: GPL-3.0

import { EventBus } from '@microsoft/msfs-sdk';
import { AircraftVersionChecker } from '@fbw-common/shared/AircraftVersionChecker';
import { AircraftGithubVersionChecker } from '@fbw-common/shared/AircraftGithubVersionChecker';

/**
* This class is used to check the version of the aircraft and display a warning if it is too old.
*/
export class VersionCheck {
constructor(private readonly bus: EventBus) {
constructor(private readonly aircraftProjectPrefix: string, private readonly bus: EventBus) {
console.log('VersionCheck: Created');
}

Expand All @@ -18,7 +18,7 @@ export class VersionCheck {

public startPublish(): void {
console.log('VersionCheck: startPublish()');
AircraftVersionChecker.checkVersion('a32nx');
AircraftGithubVersionChecker.checkVersion(this.aircraftProjectPrefix);
}

public update(): void {
Expand Down
1 change: 1 addition & 0 deletions fbw-a32nx/src/systems/instruments/buildSrc/plugins.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export function baseCompile(instrumentName, instrumentFolder) {
'process.env.CLIENT_SECRET': JSON.stringify(process.env.CLIENT_SECRET),
'process.env.CHARTFOX_SECRET': JSON.stringify(process.env.CHARTFOX_SECRET),
'process.env.SENTRY_DSN': JSON.stringify(process.env.SENTRY_DSN),
'process.env.AIRCRAFT_PROJECT_PREFIX': JSON.stringify(process.env.AIRCRAFT_PROJECT_PREFIX),
}),
postCss(instrumentName, instrumentFolder),
];
Expand Down
2 changes: 1 addition & 1 deletion fbw-a32nx/src/systems/instruments/src/Common/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const render = (Slot: React.ReactElement, enableSentryTracing = false, se
const doRender = () => {
new FbwAircraftSentryClient().onInstrumentLoaded({
dsn: process.env.SENTRY_DSN,
buildInfoFilePrefix: 'a32nx',
buildInfoFilePrefix: process.env.AIRCRAFT_PROJECT_PREFIX,
enableTracing: enableSentryTracing,
root: sentryRootClient,
});
Expand Down
2 changes: 1 addition & 1 deletion fbw-a32nx/src/systems/sentry-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ declare const process: any;

new FbwAircraftSentryClient().onInstrumentLoaded({
dsn: process.env.SENTRY_DSN,
buildInfoFilePrefix: 'a32nx',
buildInfoFilePrefix: process.env.AIRCRAFT_PROJECT_PREFIX,
root: false,
enableTracing: false,
});
1 change: 1 addition & 0 deletions fbw-a380x/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ NODE_ENV=production
CLIENT_SECRET=""
CLIENT_ID=""
SENTRY_DSN=""
AIRCRAFT_PROJECT_PREFIX="a380x"
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ size_mm=1430,1000
pixel_size=1430,1000
texture=$SCREEN_EFB

htmlgauge00=A380X/EFB/efb.html?Airframe=A380_842, 0,0,1430,1000
htmlgauge00=A380X/EFB/efb.html, 0,0,1430,1000

[VCockpit16]
size_mm=1664,1024
Expand Down Expand Up @@ -168,4 +168,4 @@ pixel_size=0,0
texture=NO_TEXTURE
background_color=0,0,0

htmlgauge04=A380X/ExtrasHost/extras-host.html,0,0,1,1
htmlgauge04=A380X/ExtrasHost/extras-host.html?Airframe=A380_842,0,0,1,1
Loading