| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- // LoopFollow
- // AlarmType.swift
- import Foundation
- /// Categorizes alarms into distinct types, prioritized in the order they appear here.
- /// Multiple user-defined alarms may share the same type but differ in configuration.
- enum AlarmType: String, CaseIterable, Codable {
- case temporary = "Temporary Alert"
- case iob = "IOB Alert"
- case cob = "COB Alert"
- case low = "Low BG Alert"
- case high = "High BG Alert"
- case fastDrop = "Fast Drop Alert"
- case fastRise = "Fast Rise Alert"
- case missedReading = "Missed Reading Alert"
- case notLooping = "Not Looping Alert"
- case missedBolus = "Missed Bolus Alert"
- case futureCarbs = "Future Carbs Alert"
- case sensorChange = "Sensor Change Alert"
- case pumpChange = "Pump Change Alert"
- case pump = "Pump Insulin Alert"
- case pumpBattery = "Pump Battery Alert"
- case battery = "Low Battery"
- case batteryDrop = "Battery Drop"
- case recBolus = "Rec. Bolus"
- case overrideStart = "Override Started"
- case overrideEnd = "Override Ended"
- case tempTargetStart = "Temp Target Started"
- case tempTargetEnd = "Temp Target Ended"
- case buildExpire = "Looping app expiration"
- case dbSize = "Nightscout Database Size"
- }
- extension AlarmType {
- var priority: Int {
- return AlarmType.allCases.firstIndex(of: self) ?? 0
- }
- }
- extension AlarmType {
- /// Localized, user-facing title. `rawValue` stays the stable identity/storage key
- /// (used for the alarm's default name and logs); this is only for display.
- var localizedTitle: String {
- String(localized: String.LocalizationValue(rawValue))
- }
- }
- extension AlarmType {
- /// `true` for alarms whose primary trigger is a blood-glucose value
- /// or its rate of change.
- var isBGBased: Bool {
- switch self {
- case .low, .high, .fastDrop, .fastRise, .missedReading, .temporary:
- return true
- default:
- return false
- }
- }
- }
|