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

feat: Random Failures #7821

Open
wants to merge 292 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
292 commits
Select commit Hold shift + click to select a range
3f00202
new individual Failures for generators
Maverickwoe Mar 1, 2023
7699efd
fix declaration of all failure hooks at each step
Maverickwoe Mar 1, 2023
0a86139
fixed failureList generation
Maverickwoe Mar 1, 2023
b893f55
added init for all failures
Maverickwoe Mar 1, 2023
5fe8c9b
attempt to display a new generator tab in failure
Maverickwoe Mar 2, 2023
07edd9b
fixed first layer tab for failures
Maverickwoe Mar 3, 2023
242579b
fix relative routing for comfort view
Maverickwoe Mar 3, 2023
7f755a5
changed translation structure
Maverickwoe Mar 3, 2023
98ce590
fix of ATAChapter with new relative path
Maverickwoe Mar 3, 2023
a5a88ba
Attempt to add generator selector
Maverickwoe Mar 3, 2023
6fd1514
optimized failureGenerator array outside of hooks
Maverickwoe Mar 3, 2023
660153b
attempt to show one button per generator - BUGGED
Maverickwoe Mar 3, 2023
b6eaf3a
added structure for all settings
Maverickwoe Mar 4, 2023
f547acb
Attempf to fix fail gen cards display
Maverickwoe Mar 5, 2023
6cd041b
added content to TAke Off failure card
Maverickwoe Mar 5, 2023
987d3fb
fix undefined setting
Maverickwoe Mar 5, 2023
25fe94e
take off setting input fields
Maverickwoe Mar 6, 2023
0a6a909
take off: replaced usestate by global var
Maverickwoe Mar 6, 2023
0e3e142
fix wrong index on altitude setting
Maverickwoe Mar 6, 2023
0e6e6cf
optimize setting split once per display
Maverickwoe Mar 6, 2023
22fbd1d
replace raw string setting with table
Maverickwoe Mar 6, 2023
474f33e
fix wrong min max in take off settings
Maverickwoe Mar 6, 2023
46dcb92
replace string setting by table verywhere
Maverickwoe Mar 6, 2023
ea00bad
added button for rearm type
Maverickwoe Mar 6, 2023
879be6c
added Max Number of failure display
Maverickwoe Mar 6, 2023
eee8201
Major visual improv of take off card
Maverickwoe Mar 6, 2023
37eeb71
fix add generator with array instead of string
Maverickwoe Mar 6, 2023
89f79de
centering of bin icon
Maverickwoe Mar 6, 2023
bfcc7a2
Factoring TakeOff settings and rearm
Maverickwoe Mar 7, 2023
6bc71a0
added check for corrupted settings Take off
Maverickwoe Mar 7, 2023
9dba7bb
protect against undefined settings
Maverickwoe Mar 7, 2023
88e6932
excluding split result instead of string itself
Maverickwoe Mar 7, 2023
f537d6a
fix newSetting still in strings
Maverickwoe Mar 7, 2023
2219e63
same fix for perHour
Maverickwoe Mar 7, 2023
5537cbe
renaming button to cards
Maverickwoe Mar 7, 2023
f854e71
fix wrong rearm button ID in refactor
Maverickwoe Mar 7, 2023
b541383
using factored components for PerHour
Maverickwoe Mar 8, 2023
0c58c13
split files for alt failure
Maverickwoe Mar 8, 2023
d0e8e9d
replaced settings hook by var for Alt Gen
Maverickwoe Mar 8, 2023
5f80609
Added Cards for altitude climb / desc
Maverickwoe Mar 8, 2023
7ef9615
Split speed failure gens, renamed to singular
Maverickwoe Mar 8, 2023
1e21d71
using vars instead of hooks for arm on speed gen
Maverickwoe Mar 8, 2023
c456fa1
Added Cards for speed gen
Maverickwoe Mar 8, 2023
b698973
fix error of setting choice
Maverickwoe Mar 8, 2023
8cffbc3
created generator failures removal function
Maverickwoe Mar 8, 2023
4620159
fix remaining border on takeoff card
Maverickwoe Mar 8, 2023
a1cc74e
fix rearm buttons always displaying takeoff gene
Maverickwoe Mar 8, 2023
b4ef546
recommit
Maverickwoe Mar 8, 2023
88db0d8
fix missing argument in alt desc
Maverickwoe Mar 8, 2023
2a6633e
fix setting number in alt climb
Maverickwoe Mar 8, 2023
a512055
reordered generator order of appearance
Maverickwoe Mar 8, 2023
63fea26
fix wrong max on timer
Maverickwoe Mar 8, 2023
9041f76
migrated UI in separate file
Maverickwoe Mar 8, 2023
410e30a
adjust size of gen selection
Maverickwoe Mar 8, 2023
1095afb
changed arm button look
Maverickwoe Mar 8, 2023
5554e7d
Reuse of setting buttons instead for rearm
Maverickwoe Mar 10, 2023
1ec8263
Major refactor through interface FailureGenData
Maverickwoe Mar 10, 2023
4e450b4
Fix incorrect arguments for cards
Maverickwoe Mar 10, 2023
6400013
moved UI of failure Setting
Maverickwoe Mar 10, 2023
ac8eda2
Further refactoring of CARDUI
Maverickwoe Mar 11, 2023
7d81c0c
fix selector of gen with new refactor
Maverickwoe Mar 11, 2023
8b86c08
fix relative route to comfort failures
Maverickwoe Mar 11, 2023
da042b8
minor fixes and tuning
Maverickwoe Mar 11, 2023
e889742
regroup all sub cards generatoin in one go
Maverickwoe Mar 11, 2023
0a0386d
Replaced setting inputs by modal input
Maverickwoe Mar 12, 2023
a0139c3
moved randomFailure Gen to directory
Maverickwoe Mar 14, 2023
145d25f
revert changes in Comfort.
Maverickwoe Mar 15, 2023
dc796d6
Migrated modal window to Routes
Maverickwoe Mar 17, 2023
ffed70c
file splitting for failure Selection
Maverickwoe Mar 17, 2023
9dc6493
split failure selection UI
Maverickwoe Mar 17, 2023
61f1d5f
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Mar 18, 2023
654b7db
add capacity to not show takeOff Rearm
Maverickwoe Mar 18, 2023
2df05a6
Localization french and english
Maverickwoe Mar 18, 2023
ac5b826
Remove all logs and comments
Maverickwoe Mar 18, 2023
2ddbeb9
removed unuseful ":" in a gen
Maverickwoe Mar 18, 2023
dd55675
use simvar on takeoff altitude
Maverickwoe Mar 19, 2023
3140ea3
adding by default all failures with new gen
Maverickwoe Mar 20, 2023
9fa1c7d
Visual improvement of gen settings
Maverickwoe Mar 20, 2023
f02b8ef
change speed and altitude setting size
Maverickwoe Mar 20, 2023
8a983c3
fix error in daysPerYear for MTTF
Maverickwoe Mar 20, 2023
a8e85a9
reducing operations for MTTF formula
Maverickwoe Mar 20, 2023
2718153
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Mar 20, 2023
86dd41d
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Mar 23, 2023
0e543e3
backbone of new UI
Maverickwoe Mar 25, 2023
e0ae938
Using now a context for modal popups
Maverickwoe Mar 25, 2023
b8adb58
changed default arming policy for each gen
Maverickwoe Mar 25, 2023
69cb9eb
Failure shortlist with chapters
Maverickwoe Mar 25, 2023
f69c855
fix improper failure handling when deleting card
Maverickwoe Mar 25, 2023
e4a3ea5
Altitude Climb/Desc has random between Min & Max
Maverickwoe Mar 26, 2023
9a374b0
fix max altitude used for rearm of descent
Maverickwoe Mar 26, 2023
319d6d8
commonalised climb and descent generators
Maverickwoe Mar 27, 2023
bf36113
gen speed and timer have min max
Maverickwoe Mar 28, 2023
16fe094
fix : take off rearm on most gens
Maverickwoe Mar 30, 2023
92d616e
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Mar 30, 2023
80fff06
conflicting css
Maverickwoe Mar 30, 2023
32f7f46
Merge branch 'a32nx-RandomFailures' of https://github.com/Maverickwoe…
Maverickwoe Mar 30, 2023
089ed1d
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Mar 30, 2023
a0bcf4c
fix min max of take off settings
Maverickwoe Mar 30, 2023
3661b64
Merge branch 'a32nx-RandomFailures' of https://github.com/Maverickwoe…
Maverickwoe Mar 30, 2023
329e8cf
Translation French
Maverickwoe Mar 31, 2023
4830fce
revert removed translation "All"
Maverickwoe Apr 2, 2023
69c4a90
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Apr 2, 2023
a7d520e
fix takeOff arming using old indexes
Maverickwoe Apr 2, 2023
cd68b42
Major rehaul of settings visual
Maverickwoe Apr 3, 2023
9c73556
font size for text only settings
Maverickwoe Apr 3, 2023
4f2bc50
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Apr 3, 2023
32d6c55
Sub section in take-off
Maverickwoe Apr 4, 2023
47069f9
Update fbw-a32nx/src/systems/instruments/src/EFB/Failures/FailureGene…
Maverickwoe Apr 6, 2023
486a8e9
removed setting from FailureGenData
Maverickwoe Apr 7, 2023
f106f0f
replaced GetSimVarValue by useSimVar
Maverickwoe Apr 7, 2023
a7f322b
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Apr 11, 2023
f6abd77
added periods to altitude and gs
Maverickwoe Apr 11, 2023
c637efb
Merge branch 'master' into a32nx-RandomFailures
2hwk Apr 13, 2023
5a2e4f7
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Apr 24, 2023
cf0f0df
fix: No Failure properly displayed
Maverickwoe Apr 24, 2023
84bd966
fix: using wrong index for chance over time
Maverickwoe Apr 24, 2023
247272e
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe May 15, 2023
53362f9
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe May 29, 2023
c941af8
Merge remote-tracking branch 'origin/master' into a32nx-RandomFailures
Saschl Jul 3, 2023
9c1de2a
update imports
Saschl Jul 4, 2023
be181d6
fix: duplicate imports
Maverickwoe Jul 6, 2023
9e03e74
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Jul 6, 2023
41e944a
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Jul 9, 2023
5e219fe
add default dropdown selection
Maverickwoe Jul 14, 2023
987f721
change generator description
Maverickwoe Jul 15, 2023
f4dd6cf
Change prob. during climb to include high speed
Maverickwoe Jul 16, 2023
57d7ad7
simplified info description with URL
Maverickwoe Jul 16, 2023
c314983
Reorg of localization
Maverickwoe Jul 16, 2023
c9bfdee
Typo "its settings"
Maverickwoe Jul 16, 2023
f89552f
fix localization to info title
Maverickwoe Jul 16, 2023
a966455
Max simult failure moved to each gen's settings
Maverickwoe Jul 17, 2023
b7e1ac4
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Jul 17, 2023
6d6cb4c
Less periodicities in the generators
Maverickwoe Jul 21, 2023
e97709b
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Jul 29, 2023
4234215
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Jul 29, 2023
c4c6360
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Aug 2, 2023
1194cf4
fix: speed and alti gen fixed on decrease+TO mode
Maverickwoe Aug 2, 2023
9695590
fix: TakeOff Gen arms below minSpeed instead of 1
Maverickwoe Aug 2, 2023
1ee147c
WIP : Migrate arming and trigger logic to non EFB
Maverickwoe Aug 12, 2023
026a69a
migrated Altitude gen logic oustide EFB
Maverickwoe Aug 27, 2023
da0a6de
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Aug 28, 2023
244c309
Speed failure gen migrated outside EFB
Maverickwoe Aug 28, 2023
3224676
Migration of Timer failure gen outside of EFB
Maverickwoe Aug 28, 2023
119d2a2
Failure over time Gen migrated outside of EFB
Maverickwoe Aug 28, 2023
f9134e4
final migration, Take Off failure gen outside EFB
Maverickwoe Aug 28, 2023
6300147
fix: path for import
Maverickwoe Aug 28, 2023
ae1583a
attempt to solve wrong imports
Maverickwoe Aug 28, 2023
9013871
fix: wrong path from maintenance reminder (EFB)
Maverickwoe Aug 28, 2023
2f12894
-
Maverickwoe Aug 28, 2023
f3b510d
fix: import, Renamed tsx files to tsx
Maverickwoe Aug 28, 2023
59d8302
fix: Using relative paths for imports
Maverickwoe Aug 28, 2023
b41bf63
fix: more incorrect links in maintenance reminders
Maverickwoe Aug 28, 2023
f3083f7
parsemetar change extension name
Maverickwoe Aug 28, 2023
8da0046
revert tsx renaming on parseMetar
Maverickwoe Aug 28, 2023
cfb3672
attempt to fix jest tests
Saschl Sep 5, 2023
90fa5cb
Merge remote-tracking branch 'fbw/master' into a32nx-RandomFailures
Saschl Sep 5, 2023
141f3d7
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Sep 9, 2023
6feccbc
Merge branch 'master' into a32nx-RandomFailures
Saschl Sep 14, 2023
caae8a1
removal of all console.log commented out
Maverickwoe Sep 14, 2023
7845977
Update fbw-a32nx/src/systems/failures/src/AltitudeFailureGenerator.ts
Maverickwoe Sep 16, 2023
594183b
fix changelog format
Maverickwoe Sep 16, 2023
0b1ef28
remove extra lines in setupJestMock
Maverickwoe Sep 16, 2023
8d7ebff
Update package.json
Maverickwoe Sep 16, 2023
f0e4b3d
change failures Flight State Enum format
Maverickwoe Sep 16, 2023
b653fdc
fix formatting for data typing
Maverickwoe Sep 16, 2023
243e0a2
remove commented import
Maverickwoe Sep 16, 2023
b5617bc
change page route to "failure-list"
Maverickwoe Sep 16, 2023
893e043
non-component functions starting with low case
Maverickwoe Sep 16, 2023
c96a8a3
correction of format type annotations in UI
Maverickwoe Sep 16, 2023
f39511f
MttfDisplay acronym to lower case
Maverickwoe Sep 16, 2023
515d39b
remove unuseful type "Any" in failure query
Maverickwoe Sep 16, 2023
68a4c4c
Lambda function formatting
Maverickwoe Sep 16, 2023
ce5c555
Update fbw-a32nx/src/systems/failures/src/AltitudeFailureGenerator.ts
Maverickwoe Sep 16, 2023
45755d5
code formatting
Maverickwoe Sep 16, 2023
23fe3c7
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Sep 16, 2023
b05896a
Merge branch 'a32nx-RandomFailures' of https://github.com/Maverickwoe…
Maverickwoe Sep 16, 2023
ab7b999
renamed didOnce with didInitialize
Maverickwoe Sep 16, 2023
4b1c996
simplification of code
Maverickwoe Sep 16, 2023
9fd42b2
fix: NaN inputs replaced by min input
Maverickwoe Sep 17, 2023
43c6b35
TimedFailure in TakeOff mode starts when rolling
Maverickwoe Sep 17, 2023
cf44e94
timer generator follows same readiness logic
Maverickwoe Sep 17, 2023
9f7b246
Added setting integrity check in generator updates
Maverickwoe Sep 18, 2023
b57c7d4
Applied new arming logic to PerHour gen
Maverickwoe Sep 18, 2023
a1c8d4f
add missing change flag for integrity check
Maverickwoe Sep 18, 2023
f2fb8e1
Add new arming logic to takeoff gen
Maverickwoe Sep 18, 2023
a214381
fix: chance per take off was not properly applied
Maverickwoe Sep 19, 2023
9d5e044
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Sep 19, 2023
cc6c416
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Sep 21, 2023
d84feb5
Fix: setting shift when generator add or del
Maverickwoe Sep 22, 2023
2c7f9a6
Merge branch 'a32nx-RandomFailures' of https://github.com/Maverickwoe…
Maverickwoe Sep 22, 2023
636a651
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Sep 22, 2023
7c3a44c
Refactor failure triggering code for all gen
Maverickwoe Sep 23, 2023
8a2a255
Merge branch 'a32nx-RandomFailures' of https://github.com/Maverickwoe…
Maverickwoe Sep 23, 2023
c6e5cae
WIP Bus Communication Failure-->UI
Maverickwoe Sep 24, 2023
38d51fa
refactor: use a single event bus instance for random failure generato…
Benjozork Sep 24, 2023
3010335
fix bus communication from system to UI
Maverickwoe Sep 24, 2023
f96ea9a
System uses one event interface for all gen
Maverickwoe Sep 25, 2023
f4ca8d8
fix imports to relative paths
Maverickwoe Sep 25, 2023
3bed9cf
replaced simplane with simvar for alt and gs
Maverickwoe Sep 25, 2023
eb97386
Setting Event reworked
Maverickwoe Sep 25, 2023
ac37a43
improvement of UI and system sync
Maverickwoe Sep 27, 2023
41a6e50
refactor: part 1: remove unnecessary context being passed around
Benjozork Sep 28, 2023
588d0f1
refactor: part 2: move functions into components
Benjozork Sep 28, 2023
0c84bf0
refactor: part 2: move functions into components
Benjozork Sep 28, 2023
f7a5e43
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Oct 20, 2023
1b470cc
resynch of branch
Maverickwoe Oct 20, 2023
6bfc416
answer to comments
Maverickwoe Sep 29, 2023
0a8a91d
New bus event for Failure pool
Maverickwoe Oct 20, 2023
ffa7f21
unecessary import
Maverickwoe Oct 20, 2023
b6b75b7
Component at EFB load for 1st setting broadcast
Maverickwoe Oct 21, 2023
a29a954
Filtering of ATA chapters in short list of card
Maverickwoe Oct 21, 2023
a75014f
bitflags imports and double definition
Maverickwoe Oct 21, 2023
15da8ac
removed unecessary broadcasts at page load
Maverickwoe Oct 21, 2023
89d3edc
Merge branch 'master' into a32nx-RandomFailures
tracernz Oct 24, 2023
08b3aad
fix: added settings to dependency array
Saschl Nov 3, 2023
a7523ca
removed duplicate condition
Saschl Nov 3, 2023
e2647e9
UI event subscription refactored
Maverickwoe Nov 3, 2023
d40d623
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Nov 3, 2023
2bf3fe9
attempt to fix test suite
Maverickwoe Nov 3, 2023
c4a754f
enums and intermediate variable for description
Maverickwoe Nov 5, 2023
cc62905
further enum creations on system side
Maverickwoe Nov 5, 2023
6a51dd5
fix: revert env
Saschl Nov 6, 2023
6ef6deb
cleaned up dead code
Maverickwoe Nov 12, 2023
0e2a962
Fixed Altitude min max values behaviour
Maverickwoe Nov 17, 2023
1cfc9f7
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Nov 24, 2023
9e7239b
Renaming EFB files
Maverickwoe Nov 26, 2023
9746dfe
Merge branch 'a32nx-RandomFailures' of https://github.com/Maverickwoe…
Maverickwoe Nov 26, 2023
7e43029
failure selection has 3-state checkboxes
Maverickwoe Nov 26, 2023
b38da31
Improvement of Failure selection UI layout
Maverickwoe Nov 26, 2023
cf9565e
modal window state "currently displayed"
Maverickwoe Nov 26, 2023
8b8315a
test to avoid unecessary hook set
Maverickwoe Nov 26, 2023
b3d7a6f
attempt to improve NaN values
Saschl Nov 27, 2023
ec97b00
Subscription to events happens once now
Maverickwoe Nov 27, 2023
ba27dd5
Merge branch 'a32nx-RandomFailures' of https://github.com/Maverickwoe…
Maverickwoe Nov 27, 2023
91999d7
modal window state "currently displayed"
Maverickwoe Nov 27, 2023
e6874c3
No pop up display if content is null or NaN
Maverickwoe Nov 27, 2023
f7e7f8a
closing modal flushs modal context
Maverickwoe Nov 27, 2023
938dad7
file separation of FailureGenCardTemplate
Maverickwoe Nov 27, 2023
ad5ea94
FailureShortList moved to different file
Maverickwoe Nov 27, 2023
420be86
setting modal now updates when mode OFF
Maverickwoe Nov 27, 2023
14602bf
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Nov 28, 2023
951c631
subscription to events on 'settings' dependency
Maverickwoe Nov 28, 2023
2e34d93
layout of Next button in triggering conditions
Maverickwoe Nov 29, 2023
689e8ad
fix default size of scrollable zone
Maverickwoe Nov 30, 2023
44205da
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Dec 9, 2023
4117ecd
Merge branch 'master' into a32nx-RandomFailures
Maverickwoe Dec 29, 2023
6cfd373
Merge remote-tracking branch 'origin/master' into a32nx-RandomFailures
Saschl May 6, 2024
10306e0
fixes after big merge
Saschl May 6, 2024
4ed7c19
fix: commbus things
Saschl May 6, 2024
a0e7878
fix: lint
Saschl May 6, 2024
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
2 changes: 2 additions & 0 deletions .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@
1. [EFCS] Fix ground spoiler retraction after increasing TLA slightly above 0 - @lukecologne (luke)
1. [FWC] Improved LDG LT memo to take into account light position - @BravoMike99 (bruno_pt99)
1. [PRESS] Add pressurization system failures - @mjuhe (Miquel Juhe)
1. [EFB] Random Failures - @Maverickwoe (Garoomf)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase/merge and move to 0.13.0.



## 0.11.0

Expand Down
9 changes: 8 additions & 1 deletion fbw-a32nx/src/systems/instruments/src/EFB/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ import React from 'react';
import { render } from '@instruments/common/index';
import { EfbWrapper } from '@flybywiresim/flypad';
import { A320FailureDefinitions } from '@failures';
import { EventBusContextProvider } from '../../../../../../fbw-common/src/systems/instruments/src/EFB/event-bus-provider';

// TODO: Move failure definition into VFS
render(<EfbWrapper failures={A320FailureDefinitions} />, true, true);
render(
<EventBusContextProvider>
<EfbWrapper failures={A320FailureDefinitions} />
</EventBusContextProvider>,
true,
true,
);
34 changes: 34 additions & 0 deletions fbw-common/src/jest/setupJestMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@ let values;

global.beforeEach(() => {
values = {};
global.SimVar = {};
// MSFS SDK overrides those with a custom implementation, hence need to recreate it before every test
global.SimVar.GetSimVarValue = jest.fn((name, _, __) => {
// eslint-disable-next-line no-prototype-builtins
if (values.hasOwnProperty(name)) {
return values[name];
} else {
return 0;
}
});

global.SimVar.SetSimVarValue = jest.fn((name, _, value, __) => {
return new Promise((resolve, _) => {
values[name] = value;
resolve();
});
});

values = {};
});

global.SimVar = {};
Expand All @@ -18,3 +37,18 @@ global.SimVar.SetSimVarValue = jest.fn(
resolve();
}),
);
global.RunwayDesignator = jest.mock();
global.Avionics = jest.mock();
global.Avionics = jest.mock();
global.Simplane = jest.mock();
global.Simplane.getIsGrounded = jest.fn();
global.Simplane.getEngineThrottleMode = jest.fn();
global.ThrottleMode = jest.mock();
global.Simplane.getAltitude = jest.fn();
global.Simplane.getGroundSpeed = jest.fn();

global.Avionics.Utils = jest.mock();
global.document = jest.mock();
global.document.getElementById = jest.fn();
global.GetStoredData = jest.fn(() => 'hi');
global.BaseInstrument = jest.fn();
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,15 @@ const ActiveFailureCard: FC<ActiveFailureCardProps> = ({ ata, name }) => {
onClick={() => {
dispatch(setSearchQuery(name.toUpperCase()));

const lastFailurePath = findLatestSeenPathname(history, '/failures');

const lastFailurePath = findLatestSeenPathname(history, '/failures/failure-list');
if (!ata) {
history.push('/failures/compact');
history.push('/failures/failure-list/compact');
}

if (!lastFailurePath || lastFailurePath.includes('comfort')) {
history.push(`/failures/comfort/${ata}`);
history.push(`/failures/failure-list/comfort/${ata}`);
} else {
history.push('/failures/compact');
history.push('/failures/failure-list/compact');
}
}}
>
Expand All @@ -51,7 +50,10 @@ export const MaintenanceReminder = () => {
const { allFailures, activeFailures } = useFailuresOrchestrator();

return (
<RemindersSection title={t('Dashboard.ImportantInformation.Maintenance.Title')} pageLinkPath="/failures">
<RemindersSection
title={t('Dashboard.ImportantInformation.Maintenance.Title')}
pageLinkPath="/failures/failure-list"
>
<div className="flex flex-row flex-wrap">
{Array.from(activeFailures)
// Sorts the failures by name length, greatest to least
Expand Down
11 changes: 8 additions & 3 deletions fbw-common/src/systems/instruments/src/EFB/Efb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import { Performance } from './Performance/Performance';
import { Navigation } from './Navigation/Navigation';
import { ATC } from './ATC/ATC';
import { Settings } from './Settings/Settings';
import { Failures } from './Failures/Failures';
import { FailuresHome } from './Failures/Failures';
import { Presets } from './Presets/Presets';
import { clearEfbState, store, useAppDispatch, useAppSelector } from './Store/store';
import { setFlightPlanProgress } from './Store/features/flightProgress';
Expand All @@ -62,6 +62,7 @@ import './Assets/Slider.scss';

import 'react-toastify/dist/ReactToastify.css';
import './toast.css';
import { FailureGeneratorsInit } from 'instruments/src/EFB/Failures/FailureGenerators/EFBFailureGeneratorsInit';

export interface EfbWrapperProps {
failures: FailureDefinition[]; // TODO: Move failure definition into VFS
Expand Down Expand Up @@ -404,7 +405,11 @@ export const Efb: React.FC<EfbProps> = ({ aircraftChecklistsProp }) => {
switch (powerState) {
case PowerStates.SHUTOFF:
case PowerStates.STANDBY:
return <div className="h-screen w-screen" onClick={offToLoaded} />;
return (
<div className="h-screen w-screen" onClick={offToLoaded}>
<FailureGeneratorsInit />
</div>
);
case PowerStates.LOADING:
case PowerStates.SHUTDOWN:
return <LoadingScreen />;
Expand Down Expand Up @@ -436,7 +441,7 @@ export const Efb: React.FC<EfbProps> = ({ aircraftChecklistsProp }) => {
<Route path="/performance" component={Performance} />
<Route path="/navigation" component={Navigation} />
<Route path="/atc" component={ATC} />
<Route path="/failures" component={Failures} />
<Route path="/failures" component={FailuresHome} />
<Route path="/checklists" component={Checklists} />
<Route path="/presets" component={Presets} />
<Route path="/settings" component={Settings} />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
// Copyright (c) 2021-2023 FlyByWire Simulations
//
// SPDX-License-Identifier: GPL-3.0

import { usePersistentProperty } from '@flybywiresim/fbw-sdk';

import React, { useMemo, useState } from 'react';
import {
FailureGenContext,
FailureGenData,
FailureGenMode,
ModalContext,
setNewSetting,
} from 'instruments/src/EFB/Failures/FailureGenerators/EFBRandomFailureGen';

import { ArrowDownRight, ArrowUpRight } from 'react-bootstrap-icons';
import {
ButtonIcon,
FailureGeneratorChoiceSetting,
FailureGeneratorSingleSetting,
} from 'instruments/src/EFB/Failures/FailureGenerators/EFBFailureGeneratorSettingsUI';
import { t } from '@flybywiresim/flypad';

enum Direction {
Climb = 0,
Descent = 1,
}

const settingName = 'EFB_FAILURE_GENERATOR_SETTING_ALTITUDE';
const defaultNumberOfFailuresAtOnce = 1;
const defaultMaxNumberOfFailures = 2;
const defaultMinAltitudeHundredsFeet = 80;
const defaultMaxAltitudeHundredsFeet = 250;
const additionalSetting = [
FailureGenMode.FailureGenTakeOff,
defaultNumberOfFailuresAtOnce,
defaultMaxNumberOfFailures,
Direction.Climb,
defaultMinAltitudeHundredsFeet,
defaultMaxAltitudeHundredsFeet,
];
const numberOfSettingsPerGenerator = 6;
const uniqueGenPrefix = 'A';
const genName = 'Altitude';
const alias = () => t('Failures.Generators.GenAlt');
const disableTakeOffRearm = false;

const AltitudeConditionIndex = 3;
const AltitudeMinIndex = 4;
const AltitudeMaxIndex = 5;

export const failureGenConfigAltitude: () => FailureGenData = () => {
const [setting, setSetting] = usePersistentProperty(settingName);
const [armedState, setArmedState] = useState<boolean[]>();
const settings = useMemo(() => {
const splitString = setting?.split(',');
if (splitString) return splitString.map((it: string) => parseFloat(it));
return [];
}, [setting]);

return {
setSetting,
settings,
setting,
numberOfSettingsPerGenerator,
uniqueGenPrefix,
additionalSetting,
genName,
alias,
disableTakeOffRearm,
generatorSettingComponents,
armedState,
setArmedState,
};
};

const generatorSettingComponents = (
genNumber: number,
modalContext: ModalContext,
failureGenContext: FailureGenContext,
) => {
const settings = modalContext.failureGenData.settings;
const settingTable = [
<FailureGeneratorChoiceSetting
title={t('Failures.Generators.AltitudeCondition')}
failureGenContext={failureGenContext}
generatorSettings={modalContext.failureGenData}
multiChoice={climbDescentMode}
setNewSetting={setNewSetting}
genIndex={genNumber}
settingIndex={AltitudeConditionIndex}
value={settings[genNumber * numberOfSettingsPerGenerator + AltitudeConditionIndex]}
/>,
<FailureGeneratorSingleSetting
title={t('Failures.Generators.AltitudeMin')}
unit={t('Failures.Generators.feet')}
min={0}
max={settings[genNumber * numberOfSettingsPerGenerator + AltitudeMaxIndex] * 100}
value={settings[genNumber * numberOfSettingsPerGenerator + AltitudeMinIndex]}
mult={100}
setNewSetting={setNewSetting}
generatorSettings={modalContext.failureGenData}
genIndex={genNumber}
settingIndex={AltitudeMinIndex}
failureGenContext={failureGenContext}
/>,
<FailureGeneratorSingleSetting
title={t('Failures.Generators.AltitudeMax')}
unit={t('Failures.Generators.feet')}
min={settings[genNumber * numberOfSettingsPerGenerator + AltitudeMinIndex] * 100}
max={40000}
value={settings[genNumber * numberOfSettingsPerGenerator + AltitudeMaxIndex]}
mult={100}
setNewSetting={setNewSetting}
generatorSettings={modalContext.failureGenData}
genIndex={genNumber}
settingIndex={AltitudeMaxIndex}
failureGenContext={failureGenContext}
/>,
];
return settingTable;
};

const climbDescentMode: ButtonIcon[] = [
{
icon: (
<>
<ArrowUpRight />
</>
),
settingVar: 0,
setting: 'Climb',
},
{
icon: (
<>
<ArrowDownRight />
</>
),
settingVar: 1,
setting: 'Descent',
},
];
Loading
Loading