PumpVolumeCondition.swift 604 B

1234567891011121314151617181920
  1. // LoopFollow
  2. // PumpVolumeCondition.swift
  3. // Created by Jonas Björkert.
  4. import Foundation
  5. /// Fires when the most-recent pump‐reservoir reading is **≤ threshold units**.
  6. /// Re-fires after the user-chosen snooze expires.
  7. struct PumpVolumeCondition: AlarmCondition {
  8. static let type: AlarmType = .pump
  9. init() {}
  10. func evaluate(alarm: Alarm, data: AlarmData, now _: Date) -> Bool {
  11. guard let threshold = alarm.threshold, threshold > 0 else { return false }
  12. guard let latestVol = data.latestPumpVolume else { return false }
  13. return latestVol <= threshold
  14. }
  15. }