Skip to content

Commit

Permalink
Creating a wrapper type around a PumpEvent that holds its reconciled …
Browse files Browse the repository at this point in the history
…Date value

Also fixes #119
  • Loading branch information
loudnate committed Jun 16, 2016
1 parent e157b38 commit 4040519
Show file tree
Hide file tree
Showing 68 changed files with 235 additions and 225 deletions.
22 changes: 22 additions & 0 deletions MinimedKit/Extensions/NSDateFormatter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// NSDateFormatter.swift
// RileyLink
//
// Created by Nate Racklyeft on 6/15/16.
// Copyright © 2016 Pete Schwamb. All rights reserved.
//

import Foundation


extension NSDateFormatter {
class func ISO8601DateFormatter() -> Self {
let formatter = self.init()
formatter.calendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierISO8601)
formatter.locale = NSLocale(localeIdentifier: "en_US_POSIX")
formatter.timeZone = NSTimeZone(forSecondsFromGMT: 0)
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssX"

return formatter
}
}
3 changes: 3 additions & 0 deletions MinimedKit/PumpEventType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public enum PumpEventType: UInt8 {
case CalBGForPH = 0x0a
case AlarmSensor = 0x0b
case ClearAlarm = 0x0c
case SelectBasalProfile = 0x14
case TempBasalDuration = 0x16
case ChangeTime = 0x17
case JournalEntryPumpLowBattery = 0x19
Expand Down Expand Up @@ -176,6 +177,8 @@ public enum PumpEventType: UInt8 {
return DeleteOtherDeviceIDPumpEvent.self
case .ChangeCaptureEventEnable:
return ChangeCaptureEventEnablePumpEvent.self
case .SelectBasalProfile:
return SelectBasalProfilePumpEvent.self
}
}
}
Expand Down
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/AlarmClockReminderPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct AlarmClockReminderPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "AlarmClockReminder",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/AlarmSensorPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct AlarmSensorPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "AlarmSensor",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/BGReceivedPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public struct BGReceivedPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "BGReceivedPumpEvent",
"timestamp": TimeFormat.timestampStr(timestamp),
"amount": amount,
"meter": meter,
]
Expand Down
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/BasalProfileStartPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public struct BasalProfileStartPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "BasalProfileStart",
"timestamp": TimeFormat.timestampStr(timestamp),
"offset": offset,
"rate": rate,
"profileIndex": profileIndex,
Expand Down
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/BatteryPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct BatteryPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "Battery",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/BolusNormalPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public struct BolusNormalPumpEvent: TimestampedPumpEvent {
"amount": amount,
"programmed": programmed,
"type": type.rawValue,
"timestamp": TimeFormat.timestampStr(timestamp),
]

if let unabsorbedInsulinRecord = unabsorbedInsulinRecord {
Expand Down
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/BolusWizardEstimatePumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public struct BolusWizardEstimatePumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "BolusWizardBolusEstimate",
"timestamp": TimeFormat.timestampStr(timestamp),
"bg": bloodGlucose,
"bgTargetHigh": bgTargetHigh,
"correctionEstimate": correctionEstimate,
Expand Down
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/CalBGForPHPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public struct CalBGForPHPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "CalBGForPH",
"timestamp": TimeFormat.timestampStr(timestamp),
"amount": amount,
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeAlarmClockEnablePumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeAlarmClockEnable",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/ChangeAlarmClockTimePumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeAlarmClockTimePumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeAlarmClockTime",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/ChangeAlarmNotifyModePumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeAlarmNotifyModePumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeAlarmNotifyMode",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/ChangeAudioBolusPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeAudioBolusPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeAudioBolus",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeBGReminderEnablePumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeBGReminderEnable",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeBGReminderOffsetPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeBGReminderOffset",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeBasalProfilePatternPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeBasalProfilePattern",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/ChangeBasalProfilePumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeBasalProfilePumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeBasalProfile",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeBolusReminderEnablePumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeBolusReminderEnable",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeBolusReminderTimePumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeBolusReminderTime",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeBolusScrollStepSizePumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeBolusScrollStepSize",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public struct ChangeBolusWizardSetupPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeBolusWizardSetup",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeCaptureEventEnablePumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeCaptureEventEnable",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/ChangeCarbUnitsPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeCarbUnitsPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeCarbUnits",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeChildBlockEnablePumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeChildBlockEnable",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/ChangeMaxBasalPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeMaxBasalPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeMaxBasal",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/ChangeMaxBolusPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeMaxBolusPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeMaxBolus",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/ChangeOtherDeviceIDPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeOtherDeviceIDPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeOtherDeviceID",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/ChangeParadigmLinkIDPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeParadigmLinkIDPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeParadigmLinkID",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeReservoirWarningTimePumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeReservoirWarningTime",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeSensorRateOfChangeAlertSetupPumpEvent: TimestampedPumpEvent
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeSensorRateOfChangeAlertSetup",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/ChangeSensorSetup2PumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeSensorSetup2PumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeSensorSetup2",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/ChangeTempBasalTypePumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public struct ChangeTempBasalTypePumpEvent: TimestampedPumpEvent {
return [
"_type": "TempBasal",
"temp": basalType,
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/ChangeTimeFormatPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeTimeFormatPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeTimeFormat",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/ChangeTimePumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeTimePumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeTime",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/ChangeVariableBolusPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeVariableBolusPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeVariableBolus",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/ChangeWatchdogEnablePumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeWatchdogEnablePumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeWatchdogEnable",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ChangeWatchdogMarriageProfilePumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ChangeWatchdogMarriageProfile",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/ClearAlarmPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct ClearAlarmPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "ClearAlarm",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/DeleteAlarmClockTimePumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct DeleteAlarmClockTimePumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "DeleteAlarmClockTime",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct DeleteBolusReminderTimePumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "DeleteBolusReminderTime",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/DeleteOtherDeviceIDPumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct DeleteOtherDeviceIDPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "DeleteOtherDeviceID",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
1 change: 0 additions & 1 deletion MinimedKit/PumpEvents/EnableDisableRemotePumpEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct EnableDisableRemotePumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "EnableDisableRemote",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct JournalEntryExerciseMarkerPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "JournalEntryExerciseMarker",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct JournalEntryPumpLowBatteryPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "JournalEntryPumpLowBattery",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public struct JournalEntryPumpLowReservoirPumpEvent: TimestampedPumpEvent {
public var dictionaryRepresentation: [String: AnyObject] {
return [
"_type": "JournalEntryPumpLowReservoir",
"timestamp": TimeFormat.timestampStr(timestamp),
]
}
}
Loading

0 comments on commit 4040519

Please sign in to comment.