DailyTotal515PumpEvent.swift 799 B

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