Skip to content

Commit

Permalink
Merge pull request #185 from ps2/correction-optional
Browse files Browse the repository at this point in the history
Make correction optional in LoopSuggested
  • Loading branch information
ps2 authored Aug 4, 2016
2 parents 5237747 + 3505a4c commit c879638
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions NightscoutUploadKit/DeviceStatus/LoopSuggested.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ public struct LoopSuggested {
let timestamp: NSDate
let rate: Double
let duration: NSTimeInterval
let correction: Double
let eventualBG: Int
let bg: Int
let reason: String?
let tick: Int?

public init(timestamp: NSDate, rate: Double, duration: NSTimeInterval, correction: Double = 0, eventualBG: Int, bg: Int, reason: String?, tick: Int?) {
let correction: Double?

public init(timestamp: NSDate, rate: Double, duration: NSTimeInterval, eventualBG: Int, bg: Int, reason: String? = nil, tick: Int? = nil, correction: Double? = nil) {
self.timestamp = timestamp
self.rate = rate
self.duration = duration
self.correction = correction
self.eventualBG = eventualBG
self.bg = bg
self.reason = reason
self.tick = tick
self.correction = correction
}

public var dictionaryRepresentation: [String: AnyObject] {
Expand All @@ -50,13 +50,17 @@ public struct LoopSuggested {
rval["rate"] = rate
rval["duration"] = duration / 60.0
rval["bg"] = bg
rval["correction"] = correction
rval["eventualBG"] = eventualBG

if let reason = reason {
rval["reason"] = reason
}

if let correction = correction {
rval["correction"] = correction
}


return rval
}
}

0 comments on commit c879638

Please sign in to comment.