44 lines
1.5 KiB
Rust
44 lines
1.5 KiB
Rust
//! C-ITS DENM Evaluation
|
|
|
|
use c_its_parser::standards::denm_2_2_1::denm_pdu_description;
|
|
use log::info;
|
|
|
|
pub fn handle_denm(etsi: &denm_pdu_description::DENM) {
|
|
let mgmt = &etsi.denm.management;
|
|
|
|
if mgmt.termination.is_some() {
|
|
return;
|
|
}
|
|
|
|
if let (Some(sit), Some(loc)) = (&etsi.denm.situation, &etsi.denm.location) {
|
|
// let timestamp: chrono::DateTime<chrono::Utc> = mgmt.reference_time.clone().into();
|
|
let end_time = chrono::DateTime::<chrono::Utc>::from(mgmt.reference_time.clone())
|
|
+ chrono::Duration::seconds(mgmt.validity_duration.0.into());
|
|
let station_id = &mgmt.action_id.originating_station_id.0;
|
|
let seq_num = mgmt.action_id.sequence_number.0;
|
|
|
|
let lat_deg = mgmt.event_position.latitude.as_deg();
|
|
let lon_deg = mgmt.event_position.longitude.as_deg();
|
|
|
|
let heading = loc
|
|
.event_position_heading
|
|
.as_ref()
|
|
.map(|v| v.value.as_deg());
|
|
|
|
// let direction = mgmt.traffic_direction;
|
|
|
|
let (cc, scc) = sit.event_type.cc_and_scc.to_u8_tuple();
|
|
|
|
if let Some(hdg) = heading {
|
|
info!(
|
|
"DENN: {station_id}/{seq_num} CC {cc}/{scc} at {lat_deg:.3}°N, {lon_deg:.3}°E, hdg {hdg:.1}° until {end_time:?}"
|
|
);
|
|
} else {
|
|
info!(
|
|
"DENN: {station_id}/{seq_num} CC {cc}/{scc} at {lat_deg:.3}°N, {lon_deg:.3}°E until {end_time:?}"
|
|
);
|
|
}
|
|
} else {
|
|
info!("DENM: One of situation or location container not available");
|
|
}
|
|
}
|