Skip to content

Commit

Permalink
Merge pull request #358 from ps2/dev
Browse files Browse the repository at this point in the history
Version 1.2.1
  • Loading branch information
ps2 authored Aug 29, 2017
2 parents 85afbb3 + f4b5508 commit 6d14ddb
Show file tree
Hide file tree
Showing 27 changed files with 163 additions and 136 deletions.
2 changes: 1 addition & 1 deletion Crypto/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>1.2.0</string>
<string>1.2.1</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
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>1.2.0</string>
<string>1.2.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
6 changes: 3 additions & 3 deletions MinimedKit/PumpEvents/BolusNormalPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import Foundation
public struct BolusNormalPumpEvent: TimestampedPumpEvent {

public enum BolusType: String {
case Normal
case Square
case normal = "Normal"
case square = "Square"
}

public let length: Int
Expand Down Expand Up @@ -92,7 +92,7 @@ public struct BolusNormalPumpEvent: TimestampedPumpEvent {
duration = TimeInterval(minutes: 30 * doubleValueFromData(at: 3))
unabsorbedInsulinTotal = 0
}
type = duration > 0 ? .Square : .Normal
type = duration > 0 ? .square : .normal

self.init(length: length, rawData: rawData, timestamp: timestamp, unabsorbedInsulinRecord: unabsorbedInsulinRecord, amount:amount, programmed: programmed, unabsorbedInsulinTotal: unabsorbedInsulinTotal, type: type, duration: duration)
}
Expand Down
4 changes: 4 additions & 0 deletions MinimedKit/PumpEvents/ClearAlarmPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public struct ClearAlarmPumpEvent: TimestampedPumpEvent {
public let length: Int
public let rawData: Data
public let timestamp: DateComponents
public let alarmType: PumpAlarmType

public init?(availableData: Data, pumpModel: PumpModel) {
length = 7
Expand All @@ -21,13 +22,16 @@ public struct ClearAlarmPumpEvent: TimestampedPumpEvent {
}

rawData = availableData.subdata(in: 0..<length)

alarmType = PumpAlarmType(rawType: availableData[1])

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

public var dictionaryRepresentation: [String: Any] {
return [
"_type": "ClearAlarm",
"alarm": "\(self.alarmType)"
]
}
}
23 changes: 11 additions & 12 deletions MinimedKit/PumpEvents/PumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,18 @@ public protocol PumpEvent : DictionaryRepresentable {
}

public extension PumpEvent {
public func isDelayedAppend(withPumpModel pumpModel: PumpModel) -> Bool {

switch self {
case let bolus as BolusNormalPumpEvent:
//Square boluses for 523's are appended at the beginning of the event
if pumpModel == .Model523 {
return bolus.type != .Square
}

return true

default:
public func isDelayedAppend(with pumpModel: PumpModel) -> Bool {
// Delays only occur for bolus events
guard let bolus = self as? BolusNormalPumpEvent else {
return false
}

// All normal bolus events are delayed
guard bolus.type == .square else {
return true
}

// Square-wave bolus events are delayed for certain pump models
return !pumpModel.appendsSquareWaveToHistoryOnStartOfDelivery
}
}
50 changes: 29 additions & 21 deletions MinimedKit/PumpModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@
/// Represents a pump model and its defining characteristics.
/// This class implements the `RawRepresentable` protocol
public enum PumpModel: String {
case Model508 = "508"
case Model511 = "511"
case Model711 = "711"
case Model512 = "512"
case Model712 = "712"
case Model515 = "515"
case Model715 = "715"
case Model522 = "522"
case Model722 = "722"
case Model523 = "523"
case Model723 = "723"
case Model530 = "530"
case Model730 = "730"
case Model540 = "540"
case Model740 = "740"
case Model551 = "551"
case Model751 = "751"
case Model554 = "554"
case Model754 = "754"
case model508 = "508"
case model511 = "511"
case model711 = "711"
case model512 = "512"
case model712 = "712"
case model515 = "515"
case model715 = "715"
case model522 = "522"
case model722 = "722"
case model523 = "523"
case model723 = "723"
case model530 = "530"
case model730 = "730"
case model540 = "540"
case model740 = "740"
case model551 = "551"
case model751 = "751"
case model554 = "554"
case model754 = "754"

private var size: Int {
return Int(rawValue)! / 100
Expand Down Expand Up @@ -57,9 +57,17 @@ public enum PumpModel: String {
var hasLowSuspend: Bool {
return generation >= 51
}

public var recordsBasalProfileStartEvents: Bool {
return generation >= 23
}

// On x15 models, a bolus in progress error is returned when bolusing, even though the bolus succeeds
public var returnsErrorOnBolus: Bool {
return generation == 15
}

/// The number of turns of the stepper motor required to deliver 1 U of U-100 insulin.
/// This is a measure of motor precision.
/// Newer models allow higher precision delivery, and have bit packing to accomodate this.
public var strokesPerUnit: Int {
return (generation >= 23) ? 40 : 10
}
Expand Down
Loading

0 comments on commit 6d14ddb

Please sign in to comment.