AlarmType.swift 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // LoopFollow
  2. // AlarmType.swift
  3. import Foundation
  4. /// Categorizes alarms into distinct types, prioritized in the order they appear here.
  5. /// Multiple user-defined alarms may share the same type but differ in configuration.
  6. enum AlarmType: String, CaseIterable, Codable {
  7. case temporary = "Temporary Alert"
  8. case iob = "IOB Alert"
  9. case cob = "COB Alert"
  10. case low = "Low BG Alert"
  11. case high = "High BG Alert"
  12. case fastDrop = "Fast Drop Alert"
  13. case fastRise = "Fast Rise Alert"
  14. case missedReading = "Missed Reading Alert"
  15. case notLooping = "Not Looping Alert"
  16. case missedBolus = "Missed Bolus Alert"
  17. case sensorChange = "Sensor Change Alert"
  18. case pumpChange = "Pump Change Alert"
  19. case pump = "Pump Insulin Alert"
  20. case pumpBattery = "Pump Battery Alert"
  21. case battery = "Low Battery"
  22. case batteryDrop = "Battery Drop"
  23. case recBolus = "Rec. Bolus"
  24. case overrideStart = "Override Started"
  25. case overrideEnd = "Override Ended"
  26. case tempTargetStart = "Temp Target Started"
  27. case tempTargetEnd = "Temp Target Ended"
  28. case buildExpire = "Looping app expiration"
  29. }
  30. extension AlarmType {
  31. var priority: Int {
  32. return AlarmType.allCases.firstIndex(of: self) ?? 0
  33. }
  34. }
  35. extension AlarmType {
  36. /// `true` for alarms whose primary trigger is a blood-glucose value
  37. /// or its rate of change.
  38. var isBGBased: Bool {
  39. switch self {
  40. case .low, .high, .fastDrop, .fastRise, .missedReading, .temporary:
  41. return true
  42. default:
  43. return false
  44. }
  45. }
  46. }