feat: Add some message parsing
This commit is contained in:
parent
919065f377
commit
9bf8b8e4de
8 changed files with 1006 additions and 6 deletions
65
src/applogic/cam.rs
Normal file
65
src/applogic/cam.rs
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
//! C-ITS CAM Evaluation
|
||||
|
||||
use c_its_parser::standards::cam_1_4_1::cam_pdu_descriptions::{self, HighFrequencyContainer};
|
||||
use log::info;
|
||||
|
||||
pub fn handle_cam(etsi: &cam_pdu_descriptions::CAM) {
|
||||
// only POC output
|
||||
match &etsi.cam.cam_parameters.high_frequency_container {
|
||||
HighFrequencyContainer::basicVehicleContainerHighFrequency(obu) => {
|
||||
let station_id = etsi.header.station_id.0;
|
||||
let lat_deg = etsi
|
||||
.cam
|
||||
.cam_parameters
|
||||
.basic_container
|
||||
.reference_position
|
||||
.latitude
|
||||
.as_deg();
|
||||
let lon_deg = etsi
|
||||
.cam
|
||||
.cam_parameters
|
||||
.basic_container
|
||||
.reference_position
|
||||
.longitude
|
||||
.as_deg();
|
||||
|
||||
if obu.speed.speed_value.is_unavailable() {
|
||||
info!(
|
||||
"Got CAM from {station_id} at {lat_deg:.3}°N, {lon_deg:.3}°E, speed unavailable",
|
||||
);
|
||||
} else {
|
||||
info!(
|
||||
"Got CAM from {station_id} at {lat_deg:.3}°N, {lon_deg:.3}°E, speed {:.2} km/h",
|
||||
obu.speed.speed_value.as_kmh()
|
||||
);
|
||||
}
|
||||
}
|
||||
HighFrequencyContainer::rsuContainerHighFrequency(rsu) => {
|
||||
info!(
|
||||
"Got RSU from {} at {:.3}°N, {:.3}°E, {} protected zones",
|
||||
etsi.header.station_id.0,
|
||||
etsi.cam
|
||||
.cam_parameters
|
||||
.basic_container
|
||||
.reference_position
|
||||
.latitude
|
||||
.as_deg(),
|
||||
etsi.cam
|
||||
.cam_parameters
|
||||
.basic_container
|
||||
.reference_position
|
||||
.longitude
|
||||
.as_deg(),
|
||||
rsu.protected_communication_zones_rsu
|
||||
.as_ref()
|
||||
.map(|d| d.0.len())
|
||||
.unwrap_or_default()
|
||||
);
|
||||
}
|
||||
|
||||
_ => {
|
||||
// enum is non-exhaustive, so we need a default case
|
||||
// but this should never be reached in pactical applications
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue