51 lines
1.9 KiB
Rust
51 lines
1.9 KiB
Rust
//! C-ITS Traffic Light Data (MAPEM/ SPATEM) Evaluation
|
|
|
|
use c_its_parser::standards::mapem_2_2_1::mapem_pdu_descriptions;
|
|
use c_its_parser::standards::spatem_2_2_1::spatem_pdu_descriptions;
|
|
use chrono::Datelike;
|
|
use esp_println::println;
|
|
|
|
pub fn handle_mapem(etsi: &mapem_pdu_descriptions::MAPEM) {
|
|
// TODO: proof of concept only -- replace with actual evaluation
|
|
if let Some(map) = &etsi.map.intersections {
|
|
for int in &map.0 {
|
|
println!("got MAPEM for intersection {}", int.id.id.0);
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn handle_spatem(etsi: &spatem_pdu_descriptions::SPATEM, now: &chrono::NaiveDateTime) {
|
|
// TODO: proof of concept only -- replace with actual evaluation
|
|
for int in &etsi.spat.intersections.0 {
|
|
println!("got SPATEM for intersection {}", int.id.id.0);
|
|
|
|
if let (Some(moy), Some(second)) = (&int.moy, &int.time_stamp) {
|
|
let year = now.year();
|
|
|
|
let ref_time = c_its_parser::time_utils::time_from_moy_and_dsecond(moy, second, year);
|
|
println!("- ref time: {ref_time:?}");
|
|
|
|
for state in &int.states.0 {
|
|
let sig_grp = state.signal_group.0;
|
|
|
|
if let Some(event) = state.state_time_speed.0.first() {
|
|
if let Some(timing) = &event.timing {
|
|
let min_end_time = timing.min_end_time.to_datetime_from_moy(moy, year);
|
|
|
|
println!(
|
|
"- sig grp. {sig_grp:03}: until {min_end_time:?} at {:?}",
|
|
event.event_state
|
|
);
|
|
} else {
|
|
println!(
|
|
"- sig grp. {sig_grp:03}: {:?} until unknown",
|
|
event.event_state
|
|
);
|
|
}
|
|
} else {
|
|
println!("- sig grp. {sig_grp:03}: no events");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|