|
|
|
@ -20,23 +20,25 @@ struct Trip {
|
|
|
|
|
down: f64
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const MAX_JERK: f64 = 0.2;
|
|
|
|
|
const MAX_ACCELERATION: f64 = 2.0;
|
|
|
|
|
const MAX_VELOCITY: f64 = 5.0;
|
|
|
|
|
|
|
|
|
|
fn main()
|
|
|
|
|
{
|
|
|
|
|
let simlog = File::open("simulation.log").expect("read simulation log");
|
|
|
|
|
let mut simlog = BufReader::new(&simlog);
|
|
|
|
|
let mut esp = None;
|
|
|
|
|
let mut jerk = 0.0;
|
|
|
|
|
let mut prev_est: Option<ElevatorState> = None;
|
|
|
|
|
let mut dst_timing: Vec<Trip> = Vec::new();
|
|
|
|
|
let mut start_location = 0.0;
|
|
|
|
|
|
|
|
|
|
let mut first_line = String::new();
|
|
|
|
|
let len = simlog.read_line(&mut first_line).unwrap();
|
|
|
|
|
let esp: ElevatorSpecification = serde_json::from_str(&first_line).unwrap();
|
|
|
|
|
|
|
|
|
|
for line in simlog.lines() {
|
|
|
|
|
let l = line.unwrap();
|
|
|
|
|
match esp.clone() {
|
|
|
|
|
None => {
|
|
|
|
|
let spec: ElevatorSpecification = serde_json::from_str(&l).unwrap();
|
|
|
|
|
esp = Some(spec);
|
|
|
|
|
},
|
|
|
|
|
Some(esp) => {
|
|
|
|
|
let (est, dst): (ElevatorState,u64) = serde_json::from_str(&l).unwrap();
|
|
|
|
|
let dl = dst_timing.len();
|
|
|
|
|
if dst_timing.len()==0 || dst_timing[dl-1].dst != dst {
|
|
|
|
@ -66,8 +68,6 @@ fn main()
|
|
|
|
|
}
|
|
|
|
|
prev_est = Some(est);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//elevator should not backup
|
|
|
|
|
let mut total_time = 0.0;
|
|
|
|
@ -87,13 +87,9 @@ fn main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//trips should finish within 20% of theoretical limit
|
|
|
|
|
let MAX_JERK = 0.2;
|
|
|
|
|
let MAX_ACCELERATION = 2.0;
|
|
|
|
|
let MAX_VELOCITY = 5.0;
|
|
|
|
|
|
|
|
|
|
let mut trip_start_location = start_location;
|
|
|
|
|
let mut theoretical_time = 0.0;
|
|
|
|
|
let floor_height = esp.unwrap().floor_height;
|
|
|
|
|
let floor_height = esp.floor_height;
|
|
|
|
|
for trip in dst_timing.clone()
|
|
|
|
|
{
|
|
|
|
|
let next_floor = (trip.dst as f64) * floor_height;
|
|
|
|
|