-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(a380x): port ewd to msfs avionics framework (#8701)
* 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
1 parent
e0dbfda
commit 67bf93b
Showing
31 changed files
with
2,666 additions
and
2,056 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
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
388 changes: 164 additions & 224 deletions
388
fbw-a380x/src/systems/instruments/src/Common/EWDMessages.tsx
Large diffs are not rendered by default.
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
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', | ||
}, | ||
}; |
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,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"> | ||
°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
63
fbw-a380x/src/systems/instruments/src/EWD/EngineWarningDisplay.tsx
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
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 | ||
} |
53 changes: 53 additions & 0 deletions
53
fbw-a380x/src/systems/instruments/src/EWD/elements/AttentionGetter.tsx
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,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> | ||
); | ||
} | ||
} |
Oops, something went wrong.