TemporaryCondition.swift 598 B

123456789101112131415161718192021
  1. // LoopFollow
  2. // TemporaryCondition.swift
  3. // Created by Jonas Björkert on 2025-05-16.
  4. import Foundation
  5. /// A throw-away, single-fire BG-limit alarm.
  6. struct TemporaryCondition: AlarmCondition {
  7. static let type: AlarmType = .temporary
  8. init() {}
  9. func evaluate(alarm: Alarm, data _: AlarmData) -> Bool {
  10. // Needs at least ONE limit
  11. guard alarm.belowBG != nil || alarm.aboveBG != nil else { return false }
  12. // BG-limit checks are handled in shouldFire → passesBGLimits.
  13. // If we get here, the limits are satisfied ⇒ fire.
  14. return true
  15. }
  16. }