Skip to content

Commit

Permalink
feat(SIAI): add variable for pushback
Browse files Browse the repository at this point in the history
  • Loading branch information
Revyn112 committed Dec 18, 2024
1 parent 8224846 commit 8898808
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 21 deletions.
8 changes: 1 addition & 7 deletions hdw-a333x/src/wasm/systems/a320_systems_wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,7 @@ async fn systems(mut gauge: msfs::Gauge) -> Result<(), Box<dyn Error>> {
.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",
Expand Down
8 changes: 1 addition & 7 deletions hdw-a339x/src/wasm/systems/a320_systems_wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,7 @@ async fn systems(mut gauge: msfs::Gauge) -> Result<(), Box<dyn Error>> {
.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",
Expand Down
47 changes: 47 additions & 0 deletions hdw-common/src/wasm/systems/systems/src/hydraulic/bypass_pin.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}
8 changes: 1 addition & 7 deletions hdw-su95x/src/wasm/systems/a320_systems_wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,7 @@ async fn systems(mut gauge: msfs::Gauge) -> Result<(), Box<dyn Error>> {
.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",
Expand Down

0 comments on commit 8898808

Please sign in to comment.