Skip to content

Commit

Permalink
fix(GSX): Fixed GSX pin not actually disabling NWS (flybywiresim#8403)
Browse files Browse the repository at this point in the history
* Fixed FSX pin not actually disabling NWS

* implemented change for 380 as well

* refactored previous solution to be more isolated

* added changes to a380 as well

* Moved the handling of GSX var into aspect layer

* fix lint

* style fix
  • Loading branch information
Maximilian-Reuter authored Jan 13, 2024
1 parent 22559ed commit 04f2e43
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 62 deletions.
3 changes: 2 additions & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@
1. [FLIGHTMODEL/ICE PROT] - Interim fix for A/I system bug and quicker windscreen clearing of ice - @donstim (donbikes)
1. [ND] Worked around a font rendering bug with the ND chrono - @tracernz (Mike)
1. [TELEX] Decrease API poll rate to random number between 45-70 seconds - @auroraisluna (alepouna)
1. [AUTOFLIGHT] Fixed managed speed not engaging when V2 is confirmed after a departure runway change - @tracernz (Mike)
1. [AUTOFLIGHT] Fixed managed speed not engaging when V2 is confirmed after a departure runway change - @tracernz (Mi
1. [GSX/EFB] FBW Chocks & Cones are usable with GSX Fuel/Payload Sync and react to GSX Pushback - @Fragtality (Fragtality)
1. [GSX] Fixed GSX pin not actually disabling NWS - @Maximilian-Reuter (\_Chaoz_)

## 0.11.0

Expand Down
28 changes: 17 additions & 11 deletions fbw-a32nx/src/wasm/systems/a320_systems/src/hydraulic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use systems::{
AutobrakeDecelerationGovernor, AutobrakeMode, AutobrakePanel,
BrakeAccumulatorCharacteristics, BrakeCircuit, BrakeCircuitController,
},
bypass_pin::BypassPin,
cargo_doors::{CargoDoor, HydraulicDoorController},
electrical_generator::{GeneratorControlUnit, HydraulicGeneratorMotor},
flap_slat::FlapSlatAssembly,
Expand All @@ -36,8 +37,7 @@ use systems::{
LinearActuator, LinearActuatorCharacteristics, LinearActuatorMode,
},
nose_steering::{
Pushback, SteeringActuator, SteeringAngleLimiter, SteeringController,
SteeringRatioToAngle,
SteeringActuator, SteeringAngleLimiter, SteeringController, SteeringRatioToAngle,
},
pumps::PumpCharacteristics,
pushback::PushbackTug,
Expand Down Expand Up @@ -1473,6 +1473,8 @@ pub(super) struct A320Hydraulic {

pushback_tug: PushbackTug,

bypass_pin: BypassPin,

ram_air_turbine: RamAirTurbine,
ram_air_turbine_controller: A320RamAirTurbineController,

Expand Down Expand Up @@ -1667,6 +1669,7 @@ impl A320Hydraulic {
),

pushback_tug: PushbackTug::new(context),
bypass_pin: BypassPin::new(context),

ram_air_turbine: RamAirTurbine::new(context, PumpCharacteristics::a320_rat()),
ram_air_turbine_controller: A320RamAirTurbineController::new(
Expand Down Expand Up @@ -1923,7 +1926,7 @@ impl A320Hydraulic {

#[cfg(test)]
fn nose_wheel_steering_pin_is_inserted(&self) -> bool {
self.pushback_tug.is_nose_wheel_steering_pin_inserted()
self.bypass_pin.is_nose_wheel_steering_pin_inserted()
}

#[cfg(test)]
Expand Down Expand Up @@ -2079,6 +2082,7 @@ impl A320Hydraulic {
self.yellow_circuit.system_section(),
&self.brake_steer_computer,
&self.pushback_tug,
&self.bypass_pin,
);

// Process brake logic (which circuit brakes) and send brake demands (how much)
Expand All @@ -2105,14 +2109,15 @@ impl A320Hydraulic {
);

self.pushback_tug.update(context);
self.bypass_pin.update(&self.pushback_tug);

self.braking_force.update_forces(
context,
&self.braking_circuit_norm,
&self.braking_circuit_altn,
engine1,
engine2,
&self.pushback_tug,
&self.bypass_pin,
);

self.slats_flaps_complex
Expand Down Expand Up @@ -2309,7 +2314,7 @@ impl A320Hydraulic {
overhead_panel,
&self.forward_cargo_door_controller,
&self.aft_cargo_door_controller,
&self.pushback_tug,
&self.bypass_pin,
lgciu2,
self.green_circuit.reservoir(),
self.yellow_circuit.reservoir(),
Expand Down Expand Up @@ -2554,6 +2559,7 @@ impl SimulationElement for A320Hydraulic {
self.aft_cargo_door.accept(visitor);

self.pushback_tug.accept(visitor);
self.bypass_pin.accept(visitor);

self.ram_air_turbine.accept(visitor);
self.ram_air_turbine_controller.accept(visitor);
Expand Down Expand Up @@ -3327,7 +3333,7 @@ impl A320PowerTransferUnitController {
overhead_panel: &A320HydraulicOverheadPanel,
forward_cargo_door_controller: &HydraulicDoorController,
aft_cargo_door_controller: &HydraulicDoorController,
pushback_tug: &PushbackTug,
bypass_pin: &BypassPin,
lgciu2: &impl LgciuInterface,
reservoir_left_side: &Reservoir,
reservoir_right_side: &Reservoir,
Expand All @@ -3346,7 +3352,7 @@ impl A320PowerTransferUnitController {
|| self.eng_1_master_on && self.eng_2_master_on
|| !self.eng_1_master_on && !self.eng_2_master_on
|| (!self.parking_brake_lever_pos
&& !pushback_tug.is_nose_wheel_steering_pin_inserted()))
&& !bypass_pin.is_nose_wheel_steering_pin_inserted()))
&& !ptu_inhibited;

// When there is no power, the PTU is always ON.
Expand Down Expand Up @@ -3936,7 +3942,7 @@ impl A320BrakingForce {
altn_brakes: &BrakeCircuit,
engine1: &impl Engine,
engine2: &impl Engine,
pushback_tug: &PushbackTug,
bypass_pin: &BypassPin,
) {
// Base formula for output force is output_force[0:1] = 50 * sqrt(current_pressure) / Max_brake_pressure
// This formula gives a bit more punch for lower brake pressures (like 1000 psi alternate braking), as linear formula
Expand All @@ -3958,7 +3964,7 @@ impl A320BrakingForce {

self.correct_with_flaps_state(context);

self.update_chocks_braking(context, engine1, engine2, pushback_tug);
self.update_chocks_braking(context, engine1, engine2, bypass_pin);
}

fn correct_with_flaps_state(&mut self, context: &UpdateContext) {
Expand Down Expand Up @@ -3988,12 +3994,12 @@ impl A320BrakingForce {
context: &UpdateContext,
engine1: &impl Engine,
engine2: &impl Engine,
pushback_tug: &PushbackTug,
bypass_pin: &BypassPin,
) {
let chocks_on_wheels = context.is_on_ground()
&& engine1.corrected_n1().get::<percent>() < 3.5
&& engine2.corrected_n1().get::<percent>() < 3.5
&& !pushback_tug.is_nose_wheel_steering_pin_inserted()
&& !bypass_pin.is_nose_wheel_steering_pin_inserted()
&& !self.is_light_beacon_on;

if self.is_chocks_enabled && chocks_on_wheels {
Expand Down
8 changes: 8 additions & 0 deletions fbw-a32nx/src/wasm/systems/a320_systems_wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,14 @@ async fn systems(mut gauge: msfs::Gauge) -> Result<(), Box<dyn Error>> {
.provides_named_variable("FSDT_GSX_NUMPASSENGERS_DEBOARDING_TOTAL")?
.provides_named_variable("FSDT_GSX_BOARDING_CARGO_PERCENT")?
.provides_named_variable("FSDT_GSX_DEBOARDING_CARGO_PERCENT")?
.provides_named_variable("FSDT_GSX_BYPASS_PIN")?
.with_aspect(|builder| {
builder.copy(
Variable::named("FSDT_GSX_BYPASS_PIN"),
Variable::aspect("EXTERNAL_BYPASS_PIN_INSERTED"),
);
Ok(())
})?
.provides_aircraft_variable(
"ROTATION ACCELERATION BODY X",
"radian per second squared",
Expand Down
31 changes: 18 additions & 13 deletions fbw-a380x/src/wasm/systems/a380_systems/src/hydraulic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use systems::{
AutobrakeDecelerationGovernor, AutobrakeMode, AutobrakePanel,
BrakeAccumulatorCharacteristics, BrakeCircuit, BrakeCircuitController,
},
bypass_pin::BypassPin,
cargo_doors::{CargoDoor, HydraulicDoorController},
flap_slat::FlapSlatAssembly,
landing_gear::{GearGravityExtension, GearSystemController, HydraulicGearSystem},
Expand All @@ -35,8 +36,7 @@ use systems::{
LinearActuator, LinearActuatorCharacteristics, LinearActuatorMode,
},
nose_steering::{
Pushback, SteeringActuator, SteeringAngleLimiter, SteeringController,
SteeringRatioToAngle,
SteeringActuator, SteeringAngleLimiter, SteeringController, SteeringRatioToAngle,
},
pumps::PumpCharacteristics,
pushback::PushbackTug,
Expand Down Expand Up @@ -1551,6 +1551,7 @@ pub(super) struct A380Hydraulic {
green_electric_aux_pump_controller: A380AuxiliaryPumpController,

pushback_tug: PushbackTug,
bypass_pin: BypassPin,

braking_circuit_norm: BrakeCircuit,
braking_circuit_altn: BrakeCircuit,
Expand Down Expand Up @@ -1800,6 +1801,7 @@ impl A380Hydraulic {
),

pushback_tug: PushbackTug::new(context),
bypass_pin: BypassPin::new(context),

braking_circuit_norm: BrakeCircuit::new(
context,
Expand Down Expand Up @@ -2020,7 +2022,7 @@ impl A380Hydraulic {

#[cfg(test)]
fn nose_wheel_steering_pin_is_inserted(&self) -> bool {
self.pushback_tug.is_nose_wheel_steering_pin_inserted()
self.bypass_pin.is_nose_wheel_steering_pin_inserted()
}

#[cfg(test)]
Expand Down Expand Up @@ -2214,6 +2216,7 @@ impl A380Hydraulic {
self.yellow_circuit.system_section(),
&self.brake_steer_computer,
&self.pushback_tug,
&self.bypass_pin,
);

// Process brake logic (which circuit brakes) and send brake demands (how much)
Expand All @@ -2229,14 +2232,15 @@ impl A380Hydraulic {
);

self.pushback_tug.update(context);
self.bypass_pin.update(&self.pushback_tug);

self.braking_force.update_forces(
context,
&self.braking_circuit_norm,
&self.braking_circuit_altn,
engine1,
engine2,
&self.pushback_tug,
&self.bypass_pin,
);

self.slats_flaps_complex
Expand Down Expand Up @@ -2277,7 +2281,7 @@ impl A380Hydraulic {
context,
&self.forward_cargo_door_controller,
&self.aft_cargo_door_controller,
&self.pushback_tug,
&self.bypass_pin,
overhead_panel,
);
}
Expand Down Expand Up @@ -2885,6 +2889,7 @@ impl SimulationElement for A380Hydraulic {
self.aft_cargo_door.accept(visitor);

self.pushback_tug.accept(visitor);
self.bypass_pin.accept(visitor);

self.green_circuit.accept(visitor);
self.yellow_circuit.accept(visitor);
Expand Down Expand Up @@ -3443,14 +3448,14 @@ impl A380ElectricPumpAutoLogic {
context: &UpdateContext,
forward_cargo_door_controller: &HydraulicDoorController,
aft_cargo_door_controller: &HydraulicDoorController,
pushback_tug: &PushbackTug,
bypass_pin: &BypassPin,
overhead: &A380HydraulicOverheadPanel,
) {
self.update_auto_run_logic(
context,
forward_cargo_door_controller,
aft_cargo_door_controller,
pushback_tug,
bypass_pin,
);

self.select_pump_in_use(overhead);
Expand All @@ -3461,7 +3466,7 @@ impl A380ElectricPumpAutoLogic {
context: &UpdateContext,
forward_cargo_door_controller: &HydraulicDoorController,
aft_cargo_door_controller: &HydraulicDoorController,
pushback_tug: &PushbackTug,
bypass_pin: &BypassPin,
) {
self.cargo_door_in_operation_previous = self.is_required_for_cargo_door_operation.output();

Expand All @@ -3475,7 +3480,7 @@ impl A380ElectricPumpAutoLogic {
self.is_required_for_body_steering_operation.output();

self.is_required_for_body_steering_operation
.update(context, pushback_tug.is_nose_wheel_steering_pin_inserted());
.update(context, bypass_pin.is_nose_wheel_steering_pin_inserted());
}

fn select_pump_in_use(&mut self, overhead: &A380HydraulicOverheadPanel) {
Expand Down Expand Up @@ -4179,7 +4184,7 @@ impl A380BrakingForce {
altn_brakes: &BrakeCircuit,
engine1: &impl Engine,
engine2: &impl Engine,
pushback_tug: &PushbackTug,
bypass_pin: &BypassPin,
) {
// Base formula for output force is output_force[0:1] = 50 * sqrt(current_pressure) / Max_brake_pressure
// This formula gives a bit more punch for lower brake pressures (like 1000 psi alternate braking), as linear formula
Expand All @@ -4201,7 +4206,7 @@ impl A380BrakingForce {

self.correct_with_flaps_state(context);

self.update_chocks_braking(context, engine1, engine2, pushback_tug);
self.update_chocks_braking(context, engine1, engine2, bypass_pin);
}

fn correct_with_flaps_state(&mut self, context: &UpdateContext) {
Expand Down Expand Up @@ -4231,12 +4236,12 @@ impl A380BrakingForce {
context: &UpdateContext,
engine1: &impl Engine,
engine2: &impl Engine,
pushback_tug: &PushbackTug,
bypass_pin: &BypassPin,
) {
let chocks_on_wheels = context.is_on_ground()
&& engine1.corrected_n1().get::<percent>() < 3.5
&& engine2.corrected_n1().get::<percent>() < 3.5
&& !pushback_tug.is_nose_wheel_steering_pin_inserted()
&& !bypass_pin.is_nose_wheel_steering_pin_inserted()
&& !self.is_light_beacon_on;

if self.is_chocks_enabled && chocks_on_wheels {
Expand Down
8 changes: 8 additions & 0 deletions fbw-a380x/src/wasm/systems/a380_systems_wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,14 @@ async fn systems(mut gauge: msfs::Gauge) -> Result<(), Box<dyn Error>> {
.provides_named_variable("FSDT_GSX_NUMPASSENGERS_DEBOARDING_TOTAL")?
.provides_named_variable("FSDT_GSX_BOARDING_CARGO_PERCENT")?
.provides_named_variable("FSDT_GSX_DEBOARDING_CARGO_PERCENT")?
.provides_named_variable("FSDT_GSX_BYPASS_PIN")?
.with_aspect(|builder| {
builder.copy(
Variable::named("FSDT_GSX_BYPASS_PIN"),
Variable::aspect("EXTERNAL_BYPASS_PIN_INSERTED"),
);
Ok(())
})?
.with_aspect(|builder| {
for i in 1..=2 {
builder.copy(
Expand Down
42 changes: 42 additions & 0 deletions fbw-common/src/wasm/systems/systems/src/hydraulic/bypass_pin.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use super::nose_steering::Pushback;
use crate::simulation::{
InitContext, Read, SimulationElement, SimulatorReader, SimulatorWriter, VariableIdentifier,
Write,
};

pub struct BypassPin {
nw_strg_disc_memo_id: VariableIdentifier,
gsx_pin_state_id: VariableIdentifier,

gsx_pin_inserted: bool,
bypass_pin_inserted: bool,
}

impl BypassPin {
pub fn new(context: &mut InitContext) -> Self {
Self {
gsx_pin_state_id: context.get_identifier("EXTERNAL_BYPASS_PIN_INSERTED".to_owned()),
gsx_pin_inserted: false,
bypass_pin_inserted: false,
nw_strg_disc_memo_id: context.get_identifier("HYD_NW_STRG_DISC_ECAM_MEMO".to_owned()),
}
}
pub fn update(&mut self, fbw_tug: &impl Pushback) {
self.bypass_pin_inserted =
fbw_tug.is_nose_wheel_steering_pin_inserted() || self.gsx_pin_inserted;
}

pub fn is_nose_wheel_steering_pin_inserted(&self) -> bool {
self.bypass_pin_inserted
}
}

impl SimulationElement for BypassPin {
fn read(&mut self, reader: &mut SimulatorReader) {
self.gsx_pin_inserted = reader.read(&self.gsx_pin_state_id);
}

fn write(&self, writer: &mut SimulatorWriter) {
writer.write(&self.nw_strg_disc_memo_id, self.bypass_pin_inserted);
}
}
1 change: 1 addition & 0 deletions fbw-common/src/wasm/systems/systems/src/hydraulic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use uom::si::{

pub mod aerodynamic_model;
pub mod brake_circuit;
pub mod bypass_pin;
pub mod cargo_doors;
pub mod electrical_generator;
pub mod electrical_pump_physics;
Expand Down
Loading

0 comments on commit 04f2e43

Please sign in to comment.