Skip to content

Commit

Permalink
removed unecessary broadcasts at page load
Browse files Browse the repository at this point in the history
new debug
  • Loading branch information
Maverickwoe committed Oct 21, 2023
1 parent a75014f commit 15da8ac
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -57,7 +57,6 @@ export const failureGenConfigPerHour: () => FailureGenData = () => {
// console.info('received arming states');
}
});
sendSettings(uniqueGenPrefix, setting, bus);
sendRefresh(bus);
return () => {
sub1.destroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -61,7 +61,6 @@ export const failureGenConfigSpeed: () => FailureGenData = () => {
// console.info('received arming states');
}
});
sendSettings(uniqueGenPrefix, setting, bus);
sendRefresh(bus);
return () => {
sub1.destroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -64,7 +64,6 @@ export const failureGenConfigTakeOff: () => FailureGenData = () => {
// console.info('received arming states');
}
});
sendSettings(uniqueGenPrefix, setting, bus);
sendRefresh(bus);
return () => {
sub1.destroy();
Expand Down Expand Up @@ -107,7 +106,7 @@ const generatorSettingComponents = (genNumber: number, generatorSettings: Failur
failureGenContext={failureGenContext}
/>,
(
<div className="pl-10 w-full divide-y-2 divide-theme-accent">
<div className="divide-theme-accent w-full divide-y-2 pl-10">
<FailureGeneratorText title={`${t('Failures.Generators.SplitOverPhases')}:`} unit="" text="" />
<FailureGeneratorSingleSetting
title={t('Failures.Generators.LowSpeedChance')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
sendRefresh, setNewSetting, updateSettings,
} from 'instruments/src/EFB/Failures/FailureGenerators/RandomFailureGenEFB';
import { t } from 'instruments/src/EFB/translation';
import { FailureGeneratorSingleSetting } from 'instruments/src/EFB/Failures/FailureGenerators/FailureGeneratorSettingsUI';
Expand All @@ -32,7 +32,11 @@ export const failureGenConfigTimer: () => FailureGenData = () => {
const [armedState, setArmedState] = useState<boolean[]>();
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]);

Expand All @@ -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;
}
Expand All @@ -63,7 +68,6 @@ export const failureGenConfigTimer: () => FailureGenData = () => {
// console.info('received arming states');
}
});
sendSettings(uniqueGenPrefix, setting, bus);
sendRefresh(bus);
return () => {
sub1.destroy();
Expand Down

0 comments on commit 15da8ac

Please sign in to comment.