Struct sim::transit::TransitSimState
source · pub(crate) struct TransitSimState {
buses: BTreeMap<CarID, Bus>,
routes: BTreeMap<TransitRouteID, Route>,
peds_waiting: BTreeMap<TransitStopID, Vec<(PedestrianID, TransitRouteID, Option<TransitStopID>, Time)>>,
events: Vec<Event>,
}
Expand description
Manages public transit vehicles (buses and trains) that follow a route. The transit model is currently kind of broken, so not describing the state machine yet.
Fields§
§buses: BTreeMap<CarID, Bus>
§routes: BTreeMap<TransitRouteID, Route>
§peds_waiting: BTreeMap<TransitStopID, Vec<(PedestrianID, TransitRouteID, Option<TransitStopID>, Time)>>
waiting at => (ped, route, bound for, started waiting)
events: Vec<Event>
Implementations§
source§impl TransitSimState
impl TransitSimState
pub fn new(map: &Map) -> TransitSimState
sourcepub fn create_empty_route(
&mut self,
bus_route: &TransitRoute,
map: &Map
) -> Path
pub fn create_empty_route( &mut self, bus_route: &TransitRoute, map: &Map ) -> Path
Returns the path for the first leg.
pub fn bus_created(&mut self, bus: CarID, r: TransitRouteID)
sourcepub fn bus_arrived_at_stop(
&mut self,
now: Time,
id: CarID,
trips: &mut TripManager,
walking: &mut WalkingSimState,
ctx: &mut Ctx<'_>
) -> bool
pub fn bus_arrived_at_stop( &mut self, now: Time, id: CarID, trips: &mut TripManager, walking: &mut WalkingSimState, ctx: &mut Ctx<'_> ) -> bool
If true, the bus is idling. If false, the bus actually arrived at a border and should now vanish.
TODO Misnomer – callback from Router::follow_bus_route
pub fn bus_departed_from_stop(&mut self, id: CarID, _: &Map) -> Router
sourcepub fn ped_waiting_for_bus(
&mut self,
now: Time,
ped: PedestrianID,
trip: TripID,
person: PersonID,
stop1: TransitStopID,
route_id: TransitRouteID,
maybe_stop2: Option<TransitStopID>,
_: &Map
) -> Option<CarID>
pub fn ped_waiting_for_bus( &mut self, now: Time, ped: PedestrianID, trip: TripID, person: PersonID, stop1: TransitStopID, route_id: TransitRouteID, maybe_stop2: Option<TransitStopID>, _: &Map ) -> Option<CarID>
Returns the bus if the pedestrian boarded immediately.
pub fn collect_events(&mut self) -> Vec<Event>
pub fn get_passengers( &self, bus: CarID ) -> &Vec<(PersonID, Option<TransitStopID>)>
pub fn bus_route(&self, bus: CarID) -> TransitRouteID
sourcepub fn buses_for_route(
&self,
route: TransitRouteID
) -> Vec<(CarID, Option<usize>)>
pub fn buses_for_route( &self, route: TransitRouteID ) -> Vec<(CarID, Option<usize>)>
also stop idx that the bus is coming from
sourcepub fn active_vehicles(&self) -> (usize, usize)
pub fn active_vehicles(&self) -> (usize, usize)
(buses, trains)
pub fn get_people_waiting_at_stop( &self, at: TransitStopID ) -> &Vec<(PedestrianID, TransitRouteID, Option<TransitStopID>, Time)>
pub fn get_unzoomed_transit_riders( &self, now: Time, driving: &DrivingSimState, map: &Map ) -> Vec<UnzoomedAgent>
Trait Implementations§
source§impl Clone for TransitSimState
impl Clone for TransitSimState
source§fn clone(&self) -> TransitSimState
fn clone(&self) -> TransitSimState
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<'de> Deserialize<'de> for TransitSimState
impl<'de> Deserialize<'de> for TransitSimState
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for TransitSimState
impl RefUnwindSafe for TransitSimState
impl Send for TransitSimState
impl Sync for TransitSimState
impl Unpin for TransitSimState
impl UnwindSafe for TransitSimState
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.