diff --git a/fbw-a32nx/src/wasm/systems/a320_systems/src/payload/mod.rs b/fbw-a32nx/src/wasm/systems/a320_systems/src/payload/mod.rs index fdf5b595dd8..96f8c30d84b 100644 --- a/fbw-a32nx/src/wasm/systems/a320_systems/src/payload/mod.rs +++ b/fbw-a32nx/src/wasm/systems/a320_systems/src/payload/mod.rs @@ -152,22 +152,24 @@ impl A320Payload { Mass::new::(c.max_cargo_kg), ) }); + let default_boarding_agent = BoardingAgent::new(None, [0, 1, 2, 3]); + let boarding_agents = [ BoardingAgent::new( - context.get_identifier("INTERACTIVE POINT OPEN:0".to_owned()), + Some(context.get_identifier("INTERACTIVE POINT OPEN:0".to_owned())), [0, 1, 2, 3], ), BoardingAgent::new( - context.get_identifier("INTERACTIVE POINT OPEN:1".to_owned()), + Some(context.get_identifier("INTERACTIVE POINT OPEN:1".to_owned())), [0, 1, 2, 3], ), BoardingAgent::new( - context.get_identifier("INTERACTIVE POINT OPEN:2".to_owned()), + Some(context.get_identifier("INTERACTIVE POINT OPEN:2".to_owned())), [3, 2, 1, 0], ), ]; - let passenger_deck = PassengerDeck::new(pax, boarding_agents); + let passenger_deck = PassengerDeck::new(pax, default_boarding_agent, boarding_agents); let cargo_deck = CargoDeck::new(cargo); A320Payload { diff --git a/fbw-a380x/src/wasm/systems/a380_systems/src/payload/mod.rs b/fbw-a380x/src/wasm/systems/a380_systems/src/payload/mod.rs index 94485b6fb57..97b06906051 100644 --- a/fbw-a380x/src/wasm/systems/a380_systems/src/payload/mod.rs +++ b/fbw-a380x/src/wasm/systems/a380_systems/src/payload/mod.rs @@ -81,7 +81,7 @@ impl From for A380Cargo { } } pub struct A380Payload { - payload_manager: PayloadManager<14, 3, 3>, + payload_manager: PayloadManager<14, 5, 3>, } impl A380Payload { // Note: These constants reflect flight_model.cfg values and will have to be updated in sync with the configuration @@ -230,23 +230,34 @@ impl A380Payload { Mass::new::(c.max_cargo_kg), ) }); + let default_boarding_agent = + BoardingAgent::new(None, [10, 13, 12, 11, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2]); + // TODO: Move into a toml cfg let boarding_agents = [ BoardingAgent::new( - context.get_identifier("INTERACTIVE POINT OPEN:0".to_owned()), - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], - ), + Some(context.get_identifier("INTERACTIVE POINT OPEN:0".to_owned())), + [10, 13, 12, 11, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2], + ), // M1L BoardingAgent::new( - context.get_identifier("INTERACTIVE POINT OPEN:2".to_owned()), - [10, 11, 12, 13, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], - ), + Some(context.get_identifier("INTERACTIVE POINT OPEN:2".to_owned())), + [1, 0, 9, 8, 7, 6, 5, 2, 3, 4, 10, 11, 12, 13], + ), // M2L BoardingAgent::new( - context.get_identifier("INTERACTIVE POINT OPEN:10".to_owned()), - [2, 3, 4, 5, 6, 7, 8, 9, 13, 12, 11, 10, 1, 0], - ), + Some(context.get_identifier("INTERACTIVE POINT OPEN:6".to_owned())), + [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], + ), // M4L + BoardingAgent::new( + Some(context.get_identifier("INTERACTIVE POINT OPEN:8".to_owned())), + [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], + ), // M5L + BoardingAgent::new( + Some(context.get_identifier("INTERACTIVE POINT OPEN:10".to_owned())), + [10, 13, 12, 11, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], + ), // U1L ]; - let passenger_deck = PassengerDeck::new(pax, boarding_agents); + let passenger_deck = PassengerDeck::new(pax, default_boarding_agent, boarding_agents); let cargo_deck = CargoDeck::new(cargo); A380Payload { diff --git a/fbw-common/src/wasm/systems/systems/src/payload/mod.rs b/fbw-common/src/wasm/systems/systems/src/payload/mod.rs index 3353494ca02..d1194ab035d 100644 --- a/fbw-common/src/wasm/systems/systems/src/payload/mod.rs +++ b/fbw-common/src/wasm/systems/systems/src/payload/mod.rs @@ -58,12 +58,12 @@ pub trait CargoPayload { #[derive(Debug)] pub struct BoardingAgent { - door_id: VariableIdentifier, + door_id: Option, door_open_ratio: Ratio, order: [usize; P], } impl BoardingAgent

{ - pub fn new(door_id: VariableIdentifier, order: [usize; P]) -> Self { + pub fn new(door_id: Option, order: [usize; P]) -> Self { BoardingAgent { door_id, order, @@ -105,19 +105,28 @@ impl BoardingAgent

{ } impl SimulationElement for BoardingAgent

{ fn read(&mut self, reader: &mut SimulatorReader) { - self.door_open_ratio = reader.read(&self.door_id); + self.door_open_ratio = self + .door_id + .map(|door_id| reader.read(&door_id)) + .unwrap_or_default(); } } #[derive(Debug)] pub struct PassengerDeck { pax: [Pax; N], + default_boarding_agent: BoardingAgent, boarding_agents: [BoardingAgent; G], } impl PassengerDeck { - pub fn new(pax: [Pax; N], boarding_agents: [BoardingAgent; G]) -> Self { + pub fn new( + pax: [Pax; N], + default_boarding_agent: BoardingAgent, + boarding_agents: [BoardingAgent; G], + ) -> Self { PassengerDeck { pax, + default_boarding_agent, boarding_agents, } } @@ -191,8 +200,7 @@ impl PassengerDeck { boarding_agent.handle_one_pax(&mut self.pax); } } else { - // assume first agent as default - self.boarding_agents[0].force_one_pax(&mut self.pax); + self.default_boarding_agent.force_one_pax(&mut self.pax); } } @@ -219,7 +227,8 @@ impl PassengerDeck { boarding_agent.handle_one_pax(&mut self.pax); } } else { - self.boarding_agents[0].force_num_pax(pax_diff, &mut self.pax); + self.default_boarding_agent + .force_num_pax(pax_diff, &mut self.pax); } } } @@ -227,7 +236,8 @@ impl PassengerDeck { fn deboard_pax_until_target(&mut self, pax_target: i32) { let pax_diff = self.total_pax_num() - pax_target; if pax_diff > 0 { - self.boarding_agents[0].force_num_pax(pax_diff, &mut self.pax); + self.default_boarding_agent + .force_num_pax(pax_diff, &mut self.pax); } } }