spat: Show signal groups without timing information
This commit is contained in:
parent
f732585989
commit
ff45df8204
4 changed files with 35 additions and 24 deletions
|
|
@ -66,7 +66,7 @@ pub struct State {
|
|||
pub struct SignalGroupData {
|
||||
pub phase: SignalPhase,
|
||||
pub maneuver: map::Maneuvers,
|
||||
pub min_end_sec: i16,
|
||||
pub min_end_sec: Option<i16>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "spat")]
|
||||
|
|
@ -285,16 +285,20 @@ impl State {
|
|||
|
||||
use num_traits::Float;
|
||||
|
||||
let min_end = sig.min_end_time();
|
||||
let dur = min_end.sub(self.time.and_utc()).as_seconds_f32();
|
||||
|
||||
let phase = sig
|
||||
.phase()
|
||||
.map(core::convert::Into::into)
|
||||
.unwrap_or_default();
|
||||
|
||||
let min_end_sec = sig.min_end_time().map(|time| {
|
||||
let dur = time.sub(self.time.and_utc()).as_seconds_f32();
|
||||
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
let min_end_sec = dur.round() as i16;
|
||||
|
||||
min_end_sec
|
||||
});
|
||||
|
||||
Some(SignalGroupData {
|
||||
phase,
|
||||
maneuver: manv,
|
||||
|
|
|
|||
|
|
@ -154,15 +154,19 @@ impl Intersection {
|
|||
for state in &value.states.0 {
|
||||
let sig_grp = state.signal_group.0;
|
||||
|
||||
if let Some(event) = state.state_time_speed.0.first()
|
||||
&& let Some(timing) = &event.timing
|
||||
{
|
||||
if let Some(event) = state.state_time_speed.0.first() {
|
||||
// get write access to SignalGroup item
|
||||
if let Some(idx) = self.signal_groups.iter().position(|i| i.id == sig_grp)
|
||||
&& let Some(sig_grp) = self.signal_groups.get_mut(idx)
|
||||
{
|
||||
sig_grp.phase = Some(event.event_state);
|
||||
sig_grp.min_end_time = timing.min_end_time.to_datetime_from_moy(moy, year);
|
||||
if let Some(timing) = &event.timing
|
||||
&& !timing.min_end_time.is_out_of_range()
|
||||
&& !timing.min_end_time.is_unknown()
|
||||
{
|
||||
sig_grp.min_end_time =
|
||||
Some(timing.min_end_time.to_datetime_from_moy(moy, year));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// warn!("SPAT: SG {sig_grp:03} has no timing in first event");
|
||||
|
|
@ -211,7 +215,7 @@ impl Intersection {
|
|||
maneuvers,
|
||||
target_lanes,
|
||||
phase: None,
|
||||
min_end_time: chrono::DateTime::default(),
|
||||
min_end_time: None,
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
|
|
@ -397,7 +401,7 @@ pub struct SignalGroup {
|
|||
// SPAT data
|
||||
/// current signal phase
|
||||
phase: Option<etsi_its_dsrc::MovementPhaseState>,
|
||||
min_end_time: chrono::DateTime<chrono::Utc>,
|
||||
min_end_time: Option<chrono::DateTime<chrono::Utc>>,
|
||||
// max_end_time: Option<chrono::DateTime<chrono::Utc>>,
|
||||
// likely_time: Option<chrono::DateTime<chrono::Utc>>,
|
||||
}
|
||||
|
|
@ -425,7 +429,7 @@ impl SignalGroup {
|
|||
pub fn phase(&self) -> Option<etsi_its_dsrc::MovementPhaseState> {
|
||||
self.phase
|
||||
}
|
||||
pub fn min_end_time(&self) -> chrono::prelude::DateTime<chrono::prelude::Utc> {
|
||||
pub fn min_end_time(&self) -> Option<chrono::prelude::DateTime<chrono::prelude::Utc>> {
|
||||
self.min_end_time
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -179,10 +179,11 @@ async fn main(spawner: Spawner) -> ! {
|
|||
let signal_groups = state.run_glosa();
|
||||
|
||||
for sig in &signal_groups {
|
||||
println!(
|
||||
"GLOSA: {} {} for {} s",
|
||||
sig.maneuver, sig.phase, sig.min_end_sec
|
||||
);
|
||||
let duration_str = sig
|
||||
.min_end_sec
|
||||
.map(|v| alloc::format!("for {v} s"))
|
||||
.unwrap_or_default();
|
||||
println!("GLOSA: {} {} {duration_str}", sig.maneuver, sig.phase);
|
||||
}
|
||||
|
||||
#[cfg(feature = "screen")]
|
||||
|
|
|
|||
|
|
@ -113,14 +113,16 @@ where
|
|||
.draw(target)?;
|
||||
|
||||
// draw timing indicator
|
||||
if let Some(min_end_sec) = sig.min_end_sec {
|
||||
text::Text::with_alignment(
|
||||
&alloc::format!("{}s", sig.min_end_sec),
|
||||
&alloc::format!("{min_end_sec}s"),
|
||||
geometry::Point::new(centerline, 160),
|
||||
text_style,
|
||||
text::Alignment::Center,
|
||||
)
|
||||
.draw(target)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue