AlarmType.swift 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 futureCarbs = "Future Carbs Alert"
  18. case sensorChange = "Sensor Change Alert"
  19. case pumpChange = "Pump Change Alert"
  20. case pump = "Pump Insulin Alert"
  21. case pumpBattery = "Pump Battery Alert"
  22. case battery = "Low Battery"
  23. case batteryDrop = "Battery Drop"
  24. case recBolus = "Rec. Bolus"
  25. case overrideStart = "Override Started"
  26. case overrideEnd = "Override Ended"
  27. case tempTargetStart = "Temp Target Started"
  28. case tempTargetEnd = "Temp Target Ended"
  29. case buildExpire = "Looping app expiration"
  30. }
  31. extension AlarmType {
  32. var priority: Int {
  33. return AlarmType.allCases.firstIndex(of: self) ?? 0
  34. }
  35. }
  36. extension AlarmType {
  37. /// `true` for alarms whose primary trigger is a blood-glucose value
  38. /// or its rate of change.
  39. var isBGBased: Bool {
  40. switch self {
  41. case .low, .high, .fastDrop, .fastRise, .missedReading, .temporary:
  42. return true
  43. default:
  44. return false
  45. }
  46. }
  47. }