Skip to content

Commit

Permalink
Remove unnecessary passing of pumpModel
Browse files Browse the repository at this point in the history
  • Loading branch information
tmecklem committed Oct 20, 2016
1 parent cf0a853 commit 6ce4626
Show file tree
Hide file tree
Showing 29 changed files with 37 additions and 53 deletions.
2 changes: 1 addition & 1 deletion MinimedKit/GlucoseEvents/BatteryChangeGlucoseEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public struct BatteryChangeGlucoseEvent : GlucoseEvent {
public let rawData: Data
public let timestamp: DateComponents

public init?(availableData: Data, pumpModel: PumpModel) {
public init?(availableData: Data) {
length = 5

guard length <= availableData.count else {
Expand Down
2 changes: 1 addition & 1 deletion MinimedKit/GlucoseEvents/CalBGForGHGlucoseEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct CalBGForGHGlucoseEvent : GlucoseEvent {
public let timestamp: DateComponents
public let amount: Int

public init?(availableData: Data, pumpModel: PumpModel) {
public init?(availableData: Data) {
length = 6

guard length <= availableData.count else {
Expand Down
2 changes: 1 addition & 1 deletion MinimedKit/GlucoseEvents/DataEndGlucoseEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public struct DataEndGlucoseEvent : RelativeTimestampedGlucoseEvent {
public let rawData: Data
public var timestamp: DateComponents

public init?(availableData: Data, pumpModel: PumpModel) {
public init?(availableData: Data) {
length = 1

guard length <= availableData.count else {
Expand Down
2 changes: 1 addition & 1 deletion MinimedKit/GlucoseEvents/DateTimeChangeGlucoseEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public struct DateTimeChangeGlucoseEvent : GlucoseEvent {
public let rawData: Data
public let timestamp: DateComponents

public init?(availableData: Data, pumpModel: PumpModel) {
public init?(availableData: Data) {
length = 5

guard length <= availableData.count else {
Expand Down
2 changes: 1 addition & 1 deletion MinimedKit/GlucoseEvents/Fokko7GlucoseEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public struct Fokko7GlucoseEvent : GlucoseEvent {
public let rawData: Data
public var timestamp: DateComponents

public init?(availableData: Data, pumpModel: PumpModel) {
public init?(availableData: Data) {
length = 2

guard length <= availableData.count else {
Expand Down
2 changes: 1 addition & 1 deletion MinimedKit/GlucoseEvents/GlucoseEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation

public protocol GlucoseEvent : DictionaryRepresentable {

init?(availableData: Data, pumpModel: PumpModel)
init?(availableData: Data)

var rawData: Data {
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct GlucoseSensorDataGlucoseEvent : RelativeTimestampedGlucoseEvent {
public let sgv: Int
public var timestamp: DateComponents

public init?(availableData: Data, pumpModel: PumpModel) {
public init?(availableData: Data) {
length = 1

guard length <= availableData.count else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public struct NineteenSomethingGlucoseEvent : RelativeTimestampedGlucoseEvent {
public let rawData: Data
public var timestamp: DateComponents

public init?(availableData: Data, pumpModel: PumpModel) {
public init?(availableData: Data) {
length = 1

guard length <= availableData.count else {
Expand Down
2 changes: 1 addition & 1 deletion MinimedKit/GlucoseEvents/SensorCalFactorGlucoseEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct SensorCalFactorGlucoseEvent : ReferenceTimestampedGlucoseEvent {
public let timestamp: DateComponents
public let factor: Float

public init?(availableData: Data, pumpModel: PumpModel) {
public init?(availableData: Data) {
length = 7

guard length <= availableData.count else {
Expand Down
2 changes: 1 addition & 1 deletion MinimedKit/GlucoseEvents/SensorCalGlucoseEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct SensorCalGlucoseEvent : RelativeTimestampedGlucoseEvent {
public let waiting: String
public var timestamp: DateComponents

public init?(availableData: Data, pumpModel: PumpModel) {
public init?(availableData: Data) {
length = 2

guard length <= availableData.count else {
Expand Down
2 changes: 1 addition & 1 deletion MinimedKit/GlucoseEvents/SensorStatusGlucoseEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public struct SensorStatusGlucoseEvent : GlucoseEvent {
public let rawData: Data
public let timestamp: DateComponents

public init?(availableData: Data, pumpModel: PumpModel) {
public init?(availableData: Data) {
length = 5

guard length <= availableData.count else {
Expand Down
2 changes: 1 addition & 1 deletion MinimedKit/GlucoseEvents/SensorSyncGlucoseEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public struct SensorSyncGlucoseEvent : GlucoseEvent {
public let rawData: Data
public let timestamp: DateComponents

public init?(availableData: Data, pumpModel: PumpModel) {
public init?(availableData: Data) {
length = 5

guard length <= availableData.count else {
Expand Down
2 changes: 1 addition & 1 deletion MinimedKit/GlucoseEvents/SensorTimestampGlucoseEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public struct SensorTimestampGlucoseEvent : ReferenceTimestampedGlucoseEvent {
public let rawData: Data
public let timestamp: DateComponents

public init?(availableData: Data, pumpModel: PumpModel) {
public init?(availableData: Data) {
length = 5

guard length <= availableData.count else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public struct SensorWeakSignalGlucoseEvent : RelativeTimestampedGlucoseEvent {
public let rawData: Data
public var timestamp: DateComponents

public init?(availableData: Data, pumpModel: PumpModel) {
public init?(availableData: Data) {
length = 1

guard length <= availableData.count else {
Expand Down
2 changes: 1 addition & 1 deletion MinimedKit/GlucoseEvents/TenSomethingGlucoseEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public struct TenSomethingGlucoseEvent : ReferenceTimestampedGlucoseEvent {
public let rawData: Data
public let timestamp: DateComponents

public init?(availableData: Data, pumpModel: PumpModel) {
public init?(availableData: Data) {
length = 5

guard length <= availableData.count else {
Expand Down
2 changes: 1 addition & 1 deletion MinimedKit/GlucoseEvents/UnknownGlucoseEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct UnknownGlucoseEvent : GlucoseEvent {
public var timestamp: DateComponents
public let op: String

public init?(availableData: Data, pumpModel: PumpModel) {
public init?(availableData: Data) {
length = 1

guard length <= availableData.count else {
Expand Down
8 changes: 4 additions & 4 deletions MinimedKit/GlucosePage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class GlucosePage {

public let events: [GlucoseEvent]

public init(pageData: Data, pumpModel: PumpModel) throws {
public init(pageData: Data) throws {

guard checkCRC16(pageData) else {
events = [GlucoseEvent]()
Expand All @@ -36,16 +36,16 @@ public class GlucosePage {
let remainingData = pageData.subdata(in: offset..<pageData.count)
let opcode = pageData[offset] as UInt8
if let eventType = GlucoseEventType(rawValue: opcode) {
if let event = eventType.eventType.init(availableData: remainingData, pumpModel: pumpModel) {
if let event = eventType.eventType.init(availableData: remainingData) {
return event
}
}

if opcode >= 20 {
return GlucoseSensorDataGlucoseEvent(availableData: remainingData, pumpModel: pumpModel)!
return GlucoseSensorDataGlucoseEvent(availableData: remainingData)!
}

return UnknownGlucoseEvent(availableData: remainingData, pumpModel: pumpModel)!
return UnknownGlucoseEvent(availableData: remainingData)!
}

func addTimestampsToEvents(startTimestamp: DateComponents, eventsNeedingTimestamp: [RelativeTimestampedGlucoseEvent]) -> [GlucoseEvent] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ class BatteryChangeGlucoseEventTests: XCTestCase {
}

func testDecoding() {
let pumpModel = PumpModel.Model551
let rawData = Data(hexadecimalString: "0a0bae0a0e")!
let subject = BatteryChangeGlucoseEvent(availableData: rawData, pumpModel: pumpModel)!
let subject = BatteryChangeGlucoseEvent(availableData: rawData)!

let expectedTimestamp = DateComponents(calendar: Calendar.current,
year: 2014, month: 2, day: 10, hour: 11, minute: 46)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ class CalBGForGHGlucoseEventTests: XCTestCase {
}

func testDecoding() {
let pumpModel = PumpModel.Model551
let rawData = Data(hexadecimalString: "0e4f5b138fa0")!
let subject = CalBGForGHGlucoseEvent(availableData: rawData, pumpModel: pumpModel)!
let subject = CalBGForGHGlucoseEvent(availableData: rawData)!

let expectedTimestamp = DateComponents(calendar: Calendar.current,
year: 2015, month: 5, day: 19, hour: 15, minute: 27)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ class DateTimeChangeGlucoseEventTests: XCTestCase {
}

func testDecoding() {
let pumpModel = PumpModel.Model551
let rawData = Data(hexadecimalString: "0c0ad23e0e")!
let subject = DateTimeChangeGlucoseEvent(availableData: rawData, pumpModel: pumpModel)!
let subject = DateTimeChangeGlucoseEvent(availableData: rawData)!

let expectedTimestamp = DateComponents(calendar: Calendar.current,
year: 2014, month: 3, day: 30, hour: 10, minute: 18)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ class GlucoseSensorDataGlucoseEventTests: XCTestCase {
}

func testDecoding() {
let pumpModel = PumpModel.Model551
let rawData = Data(hexadecimalString: "35")!
let subject = GlucoseSensorDataGlucoseEvent(availableData: rawData, pumpModel: pumpModel)!
let subject = GlucoseSensorDataGlucoseEvent(availableData: rawData)!

XCTAssertEqual(subject.sgv, 106)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ class SensorCalFactorGlucoseEventTests: XCTestCase {
}

func testDecoding() {
let pumpModel = PumpModel.Model551
let rawData = Data(hexadecimalString: "0f4f67130f128c")!
let subject = SensorCalFactorGlucoseEvent(availableData: rawData, pumpModel: pumpModel)!
let subject = SensorCalFactorGlucoseEvent(availableData: rawData)!

let expectedTimestamp = DateComponents(calendar: Calendar.current,
year: 2015, month: 5, day: 19, hour: 15, minute: 39)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@ class SensorCalGlucoseEventTests: XCTestCase {
}

func testDecodingMeterBgNow() {
let pumpModel = PumpModel.Model551
let rawData = Data(hexadecimalString: "0300")!
let subject = SensorCalGlucoseEvent(availableData: rawData, pumpModel: pumpModel)!
let subject = SensorCalGlucoseEvent(availableData: rawData)!

XCTAssertEqual(subject.waiting, "meter_bg_now")
}

func testDecodingWaiting() {
let pumpModel = PumpModel.Model551
let rawData = Data(hexadecimalString: "0301")!
let subject = SensorCalGlucoseEvent(availableData: rawData, pumpModel: pumpModel)!
let subject = SensorCalGlucoseEvent(availableData: rawData)!

XCTAssertEqual(subject.waiting, "waiting")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ class SensorStatusGlucoseEventTests: XCTestCase {
}

func testDecoding() {
let pumpModel = PumpModel.Model551
let rawData = Data(hexadecimalString: "0b0baf0a0e")!
let subject = SensorStatusGlucoseEvent(availableData: rawData, pumpModel: pumpModel)!
let subject = SensorStatusGlucoseEvent(availableData: rawData)!

let expectedTimestamp = DateComponents(calendar: Calendar.current,
year: 2014, month: 2, day: 10, hour: 11, minute: 47)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ class SensorSyncGlucoseEventTests: XCTestCase {
}

func testPerformanceExample() {
let pumpModel = PumpModel.Model551
let rawData = Data(hexadecimalString: "0d4d44330f")!
let subject = SensorSyncGlucoseEvent(availableData: rawData, pumpModel: pumpModel)!
let subject = SensorSyncGlucoseEvent(availableData: rawData)!

let expectedTimestamp = DateComponents(calendar: Calendar.current,
year: 2015, month: 5, day: 19, hour: 13, minute: 04)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ class SensorTimestampGlucoseEventTests: XCTestCase {
}

func testDecoding() {
let pumpModel = PumpModel.Model551
let rawData = Data(hexadecimalString: "088d9b5d0c")!
let subject = SensorTimestampGlucoseEvent(availableData: rawData, pumpModel: pumpModel)!
let subject = SensorTimestampGlucoseEvent(availableData: rawData)!

let expectedTimestamp = DateComponents(calendar: Calendar.current,
year: 2012, month: 10, day: 29, hour: 13, minute: 27)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ class TenSomethingGlucoseEventTests: XCTestCase {
}

func testDecoding() {
let pumpModel = PumpModel.Model551
let rawData = Data(hexadecimalString: "100bb40a0e")!
let subject = TenSomethingGlucoseEvent(availableData: rawData, pumpModel: pumpModel)!
let subject = TenSomethingGlucoseEvent(availableData: rawData)!

let expectedTimestamp = DateComponents(calendar: Calendar.current,
year: 2014, month: 2, day: 10, hour: 11, minute: 52)
Expand Down
Loading

0 comments on commit 6ce4626

Please sign in to comment.