From 2bb6230645cd3b69035a5e82a7a2fa0be5b492a4 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Fri, 28 Oct 2022 14:00:06 +0200 Subject: [PATCH 01/39] first proto --- src/systems/a320_systems/src/hydraulic/mod.rs | 20 +- src/systems/systems/src/hydraulic/mod.rs | 191 +++++++++++++++++- src/systems/systems/src/hydraulic/pumps.rs | 15 +- .../systems/src/shared/low_pass_filter.rs | 4 + 4 files changed, 213 insertions(+), 17 deletions(-) diff --git a/src/systems/a320_systems/src/hydraulic/mod.rs b/src/systems/a320_systems/src/hydraulic/mod.rs index e87e745ede4..745cb04773d 100644 --- a/src/systems/a320_systems/src/hydraulic/mod.rs +++ b/src/systems/a320_systems/src/hydraulic/mod.rs @@ -41,10 +41,10 @@ use systems::{ ManualPitchTrimController, PitchTrimActuatorController, TrimmableHorizontalStabilizerAssembly, }, - ElectricPump, EngineDrivenPump, HydraulicCircuit, HydraulicCircuitController, - HydraulicPressureSensors, PowerTransferUnit, PowerTransferUnitCharacteristics, - PowerTransferUnitController, PressureSwitch, PressureSwitchType, PumpController, - RamAirTurbine, RamAirTurbineController, Reservoir, + ElectricPump, EngineDrivenPump, HeatingElement, HydraulicCircuit, + HydraulicCircuitController, HydraulicPressureSensors, PowerTransferUnit, + PowerTransferUnitCharacteristics, PowerTransferUnitController, PressureSwitch, + PressureSwitchType, PumpController, RamAirTurbine, RamAirTurbineController, Reservoir, }, landing_gear::{GearSystemSensors, LandingGearControlInterfaceUnitSet}, overhead::{ @@ -1746,6 +1746,7 @@ impl A320Hydraulic { self.power_transfer_unit_controller .has_air_pressure_low_fault() || self.power_transfer_unit_controller.has_low_level_fault() + || self.power_transfer_unit_controller.has_overheat_fault() } fn green_edp_has_fault(&self) -> bool { @@ -2188,7 +2189,9 @@ impl A320Hydraulic { lgciu2, self.green_circuit.reservoir(), self.yellow_circuit.reservoir(), + &self.power_transfer_unit, ); + self.power_transfer_unit.update( context, self.green_circuit.system_section(), @@ -3110,6 +3113,7 @@ struct A320PowerTransferUnitController { has_air_pressure_low_fault: bool, has_low_level_fault: bool, + has_overheat_fault: bool, } impl A320PowerTransferUnitController { const DURATION_OF_PTU_INHIBIT_AFTER_CARGO_DOOR_OPERATION: Duration = Duration::from_secs(40); @@ -3135,6 +3139,7 @@ impl A320PowerTransferUnitController { has_air_pressure_low_fault: false, has_low_level_fault: false, + has_overheat_fault: false, } } @@ -3148,6 +3153,7 @@ impl A320PowerTransferUnitController { lgciu2: &impl LgciuInterface, reservoir_left_side: &Reservoir, reservoir_right_side: &Reservoir, + ptu: &impl HeatingElement, ) { self.should_inhibit_ptu_after_cargo_door_operation.update( context, @@ -3172,6 +3178,8 @@ impl A320PowerTransferUnitController { self.update_low_air_pressure(reservoir_left_side, reservoir_right_side, overhead_panel); self.update_low_level(reservoir_left_side, reservoir_right_side, overhead_panel); + + self.has_overheat_fault = ptu.is_overheating(); } fn update_low_air_pressure( @@ -3203,6 +3211,10 @@ impl A320PowerTransferUnitController { fn has_low_level_fault(&self) -> bool { self.has_low_level_fault } + + fn has_overheat_fault(&self) -> bool { + self.has_overheat_fault + } } impl PowerTransferUnitController for A320PowerTransferUnitController { fn should_enable(&self) -> bool { diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index ff4356ea8fc..10c3b8d7ac7 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -74,15 +74,36 @@ pub trait PressureSource { pub struct Fluid { current_bulk: Pressure, + heat_state: HeatingProperties, } impl Fluid { pub fn new(bulk: Pressure) -> Self { - Self { current_bulk: bulk } + Self { + current_bulk: bulk, + heat_state: HeatingProperties::new( + Duration::from_secs_f64(0.5 * 60.), + Duration::from_secs_f64(3. * 60.), + Duration::from_secs_f64(3. * 60.), + ), + } } pub fn bulk_mod(&self) -> Pressure { self.current_bulk } + + fn update(&mut self, context: &UpdateContext, is_heating: bool) { + self.heat_state.update(context, is_heating); + } +} +impl HeatingElement for Fluid { + fn is_overheating(&self) -> bool { + self.heat_state.is_overheating() + } + + fn is_damaged(&self) -> bool { + self.heat_state.is_damaged() + } } #[derive(PartialEq, Clone, Copy)] @@ -173,6 +194,60 @@ impl LevelSwitch { } } +pub trait HeatingElement { + fn is_overheating(&self) -> bool; + fn is_damaged(&self) -> bool; +} + +struct HeatingProperties { + is_overheating: bool, + is_damaged_by_heat: bool, + + damaging_time: DelayedTrueLogicGate, + + heat_factor: LowPassFilter, + heat_time: Duration, + cool_time: Duration, +} +impl HeatingProperties { + fn new(heat_time: Duration, cool_time: Duration, damage_time: Duration) -> Self { + Self { + is_overheating: false, + is_damaged_by_heat: false, + damaging_time: DelayedTrueLogicGate::new(damage_time), + heat_factor: LowPassFilter::new(heat_time), + heat_time, + cool_time, + } + } + + fn update(&mut self, context: &UpdateContext, is_heating: bool) { + if is_heating { + self.heat_factor.set_time_constant(self.heat_time); + self.heat_factor + .update(context.delta(), Ratio::new::(1.)); + } else { + self.heat_factor.set_time_constant(self.cool_time); + self.heat_factor + .update(context.delta(), Ratio::new::(0.)); + }; + + self.is_overheating = self.heat_factor.output().get::() > 0.5; + + self.damaging_time.update(context, self.is_overheating); + self.is_damaged_by_heat = self.is_damaged_by_heat || self.damaging_time.output(); + } +} +impl HeatingElement for HeatingProperties { + fn is_overheating(&self) -> bool { + self.is_overheating + } + + fn is_damaged(&self) -> bool { + self.is_damaged_by_heat + } +} + pub trait PowerTransferUnitController { fn should_enable(&self) -> bool; } @@ -223,6 +298,8 @@ pub struct PowerTransferUnit { has_stopped_since_last_write: bool, efficiency: Ratio, + + heat_state: HeatingProperties, } impl PowerTransferUnit { const MIN_SPEED_SIMULATION_RPM: f64 = 50.; @@ -303,6 +380,12 @@ impl PowerTransferUnit { has_stopped_since_last_write: false, efficiency: characteristics.efficiency(), + + heat_state: HeatingProperties::new( + Duration::from_secs_f64(1. * 60.), + Duration::from_secs_f64(3. * 60.), + Duration::from_secs_f64(5. * 60.), + ), } } @@ -337,6 +420,18 @@ impl PowerTransferUnit { self.update_continuous_state(context); self.capture_bark_strength(); self.update_flows(); + + self.heat_state.update( + context, + self.shaft_speed.get::() > 2000., + ); + + println!( + "PTU SPEED {:.0} PTU HEAT FACTOR {:.2} PTU DAMAGED {:?}", + self.shaft_speed.get::(), + self.heat_state.heat_factor.output().get::(), + self.heat_state.is_damaged(), + ); } fn update_displacement( @@ -431,12 +526,16 @@ impl PowerTransferUnit { let left_side_torque = -Self::calc_generated_torque(left_pressure, self.left_displacement); let right_side_torque = Self::calc_generated_torque(right_pressure, self.right_displacement.output()); + let friction_torque = Torque::new::( Self::SHAFT_FRICTION * -self.shaft_speed.get::(), ); + let total_torque = friction_torque + left_side_torque + right_side_torque; - if self.is_rotating() || total_torque.abs().get::() > Self::BREAKOUT_TORQUE_NM + if !self.heat_state.is_damaged() + && (self.is_rotating() + || total_torque.abs().get::() > Self::BREAKOUT_TORQUE_NM) { let acc = total_torque.get::() / Self::SHAFT_INERTIA; self.shaft_speed += @@ -593,6 +692,15 @@ impl SimulationElement for PowerTransferUnit { self.has_stopped_since_last_write = false; } } +impl HeatingElement for PowerTransferUnit { + fn is_overheating(&self) -> bool { + self.heat_state.is_overheating() + } + + fn is_damaged(&self) -> bool { + self.heat_state.is_damaged() + } +} pub trait HydraulicCircuitController { fn should_open_fire_shutoff_valve(&self, pump_index: usize) -> bool; @@ -729,6 +837,8 @@ pub struct HydraulicCircuit { system_section: Section, auxiliary_section: Option
, + id: HydraulicColor, + pump_sections_check_valves: Vec, // True routed to auxiliary False routed to system section @@ -873,7 +983,7 @@ impl HydraulicCircuit { } else { None }, - + id, pump_sections_check_valves: pump_to_system_check_valves, pump_section_routed_to_auxiliary_section: pump_section_to_auxiliary, fluid: Fluid::new(Pressure::new::(Self::FLUID_BULK_MODULUS_PASCAL)), @@ -908,7 +1018,29 @@ impl HydraulicCircuit { controller: &impl HydraulicCircuitController, reservoir_pressure: Pressure, ) { - self.reservoir.update(context, reservoir_pressure); + let mut ptu_overheats_fluid = false; + if let Some(ptu) = ptu.as_ref() { + if ptu.is_overheating() && ptu.is_rotating() { + ptu_overheats_fluid = true; + } + } + self.fluid.update(context, ptu_overheats_fluid); + + self.reservoir + .update(context, reservoir_pressure, &self.fluid); + + println!( + "LOOP {:?}, PTU OH {:?} FLUID ratio {:?} RES ratio {:?} Res flow gps{:.3}", + self.id, + ptu_overheats_fluid, + self.fluid.heat_state.heat_factor.output().get::(), + self.reservoir + .heat_state + .heat_factor + .output() + .get::(), + self.reservoir.total_return_flow.get::() + ); self.update_shutoff_valves(controller); self.update_leak_measurement_valves(context, controller); @@ -1950,6 +2082,11 @@ pub struct Reservoir { return_failure: Failure, fluid_physics: FluidPhysics, + + heat_state: HeatingProperties, + + total_return_flow: VolumeRate, + total_return_volume: Volume, } impl Reservoir { const MIN_USABLE_VOLUME_GAL: f64 = 0.2; @@ -1985,12 +2122,28 @@ impl Reservoir { air_pressure_switches, level_switch: LevelSwitch::new(low_level_threshold), fluid_physics: FluidPhysics::new(), + + heat_state: HeatingProperties::new( + Duration::from_secs_f64(0.5 * 60.), + Duration::from_secs_f64(3. * 60.), + Duration::from_secs_f64(5. * 60.), + ), + total_return_flow: VolumeRate::default(), + total_return_volume: Volume::default(), } } - fn update(&mut self, context: &UpdateContext, air_pressure: Pressure) { + fn update( + &mut self, + context: &UpdateContext, + air_pressure: Pressure, + fluid: &impl HeatingElement, + ) { self.air_pressure = air_pressure; + self.update_return_flow(context); + self.update_heat(context, fluid); + self.fluid_physics.update(context); self.level_switch.update( @@ -2003,6 +2156,17 @@ impl Reservoir { self.update_leak_failure(context); } + fn update_return_flow(&mut self, context: &UpdateContext) { + self.total_return_flow = self.total_return_volume / context.delta_as_time(); + self.total_return_volume = Volume::default(); + } + + fn update_heat(&mut self, context: &UpdateContext, fluid: &impl HeatingElement) { + let has_fluid_return = self.total_return_flow.get::() > 0.1; + self.heat_state + .update(context, has_fluid_return && fluid.is_overheating()) + } + fn update_leak_failure(&mut self, context: &UpdateContext) { if self.leak_failure.is_active() { self.current_level -= @@ -2052,6 +2216,8 @@ impl Reservoir { }; self.current_level = (self.current_level + volume_actually_returned).min(self.max_capacity); + + self.total_return_volume += volume_actually_returned; } fn fluid_level_real(&self) -> Volume { @@ -2105,6 +2271,15 @@ impl PressurizeableReservoir for Reservoir { self.max_capacity - self.fluid_level_real() } } +impl HeatingElement for Reservoir { + fn is_damaged(&self) -> bool { + self.heat_state.is_damaged() + } + + fn is_overheating(&self) -> bool { + self.heat_state.is_overheating() + } +} pub trait PumpController { fn should_pressurise(&self) -> bool; @@ -2174,8 +2349,10 @@ impl Pump { fn update_cavitation(&mut self, reservoir: &Reservoir) { self.cavitation_efficiency = if !reservoir.is_empty() { - self.pump_characteristics - .cavitation_efficiency(reservoir.air_pressure()) + self.pump_characteristics.cavitation_efficiency( + reservoir.air_pressure(), + reservoir.heat_state.heat_factor.output(), + ) } else { Ratio::new::(0.) }; diff --git a/src/systems/systems/src/hydraulic/pumps.rs b/src/systems/systems/src/hydraulic/pumps.rs index 2e4239dc85a..4febc44ac37 100644 --- a/src/systems/systems/src/hydraulic/pumps.rs +++ b/src/systems/systems/src/hydraulic/pumps.rs @@ -118,12 +118,15 @@ impl PumpCharacteristics { )) } - pub fn cavitation_efficiency(&self, air_pressure: Pressure) -> Ratio { - Ratio::new::(interpolation( - &self.air_pressure_map_breakpoints_psi, - &self.cavitation_map_ratio, - air_pressure.get::(), - )) + pub fn cavitation_efficiency(&self, air_pressure: Pressure, heat_factor: Ratio) -> Ratio { + Ratio::new::( + (1. - heat_factor.get::()) + * interpolation( + &self.air_pressure_map_breakpoints_psi, + &self.cavitation_map_ratio, + air_pressure.get::(), + ), + ) } pub fn regulated_speed(&self) -> AngularVelocity { diff --git a/src/systems/systems/src/shared/low_pass_filter.rs b/src/systems/systems/src/shared/low_pass_filter.rs index 9bb19491673..f42ec0d0e2c 100644 --- a/src/systems/systems/src/shared/low_pass_filter.rs +++ b/src/systems/systems/src/shared/low_pass_filter.rs @@ -45,6 +45,10 @@ where self.filtered_output } + pub fn set_time_constant(&mut self, time_constant: Duration) { + self.time_constant = time_constant; + } + pub fn reset(&mut self, reset_value: T) { self.filtered_output = reset_value; } From 7435fc00905fa00d4c6d4a5ccb3ee900ba08557c Mon Sep 17 00:00:00 2001 From: lukecologne Date: Fri, 28 Oct 2022 14:11:42 +0200 Subject: [PATCH 02/39] feat(sd): add OVHT indication to HYD page --- src/instruments/src/SD/Pages/Hyd/Hyd.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/instruments/src/SD/Pages/Hyd/Hyd.tsx b/src/instruments/src/SD/Pages/Hyd/Hyd.tsx index 218915a7ff2..0158eb47079 100644 --- a/src/instruments/src/SD/Pages/Hyd/Hyd.tsx +++ b/src/instruments/src/SD/Pages/Hyd/Hyd.tsx @@ -255,6 +255,10 @@ const HydReservoir = ({ system, x, y, lowLevel } : HydReservoirProps) => { const [lowAirPress] = useSimVar(`L:A32NX_HYD_${system}_RESERVOIR_AIR_PRESSURE_IS_LOW`, 'boolean', 1000); + // The overheat indication should be computed by the EIS itself from the numerical temperature value, + // by applying a hysteresis logic. For now, we just use a boolean from the hydraulics directly. + const [overheat] = useSimVar(`L:A32NX_HYD_${system}_RESERVOIR_OVHT`, 'boolean', 1000); + const fluidLevelInLitres = fluidLevel * litersPerGallon; const values = levels[system]; @@ -282,6 +286,9 @@ const HydReservoir = ({ system, x, y, lowLevel } : HydReservoirProps) => { LO AIR PRESS + + { /* Not sure about the exact placement, have to wait for an IRL ref */ } + OVHT ); }; From c334bf956d161a34cb267bda0e5ea0794d44bd27 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Fri, 28 Oct 2022 14:37:05 +0200 Subject: [PATCH 03/39] added faults lvars --- docs/a320-simvars.md | 8 ++++++++ src/systems/a320_systems/src/hydraulic/mod.rs | 4 ++++ src/systems/systems/src/hydraulic/mod.rs | 3 +++ 3 files changed, 15 insertions(+) diff --git a/docs/a320-simvars.md b/docs/a320-simvars.md index 47878c5e5cb..415a1fd7692 100644 --- a/docs/a320-simvars.md +++ b/docs/a320-simvars.md @@ -807,6 +807,14 @@ - BLUE - YELLOW +- A32NX_HYD_{loop_name}_RESERVOIR_OVHT + - Boolean + - Reservoir of {loop_name} hydraulic circuit is overheating + - {loop_name} + - GREEN + - BLUE + - YELLOW + - A32NX_HYD_{loop_name}_EDPUMP_ACTIVE - Bool - Engine driven pump of {loop_name} hydraulic circuit is active diff --git a/src/systems/a320_systems/src/hydraulic/mod.rs b/src/systems/a320_systems/src/hydraulic/mod.rs index 745cb04773d..5c73a462f3c 100644 --- a/src/systems/a320_systems/src/hydraulic/mod.rs +++ b/src/systems/a320_systems/src/hydraulic/mod.rs @@ -1756,6 +1756,7 @@ impl A320Hydraulic { .engine_driven_pump_1_controller .has_air_pressure_low_fault() || self.engine_driven_pump_1_controller.has_low_level_fault() + || self.green_reservoir().is_overheating() } fn yellow_epump_has_fault(&self) -> bool { @@ -1765,6 +1766,7 @@ impl A320Hydraulic { .yellow_electric_pump_controller .has_air_pressure_low_fault() || self.yellow_electric_pump_controller.has_low_level_fault() + || self.yellow_reservoir().is_overheating() } fn yellow_edp_has_fault(&self) -> bool { @@ -1774,6 +1776,7 @@ impl A320Hydraulic { .engine_driven_pump_2_controller .has_air_pressure_low_fault() || self.engine_driven_pump_2_controller.has_low_level_fault() + || self.yellow_reservoir().is_overheating() } fn blue_epump_has_fault(&self) -> bool { @@ -1782,6 +1785,7 @@ impl A320Hydraulic { .blue_electric_pump_controller .has_air_pressure_low_fault() || self.blue_electric_pump_controller.has_low_level_fault() + || self.blue_reservoir().is_overheating() } pub fn green_reservoir(&self) -> &Reservoir { diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index 10c3b8d7ac7..56cd402913b 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -2067,6 +2067,7 @@ pub struct Reservoir { level_id: VariableIdentifier, low_level_id: VariableIdentifier, low_air_press_id: VariableIdentifier, + overheating_id: VariableIdentifier, max_capacity: Volume, max_gaugeable: Volume, @@ -2111,6 +2112,7 @@ impl Reservoir { .get_identifier(format!("HYD_{}_RESERVOIR_LEVEL_IS_LOW", hyd_loop_id)), low_air_press_id: context .get_identifier(format!("HYD_{}_RESERVOIR_AIR_PRESSURE_IS_LOW", hyd_loop_id)), + overheating_id: context.get_identifier(format!("HYD_{}_RESERVOIR_OVHT", hyd_loop_id)), max_capacity, max_gaugeable, @@ -2264,6 +2266,7 @@ impl SimulationElement for Reservoir { writer.write(&self.level_id, self.fluid_level_from_gauge()); writer.write(&self.low_level_id, self.is_low_level()); writer.write(&self.low_air_press_id, self.is_low_air_pressure()); + writer.write(&self.overheating_id, self.is_overheating()); } } impl PressurizeableReservoir for Reservoir { From 7e3f3c4473146657ba8da0d48451bd9624ca32c8 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Fri, 28 Oct 2022 14:37:07 +0200 Subject: [PATCH 04/39] Update CHANGELOG.md --- .github/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index a6dde40d40f..f2130cebb82 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -91,6 +91,7 @@ 1. [LIGHTS] Redone cockpit emissives panels and ambient lighting -@FinalLightNL (FinalLight) 1. [FMGC] Rework f-pln departure page - @tracernz (Mike) 1. [MCDU] Support coroute loading and viewing - @lucky38i (Alex) +1. [HYD] Simple temperature simulation - @Crocket63 (crocket) ## 0.8.0 From d5957f381d914749467436d05255ac928872fa5f Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Fri, 28 Oct 2022 17:10:12 +0200 Subject: [PATCH 05/39] ecam faults --- src/instruments/src/Common/EWDMessages.tsx | 4 +++ .../src/EWD/elements/PseudoFWC.tsx | 26 ++++++++++++++++++- src/systems/systems/src/hydraulic/mod.rs | 18 ++++++++++--- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/instruments/src/Common/EWDMessages.tsx b/src/instruments/src/Common/EWDMessages.tsx index fe534dab8e7..74b15aafe92 100644 --- a/src/instruments/src/Common/EWDMessages.tsx +++ b/src/instruments/src/Common/EWDMessages.tsx @@ -232,6 +232,10 @@ const EWDMessages = { '270055701': '\x1b<4m\x1b4mF/CTL\x1bm FCDC 2 FAULT', '290031001': '\x1b<4m*HYD', '290031201': '\x1b<4m*HYD', + '290012701': '\x1b<4m*HYD Y RSVR OVHT', + '290012702': '\x1b<5m -PTU................OFF', + '290012703': '\x1b<5m -YELLOW ENG 2 PUMP..OFF', + '290012704': '\x1b<5m -YELLOW ELEC PUMP...OFF', '308118601': '\x1b<4m\x1b4mSEVERE ICE\x1bm DETECTED', '308118602': '\x1b5m -WING ANTI ICE.......ON', '308118603': '\x1b5m -ENG MOD SEL........IGN', diff --git a/src/instruments/src/EWD/elements/PseudoFWC.tsx b/src/instruments/src/EWD/elements/PseudoFWC.tsx index 5ae38f09437..5f79bfc9b85 100644 --- a/src/instruments/src/EWD/elements/PseudoFWC.tsx +++ b/src/instruments/src/EWD/elements/PseudoFWC.tsx @@ -193,11 +193,15 @@ const PseudoFWC: React.FC = () => { const [blueLP] = useSimVar('L:A32NX_HYD_BLUE_EDPUMP_LOW_PRESS', 'bool', 500); const [blueSysPressurised] = useSimVar('L:A32NX_HYD_BLUE_SYSTEM_1_SECTION_PRESSURE_SWITCH', 'bool', 500); const [blueRvrLow] = useSimVar('L:A32NX_HYD_BLUE_RESERVOIR_LEVEL_IS_LOW', 'bool', 500); + + const [yellowRvrOvht] = useSimVar('L:A32NX_HYD_YELLOW_RESERVOIR_OVHT', 'bool', 500); const [blueElecPumpPBAuto] = useSimVar('L:A32NX_OVHD_HYD_EPUMPB_PB_IS_AUTO', 'bool', 500); const [yellowLP] = useSimVar('L:A32NX_HYD_YELLOW_EDPUMP_LOW_PRESS', 'bool', 500); const [yellowSysPressurised] = useSimVar('L:A32NX_HYD_YELLOW_SYSTEM_1_SECTION_PRESSURE_SWITCH', 'bool', 500); const [eng1pumpPBisAuto] = useSimVar('L:A32NX_OVHD_HYD_ENG_1_PUMP_PB_IS_AUTO', 'bool', 500); const [eng2pumpPBisAuto] = useSimVar('L:A32NX_OVHD_HYD_ENG_2_PUMP_PB_IS_AUTO', 'bool', 500); + const [yepumpPBisAuto] = useSimVar('L:A32NX_OVHD_HYD_EPUMPY_PB_IS_AUTO', 'bool', 500); + const [ptuIsAuto] = useSimVar('L:A32NX_OVHD_HYD_PTU_PB_IS_AUTO', 'bool', 500); const [hydPTU] = useSimVar('L:A32NX_HYD_PTU_ON_ECAM_MEMO', 'bool', 500); const [ratDeployed] = useSimVar('L:A32NX_HYD_RAT_STOW_POSITION', 'percent over 100', 500); @@ -1181,6 +1185,22 @@ const PseudoFWC: React.FC = () => { sysPage: -1, side: 'LEFT', }, + 2900127: // *HYD - Yellow reservoir overheat + { + flightPhaseInhib: [3, 4, 5, 7, 8], + simVarIsActive: yellowRvrOvht, + whichCodeToReturn: [ + 0, + ptuIsAuto ? 1 : null, + eng2pumpPBisAuto ? 2 : null, + !yepumpPBisAuto ? 3 : null, + ], + codesToReturn: ['290012701', '290012702', '290012703', '290012704'], + memoInhibit: false, + failure: 2, + sysPage: 4, + side: 'LEFT', + }, 2900310: // *HYD - Blue { flightPhaseInhib: [4, 5], @@ -1708,7 +1728,7 @@ const PseudoFWC: React.FC = () => { } } }, [ - engine1Generator, engine2Generator, blueLP, greenLP, yellowLP, eng1pumpPBisAuto, eng2pumpPBisAuto, + engine1Generator, engine2Generator, blueLP, greenLP, yellowLP, eng1pumpPBisAuto, eng2pumpPBisAuto, yepumpPBisAuto, ptuIsAuto, flapsMcdu, flapsMcduEntered, speedBrakeCommand, parkBrake, v1Speed, vrSpeed, v2Speed, cabin, catering, cargoaftLocked, cargofwdLocked, toconfigBtn, tomemo, flapsHandle, brakesHot, ]); @@ -1937,6 +1957,7 @@ const PseudoFWC: React.FC = () => { eng2Agent2PB, eng2AntiIce, eng2FireTest, + eng2pumpPBisAuto, engine2State, engDualFault, engSelectorPosition, @@ -1984,6 +2005,7 @@ const PseudoFWC: React.FC = () => { packOffNotFailure2, parkBrake, predWSOn, + ptuIsAuto, ratDeployed, recallReset, rightOuterInnerValve, @@ -2008,6 +2030,8 @@ const PseudoFWC: React.FC = () => { usrStartRefueling, wingAntiIce, voiceVHF3, + yellowRvrOvht, + yepumpPBisAuto, ]); useEffect(() => { diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index 56cd402913b..74d70a86853 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -81,7 +81,7 @@ impl Fluid { Self { current_bulk: bulk, heat_state: HeatingProperties::new( - Duration::from_secs_f64(0.5 * 60.), + Duration::from_secs_f64(0.6 * 60.), Duration::from_secs_f64(3. * 60.), Duration::from_secs_f64(3. * 60.), ), @@ -237,6 +237,18 @@ impl HeatingProperties { self.damaging_time.update(context, self.is_overheating); self.is_damaged_by_heat = self.is_damaged_by_heat || self.damaging_time.output(); } + + fn overheat_ratio(&self) -> Ratio { + if self.heat_factor.output().get::() < 0.5 { + Ratio::new::(1.) + } else { + Ratio::new::( + (self.heat_factor.output().get::() - 0.5 * 2.) + .max(0.) + .min(1.), + ) + } + } } impl HeatingElement for HeatingProperties { fn is_overheating(&self) -> bool { @@ -2126,7 +2138,7 @@ impl Reservoir { fluid_physics: FluidPhysics::new(), heat_state: HeatingProperties::new( - Duration::from_secs_f64(0.5 * 60.), + Duration::from_secs_f64(0.6 * 60.), Duration::from_secs_f64(3. * 60.), Duration::from_secs_f64(5. * 60.), ), @@ -2354,7 +2366,7 @@ impl Pump { self.cavitation_efficiency = if !reservoir.is_empty() { self.pump_characteristics.cavitation_efficiency( reservoir.air_pressure(), - reservoir.heat_state.heat_factor.output(), + reservoir.heat_state.overheat_ratio(), ) } else { Ratio::new::(0.) From 421da2f08d52a04985225c5e2f16cf3c75cc3280 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Sat, 29 Oct 2022 12:43:19 +0200 Subject: [PATCH 06/39] added pump failures --- src/failures/src/a320.ts | 6 ++ .../EFB/failures-orchestrator-provider.tsx | 4 ++ .../src/main.rs | 8 ++- src/systems/a320_systems/src/hydraulic/mod.rs | 8 +-- src/systems/a320_systems_wasm/src/lib.rs | 13 ++++ src/systems/a380_systems/src/hydraulic/mod.rs | 8 +-- src/systems/systems/src/failures/mod.rs | 2 + .../src/hydraulic/electrical_pump_physics.rs | 56 +++++++++++++++-- src/systems/systems/src/hydraulic/mod.rs | 62 ++++++++++++++----- 9 files changed, 138 insertions(+), 29 deletions(-) diff --git a/src/failures/src/a320.ts b/src/failures/src/a320.ts index 96b50241570..90fa2fe1667 100644 --- a/src/failures/src/a320.ts +++ b/src/failures/src/a320.ts @@ -13,6 +13,7 @@ export const A320Failure = Object.freeze({ Sec3Failure: 27004, Fcdc1Failure: 27005, Fcdc2Failure: 27006, + GreenReservoirLeak: 29000, BlueReservoirLeak: 29001, YellowReservoirLeak: 29002, @@ -22,6 +23,11 @@ export const A320Failure = Object.freeze({ GreenReservoirReturnLeak: 29006, BlueReservoirReturnLeak: 29007, YellowReservoirReturnLeak: 29008, + GreenEdpOverheat: 29009, + BlueEpumpOverheat: 29010, + YellowEdpOverheat: 29011, + YellowEpumpOverheat: 29012, + LeftPfdDisplay: 31000, RightPfdDisplay: 31001, diff --git a/src/instruments/src/EFB/failures-orchestrator-provider.tsx b/src/instruments/src/EFB/failures-orchestrator-provider.tsx index 46bdf27514b..f3c011e649c 100644 --- a/src/instruments/src/EFB/failures-orchestrator-provider.tsx +++ b/src/instruments/src/EFB/failures-orchestrator-provider.tsx @@ -35,6 +35,10 @@ const createOrchestrator = () => new FailuresOrchestrator('A32NX', [ [29, A320Failure.GreenReservoirReturnLeak, 'Green reservoir return leak'], [29, A320Failure.BlueReservoirReturnLeak, 'Blue reservoir return leak'], [29, A320Failure.YellowReservoirReturnLeak, 'Yellow reservoir return leak'], + [29, A320Failure.GreenEdpOverheat, 'Green engine pump overheat'], + [29, A320Failure.BlueEpumpOverheat, 'Blue electric pump overheat'], + [29, A320Failure.YellowEdpOverheat, 'Yellow engine pump overheat'], + [29, A320Failure.YellowEpumpOverheat, 'Yellow electric pump overheat'], [31, A320Failure.LeftPfdDisplay, 'Captain PFD display'], [31, A320Failure.RightPfdDisplay, 'F/O PFD display'], diff --git a/src/systems/a320_hydraulic_simulation_graphs/src/main.rs b/src/systems/a320_hydraulic_simulation_graphs/src/main.rs index 214b1c9cffa..382c9d7e557 100644 --- a/src/systems/a320_hydraulic_simulation_graphs/src/main.rs +++ b/src/systems/a320_hydraulic_simulation_graphs/src/main.rs @@ -358,7 +358,7 @@ fn hydraulic_loop(context: &mut InitContext, loop_color: HydraulicColor) -> Hydr fn electric_pump(context: &mut InitContext) -> ElectricPump { ElectricPump::new( context, - "DEFAULT", + HydraulicColor::Green, ElectricalBusType::AlternatingCurrentGndFltService, ElectricCurrent::new::(45.), PumpCharacteristics::a320_electric_pump(), @@ -366,7 +366,11 @@ fn electric_pump(context: &mut InitContext) -> ElectricPump { } fn _engine_driven_pump(context: &mut InitContext) -> EngineDrivenPump { - EngineDrivenPump::new(context, "DEFAULT", PumpCharacteristics::a320_edp()) + EngineDrivenPump::new( + context, + HydraulicColor::Green, + PumpCharacteristics::a320_edp(), + ) } struct A320TestPneumatics { diff --git a/src/systems/a320_systems/src/hydraulic/mod.rs b/src/systems/a320_systems/src/hydraulic/mod.rs index 5c73a462f3c..7bda08b68c7 100644 --- a/src/systems/a320_systems/src/hydraulic/mod.rs +++ b/src/systems/a320_systems/src/hydraulic/mod.rs @@ -1500,7 +1500,7 @@ impl A320Hydraulic { engine_driven_pump_1: EngineDrivenPump::new( context, - "GREEN", + HydraulicColor::Green, PumpCharacteristics::a320_edp(), ), engine_driven_pump_1_controller: A320EngineDrivenPumpController::new( @@ -1511,7 +1511,7 @@ impl A320Hydraulic { engine_driven_pump_2: EngineDrivenPump::new( context, - "YELLOW", + HydraulicColor::Yellow, PumpCharacteristics::a320_edp(), ), engine_driven_pump_2_controller: A320EngineDrivenPumpController::new( @@ -1525,7 +1525,7 @@ impl A320Hydraulic { blue_electric_pump: ElectricPump::new( context, - "BLUE", + HydraulicColor::Blue, Self::BLUE_ELEC_PUMP_SUPPLY_POWER_BUS, ElectricCurrent::new::(Self::ELECTRIC_PUMP_MAX_CURRENT_AMPERE), PumpCharacteristics::a320_electric_pump(), @@ -1537,7 +1537,7 @@ impl A320Hydraulic { yellow_electric_pump: ElectricPump::new( context, - "YELLOW", + HydraulicColor::Yellow, Self::YELLOW_ELEC_PUMP_SUPPLY_POWER_BUS, ElectricCurrent::new::(Self::ELECTRIC_PUMP_MAX_CURRENT_AMPERE), PumpCharacteristics::a320_electric_pump(), diff --git a/src/systems/a320_systems_wasm/src/lib.rs b/src/systems/a320_systems_wasm/src/lib.rs index 8ccc01bfd93..f657a234c39 100644 --- a/src/systems/a320_systems_wasm/src/lib.rs +++ b/src/systems/a320_systems_wasm/src/lib.rs @@ -80,6 +80,19 @@ async fn systems(mut gauge: msfs::Gauge) -> Result<(), Box> { 29_008, FailureType::ReservoirReturnLeak(HydraulicColor::Yellow), ), + ( + 29_009, + FailureType::EnginePumpOverheat(HydraulicColor::Green), + ), + ( + 29_011, + FailureType::EnginePumpOverheat(HydraulicColor::Yellow), + ), + (29_010, FailureType::ElecPumpOverheat(HydraulicColor::Blue)), + ( + 29_012, + FailureType::ElecPumpOverheat(HydraulicColor::Yellow), + ), (32_000, FailureType::LgciuPowerSupply(LgciuId::Lgciu1)), (32_001, FailureType::LgciuPowerSupply(LgciuId::Lgciu2)), (32_002, FailureType::LgciuInternalError(LgciuId::Lgciu1)), diff --git a/src/systems/a380_systems/src/hydraulic/mod.rs b/src/systems/a380_systems/src/hydraulic/mod.rs index 30c6befb3e3..30448452bf2 100644 --- a/src/systems/a380_systems/src/hydraulic/mod.rs +++ b/src/systems/a380_systems/src/hydraulic/mod.rs @@ -1488,7 +1488,7 @@ impl A380Hydraulic { engine_driven_pump_1: EngineDrivenPump::new( context, - "GREEN", + HydraulicColor::Green, PumpCharacteristics::a380_edp(), ), engine_driven_pump_1_controller: A380EngineDrivenPumpController::new( @@ -1499,7 +1499,7 @@ impl A380Hydraulic { engine_driven_pump_2: EngineDrivenPump::new( context, - "YELLOW", + HydraulicColor::Yellow, PumpCharacteristics::a380_edp(), ), engine_driven_pump_2_controller: A380EngineDrivenPumpController::new( @@ -1513,7 +1513,7 @@ impl A380Hydraulic { blue_electric_pump: ElectricPump::new( context, - "BLUE", + HydraulicColor::Blue, Self::BLUE_ELEC_PUMP_SUPPLY_POWER_BUS, ElectricCurrent::new::(Self::ELECTRIC_PUMP_MAX_CURRENT_AMPERE), PumpCharacteristics::a320_electric_pump(), @@ -1525,7 +1525,7 @@ impl A380Hydraulic { yellow_electric_pump: ElectricPump::new( context, - "YELLOW", + HydraulicColor::Yellow, Self::YELLOW_ELEC_PUMP_SUPPLY_POWER_BUS, ElectricCurrent::new::(Self::ELECTRIC_PUMP_MAX_CURRENT_AMPERE), PumpCharacteristics::a320_electric_pump(), diff --git a/src/systems/systems/src/failures/mod.rs b/src/systems/systems/src/failures/mod.rs index 6a6f45b406e..6814eadf11f 100644 --- a/src/systems/systems/src/failures/mod.rs +++ b/src/systems/systems/src/failures/mod.rs @@ -7,6 +7,8 @@ pub enum FailureType { ReservoirLeak(HydraulicColor), ReservoirAirLeak(HydraulicColor), ReservoirReturnLeak(HydraulicColor), + EnginePumpOverheat(HydraulicColor), + ElecPumpOverheat(HydraulicColor), LgciuPowerSupply(LgciuId), LgciuInternalError(LgciuId), GearProxSensorDamage(ProximityDetectorId), diff --git a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs index 44d73d953b2..79762b566c6 100644 --- a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs +++ b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs @@ -6,17 +6,20 @@ use uom::si::{ f64::*, power::watt, pressure::psi, + ratio::ratio, torque::{newton_meter, pound_force_inch}, volume::cubic_inch, }; -use crate::hydraulic::SectionPressure; +use crate::failures::{Failure, FailureType}; +use crate::hydraulic::{HeatingElement, HeatingProperties, SectionPressure}; use crate::shared::{ low_pass_filter::LowPassFilter, pid::PidController, ConsumePower, ElectricalBusType, - ElectricalBuses, + ElectricalBuses, HydraulicColor, }; use crate::simulation::{ - InitContext, SimulationElement, SimulatorWriter, UpdateContext, VariableIdentifier, Write, + InitContext, SimulationElement, SimulationElementVisitor, SimulatorWriter, UpdateContext, + VariableIdentifier, Write, }; use std::time::Duration; @@ -43,6 +46,9 @@ pub(super) struct ElectricalPumpPhysics { current_controller: PidController, displacement_filtered: LowPassFilter, + + overheat_failure: Failure, + heat_state: HeatingProperties, } impl ElectricalPumpPhysics { const DEFAULT_INERTIA: f64 = 0.011; @@ -62,7 +68,7 @@ impl ElectricalPumpPhysics { pub fn new( context: &mut InitContext, - id: &str, + id: HydraulicColor, bus_type: ElectricalBusType, max_current: ElectricCurrent, regulated_speed: AngularVelocity, @@ -97,6 +103,12 @@ impl ElectricalPumpPhysics { displacement_filtered: LowPassFilter::::new( Self::SPEED_DISPLACEMENT_FILTER_TIME_CONSTANT, ), + overheat_failure: Failure::new(FailureType::ElecPumpOverheat(id)), + heat_state: HeatingProperties::new( + Duration::from_secs_f64(30.), + Duration::from_secs_f64(2. * 60.), + Duration::from_secs_f64(2. * 60.), + ), } } @@ -106,6 +118,17 @@ impl ElectricalPumpPhysics { section: &impl SectionPressure, current_displacement: Volume, ) { + println!("ELECPUMP overheatRatio {:.2}, is overheat {:?}, is damaged {:?}, current {:.1}, speed {:.0}", + self.heat_state.overheat_ratio().get::(), + self.heat_state.is_overheating(), + self.heat_state.is_damaged(), + self.output_current.get::(), + self.speed().get::() + + ); + self.heat_state + .update(context, self.overheat_failure.is_active()); + self.displacement_filtered .update(context.delta(), current_displacement); @@ -155,7 +178,16 @@ impl ElectricalPumpPhysics { Torque::new::(Self::DEFAULT_RESISTANT_TORQUE_WHEN_OFF_NEWTON_METER) }; - self.resistant_torque = pumping_torque + dynamic_friction_torque; + let overheat_resistant_torque_factor = if !self.heat_state.is_overheating() { + 1. + } else if !self.heat_state.is_damaged() { + 30. * self.heat_state.overheat_ratio().get::() + } else { + 80. + }; + + self.resistant_torque = + pumping_torque + dynamic_friction_torque * overheat_resistant_torque_factor; } fn update_current_control(&mut self, context: &UpdateContext) { @@ -217,6 +249,11 @@ impl ElectricalPumpPhysics { } } impl SimulationElement for ElectricalPumpPhysics { + fn accept(&mut self, visitor: &mut T) { + self.overheat_failure.accept(visitor); + visitor.visit(self); + } + fn write(&self, writer: &mut SimulatorWriter) { writer.write(&self.active_id, self.is_active); writer.write(&self.rpm_id, self.speed()); @@ -231,6 +268,15 @@ impl SimulationElement for ElectricalPumpPhysics { consumption.consume_from_bus(self.powered_by, self.consumed_power); } } +impl HeatingElement for ElectricalPumpPhysics { + fn is_damaged(&self) -> bool { + self.heat_state.is_damaged() + } + + fn is_overheating(&self) -> bool { + self.heat_state.is_overheating() + } +} #[cfg(test)] mod tests { diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index 74d70a86853..2c225e1d2c6 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -199,7 +199,7 @@ pub trait HeatingElement { fn is_damaged(&self) -> bool; } -struct HeatingProperties { +pub struct HeatingProperties { is_overheating: bool, is_damaged_by_heat: bool, @@ -210,6 +210,8 @@ struct HeatingProperties { cool_time: Duration, } impl HeatingProperties { + const OVERHEATING_THRESHOLD: f64 = 0.5; + fn new(heat_time: Duration, cool_time: Duration, damage_time: Duration) -> Self { Self { is_overheating: false, @@ -232,22 +234,22 @@ impl HeatingProperties { .update(context.delta(), Ratio::new::(0.)); }; - self.is_overheating = self.heat_factor.output().get::() > 0.5; + self.is_overheating = + self.heat_factor.output().get::() > Self::OVERHEATING_THRESHOLD; self.damaging_time.update(context, self.is_overheating); self.is_damaged_by_heat = self.is_damaged_by_heat || self.damaging_time.output(); } + /// When overheating, provides a ratio of the heating severity + /// Above OVERHEATING_THRESHOLD it will rise from 0 to 1, while always 0 under the threshold fn overheat_ratio(&self) -> Ratio { - if self.heat_factor.output().get::() < 0.5 { - Ratio::new::(1.) - } else { - Ratio::new::( - (self.heat_factor.output().get::() - 0.5 * 2.) - .max(0.) - .min(1.), - ) - } + Ratio::new::( + ((self.heat_factor.output().get::() - Self::OVERHEATING_THRESHOLD) * 1. + / (1. - Self::OVERHEATING_THRESHOLD)) + .max(0.) + .min(1.), + ) } } impl HeatingElement for HeatingProperties { @@ -2471,7 +2473,7 @@ pub struct ElectricPump { impl ElectricPump { pub fn new( context: &mut InitContext, - id: &str, + id: HydraulicColor, bus_type: ElectricalBusType, max_current: ElectricCurrent, pump_characteristics: PumpCharacteristics, @@ -2571,11 +2573,14 @@ pub struct EngineDrivenPump { is_active: bool, speed: AngularVelocity, pump: Pump, + + overheat_failure: Failure, + heat_state: HeatingProperties, } impl EngineDrivenPump { pub fn new( context: &mut InitContext, - id: &str, + id: HydraulicColor, pump_characteristics: PumpCharacteristics, ) -> Self { Self { @@ -2583,6 +2588,12 @@ impl EngineDrivenPump { is_active: false, speed: AngularVelocity::new::(0.), pump: Pump::new(pump_characteristics), + overheat_failure: Failure::new(FailureType::EnginePumpOverheat(id)), + heat_state: HeatingProperties::new( + Duration::from_secs_f64(30.), + Duration::from_secs_f64(2. * 60.), + Duration::from_secs_f64(2. * 60.), + ), } } @@ -2594,9 +2605,18 @@ impl EngineDrivenPump { pump_speed: AngularVelocity, controller: &impl PumpController, ) { - self.speed = pump_speed; + self.heat_state + .update(context, self.overheat_failure.is_active()); + + self.speed = if !self.is_damaged() { + pump_speed + } else { + AngularVelocity::default() + }; + self.pump .update(context, section, reservoir, pump_speed, controller); + self.is_active = controller.should_pressurise(); } } @@ -2629,10 +2649,24 @@ impl PressureSource for EngineDrivenPump { } } impl SimulationElement for EngineDrivenPump { + fn accept(&mut self, visitor: &mut T) { + self.overheat_failure.accept(visitor); + visitor.visit(self); + } + fn write(&self, writer: &mut SimulatorWriter) { writer.write(&self.active_id, self.is_active); } } +impl HeatingElement for EngineDrivenPump { + fn is_damaged(&self) -> bool { + self.heat_state.is_damaged() + } + + fn is_overheating(&self) -> bool { + self.heat_state.is_overheating() + } +} struct WindTurbine { rpm_id: VariableIdentifier, From 7570d594bf5e498e0ef3d077809b4b53bef8a428 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Sat, 29 Oct 2022 14:36:01 +0200 Subject: [PATCH 07/39] pumps heats circuit fluid --- .../src/hydraulic/electrical_pump_physics.rs | 4 +- src/systems/systems/src/hydraulic/mod.rs | 53 ++++++++++++++++--- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs index 79762b566c6..240bf2178dd 100644 --- a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs +++ b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs @@ -181,9 +181,9 @@ impl ElectricalPumpPhysics { let overheat_resistant_torque_factor = if !self.heat_state.is_overheating() { 1. } else if !self.heat_state.is_damaged() { - 30. * self.heat_state.overheat_ratio().get::() + 50. * self.heat_state.overheat_ratio().get::() } else { - 80. + 100. }; self.resistant_torque = diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index 2c225e1d2c6..08b856edc4e 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -195,8 +195,12 @@ impl LevelSwitch { } pub trait HeatingElement { - fn is_overheating(&self) -> bool; - fn is_damaged(&self) -> bool; + fn is_overheating(&self) -> bool { + false + } + fn is_damaged(&self) -> bool { + false + } } pub struct HeatingProperties { @@ -1025,20 +1029,45 @@ impl HydraulicCircuit { pub fn update( &mut self, context: &UpdateContext, - main_section_pumps: &mut Vec<&mut impl PressureSource>, - system_section_pump: Option<&mut impl PressureSource>, - auxiliary_section_pump: Option<&mut impl PressureSource>, + main_section_pumps: &mut Vec<&mut (impl PressureSource + HeatingElement)>, + system_section_pump: Option<&mut (impl PressureSource + HeatingElement)>, + auxiliary_section_pump: Option<&mut (impl PressureSource + HeatingElement)>, ptu: Option<&PowerTransferUnit>, controller: &impl HydraulicCircuitController, reservoir_pressure: Pressure, ) { + let mut any_pump_is_overheating = false; + for pump in main_section_pumps.as_slice() { + if pump.flow().get::() > 0.01 && pump.is_overheating() { + // println!( + // "MAIN PUMP FLOW {:.2} OVERHEAT? {:?}", + // pump.flow().get::(), + // pump.is_overheating() + // ); + any_pump_is_overheating = true; + } + } + + if let Some(pump) = system_section_pump.as_ref() { + if pump.flow().get::() > 0.01 && pump.is_overheating() { + any_pump_is_overheating = true; + } + } + + if let Some(pump) = auxiliary_section_pump.as_ref() { + if pump.flow().get::() > 0.01 && pump.is_overheating() { + any_pump_is_overheating = true; + } + } + let mut ptu_overheats_fluid = false; if let Some(ptu) = ptu.as_ref() { if ptu.is_overheating() && ptu.is_rotating() { ptu_overheats_fluid = true; } } - self.fluid.update(context, ptu_overheats_fluid); + self.fluid + .update(context, ptu_overheats_fluid || any_pump_is_overheating); self.reservoir .update(context, reservoir_pressure, &self.fluid); @@ -2178,7 +2207,7 @@ impl Reservoir { } fn update_heat(&mut self, context: &UpdateContext, fluid: &impl HeatingElement) { - let has_fluid_return = self.total_return_flow.get::() > 0.1; + let has_fluid_return = self.total_return_flow.get::() > 0.01; self.heat_state .update(context, has_fluid_return && fluid.is_overheating()) } @@ -2566,6 +2595,15 @@ impl SimulationElement for ElectricPump { ); } } +impl HeatingElement for ElectricPump { + fn is_damaged(&self) -> bool { + self.pump_physics.is_damaged() + } + + fn is_overheating(&self) -> bool { + self.pump_physics.is_overheating() + } +} pub struct EngineDrivenPump { active_id: VariableIdentifier, @@ -2902,6 +2940,7 @@ impl SimulationElement for RamAirTurbine { writer.write(&self.stow_position_id, self.position); } } +impl HeatingElement for RamAirTurbine {} #[cfg(test)] mod tests { From 39502db3d8071f755d386aab8f1cb5d162dd9ee7 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Sat, 29 Oct 2022 16:07:10 +0200 Subject: [PATCH 08/39] fault logic reworked --- src/instruments/src/Common/EWDMessages.tsx | 5 ++ .../src/EWD/elements/PseudoFWC.tsx | 34 +++++++++++++ src/systems/a320_systems/src/hydraulic/mod.rs | 48 +++++++++++++++---- src/systems/systems/src/hydraulic/mod.rs | 3 ++ 4 files changed, 82 insertions(+), 8 deletions(-) diff --git a/src/instruments/src/Common/EWDMessages.tsx b/src/instruments/src/Common/EWDMessages.tsx index 74b15aafe92..a17a3b38ead 100644 --- a/src/instruments/src/Common/EWDMessages.tsx +++ b/src/instruments/src/Common/EWDMessages.tsx @@ -232,10 +232,15 @@ const EWDMessages = { '270055701': '\x1b<4m\x1b4mF/CTL\x1bm FCDC 2 FAULT', '290031001': '\x1b<4m*HYD', '290031201': '\x1b<4m*HYD', + '290012601': '\x1b<4m*HYD B RSVR OVHT', + '290012602': '\x1b<5m -BLUE ELEC PUMP.....OFF', '290012701': '\x1b<4m*HYD Y RSVR OVHT', '290012702': '\x1b<5m -PTU................OFF', '290012703': '\x1b<5m -YELLOW ENG 2 PUMP..OFF', '290012704': '\x1b<5m -YELLOW ELEC PUMP...OFF', + '290012801': '\x1b<4m*HYD G RSVR OVHT', + '290012802': '\x1b<5m -PTU................OFF', + '290012803': '\x1b<5m -GREEN ENG 1 PUMP...OFF', '308118601': '\x1b<4m\x1b4mSEVERE ICE\x1bm DETECTED', '308118602': '\x1b5m -WING ANTI ICE.......ON', '308118603': '\x1b5m -ENG MOD SEL........IGN', diff --git a/src/instruments/src/EWD/elements/PseudoFWC.tsx b/src/instruments/src/EWD/elements/PseudoFWC.tsx index 5f79bfc9b85..b4916195e5f 100644 --- a/src/instruments/src/EWD/elements/PseudoFWC.tsx +++ b/src/instruments/src/EWD/elements/PseudoFWC.tsx @@ -195,6 +195,8 @@ const PseudoFWC: React.FC = () => { const [blueRvrLow] = useSimVar('L:A32NX_HYD_BLUE_RESERVOIR_LEVEL_IS_LOW', 'bool', 500); const [yellowRvrOvht] = useSimVar('L:A32NX_HYD_YELLOW_RESERVOIR_OVHT', 'bool', 500); + const [greenRvrOvht] = useSimVar('L:A32NX_HYD_GREEN_RESERVOIR_OVHT', 'bool', 500); + const [blueRvrOvht] = useSimVar('L:A32NX_HYD_BLUE_RESERVOIR_OVHT', 'bool', 500); const [blueElecPumpPBAuto] = useSimVar('L:A32NX_OVHD_HYD_EPUMPB_PB_IS_AUTO', 'bool', 500); const [yellowLP] = useSimVar('L:A32NX_HYD_YELLOW_EDPUMP_LOW_PRESS', 'bool', 500); const [yellowSysPressurised] = useSimVar('L:A32NX_HYD_YELLOW_SYSTEM_1_SECTION_PRESSURE_SWITCH', 'bool', 500); @@ -1185,6 +1187,20 @@ const PseudoFWC: React.FC = () => { sysPage: -1, side: 'LEFT', }, + 2900126: // *HYD - Blue reservoir overheat + { + flightPhaseInhib: [3, 4, 5, 7, 8], + simVarIsActive: blueRvrOvht, + whichCodeToReturn: [ + 0, + blueElecPumpPBAuto ? 1 : null, + ], + codesToReturn: ['290012601', '290012602'], + memoInhibit: false, + failure: 2, + sysPage: 4, + side: 'LEFT', + }, 2900127: // *HYD - Yellow reservoir overheat { flightPhaseInhib: [3, 4, 5, 7, 8], @@ -1201,6 +1217,21 @@ const PseudoFWC: React.FC = () => { sysPage: 4, side: 'LEFT', }, + 2900128: // *HYD - Green reservoir overheat + { + flightPhaseInhib: [3, 4, 5, 7, 8], + simVarIsActive: greenRvrOvht, + whichCodeToReturn: [ + 0, + ptuIsAuto ? 1 : null, + eng1pumpPBisAuto ? 2 : null, + ], + codesToReturn: ['290012801', '290012802', '290012803'], + memoInhibit: false, + failure: 2, + sysPage: 4, + side: 'LEFT', + }, 2900310: // *HYD - Blue { flightPhaseInhib: [4, 5], @@ -1917,6 +1948,7 @@ const PseudoFWC: React.FC = () => { autoThrustStatus, blueElecPumpPBAuto, blueRvrLow, + blueRvrOvht, brakeFan, cabAltSetResetState1, cabAltSetResetState2, @@ -1953,6 +1985,7 @@ const PseudoFWC: React.FC = () => { eng1AntiIce, eng1FireTest, engine1State, + eng1pumpPBisAuto, eng2Agent1PB, eng2Agent2PB, eng2AntiIce, @@ -1979,6 +2012,7 @@ const PseudoFWC: React.FC = () => { gpwsFlaps3, gpwsTerrOff, greenHydEng1PBAuto, + greenRvrOvht, height1Failed, height2Failed, hydPTU, diff --git a/src/systems/a320_systems/src/hydraulic/mod.rs b/src/systems/a320_systems/src/hydraulic/mod.rs index 7bda08b68c7..5a17b0f6fc5 100644 --- a/src/systems/a320_systems/src/hydraulic/mod.rs +++ b/src/systems/a320_systems/src/hydraulic/mod.rs @@ -1756,7 +1756,7 @@ impl A320Hydraulic { .engine_driven_pump_1_controller .has_air_pressure_low_fault() || self.engine_driven_pump_1_controller.has_low_level_fault() - || self.green_reservoir().is_overheating() + || self.engine_driven_pump_1_controller.has_overheat_fault() } fn yellow_epump_has_fault(&self) -> bool { @@ -1766,7 +1766,7 @@ impl A320Hydraulic { .yellow_electric_pump_controller .has_air_pressure_low_fault() || self.yellow_electric_pump_controller.has_low_level_fault() - || self.yellow_reservoir().is_overheating() + || self.yellow_electric_pump_controller.has_overheat_fault() } fn yellow_edp_has_fault(&self) -> bool { @@ -1776,7 +1776,7 @@ impl A320Hydraulic { .engine_driven_pump_2_controller .has_air_pressure_low_fault() || self.engine_driven_pump_2_controller.has_low_level_fault() - || self.yellow_reservoir().is_overheating() + || self.engine_driven_pump_2_controller.has_overheat_fault() } fn blue_epump_has_fault(&self) -> bool { @@ -1785,7 +1785,7 @@ impl A320Hydraulic { .blue_electric_pump_controller .has_air_pressure_low_fault() || self.blue_electric_pump_controller.has_low_level_fault() - || self.blue_reservoir().is_overheating() + || self.blue_electric_pump_controller.has_overheat_fault() } pub fn green_reservoir(&self) -> &Reservoir { @@ -2193,9 +2193,7 @@ impl A320Hydraulic { lgciu2, self.green_circuit.reservoir(), self.yellow_circuit.reservoir(), - &self.power_transfer_unit, ); - self.power_transfer_unit.update( context, self.green_circuit.system_section(), @@ -2247,6 +2245,7 @@ impl A320Hydraulic { lgciu1, lgciu2, self.blue_circuit.reservoir(), + &self.blue_electric_pump, ); self.blue_electric_pump.update( context, @@ -2263,6 +2262,7 @@ impl A320Hydraulic { &self.aft_cargo_door_controller, &self.yellow_circuit, self.yellow_circuit.reservoir(), + &self.yellow_electric_pump, ); self.yellow_electric_pump.update( context, @@ -2663,6 +2663,7 @@ struct A320EngineDrivenPumpController { has_air_pressure_low_fault: bool, has_low_level_fault: bool, is_pressure_low: bool, + has_overheat_fault: bool, } impl A320EngineDrivenPumpController { fn new( @@ -2686,6 +2687,8 @@ impl A320EngineDrivenPumpController { has_low_level_fault: false, is_pressure_low: true, + + has_overheat_fault: false, } } @@ -2752,6 +2755,8 @@ impl A320EngineDrivenPumpController { self.update_low_air_pressure(reservoir, overhead_panel); self.update_low_level(reservoir, overhead_panel); + + self.has_overheat_fault = reservoir.is_overheating(); } fn has_pressure_low_fault(&self) -> bool { @@ -2765,6 +2770,10 @@ impl A320EngineDrivenPumpController { fn has_low_level_fault(&self) -> bool { self.has_low_level_fault } + + fn has_overheat_fault(&self) -> bool { + self.has_overheat_fault + } } impl PumpController for A320EngineDrivenPumpController { fn should_pressurise(&self) -> bool { @@ -2797,6 +2806,7 @@ struct A320BlueElectricPumpController { has_air_pressure_low_fault: bool, has_low_level_fault: bool, is_pressure_low: bool, + has_overheat_fault: bool, } impl A320BlueElectricPumpController { fn new(context: &mut InitContext, powered_by: ElectricalBusType) -> Self { @@ -2812,6 +2822,8 @@ impl A320BlueElectricPumpController { has_low_level_fault: false, is_pressure_low: true, + + has_overheat_fault: false, } } @@ -2824,6 +2836,7 @@ impl A320BlueElectricPumpController { lgciu1: &impl LgciuInterface, lgciu2: &impl LgciuInterface, reservoir: &Reservoir, + elec_pump: &impl HeatingElement, ) { let mut should_pressurise_if_powered = false; if overhead_panel.blue_epump_push_button.is_auto() { @@ -2854,6 +2867,9 @@ impl A320BlueElectricPumpController { self.update_low_air_pressure(reservoir, overhead_panel); self.update_low_level(reservoir, overhead_panel); + + // Elec pump has temperature sensor so we check also pump overheating state + self.has_overheat_fault = elec_pump.is_overheating() || reservoir.is_overheating(); } fn update_low_pressure( @@ -2910,6 +2926,10 @@ impl A320BlueElectricPumpController { fn has_low_level_fault(&self) -> bool { self.has_low_level_fault } + + fn has_overheat_fault(&self) -> bool { + self.has_low_level_fault + } } impl PumpController for A320BlueElectricPumpController { fn should_pressurise(&self) -> bool { @@ -2942,6 +2962,8 @@ struct A320YellowElectricPumpController { should_pressurise_for_cargo_door_operation: bool, low_pressure_hystereris: bool, + + has_overheat_fault: bool, } impl A320YellowElectricPumpController { const DURATION_OF_YELLOW_PUMP_ACTIVATION_AFTER_CARGO_DOOR_OPERATION: Duration = @@ -2974,6 +2996,8 @@ impl A320YellowElectricPumpController { should_pressurise_for_cargo_door_operation: false, low_pressure_hystereris: false, + + has_overheat_fault: false, } } @@ -2985,6 +3009,7 @@ impl A320YellowElectricPumpController { aft_cargo_door_controller: &A320DoorController, hydraulic_circuit: &impl HydraulicPressureSensors, reservoir: &Reservoir, + elec_pump: &impl HeatingElement, ) { self.update_cargo_door_logic( context, @@ -3002,6 +3027,9 @@ impl A320YellowElectricPumpController { self.update_low_air_pressure(reservoir, overhead_panel); self.update_low_level(reservoir, overhead_panel); + + // Elec pump has temperature sensor so we check also pump overheating state + self.has_overheat_fault = elec_pump.is_overheating() || reservoir.is_overheating(); } fn update_low_pressure(&mut self, hydraulic_circuit: &impl HydraulicPressureSensors) { @@ -3079,6 +3107,10 @@ impl A320YellowElectricPumpController { self.has_low_level_fault } + fn has_overheat_fault(&self) -> bool { + self.has_overheat_fault + } + fn should_pressurise_for_cargo_door_operation(&self) -> bool { self.should_pressurise_for_cargo_door_operation } @@ -3157,7 +3189,6 @@ impl A320PowerTransferUnitController { lgciu2: &impl LgciuInterface, reservoir_left_side: &Reservoir, reservoir_right_side: &Reservoir, - ptu: &impl HeatingElement, ) { self.should_inhibit_ptu_after_cargo_door_operation.update( context, @@ -3183,7 +3214,8 @@ impl A320PowerTransferUnitController { self.update_low_level(reservoir_left_side, reservoir_right_side, overhead_panel); - self.has_overheat_fault = ptu.is_overheating(); + self.has_overheat_fault = + reservoir_left_side.is_overheating() || reservoir_right_side.is_overheating(); } fn update_low_air_pressure( diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index 08b856edc4e..d929b853455 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -2496,6 +2496,7 @@ impl PressureSource for Pump { pub struct ElectricPump { cavitation_id: VariableIdentifier, + overheat_id: VariableIdentifier, pump: Pump, pump_physics: ElectricalPumpPhysics, } @@ -2510,6 +2511,7 @@ impl ElectricPump { let regulated_speed = pump_characteristics.regulated_speed(); Self { cavitation_id: context.get_identifier(format!("HYD_{}_EPUMP_CAVITATION", id)), + overheat_id: context.get_identifier(format!("HYD_{}_EPUMP_OVHT", id)), pump: Pump::new(pump_characteristics), pump_physics: ElectricalPumpPhysics::new( context, @@ -2593,6 +2595,7 @@ impl SimulationElement for ElectricPump { &self.cavitation_id, self.cavitation_efficiency().get::(), ); + writer.write(&self.overheat_id, self.is_overheating()); } } impl HeatingElement for ElectricPump { From 2bdf2bc649cb55f1a9a50bfcbb20b181ade46f34 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Sat, 29 Oct 2022 16:20:15 +0200 Subject: [PATCH 09/39] EWD formatting --- src/instruments/src/Common/EWDMessages.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/instruments/src/Common/EWDMessages.tsx b/src/instruments/src/Common/EWDMessages.tsx index a17a3b38ead..0fe9bad737b 100644 --- a/src/instruments/src/Common/EWDMessages.tsx +++ b/src/instruments/src/Common/EWDMessages.tsx @@ -232,13 +232,13 @@ const EWDMessages = { '270055701': '\x1b<4m\x1b4mF/CTL\x1bm FCDC 2 FAULT', '290031001': '\x1b<4m*HYD', '290031201': '\x1b<4m*HYD', - '290012601': '\x1b<4m*HYD B RSVR OVHT', + '290012601': '\x1b<4m\x1b4mHYD\x1bm B RSVR OVHT', '290012602': '\x1b<5m -BLUE ELEC PUMP.....OFF', - '290012701': '\x1b<4m*HYD Y RSVR OVHT', + '290012701': '\x1b<4m\x1b4mHYD\x1bm Y RSVR OVHT', '290012702': '\x1b<5m -PTU................OFF', '290012703': '\x1b<5m -YELLOW ENG 2 PUMP..OFF', '290012704': '\x1b<5m -YELLOW ELEC PUMP...OFF', - '290012801': '\x1b<4m*HYD G RSVR OVHT', + '290012801': '\x1b<4m\x1b4mHYD\x1bm G RSVR OVHT', '290012802': '\x1b<5m -PTU................OFF', '290012803': '\x1b<5m -GREEN ENG 1 PUMP...OFF', '308118601': '\x1b<4m\x1b4mSEVERE ICE\x1bm DETECTED', From 792bec3be1c1f44dfcadaf2e3b22d24001a0cb21 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Sat, 29 Oct 2022 16:27:40 +0200 Subject: [PATCH 10/39] Update a320-simvars.md --- docs/a320-simvars.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/a320-simvars.md b/docs/a320-simvars.md index 415a1fd7692..8a2c80448b5 100644 --- a/docs/a320-simvars.md +++ b/docs/a320-simvars.md @@ -894,6 +894,13 @@ - BLUE - YELLOW +- A32NX_HYD_{loop_name}_EPUMP_OVHT + - Bool + - Electric pump of {loop_name} hydraulic circuit is overheating + - {loop_name} + - BLUE + - YELLOW + - A32NX_HYD_{loop_name}_PUMP_1_FIRE_VALVE_OPENED - Bool - Engine driven pump of {loop_name} hydraulic circuit can receive hydraulic fluid From 240ee895bcabab2f593b876c122ab242afb9e2fd Mon Sep 17 00:00:00 2001 From: lukecologne Date: Sat, 29 Oct 2022 16:34:28 +0200 Subject: [PATCH 11/39] feat(sd): add ELEC PUMP OVHT indication --- src/instruments/src/SD/Pages/Hyd/Hyd.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/instruments/src/SD/Pages/Hyd/Hyd.tsx b/src/instruments/src/SD/Pages/Hyd/Hyd.tsx index 0158eb47079..454ca7c486c 100644 --- a/src/instruments/src/SD/Pages/Hyd/Hyd.tsx +++ b/src/instruments/src/SD/Pages/Hyd/Hyd.tsx @@ -44,6 +44,8 @@ export const HydPage = () => { const [ACBus1IsPowered] = useSimVar('L:A32NX_ELEC_AC_1_BUS_IS_POWERED', 'bool', 1000); + const [blueElecPumpOvht] = useSimVar('L:A32NX_HYD_BLUE_EPUMP_OVHT', 'bool', 1000); + const [engine1Running, setEngine1Running] = useState(false); const [engine2Running, setEngine2Running] = useState(false); @@ -111,6 +113,13 @@ export const HydPage = () => { > ELEC + + OVHT + @@ -302,6 +311,8 @@ type YellowElecPumpProps = { const YellowElecPump = ({ pumpPushbuttonOn, pressure, enginePumpPressureLowSwitch }: YellowElecPumpProps) => { const [ACBus2IsPowered] = useSimVar('L:A32NX_ELEC_AC_2_BUS_IS_POWERED', 'bool', 1000); + const [yellowElecPumpOvht] = useSimVar('L:A32NX_HYD_YELLOW_EPUMP_OVHT', 'bool', 1000); + let elecHorizontalLineFormat: string; let verticalLineFormat: string; let elecTriangleFill: number; @@ -333,6 +344,13 @@ const YellowElecPump = ({ pumpPushbuttonOn, pressure, enginePumpPressureLowSwitc > ELEC + + OVHT + From b6abd926ec600de03fd49967292be0971f5243a6 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Sat, 29 Oct 2022 17:00:26 +0200 Subject: [PATCH 12/39] Update electrical_pump_physics.rs --- .../systems/src/hydraulic/electrical_pump_physics.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs index 240bf2178dd..c9f30ac2f28 100644 --- a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs +++ b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs @@ -126,8 +126,10 @@ impl ElectricalPumpPhysics { self.speed().get::() ); - self.heat_state - .update(context, self.overheat_failure.is_active()); + self.heat_state.update( + context, + self.overheat_failure.is_active() && self.speed().get::() > 100., + ); self.displacement_filtered .update(context.delta(), current_displacement); @@ -219,7 +221,7 @@ impl ElectricalPumpPhysics { self.update_electrical_power_consumption(); - if self.pump_should_run() { + if self.pump_should_run() && !self.is_damaged() { if self.speed_raw.get::() < 5. && self.output_current.get::() > 0. { From bf6db36dc464d8e3d8c9a45402b1f43bdd903b98 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Sat, 29 Oct 2022 17:23:42 +0200 Subject: [PATCH 13/39] pump damaged do not consume current --- src/systems/systems/src/hydraulic/electrical_pump_physics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs index c9f30ac2f28..09aa2578b57 100644 --- a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs +++ b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs @@ -193,7 +193,7 @@ impl ElectricalPumpPhysics { } fn update_current_control(&mut self, context: &UpdateContext) { - self.output_current = if self.pump_should_run() { + self.output_current = if self.pump_should_run() && !self.is_damaged() { ElectricCurrent::new::(self.current_controller.next_control_output( self.speed_raw.get::(), Some(context.delta()), From 0148d8bbe8e4d025109b394429b805e0afbb57e0 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Sat, 29 Oct 2022 18:46:01 +0200 Subject: [PATCH 14/39] fix tests --- .../src/hydraulic/electrical_pump_physics.rs | 2 +- src/systems/systems/src/hydraulic/mod.rs | 34 +++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs index 09aa2578b57..a1380a674b0 100644 --- a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs +++ b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs @@ -488,7 +488,7 @@ mod tests { fn physical_pump(context: &mut InitContext) -> ElectricalPumpPhysics { ElectricalPumpPhysics::new( context, - "YELLOW", + HydraulicColor::Yellow, ElectricalBusType::AlternatingCurrent(1), ElectricCurrent::new::(45.), AngularVelocity::new::(7600.), diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index d929b853455..0c07b765781 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -2957,6 +2957,24 @@ mod tests { use super::*; + struct TestFluid { + is_hot: bool, + } + impl TestFluid { + fn overheat() -> Self { + Self { is_hot: true } + } + + fn nominal() -> Self { + Self { is_hot: true } + } + } + impl HeatingElement for TestFluid { + fn is_overheating(&self) -> bool { + self.is_hot + } + } + #[test] fn section_writes_its_state() { let mut test_bed = SimulationTestBed::from(ElementCtorFn(|context| { @@ -3082,7 +3100,7 @@ mod tests { })); test_bed.set_update_after_power_distribution(|reservoir, context| { - reservoir.update(context, Pressure::new::(50.)) + reservoir.update(context, Pressure::new::(50.), &TestFluid::nominal()) }); test_bed.fail(FailureType::ReservoirLeak(HydraulicColor::Green)); @@ -3105,7 +3123,7 @@ mod tests { })); test_bed.set_update_after_power_distribution(|reservoir, context| { - reservoir.update(context, Pressure::new::(50.)) + reservoir.update(context, Pressure::new::(50.), &TestFluid::nominal()) }); test_bed.fail(FailureType::ReservoirLeak(HydraulicColor::Green)); @@ -3128,7 +3146,7 @@ mod tests { })); test_bed.set_update_after_power_distribution(|reservoir, context| { - reservoir.update(context, Pressure::new::(50.)) + reservoir.update(context, Pressure::new::(50.), &TestFluid::nominal()) }); let is_low: bool = test_bed.read_by_name("HYD_GREEN_RESERVOIR_LEVEL_IS_LOW"); @@ -3154,7 +3172,7 @@ mod tests { })); test_bed.set_update_after_power_distribution(|reservoir, context| { - reservoir.update(context, Pressure::new::(50.)) + reservoir.update(context, Pressure::new::(50.), &TestFluid::nominal()) }); test_bed.run_multiple_frames(Duration::from_secs(2)); @@ -3181,7 +3199,7 @@ mod tests { ) })) .with_update_after_power_distribution(|el, context| { - el.update(context, Pressure::new::(50.)) + el.update(context, Pressure::new::(50.), &TestFluid::nominal()) }); test_bed.write_by_name("PLANE BANK DEGREES", 180.); @@ -3311,7 +3329,11 @@ mod tests { } fn engine_driven_pump(context: &mut InitContext) -> EngineDrivenPump { - EngineDrivenPump::new(context, "DEFAULT", PumpCharacteristics::a320_edp()) + EngineDrivenPump::new( + context, + HydraulicColor::Green, + PumpCharacteristics::a320_edp(), + ) } #[cfg(test)] From cb4695cc7fff8759265bf7e290cf3ac320c280dc Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Sun, 30 Oct 2022 14:07:21 +0100 Subject: [PATCH 15/39] Update mod.rs --- src/systems/systems/src/hydraulic/mod.rs | 108 +++++++++++++++-------- 1 file changed, 71 insertions(+), 37 deletions(-) diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index 0c07b765781..44b993320b3 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -77,13 +77,25 @@ pub struct Fluid { heat_state: HeatingProperties, } impl Fluid { + const HEATING_TIME_CONSTANT_MEAN_S: f64 = 40.; + const HEATING_TIME_CONSTANT_STD_S: f64 = 10.; + + const COOLING_TIME_CONSTANT: Duration = Duration::from_secs(60 * 3); + const DAMAGE_TIME_CONSTANT: Duration = Duration::from_secs(60 * 3); + pub fn new(bulk: Pressure) -> Self { Self { current_bulk: bulk, heat_state: HeatingProperties::new( - Duration::from_secs_f64(0.6 * 60.), - Duration::from_secs_f64(3. * 60.), - Duration::from_secs_f64(3. * 60.), + Duration::from_secs_f64( + random_from_normal_distribution( + Self::HEATING_TIME_CONSTANT_MEAN_S, + Self::HEATING_TIME_CONSTANT_STD_S, + ) + .max(10.), + ), + Self::COOLING_TIME_CONSTANT, + Self::DAMAGE_TIME_CONSTANT, ), } } @@ -352,6 +364,11 @@ impl PowerTransferUnit { const THRESHOLD_DELTA_TO_DECLARE_CONTINUOUS_RPM: f64 = 400.; const DURATION_BEFORE_CAPTURING_BARK_STRENGTH_SPEED: Duration = Duration::from_millis(133); + const HEATING_TIME_CONSTANT_MEAN_S: f64 = 60.; + const HEATING_TIME_CONSTANT_STD_S: f64 = 10.; + const COOLING_TIME_CONSTANT: Duration = Duration::from_secs(60 * 3); + const DAMAGE_TIME_CONSTANT: Duration = Duration::from_secs(60 * 3); + pub fn new( context: &mut InitContext, characteristics: &impl PowerTransferUnitCharacteristics, @@ -400,9 +417,15 @@ impl PowerTransferUnit { efficiency: characteristics.efficiency(), heat_state: HeatingProperties::new( - Duration::from_secs_f64(1. * 60.), - Duration::from_secs_f64(3. * 60.), - Duration::from_secs_f64(5. * 60.), + Duration::from_secs_f64( + random_from_normal_distribution( + Self::HEATING_TIME_CONSTANT_MEAN_S, + Self::HEATING_TIME_CONSTANT_STD_S, + ) + .max(10.), + ), + Self::COOLING_TIME_CONSTANT, + Self::DAMAGE_TIME_CONSTANT, ), } } @@ -443,13 +466,6 @@ impl PowerTransferUnit { context, self.shaft_speed.get::() > 2000., ); - - println!( - "PTU SPEED {:.0} PTU HEAT FACTOR {:.2} PTU DAMAGED {:?}", - self.shaft_speed.get::(), - self.heat_state.heat_factor.output().get::(), - self.heat_state.is_damaged(), - ); } fn update_displacement( @@ -1039,11 +1055,6 @@ impl HydraulicCircuit { let mut any_pump_is_overheating = false; for pump in main_section_pumps.as_slice() { if pump.flow().get::() > 0.01 && pump.is_overheating() { - // println!( - // "MAIN PUMP FLOW {:.2} OVERHEAT? {:?}", - // pump.flow().get::(), - // pump.is_overheating() - // ); any_pump_is_overheating = true; } } @@ -1060,22 +1071,16 @@ impl HydraulicCircuit { } } - let mut ptu_overheats_fluid = false; - if let Some(ptu) = ptu.as_ref() { - if ptu.is_overheating() && ptu.is_rotating() { - ptu_overheats_fluid = true; - } - } - self.fluid - .update(context, ptu_overheats_fluid || any_pump_is_overheating); - - self.reservoir - .update(context, reservoir_pressure, &self.fluid); + let ptu_overheats_fluid = if let Some(ptu) = ptu.as_ref() { + ptu.is_overheating() && ptu.is_rotating() + } else { + false + }; println!( - "LOOP {:?}, PTU OH {:?} FLUID ratio {:?} RES ratio {:?} Res flow gps{:.3}", + "LOOP {:?}, PTU OH {:?} ANYpump OH fluid {:?} FLUID ratio {:?} RES ratio {:?} Res flow gps{:.3}", self.id, - ptu_overheats_fluid, + ptu_overheats_fluid,any_pump_is_overheating, self.fluid.heat_state.heat_factor.output().get::(), self.reservoir .heat_state @@ -1085,6 +1090,12 @@ impl HydraulicCircuit { self.reservoir.total_return_flow.get::() ); + self.fluid + .update(context, ptu_overheats_fluid || any_pump_is_overheating); + + self.reservoir + .update(context, reservoir_pressure, &self.fluid); + self.update_shutoff_valves(controller); self.update_leak_measurement_valves(context, controller); self.update_auxiliary_selector_valve(controller); @@ -2140,6 +2151,11 @@ impl Reservoir { // Part of the fluid lost instead of returning to reservoir const RETURN_FAILURE_LEAK_RATIO: f64 = 0.1; + const HEATING_TIME_CONSTANT_MEAN_S: f64 = 30.; + const HEATING_TIME_CONSTANT_STD_S: f64 = 5.; + const COOLING_TIME_CONSTANT: Duration = Duration::from_secs(60 * 3); + const DAMAGE_TIME_CONSTANT: Duration = Duration::from_secs(60 * 5); + pub fn new( context: &mut InitContext, hyd_loop_id: HydraulicColor, @@ -2169,9 +2185,15 @@ impl Reservoir { fluid_physics: FluidPhysics::new(), heat_state: HeatingProperties::new( - Duration::from_secs_f64(0.6 * 60.), - Duration::from_secs_f64(3. * 60.), - Duration::from_secs_f64(5. * 60.), + Duration::from_secs_f64( + random_from_normal_distribution( + Self::HEATING_TIME_CONSTANT_MEAN_S, + Self::HEATING_TIME_CONSTANT_STD_S, + ) + .max(10.), + ), + Self::COOLING_TIME_CONSTANT, + Self::DAMAGE_TIME_CONSTANT, ), total_return_flow: VolumeRate::default(), total_return_volume: Volume::default(), @@ -2619,6 +2641,12 @@ pub struct EngineDrivenPump { heat_state: HeatingProperties, } impl EngineDrivenPump { + const HEATING_TIME_CONSTANT_MEAN_S: f64 = 30.; + const HEATING_TIME_CONSTANT_STD_S: f64 = 5.; + + const COOLING_TIME_CONSTANT: Duration = Duration::from_secs(60 * 2); + const DAMAGE_TIME_CONSTANT: Duration = Duration::from_secs(60 * 2); + pub fn new( context: &mut InitContext, id: HydraulicColor, @@ -2631,9 +2659,15 @@ impl EngineDrivenPump { pump: Pump::new(pump_characteristics), overheat_failure: Failure::new(FailureType::EnginePumpOverheat(id)), heat_state: HeatingProperties::new( - Duration::from_secs_f64(30.), - Duration::from_secs_f64(2. * 60.), - Duration::from_secs_f64(2. * 60.), + Duration::from_secs_f64( + random_from_normal_distribution( + Self::HEATING_TIME_CONSTANT_MEAN_S, + Self::HEATING_TIME_CONSTANT_STD_S, + ) + .max(10.), + ), + Self::COOLING_TIME_CONSTANT, + Self::DAMAGE_TIME_CONSTANT, ), } } From 231e7e377bca90ac5efd98680e47e0a5e07c39ce Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Sun, 30 Oct 2022 15:10:19 +0100 Subject: [PATCH 16/39] fix elec pump staying active when not spinning --- src/systems/systems/src/hydraulic/electrical_pump_physics.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs index a1380a674b0..1bca0c05b4a 100644 --- a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs +++ b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs @@ -257,7 +257,10 @@ impl SimulationElement for ElectricalPumpPhysics { } fn write(&self, writer: &mut SimulatorWriter) { - writer.write(&self.active_id, self.is_active); + writer.write( + &self.active_id, + self.is_active && self.speed().get::() > 10., + ); writer.write(&self.rpm_id, self.speed()); } From 2d9bffa18b6be4e53c9592b24bbc03f9a61060d7 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Sun, 30 Oct 2022 15:10:33 +0100 Subject: [PATCH 17/39] fix edp spinning when damaged --- src/systems/systems/src/hydraulic/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index 44b993320b3..59221e59f70 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -2690,7 +2690,7 @@ impl EngineDrivenPump { }; self.pump - .update(context, section, reservoir, pump_speed, controller); + .update(context, section, reservoir, self.speed, controller); self.is_active = controller.should_pressurise(); } From 3de52f6d10fa59f57a0ea3cff43e20ad4fc0e00b Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Sun, 30 Oct 2022 17:15:40 +0100 Subject: [PATCH 18/39] some tests --- .../src/hydraulic/electrical_pump_physics.rs | 65 +++++++++++++++---- src/systems/systems/src/hydraulic/mod.rs | 52 +++++++++++++++ 2 files changed, 104 insertions(+), 13 deletions(-) diff --git a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs index 1bca0c05b4a..04611eb4b9b 100644 --- a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs +++ b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs @@ -14,8 +14,8 @@ use uom::si::{ use crate::failures::{Failure, FailureType}; use crate::hydraulic::{HeatingElement, HeatingProperties, SectionPressure}; use crate::shared::{ - low_pass_filter::LowPassFilter, pid::PidController, ConsumePower, ElectricalBusType, - ElectricalBuses, HydraulicColor, + low_pass_filter::LowPassFilter, pid::PidController, random_from_normal_distribution, + ConsumePower, ElectricalBusType, ElectricalBuses, HydraulicColor, }; use crate::simulation::{ InitContext, SimulationElement, SimulationElementVisitor, SimulatorWriter, UpdateContext, @@ -66,6 +66,12 @@ impl ElectricalPumpPhysics { const DEFAULT_P_GAIN: f64 = 0.1; const DEFAULT_I_GAIN: f64 = 0.45; + const HEATING_TIME_CONSTANT_MEAN_S: f64 = 30.; + const HEATING_TIME_CONSTANT_STD_S: f64 = 5.; + + const COOLING_TIME_CONSTANT: Duration = Duration::from_secs(60 * 2); + const DAMAGE_TIME_CONSTANT: Duration = Duration::from_secs(60 * 2); + pub fn new( context: &mut InitContext, id: HydraulicColor, @@ -105,9 +111,15 @@ impl ElectricalPumpPhysics { ), overheat_failure: Failure::new(FailureType::ElecPumpOverheat(id)), heat_state: HeatingProperties::new( - Duration::from_secs_f64(30.), - Duration::from_secs_f64(2. * 60.), - Duration::from_secs_f64(2. * 60.), + Duration::from_secs_f64( + random_from_normal_distribution( + Self::HEATING_TIME_CONSTANT_MEAN_S, + Self::HEATING_TIME_CONSTANT_STD_S, + ) + .max(10.), + ), + Self::COOLING_TIME_CONSTANT, + Self::DAMAGE_TIME_CONSTANT, ), } } @@ -118,14 +130,6 @@ impl ElectricalPumpPhysics { section: &impl SectionPressure, current_displacement: Volume, ) { - println!("ELECPUMP overheatRatio {:.2}, is overheat {:?}, is damaged {:?}, current {:.1}, speed {:.0}", - self.heat_state.overheat_ratio().get::(), - self.heat_state.is_overheating(), - self.heat_state.is_damaged(), - self.output_current.get::(), - self.speed().get::() - - ); self.heat_state.update( context, self.overheat_failure.is_active() && self.speed().get::() > 100., @@ -488,6 +492,41 @@ mod tests { ); } + #[test] + fn pump_with_overheat_fail_overheats_and_fails() { + let mut test_bed = SimulationTestBed::new(TestAircraft::new); + + test_bed.command(|a| a.set_ac_1_power(true)); + test_bed.command(|a| a.pump.set_active(true)); + test_bed.command(|a| a.set_current_displacement(Volume::new::(0.))); + test_bed.command(|a| a.set_current_pressure(Pressure::new::(3000.))); + + test_bed.run_with_delta(Duration::from_secs_f64(1.)); + + assert!( + test_bed.query(|a| a.pump.speed()) + >= AngularVelocity::new::(7000.) + ); + + test_bed.fail(FailureType::ElecPumpOverheat(HydraulicColor::Yellow)); + + test_bed.run_with_delta(Duration::from_secs_f64( + ElectricalPumpPhysics::HEATING_TIME_CONSTANT_MEAN_S + + 4. * ElectricalPumpPhysics::HEATING_TIME_CONSTANT_STD_S, + )); + + assert!(test_bed.query(|a| a.pump.is_overheating())); + + test_bed.run_with_delta(ElectricalPumpPhysics::DAMAGE_TIME_CONSTANT); + + assert!(test_bed.query(|a| a.pump.is_damaged())); + + assert!( + test_bed.query(|a| a.pump.speed()) + <= AngularVelocity::new::(100.) + ); + } + fn physical_pump(context: &mut InitContext) -> ElectricalPumpPhysics { ElectricalPumpPhysics::new( context, diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index 59221e59f70..9d571a3bfb7 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -3276,6 +3276,58 @@ mod tests { ); } + #[test] + fn reservoir_receiving_heating_fluid_overheats() { + let mut test_bed = SimulationTestBed::from(ElementCtorFn(|context| { + reservoir( + context, + HydraulicColor::Green, + Volume::new::(5.), + Volume::new::(2.), + Volume::new::(0.5), + ) + })); + + test_bed.set_update_after_power_distribution(|reservoir, context| { + reservoir.update(context, Pressure::new::(50.), &TestFluid::overheat()); + + reservoir.try_take_volume(Volume::new::(0.10)); + + reservoir.add_return_volume(Volume::new::(0.10)); + }); + + test_bed.run_multiple_frames(Duration::from_secs_f64( + Reservoir::HEATING_TIME_CONSTANT_MEAN_S + 4. * Reservoir::HEATING_TIME_CONSTANT_STD_S, + )); + + let is_overheating: bool = test_bed.read_by_name("HYD_GREEN_RESERVOIR_OVHT"); + assert!(is_overheating); + } + + #[test] + fn reservoir_receiving_zero_flow_of_heating_fluid_do_not_overheat() { + let mut test_bed = SimulationTestBed::from(ElementCtorFn(|context| { + reservoir( + context, + HydraulicColor::Green, + Volume::new::(5.), + Volume::new::(2.), + Volume::new::(0.5), + ) + })); + + test_bed.set_update_after_power_distribution(|reservoir, context| { + reservoir.update(context, Pressure::new::(50.), &TestFluid::overheat()); + }); + + test_bed.run_multiple_frames(Duration::from_secs_f64( + Reservoir::HEATING_TIME_CONSTANT_MEAN_S + 4. * Reservoir::HEATING_TIME_CONSTANT_STD_S, + )); + + let is_overheating: bool = test_bed.read_by_name("HYD_GREEN_RESERVOIR_OVHT"); + assert!(!is_overheating); + } + fn section( context: &mut InitContext, loop_id: HydraulicColor, From 664328fcde858bf0dbdf9d13159f8db7aecfa250 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Sun, 30 Oct 2022 17:27:54 +0100 Subject: [PATCH 19/39] Update PseudoFWC.tsx --- src/instruments/src/EWD/elements/PseudoFWC.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/instruments/src/EWD/elements/PseudoFWC.tsx b/src/instruments/src/EWD/elements/PseudoFWC.tsx index b4916195e5f..c70d63a7eed 100644 --- a/src/instruments/src/EWD/elements/PseudoFWC.tsx +++ b/src/instruments/src/EWD/elements/PseudoFWC.tsx @@ -1759,7 +1759,7 @@ const PseudoFWC: React.FC = () => { } } }, [ - engine1Generator, engine2Generator, blueLP, greenLP, yellowLP, eng1pumpPBisAuto, eng2pumpPBisAuto, yepumpPBisAuto, ptuIsAuto, + engine1Generator, engine2Generator, blueLP, greenLP, yellowLP, eng1pumpPBisAuto, eng2pumpPBisAuto, flapsMcdu, flapsMcduEntered, speedBrakeCommand, parkBrake, v1Speed, vrSpeed, v2Speed, cabin, catering, cargoaftLocked, cargofwdLocked, toconfigBtn, tomemo, flapsHandle, brakesHot, ]); From a5f9f1d99fc27382ea7457a1783ca54e9d9cece2 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Mon, 31 Oct 2022 10:00:40 +0100 Subject: [PATCH 20/39] clean up --- .../src/hydraulic/electrical_pump_physics.rs | 6 +++- src/systems/systems/src/hydraulic/mod.rs | 30 +++++++------------ 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs index 04611eb4b9b..4b8d3e33bd8 100644 --- a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs +++ b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs @@ -72,6 +72,8 @@ impl ElectricalPumpPhysics { const COOLING_TIME_CONSTANT: Duration = Duration::from_secs(60 * 2); const DAMAGE_TIME_CONSTANT: Duration = Duration::from_secs(60 * 2); + const MIN_SPEED_TO_REPORT_ACTIVE_RPM: f64 = 10.; + pub fn new( context: &mut InitContext, id: HydraulicColor, @@ -263,7 +265,9 @@ impl SimulationElement for ElectricalPumpPhysics { fn write(&self, writer: &mut SimulatorWriter) { writer.write( &self.active_id, - self.is_active && self.speed().get::() > 10., + self.is_active + && self.speed().get::() + > Self::MIN_SPEED_TO_REPORT_ACTIVE_RPM, ); writer.write(&self.rpm_id, self.speed()); } diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index 9d571a3bfb7..c363485dde1 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -369,6 +369,8 @@ impl PowerTransferUnit { const COOLING_TIME_CONSTANT: Duration = Duration::from_secs(60 * 3); const DAMAGE_TIME_CONSTANT: Duration = Duration::from_secs(60 * 3); + const MAX_SPEED_BEFORE_HEATING_UP_RPM: f64 = 2000.; + pub fn new( context: &mut InitContext, characteristics: &impl PowerTransferUnitCharacteristics, @@ -464,7 +466,7 @@ impl PowerTransferUnit { self.heat_state.update( context, - self.shaft_speed.get::() > 2000., + self.shaft_speed.get::() > Self::MAX_SPEED_BEFORE_HEATING_UP_RPM, ); } @@ -871,8 +873,6 @@ pub struct HydraulicCircuit { system_section: Section, auxiliary_section: Option
, - id: HydraulicColor, - pump_sections_check_valves: Vec, // True routed to auxiliary False routed to system section @@ -1017,7 +1017,6 @@ impl HydraulicCircuit { } else { None }, - id, pump_sections_check_valves: pump_to_system_check_valves, pump_section_routed_to_auxiliary_section: pump_section_to_auxiliary, fluid: Fluid::new(Pressure::new::(Self::FLUID_BULK_MODULUS_PASCAL)), @@ -1077,19 +1076,6 @@ impl HydraulicCircuit { false }; - println!( - "LOOP {:?}, PTU OH {:?} ANYpump OH fluid {:?} FLUID ratio {:?} RES ratio {:?} Res flow gps{:.3}", - self.id, - ptu_overheats_fluid,any_pump_is_overheating, - self.fluid.heat_state.heat_factor.output().get::(), - self.reservoir - .heat_state - .heat_factor - .output() - .get::(), - self.reservoir.total_return_flow.get::() - ); - self.fluid .update(context, ptu_overheats_fluid || any_pump_is_overheating); @@ -2647,6 +2633,8 @@ impl EngineDrivenPump { const COOLING_TIME_CONSTANT: Duration = Duration::from_secs(60 * 2); const DAMAGE_TIME_CONSTANT: Duration = Duration::from_secs(60 * 2); + const MIN_SPEED_TO_REPORT_HEATING_RPM: f64 = 200.; + pub fn new( context: &mut InitContext, id: HydraulicColor, @@ -2680,8 +2668,12 @@ impl EngineDrivenPump { pump_speed: AngularVelocity, controller: &impl PumpController, ) { - self.heat_state - .update(context, self.overheat_failure.is_active()); + self.heat_state.update( + context, + self.overheat_failure.is_active() + && pump_speed.get::() + > Self::MIN_SPEED_TO_REPORT_HEATING_RPM, + ); self.speed = if !self.is_damaged() { pump_speed From 3b4c05eafe1dfd236fe723b01d4cdc99391c149c Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Mon, 31 Oct 2022 11:37:17 +0100 Subject: [PATCH 21/39] removed failing test --- src/systems/a380_systems/src/hydraulic/mod.rs | 61 ------------------- 1 file changed, 61 deletions(-) diff --git a/src/systems/a380_systems/src/hydraulic/mod.rs b/src/systems/a380_systems/src/hydraulic/mod.rs index 30448452bf2..cab3d384050 100644 --- a/src/systems/a380_systems/src/hydraulic/mod.rs +++ b/src/systems/a380_systems/src/hydraulic/mod.rs @@ -8430,67 +8430,6 @@ mod tests { assert!(test_bed.get_brake_right_yellow_pressure() < Pressure::new::(3500.)); } - #[test] - fn no_brake_inversion() { - let mut test_bed = test_bed_on_ground_with() - .engines_off() - .on_the_ground() - .set_cold_dark_inputs() - .run_one_tick(); - - test_bed = test_bed - .start_eng1(Ratio::new::(100.)) - .start_eng2(Ratio::new::(100.)) - .set_park_brake(false) - .run_waiting_for(Duration::from_secs(5)); - - assert!(test_bed.is_green_pressure_switch_pressurised()); - assert!(test_bed.is_yellow_pressure_switch_pressurised()); - // Braking left - test_bed = test_bed - .set_left_brake(Ratio::new::(100.)) - .set_right_brake(Ratio::new::(0.)) - .run_waiting_for(Duration::from_secs(1)); - - assert!(test_bed.get_brake_left_green_pressure() > Pressure::new::(2000.)); - assert!(test_bed.get_brake_right_green_pressure() < Pressure::new::(50.)); - assert!(test_bed.get_brake_left_yellow_pressure() < Pressure::new::(50.)); - assert!(test_bed.get_brake_right_yellow_pressure() < Pressure::new::(50.)); - - // Braking right - test_bed = test_bed - .set_left_brake(Ratio::new::(0.)) - .set_right_brake(Ratio::new::(100.)) - .run_waiting_for(Duration::from_secs(1)); - - assert!(test_bed.get_brake_left_green_pressure() < Pressure::new::(50.)); - assert!(test_bed.get_brake_right_green_pressure() > Pressure::new::(2000.)); - assert!(test_bed.get_brake_left_yellow_pressure() < Pressure::new::(50.)); - assert!(test_bed.get_brake_right_yellow_pressure() < Pressure::new::(50.)); - - // Disabling Askid causes alternate braking to work and release green brakes - test_bed = test_bed - .set_left_brake(Ratio::new::(0.)) - .set_right_brake(Ratio::new::(100.)) - .set_anti_skid(false) - .run_waiting_for(Duration::from_secs(2)); - - assert!(test_bed.get_brake_left_green_pressure() < Pressure::new::(50.)); - assert!(test_bed.get_brake_right_green_pressure() < Pressure::new::(50.)); - assert!(test_bed.get_brake_left_yellow_pressure() < Pressure::new::(50.)); - assert!(test_bed.get_brake_right_yellow_pressure() > Pressure::new::(950.)); - - test_bed = test_bed - .set_left_brake(Ratio::new::(100.)) - .set_right_brake(Ratio::new::(0.)) - .run_waiting_for(Duration::from_secs(2)); - - assert!(test_bed.get_brake_left_green_pressure() < Pressure::new::(50.)); - assert!(test_bed.get_brake_right_green_pressure() < Pressure::new::(50.)); - assert!(test_bed.get_brake_left_yellow_pressure() > Pressure::new::(950.)); - assert!(test_bed.get_brake_right_yellow_pressure() < Pressure::new::(50.)); - } - #[test] fn auto_brake_at_gear_retraction() { let mut test_bed = test_bed_on_ground_with() From 5233938125bbbf5a84863dd6c99405df730374a8 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Thu, 3 Nov 2022 14:18:57 +0100 Subject: [PATCH 22/39] fix ptu heating only in one direction --- src/systems/a320_systems/src/hydraulic/mod.rs | 37 +++++++++++++++++++ src/systems/systems/src/hydraulic/mod.rs | 7 ++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/systems/a320_systems/src/hydraulic/mod.rs b/src/systems/a320_systems/src/hydraulic/mod.rs index 955613c5331..47b28c9b755 100644 --- a/src/systems/a320_systems/src/hydraulic/mod.rs +++ b/src/systems/a320_systems/src/hydraulic/mod.rs @@ -2385,6 +2385,7 @@ impl A320Hydraulic { > Pressure::new::(Self::HIGH_PITCH_PTU_SOUND_DELTA_PRESS_THRESHOLD_PSI) && is_ptu_rotating && !self.ptu_high_pitch_sound_active.output() + && !self.power_transfer_unit.is_in_continuous_mode() } pub fn gear_system(&self) -> &impl GearSystemSensors { @@ -6199,6 +6200,14 @@ mod tests { self.read_by_name("OVHD_HYD_EPUMPY_PB_HAS_FAULT") } + fn yellow_reservoir_has_overheat_fault(&mut self) -> bool { + self.read_by_name("HYD_YELLOW_RESERVOIR_OVHT") + } + + fn green_reservoir_has_overheat_fault(&mut self) -> bool { + self.read_by_name("HYD_GREEN_RESERVOIR_OVHT") + } + fn ptu_has_fault(&mut self) -> bool { self.read_by_name("OVHD_HYD_PTU_PB_HAS_FAULT") } @@ -10956,5 +10965,33 @@ mod tests { assert!(test_bed.is_all_gears_really_up()); assert!(test_bed.is_all_doors_really_up()); } + + #[test] + #[ignore] + fn empty_green_reservoir_causes_yellow_overheat_if_ptu_on() { + let mut test_bed = test_bed_in_flight_with() + .set_cold_dark_inputs() + .in_flight() + .run_waiting_for(Duration::from_secs_f64(1.)); + + test_bed.fail(FailureType::ReservoirLeak(HydraulicColor::Green)); + + test_bed = test_bed.run_waiting_for(Duration::from_secs_f64(120.)); + assert!(test_bed.yellow_reservoir_has_overheat_fault()); + } + + #[test] + #[ignore] + fn empty_yellow_reservoir_causes_green_overheat_if_ptu_on() { + let mut test_bed = test_bed_in_flight_with() + .set_cold_dark_inputs() + .in_flight() + .run_waiting_for(Duration::from_secs_f64(1.)); + + test_bed.fail(FailureType::ReservoirLeak(HydraulicColor::Yellow)); + + test_bed = test_bed.run_waiting_for(Duration::from_secs_f64(120.)); + assert!(test_bed.green_reservoir_has_overheat_fault()); + } } } diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index c363485dde1..e0fba706afb 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -364,8 +364,8 @@ impl PowerTransferUnit { const THRESHOLD_DELTA_TO_DECLARE_CONTINUOUS_RPM: f64 = 400.; const DURATION_BEFORE_CAPTURING_BARK_STRENGTH_SPEED: Duration = Duration::from_millis(133); - const HEATING_TIME_CONSTANT_MEAN_S: f64 = 60.; - const HEATING_TIME_CONSTANT_STD_S: f64 = 10.; + const HEATING_TIME_CONSTANT_MEAN_S: f64 = 20.; + const HEATING_TIME_CONSTANT_STD_S: f64 = 5.; const COOLING_TIME_CONSTANT: Duration = Duration::from_secs(60 * 3); const DAMAGE_TIME_CONSTANT: Duration = Duration::from_secs(60 * 3); @@ -466,7 +466,8 @@ impl PowerTransferUnit { self.heat_state.update( context, - self.shaft_speed.get::() > Self::MAX_SPEED_BEFORE_HEATING_UP_RPM, + self.shaft_speed.get::().abs() + > Self::MAX_SPEED_BEFORE_HEATING_UP_RPM, ); } From 05a1e4082dd48e6e757c2ef614e2ea645e299ee5 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Mon, 14 Nov 2022 15:20:49 +0100 Subject: [PATCH 23/39] generic pump identifiers --- .../src/main.rs | 8 +- src/systems/a320_systems/src/hydraulic/mod.rs | 19 ++--- src/systems/a320_systems_wasm/src/lib.rs | 14 ++-- src/systems/a380_systems/src/hydraulic/mod.rs | 19 ++--- src/systems/systems/src/failures/mod.rs | 9 ++- .../src/hydraulic/electrical_pump_physics.rs | 9 ++- src/systems/systems/src/hydraulic/mod.rs | 9 ++- src/systems/systems/src/shared/mod.rs | 74 +++++++++++++++++++ 8 files changed, 124 insertions(+), 37 deletions(-) diff --git a/src/systems/a320_hydraulic_simulation_graphs/src/main.rs b/src/systems/a320_hydraulic_simulation_graphs/src/main.rs index 382c9d7e557..3767bd36c85 100644 --- a/src/systems/a320_hydraulic_simulation_graphs/src/main.rs +++ b/src/systems/a320_hydraulic_simulation_graphs/src/main.rs @@ -10,8 +10,8 @@ use systems::hydraulic::*; use systems::{ electrical::{test::TestElectricitySource, ElectricalBus, Electricity}, shared::{ - update_iterator::FixedStepLoop, ElectricalBusType, HydraulicColor, PotentialOrigin, - ReservoirAirPressure, + update_iterator::FixedStepLoop, AirbusElectricPumpId, AirbusEngineDrivenPumpId, + ElectricalBusType, HydraulicColor, PotentialOrigin, ReservoirAirPressure, }, simulation::{ test::{SimulationTestBed, TestBed}, @@ -358,7 +358,7 @@ fn hydraulic_loop(context: &mut InitContext, loop_color: HydraulicColor) -> Hydr fn electric_pump(context: &mut InitContext) -> ElectricPump { ElectricPump::new( context, - HydraulicColor::Green, + AirbusElectricPumpId::Green, ElectricalBusType::AlternatingCurrentGndFltService, ElectricCurrent::new::(45.), PumpCharacteristics::a320_electric_pump(), @@ -368,7 +368,7 @@ fn electric_pump(context: &mut InitContext) -> ElectricPump { fn _engine_driven_pump(context: &mut InitContext) -> EngineDrivenPump { EngineDrivenPump::new( context, - HydraulicColor::Green, + AirbusEngineDrivenPumpId::Green, PumpCharacteristics::a320_edp(), ) } diff --git a/src/systems/a320_systems/src/hydraulic/mod.rs b/src/systems/a320_systems/src/hydraulic/mod.rs index 47b28c9b755..956db07daa7 100644 --- a/src/systems/a320_systems/src/hydraulic/mod.rs +++ b/src/systems/a320_systems/src/hydraulic/mod.rs @@ -55,11 +55,12 @@ use systems::{ low_pass_filter::LowPassFilter, random_from_normal_distribution, random_from_range, update_iterator::{FixedStepLoop, MaxStepLoop}, - AdirsDiscreteOutputs, DelayedFalseLogicGate, DelayedPulseTrueLogicGate, - DelayedTrueLogicGate, ElectricalBusType, ElectricalBuses, EmergencyElectricalRatPushButton, - EmergencyElectricalState, EmergencyGeneratorPower, EngineFirePushButtons, GearWheel, - HydraulicColor, HydraulicGeneratorControlUnit, LandingGearHandle, LgciuInterface, - LgciuWeightOnWheels, ReservoirAirPressure, SectionPressure, + AdirsDiscreteOutputs, AirbusElectricPumpId, AirbusEngineDrivenPumpId, + DelayedFalseLogicGate, DelayedPulseTrueLogicGate, DelayedTrueLogicGate, ElectricalBusType, + ElectricalBuses, EmergencyElectricalRatPushButton, EmergencyElectricalState, + EmergencyGeneratorPower, EngineFirePushButtons, GearWheel, HydraulicColor, + HydraulicGeneratorControlUnit, LandingGearHandle, LgciuInterface, LgciuWeightOnWheels, + ReservoirAirPressure, SectionPressure, }, simulation::{ InitContext, Read, Reader, SimulationElement, SimulationElementVisitor, SimulatorReader, @@ -1500,7 +1501,7 @@ impl A320Hydraulic { engine_driven_pump_1: EngineDrivenPump::new( context, - HydraulicColor::Green, + AirbusEngineDrivenPumpId::Green, PumpCharacteristics::a320_edp(), ), engine_driven_pump_1_controller: A320EngineDrivenPumpController::new( @@ -1511,7 +1512,7 @@ impl A320Hydraulic { engine_driven_pump_2: EngineDrivenPump::new( context, - HydraulicColor::Yellow, + AirbusEngineDrivenPumpId::Yellow, PumpCharacteristics::a320_edp(), ), engine_driven_pump_2_controller: A320EngineDrivenPumpController::new( @@ -1525,7 +1526,7 @@ impl A320Hydraulic { blue_electric_pump: ElectricPump::new( context, - HydraulicColor::Blue, + AirbusElectricPumpId::Blue, Self::BLUE_ELEC_PUMP_SUPPLY_POWER_BUS, ElectricCurrent::new::(Self::ELECTRIC_PUMP_MAX_CURRENT_AMPERE), PumpCharacteristics::a320_electric_pump(), @@ -1537,7 +1538,7 @@ impl A320Hydraulic { yellow_electric_pump: ElectricPump::new( context, - HydraulicColor::Yellow, + AirbusElectricPumpId::Yellow, Self::YELLOW_ELEC_PUMP_SUPPLY_POWER_BUS, ElectricCurrent::new::(Self::ELECTRIC_PUMP_MAX_CURRENT_AMPERE), PumpCharacteristics::a320_electric_pump(), diff --git a/src/systems/a320_systems_wasm/src/lib.rs b/src/systems/a320_systems_wasm/src/lib.rs index f657a234c39..bb1e2438e48 100644 --- a/src/systems/a320_systems_wasm/src/lib.rs +++ b/src/systems/a320_systems_wasm/src/lib.rs @@ -22,7 +22,8 @@ use spoilers::spoilers; use std::error::Error; use systems::failures::FailureType; use systems::shared::{ - ElectricalBusType, GearActuatorId, HydraulicColor, LgciuId, ProximityDetectorId, + AirbusElectricPumpId, AirbusEngineDrivenPumpId, ElectricalBusType, GearActuatorId, + HydraulicColor, LgciuId, ProximityDetectorId, }; use systems_wasm::aspects::ExecuteOn; use systems_wasm::{MsfsSimulationBuilder, Variable}; @@ -82,16 +83,19 @@ async fn systems(mut gauge: msfs::Gauge) -> Result<(), Box> { ), ( 29_009, - FailureType::EnginePumpOverheat(HydraulicColor::Green), + FailureType::EnginePumpOverheat(AirbusEngineDrivenPumpId::Green), ), ( 29_011, - FailureType::EnginePumpOverheat(HydraulicColor::Yellow), + FailureType::EnginePumpOverheat(AirbusEngineDrivenPumpId::Yellow), + ), + ( + 29_010, + FailureType::ElecPumpOverheat(AirbusElectricPumpId::Blue), ), - (29_010, FailureType::ElecPumpOverheat(HydraulicColor::Blue)), ( 29_012, - FailureType::ElecPumpOverheat(HydraulicColor::Yellow), + FailureType::ElecPumpOverheat(AirbusElectricPumpId::Yellow), ), (32_000, FailureType::LgciuPowerSupply(LgciuId::Lgciu1)), (32_001, FailureType::LgciuPowerSupply(LgciuId::Lgciu2)), diff --git a/src/systems/a380_systems/src/hydraulic/mod.rs b/src/systems/a380_systems/src/hydraulic/mod.rs index cab3d384050..2d06bb5c2af 100644 --- a/src/systems/a380_systems/src/hydraulic/mod.rs +++ b/src/systems/a380_systems/src/hydraulic/mod.rs @@ -55,11 +55,12 @@ use systems::{ low_pass_filter::LowPassFilter, random_from_normal_distribution, random_from_range, update_iterator::{FixedStepLoop, MaxStepLoop}, - AdirsDiscreteOutputs, DelayedFalseLogicGate, DelayedPulseTrueLogicGate, - DelayedTrueLogicGate, ElectricalBusType, ElectricalBuses, EmergencyElectricalRatPushButton, - EmergencyElectricalState, EmergencyGeneratorPower, EngineFirePushButtons, GearWheel, - HydraulicColor, HydraulicGeneratorControlUnit, LandingGearHandle, LgciuInterface, - LgciuWeightOnWheels, ReservoirAirPressure, SectionPressure, + AdirsDiscreteOutputs, AirbusElectricPumpId, AirbusEngineDrivenPumpId, + DelayedFalseLogicGate, DelayedPulseTrueLogicGate, DelayedTrueLogicGate, ElectricalBusType, + ElectricalBuses, EmergencyElectricalRatPushButton, EmergencyElectricalState, + EmergencyGeneratorPower, EngineFirePushButtons, GearWheel, HydraulicColor, + HydraulicGeneratorControlUnit, LandingGearHandle, LgciuInterface, LgciuWeightOnWheels, + ReservoirAirPressure, SectionPressure, }, simulation::{ InitContext, Read, Reader, SimulationElement, SimulationElementVisitor, SimulatorReader, @@ -1488,7 +1489,7 @@ impl A380Hydraulic { engine_driven_pump_1: EngineDrivenPump::new( context, - HydraulicColor::Green, + AirbusEngineDrivenPumpId::Green, PumpCharacteristics::a380_edp(), ), engine_driven_pump_1_controller: A380EngineDrivenPumpController::new( @@ -1499,7 +1500,7 @@ impl A380Hydraulic { engine_driven_pump_2: EngineDrivenPump::new( context, - HydraulicColor::Yellow, + AirbusEngineDrivenPumpId::Yellow, PumpCharacteristics::a380_edp(), ), engine_driven_pump_2_controller: A380EngineDrivenPumpController::new( @@ -1513,7 +1514,7 @@ impl A380Hydraulic { blue_electric_pump: ElectricPump::new( context, - HydraulicColor::Blue, + AirbusElectricPumpId::Blue, Self::BLUE_ELEC_PUMP_SUPPLY_POWER_BUS, ElectricCurrent::new::(Self::ELECTRIC_PUMP_MAX_CURRENT_AMPERE), PumpCharacteristics::a320_electric_pump(), @@ -1525,7 +1526,7 @@ impl A380Hydraulic { yellow_electric_pump: ElectricPump::new( context, - HydraulicColor::Yellow, + AirbusElectricPumpId::Yellow, Self::YELLOW_ELEC_PUMP_SUPPLY_POWER_BUS, ElectricCurrent::new::(Self::ELECTRIC_PUMP_MAX_CURRENT_AMPERE), PumpCharacteristics::a320_electric_pump(), diff --git a/src/systems/systems/src/failures/mod.rs b/src/systems/systems/src/failures/mod.rs index 6814eadf11f..fbbc5ed737b 100644 --- a/src/systems/systems/src/failures/mod.rs +++ b/src/systems/systems/src/failures/mod.rs @@ -1,4 +1,7 @@ -use crate::shared::{GearActuatorId, HydraulicColor, LgciuId, ProximityDetectorId}; +use crate::shared::{ + AirbusElectricPumpId, AirbusEngineDrivenPumpId, GearActuatorId, HydraulicColor, LgciuId, + ProximityDetectorId, +}; use crate::simulation::SimulationElement; #[derive(Clone, Copy, PartialEq)] @@ -7,8 +10,8 @@ pub enum FailureType { ReservoirLeak(HydraulicColor), ReservoirAirLeak(HydraulicColor), ReservoirReturnLeak(HydraulicColor), - EnginePumpOverheat(HydraulicColor), - ElecPumpOverheat(HydraulicColor), + EnginePumpOverheat(AirbusEngineDrivenPumpId), + ElecPumpOverheat(AirbusElectricPumpId), LgciuPowerSupply(LgciuId), LgciuInternalError(LgciuId), GearProxSensorDamage(ProximityDetectorId), diff --git a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs index 4b8d3e33bd8..17f7e7e95da 100644 --- a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs +++ b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs @@ -11,16 +11,19 @@ use uom::si::{ volume::cubic_inch, }; -use crate::failures::{Failure, FailureType}; use crate::hydraulic::{HeatingElement, HeatingProperties, SectionPressure}; use crate::shared::{ low_pass_filter::LowPassFilter, pid::PidController, random_from_normal_distribution, - ConsumePower, ElectricalBusType, ElectricalBuses, HydraulicColor, + ConsumePower, ElectricalBusType, ElectricalBuses, }; use crate::simulation::{ InitContext, SimulationElement, SimulationElementVisitor, SimulatorWriter, UpdateContext, VariableIdentifier, Write, }; +use crate::{ + failures::{Failure, FailureType}, + shared::AirbusElectricPumpId, +}; use std::time::Duration; @@ -76,7 +79,7 @@ impl ElectricalPumpPhysics { pub fn new( context: &mut InitContext, - id: HydraulicColor, + id: AirbusElectricPumpId, bus_type: ElectricalBusType, max_current: ElectricCurrent, regulated_speed: AngularVelocity, diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index e0fba706afb..ea5bc9db73e 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -4,10 +4,11 @@ use crate::hydraulic::{ electrical_pump_physics::ElectricalPumpPhysics, pumps::PumpCharacteristics, }; use crate::pneumatic::PressurizeableReservoir; + use crate::shared::{ interpolation, low_pass_filter::LowPassFilter, random_from_normal_distribution, - random_from_range, DelayedTrueLogicGate, ElectricalBusType, ElectricalBuses, HydraulicColor, - SectionPressure, + random_from_range, AirbusElectricPumpId, AirbusEngineDrivenPumpId, DelayedTrueLogicGate, + ElectricalBusType, ElectricalBuses, HydraulicColor, SectionPressure, }; use crate::simulation::{ InitContext, Read, SimulationElement, SimulationElementVisitor, SimulatorReader, @@ -2512,7 +2513,7 @@ pub struct ElectricPump { impl ElectricPump { pub fn new( context: &mut InitContext, - id: HydraulicColor, + id: AirbusElectricPumpId, bus_type: ElectricalBusType, max_current: ElectricCurrent, pump_characteristics: PumpCharacteristics, @@ -2638,7 +2639,7 @@ impl EngineDrivenPump { pub fn new( context: &mut InitContext, - id: HydraulicColor, + id: AirbusEngineDrivenPumpId, pump_characteristics: PumpCharacteristics, ) -> Self { Self { diff --git a/src/systems/systems/src/shared/mod.rs b/src/systems/systems/src/shared/mod.rs index 5b4a45cdbb3..fb5d25e8936 100644 --- a/src/systems/systems/src/shared/mod.rs +++ b/src/systems/systems/src/shared/mod.rs @@ -236,6 +236,80 @@ impl Display for HydraulicColor { } } +#[derive(Clone, Copy, PartialEq)] +pub enum AirbusEngineDrivenPumpId { + Edp1a, + Edp1b, + Edp2a, + Edp2b, + Edp3a, + Edp3b, + Edp4a, + Edp4b, + Green, + Yellow, +} +impl AirbusEngineDrivenPumpId { + fn into_engine_num(self) -> usize { + match self { + AirbusEngineDrivenPumpId::Edp1a => 1, + AirbusEngineDrivenPumpId::Edp1b => 1, + AirbusEngineDrivenPumpId::Edp2a => 2, + AirbusEngineDrivenPumpId::Edp2b => 2, + AirbusEngineDrivenPumpId::Edp3a => 3, + AirbusEngineDrivenPumpId::Edp3b => 3, + AirbusEngineDrivenPumpId::Edp4a => 4, + AirbusEngineDrivenPumpId::Edp4b => 4, + AirbusEngineDrivenPumpId::Green => 1, + AirbusEngineDrivenPumpId::Yellow => 2, + } + } + + fn into_engine_index(self) -> usize { + self.into_engine_num() - 1 + } +} +impl Display for AirbusEngineDrivenPumpId { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + AirbusEngineDrivenPumpId::Edp1a => write!(f, "GREEN_1A"), + AirbusEngineDrivenPumpId::Edp1b => write!(f, "GREEN_1B"), + AirbusEngineDrivenPumpId::Edp2a => write!(f, "GREEN_2A"), + AirbusEngineDrivenPumpId::Edp2b => write!(f, "GREEN_2B"), + AirbusEngineDrivenPumpId::Edp3a => write!(f, "YELLOW_3A"), + AirbusEngineDrivenPumpId::Edp3b => write!(f, "YELLOW_3B"), + AirbusEngineDrivenPumpId::Edp4a => write!(f, "YELLOW_4A"), + AirbusEngineDrivenPumpId::Edp4b => write!(f, "YELLOW_4B"), + AirbusEngineDrivenPumpId::Green => write!(f, "GREEN"), + AirbusEngineDrivenPumpId::Yellow => write!(f, "YELLOW"), + } + } +} + +#[derive(Clone, Copy, PartialEq)] +pub enum AirbusElectricPumpId { + GreenA, + GreenB, + YellowA, + YellowB, + Green, + Blue, + Yellow, +} +impl Display for AirbusElectricPumpId { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + AirbusElectricPumpId::GreenA => write!(f, "GA"), + AirbusElectricPumpId::YellowA => write!(f, "YA"), + AirbusElectricPumpId::GreenB => write!(f, "GB"), + AirbusElectricPumpId::YellowB => write!(f, "YB"), + AirbusElectricPumpId::Green => write!(f, "GREEN"), + AirbusElectricPumpId::Blue => write!(f, "BLUE"), + AirbusElectricPumpId::Yellow => write!(f, "YELLOW"), + } + } +} + /// The common types of electrical buses within Airbus aircraft. /// These include types such as AC, DC, AC ESS, etc. #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] From d2d9ea71fa94765b6bfe01e5147ab0c5e4db1494 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Mon, 14 Nov 2022 15:55:35 +0100 Subject: [PATCH 24/39] fix merge --- src/systems/a320_systems/src/hydraulic/mod.rs | 19 ++---------------- .../src/hydraulic/electrical_pump_physics.rs | 4 ++-- src/systems/systems/src/shared/mod.rs | 20 ------------------- 3 files changed, 4 insertions(+), 39 deletions(-) diff --git a/src/systems/a320_systems/src/hydraulic/mod.rs b/src/systems/a320_systems/src/hydraulic/mod.rs index 956db07daa7..8838989ffff 100644 --- a/src/systems/a320_systems/src/hydraulic/mod.rs +++ b/src/systems/a320_systems/src/hydraulic/mod.rs @@ -9029,11 +9029,6 @@ mod tests { test_bed = test_bed .set_autobrake_max() - .run_waiting_for(Duration::from_secs(1)); - - assert!(test_bed.autobrake_mode() == AutobrakeMode::MAX); - - test_bed = test_bed .set_deploy_ground_spoilers() .run_waiting_for(Duration::from_secs(6)); @@ -9077,11 +9072,6 @@ mod tests { test_bed = test_bed .set_autobrake_med() - .run_waiting_for(Duration::from_secs(1)); - - assert!(test_bed.autobrake_mode() == AutobrakeMode::MED); - - test_bed = test_bed .set_deploy_ground_spoilers() .run_waiting_for(Duration::from_secs(6)); @@ -9118,15 +9108,10 @@ mod tests { .set_park_brake(false) .start_eng1(Ratio::new::(100.)) .start_eng2(Ratio::new::(100.)) - .run_waiting_for(Duration::from_secs(10)); + .run_waiting_for(Duration::from_secs(5)); test_bed = test_bed .set_autobrake_med() - .run_waiting_for(Duration::from_secs(1)); - - assert!(test_bed.autobrake_mode() == AutobrakeMode::MED); - - test_bed = test_bed .set_deploy_ground_spoilers() .run_waiting_for(Duration::from_secs(6)); @@ -9165,7 +9150,7 @@ mod tests { .set_park_brake(false) .start_eng1(Ratio::new::(100.)) .start_eng2(Ratio::new::(100.)) - .run_waiting_for(Duration::from_secs(10)); + .run_waiting_for(Duration::from_secs(5)); test_bed = test_bed .set_autobrake_max() diff --git a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs index 17f7e7e95da..4817e109008 100644 --- a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs +++ b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs @@ -515,7 +515,7 @@ mod tests { >= AngularVelocity::new::(7000.) ); - test_bed.fail(FailureType::ElecPumpOverheat(HydraulicColor::Yellow)); + test_bed.fail(FailureType::ElecPumpOverheat(AirbusElectricPumpId::Yellow)); test_bed.run_with_delta(Duration::from_secs_f64( ElectricalPumpPhysics::HEATING_TIME_CONSTANT_MEAN_S @@ -537,7 +537,7 @@ mod tests { fn physical_pump(context: &mut InitContext) -> ElectricalPumpPhysics { ElectricalPumpPhysics::new( context, - HydraulicColor::Yellow, + AirbusElectricPumpId::Yellow, ElectricalBusType::AlternatingCurrent(1), ElectricCurrent::new::(45.), AngularVelocity::new::(7600.), diff --git a/src/systems/systems/src/shared/mod.rs b/src/systems/systems/src/shared/mod.rs index fb5d25e8936..dab2aef4ae1 100644 --- a/src/systems/systems/src/shared/mod.rs +++ b/src/systems/systems/src/shared/mod.rs @@ -249,26 +249,6 @@ pub enum AirbusEngineDrivenPumpId { Green, Yellow, } -impl AirbusEngineDrivenPumpId { - fn into_engine_num(self) -> usize { - match self { - AirbusEngineDrivenPumpId::Edp1a => 1, - AirbusEngineDrivenPumpId::Edp1b => 1, - AirbusEngineDrivenPumpId::Edp2a => 2, - AirbusEngineDrivenPumpId::Edp2b => 2, - AirbusEngineDrivenPumpId::Edp3a => 3, - AirbusEngineDrivenPumpId::Edp3b => 3, - AirbusEngineDrivenPumpId::Edp4a => 4, - AirbusEngineDrivenPumpId::Edp4b => 4, - AirbusEngineDrivenPumpId::Green => 1, - AirbusEngineDrivenPumpId::Yellow => 2, - } - } - - fn into_engine_index(self) -> usize { - self.into_engine_num() - 1 - } -} impl Display for AirbusEngineDrivenPumpId { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { From ed39962d52fd00f84a16973593cb2d2eef2bf686 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Fri, 18 Nov 2022 14:57:09 +0100 Subject: [PATCH 25/39] test update --- src/systems/a320_systems/src/hydraulic/mod.rs | 51 ++++++++++++++++++- .../src/hydraulic/electrical_pump_physics.rs | 2 +- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/systems/a320_systems/src/hydraulic/mod.rs b/src/systems/a320_systems/src/hydraulic/mod.rs index 8838989ffff..88072ef62ef 100644 --- a/src/systems/a320_systems/src/hydraulic/mod.rs +++ b/src/systems/a320_systems/src/hydraulic/mod.rs @@ -10953,7 +10953,6 @@ mod tests { } #[test] - #[ignore] fn empty_green_reservoir_causes_yellow_overheat_if_ptu_on() { let mut test_bed = test_bed_in_flight_with() .set_cold_dark_inputs() @@ -10967,7 +10966,6 @@ mod tests { } #[test] - #[ignore] fn empty_yellow_reservoir_causes_green_overheat_if_ptu_on() { let mut test_bed = test_bed_in_flight_with() .set_cold_dark_inputs() @@ -10979,5 +10977,54 @@ mod tests { test_bed = test_bed.run_waiting_for(Duration::from_secs_f64(120.)); assert!(test_bed.green_reservoir_has_overheat_fault()); } + + #[test] + fn green_edp_overheat_failure_causes_green_reservoir_overheat() { + let mut test_bed = test_bed_in_flight_with() + .set_cold_dark_inputs() + .in_flight() + .run_waiting_for(Duration::from_secs_f64(1.)); + + test_bed.fail(FailureType::EnginePumpOverheat( + AirbusEngineDrivenPumpId::Green, + )); + + test_bed = test_bed.run_waiting_for(Duration::from_secs_f64(120.)); + assert!(test_bed.green_reservoir_has_overheat_fault()); + } + + #[test] + fn green_edp_overheat_failure_do_not_causes_green_reservoir_overheat_if_unpressurised() { + let mut test_bed = test_bed_in_flight_with() + .set_cold_dark_inputs() + .in_flight() + .run_waiting_for(Duration::from_secs_f64(1.)); + + test_bed.fail(FailureType::EnginePumpOverheat( + AirbusEngineDrivenPumpId::Green, + )); + + test_bed = test_bed + .set_green_ed_pump(false) + .run_waiting_for(Duration::from_secs_f64(120.)); + assert!(!test_bed.green_reservoir_has_overheat_fault()); + } + + #[test] + fn yellow_edp_overheat_failure_do_not_causes_yellow_reservoir_overheat_if_unpressurised() { + let mut test_bed = test_bed_in_flight_with() + .set_cold_dark_inputs() + .in_flight() + .run_waiting_for(Duration::from_secs_f64(1.)); + + test_bed.fail(FailureType::EnginePumpOverheat( + AirbusEngineDrivenPumpId::Yellow, + )); + + test_bed = test_bed + .set_yellow_ed_pump(false) + .run_waiting_for(Duration::from_secs_f64(120.)); + assert!(!test_bed.yellow_reservoir_has_overheat_fault()); + } } } diff --git a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs index 4817e109008..d7e9f29fb1e 100644 --- a/src/systems/systems/src/hydraulic/electrical_pump_physics.rs +++ b/src/systems/systems/src/hydraulic/electrical_pump_physics.rs @@ -500,7 +500,7 @@ mod tests { } #[test] - fn pump_with_overheat_fail_overheats_and_fails() { + fn pump_with_overheat_failure_overheats_and_fails() { let mut test_bed = SimulationTestBed::new(TestAircraft::new); test_bed.command(|a| a.set_ac_1_power(true)); From e39005a3aa475c87e9be728153a80ea2664047e4 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Fri, 18 Nov 2022 16:09:23 +0100 Subject: [PATCH 26/39] merged with latest rust changes --- Cargo.lock | 183 +++++++++--------- .../src/main.rs | 2 +- src/systems/a320_systems/src/hydraulic/mod.rs | 7 +- src/systems/a380_systems/src/hydraulic/mod.rs | 4 +- src/systems/systems/src/shared/mod.rs | 4 +- 5 files changed, 102 insertions(+), 98 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b1d6c152205..793f28bc77c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,9 +80,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "0.7.18" +version = "0.7.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +checksum = "b4f55bd91a0978cbfd91c457a164bab8b4001c833b7f323132c0a4e1922dd44e" dependencies = [ "memchr", ] @@ -124,9 +124,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.65" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11a17d453482a265fd5f8479f2a3f405566e6ca627837aaddb85af8b1ab8ef61" +checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" dependencies = [ "addr2line", "cc", @@ -180,9 +180,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cc" -version = "1.0.73" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "76a284da2e6fe2092f2353e51713435363112dfd60030e22add80be333fb928f" [[package]] name = "cexpr" @@ -201,9 +201,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clang-sys" -version = "1.3.3" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a050e2153c5be08febd6734e29298e844fdb0fa21aeddd63b4eb7baa106c69b" +checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3" dependencies = [ "glob", "libc", @@ -227,9 +227,9 @@ dependencies = [ [[package]] name = "either" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" [[package]] name = "enum_dispatch" @@ -245,9 +245,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.9.0" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3" +checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" dependencies = [ "atty", "humantime", @@ -280,9 +280,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.21" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" +checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" dependencies = [ "futures-channel", "futures-core", @@ -295,9 +295,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.21" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" +checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" dependencies = [ "futures-core", "futures-sink", @@ -305,15 +305,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.21" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" [[package]] name = "futures-executor" -version = "0.3.21" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" +checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" dependencies = [ "futures-core", "futures-task", @@ -322,15 +322,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.21" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" +checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" [[package]] name = "futures-macro" -version = "0.3.21" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" +checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" dependencies = [ "proc-macro2", "quote", @@ -339,21 +339,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.21" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" +checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" [[package]] name = "futures-task" -version = "0.3.21" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" +checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" [[package]] name = "futures-util" -version = "0.3.21" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" +checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" dependencies = [ "futures-channel", "futures-core", @@ -378,9 +378,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.5" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", "version_check", @@ -388,9 +388,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if", "libc", @@ -399,9 +399,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" [[package]] name = "glob" @@ -438,15 +438,15 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.126" +version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" [[package]] name = "libloading" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efbc0f03f9a775e9f6aed295c6a1ba2253c5757a9e03d55c6caa46a681abcddd" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" dependencies = [ "cfg-if", "winapi", @@ -454,9 +454,9 @@ dependencies = [ [[package]] name = "libm" -version = "0.2.2" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33a33a362ce288760ec6a508b94caaec573ae7d3bbbd91b87aa0bad4456839db" +checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb" [[package]] name = "log" @@ -490,9 +490,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" +checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" dependencies = [ "adler", ] @@ -645,24 +645,24 @@ dependencies = [ [[package]] name = "object" -version = "0.28.4" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.12.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" [[package]] name = "paste" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c520e05135d6e763148b6426a837e239041653ba7becd2e538c076c738025fc" +checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" [[package]] name = "peeking_take_while" @@ -672,10 +672,11 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" [[package]] name = "pest" -version = "2.1.3" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +checksum = "a528564cc62c19a7acac4d81e01f39e53e25e17b934878f4c6d25cc2836e62f8" dependencies = [ + "thiserror", "ucd-trie", ] @@ -703,34 +704,35 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro-crate" -version = "1.1.3" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" +checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" dependencies = [ + "once_cell", "thiserror", "toml", ] [[package]] name = "proc-macro2" -version = "1.0.40" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" dependencies = [ "proc-macro2", ] @@ -758,9 +760,9 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ "getrandom", ] @@ -783,9 +785,9 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "regex" -version = "1.5.6" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1" +checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" dependencies = [ "aho-corasick", "memchr", @@ -794,9 +796,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.26" +version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" [[package]] name = "rstest" @@ -858,18 +860,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.137" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" +checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.137" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" +checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" dependencies = [ "proc-macro2", "quote", @@ -896,9 +898,12 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] [[package]] name = "strsim" @@ -914,9 +919,9 @@ checksum = "3685c82a045a6af0c488f0550b0f52b4c77d2a52b0ca8aba719f9d268fa96965" [[package]] name = "syn" -version = "1.0.98" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" +checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" dependencies = [ "proc-macro2", "quote", @@ -982,18 +987,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.31" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.31" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" dependencies = [ "proc-macro2", "quote", @@ -1017,27 +1022,27 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "ucd-trie" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" +checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" [[package]] name = "unicode-ident" -version = "1.0.1" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" [[package]] name = "unicode-width" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] name = "unicode-xid" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "uom" @@ -1069,13 +1074,13 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "which" -version = "4.2.5" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae" +checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" dependencies = [ "either", - "lazy_static", "libc", + "once_cell", ] [[package]] diff --git a/src/systems/a320_hydraulic_simulation_graphs/src/main.rs b/src/systems/a320_hydraulic_simulation_graphs/src/main.rs index b1b15da5a19..3767bd36c85 100644 --- a/src/systems/a320_hydraulic_simulation_graphs/src/main.rs +++ b/src/systems/a320_hydraulic_simulation_graphs/src/main.rs @@ -503,7 +503,7 @@ impl Aircraft for A320SimpleMainElecHydraulicsTestAircraft { self.hydraulic_circuit.update( &context.with_delta(cur_time_step), - &mut [&mut self.elec_pump], + &mut vec![&mut self.elec_pump], None::<&mut ElectricPump>, None::<&mut ElectricPump>, None, diff --git a/src/systems/a320_systems/src/hydraulic/mod.rs b/src/systems/a320_systems/src/hydraulic/mod.rs index 10db0eec350..df28e65b139 100644 --- a/src/systems/a320_systems/src/hydraulic/mod.rs +++ b/src/systems/a320_systems/src/hydraulic/mod.rs @@ -2296,7 +2296,7 @@ impl A320Hydraulic { ); self.green_circuit.update( context, - &mut [&mut self.engine_driven_pump_1], + &mut vec![&mut self.engine_driven_pump_1], None::<&mut ElectricPump>, None::<&mut ElectricPump>, Some(&self.power_transfer_unit), @@ -2312,7 +2312,7 @@ impl A320Hydraulic { ); self.yellow_circuit.update( context, - &mut [&mut self.engine_driven_pump_2], + &mut vec![&mut self.engine_driven_pump_2], Some(&mut self.yellow_electric_pump), None::<&mut ElectricPump>, Some(&self.power_transfer_unit), @@ -2328,7 +2328,7 @@ impl A320Hydraulic { ); self.blue_circuit.update( context, - &mut [&mut self.blue_electric_pump], + &mut vec![&mut self.blue_electric_pump], Some(&mut self.ram_air_turbine), None::<&mut ElectricPump>, None, @@ -9124,7 +9124,6 @@ mod tests { .start_eng2(Ratio::new::(100.)) .run_waiting_for(Duration::from_secs(3)); - test_bed = test_bed .set_autobrake_med() .set_deploy_ground_spoilers() diff --git a/src/systems/a380_systems/src/hydraulic/mod.rs b/src/systems/a380_systems/src/hydraulic/mod.rs index 2e549bb7714..de3464b9d34 100644 --- a/src/systems/a380_systems/src/hydraulic/mod.rs +++ b/src/systems/a380_systems/src/hydraulic/mod.rs @@ -2148,7 +2148,7 @@ impl A380Hydraulic { self.green_circuit.update( context, - &mut [ + &mut vec![ &mut self.engine_driven_pump_1a, &mut self.engine_driven_pump_1b, &mut self.engine_driven_pump_2a, @@ -2173,7 +2173,7 @@ impl A380Hydraulic { ); self.yellow_circuit.update( context, - &mut [ + &mut vec![ &mut self.engine_driven_pump_3a, &mut self.engine_driven_pump_3b, &mut self.engine_driven_pump_4a, diff --git a/src/systems/systems/src/shared/mod.rs b/src/systems/systems/src/shared/mod.rs index 6701c8b1eef..1307b07b1dd 100644 --- a/src/systems/systems/src/shared/mod.rs +++ b/src/systems/systems/src/shared/mod.rs @@ -236,7 +236,7 @@ impl Display for HydraulicColor { } } -#[derive(Clone, Copy, PartialEq)] +#[derive(Clone, Copy, PartialEq, Eq)] pub enum AirbusEngineDrivenPumpId { Edp1a, Edp1b, @@ -266,7 +266,7 @@ impl Display for AirbusEngineDrivenPumpId { } } -#[derive(Clone, Copy, PartialEq)] +#[derive(Clone, Copy, PartialEq, Eq)] pub enum AirbusElectricPumpId { GreenA, GreenB, From b427bc98e25ef945ef19580944878c7297dec592 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Fri, 18 Nov 2022 16:12:50 +0100 Subject: [PATCH 27/39] update test profile fixing stack overflow --- Cargo.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 4d96e2d5457..d0f18d3834b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,3 +13,9 @@ members = [ [profile.release] lto = true strip = true + +[profile.test] +opt-level=1 +lto = false +debug-assertions=true +debug=true From 1c9e260cfe55f9ac8207470141b04902022cd28b Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Fri, 18 Nov 2022 16:35:16 +0100 Subject: [PATCH 28/39] fix OVHT SD ecam that disapeared --- src/instruments/src/SD/Pages/Hyd/Hyd.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/instruments/src/SD/Pages/Hyd/Hyd.tsx b/src/instruments/src/SD/Pages/Hyd/Hyd.tsx index 134f9bddfad..7050243bd55 100644 --- a/src/instruments/src/SD/Pages/Hyd/Hyd.tsx +++ b/src/instruments/src/SD/Pages/Hyd/Hyd.tsx @@ -295,6 +295,10 @@ const HydReservoir = ({ system, x, y, lowLevel } : HydReservoirProps) => { LO AIR PRESS + + { /* Not sure about the exact placement, have to wait for an IRL ref */ } + OVHT + ); }; From 0867664c5070eb6e2f4cda52339f047c17ad7dee Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Fri, 18 Nov 2022 18:13:53 +0100 Subject: [PATCH 29/39] clippy --- src/systems/systems/src/hydraulic/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index 6746d1f1b33..5f41e441aab 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -1151,7 +1151,7 @@ impl HydraulicCircuit { fn update_pumps( &mut self, context: &UpdateContext, - main_section_pumps: &mut Vec<&mut dyn HeatingPressureSource>, + main_section_pumps: &mut [&mut dyn HeatingPressureSource], system_section_pump: Option<&mut impl HeatingPressureSource>, auxiliary_section_pump: Option<&mut impl HeatingPressureSource>, ) { @@ -1203,7 +1203,7 @@ impl HydraulicCircuit { fn update_maximum_pumping_capacities( &mut self, - main_section_pumps: &mut Vec<&mut dyn HeatingPressureSource>, + main_section_pumps: &mut [&mut dyn HeatingPressureSource], system_section_pump: &Option<&mut impl HeatingPressureSource>, auxiliary_section_pump: &Option<&mut impl HeatingPressureSource>, ) { From 27fb28469db17feb7ef91333f092a95b8cdde910 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Mon, 19 Dec 2022 17:06:43 +0100 Subject: [PATCH 30/39] Update CHANGELOG.md --- .github/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md index f86392f3225..3c684b8be62 100644 --- a/.github/CHANGELOG.md +++ b/.github/CHANGELOG.md @@ -11,6 +11,7 @@ 1. [FMGC] Show proper transition names and final approach slope from AAU1 - @tracernz (Mike) 1. [FMGC] Don't accept blank input or / for hold distance - @tracernz (Mike) 1. [ATSU] Fix LSK6L not returning to ATSU DATALINK page in ATC MENU - @BravoMike99 (Bruno_pt99#5802) +1. [HYD] Simple temperature simulation - @Crocket63 (crocket) ## 0.9.0 @@ -105,7 +106,6 @@ 1. [FLIGHTMODEL] Flight Model update - @donstim (donbikes#4084) 1. [HYD] Fix incorrect gain in down pitch commands - @Crocket63 (crocket) 1. [PFD] Improve appearance of L/DEV and V/DEV scales - @tracernz (Mike) -1. [HYD] Simple temperature simulation - @Crocket63 (crocket) 1. [HYD] Implemented Electro Hydrostatic actuators - @Crocket63 (crocket) 1. [MISC] Change 2 way overhead switches to be also controllable with mouse wheel up/down @patsta32 (Pat) 1. [FAC] Move Speedscale computation to FAC - @lukecologne (luke) From 9283b94e5016cd646424cc5d273a563a78e77585 Mon Sep 17 00:00:00 2001 From: crocket63 <38904654+crocket63@users.noreply.github.com> Date: Mon, 19 Dec 2022 17:15:12 +0100 Subject: [PATCH 31/39] Update src/systems/a320_systems_wasm/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Pascal Störzbach --- src/systems/a320_systems_wasm/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/systems/a320_systems_wasm/src/lib.rs b/src/systems/a320_systems_wasm/src/lib.rs index bb1e2438e48..bb07bf3430e 100644 --- a/src/systems/a320_systems_wasm/src/lib.rs +++ b/src/systems/a320_systems_wasm/src/lib.rs @@ -85,14 +85,14 @@ async fn systems(mut gauge: msfs::Gauge) -> Result<(), Box> { 29_009, FailureType::EnginePumpOverheat(AirbusEngineDrivenPumpId::Green), ), - ( - 29_011, - FailureType::EnginePumpOverheat(AirbusEngineDrivenPumpId::Yellow), - ), ( 29_010, FailureType::ElecPumpOverheat(AirbusElectricPumpId::Blue), ), + ( + 29_011, + FailureType::EnginePumpOverheat(AirbusEngineDrivenPumpId::Yellow), + ), ( 29_012, FailureType::ElecPumpOverheat(AirbusElectricPumpId::Yellow), From 78d8d4760f6d8c43a5e9d67c9fc6a93114824852 Mon Sep 17 00:00:00 2001 From: crocket63 <38904654+crocket63@users.noreply.github.com> Date: Mon, 19 Dec 2022 17:17:27 +0100 Subject: [PATCH 32/39] Update src/systems/systems/src/hydraulic/mod.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Pascal Störzbach --- src/systems/systems/src/hydraulic/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index 5f41e441aab..fb13b0ee229 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -260,7 +260,7 @@ impl HeatingProperties { } /// When overheating, provides a ratio of the heating severity - /// Above OVERHEATING_THRESHOLD it will rise from 0 to 1, while always 0 under the threshold + /// Above OVERHEATING_THRESHOLD it will rise from 0 to 1, while always 0 under the threshold fn overheat_ratio(&self) -> Ratio { Ratio::new::( ((self.heat_factor.output().get::() - Self::OVERHEATING_THRESHOLD) * 1. From e9acedf1c4772b60899a15f6f07956567ea113f6 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Mon, 19 Dec 2022 17:25:38 +0100 Subject: [PATCH 33/39] removed vectors --- src/systems/a320_hydraulic_simulation_graphs/src/main.rs | 2 +- src/systems/a320_systems/src/hydraulic/mod.rs | 6 +++--- src/systems/a380_systems/src/hydraulic/mod.rs | 4 ++-- src/systems/systems/src/hydraulic/mod.rs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/systems/a320_hydraulic_simulation_graphs/src/main.rs b/src/systems/a320_hydraulic_simulation_graphs/src/main.rs index 3767bd36c85..b1b15da5a19 100644 --- a/src/systems/a320_hydraulic_simulation_graphs/src/main.rs +++ b/src/systems/a320_hydraulic_simulation_graphs/src/main.rs @@ -503,7 +503,7 @@ impl Aircraft for A320SimpleMainElecHydraulicsTestAircraft { self.hydraulic_circuit.update( &context.with_delta(cur_time_step), - &mut vec![&mut self.elec_pump], + &mut [&mut self.elec_pump], None::<&mut ElectricPump>, None::<&mut ElectricPump>, None, diff --git a/src/systems/a320_systems/src/hydraulic/mod.rs b/src/systems/a320_systems/src/hydraulic/mod.rs index df28e65b139..f19f38eb42e 100644 --- a/src/systems/a320_systems/src/hydraulic/mod.rs +++ b/src/systems/a320_systems/src/hydraulic/mod.rs @@ -2296,7 +2296,7 @@ impl A320Hydraulic { ); self.green_circuit.update( context, - &mut vec![&mut self.engine_driven_pump_1], + &mut [&mut self.engine_driven_pump_1], None::<&mut ElectricPump>, None::<&mut ElectricPump>, Some(&self.power_transfer_unit), @@ -2312,7 +2312,7 @@ impl A320Hydraulic { ); self.yellow_circuit.update( context, - &mut vec![&mut self.engine_driven_pump_2], + &mut [&mut self.engine_driven_pump_2], Some(&mut self.yellow_electric_pump), None::<&mut ElectricPump>, Some(&self.power_transfer_unit), @@ -2328,7 +2328,7 @@ impl A320Hydraulic { ); self.blue_circuit.update( context, - &mut vec![&mut self.blue_electric_pump], + &mut [&mut self.blue_electric_pump], Some(&mut self.ram_air_turbine), None::<&mut ElectricPump>, None, diff --git a/src/systems/a380_systems/src/hydraulic/mod.rs b/src/systems/a380_systems/src/hydraulic/mod.rs index ef6fc1d65ca..3c0cf6e9bd9 100644 --- a/src/systems/a380_systems/src/hydraulic/mod.rs +++ b/src/systems/a380_systems/src/hydraulic/mod.rs @@ -2207,7 +2207,7 @@ impl A380Hydraulic { self.green_circuit.update( context, - &mut vec![ + &mut [ &mut self.engine_driven_pump_1a, &mut self.engine_driven_pump_1b, &mut self.engine_driven_pump_2a, @@ -2232,7 +2232,7 @@ impl A380Hydraulic { ); self.yellow_circuit.update( context, - &mut vec![ + &mut [ &mut self.engine_driven_pump_3a, &mut self.engine_driven_pump_3b, &mut self.engine_driven_pump_4a, diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index 5f41e441aab..637b0febdd3 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -1047,7 +1047,7 @@ impl HydraulicCircuit { pub fn update( &mut self, context: &UpdateContext, - main_section_pumps: &mut Vec<&mut dyn HeatingPressureSource>, + main_section_pumps: &mut [&mut dyn HeatingPressureSource], system_section_pump: Option<&mut impl HeatingPressureSource>, auxiliary_section_pump: Option<&mut impl HeatingPressureSource>, ptu: Option<&PowerTransferUnit>, @@ -1055,7 +1055,7 @@ impl HydraulicCircuit { reservoir_pressure: Pressure, ) { let mut any_pump_is_overheating = false; - for pump in main_section_pumps.as_slice() { + for pump in main_section_pumps.iter() { if pump.flow().get::() > 0.01 && pump.is_overheating() { any_pump_is_overheating = true; } From 296b57f08afb870c5130fd91f66b5193814046c2 Mon Sep 17 00:00:00 2001 From: crocket63 <38904654+crocket63@users.noreply.github.com> Date: Mon, 19 Dec 2022 17:28:30 +0100 Subject: [PATCH 34/39] Update src/systems/systems/src/hydraulic/mod.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Pascal Störzbach --- src/systems/systems/src/hydraulic/mod.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index 258fe93f96c..aa59888d0e0 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -1073,11 +1073,7 @@ impl HydraulicCircuit { } } - let ptu_overheats_fluid = if let Some(ptu) = ptu.as_ref() { - ptu.is_overheating() && ptu.is_rotating() - } else { - false - }; + let ptu_overheats_fluid = ptu.map_or(false, |p| p.is_overheating() && p.is_rotating()); self.fluid .update(context, ptu_overheats_fluid || any_pump_is_overheating); From a19388b2ae1c6fe0bb0b2539de4955787b78e79b Mon Sep 17 00:00:00 2001 From: crocket63 <38904654+crocket63@users.noreply.github.com> Date: Mon, 19 Dec 2022 17:29:11 +0100 Subject: [PATCH 35/39] Update src/systems/systems/src/hydraulic/mod.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Pascal Störzbach --- src/systems/systems/src/hydraulic/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index aa59888d0e0..a660b33bf80 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -3002,7 +3002,7 @@ mod tests { } fn nominal() -> Self { - Self { is_hot: true } + Self { is_hot: false } } } impl HeatingElement for TestFluid { From c8d4100d3377202eec45140142bf97786440c3da Mon Sep 17 00:00:00 2001 From: crocket63 <38904654+crocket63@users.noreply.github.com> Date: Mon, 19 Dec 2022 17:35:02 +0100 Subject: [PATCH 36/39] Update src/systems/systems/src/hydraulic/mod.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Pascal Störzbach --- src/systems/systems/src/hydraulic/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index a660b33bf80..c2f92fb6c8b 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -215,6 +215,7 @@ pub trait HeatingElement { false } } + pub trait HeatingPressureSource: PressureSource + HeatingElement {} pub struct HeatingProperties { From ae0c3d0fc99da9a487c6ec4f7bcaa3f71930091a Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Mon, 19 Dec 2022 17:35:59 +0100 Subject: [PATCH 37/39] Update mod.rs --- src/systems/systems/src/hydraulic/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index a660b33bf80..3f43d358895 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -263,7 +263,7 @@ impl HeatingProperties { /// Above OVERHEATING_THRESHOLD it will rise from 0 to 1, while always 0 under the threshold fn overheat_ratio(&self) -> Ratio { Ratio::new::( - ((self.heat_factor.output().get::() - Self::OVERHEATING_THRESHOLD) * 1. + ((self.heat_factor.output().get::() - Self::OVERHEATING_THRESHOLD) / (1. - Self::OVERHEATING_THRESHOLD)) .max(0.) .min(1.), From 9d416042810ada24fec2409fc8e3238dd10cce7c Mon Sep 17 00:00:00 2001 From: lukecologne Date: Mon, 19 Dec 2022 18:08:49 +0100 Subject: [PATCH 38/39] fix(hyd): fix use imports after merge --- src/systems/a320_systems/src/hydraulic/mod.rs | 11 ++++++----- src/systems/a380_systems/src/hydraulic/mod.rs | 9 +++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/systems/a320_systems/src/hydraulic/mod.rs b/src/systems/a320_systems/src/hydraulic/mod.rs index 680c9f5a825..e7c33d7e519 100644 --- a/src/systems/a320_systems/src/hydraulic/mod.rs +++ b/src/systems/a320_systems/src/hydraulic/mod.rs @@ -60,11 +60,12 @@ use systems::{ low_pass_filter::LowPassFilter, random_from_normal_distribution, random_from_range, update_iterator::{FixedStepLoop, MaxStepLoop}, - AdirsDiscreteOutputs, DelayedFalseLogicGate, DelayedPulseTrueLogicGate, - DelayedTrueLogicGate, ElectricalBusType, ElectricalBuses, EmergencyElectricalRatPushButton, - EmergencyElectricalState, EmergencyGeneratorPower, EngineFirePushButtons, GearWheel, - HydraulicColor, HydraulicGeneratorControlUnit, LandingGearHandle, LgciuInterface, - LgciuWeightOnWheels, ReservoirAirPressure, SectionPressure, TrimmableHorizontalStabilizer, + AdirsDiscreteOutputs, AirbusElectricPumpId, AirbusEngineDrivenPumpId, + DelayedFalseLogicGate, DelayedPulseTrueLogicGate, DelayedTrueLogicGate, ElectricalBusType, + ElectricalBuses, EmergencyElectricalRatPushButton, EmergencyElectricalState, + EmergencyGeneratorPower, EngineFirePushButtons, GearWheel, HydraulicColor, + HydraulicGeneratorControlUnit, LandingGearHandle, LgciuInterface, LgciuWeightOnWheels, + ReservoirAirPressure, SectionPressure, TrimmableHorizontalStabilizer, }, simulation::{ InitContext, Read, Reader, SimulationElement, SimulationElementVisitor, SimulatorReader, diff --git a/src/systems/a380_systems/src/hydraulic/mod.rs b/src/systems/a380_systems/src/hydraulic/mod.rs index da88674ff0b..f093da09f1e 100644 --- a/src/systems/a380_systems/src/hydraulic/mod.rs +++ b/src/systems/a380_systems/src/hydraulic/mod.rs @@ -49,10 +49,11 @@ use systems::{ overhead::{AutoOffFaultPushButton, AutoOnFaultPushButton}, shared::{ interpolation, low_pass_filter::LowPassFilter, random_from_range, - update_iterator::MaxStepLoop, AdirsDiscreteOutputs, DelayedFalseLogicGate, - DelayedPulseTrueLogicGate, DelayedTrueLogicGate, ElectricalBusType, ElectricalBuses, - EngineFirePushButtons, GearWheel, HydraulicColor, LandingGearHandle, LgciuInterface, - LgciuWeightOnWheels, ReservoirAirPressure, SectionPressure, + update_iterator::MaxStepLoop, AdirsDiscreteOutputs, AirbusElectricPumpId, + AirbusEngineDrivenPumpId, DelayedFalseLogicGate, DelayedPulseTrueLogicGate, + DelayedTrueLogicGate, ElectricalBusType, ElectricalBuses, EngineFirePushButtons, GearWheel, + HydraulicColor, LandingGearHandle, LgciuInterface, LgciuWeightOnWheels, + ReservoirAirPressure, SectionPressure, }, simulation::{ InitContext, Read, Reader, SimulationElement, SimulationElementVisitor, SimulatorReader, From 439b74871d7f4450f79626ed24b92ef7f6913399 Mon Sep 17 00:00:00 2001 From: davydecorps <38904654+crocket63@users.noreply.github.com> Date: Thu, 22 Dec 2022 17:04:43 +0100 Subject: [PATCH 39/39] fix ptu overheating when theres fluid --- src/systems/a320_systems/src/hydraulic/mod.rs | 28 +++++++++++++++++++ src/systems/systems/src/hydraulic/mod.rs | 9 +++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/systems/a320_systems/src/hydraulic/mod.rs b/src/systems/a320_systems/src/hydraulic/mod.rs index e7c33d7e519..5c3f3518c9a 100644 --- a/src/systems/a320_systems/src/hydraulic/mod.rs +++ b/src/systems/a320_systems/src/hydraulic/mod.rs @@ -11278,6 +11278,34 @@ mod tests { assert!(test_bed.yellow_reservoir_has_overheat_fault()); } + #[test] + fn green_edp_off_do_not_causes_ptu_overheat_if_ptu_on_and_cycling_gear() { + let mut test_bed = test_bed_in_flight_with() + .set_cold_dark_inputs() + .with_worst_case_ptu() + .in_flight() + .set_green_ed_pump(false) + .run_waiting_for(Duration::from_secs_f64(1.)); + + test_bed = test_bed + .set_gear_lever_down() + .run_waiting_for(Duration::from_secs_f64(35.)); + + assert!(!test_bed.ptu_has_fault()); + + test_bed = test_bed + .set_gear_lever_up() + .run_waiting_for(Duration::from_secs_f64(35.)); + + assert!(!test_bed.ptu_has_fault()); + + test_bed = test_bed + .set_gear_lever_down() + .run_waiting_for(Duration::from_secs_f64(35.)); + + assert!(!test_bed.ptu_has_fault()); + } + #[test] fn empty_yellow_reservoir_causes_green_overheat_if_ptu_on() { let mut test_bed = test_bed_in_flight_with() diff --git a/src/systems/systems/src/hydraulic/mod.rs b/src/systems/systems/src/hydraulic/mod.rs index 7c107146673..7f88975be94 100644 --- a/src/systems/systems/src/hydraulic/mod.rs +++ b/src/systems/systems/src/hydraulic/mod.rs @@ -375,6 +375,9 @@ impl PowerTransferUnit { const MAX_SPEED_BEFORE_HEATING_UP_RPM: f64 = 2000.; + // We consider that ptu can't overheat if there's enough pressure on both side (it's cooled by hyd fluid) + const MIN_PRESSURE_ALLOWING_PTU_HEATING_UP_RPM: f64 = 500.; + pub fn new( context: &mut InitContext, characteristics: &impl PowerTransferUnitCharacteristics, @@ -471,7 +474,11 @@ impl PowerTransferUnit { self.heat_state.update( context, self.shaft_speed.get::().abs() - > Self::MAX_SPEED_BEFORE_HEATING_UP_RPM, + > Self::MAX_SPEED_BEFORE_HEATING_UP_RPM + && (loop_left_section.pressure().get::() + < Self::MIN_PRESSURE_ALLOWING_PTU_HEATING_UP_RPM + || loop_right_section.pressure().get::() + < Self::MIN_PRESSURE_ALLOWING_PTU_HEATING_UP_RPM), ); }