pub struct SignalTiming {
pub cycle_s: f64,
pub offset_s: f64,
pub green_phases_s: Vec<f64>,
}Expand description
Fixed-time signal timing parameters.
Describes a repeating cycle of green and red intervals. Multiple green phases can be specified (their durations are summed to form the total green window at the start of each cycle).
Fields§
§cycle_s: f64Total cycle length in seconds.
offset_s: f64Offset in seconds (shifts the start of the green window).
green_phases_s: Vec<f64>Durations of each green phase in seconds. The sum of these values defines the total green window at the start of each cycle.
Implementations§
Source§impl SignalTiming
impl SignalTiming
Sourcepub fn new(cycle_s: f64, offset_s: f64, green_phases_s: Vec<f64>) -> Self
pub fn new(cycle_s: f64, offset_s: f64, green_phases_s: Vec<f64>) -> Self
Create a new signal timing with the given cycle, offset, and green phase durations.
Sourcepub fn phase_at(&self, sim_time_s: f64) -> (SignalPhase, f64)
pub fn phase_at(&self, sim_time_s: f64) -> (SignalPhase, f64)
Determine the signal phase at the given simulation time.
Returns (phase, remaining_s) where remaining_s is the time in
seconds until the phase changes.
- If
cycle_s <= 0, returns(Green, 0.0). - If total green >= cycle, returns
(Green, 0.0)(always permissive). - If total green <= 0, returns
(Red, cycle_s)(always blocked).
Sourcepub fn total_green_s(&self) -> f64
pub fn total_green_s(&self) -> f64
Total green time per cycle (sum of all green phase durations).
Sourcepub fn total_red_s(&self) -> f64
pub fn total_red_s(&self) -> f64
Total red time per cycle.
Sourcepub fn green_ratio(&self) -> f64
pub fn green_ratio(&self) -> f64
Green ratio (g/C). Returns 0.0 if cycle is zero.
Trait Implementations§
Source§impl Clone for SignalTiming
impl Clone for SignalTiming
Source§fn clone(&self) -> SignalTiming
fn clone(&self) -> SignalTiming
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more