Skip to content

Commit

Permalink
refactor: port SD to full react-based instrument (#7345)
Browse files Browse the repository at this point in the history
Co-authored-by: Benjamin Dupont <[email protected]>
  • Loading branch information
Saschl and Benjozork authored Jan 10, 2023
1 parent 5140532 commit 010bd3e
Show file tree
Hide file tree
Showing 55 changed files with 620 additions and 615 deletions.
10 changes: 7 additions & 3 deletions flybywire-aircraft-a320-neo/ModelBehaviorDefs/A32NX/Airbus.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@
<ANIM_NAME_BUTTON>PUSH_ECAM_#BASE_NAME#</ANIM_NAME_BUTTON>
<LED_NODE_ID>PUSH_ECAM_#BASE_NAME#_SEQ2</LED_NODE_ID>
<BACKLIGHT_NODE_ID>PUSH_ECAM_#BASE_NAME#_SEQ1</BACKLIGHT_NODE_ID>
<EVENT_NAME>A320_Neo_EICAS_2_ECAM_CHANGE_PAGE_#BASE_NAME#</EVENT_NAME>
<!-- <EVENT_NAME>A320_Neo_EICAS_2_ECAM_CHANGE_PAGE_#BASE_NAME#</EVENT_NAME> -->
<EVENT_NAME>A32NX_SD_PAGE_CHANGED</EVENT_NAME>
<CURRENT_BUTTON_VAR_NAME>A32NX_ECAM_SD_CURRENT_PAGE_INDEX</CURRENT_BUTTON_VAR_NAME>
<WWISE_EVENT_1>mcdubuttons</WWISE_EVENT_1>
<NORMALIZED_TIME_1>0.1</NORMALIZED_TIME_1>
Expand All @@ -160,9 +161,12 @@
<UseTemplate Name="ASOBO_GT_Push_Button">
<ANIM_NAME>#ANIM_NAME_BUTTON#</ANIM_NAME>
<LEFT_SINGLE_CODE>
#GROUP_INDEX# -1 &gt; if{
(&gt;H:#EVENT_NAME#) #GROUP_INDEX#
(L:A32NX_ECAM_SD_CURRENT_PAGE_INDEX) #GROUP_INDEX# != if{
#GROUP_INDEX# (&gt;L:A32NX_ECAM_SD_CURRENT_PAGE_INDEX)
} els{
-1 (&gt;L:A32NX_ECAM_SD_CURRENT_PAGE_INDEX)
}
(&gt;H:A32NX_SD_PAGE_CHANGED)
</LEFT_SINGLE_CODE>
</UseTemplate>
</Component>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ A32NX_GEAR_CENTER_POSITION = 100
A32NX_GEAR_LEFT_POSITION = 100
A32NX_GEAR_RIGHT_POSITION = 100
A32NX_GEAR_LEVER_POSITION_REQUEST = 1
A32NX_ECAM_SD_CURRENT_PAGE_INDEX = -1

[Gauges.0]
KollsmanSetting=29.921342849731445313
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ texture = $EWD
htmlgauge00 = A32NX/EWD/template.html?Index=1, 0,0,768,768

[VCockpit04]
size_mm = 1280,1280 #TODO FIXME - Should be 768,768
pixel_size = 1280,1280 #TODO FIXME - Should be 768,768
size_mm = 768,768 #TODO FIXME - Should be 768,768
pixel_size = 768,768 #TODO FIXME - Should be 768,768
texture = $EICAS2

htmlgauge00 = Airliners/FlyByWire_A320_Neo/EICAS/A320_Neo_EICAS.html?Index=2, 0,0,1280,1280 #TODO FIXME - Should be 768,768
htmlgauge00 = A32NX/SD/template.html, 0,0,768,768

[VCockpit05]
size_mm = 512,512
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var Airliners;
this.SwitchToPageName(BaseEICAS.LOWER_SCREEN_GROUP_NAME, pageName);
for (let i = 0; i < this.lowerScreenPages.length; i++) {
if (this.lowerScreenPages[i].name == pageName) {
SimVar.SetSimVarValue("L:A32NX_ECAM_SD_CURRENT_PAGE_INDEX", "number", i);
// SimVar.SetSimVarValue("L:A32NX_ECAM_SD_CURRENT_PAGE_INDEX", "number", i);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class A320_Neo_EICAS extends Airliners.BaseEICAS {
}
}
this.SwitchToPageName(this.LOWER_SCREEN_GROUP_NAME, pageName);
SimVar.SetSimVarValue("L:A32NX_ECAM_SD_CURRENT_PAGE_INDEX", "number", this.currentPage);
//SimVar.SetSimVarValue("L:A32NX_ECAM_SD_CURRENT_PAGE_INDEX", "number", this.currentPage);
}

createLowerScreenPages() {
Expand Down Expand Up @@ -234,7 +234,7 @@ class A320_Neo_EICAS extends Airliners.BaseEICAS {
// Disable user selected page when new failure detected
if (this.PrevFailPage !== sFailPage) {
this.currentPage = -1;
SimVar.SetSimVarValue("L:A32NX_ECAM_SD_CURRENT_PAGE_INDEX", "number", -1);
//SimVar.SetSimVarValue("L:A32NX_ECAM_SD_CURRENT_PAGE_INDEX", "number", -1);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ class EICASCommonDisplay extends Airliners.EICASTemplateElement {
const airDataReferenceSource = this.getStatusAirDataReferenceSource();
const inertialReferenceSource = this.getStatusInertialReferenceSource();
const sat = Arinc429Word.fromSimVarValue(`L:A32NX_ADIRS_ADR_${airDataReferenceSource}_STATIC_AIR_TEMPERATURE`);
this.refreshTAT(Arinc429Word.fromSimVarValue(`L:A32NX_ADIRS_ADR_${airDataReferenceSource}_TOTAL_AIR_TEMPERATURE`));
/* this.refreshTAT(Arinc429Word.fromSimVarValue(`L:A32NX_ADIRS_ADR_${airDataReferenceSource}_TOTAL_AIR_TEMPERATURE`));
this.refreshSAT(sat);
this.refreshISA(Arinc429Word.fromSimVarValue(`L:A32NX_ADIRS_ADR_${airDataReferenceSource}_INTERNATIONAL_STANDARD_ATMOSPHERE_DELTA`), sat);
this.refreshISA(Arinc429Word.fromSimVarValue(`L:A32NX_ADIRS_ADR_${airDataReferenceSource}_INTERNATIONAL_STANDARD_ATMOSPHERE_DELTA`), sat); */

this.refreshClock();
this.refreshLoadFactor(_deltaTime, Arinc429Word.fromSimVarValue(`L:A32NX_ADIRS_IR_${inertialReferenceSource}_BODY_NORMAL_ACC`));
Expand Down
4 changes: 2 additions & 2 deletions src/behavior/src/A32NX_Interior_Misc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,12 @@
<Component ID="#NODE_ID#" Node="#NODE_ID#">
<UseTemplate Name="ASOBO_GT_Push_Button">
<ANIM_NAME>#ANIM_NAME_BUTTON#</ANIM_NAME>
<LEFT_SINGLE_CODE>
<!-- <LEFT_SINGLE_CODE>
#GROUP_INDEX# -1 &gt; if{
(&gt;H:A32NX_SD_PAGE_CHANGED)
#GROUP_INDEX# (&gt;L:A32NX_ECAM_SD_CURRENT_PAGE_INDEX)
}
</LEFT_SINGLE_CODE>
</LEFT_SINGLE_CODE> -->
</UseTemplate>
</Component>

Expand Down
77 changes: 6 additions & 71 deletions src/instruments/buildSrc/igniter/tasks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,85 +3,20 @@ import { join } from 'path';
import { ExecTask } from '@flybywiresim/igniter';
import { Directories } from '../directories.mjs';

const ecamPages = [
{
name: 'eng-page',
path: 'SD/Pages/Eng',
},
{
name: 'door-page',
path: 'SD/Pages/Door',
},
{
name: 'cond-page',
path: 'SD/Pages/Cond',
},
{
name: 'fctl-page',
path: 'SD/Pages/Fctl',
},
{
name: 'elec-page',
path: 'SD/Pages/Elec',
},
{
name: 'hyd-page',
path: 'SD/Pages/Hyd',
},
{
name: 'wheel-page',
path: 'SD/Pages/Wheel',
},
{
name: 'crz-page',
path: 'SD/Pages/Crz',
},
{
name: 'fuel-page',
path: 'SD/Pages/Fuel',
},
{
name: 'apu-page',
path: 'SD/Pages/Apu',
},
{
name: 'press-page',
path: 'SD/Pages/Press',
},
{
name: 'bleed-page',
path: 'SD/Pages/Bleed',
},
{
name: 'status-page',
path: 'SD/Pages/Status',
},
];

export function getInputs() {
const baseInstruments = fs.readdirSync(join(Directories.instruments, 'src'), { withFileTypes: true })
.filter((d) => d.isDirectory() && fs.existsSync(join(Directories.instruments, 'src', d.name, 'config.json')));

return [
...baseInstruments.map(({ name }) => ({ path: name, name, isInstrument: true })),
...ecamPages.map((def) => ({ ...def, isInstrument: false })),
];
return baseInstruments.map(({ name }) => ({ path: name, name }));
}

export function getInstrumentsIgniterTasks() {
const baseInstruments = fs.readdirSync(join(Directories.instruments, 'src'), { withFileTypes: true })
.filter((d) => d.isDirectory() && fs.existsSync(join(Directories.instruments, 'src', d.name, 'config.json')));

return [
...baseInstruments.map(({ name }) => new ExecTask(
name,
`node src/instruments/buildSrc/igniter/worker.mjs ${name}`,
[join('src/instruments/src', name), join('flybywire-aircraft-a320-neo/html_ui/Pages/VCockpit/Instruments/A32NX', name)],
)),
...ecamPages.map(({ name, path }) => new ExecTask(
name,
`node src/instruments/buildSrc/igniter/worker.mjs ${name}`,
[join('src/instruments/src', path), join('flybywire-aircraft-a320-neo/html_ui/Pages/VCockpit/Instruments/A32NX/EcamPages', name)],
)),
];
return baseInstruments.map(({ name }) => new ExecTask(
name,
`node src/instruments/buildSrc/igniter/worker.mjs ${name}`,
[join('src/instruments/src', name), join('flybywire-aircraft-a320-neo/html_ui/Pages/VCockpit/Instruments/A32NX', name)],
));
}
3 changes: 1 addition & 2 deletions src/instruments/buildSrc/simulatorBuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getInputs } from './igniter/tasks.mjs';
process.chdir(Directories.src);

export default getInputs()
.map(({ path, name, isInstrument }) => {
.map(({ path, name }) => {
const config = JSON.parse(fs.readFileSync(join(Directories.instruments, 'src', path, 'config.json')));

const additionalImports = config.additionalImports ? config.additionalImports : [];
Expand Down Expand Up @@ -36,7 +36,6 @@ export default getInputs()
...additionalImports,
],
config,
isInstrument,
}),
],
};
Expand Down
19 changes: 6 additions & 13 deletions src/instruments/buildSrc/templatePlugins.mjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import { join } from 'path';
import instrumentTemplate from '@flybywiresim/rollup-plugin-msfs';
import ecamPageTemplate from '../ecam-page-template/rollup.js';
import { Directories } from './directories.mjs';

export function getTemplatePlugin({ name, config, imports = [], isInstrument }) {
if (isInstrument) {
return instrumentTemplate({
name,
elementName: `a32nx-${name.toLowerCase()}`,
config,
imports,
outputDir: join(Directories.root, 'flybywire-aircraft-a320-neo/html_ui/Pages/VCockpit/Instruments/A32NX'),
});
}
return ecamPageTemplate({
export function getTemplatePlugin({ name, config, imports = [] }) {
return instrumentTemplate({
name,
outputDir: join(Directories.root, 'flybywire-aircraft-a320-neo/html_ui/Pages/VCockpit/Instruments/A32NX/EcamPages'),
elementName: `a32nx-${name.toLowerCase()}`,
config,
imports,
outputDir: join(Directories.root, 'flybywire-aircraft-a320-neo/html_ui/Pages/VCockpit/Instruments/A32NX'),
});
}
41 changes: 0 additions & 41 deletions src/instruments/ecam-page-template/rollup.js

This file was deleted.

21 changes: 0 additions & 21 deletions src/instruments/ecam-page-template/template.html

This file was deleted.

48 changes: 0 additions & 48 deletions src/instruments/ecam-page-template/template.js

This file was deleted.

Loading

0 comments on commit 010bd3e

Please sign in to comment.