OpenAPSSwift.swift 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import Foundation
  2. struct OpenAPSSwift {
  3. static func makeProfile(
  4. preferences: JSON,
  5. pumpSettings: JSON,
  6. bgTargets: JSON,
  7. basalProfile: JSON,
  8. isf: JSON,
  9. carbRatio: JSON,
  10. tempTargets: JSON,
  11. model: JSON,
  12. trioSettings: JSON
  13. ) -> OrefFunctionResult {
  14. do {
  15. let preferences = try JSONBridge.preferences(from: preferences)
  16. let pumpSettings = try JSONBridge.pumpSettings(from: pumpSettings)
  17. let bgTargets = try JSONBridge.bgTargets(from: bgTargets)
  18. let basalProfile = try JSONBridge.basalProfile(from: basalProfile)
  19. let isf = try JSONBridge.insulinSensitivities(from: isf)
  20. let carbRatio = try JSONBridge.carbRatios(from: carbRatio)
  21. let tempTargets = try JSONBridge.tempTargets(from: tempTargets)
  22. let model = JSONBridge.model(from: model)
  23. let trioSettings = try JSONBridge.trioSettings(from: trioSettings)
  24. let profile = try ProfileGenerator.generate(
  25. pumpSettings: pumpSettings,
  26. bgTargets: bgTargets,
  27. basalProfile: basalProfile,
  28. isf: isf,
  29. preferences: preferences,
  30. carbRatios: carbRatio,
  31. tempTargets: tempTargets,
  32. model: model,
  33. trioSettings: trioSettings
  34. )
  35. return try .success(JSONBridge.to(profile))
  36. } catch {
  37. return .failure(error)
  38. }
  39. }
  40. }