-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #186 from ps2/dev
v0.8.0
- Loading branch information
Showing
42 changed files
with
1,007 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// ReadPumpStatusMessageBody.swift | ||
// RileyLink | ||
// | ||
// Created by Pete Schwamb on 7/31/16. | ||
// Copyright © 2016 Pete Schwamb. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public class ReadPumpStatusMessageBody: CarelinkLongMessageBody { | ||
|
||
public let bolusing: Bool | ||
public let suspended: Bool | ||
|
||
public required init?(rxData: NSData) { | ||
guard rxData.length == self.dynamicType.length else { | ||
return nil | ||
} | ||
|
||
bolusing = (rxData[2] as UInt8) > 0 | ||
suspended = (rxData[3] as UInt8) > 0 | ||
|
||
super.init(rxData: rxData) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// BatteryStatus.swift | ||
// RileyLink | ||
// | ||
// Created by Pete Schwamb on 7/28/16. | ||
// Copyright © 2016 Pete Schwamb. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public enum BatteryIndicator: String { | ||
case Low = "low" | ||
case Normal = "normal" | ||
} | ||
|
||
public struct BatteryStatus { | ||
let percent: Int? | ||
let voltage: Double? | ||
let status: BatteryIndicator? | ||
|
||
public init(percent: Int? = nil, voltage: Double? = nil, status: BatteryIndicator? = nil) { | ||
self.percent = percent | ||
self.voltage = voltage | ||
self.status = status | ||
} | ||
|
||
public var dictionaryRepresentation: [String: AnyObject] { | ||
var rval = [String: AnyObject]() | ||
|
||
if let percent = percent { | ||
rval["percent"] = percent | ||
} | ||
if let voltage = voltage { | ||
rval["voltage"] = voltage | ||
} | ||
|
||
if let status = status { | ||
rval["status"] = status.rawValue | ||
} | ||
|
||
return rval | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// COBStatus.swift | ||
// RileyLink | ||
// | ||
// Created by Pete Schwamb on 8/2/16. | ||
// Copyright © 2016 Pete Schwamb. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct COBStatus { | ||
let cob: Double | ||
let timestamp: NSDate | ||
|
||
public init(cob: Double, timestamp: NSDate) { | ||
self.cob = cob // grams | ||
self.timestamp = timestamp | ||
} | ||
|
||
public var dictionaryRepresentation: [String: AnyObject] { | ||
|
||
var rval = [String: AnyObject]() | ||
|
||
rval["timestamp"] = TimeFormat.timestampStrFromDate(timestamp) | ||
rval["cob"] = cob | ||
|
||
return rval | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// DeviceStatus.swift | ||
// RileyLink | ||
// | ||
// Created by Pete Schwamb on 7/26/16. | ||
// Copyright © 2016 Pete Schwamb. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct DeviceStatus { | ||
let device: String | ||
let timestamp: NSDate | ||
let pumpStatus: PumpStatus? | ||
let uploaderStatus: UploaderStatus? | ||
let loopStatus: LoopStatus? | ||
|
||
public init(device: String, timestamp: NSDate, pumpStatus: PumpStatus? = nil, uploaderStatus: UploaderStatus? = nil, loopStatus: LoopStatus? = nil) { | ||
self.device = device | ||
self.timestamp = timestamp | ||
self.pumpStatus = pumpStatus | ||
self.uploaderStatus = uploaderStatus | ||
self.loopStatus = loopStatus | ||
} | ||
|
||
public var dictionaryRepresentation: [String: AnyObject] { | ||
var rval = [String: AnyObject]() | ||
|
||
rval["device"] = device | ||
rval["created_at"] = TimeFormat.timestampStrFromDate(timestamp) | ||
|
||
if let pump = pumpStatus { | ||
rval["pump"] = pump.dictionaryRepresentation | ||
} | ||
|
||
if let uploader = uploaderStatus { | ||
rval["uploader"] = uploader.dictionaryRepresentation | ||
} | ||
|
||
if let loop = loopStatus { | ||
// Would like to change this to avoid confusion about whether or not this was uploaded from Loop or openaps | ||
rval["openaps"] = loop.dictionaryRepresentation | ||
} | ||
|
||
return rval | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// IOBStatus.swift | ||
// RileyLink | ||
// | ||
// Created by Pete Schwamb on 7/28/16. | ||
// Copyright © 2016 Pete Schwamb. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct IOBStatus { | ||
let timestamp: NSDate | ||
let iob: Double? // basal iob + bolus iob: can be negative | ||
let basalIOB: Double? // does not include bolus iob | ||
|
||
public init(timestamp: NSDate, iob: Double? = nil, basalIOB: Double? = nil) { | ||
self.timestamp = timestamp | ||
self.iob = iob | ||
self.basalIOB = basalIOB | ||
} | ||
|
||
public var dictionaryRepresentation: [String: AnyObject] { | ||
|
||
var rval = [String: AnyObject]() | ||
|
||
rval["timestamp"] = TimeFormat.timestampStrFromDate(timestamp) | ||
|
||
if let iob = iob { | ||
rval["iob"] = iob | ||
} | ||
|
||
if let basalIOB = basalIOB { | ||
rval["basaliob"] = basalIOB | ||
} | ||
|
||
return rval | ||
} | ||
} |
Oops, something went wrong.