PumpVolumeCondition.swift 573 B

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