Skip to content

Commit

Permalink
Merge pull request #134 from ps2/dev
Browse files Browse the repository at this point in the history
Version 0.5.0
  • Loading branch information
loudnate authored Jun 26, 2016
2 parents ba5358c + 32e5fce commit 51480a1
Show file tree
Hide file tree
Showing 82 changed files with 428 additions and 152 deletions.
2 changes: 1 addition & 1 deletion MinimedKit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.4.0</string>
<string>0.5.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
1 change: 1 addition & 0 deletions MinimedKit/MessageType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public enum MessageType: UInt8 {
case PumpBackfill = 0x08
case FindDevice = 0x09
case DeviceLink = 0x0A
case EmptyHistoryPage = 0x15
case ChangeTime = 0x40
case Bolus = 0x42
case ChangeTempBasal = 0x4c
Expand Down
8 changes: 4 additions & 4 deletions MinimedKit/Messages/MySentryPumpStatusMessageBody.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public enum SensorReading {
```
*/
public struct MySentryPumpStatusMessageBody: MessageBody, DictionaryRepresentable {
private static let reservoirSignificantDigit = 0.1
private static let iobSigificantDigit = 0.025
private static let reservoirMultiplier: Double = 10
private static let iobMultiplier: Double = 40
public static let length = 36

public let sequence: UInt8
Expand Down Expand Up @@ -137,14 +137,14 @@ public struct MySentryPumpStatusMessageBody: MessageBody, DictionaryRepresentabl

self.glucoseTrend = trend

reservoirRemainingUnits = Double(Int(bigEndianBytes: rxData[12...13])) * self.dynamicType.reservoirSignificantDigit
reservoirRemainingUnits = Double(Int(bigEndianBytes: rxData[12...13])) / self.dynamicType.reservoirMultiplier

let reservoirRemainingPercent: UInt8 = rxData[15]
self.reservoirRemainingPercent = Int(round(Double(reservoirRemainingPercent) / 4.0 * 100))

reservoirRemainingMinutes = Int(bigEndianBytes: [rxData[16], rxData[17]])

iob = Double(Int(bigEndianBytes: rxData[22...23])) * self.dynamicType.iobSigificantDigit
iob = Double(Int(bigEndianBytes: rxData[22...23])) / self.dynamicType.iobMultiplier

let batteryRemainingPercent: UInt8 = rxData[14]
self.batteryRemainingPercent = Int(round(Double(batteryRemainingPercent) / 4.0 * 100))
Expand Down
8 changes: 4 additions & 4 deletions MinimedKit/Messages/ReadSettingsCarelinkMessageBody.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public enum BasalProfile {
```
*/
public class ReadSettingsCarelinkMessageBody: CarelinkLongMessageBody {
private static let maxBolusSignificantDigit = 0.1
private static let maxBasalSignificantDigit = 0.025
private static let maxBolusMultiplier: Double = 10
private static let maxBasalMultiplier: Double = 40

public let maxBasal: Double
public let maxBolus: Double
Expand All @@ -54,10 +54,10 @@ public class ReadSettingsCarelinkMessageBody: CarelinkLongMessageBody {
}

let maxBolusTicks: UInt8 = rxData[7]
maxBolus = Double(maxBolusTicks) * self.dynamicType.maxBolusSignificantDigit
maxBolus = Double(maxBolusTicks) * self.dynamicType.maxBolusMultiplier

let maxBasalTicks: Int = Int(bigEndianBytes: rxData[8...9])
maxBasal = Double(maxBasalTicks) * self.dynamicType.maxBasalSignificantDigit
maxBasal = Double(maxBasalTicks) * self.dynamicType.maxBasalMultiplier

let rawSelectedBasalProfile: UInt8 = rxData[12]
selectedBasalProfile = BasalProfile(rawValue: rawSelectedBasalProfile)
Expand Down
3 changes: 3 additions & 0 deletions MinimedKit/PumpEventType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public enum PumpEventType: UInt8 {
case TempBasal = 0x33
case JournalEntryPumpLowReservoir = 0x34
case AlarmClockReminder = 0x35
case Questionable3b = 0x3b
case ChangeParadigmLinkID = 0x3c
case BGReceived = 0x3f
case JournalEntryExerciseMarker = 0x41
Expand Down Expand Up @@ -179,6 +180,8 @@ public enum PumpEventType: UInt8 {
return ChangeCaptureEventEnablePumpEvent.self
case .SelectBasalProfile:
return SelectBasalProfilePumpEvent.self
default:
return UnknownPumpEvent.self
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion MinimedKit/PumpEvents/AlarmClockReminderPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

public struct AlarmClockReminderPumpEvent: TimestampedPumpEvent {
public let length: Int
public let rawData: NSData
public let timestamp: NSDateComponents

public init?(availableData: NSData, pumpModel: PumpModel) {
Expand All @@ -18,7 +19,9 @@ public struct AlarmClockReminderPumpEvent: TimestampedPumpEvent {
guard length <= availableData.length else {
return nil
}


rawData = availableData[0..<length]

timestamp = NSDateComponents(pumpEventData: availableData, offset: 2)
}

Expand Down
3 changes: 3 additions & 0 deletions MinimedKit/PumpEvents/AlarmSensorPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

public struct AlarmSensorPumpEvent: TimestampedPumpEvent {
public let length: Int
public let rawData: NSData
public let timestamp: NSDateComponents

public init?(availableData: NSData, pumpModel: PumpModel) {
Expand All @@ -18,6 +19,8 @@ public struct AlarmSensorPumpEvent: TimestampedPumpEvent {
guard length <= availableData.length else {
return nil
}

rawData = availableData[0..<length]

timestamp = NSDateComponents(pumpEventData: availableData, offset: 2)
}
Expand Down
3 changes: 3 additions & 0 deletions MinimedKit/PumpEvents/BGReceivedPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

public struct BGReceivedPumpEvent: TimestampedPumpEvent {
public let length: Int
public let rawData: NSData
public let timestamp: NSDateComponents
public let amount: Int
public let meter: String
Expand All @@ -20,6 +21,8 @@ public struct BGReceivedPumpEvent: TimestampedPumpEvent {
guard length <= availableData.length else {
return nil
}

rawData = availableData[0..<length]

func d(idx:Int) -> Int {
return Int(availableData[idx] as UInt8)
Expand Down
3 changes: 3 additions & 0 deletions MinimedKit/PumpEvents/BasalProfileStartPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

public struct BasalProfileStartPumpEvent: TimestampedPumpEvent {
public let length: Int
public let rawData: NSData
public let timestamp: NSDateComponents
let rate: Double
let profileIndex: Int
Expand All @@ -22,6 +23,8 @@ public struct BasalProfileStartPumpEvent: TimestampedPumpEvent {
guard length <= availableData.length else {
return nil
}

rawData = availableData[0..<length]

func d(idx:Int) -> Int {
return Int(availableData[idx] as UInt8)
Expand Down
3 changes: 3 additions & 0 deletions MinimedKit/PumpEvents/BatteryPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

public struct BatteryPumpEvent: TimestampedPumpEvent {
public let length: Int
public let rawData: NSData
public let timestamp: NSDateComponents

public init?(availableData: NSData, pumpModel: PumpModel) {
Expand All @@ -18,6 +19,8 @@ public struct BatteryPumpEvent: TimestampedPumpEvent {
guard length <= availableData.length else {
return nil
}

rawData = availableData[0..<length]

timestamp = NSDateComponents(pumpEventData: availableData, offset: 2)
}
Expand Down
3 changes: 3 additions & 0 deletions MinimedKit/PumpEvents/BolusNormalPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public struct BolusNormalPumpEvent: TimestampedPumpEvent {
}

public let length: Int
public let rawData: NSData
public let timestamp: NSDateComponents
public var unabsorbedInsulinRecord: UnabsorbedInsulinPumpEvent?
public let amount: Double
Expand Down Expand Up @@ -58,6 +59,8 @@ public struct BolusNormalPumpEvent: TimestampedPumpEvent {
guard length <= availableData.length else {
return nil
}

rawData = availableData[0..<length]

if pumpModel.larger {
timestamp = NSDateComponents(pumpEventData: availableData, offset: 8)
Expand Down
20 changes: 6 additions & 14 deletions MinimedKit/PumpEvents/BolusWizardEstimatePumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

public struct BolusWizardEstimatePumpEvent: TimestampedPumpEvent {
public let length: Int
public let rawData: NSData
public let timestamp: NSDateComponents
public let carbohydrates: Int
public let bloodGlucose: Int
Expand Down Expand Up @@ -37,22 +38,13 @@ public struct BolusWizardEstimatePumpEvent: TimestampedPumpEvent {
} else {
length = 20
}

if length >= availableData.length {
carbohydrates = 0
bloodGlucose = 0
foodEstimate = 0
correctionEstimate = 0
bolusEstimate = 0
unabsorbedInsulinTotal = 0
bgTargetLow = 0
bgTargetHigh = 0
insulinSensitivity = 0
carbRatio = 0
timestamp = NSDateComponents()

guard length <= availableData.length else {
return nil
}


rawData = availableData[0..<length]

timestamp = NSDateComponents(pumpEventData: availableData, offset: 2)

if pumpModel.larger {
Expand Down
3 changes: 3 additions & 0 deletions MinimedKit/PumpEvents/CalBGForPHPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

public struct CalBGForPHPumpEvent: TimestampedPumpEvent {
public let length: Int
public let rawData: NSData
public let timestamp: NSDateComponents
public let amount: Int

Expand All @@ -19,6 +20,8 @@ public struct CalBGForPHPumpEvent: TimestampedPumpEvent {
guard length <= availableData.length else {
return nil
}

rawData = availableData[0..<length]

func d(idx:Int) -> Int {
return Int(availableData[idx] as UInt8)
Expand Down
3 changes: 3 additions & 0 deletions MinimedKit/PumpEvents/ChangeAlarmClockEnablePumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

public struct ChangeAlarmClockEnablePumpEvent: TimestampedPumpEvent {
public let length: Int
public let rawData: NSData
public let timestamp: NSDateComponents

public init?(availableData: NSData, pumpModel: PumpModel) {
Expand All @@ -18,6 +19,8 @@ public struct ChangeAlarmClockEnablePumpEvent: TimestampedPumpEvent {
guard length <= availableData.length else {
return nil
}

rawData = availableData[0..<length]

timestamp = NSDateComponents(pumpEventData: availableData, offset: 2)
}
Expand Down
3 changes: 3 additions & 0 deletions MinimedKit/PumpEvents/ChangeAlarmClockTimePumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

public struct ChangeAlarmClockTimePumpEvent: TimestampedPumpEvent {
public let length: Int
public let rawData: NSData
public let timestamp: NSDateComponents

public init?(availableData: NSData, pumpModel: PumpModel) {
Expand All @@ -18,6 +19,8 @@ public struct ChangeAlarmClockTimePumpEvent: TimestampedPumpEvent {
guard length <= availableData.length else {
return nil
}

rawData = availableData[0..<length]

timestamp = NSDateComponents(pumpEventData: availableData, offset: 2)
}
Expand Down
3 changes: 3 additions & 0 deletions MinimedKit/PumpEvents/ChangeAlarmNotifyModePumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

public struct ChangeAlarmNotifyModePumpEvent: TimestampedPumpEvent {
public let length: Int
public let rawData: NSData
public let timestamp: NSDateComponents

public init?(availableData: NSData, pumpModel: PumpModel) {
Expand All @@ -18,6 +19,8 @@ public struct ChangeAlarmNotifyModePumpEvent: TimestampedPumpEvent {
guard length <= availableData.length else {
return nil
}

rawData = availableData[0..<length]

timestamp = NSDateComponents(pumpEventData: availableData, offset: 2)
}
Expand Down
3 changes: 3 additions & 0 deletions MinimedKit/PumpEvents/ChangeAudioBolusPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

public struct ChangeAudioBolusPumpEvent: TimestampedPumpEvent {
public let length: Int
public let rawData: NSData
public let timestamp: NSDateComponents

public init?(availableData: NSData, pumpModel: PumpModel) {
Expand All @@ -18,6 +19,8 @@ public struct ChangeAudioBolusPumpEvent: TimestampedPumpEvent {
guard length <= availableData.length else {
return nil
}

rawData = availableData[0..<length]

timestamp = NSDateComponents(pumpEventData: availableData, offset: 2)
}
Expand Down
3 changes: 3 additions & 0 deletions MinimedKit/PumpEvents/ChangeBGReminderEnablePumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

public struct ChangeBGReminderEnablePumpEvent: TimestampedPumpEvent {
public let length: Int
public let rawData: NSData
public let timestamp: NSDateComponents

public init?(availableData: NSData, pumpModel: PumpModel) {
Expand All @@ -18,6 +19,8 @@ public struct ChangeBGReminderEnablePumpEvent: TimestampedPumpEvent {
guard length <= availableData.length else {
return nil
}

rawData = availableData[0..<length]

timestamp = NSDateComponents(pumpEventData: availableData, offset: 2)
}
Expand Down
3 changes: 3 additions & 0 deletions MinimedKit/PumpEvents/ChangeBGReminderOffsetPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

public struct ChangeBGReminderOffsetPumpEvent: TimestampedPumpEvent {
public let length: Int
public let rawData: NSData
public let timestamp: NSDateComponents

public init?(availableData: NSData, pumpModel: PumpModel) {
Expand All @@ -18,6 +19,8 @@ public struct ChangeBGReminderOffsetPumpEvent: TimestampedPumpEvent {
guard length <= availableData.length else {
return nil
}

rawData = availableData[0..<length]

timestamp = NSDateComponents(pumpEventData: availableData, offset: 2)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

public struct ChangeBasalProfilePatternPumpEvent: TimestampedPumpEvent {
public let length: Int
public let rawData: NSData
public let timestamp: NSDateComponents

public init?(availableData: NSData, pumpModel: PumpModel) {
Expand All @@ -18,6 +19,8 @@ public struct ChangeBasalProfilePatternPumpEvent: TimestampedPumpEvent {
guard length <= availableData.length else {
return nil
}

rawData = availableData[0..<length]

timestamp = NSDateComponents(pumpEventData: availableData, offset: 2)
}
Expand Down
3 changes: 3 additions & 0 deletions MinimedKit/PumpEvents/ChangeBasalProfilePumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

public struct ChangeBasalProfilePumpEvent: TimestampedPumpEvent {
public let length: Int
public let rawData: NSData
public let timestamp: NSDateComponents

public init?(availableData: NSData, pumpModel: PumpModel) {
Expand All @@ -18,6 +19,8 @@ public struct ChangeBasalProfilePumpEvent: TimestampedPumpEvent {
guard length <= availableData.length else {
return nil
}

rawData = availableData[0..<length]

timestamp = NSDateComponents(pumpEventData: availableData, offset: 2)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation

public struct ChangeBolusReminderEnablePumpEvent: TimestampedPumpEvent {
public let length: Int
public let rawData: NSData
public let timestamp: NSDateComponents

public init?(availableData: NSData, pumpModel: PumpModel) {
Expand All @@ -18,6 +19,8 @@ public struct ChangeBolusReminderEnablePumpEvent: TimestampedPumpEvent {
guard length <= availableData.length else {
return nil
}

rawData = availableData[0..<length]

timestamp = NSDateComponents(pumpEventData: availableData, offset: 2)
}
Expand Down
Loading

0 comments on commit 51480a1

Please sign in to comment.