--- a/src/ui.rs +++ b/src/ui.rs @@ -136,6 +136,13 @@ window } +/// Map an Admin NIBP measurement interval to its dropdown selection. +/// The touchscreen alarm menus do not expose scheduling controls. +fn nibp_interval_index(minutes: i32) -> u32 { + const INTERVALS: [i32; 7] = [1, 3, 5, 10, 20, 30, 60]; + INTERVALS.iter().position(|&value| value == minutes).unwrap_or(2) as u32 +} + fn create_admin(app: &Application, params: SharedParams, simulator: Rc>, monitor: &ApplicationWindow, @@ -837,6 +844,14 @@ assert_eq!(stepped_hr_limit(None, 60, 1), 60); assert_eq!(stepped_hr_limit(None, 100, -1), 100); } + + #[test] + fn nibp_interval_dropdown_supports_every_admin_interval() { + for (index, minutes) in [1, 3, 5, 10, 20, 30, 60].into_iter().enumerate() { + assert_eq!(nibp_interval_index(minutes), index as u32); + } + assert_eq!(nibp_interval_index(999), 2); // 5-minute fallback + } } /// Touchscreen alarm controls for a numerical value. The two bounds are