added parameter station to determine the location to be checked
This commit is contained in:
@@ -34,6 +34,8 @@ struct Args {
|
|||||||
port: u16,
|
port: u16,
|
||||||
#[arg(long, default_value_t = 300)]
|
#[arg(long, default_value_t = 300)]
|
||||||
interval: u32,
|
interval: u32,
|
||||||
|
#[arg(long, default_value = "Lettestr")]
|
||||||
|
station: String,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +55,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
//FIXME Set last_request initially to 1 hour before now
|
//FIXME Set last_request initially to 1 hour before now
|
||||||
let mut last_request = Instant::now() - Duration::from_secs(3600);
|
let mut last_request = Instant::now() - Duration::from_secs(3600);
|
||||||
let interval = Duration::from_secs(args.interval as u64);
|
let interval = Duration::from_secs(args.interval as u64);
|
||||||
let station_id = tokio::task::spawn_blocking(|| straba::lookup_station_id("Lettestr"))
|
let station_id = tokio::task::spawn_blocking(move || straba::lookup_station_id(&args.station))
|
||||||
.await
|
.await
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.expect("Failed to lookup station ID");
|
.expect("Failed to lookup station ID");
|
||||||
|
|||||||
@@ -214,6 +214,17 @@ pub fn fetch_data(station_id: u64, debug_print: Option<bool>) -> NextDeparture {
|
|||||||
return_value.inbound_station = stop.destination_label;
|
return_value.inbound_station = stop.destination_label;
|
||||||
return_value.inbound_diff = diff;
|
return_value.inbound_diff = diff;
|
||||||
}
|
}
|
||||||
|
} else if stop.destination_label.contains("Mannheim") {
|
||||||
|
if diff < return_value.inbound_diff {
|
||||||
|
return_value.inbound_station = stop.destination_label;
|
||||||
|
return_value.inbound_diff = diff;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Unkown stations are declared as outbound
|
||||||
|
if diff < return_value.outbound_diff {
|
||||||
|
return_value.outbound_station = stop.destination_label;
|
||||||
|
return_value.outbound_diff = diff;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println!(
|
println!(
|
||||||
|
|||||||
Reference in New Issue
Block a user