diff --git a/hdw-a333x/src/wasm/systems/a320_systems_wasm/src/lib.rs b/hdw-a333x/src/wasm/systems/a320_systems_wasm/src/lib.rs index c8016976a..ff5e9dd9d 100644 --- a/hdw-a333x/src/wasm/systems/a320_systems_wasm/src/lib.rs +++ b/hdw-a333x/src/wasm/systems/a320_systems_wasm/src/lib.rs @@ -391,13 +391,7 @@ async fn systems(mut gauge: msfs::Gauge) -> Result<(), Box> { .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_named_variable("SIAI_PUSHBACK_ACTIVE")? .provides_aircraft_variable( "ROTATION ACCELERATION BODY X", "radian per second squared", diff --git a/hdw-a339x/src/wasm/systems/a320_systems_wasm/src/lib.rs b/hdw-a339x/src/wasm/systems/a320_systems_wasm/src/lib.rs index ac2923160..481b5eb70 100644 --- a/hdw-a339x/src/wasm/systems/a320_systems_wasm/src/lib.rs +++ b/hdw-a339x/src/wasm/systems/a320_systems_wasm/src/lib.rs @@ -392,13 +392,7 @@ async fn systems(mut gauge: msfs::Gauge) -> Result<(), Box> { .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_named_variable("SIAI_PUSHBACK_ACTIVE")? .provides_aircraft_variable( "ROTATION ACCELERATION BODY X", "radian per second squared", diff --git a/hdw-common/src/wasm/systems/systems/src/hydraulic/bypass_pin.rs b/hdw-common/src/wasm/systems/systems/src/hydraulic/bypass_pin.rs new file mode 100644 index 000000000..90a4e00ce --- /dev/null +++ b/hdw-common/src/wasm/systems/systems/src/hydraulic/bypass_pin.rs @@ -0,0 +1,47 @@ +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, + siai_pin_state_id: VariableIdentifier, + + gsx_pin_inserted: bool, + siai_pin_inserted: bool, + bypass_pin_inserted: bool, +} + +impl BypassPin { + pub fn new(context: &mut InitContext) -> Self { + Self { + gsx_pin_state_id: context.get_identifier("FSDT_GSX_BYPASS_PIN".to_owned()), + siai_pin_state_id: context.get_identifier("SIAI_PUSHBACK_ACTIVE".to_owned()), + gsx_pin_inserted: false, + siai_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 || self.siai_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); + self.siai_pin_inserted = reader.read(&self.siai_pin_state_id); + } + + fn write(&self, writer: &mut SimulatorWriter) { + writer.write(&self.nw_strg_disc_memo_id, self.bypass_pin_inserted); + } +} diff --git a/hdw-su95x/src/wasm/systems/a320_systems_wasm/src/lib.rs b/hdw-su95x/src/wasm/systems/a320_systems_wasm/src/lib.rs index 0f6be2633..a0404db26 100644 --- a/hdw-su95x/src/wasm/systems/a320_systems_wasm/src/lib.rs +++ b/hdw-su95x/src/wasm/systems/a320_systems_wasm/src/lib.rs @@ -385,13 +385,7 @@ async fn systems(mut gauge: msfs::Gauge) -> Result<(), Box> { .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_named_variable("SIAI_PUSHBACK_ACTIVE")? .provides_aircraft_variable( "ROTATION ACCELERATION BODY X", "radian per second squared",