Ivan Valkou 5 rokov pred
rodič
commit
24470d8010

+ 8 - 0
FreeAPS/Resources/Info.plist

@@ -60,5 +60,13 @@
 		<key>NSAllowsArbitraryLoads</key>
 		<true/>
 	</dict>
+	<key>LSApplicationQueriesSchemes</key>
+	<array>
+		<string>dexcomg6</string>
+		<string>dexcomcgm</string>
+		<string>dexcomshare</string>
+		<string>diabox</string>
+		<string>spikeapp</string>
+	</array>
 </dict>
 </plist>

+ 0 - 1
FreeAPS/Resources/json/autosens.json

@@ -1 +0,0 @@
-{"ratio":1.0}

+ 0 - 8
FreeAPS/Resources/json/basal_profile.json

@@ -1,8 +0,0 @@
-[
-  {
-    "minutes": 0,
-    "rate": 1,
-    "start": "00:00:00",
-    "i": 0
-  }
-]

+ 0 - 14
FreeAPS/Resources/json/carbhistory.json

@@ -1,14 +0,0 @@
-[
-  {
-    "enteredBy": "fakecarbs",
-    "carbs": 5,
-    "created_at": "2018-06-02T07:00:00.000Z",
-    "insulin": null
-  },
-  {
-    "enteredBy": "fakecarbs",
-    "carbs": 15,
-    "created_at": "2018-06-02T07:05:00.000Z",
-    "insulin": null
-  }
-]

+ 0 - 1
FreeAPS/Resources/json/clock.json

@@ -1 +0,0 @@
-"2018-06-02T00:30:00-07:00"

+ 0 - 8
FreeAPS/Resources/json/example.sh

@@ -1,8 +0,0 @@
-#!/bin/bash
-
-oref0-calculate-iob pumphistory.json profile.json clock.json autosens.json > iob.json
-oref0-meal pumphistory.json profile.json clock.json glucose.json basal_profile.json carbhistory.json > meal.json
-oref0-determine-basal iob.json temp_basal.json glucose.json profile.json --auto-sens autosens.json --meal meal.json --microbolus --currentTime 1527924300000 > suggested.json
-cat suggested.json | jq -C -c '. | del(.predBGs) | del(.reason)'
-cat suggested.json | jq -C -c .reason
-cat suggested.json | jq -C -c .predBGs

+ 0 - 50
FreeAPS/Resources/json/glucose.json

@@ -1,50 +0,0 @@
-[
-  {
-    "date": 1527924300000,
-    "dateString": "2018-06-02T00:25:00-07:00",
-    "sgv": 101,
-    "device": "fakecgm",
-    "type": "sgv",
-    "glucose": 101
-  },
-  {
-    "date": 1527924000000,
-    "dateString": "2018-06-02T00:20:00-07:00",
-    "sgv": 102,
-    "device": "fakecgm",
-    "type": "sgv",
-    "glucose": 102
-  },
-  {
-    "date": 1527923700000,
-    "dateString": "2018-06-02T00:15:00-07:00",
-    "sgv": 105,
-    "device": "fakecgm",
-    "type": "sgv",
-    "glucose": 105
-  },
-  {
-    "date": 1527923400000,
-    "dateString": "2018-06-02T00:10:00-07:00",
-    "sgv": 105,
-    "device": "fakecgm",
-    "type": "sgv",
-    "glucose": 105
-  },
-  {
-    "date": 1527923100000,
-    "dateString": "2018-06-02T00:05:00-07:00",
-    "sgv": 102,
-    "device": "fakecgm",
-    "type": "sgv",
-    "glucose": 102
-  },
-  {
-    "date": 1527922800000,
-    "dateString": "2018-06-02T00:00:00-07:00",
-    "sgv": 100,
-    "device": "fakecgm",
-    "type": "sgv",
-    "glucose": 100
-  }
-]

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 1
FreeAPS/Resources/json/iob.json


+ 0 - 1
FreeAPS/Resources/json/meal.json

@@ -1 +0,0 @@
-{"carbs":20,"nsCarbs":20,"bwCarbs":0,"journalCarbs":0,"mealCOB":20,"currentDeviation":-1.21,"maxDeviation":1.74,"minDeviation":0.1,"slopeFromMaxDeviation":-0.983,"slopeFromMinDeviation":0,"allDeviations":[-1,0,2],"lastCarbTime":1527923100000,"bwFound":false,"reason":"not enough glucose data to calculate carb absorption"}

+ 0 - 83
FreeAPS/Resources/json/profile.json

@@ -1,83 +0,0 @@
-{
-  "carb_ratios": {
-    "schedule": [
-      {
-        "x": 0,
-        "i": 0,
-        "offset": 0,
-        "ratio": 10,
-        "r": 10,
-        "start": "00:00:00"
-      }
-    ],
-    "units": "grams"
-  },
-  "carb_ratio": 10,
-  "isfProfile": {
-    "first": 1,
-    "sensitivities": [
-      {
-        "endOffset": 1440,
-        "offset": 0,
-        "x": 0,
-        "sensitivity": 50,
-        "start": "00:00:00",
-        "i": 0
-      }
-    ],
-    "user_preferred_units": "mg/dL",
-    "units": "mg/dL"
-  },
-  "sens": 50,
-  "bg_targets": {
-    "first": 1,
-    "targets": [
-      {
-        "max_bg": 100,
-        "min_bg": 100,
-        "x": 0,
-        "offset": 0,
-        "low": 100,
-        "start": "00:00:00",
-        "high": 100,
-        "i": 0
-      }
-    ],
-    "user_preferred_units": "mg/dL",
-    "units": "mg/dL"
-  },
-  "max_bg": 100,
-  "min_bg": 100,
-  "out_units": "mg/dL",
-  "max_basal": 4,
-  "min_5m_carbimpact": 8,
-  "maxCOB": 120,
-  "max_iob": 6,
-  "max_daily_safety_multiplier": 4,
-  "current_basal_safety_multiplier": 5,
-  "autosens_max": 2,
-  "autosens_min": 0.5,
-  "remainingCarbsCap": 90,
-  "enableUAM": true,
-  "enableSMB_with_bolus": true,
-  "enableSMB_with_COB": true,
-  "enableSMB_with_temptarget": false,
-  "enableSMB_after_carbs": true,
-  "maxSMBBasalMinutes": 75,
-  "curve": "rapid-acting",
-  "useCustomPeakTime": false,
-  "insulinPeakTime": 75,
-  "dia": 6,
-  "bolus_increment": 0.1,
-  "current_basal": 1.0,
-  "rewind_resets_autosens": true,
-  "basalprofile": [
-    {
-      "minutes": 0,
-      "rate": 1.0,
-      "start": "00:00:00",
-      "i": 0
-    }
-  ],
-  "max_daily_basal": 1.0
-}

+ 0 - 19
FreeAPS/Resources/json/pumphistory.json

@@ -1,19 +0,0 @@
-[
-  {
-    "timestamp": "2018-06-02T00:05:00-07:00",
-    "_type": "Bolus",
-    "amount": 0.4,
-    "duration": 0
-  },
-  {
-    "timestamp": "2018-06-02T00:00:00-07:00",
-    "_type": "TempBasalDuration",
-    "duration (min)": 14400
-  },
-  {
-    "timestamp": "2018-06-02T00:00:00-07:00",
-    "_type": "TempBasal",
-    "temp": "absolute",
-    "rate": 0
-  }
-]

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 1
FreeAPS/Resources/json/suggested.json


+ 0 - 5
FreeAPS/Resources/json/temp_basal.json

@@ -1,5 +0,0 @@
-{
-  "duration": 30,
-  "temp": "absolute",
-  "rate": 0
-}

+ 14 - 0
FreeAPS/Sources/Modules/Home/HomeViewModel.swift

@@ -7,6 +7,7 @@ extension Home {
         @Injected() var broadcaster: Broadcaster!
         @Injected() var settingsManager: SettingsManager!
         @Injected() var apsManager: APSManager!
+        @Injected() var nightscoutManager: NightscoutManager!
         private let timer = Timer.publish(every: 5, on: .main, in: .common).autoconnect()
         private(set) var filteredHours = 24
 
@@ -229,6 +230,19 @@ extension Home {
                 self.battery = self.provider.pumpBattery()
             }
         }
+
+        func openCGM() {
+            guard var url = nightscoutManager.cgmURL else { return }
+
+            switch url.absoluteString {
+            case "http://127.0.0.1:1979":
+                url = URL(string: "spikeapp://")!
+            case "http://127.0.0.1:17580":
+                url = URL(string: "diabox://")!
+            default: break
+            }
+            UIApplication.shared.open(url, options: [:], completionHandler: nil)
+        }
     }
 }
 

+ 3 - 0
FreeAPS/Sources/Modules/Home/View/HomeRootView.swift

@@ -35,6 +35,9 @@ extension Home {
                     delta: $viewModel.glucoseDelta,
                     units: viewModel.units
                 )
+                .onTapGesture {
+                    viewModel.openCGM()
+                }
                 Spacer()
                 PumpView(
                     reservoir: $viewModel.reservoir,

+ 12 - 0
FreeAPS/Sources/Services/Network/NightscoutManager.swift

@@ -9,6 +9,7 @@ protocol NightscoutManager {
     func fetchTempTargets() -> AnyPublisher<Void, Never>
     func fetchAnnouncements() -> AnyPublisher<Void, Never>
     func uploadStatus()
+    var cgmURL: URL? { get }
 }
 
 final class BaseNightscoutManager: NightscoutManager, Injectable {
@@ -51,6 +52,17 @@ final class BaseNightscoutManager: NightscoutManager, Injectable {
         broadcaster.register(TempTargetsObserver.self, observer: self)
     }
 
+    var cgmURL: URL? {
+        let useLocal = (settingsManager.settings.useLocalGlucoseSource ?? false) && settingsManager.settings
+            .localGlucosePort != nil
+
+        let maybeNightscout = useLocal
+            ? NightscoutAPI(url: URL(string: "http://127.0.0.1:\(settingsManager.settings.localGlucosePort!)")!)
+            : nightscoutAPI
+
+        return maybeNightscout?.url
+    }
+
     func fetchGlucose() -> AnyPublisher<[BloodGlucose], Never> {
         let useLocal = (settingsManager.settings.useLocalGlucoseSource ?? false) && settingsManager.settings
             .localGlucosePort != nil