ReadPumpStatusMessageBody.swift 732 B

12345678910111213141516171819202122232425262728293031323334
  1. //
  2. // ReadPumpStatusMessageBody.swift
  3. // RileyLink
  4. //
  5. // Created by Pete Schwamb on 7/31/16.
  6. // Copyright © 2016 Pete Schwamb. All rights reserved.
  7. //
  8. import Foundation
  9. public class ReadPumpStatusMessageBody: DecodableMessageBody {
  10. public static var length: Int = 65
  11. public var txData: Data
  12. public let bolusing: Bool
  13. public let suspended: Bool
  14. public required init?(rxData: Data) {
  15. guard rxData.count == type(of: self).length else {
  16. return nil
  17. }
  18. bolusing = rxData[2] > 0
  19. suspended = rxData[3] > 0
  20. self.txData = rxData
  21. }
  22. public var description: String {
  23. return "ReadPumpStatus(bolusing:\(bolusing), suspended:\(suspended))"
  24. }
  25. }