Skip to content

Commit

Permalink
feat(a380x): port ewd to msfs avionics framework (#8701)
Browse files Browse the repository at this point in the history
* start the port

* some fixes

* point to new ewd

* finish thrustratingmode

* add memo

* fix import

* fix visibility

* config changes, delete PseudoFWC

* new structure; add EGT

* add N1, THR

* add IDLE, PACKS/NAI/WAI

* add transient to N1 degraded gauge

* add LIMITATIONs and MEMOs

* clean up

* rename EWDv2 to EWD

* clean up code

* memo & thrust gauge fixes

* enable strict mode

---------

Co-authored-by: Florian Gross <[email protected]>
  • Loading branch information
Saschl and flogross89 authored Aug 8, 2024
1 parent e0dbfda commit 67bf93b
Show file tree
Hide file tree
Showing 31 changed files with 2,666 additions and 2,056 deletions.
2 changes: 1 addition & 1 deletion fbw-a380x/mach.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ module.exports = {
],
instruments: [
msfsAvionicsInstrument('Clock'),
msfsAvionicsInstrument('EWD'),
msfsAvionicsInstrument('ND'),
msfsAvionicsInstrument('PFD'),
msfsAvionicsInstrument('RMP'),

reactInstrument('BAT'),
reactInstrument('EFB', ['/Pages/VCockpit/Instruments/Shared/Map/MapInstrument.html']),
reactInstrument('EWD'),
reactInstrument('MFD'),
reactInstrument('OIT'),
reactInstrument('SD'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3943,7 +3943,7 @@
<UseTemplate Name="FBW_Airbus_AntiIce_Engine">
<NODE_ID>PUSH_OVHD_ANTIICE_ENG3</NODE_ID>
<PART_ID>ANTIICE_ENG1</PART_ID>
<ID>1</ID>
<ID>3</ID>
<SEQ_POWERED>(L:A32NX_ELEC_AC_1_BUS_IS_POWERED, Bool)</SEQ_POWERED>
<SEQ2_EMISSIVE_DRIVES_VISIBILITY>False</SEQ2_EMISSIVE_DRIVES_VISIBILITY>
<SEQ1_CODE_DRIVES_VISIBILITY>False</SEQ1_CODE_DRIVES_VISIBILITY>
Expand All @@ -3952,7 +3952,7 @@
<UseTemplate Name="FBW_Airbus_AntiIce_Engine">
<NODE_ID>PUSH_OVHD_ANTIICE_ENG4</NODE_ID>
<PART_ID>ANTIICE_ENG2</PART_ID>
<ID>2</ID>
<ID>4</ID>
<SEQ_POWERED>(L:A32NX_ELEC_AC_2_BUS_IS_POWERED, Bool)</SEQ_POWERED>
<SEQ2_EMISSIVE_DRIVES_VISIBILITY>False</SEQ2_EMISSIVE_DRIVES_VISIBILITY>
<SEQ1_CODE_DRIVES_VISIBILITY>False</SEQ1_CODE_DRIVES_VISIBILITY>
Expand Down
388 changes: 164 additions & 224 deletions fbw-a380x/src/systems/instruments/src/Common/EWDMessages.tsx

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions fbw-a380x/src/systems/instruments/src/EWD/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

module.exports = {
extends: '../../../../../../.eslintrc.js',

// overrides airbnb, use sparingly
rules: {
'react/react-in-jsx-scope': 'off',
'react/no-unknown-property': 'off',
'react/style-prop-object': 'off',
'arrow-body-style': 'off',
camelcase: 'off',
},
};
182 changes: 182 additions & 0 deletions fbw-a380x/src/systems/instruments/src/EWD/EWD.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
import { CdsDisplayUnit, DisplayUnitID } from '../MsfsAvionicsCommon/CdsDisplayUnit';

import { ConsumerSubject, DisplayComponent, FSComponent, MappedSubject, Subject, VNode } from '@microsoft/msfs-sdk';
import { EwdSimvars } from './shared/EwdSimvarPublisher';
import { ArincEventBus } from '@flybywiresim/fbw-sdk';
import { N1Limit } from './elements/ThrustRatingMode';
import { EngineGauge } from 'instruments/src/EWD/elements/EngineGauge';
import { Idle } from 'instruments/src/EWD/elements/Idle';
import { BleedSupply } from 'instruments/src/EWD/elements/BleedSupply';
import { WdMemos } from 'instruments/src/EWD/elements/WdMemos';
import { WdLimitations } from 'instruments/src/EWD/elements/WdLimitations';

export class EngineWarningDisplay extends DisplayComponent<{ bus: ArincEventBus }> {
private readonly engineStateSubs: ConsumerSubject<number>[] = [
ConsumerSubject.create(null, 0),
ConsumerSubject.create(null, 0),
ConsumerSubject.create(null, 0),
ConsumerSubject.create(null, 0),
];

private readonly engSelectorPosition = ConsumerSubject.create(null, 0);

private readonly engineRunningOrIgnitionOn = MappedSubject.create(
([eng1, eng2, eng3, eng4, engSelectorPosition]) => {
const isAnyEngineRunning = eng1 !== 0 || eng2 !== 0 || eng3 !== 0 || eng4 !== 0; // TODO Implement FADEC SimVars once available

return !!(engSelectorPosition === 2 || isAnyEngineRunning);
},
...this.engineStateSubs,
this.engSelectorPosition,
);

private readonly n1Degraded = [
Subject.create(false),
Subject.create(false),
Subject.create(false),
Subject.create(false),
];

public onAfterRender(node: VNode): void {
super.onAfterRender(node);

const sub = this.props.bus.getSubscriber<EwdSimvars>();

this.engineStateSubs[0].setConsumer(sub.on('engine_state_1').whenChanged());
this.engineStateSubs[1].setConsumer(sub.on('engine_state_2').whenChanged());
this.engineStateSubs[2].setConsumer(sub.on('engine_state_3').whenChanged());
this.engineStateSubs[3].setConsumer(sub.on('engine_state_4').whenChanged());

this.engSelectorPosition.setConsumer(sub.on('eng_selector_position').whenChanged());
}

render(): VNode {
return (
<CdsDisplayUnit
bus={this.props.bus}
displayUnitId={DisplayUnitID.Ewd}
test={Subject.create(-1)}
failed={Subject.create(false)}
>
<div class="ewd-main">
<div class="EngineDisplayArea">
<svg class="ewd-svg" version="1.1" viewBox="0 0 768 375" xmlns="http://www.w3.org/2000/svg">
<text x={20} y={30} class="Amber F26" visibility="hidden">
A FLOOR
</text>
<N1Limit x={330} y={30} active={this.engineRunningOrIgnitionOn} bus={this.props.bus} />
<BleedSupply bus={this.props.bus} x={750} y={30} />

<EngineGauge
bus={this.props.bus}
x={93}
y={126}
engine={1}
active={this.engineRunningOrIgnitionOn}
n1Degraded={this.n1Degraded[0]}
/>
<EngineGauge
bus={this.props.bus}
x={262}
y={126}
engine={2}
active={this.engineRunningOrIgnitionOn}
n1Degraded={this.n1Degraded[1]}
/>
<EngineGauge
bus={this.props.bus}
x={497}
y={126}
engine={3}
active={this.engineRunningOrIgnitionOn}
n1Degraded={this.n1Degraded[2]}
/>
<EngineGauge
bus={this.props.bus}
x={668}
y={126}
engine={4}
active={this.engineRunningOrIgnitionOn}
n1Degraded={this.n1Degraded[3]}
/>

<Idle bus={this.props.bus} x={386} y={90} />
<text x={386} y={121} class="White F26 Center">
THR
</text>
<text x={386} y={142} class="Cyan F20 Center">
%
</text>

{/* N1 */}

<text x={386} y={220} class="White F26 Center">
N1
</text>
<text x={386} y={243} class="Cyan F20 Center">
%
</text>

<path
class={MappedSubject.create(
([eng1N1Degraded, eng2N1Degraded, engineRunningOrIgnitionOn]) =>
eng1N1Degraded || eng2N1Degraded || !engineRunningOrIgnitionOn
? 'LightGreyLine Hide'
: 'LightGreyLine Show',
this.n1Degraded[0],
this.n1Degraded[1],
this.engineRunningOrIgnitionOn,
)}
d={'m 171 228 l 24 -2'}
/>
<path
class={MappedSubject.create(
([eng2N1Degraded, engineRunningOrIgnitionOn]) =>
eng2N1Degraded || !engineRunningOrIgnitionOn ? 'LightGreyLine Hide' : 'LightGreyLine Show',
this.n1Degraded[1],
this.engineRunningOrIgnitionOn,
)}
d={'m 335 216 l 20 -2'}
/>
<path
class={MappedSubject.create(
([eng3N1Degraded, engineRunningOrIgnitionOn]) =>
eng3N1Degraded || !engineRunningOrIgnitionOn ? 'LightGreyLine Hide' : 'LightGreyLine Show',
this.n1Degraded[2],
this.engineRunningOrIgnitionOn,
)}
d={'m 416 216 l 20 2'}
/>
<path
class={MappedSubject.create(
([eng3N1Degraded, eng4N1Degraded, engineRunningOrIgnitionOn]) =>
eng3N1Degraded || eng4N1Degraded || !engineRunningOrIgnitionOn
? 'LightGreyLine Hide'
: 'LightGreyLine Show',
this.n1Degraded[2],
this.n1Degraded[3],
this.engineRunningOrIgnitionOn,
)}
d={'m 576 226 l 24 2'}
/>

{/* EGT */}

<text x={384} y={316} class="White F26 Center">
EGT
</text>
<text x={384} y={339} class="Cyan F20 Center">
&deg;C
</text>
</svg>
</div>
<div class="WarningDisplayArea">
<WdLimitations bus={this.props.bus} />
<WdMemos bus={this.props.bus} />
<div class="StsArea" /> {/* Reserved for STS */}
</div>
</div>
</CdsDisplayUnit>
);
}
}
63 changes: 0 additions & 63 deletions fbw-a380x/src/systems/instruments/src/EWD/EngineWarningDisplay.tsx

This file was deleted.

6 changes: 3 additions & 3 deletions fbw-a380x/src/systems/instruments/src/EWD/config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"index": "./index.tsx",
"isInteractive": true,
"index": "./instrument.tsx",
"name": "EWD",
"dimensions": {
"width": 768,
"height": 1024
}
},
"isInteractive": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import {
ConsumerSubject,
DisplayComponent,
EventBus,
FSComponent,
MappedSubject,
Subscribable,
} from '@microsoft/msfs-sdk';
import { EwdSimvars } from 'instruments/src/EWD/shared/EwdSimvarPublisher';

interface AttentionGetterProps {
bus: EventBus;
x: number;
y: number;
engine: number;
active: Subscribable<boolean>;
}

export class AttentionGetter extends DisplayComponent<AttentionGetterProps> {
private readonly sub = this.props.bus.getSubscriber<EwdSimvars>();

private readonly n1 = ConsumerSubject.create(
this.sub.on(`n1_${this.props.engine}`).withPrecision(1).whenChanged(),
0,
);

private readonly engineState = ConsumerSubject.create(
this.sub.on(`engine_state_${this.props.engine}`).whenChanged(),
0,
);

private readonly n1Idle = ConsumerSubject.create(this.sub.on('n1Idle').withPrecision(1).whenChanged(), 0);

private readonly visible = MappedSubject.create(
([active, n1, n1Idle, es]) => active && !!(n1 < Math.floor(n1Idle) - 1 && es === 2),
this.props.active,
this.n1,
this.n1Idle,
this.engineState,
);

render() {
return (
<g
id={`attention-getter-${this.props.engine}`}
visibility={this.visible.map((it) => (it ? 'inherit' : 'hidden'))}
>
<path class="WhiteLine" d={`m ${this.props.x - 74} ${this.props.y - 13} l 0,-72 l 162,0 l 0,72`} />
<path class="WhiteLine" d={`m ${this.props.x - 74} ${this.props.y + 168} l 0,72 l 162,0 l 0,-72`} />
</g>
);
}
}
Loading

0 comments on commit 67bf93b

Please sign in to comment.