InfoType.swift 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // LoopFollow
  2. // InfoType.swift
  3. import Foundation
  4. enum InfoType: Int, CaseIterable, Codable {
  5. case iob, cob, basal, override, battery, pump, pumpBattery, sage, cage, recBolus, minMax, carbsToday, autosens, profile, target, isf, carbRatio, updated, tdd, iage, dbSize
  6. var name: String {
  7. switch self {
  8. case .iob: return "IOB"
  9. case .cob: return "COB"
  10. case .basal: return "Basal"
  11. case .override: return "Override"
  12. case .battery: return "Battery"
  13. case .pump: return "Pump"
  14. case .pumpBattery: return "Pump Battery"
  15. case .sage: return "SAGE"
  16. case .cage: return "CAGE"
  17. case .recBolus: return "Rec. Bolus"
  18. case .minMax: return "Min/Max"
  19. case .carbsToday: return "Carbs today"
  20. case .autosens: return "Autosens"
  21. case .profile: return "Profile"
  22. case .target: return "Target"
  23. case .isf: return "ISF"
  24. case .carbRatio: return "CR"
  25. case .updated: return "Updated"
  26. case .tdd: return "TDD"
  27. case .iage: return "IAGE"
  28. case .dbSize: return "DB Size"
  29. }
  30. }
  31. var defaultVisible: Bool {
  32. switch self {
  33. case .iob, .cob, .basal, .override, .battery, .pump, .sage, .cage, .recBolus, .minMax, .carbsToday:
  34. return true
  35. default:
  36. return false
  37. }
  38. }
  39. var sortOrder: Int {
  40. return rawValue
  41. }
  42. /// Rows that carry a single numeric value can offer color thresholds.
  43. /// Combined rows (basal, min/max), BG-unit rows (target, ISF, CR) and
  44. /// pure-text rows have no config and are therefore not colorable.
  45. /// Steps mirror the equivalent alarm editors, so a value that takes decimals
  46. /// in an alarm takes decimals here too.
  47. var colorConfig: InfoColorConfig? {
  48. switch self {
  49. case .iob:
  50. return InfoColorConfig(direction: .above, unit: "U", range: 0 ... 20, step: 0.5, defaultWarning: 3, defaultUrgent: 5)
  51. case .cob:
  52. return InfoColorConfig(direction: .above, unit: "g", range: 0 ... 200, step: 1, defaultWarning: 30, defaultUrgent: 60)
  53. case .battery, .pumpBattery:
  54. return InfoColorConfig(direction: .below, unit: "%", range: 0 ... 100, step: 5, defaultWarning: 30, defaultUrgent: 15)
  55. case .pump:
  56. return InfoColorConfig(direction: .below, unit: "U", range: 0 ... 50, step: 1, defaultWarning: 20, defaultUrgent: 10)
  57. case .tdd:
  58. return InfoColorConfig(direction: .above, unit: "U", range: 0 ... 200, step: 1, defaultWarning: 60, defaultUrgent: 80)
  59. case .recBolus:
  60. return InfoColorConfig(direction: .above, unit: "U", range: 0 ... 20, step: 0.1, defaultWarning: 1, defaultUrgent: 2)
  61. case .carbsToday:
  62. return InfoColorConfig(direction: .above, unit: "g", range: 0 ... 500, step: 5, defaultWarning: 150, defaultUrgent: 250)
  63. case .sage:
  64. return InfoColorConfig(direction: .above, unit: "days", range: 0.5 ... 15, step: 0.5, defaultWarning: 9, defaultUrgent: 9.5)
  65. case .cage, .iage:
  66. return InfoColorConfig(direction: .above, unit: "days", range: 0.5 ... 10, step: 0.5, defaultWarning: 2.5, defaultUrgent: 3)
  67. default:
  68. return nil
  69. }
  70. }
  71. var isColorable: Bool { colorConfig != nil }
  72. }