From ba312ba10030c69291c8300cf35a58139a328b71 Mon Sep 17 00:00:00 2001 From: Frank Kopp Date: Wed, 16 Mar 2022 02:31:35 +0100 Subject: [PATCH] Fixed progress value and progress bar. --- .../EFB/Presets/Widgets/AircraftPresets.tsx | 32 ++++++++++--------- src/presets/src/Aircraft/AircraftPreset.cpp | 6 ++-- src/presets/src/Aircraft/AircraftPreset.h | 4 +-- src/presets/src/Aircraft/AircraftProcedures.h | 11 +++++-- 4 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/instruments/src/EFB/Presets/Widgets/AircraftPresets.tsx b/src/instruments/src/EFB/Presets/Widgets/AircraftPresets.tsx index 304c7cd2b12c..ba1c622a5ece 100644 --- a/src/instruments/src/EFB/Presets/Widgets/AircraftPresets.tsx +++ b/src/instruments/src/EFB/Presets/Widgets/AircraftPresets.tsx @@ -21,16 +21,11 @@ export const AircraftPresets = () => { const [loadPresetProgress] = useSimVar('L:A32NX_LOAD_AIRCRAFT_PRESET_PROGRESS', 'number', 100); // Sets the LVAR to tell the wasm to load the preset into the aircraft - function loadPreset(presetID: number, presetName: string) { + function loadPreset(presetID: number) { setLoadPresetVar(presetID); - toast.success(`Loading Preset: ${presetID}: ${presetName}`, { - autoClose: 250, - hideProgressBar: true, - closeButton: false, - }); } - const AIRCRAFT_PRESETS: {index: number, name: string}[] = [ + const AIRCRAFT_PRESETS: { index: number, name: string }[] = [ { index: 1, name: 'Cold & Dark' }, { index: 2, name: 'Turnaround' }, { index: 3, name: 'Ready for Pushback' }, @@ -39,16 +34,23 @@ export const AircraftPresets = () => { ]; return ( -
-
- { loadPresetVar ? ( +
+
+ {loadPresetVar ? ( <> -
-
+
+
setLoadPresetVar(0)} > Cancel @@ -64,9 +66,9 @@ export const AircraftPresets = () => { {AIRCRAFT_PRESETS.map(({ index, name }) => (
loadPreset(index, name)} + onClick={() => loadPreset(index)} > - { name } + {name}
))}
diff --git a/src/presets/src/Aircraft/AircraftPreset.cpp b/src/presets/src/Aircraft/AircraftPreset.cpp index 72caf6cb653c..6d9a55c0ecae 100644 --- a/src/presets/src/Aircraft/AircraftPreset.cpp +++ b/src/presets/src/Aircraft/AircraftPreset.cpp @@ -37,7 +37,7 @@ void AircraftPreset::onUpdate(double deltaTime) { // new loading process std::cout << "PRESETS: Aircraft Preset Start" << std::endl; - setProgressAircraftPreset(0); + setProgressAircraftPreset(0.0); currentLoadingTime = 0; currentDelay = 0; currentStep = 0; @@ -48,14 +48,14 @@ void AircraftPreset::onUpdate(double deltaTime) { // check if all preset steps are done if (currentStep >= currentProcedure->size()) { std::cout << "PRESETS: Aircraft Preset Done " << std::endl; - setProgressAircraftPreset(100); + setProgressAircraftPreset(0); setLoadAircraftPresetRequest(0); loadingIsActive = false; return; } // progress - setProgressAircraftPreset(((double) currentStep / currentProcedure->size()) * 100); + setProgressAircraftPreset((double) currentStep / currentProcedure->size()); // update run timer currentLoadingTime += deltaTime * 1000; diff --git a/src/presets/src/Aircraft/AircraftPreset.h b/src/presets/src/Aircraft/AircraftPreset.h index f60dd5ed82f5..4e6eb9c4d501 100644 --- a/src/presets/src/Aircraft/AircraftPreset.h +++ b/src/presets/src/Aircraft/AircraftPreset.h @@ -91,7 +91,7 @@ class AircraftPreset { * Reads the preset loading request variable. * @return INT64 signifying the preset to be loaded */ - INT64 + FLOAT64 progressAircraftPreset() { return get_named_variable_value(ProgressAircraftPreset); } /** @@ -99,5 +99,5 @@ class AircraftPreset { * @param value usually loadFromData to 0 to reset the request. */ void setProgressAircraftPreset( - INT64 value) { set_named_variable_value(ProgressAircraftPreset, value); } + FLOAT64 value) { set_named_variable_value(ProgressAircraftPreset, value); } }; diff --git a/src/presets/src/Aircraft/AircraftProcedures.h b/src/presets/src/Aircraft/AircraftProcedures.h index 276490c7e83c..9d05c35d2316 100644 --- a/src/presets/src/Aircraft/AircraftProcedures.h +++ b/src/presets/src/Aircraft/AircraftProcedures.h @@ -19,9 +19,14 @@ static vector* TURNAROUND_CONFIG_ON = new vector{ {"BAT1 On", false, 0, 100, "(L:A32NX_OVHD_ELEC_BAT_1_PB_IS_AUTO) 1 ==", "1 (>L:A32NX_OVHD_ELEC_BAT_1_PB_IS_AUTO)"}, {"BAT2 On", false, 0, 3000, "(L:A32NX_OVHD_ELEC_BAT_2_PB_IS_AUTO) 1 ==", "1 (>L:A32NX_OVHD_ELEC_BAT_2_PB_IS_AUTO)"}, {"EXT PWR ON", false, 0, 3000, "(L:A32NX_ELEC_AC_1_BUS_IS_POWERED)", "(A:EXTERNAL POWER ON:1, BOOL) ! if{ 1 (>K:TOGGLE_EXTERNAL_POWER) }"}, - {"APU Master On", false, 0, 3000, "(L:A32NX_OVHD_APU_MASTER_SW_PB_IS_ON) 1 ==", "1 (>L:A32NX_OVHD_APU_MASTER_SW_PB_IS_ON)"}, - {"APU Start On", false, 0, 1000, "(L:A32NX_OVHD_APU_START_PB_IS_AVAILABLE) 1 == " - "(L:A32NX_OVHD_APU_START_PB_IS_ON) 1 == or", "1 (>L:A32NX_OVHD_APU_START_PB_IS_ON)"}, + {"APU Master On", false, 0, 3000, "((L:A32NX_ENGINE_STATE:2) 1 ==" + "(L:A32NX_ENGINE_STATE:2) 1 == or) " + "(L:A32NX_OVHD_APU_MASTER_SW_PB_IS_ON) 1 == or", "1 (>L:A32NX_OVHD_APU_MASTER_SW_PB_IS_ON)"}, + // FIXME: The expected state check does not work correctly. + {"APU Start On", false, 0, 1000, "((L:A32NX_ENGINE_STATE:2) 1 == " + "(L:A32NX_ENGINE_STATE:2) 1 == or)" + "((L:A32NX_OVHD_APU_START_PB_IS_AVAILABLE) 1 == " + "(L:A32NX_OVHD_APU_START_PB_IS_ON) 1 == or) or", "1 (>L:A32NX_OVHD_APU_START_PB_IS_ON)"}, {"AC BUS Avail Check", true, 1, 2000, "", "(L:A32NX_ELEC_AC_1_BUS_IS_POWERED)"}, {"Nav & Logo Lt On", false, 0, 1000, "(A:LIGHT LOGO, Bool) (A:LIGHT NAV, Bool) and", "1 (>K:2:LOGO_LIGHTS_SET) 1 (>K:2:NAV_LIGHTS_SET)"},