From c4c61cf7d9d9ffa6b3aba482c8fc9d75892966b5 Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Wed, 22 Apr 2020 16:16:17 -0700 Subject: [PATCH] recording and communicating delayed starts --- data/MANIFEST.txt | 18 ++++++------- data/system/assets/timeline/delayed_start.svg | 3 +++ game/src/info/person.rs | 26 +++++++++++++------ game/src/info/trip.rs | 10 +++++++ sim/src/events.rs | 2 ++ sim/src/trips.rs | 7 +++++ 6 files changed, 49 insertions(+), 17 deletions(-) create mode 100644 data/system/assets/timeline/delayed_start.svg diff --git a/data/MANIFEST.txt b/data/MANIFEST.txt index 0d28f05d0c..23b6c037cb 100644 --- a/data/MANIFEST.txt +++ b/data/MANIFEST.txt @@ -196,6 +196,7 @@ c8433d44c82e2471ee777c90d4bcd449 data/system/assets/timeline/goal_pos.svg 4527c9b19de34133f1db07577284e7cf data/system/assets/timeline/biking.svg 28f143690de67bbda88e141228393c1c data/system/assets/timeline/parking.svg 8bf3eba8ea9d96e00395ad117385d0e5 data/system/assets/timeline/waiting_for_bus.svg +6c85abc97c8faf30defe1cfb53af4fe8 data/system/assets/timeline/delayed_start.svg cb589c4b42bb9f3bdaabbf485897ab51 data/system/assets/timeline/current_pos.svg 10b02a86fe4b695ee5bfcde982a41c10 data/system/assets/timeline/walking.svg 680d81bc03b0115abcc85a28885ae94b data/system/assets/timeline/driving.svg @@ -227,16 +228,15 @@ e27d41c916a721b330459ce85a114dbc data/system/maps/23rd.bin cc45f42cb24cad1cfdbf5ed7a0cb86d4 data/system/synthetic_maps/signal_double.json 8b949cc34d9a27ace0bd8ecde55a9520 data/system/synthetic_maps/signal_single.json 1cd7be125e1d992613ed3a41e8b25b6a data/system/synthetic_maps/signal_fan_in.json -e6e6a0d69e999d13914d038182a610df data/system/scenarios/ballard/weekday.bin -90a2f56be7381f7cb7d6fe581ccbd71c data/system/scenarios/intl_district/weekday.bin -06e5969553aac31397fb82a46d965218 data/system/scenarios/23rd/weekday.bin -55e34b7ad84ba414d7a727105b2a4214 data/system/scenarios/lakeslice/weekday.bin -c13a214eeac17fe005531e9d2b820371 data/system/scenarios/downtown/weekday.bin -23484818ce17120fd059fc8e12590487 data/system/scenarios/huge_seattle/weekday.bin -ce9000d9f0fb5e80f87580808641f5e0 data/system/scenarios/caphill/weekday.bin -06552edb374a27ac8cbf84e0bde83cac data/system/scenarios/montlake/weekday.bin +3395f869c843e975a865ec6abdfd73a6 data/system/scenarios/ballard/weekday.bin +5808fa3463d40ebdc11df740af957e27 data/system/scenarios/intl_district/weekday.bin +ba178b246461b66a0b888fae82392be6 data/system/scenarios/23rd/weekday.bin +8dae2cd0dd23a72d9b225a218b203c13 data/system/scenarios/lakeslice/weekday.bin +e26238b69d0ce1c00948221d9a089445 data/system/scenarios/downtown/weekday.bin +7fa74272f3b443f985c8e2c9f2eb6175 data/system/scenarios/huge_seattle/weekday.bin +dfe4f16099b828e06cedea0eaa1531d9 data/system/scenarios/caphill/weekday.bin +f180a68083c44e0e21b65e3e63be8068 data/system/scenarios/montlake/weekday.bin ae0946df6ab1edf0ca3b6959093e27d3 data/system/prebaked_results/signal_single/tutorial lvl1.bin 1d0772af01ceea5d1f28e586b227597e data/system/prebaked_results/signal_single/tutorial lvl2.bin fcc727e48613c12ab336847b81a43bf4 data/system/prebaked_results/montlake/car vs bike contention.bin -a8ae974a16816f4a74b7d87d155fee83 data/system/prebaked_results/montlake/weekday.bin 560083ca84a7367a4bc11a320655206b data/system/prebaked_results/montlake/car vs bus contention.bin diff --git a/data/system/assets/timeline/delayed_start.svg b/data/system/assets/timeline/delayed_start.svg new file mode 100644 index 0000000000..4d238ceba1 --- /dev/null +++ b/data/system/assets/timeline/delayed_start.svg @@ -0,0 +1,3 @@ + + + diff --git a/game/src/info/person.rs b/game/src/info/person.rs index 1a3f47ff51..8349bd233f 100644 --- a/game/src/info/person.rs +++ b/game/src/info/person.rs @@ -41,14 +41,24 @@ pub fn trips( wheres_waldo = false; rows.push(current_status(ctx, person, map)); } - - ( - "future", - Color::hex("#4CA7E9"), - open_trips - .get(t) - .map(|_| trip::future(ctx, app, *t, details)), - ) + let start_time = sim.trip_info(*t).0; + if sim.time() > start_time { + ( + "delayed start", + Color::YELLOW, + open_trips + .get(t) + .map(|_| trip::future(ctx, app, *t, details)), + ) + } else { + ( + "future", + Color::hex("#4CA7E9"), + open_trips + .get(t) + .map(|_| trip::future(ctx, app, *t, details)), + ) + } } TripResult::Ok(a) => { assert!(wheres_waldo); diff --git a/game/src/info/trip.rs b/game/src/info/trip.rs index 8aaa20524e..54d66969bb 100644 --- a/game/src/info/trip.rs +++ b/game/src/info/trip.rs @@ -111,6 +111,14 @@ pub fn future(ctx: &mut EventCtx, app: &App, trip: TripID, details: &mut Details let mut col = Vec::new(); + let now = app.primary.sim.time(); + if now > start_time { + col.extend(make_table( + ctx, + vec![("Start delayed", (now - start_time).to_string())], + )); + } + if let Some(estimated_trip_time) = app .has_prebaked() .and_then(|_| app.prebaked().finished_trip_time(trip)) @@ -341,6 +349,7 @@ fn make_timeline( TripPhaseType::WaitingForBus(_, _) => app.cs.bus_stop, TripPhaseType::RidingBus(_, _, _) => app.cs.bus_lane, TripPhaseType::Aborted | TripPhaseType::Finished => unreachable!(), + TripPhaseType::DelayedStart => Color::YELLOW, } .alpha(0.7); @@ -402,6 +411,7 @@ fn make_timeline( "../data/system/assets/timeline/riding_bus.svg" } TripPhaseType::Aborted | TripPhaseType::Finished => unreachable!(), + TripPhaseType::DelayedStart => "../data/system/assets/timeline/delayed_start.svg", }, // TODO Hardcoded layouting... Pt2D::new(0.5 * phase_width, -20.0), diff --git a/sim/src/events.rs b/sim/src/events.rs index e168b6d402..8e4b87f770 100644 --- a/sim/src/events.rs +++ b/sim/src/events.rs @@ -61,6 +61,7 @@ pub enum TripPhaseType { RidingBus(BusRouteID, BusStopID, CarID), Aborted, Finished, + DelayedStart, } impl TripPhaseType { @@ -74,6 +75,7 @@ impl TripPhaseType { TripPhaseType::RidingBus(r, _, _) => format!("riding bus {}", map.get_br(r).name), TripPhaseType::Aborted => "trip aborted due to some bug".to_string(), TripPhaseType::Finished => "trip finished".to_string(), + TripPhaseType::DelayedStart => "delayed by previous trip taking too long".to_string(), } } } diff --git a/sim/src/trips.rs b/sim/src/trips.rs index 7af27c4541..57ae6f61a4 100644 --- a/sim/src/trips.rs +++ b/sim/src/trips.rs @@ -826,6 +826,13 @@ impl TripManager { person .delayed_trips .push((trip, spec, maybe_req, maybe_path)); + self.events.push(Event::TripPhaseStarting( + trip, + person.id, + self.trips[trip.0].mode, + None, + TripPhaseType::DelayedStart, + )); return; }