PumpBatteryCondition.swift 428 B

1234567891011121314151617
  1. // LoopFollow
  2. // PumpBatteryCondition.swift
  3. import Foundation
  4. struct PumpBatteryCondition: AlarmCondition {
  5. static let type: AlarmType = .pumpBattery
  6. init() {}
  7. func evaluate(alarm: Alarm, data: AlarmData, now _: Date) -> Bool {
  8. guard let limit = alarm.threshold, limit > 0 else { return false }
  9. guard let level = data.latestPumpBattery else { return false }
  10. return level <= limit
  11. }
  12. }