ForecastError.swift 894 B

123456789101112131415161718192021222324252627282930313233
  1. //
  2. // ForecastError.swift
  3. // NightscoutUploadKit
  4. //
  5. // Created by Pete Schwamb on 5/28/18.
  6. // Copyright © 2018 Pete Schwamb. All rights reserved.
  7. //
  8. import Foundation
  9. import HealthKit
  10. public struct ForecastError {
  11. let velocity: Double
  12. let measurementDuration: Double
  13. public init(velocity: HKQuantity, measurementDuration: TimeInterval) {
  14. let glucoseUnit = HKUnit.milligramsPerDeciliterUnit()
  15. let velocityUnit = glucoseUnit.unitDivided(by: HKUnit.second())
  16. self.velocity = velocity.doubleValue(for: velocityUnit)
  17. self.measurementDuration = measurementDuration
  18. }
  19. public var dictionaryRepresentation: [String: Any] {
  20. var rval = [String: Any]()
  21. rval["velocity"] = velocity
  22. rval["measurementDuration"] = measurementDuration
  23. //rval["velocityUnits"] = "mg/dL/s"
  24. return rval
  25. }
  26. }