SensorDataHighGlucoseEvent.swift 846 B

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // SensorDataHighGlucoseEvent.swift
  3. // RileyLink
  4. //
  5. // Created by Timothy Mecklem on 12/6/16.
  6. // Copyright © 2016 Pete Schwamb. All rights reserved.
  7. //
  8. import Foundation
  9. public struct SensorDataHighGlucoseEvent: SensorValueGlucoseEvent {
  10. public let length: Int
  11. public let rawData: Data
  12. public let sgv: Int
  13. public let timestamp: DateComponents
  14. public init?(availableData: Data, relativeTimestamp: DateComponents) {
  15. length = 2
  16. guard length <= availableData.count else {
  17. return nil
  18. }
  19. rawData = availableData.subdata(in: 0..<length)
  20. sgv = 400
  21. timestamp = relativeTimestamp
  22. }
  23. public var dictionaryRepresentation: [String: Any] {
  24. return [
  25. "name": "SensorDataHigh",
  26. "sgv": sgv
  27. ]
  28. }
  29. }