TemporaryCondition.swift 566 B

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