Skip to content

Commit

Permalink
feat(a380x/payload): redone boarding agents (priority boarding, stair…
Browse files Browse the repository at this point in the history
…s, etc) (flybywiresim#8985)

* fix(payload): correct boarding agent for U1L and M2L, added agents for possible quad stair boarding option

* fix: 6-> 8

* fix: rust lint

* feat: priority boarding order

* fix: adjusted values

* fix: review comments

---------

Co-authored-by: Andreas Guther <[email protected]>
  • Loading branch information
2hwk and aguther authored Oct 19, 2024
1 parent f4383fa commit 1be841d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 23 deletions.
10 changes: 6 additions & 4 deletions fbw-a32nx/src/wasm/systems/a320_systems/src/payload/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,22 +152,24 @@ impl A320Payload {
Mass::new::<kilogram>(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 {
Expand Down
33 changes: 22 additions & 11 deletions fbw-a380x/src/wasm/systems/a380_systems/src/payload/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl From<usize> 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
Expand Down Expand Up @@ -230,23 +230,34 @@ impl A380Payload {
Mass::new::<kilogram>(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 {
Expand Down
26 changes: 18 additions & 8 deletions fbw-common/src/wasm/systems/systems/src/payload/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ pub trait CargoPayload {

#[derive(Debug)]
pub struct BoardingAgent<const P: usize> {
door_id: VariableIdentifier,
door_id: Option<VariableIdentifier>,
door_open_ratio: Ratio,
order: [usize; P],
}
impl<const P: usize> BoardingAgent<P> {
pub fn new(door_id: VariableIdentifier, order: [usize; P]) -> Self {
pub fn new(door_id: Option<VariableIdentifier>, order: [usize; P]) -> Self {
BoardingAgent {
door_id,
order,
Expand Down Expand Up @@ -105,19 +105,28 @@ impl<const P: usize> BoardingAgent<P> {
}
impl<const P: usize> SimulationElement for BoardingAgent<P> {
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<const N: usize, const G: usize> {
pax: [Pax; N],
default_boarding_agent: BoardingAgent<N>,
boarding_agents: [BoardingAgent<N>; G],
}
impl<const N: usize, const G: usize> PassengerDeck<N, G> {
pub fn new(pax: [Pax; N], boarding_agents: [BoardingAgent<N>; G]) -> Self {
pub fn new(
pax: [Pax; N],
default_boarding_agent: BoardingAgent<N>,
boarding_agents: [BoardingAgent<N>; G],
) -> Self {
PassengerDeck {
pax,
default_boarding_agent,
boarding_agents,
}
}
Expand Down Expand Up @@ -191,8 +200,7 @@ impl<const N: usize, const G: usize> PassengerDeck<N, G> {
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);
}
}

Expand All @@ -219,15 +227,17 @@ impl<const N: usize, const G: usize> PassengerDeck<N, G> {
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);
}
}
}

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);
}
}
}
Expand Down

0 comments on commit 1be841d

Please sign in to comment.