From 15da8ac5fb4c3da7f03242e41ee35f28836dd48e Mon Sep 17 00:00:00 2001 From: Maverickwoe Date: Sat, 21 Oct 2023 15:46:58 +0200 Subject: [PATCH] removed unecessary broadcasts at page load new debug --- .../FailureGenerators/PerHourFailureGeneratorUI.tsx | 3 +-- .../FailureGenerators/RandomFailureGenEFB.tsx | 1 + .../FailureGenerators/SpeedFailureGeneratorUI.tsx | 3 +-- .../FailureGenerators/TakeOffFailureGeneratorUI.tsx | 5 ++--- .../FailureGenerators/TimerFailureGeneratorUI.tsx | 12 ++++++++---- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/fbw-a32nx/src/systems/instruments/src/EFB/Failures/FailureGenerators/PerHourFailureGeneratorUI.tsx b/fbw-a32nx/src/systems/instruments/src/EFB/Failures/FailureGenerators/PerHourFailureGeneratorUI.tsx index 96f6aadaacd..e9e3b0e250f 100644 --- a/fbw-a32nx/src/systems/instruments/src/EFB/Failures/FailureGenerators/PerHourFailureGeneratorUI.tsx +++ b/fbw-a32nx/src/systems/instruments/src/EFB/Failures/FailureGenerators/PerHourFailureGeneratorUI.tsx @@ -7,7 +7,7 @@ import { usePersistentProperty } from '@flybywiresim/fbw-sdk'; import React, { useEffect, useMemo, useState } from 'react'; import { FailureGenContext, FailureGenData, FailureGenFeedbackEvent, sendRefresh, - sendSettings, setNewSetting, updateSettings, + setNewSetting, updateSettings, } from 'instruments/src/EFB/Failures/FailureGenerators/RandomFailureGenEFB'; import { t } from 'instruments/src/EFB/translation'; import { FailureGeneratorSingleSetting, FailureGeneratorText } from 'instruments/src/EFB/Failures/FailureGenerators/FailureGeneratorSettingsUI'; @@ -57,7 +57,6 @@ export const failureGenConfigPerHour: () => FailureGenData = () => { // console.info('received arming states'); } }); - sendSettings(uniqueGenPrefix, setting, bus); sendRefresh(bus); return () => { sub1.destroy(); diff --git a/fbw-a32nx/src/systems/instruments/src/EFB/Failures/FailureGenerators/RandomFailureGenEFB.tsx b/fbw-a32nx/src/systems/instruments/src/EFB/Failures/FailureGenerators/RandomFailureGenEFB.tsx index 7f6dba98256..d2077f1bee4 100644 --- a/fbw-a32nx/src/systems/instruments/src/EFB/Failures/FailureGenerators/RandomFailureGenEFB.tsx +++ b/fbw-a32nx/src/systems/instruments/src/EFB/Failures/FailureGenerators/RandomFailureGenEFB.tsx @@ -138,6 +138,7 @@ export const updateSettings: (settings: number[], setSetting: (value: string) => => void = (settings: number[], setSetting: (value: string) => void, bus: EventBus, uniqueGenPrefix: string) => { const flattenedData = flatten(settings); sendSettings(uniqueGenPrefix, flattenedData, bus); + console.info(`new permanent setting:${flattenedData}`); setSetting(flattenedData); }; diff --git a/fbw-a32nx/src/systems/instruments/src/EFB/Failures/FailureGenerators/SpeedFailureGeneratorUI.tsx b/fbw-a32nx/src/systems/instruments/src/EFB/Failures/FailureGenerators/SpeedFailureGeneratorUI.tsx index 5e0653f3769..931a9a9b237 100644 --- a/fbw-a32nx/src/systems/instruments/src/EFB/Failures/FailureGenerators/SpeedFailureGeneratorUI.tsx +++ b/fbw-a32nx/src/systems/instruments/src/EFB/Failures/FailureGenerators/SpeedFailureGeneratorUI.tsx @@ -7,7 +7,7 @@ import { usePersistentProperty } from '@flybywiresim/fbw-sdk'; import React, { useEffect, useMemo, useState } from 'react'; import { FailureGenContext, FailureGenData, FailureGenFeedbackEvent, sendRefresh, - sendSettings, setNewSetting, updateSettings, + setNewSetting, updateSettings, } from 'instruments/src/EFB/Failures/FailureGenerators/RandomFailureGenEFB'; import { t } from 'instruments/src/EFB/translation'; import { ArrowDownRight, ArrowUpRight } from 'react-bootstrap-icons'; @@ -61,7 +61,6 @@ export const failureGenConfigSpeed: () => FailureGenData = () => { // console.info('received arming states'); } }); - sendSettings(uniqueGenPrefix, setting, bus); sendRefresh(bus); return () => { sub1.destroy(); diff --git a/fbw-a32nx/src/systems/instruments/src/EFB/Failures/FailureGenerators/TakeOffFailureGeneratorUI.tsx b/fbw-a32nx/src/systems/instruments/src/EFB/Failures/FailureGenerators/TakeOffFailureGeneratorUI.tsx index ebd45a9401e..566245e01b2 100644 --- a/fbw-a32nx/src/systems/instruments/src/EFB/Failures/FailureGenerators/TakeOffFailureGeneratorUI.tsx +++ b/fbw-a32nx/src/systems/instruments/src/EFB/Failures/FailureGenerators/TakeOffFailureGeneratorUI.tsx @@ -7,7 +7,7 @@ import { usePersistentProperty } from '@flybywiresim/fbw-sdk'; import React, { useEffect, useMemo, useState } from 'react'; import { FailureGenContext, FailureGenData, FailureGenFeedbackEvent, sendRefresh, - sendSettings, setNewSetting, updateSettings, + setNewSetting, updateSettings, } from 'instruments/src/EFB/Failures/FailureGenerators/RandomFailureGenEFB'; import { t } from 'instruments/src/EFB/translation'; import { FailureGeneratorSingleSetting, FailureGeneratorText } from 'instruments/src/EFB/Failures/FailureGenerators/FailureGeneratorSettingsUI'; @@ -64,7 +64,6 @@ export const failureGenConfigTakeOff: () => FailureGenData = () => { // console.info('received arming states'); } }); - sendSettings(uniqueGenPrefix, setting, bus); sendRefresh(bus); return () => { sub1.destroy(); @@ -107,7 +106,7 @@ const generatorSettingComponents = (genNumber: number, generatorSettings: Failur failureGenContext={failureGenContext} />, ( -
+
FailureGenData = () => { const [armedState, setArmedState] = useState(); const settings = useMemo(() => { const splitString = setting?.split(','); - if (splitString) return splitString.map(((it: string) => parseFloat(it))); + if (splitString) { + const newSettings = splitString.map(((it: string) => parseFloat(it))); + console.info(`TIM update of setting array:${newSettings.toString()}`); + return newSettings; + } return []; }, [setting]); @@ -42,9 +46,10 @@ export const failureGenConfigTimer: () => FailureGenData = () => { console.info(`TIM expectedMode received: ${generatorType} - ${mode.toString()}`); const nbGenerator = Math.floor(settings.length / numberOfSettingsPerGenerator); let changeNeeded = false; - for (let i = 0; i < nbGenerator; i++) { + for (let i = 0; i < nbGenerator && i < mode?.length; i++) { if (settings[i * numberOfSettingsPerGenerator + ArmingModeIndex] !== -1) { if (i < mode?.length && mode[i] === 0) { + console.info(`TIM gen ${i.toString()} switched off`); settings[i * numberOfSettingsPerGenerator + ArmingModeIndex] = 0; changeNeeded = true; } @@ -63,7 +68,6 @@ export const failureGenConfigTimer: () => FailureGenData = () => { // console.info('received arming states'); } }); - sendSettings(uniqueGenPrefix, setting, bus); sendRefresh(bus); return () => { sub1.destroy();