rename CarState enum

This commit is contained in:
Dustin Carlino 2019-02-26 16:39:17 -08:00
parent fdecedc508
commit b3b4f82f45
10 changed files with 36 additions and 36 deletions

View File

@ -1,7 +1,7 @@
use crate::plugins::sim::des_model::interval::{Delta, Interval};
use geom::{Acceleration, Distance, Duration, Speed, EPSILON_DIST};
use map_model::{Lane, Traversable};
use sim::{CarID, CarState, DrawCarInput, VehicleType};
use sim::{CarID, CarStatus, DrawCarInput, VehicleType};
use std::cmp;
pub const FOLLOWING_DISTANCE: Distance = Distance::const_meters(1.0);
@ -9,7 +9,7 @@ pub const FOLLOWING_DISTANCE: Distance = Distance::const_meters(1.0);
pub struct Car {
pub id: CarID,
// Hack used for different colors
pub state: CarState,
pub state: CarStatus,
pub car_length: Distance,
// Note that if we always used these, things would look quite jerky.
pub max_accel: Acceleration,
@ -77,7 +77,7 @@ impl Car {
id: self.id,
waiting_for_turn: None,
stopping_trace: None,
state: self.state,
status: self.state,
vehicle_type: VehicleType::Car,
on: Traversable::Lane(lane.id),
body: lane

View File

@ -6,7 +6,7 @@ use crate::plugins::sim::des_model::car::Car;
use ezgui::{GfxCtx, Text};
use geom::{Acceleration, Distance, Duration, Speed, EPSILON_DIST};
use map_model::{LaneID, Map};
use sim::{CarID, CarState, DrawCarInput, VehicleType};
use sim::{CarID, CarStatus, DrawCarInput, VehicleType};
pub struct World {
pub lane: LaneID,
@ -20,7 +20,7 @@ impl World {
let mut leader = Car {
id: CarID::tmp_new(0, VehicleType::Car),
state: CarState::Moving,
state: CarStatus::Moving,
car_length: Distance::meters(5.0),
max_accel: Acceleration::meters_per_second_squared(2.5),
max_deaccel: Acceleration::meters_per_second_squared(-3.0),
@ -39,7 +39,7 @@ impl World {
for i in 0..num_followers {
let mut follower = Car {
id: CarID::tmp_new(cars.len(), VehicleType::Car),
state: CarState::Stuck,
state: CarStatus::Stuck,
car_length: Distance::meters(5.0),
max_accel: Acceleration::meters_per_second_squared(4.5),
max_deaccel: Acceleration::meters_per_second_squared(-2.0),

View File

@ -4,7 +4,7 @@ use crate::plugins::sim::new_des_model::{
use geom::{Distance, Duration, PolyLine};
use map_model::{Map, Traversable, LANE_THICKNESS};
use serde_derive::{Deserialize, Serialize};
use sim::DrawCarInput;
use sim::{CarStatus, DrawCarInput};
use std::collections::VecDeque;
#[derive(Debug, Serialize, Deserialize)]
@ -107,13 +107,13 @@ impl Car {
id: self.vehicle.id,
waiting_for_turn: None,
stopping_trace: None,
state: match self.state {
status: match self.state {
// TODO Cars can be Queued behind a slow Crossing. Looks kind of weird.
CarState::Queued => sim::CarState::Stuck,
CarState::Crossing(_, _) => sim::CarState::Moving,
CarState::Queued => CarStatus::Stuck,
CarState::Crossing(_, _) => CarStatus::Moving,
// Eh they're technically moving, but this is a bit easier to spot
CarState::Unparking(_, _) => sim::CarState::Parked,
CarState::Parking(_, _, _) => sim::CarState::Parked,
CarState::Unparking(_, _) => CarStatus::Parked,
CarState::Parking(_, _, _) => CarStatus::Parked,
},
vehicle_type: self.vehicle.vehicle_type,
on: self.router.head(),

View File

@ -7,7 +7,7 @@ use map_model;
use map_model::{BuildingID, Lane, LaneID, LaneType, Map, Position, Traversable};
use multimap::MultiMap;
use serde_derive::{Deserialize, Serialize};
use sim::{CarID, CarState, DrawCarInput, VehicleType};
use sim::{CarID, CarStatus, DrawCarInput, VehicleType};
use std::collections::{BTreeMap, BTreeSet};
use std::iter;
@ -126,7 +126,7 @@ impl ParkingSimState {
id: p.vehicle.id,
waiting_for_turn: None,
stopping_trace: None,
state: CarState::Parked,
status: CarStatus::Parked,
vehicle_type: VehicleType::Car,
on: Traversable::Lane(lane),

View File

@ -4,7 +4,7 @@ use crate::render::{RenderOptions, Renderable};
use ezgui::{Color, Drawable, GfxCtx, Prerender};
use geom::{Bounds, Distance, Polygon, Pt2D};
use map_model::Map;
use sim::{CarID, CarState, DrawCarInput};
use sim::{CarID, CarStatus, DrawCarInput};
const BIKE_WIDTH: Distance = Distance::const_meters(0.8);
@ -24,14 +24,14 @@ impl DrawBike {
let polygon = input.body.make_polygons(BIKE_WIDTH);
let draw_default = prerender.upload_borrowed(vec![(
match input.state {
CarState::Debug => cs
match input.status {
CarStatus::Debug => cs
.get_def("debug bike", Color::BLUE.alpha(0.8))
.shift(input.id.0),
// TODO Hard to see on the greenish bike lanes? :P
CarState::Moving => cs.get_def("moving bike", Color::GREEN).shift(input.id.0),
CarState::Stuck => cs.get_def("stuck bike", Color::RED).shift(input.id.0),
CarState::Parked => panic!("Can't have a parked bike"),
CarStatus::Moving => cs.get_def("moving bike", Color::GREEN).shift(input.id.0),
CarStatus::Stuck => cs.get_def("stuck bike", Color::RED).shift(input.id.0),
CarStatus::Parked => panic!("Can't have a parked bike"),
},
&polygon,
)]);

View File

@ -4,7 +4,7 @@ use crate::render::{RenderOptions, Renderable};
use ezgui::{Color, Drawable, GfxCtx, Prerender};
use geom::{Angle, Bounds, Circle, Distance, PolyLine, Polygon, Pt2D};
use map_model::{Map, TurnType};
use sim::{CarID, CarState, DrawCarInput};
use sim::{CarID, CarStatus, DrawCarInput};
use std;
const CAR_WIDTH: Distance = Distance::const_meters(2.0);
@ -78,11 +78,11 @@ impl DrawCar {
let body_polygon = input.body.make_polygons(CAR_WIDTH);
// TODO if it's a bus, color it differently -- but how? :\
let color = match input.state {
CarState::Debug => cs.get_def("debug car", Color::BLUE.alpha(0.8)),
CarState::Moving => cs.get_def("moving car", Color::CYAN),
CarState::Stuck => cs.get_def("stuck car", Color::rgb_f(0.9, 0.0, 0.0)),
CarState::Parked => cs.get_def("parked car", Color::rgb(180, 233, 76)),
let color = match input.status {
CarStatus::Debug => cs.get_def("debug car", Color::BLUE.alpha(0.8)),
CarStatus::Moving => cs.get_def("moving car", Color::CYAN),
CarStatus::Stuck => cs.get_def("stuck car", Color::rgb_f(0.9, 0.0, 0.0)),
CarStatus::Parked => cs.get_def("parked car", Color::rgb(180, 233, 76)),
};
let draw_default = prerender.upload_borrowed(vec![
(

View File

@ -6,7 +6,7 @@ use crate::router::Router;
use crate::transit::TransitSimState;
use crate::view::{AgentView, WorldView};
use crate::{
AgentID, CarID, CarState, DrawCarInput, Event, ParkedCar, ParkingSpot, Tick, TripID,
AgentID, CarID, CarStatus, DrawCarInput, Event, ParkedCar, ParkingSpot, Tick, TripID,
VehicleType, TIMESTEP,
};
use abstutil;
@ -935,12 +935,12 @@ impl DrivingSimState {
map,
Some(c.vehicle.stopping_distance(c.speed).unwrap()),
),
state: if c.debug {
CarState::Debug
status: if c.debug {
CarStatus::Debug
} else if c.speed.is_zero(TIMESTEP) {
CarState::Stuck
CarStatus::Stuck
} else {
CarState::Moving
CarStatus::Moving
},
vehicle_type: c.vehicle.vehicle_type,
on: c.on,

View File

@ -29,7 +29,7 @@ pub use crate::make::{
};
pub use crate::physics::{Tick, TIMESTEP};
pub use crate::query::{Benchmark, ScoreSummary, SimStats, Summary};
pub use crate::render::{CarState, DrawCarInput, DrawPedestrianInput, GetDrawAgents};
pub use crate::render::{CarStatus, DrawCarInput, DrawPedestrianInput, GetDrawAgents};
pub use crate::sim::Sim;
use abstutil::Cloneable;
use map_model::{BuildingID, LaneID};

View File

@ -1,5 +1,5 @@
use crate::kinematics::Vehicle;
use crate::{CarID, CarState, DrawCarInput, ParkedCar, ParkingSpot, VehicleType};
use crate::{CarID, CarStatus, DrawCarInput, ParkedCar, ParkingSpot, VehicleType};
use abstutil::{deserialize_btreemap, serialize_btreemap};
use geom::{Angle, Distance, Pt2D};
use map_model;
@ -95,7 +95,7 @@ impl ParkingSimState {
id: p.car,
waiting_for_turn: None,
stopping_trace: None,
state: CarState::Parked,
status: CarStatus::Parked,
vehicle_type: VehicleType::Car,
on: Traversable::Lane(lane),

View File

@ -17,7 +17,7 @@ pub struct DrawCarInput {
pub id: CarID,
pub waiting_for_turn: Option<TurnID>,
pub stopping_trace: Option<Trace>,
pub state: CarState,
pub status: CarStatus,
// TODO This is definitely redundant
pub vehicle_type: VehicleType,
pub on: Traversable,
@ -27,7 +27,7 @@ pub struct DrawCarInput {
}
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum CarState {
pub enum CarStatus {
Moving,
Stuck,
Parked,