Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(press): delta pressure calculation before adirs on #8648

Merged
merged 7 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 19 additions & 4 deletions fbw-a32nx/src/systems/instruments/src/SD/Pages/Press/Press.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ export const PressPage: FC = () => {
}, [cabinAlt]);

const deltaPress = splitDecimals(MathUtils.clamp(deltaPsi, -9.9, 9.9));
// TODO: SDAC logic missing. Delta pressure is not available when the SDAC indication is not valid.
// This happens when both the CPCs and ADRs are not sending pressure information. Here we only check
// for CPC no computed data.
const deltaPressNotAvail = arincDeltaPsi.isNoComputedData();
mjuhe marked this conversation as resolved.
Show resolved Hide resolved
const cax = 455;
const dpx = 110;
const y = 165;
Expand All @@ -77,19 +81,30 @@ export const PressPage: FC = () => {
<text className="Medium Center Cyan" x={dpx - 5} y="100">
PSI
</text>
<text className={`Huge End ${deltaPsi < -0.4 || deltaPsi >= 8.5 ? 'Amber' : 'Green'}`} x={dpx + 38} y={y + 25}>
<text
className={`Huge End ${deltaPsi < -0.4 || deltaPsi >= 8.5 ? 'Amber' : 'Green'} ${deltaPressNotAvail ? 'hide' : 'show'}`}
x={dpx + 38}
y={y + 25}
>
{deltaPress[0]}
</text>
<text className={`Huge End ${deltaPsi < -0.4 || deltaPsi >= 8.5 ? 'Amber' : 'Green'}`} x={dpx + 53} y={y + 25}>
<text
className={`Huge End ${deltaPsi < -0.4 || deltaPsi >= 8.5 ? 'Amber' : 'Green'} ${deltaPressNotAvail ? 'hide' : 'show'}`}
x={dpx + 53}
y={y + 25}
>
.
</text>
<text
className={`Standard End ${deltaPsi < -0.4 || deltaPsi >= 8.5 ? 'Amber' : 'Green'}`}
className={`Standard End ${deltaPsi < -0.4 || deltaPsi >= 8.5 ? 'Amber' : 'Green'} ${deltaPressNotAvail ? 'hide' : 'show'}`}
x={dpx + 63}
y={y + 25}
>
{deltaPress[1]}
</text>
<text className={`Standard End Amber ${deltaPressNotAvail ? 'show' : 'hide'}`} x={dpx + 53} y={y + 25}>
XX
</text>
<GaugeComponent x={dpx} y={y} radius={radius} startAngle={210} endAngle={50} visible className="Gauge">
<GaugeComponent x={dpx} y={y} radius={radius} startAngle={40} endAngle={50} visible className="Gauge Amber" />
<GaugeComponent
Expand Down Expand Up @@ -148,7 +163,7 @@ export const PressPage: FC = () => {
radius={radius}
startAngle={210}
endAngle={50}
className={`GaugeIndicator ${deltaPsi < -0.4 || deltaPsi >= 8.5 ? 'Amber' : ''}`}
className={`GaugeIndicator ${deltaPsi < -0.4 || deltaPsi >= 8.5 ? 'Amber' : ''} ${deltaPressNotAvail ? 'hide' : 'show'}`}
indicator
/>
</GaugeComponent>
Expand Down
14 changes: 10 additions & 4 deletions fbw-a32nx/src/wasm/systems/a320_systems/src/air_conditioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use systems::{
acs_controller::{AcscId, AirConditioningSystemController, Pack},
cabin_air::CabinAirSimulation,
cabin_pressure_controller::{CabinPressureController, CpcId},
pressure_valve::{OutflowValve, SafetyValve},
pressure_valve::{OutflowValve, SafetyValve, SafetyValveSignal},
AdirsToAirCondInterface, Air, AirConditioningOverheadShared, AirConditioningPack, CabinFan,
Channel, DuctTemperature, MixerUnit, OutflowValveSignal, OutletAir, OverheadFlowSelector,
PackFlowControllers, PressurizationConstants, PressurizationOverheadShared, TrimAirSystem,
Expand Down Expand Up @@ -696,6 +696,7 @@ struct A320PressurizationSystem {
cpc_interface: [PressurizationSystemInterfaceUnit; 2],
outflow_valve: [OutflowValve; 1], // Array to prepare for more than 1 outflow valve in A380
safety_valve: SafetyValve,
safety_valve_signal: SafetyValveSignal<A320PressurizationConstants>,
residual_pressure_controller: ResidualPressureController,
active_system: usize,

Expand Down Expand Up @@ -725,6 +726,7 @@ impl A320PressurizationSystem {
vec![ElectricalBusType::DirectCurrentBattery],
)],
safety_valve: SafetyValve::new(),
safety_valve_signal: SafetyValveSignal::new(),
residual_pressure_controller: ResidualPressureController::new(),
active_system: active as usize,

Expand Down Expand Up @@ -794,8 +796,12 @@ impl A320PressurizationSystem {
});
}

self.safety_valve
.update(context, &self.cpc[self.active_system - 1]);
self.safety_valve_signal.update(
context,
cabin_simulation.cabin_pressure(),
self.safety_valve.open_amount(),
);
self.safety_valve.update(context, &self.safety_valve_signal);

self.switch_active_system();

Expand Down Expand Up @@ -2628,7 +2634,7 @@ mod tests {
InternationalStandardAtmosphere::pressure_at_altitude(Length::default())
- Pressure::new::<psi>(10.),
)
.iterate(10);
.iterate(2);

assert!(test_bed.safety_valve_open_amount() > Ratio::default());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use systems::{
air_conditioning::{
cabin_pressure_controller::OutflowValveController,
pressure_valve::{OutflowValve, PressureValveSignal},
cabin_pressure_controller::OutflowValveController, pressure_valve::OutflowValve,
AdirsToAirCondInterface, Air, OperatingChannel, PressurizationConstants,
PressurizationOverheadShared,
},
shared::{
low_pass_filter::LowPassFilter, CabinSimulation, ControllerSignal, ElectricalBusType,
low_pass_filter::LowPassFilter, CabinSimulation, ElectricalBusType,
InternationalStandardAtmosphere,
},
simulation::{
Expand All @@ -21,7 +20,6 @@ use uom::si::{
f64::*,
length::foot,
pressure::{hectopascal, psi},
ratio::percent,
velocity::foot_per_minute,
};

Expand Down Expand Up @@ -139,10 +137,6 @@ impl OutflowValveControlModule {
fn switch_active_channel(&mut self) {
std::mem::swap(&mut self.stand_by_channel, &mut self.active_channel);
}

pub fn negative_relief_valve_trigger(&self) -> &impl ControllerSignal<PressureValveSignal> {
&self.epp
}
}

impl OcsmShared for OutflowValveControlModule {
Expand Down Expand Up @@ -449,32 +443,3 @@ impl EmergencyPressurizationPartition {
&self.outflow_valve_controller
}
}

/// Negative relieve valves signal. This returns a controller signal, but the valves are mechanical assemblies
impl ControllerSignal<PressureValveSignal> for EmergencyPressurizationPartition {
fn signal(&self) -> Option<PressureValveSignal> {
let open = Some(PressureValveSignal::Open(
Ratio::new::<percent>(100.),
Duration::from_secs(1),
));
let closed = Some(PressureValveSignal::Close(
Ratio::new::<percent>(0.),
Duration::from_secs(1),
));
if self.differential_pressure.get::<psi>()
< A380PressurizationConstants::MIN_SAFETY_DELTA_P + 0.2
{
if self.differential_pressure.get::<psi>()
< A380PressurizationConstants::MIN_SAFETY_DELTA_P
{
open
} else {
Some(PressureValveSignal::Neutral)
}
} else if self.safety_valve_open_amount.get::<percent>() > 0. {
closed
} else {
Some(PressureValveSignal::Neutral)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use systems::{
accept_iterable,
air_conditioning::{
acs_controller::Pack, cabin_air::CabinAirSimulation, pressure_valve::SafetyValve,
acs_controller::Pack,
cabin_air::CabinAirSimulation,
pressure_valve::{NegativeRelieveValveSignal, SafetyValve},
AdirsToAirCondInterface, Air, AirConditioningOverheadShared, AirConditioningPack,
AirHeater, CabinFan, DuctTemperature, MixerUnit, OutletAir, OverheadFlowSelector, PackFlow,
PackFlowControllers, PressurizationConstants, PressurizationOverheadShared, TrimAirSystem,
Expand Down Expand Up @@ -861,6 +863,7 @@ struct A380PressurizationSystem {

negative_relief_valves_id: VariableIdentifier,
negative_relief_valves: SafetyValve,
negative_relief_valves_signal: NegativeRelieveValveSignal<A380PressurizationConstants>,
}

impl A380PressurizationSystem {
Expand Down Expand Up @@ -904,6 +907,7 @@ impl A380PressurizationSystem {
negative_relief_valves_id: context
.get_identifier("PRESS_SAFETY_VALVE_OPEN_PERCENTAGE".to_owned()),
negative_relief_valves: SafetyValve::new(),
negative_relief_valves_signal: NegativeRelieveValveSignal::new(),
}
}

Expand All @@ -926,9 +930,14 @@ impl A380PressurizationSystem {
);
}

self.negative_relief_valves_signal.update(
context,
cabin_simulation.cabin_pressure(),
self.negative_relief_valves.open_amount(),
);
// TODO Add check for failure
self.negative_relief_valves
.update(context, self.ocsm[0].negative_relief_valve_trigger());
.update(context, &self.negative_relief_valves_signal);
}

fn safety_valve_open_amount(&self) -> Ratio {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use crate::{
};

use super::{
pressure_valve::{OutflowValve, PressureValveSignal, SafetyValve},
AdirsToAirCondInterface, OutflowValveSignal, PressurizationConstants,
pressure_valve::{OutflowValve, SafetyValve},
AdirsToAirCondInterface, Air, OutflowValveSignal, PressurizationConstants,
PressurizationOverheadShared,
};

Expand Down Expand Up @@ -56,6 +56,7 @@ pub struct CabinPressureController<C: PressurizationConstants> {
pressure_schedule_manager: Option<PressureScheduleManager>,
manual_partition: Option<CpcManualPartition>,
outflow_valve_controller: OutflowValveController,
adirs_data_is_valid: bool,
exterior_pressure: LowPassFilter<Pressure>,
exterior_flight_altitude: Length,
exterior_vertical_speed: LowPassFilter<Velocity>,
Expand Down Expand Up @@ -124,6 +125,7 @@ impl<C: PressurizationConstants> CabinPressureController<C> {
Self::OFV_CONTROLLER_KP,
Self::OFV_CONTROLLER_KI,
),
adirs_data_is_valid: false,
exterior_pressure: LowPassFilter::new_with_init_value(
Self::AMBIENT_CONDITIONS_FILTER_TIME_CONSTANT,
Pressure::new::<hectopascal>(Self::P_0),
Expand Down Expand Up @@ -172,6 +174,9 @@ impl<C: PressurizationConstants> CabinPressureController<C> {
safety_valve: &SafetyValve,
is_active: bool,
) {
self.adirs_data_is_valid = [1, 2, 3]
.iter()
.any(|&adr| adirs.ambient_static_pressure(adr).is_normal_operation());
let (adirs_airspeed, _) = self.adirs_values_calculation(adirs);

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

if !self.is_initialised {
if !self.is_initialised && adirs_ambient_pressure.is_some() {
self.exterior_pressure.reset(
adirs_ambient_pressure.unwrap_or_else(|| Pressure::new::<hectopascal>(Self::P_0)),
adirs_ambient_pressure.unwrap_or_else(|| Pressure::new::<hectopascal>(Air::P_0)),
);
new_exterior_altitude =
self.calculate_altitude(self.exterior_pressure.output(), self.reference_pressure);
self.is_initialised = true;
} else {
self.exterior_pressure.update(
context.delta(),
adirs_ambient_pressure.unwrap_or_else(|| Pressure::new::<hectopascal>(Self::P_0)),
adirs_ambient_pressure.unwrap_or_else(|| Pressure::new::<hectopascal>(Air::P_0)),
);

new_exterior_altitude =
Expand Down Expand Up @@ -641,39 +646,6 @@ impl<C: PressurizationConstants> ControllerSignal<OutflowValveSignal>
}
}

// Safety valve signal
impl<C: PressurizationConstants> ControllerSignal<PressureValveSignal>
for CabinPressureController<C>
{
fn signal(&self) -> Option<PressureValveSignal> {
let open = Some(PressureValveSignal::Open(
Ratio::new::<percent>(100.),
Duration::from_secs(1),
));
let closed = Some(PressureValveSignal::Close(
Ratio::new::<percent>(0.),
Duration::from_secs(1),
));
if self.cabin_delta_p() > Pressure::new::<psi>(8.1) {
if self.cabin_delta_p() > Pressure::new::<psi>(8.6) {
open
} else {
Some(PressureValveSignal::Neutral)
}
} else if self.cabin_delta_p() < Pressure::new::<psi>(-0.5) {
if self.cabin_delta_p() < Pressure::new::<psi>(-1.) {
open
} else {
Some(PressureValveSignal::Neutral)
}
} else if self.safety_valve_open_amount > Ratio::new::<percent>(0.) {
closed
} else {
Some(PressureValveSignal::Neutral)
}
}
}

impl<C: PressurizationConstants> SimulationElement for CabinPressureController<C> {
fn write(&self, writer: &mut SimulatorWriter) {
let ssm = if self.failure.is_active() {
Expand All @@ -682,13 +654,26 @@ impl<C: PressurizationConstants> SimulationElement for CabinPressureController<C
SignStatus::NormalOperation
};

// Delta P is no computed data if the adirs are not sending ambient pressure information
let delta_p_ssm = if self.failure.is_active() {
SignStatus::FailureWarning
} else if !self.adirs_data_is_valid {
SignStatus::NoComputedData
} else {
SignStatus::NormalOperation
};

// Safety valve open percentage is not sent by the CPC in real life
writer.write(
&self.safety_valve_open_percentage_id,
self.safety_valve_open_amount,
);

writer.write_arinc429(&self.cabin_delta_pressure_id, self.cabin_delta_p_out(), ssm);
writer.write_arinc429(
&self.cabin_delta_pressure_id,
self.cabin_delta_p_out(),
delta_p_ssm,
);
writer.write_arinc429(&self.cabin_altitude_id, self.cabin_altitude_out(), ssm);
writer.write_arinc429(
&self.outflow_valve_open_percentage_id,
Expand Down