DataEndGlucoseEvent.swift 751 B

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