AlarmSensorPumpEvent.swift 928 B

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