TemporaryCondition.swift 666 B

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