Skip to content

Commit 5e177cc

Browse files
authored
fix(press): delta pressure calculation before adirs on (flybywiresim#8648)
* fix: show xx when adirs not aligned * style: fix lint * style: reworded comment for accuracy * fix: safety valve uses ambient pressure from context * style: add comment to clarify DMC behaviour
1 parent 37f5601 commit 5e177cc

File tree

6 files changed

+207
-89
lines changed

6 files changed

+207
-89
lines changed

fbw-a32nx/src/systems/instruments/src/SD/Pages/Press/Press.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ export const PressPage: FC = () => {
5454
}, [cabinAlt]);
5555

5656
const deltaPress = splitDecimals(MathUtils.clamp(deltaPsi, -9.9, 9.9));
57+
// TODO: SDAC logic missing. Delta pressure is not available when the SDAC indication is not valid.
58+
// This happens when both the CPCs and ADRs are not sending pressure information. Here we only check
59+
// for CPC no computed data.
60+
const deltaPressNotAvail = arincDeltaPsi.isNoComputedData();
5761
const cax = 455;
5862
const dpx = 110;
5963
const y = 165;
@@ -77,19 +81,30 @@ export const PressPage: FC = () => {
7781
<text className="Medium Center Cyan" x={dpx - 5} y="100">
7882
PSI
7983
</text>
80-
<text className={`Huge End ${deltaPsi < -0.4 || deltaPsi >= 8.5 ? 'Amber' : 'Green'}`} x={dpx + 38} y={y + 25}>
84+
<text
85+
className={`Huge End ${deltaPsi < -0.4 || deltaPsi >= 8.5 ? 'Amber' : 'Green'} ${deltaPressNotAvail ? 'hide' : 'show'}`}
86+
x={dpx + 38}
87+
y={y + 25}
88+
>
8189
{deltaPress[0]}
8290
</text>
83-
<text className={`Huge End ${deltaPsi < -0.4 || deltaPsi >= 8.5 ? 'Amber' : 'Green'}`} x={dpx + 53} y={y + 25}>
91+
<text
92+
className={`Huge End ${deltaPsi < -0.4 || deltaPsi >= 8.5 ? 'Amber' : 'Green'} ${deltaPressNotAvail ? 'hide' : 'show'}`}
93+
x={dpx + 53}
94+
y={y + 25}
95+
>
8496
.
8597
</text>
8698
<text
87-
className={`Standard End ${deltaPsi < -0.4 || deltaPsi >= 8.5 ? 'Amber' : 'Green'}`}
99+
className={`Standard End ${deltaPsi < -0.4 || deltaPsi >= 8.5 ? 'Amber' : 'Green'} ${deltaPressNotAvail ? 'hide' : 'show'}`}
88100
x={dpx + 63}
89101
y={y + 25}
90102
>
91103
{deltaPress[1]}
92104
</text>
105+
<text className={`Standard End Amber ${deltaPressNotAvail ? 'show' : 'hide'}`} x={dpx + 53} y={y + 25}>
106+
XX
107+
</text>
93108
<GaugeComponent x={dpx} y={y} radius={radius} startAngle={210} endAngle={50} visible className="Gauge">
94109
<GaugeComponent x={dpx} y={y} radius={radius} startAngle={40} endAngle={50} visible className="Gauge Amber" />
95110
<GaugeComponent
@@ -148,7 +163,7 @@ export const PressPage: FC = () => {
148163
radius={radius}
149164
startAngle={210}
150165
endAngle={50}
151-
className={`GaugeIndicator ${deltaPsi < -0.4 || deltaPsi >= 8.5 ? 'Amber' : ''}`}
166+
className={`GaugeIndicator ${deltaPsi < -0.4 || deltaPsi >= 8.5 ? 'Amber' : ''} ${deltaPressNotAvail ? 'hide' : 'show'}`}
152167
indicator
153168
/>
154169
</GaugeComponent>

fbw-a32nx/src/wasm/systems/a320_systems/src/air_conditioning.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use systems::{
44
acs_controller::{AcscId, AirConditioningSystemController, Pack},
55
cabin_air::CabinAirSimulation,
66
cabin_pressure_controller::{CabinPressureController, CpcId},
7-
pressure_valve::{OutflowValve, SafetyValve},
7+
pressure_valve::{OutflowValve, SafetyValve, SafetyValveSignal},
88
AdirsToAirCondInterface, Air, AirConditioningOverheadShared, AirConditioningPack, CabinFan,
99
Channel, DuctTemperature, MixerUnit, OutflowValveSignal, OutletAir, OverheadFlowSelector,
1010
PackFlowControllers, PressurizationConstants, PressurizationOverheadShared, TrimAirSystem,
@@ -696,6 +696,7 @@ struct A320PressurizationSystem {
696696
cpc_interface: [PressurizationSystemInterfaceUnit; 2],
697697
outflow_valve: [OutflowValve; 1], // Array to prepare for more than 1 outflow valve in A380
698698
safety_valve: SafetyValve,
699+
safety_valve_signal: SafetyValveSignal<A320PressurizationConstants>,
699700
residual_pressure_controller: ResidualPressureController,
700701
active_system: usize,
701702

@@ -725,6 +726,7 @@ impl A320PressurizationSystem {
725726
vec![ElectricalBusType::DirectCurrentBattery],
726727
)],
727728
safety_valve: SafetyValve::new(),
729+
safety_valve_signal: SafetyValveSignal::new(),
728730
residual_pressure_controller: ResidualPressureController::new(),
729731
active_system: active as usize,
730732

@@ -794,8 +796,12 @@ impl A320PressurizationSystem {
794796
});
795797
}
796798

797-
self.safety_valve
798-
.update(context, &self.cpc[self.active_system - 1]);
799+
self.safety_valve_signal.update(
800+
context,
801+
cabin_simulation.cabin_pressure(),
802+
self.safety_valve.open_amount(),
803+
);
804+
self.safety_valve.update(context, &self.safety_valve_signal);
799805

800806
self.switch_active_system();
801807

@@ -2628,7 +2634,7 @@ mod tests {
26282634
InternationalStandardAtmosphere::pressure_at_altitude(Length::default())
26292635
- Pressure::new::<psi>(10.),
26302636
)
2631-
.iterate(10);
2637+
.iterate(2);
26322638

26332639
assert!(test_bed.safety_valve_open_amount() > Ratio::default());
26342640
}

fbw-a380x/src/wasm/systems/a380_systems/src/air_conditioning/local_controllers/outflow_valve_control_module.rs

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use systems::{
22
air_conditioning::{
3-
cabin_pressure_controller::OutflowValveController,
4-
pressure_valve::{OutflowValve, PressureValveSignal},
3+
cabin_pressure_controller::OutflowValveController, pressure_valve::OutflowValve,
54
AdirsToAirCondInterface, Air, OperatingChannel, PressurizationConstants,
65
PressurizationOverheadShared,
76
},
87
shared::{
9-
low_pass_filter::LowPassFilter, CabinSimulation, ControllerSignal, ElectricalBusType,
8+
low_pass_filter::LowPassFilter, CabinSimulation, ElectricalBusType,
109
InternationalStandardAtmosphere,
1110
},
1211
simulation::{
@@ -21,7 +20,6 @@ use uom::si::{
2120
f64::*,
2221
length::foot,
2322
pressure::{hectopascal, psi},
24-
ratio::percent,
2523
velocity::foot_per_minute,
2624
};
2725

@@ -139,10 +137,6 @@ impl OutflowValveControlModule {
139137
fn switch_active_channel(&mut self) {
140138
std::mem::swap(&mut self.stand_by_channel, &mut self.active_channel);
141139
}
142-
143-
pub fn negative_relief_valve_trigger(&self) -> &impl ControllerSignal<PressureValveSignal> {
144-
&self.epp
145-
}
146140
}
147141

148142
impl OcsmShared for OutflowValveControlModule {
@@ -449,32 +443,3 @@ impl EmergencyPressurizationPartition {
449443
&self.outflow_valve_controller
450444
}
451445
}
452-
453-
/// Negative relieve valves signal. This returns a controller signal, but the valves are mechanical assemblies
454-
impl ControllerSignal<PressureValveSignal> for EmergencyPressurizationPartition {
455-
fn signal(&self) -> Option<PressureValveSignal> {
456-
let open = Some(PressureValveSignal::Open(
457-
Ratio::new::<percent>(100.),
458-
Duration::from_secs(1),
459-
));
460-
let closed = Some(PressureValveSignal::Close(
461-
Ratio::new::<percent>(0.),
462-
Duration::from_secs(1),
463-
));
464-
if self.differential_pressure.get::<psi>()
465-
< A380PressurizationConstants::MIN_SAFETY_DELTA_P + 0.2
466-
{
467-
if self.differential_pressure.get::<psi>()
468-
< A380PressurizationConstants::MIN_SAFETY_DELTA_P
469-
{
470-
open
471-
} else {
472-
Some(PressureValveSignal::Neutral)
473-
}
474-
} else if self.safety_valve_open_amount.get::<percent>() > 0. {
475-
closed
476-
} else {
477-
Some(PressureValveSignal::Neutral)
478-
}
479-
}
480-
}

fbw-a380x/src/wasm/systems/a380_systems/src/air_conditioning/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use systems::{
22
accept_iterable,
33
air_conditioning::{
4-
acs_controller::Pack, cabin_air::CabinAirSimulation, pressure_valve::SafetyValve,
4+
acs_controller::Pack,
5+
cabin_air::CabinAirSimulation,
6+
pressure_valve::{NegativeRelieveValveSignal, SafetyValve},
57
AdirsToAirCondInterface, Air, AirConditioningOverheadShared, AirConditioningPack,
68
AirHeater, CabinFan, DuctTemperature, MixerUnit, OutletAir, OverheadFlowSelector, PackFlow,
79
PackFlowControllers, PressurizationConstants, PressurizationOverheadShared, TrimAirSystem,
@@ -861,6 +863,7 @@ struct A380PressurizationSystem {
861863

862864
negative_relief_valves_id: VariableIdentifier,
863865
negative_relief_valves: SafetyValve,
866+
negative_relief_valves_signal: NegativeRelieveValveSignal<A380PressurizationConstants>,
864867
}
865868

866869
impl A380PressurizationSystem {
@@ -904,6 +907,7 @@ impl A380PressurizationSystem {
904907
negative_relief_valves_id: context
905908
.get_identifier("PRESS_SAFETY_VALVE_OPEN_PERCENTAGE".to_owned()),
906909
negative_relief_valves: SafetyValve::new(),
910+
negative_relief_valves_signal: NegativeRelieveValveSignal::new(),
907911
}
908912
}
909913

@@ -926,9 +930,14 @@ impl A380PressurizationSystem {
926930
);
927931
}
928932

933+
self.negative_relief_valves_signal.update(
934+
context,
935+
cabin_simulation.cabin_pressure(),
936+
self.negative_relief_valves.open_amount(),
937+
);
929938
// TODO Add check for failure
930939
self.negative_relief_valves
931-
.update(context, self.ocsm[0].negative_relief_valve_trigger());
940+
.update(context, &self.negative_relief_valves_signal);
932941
}
933942

934943
fn safety_valve_open_amount(&self) -> Ratio {

fbw-common/src/wasm/systems/systems/src/air_conditioning/cabin_pressure_controller.rs

Lines changed: 24 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ use crate::{
1313
};
1414

1515
use super::{
16-
pressure_valve::{OutflowValve, PressureValveSignal, SafetyValve},
17-
AdirsToAirCondInterface, OutflowValveSignal, PressurizationConstants,
16+
pressure_valve::{OutflowValve, SafetyValve},
17+
AdirsToAirCondInterface, Air, OutflowValveSignal, PressurizationConstants,
1818
PressurizationOverheadShared,
1919
};
2020

@@ -56,6 +56,7 @@ pub struct CabinPressureController<C: PressurizationConstants> {
5656
pressure_schedule_manager: Option<PressureScheduleManager>,
5757
manual_partition: Option<CpcManualPartition>,
5858
outflow_valve_controller: OutflowValveController,
59+
adirs_data_is_valid: bool,
5960
exterior_pressure: LowPassFilter<Pressure>,
6061
exterior_flight_altitude: Length,
6162
exterior_vertical_speed: LowPassFilter<Velocity>,
@@ -124,6 +125,7 @@ impl<C: PressurizationConstants> CabinPressureController<C> {
124125
Self::OFV_CONTROLLER_KP,
125126
Self::OFV_CONTROLLER_KI,
126127
),
128+
adirs_data_is_valid: false,
127129
exterior_pressure: LowPassFilter::new_with_init_value(
128130
Self::AMBIENT_CONDITIONS_FILTER_TIME_CONSTANT,
129131
Pressure::new::<hectopascal>(Self::P_0),
@@ -172,6 +174,9 @@ impl<C: PressurizationConstants> CabinPressureController<C> {
172174
safety_valve: &SafetyValve,
173175
is_active: bool,
174176
) {
177+
self.adirs_data_is_valid = [1, 2, 3]
178+
.iter()
179+
.any(|&adr| adirs.ambient_static_pressure(adr).is_normal_operation());
175180
let (adirs_airspeed, _) = self.adirs_values_calculation(adirs);
176181

177182
self.cabin_pressure = cabin_simulation.cabin_pressure();
@@ -255,17 +260,17 @@ impl<C: PressurizationConstants> CabinPressureController<C> {
255260
let (_, adirs_ambient_pressure) = self.adirs_values_calculation(adirs);
256261
let new_exterior_altitude: Length;
257262

258-
if !self.is_initialised {
263+
if !self.is_initialised && adirs_ambient_pressure.is_some() {
259264
self.exterior_pressure.reset(
260-
adirs_ambient_pressure.unwrap_or_else(|| Pressure::new::<hectopascal>(Self::P_0)),
265+
adirs_ambient_pressure.unwrap_or_else(|| Pressure::new::<hectopascal>(Air::P_0)),
261266
);
262267
new_exterior_altitude =
263268
self.calculate_altitude(self.exterior_pressure.output(), self.reference_pressure);
264269
self.is_initialised = true;
265270
} else {
266271
self.exterior_pressure.update(
267272
context.delta(),
268-
adirs_ambient_pressure.unwrap_or_else(|| Pressure::new::<hectopascal>(Self::P_0)),
273+
adirs_ambient_pressure.unwrap_or_else(|| Pressure::new::<hectopascal>(Air::P_0)),
269274
);
270275

271276
new_exterior_altitude =
@@ -641,39 +646,6 @@ impl<C: PressurizationConstants> ControllerSignal<OutflowValveSignal>
641646
}
642647
}
643648

644-
// Safety valve signal
645-
impl<C: PressurizationConstants> ControllerSignal<PressureValveSignal>
646-
for CabinPressureController<C>
647-
{
648-
fn signal(&self) -> Option<PressureValveSignal> {
649-
let open = Some(PressureValveSignal::Open(
650-
Ratio::new::<percent>(100.),
651-
Duration::from_secs(1),
652-
));
653-
let closed = Some(PressureValveSignal::Close(
654-
Ratio::new::<percent>(0.),
655-
Duration::from_secs(1),
656-
));
657-
if self.cabin_delta_p() > Pressure::new::<psi>(8.1) {
658-
if self.cabin_delta_p() > Pressure::new::<psi>(8.6) {
659-
open
660-
} else {
661-
Some(PressureValveSignal::Neutral)
662-
}
663-
} else if self.cabin_delta_p() < Pressure::new::<psi>(-0.5) {
664-
if self.cabin_delta_p() < Pressure::new::<psi>(-1.) {
665-
open
666-
} else {
667-
Some(PressureValveSignal::Neutral)
668-
}
669-
} else if self.safety_valve_open_amount > Ratio::new::<percent>(0.) {
670-
closed
671-
} else {
672-
Some(PressureValveSignal::Neutral)
673-
}
674-
}
675-
}
676-
677649
impl<C: PressurizationConstants> SimulationElement for CabinPressureController<C> {
678650
fn write(&self, writer: &mut SimulatorWriter) {
679651
let ssm = if self.failure.is_active() {
@@ -682,13 +654,26 @@ impl<C: PressurizationConstants> SimulationElement for CabinPressureController<C
682654
SignStatus::NormalOperation
683655
};
684656

657+
// Delta P is no computed data if the adirs are not sending ambient pressure information
658+
let delta_p_ssm = if self.failure.is_active() {
659+
SignStatus::FailureWarning
660+
} else if !self.adirs_data_is_valid {
661+
SignStatus::NoComputedData
662+
} else {
663+
SignStatus::NormalOperation
664+
};
665+
685666
// Safety valve open percentage is not sent by the CPC in real life
686667
writer.write(
687668
&self.safety_valve_open_percentage_id,
688669
self.safety_valve_open_amount,
689670
);
690671

691-
writer.write_arinc429(&self.cabin_delta_pressure_id, self.cabin_delta_p_out(), ssm);
672+
writer.write_arinc429(
673+
&self.cabin_delta_pressure_id,
674+
self.cabin_delta_p_out(),
675+
delta_p_ssm,
676+
);
692677
writer.write_arinc429(&self.cabin_altitude_id, self.cabin_altitude_out(), ssm);
693678
writer.write_arinc429(
694679
&self.outflow_valve_open_percentage_id,

0 commit comments

Comments
 (0)