AlarmType.swift 1.5 KB

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