Kaynağa Gözat

Merge pull request #3 from ivalkou/preparejs

all hail oref0 detect-sensivity
Ivan 5 yıl önce
ebeveyn
işleme
a35f443a99

+ 4 - 4
FreeAPS.xcodeproj/project.pbxproj

@@ -1834,7 +1834,7 @@
 				CODE_SIGN_ENTITLEMENTS = FreeAPS/Resources/FreeAPS.entitlements;
 				CODE_SIGN_STYLE = Automatic;
 				DEVELOPMENT_ASSET_PATHS = "";
-				DEVELOPMENT_TEAM = BA7ZHP4963;
+				DEVELOPMENT_TEAM = 777258T3K8;
 				ENABLE_PREVIEWS = YES;
 				INFOPLIST_FILE = FreeAPS/Resources/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 14.0;
@@ -1857,7 +1857,7 @@
 				CODE_SIGN_ENTITLEMENTS = FreeAPS/Resources/FreeAPS.entitlements;
 				CODE_SIGN_STYLE = Automatic;
 				DEVELOPMENT_ASSET_PATHS = "";
-				DEVELOPMENT_TEAM = BA7ZHP4963;
+				DEVELOPMENT_TEAM = 777258T3K8;
 				ENABLE_PREVIEWS = YES;
 				INFOPLIST_FILE = FreeAPS/Resources/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 14.0;
@@ -1877,7 +1877,7 @@
 			buildSettings = {
 				BUNDLE_LOADER = "$(TEST_HOST)";
 				CODE_SIGN_STYLE = Automatic;
-				DEVELOPMENT_TEAM = BA7ZHP4963;
+				DEVELOPMENT_TEAM = 777258T3K8;
 				INFOPLIST_FILE = FreeAPSTests/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 14.4;
 				LD_RUNPATH_SEARCH_PATHS = (
@@ -1898,7 +1898,7 @@
 			buildSettings = {
 				BUNDLE_LOADER = "$(TEST_HOST)";
 				CODE_SIGN_STYLE = Automatic;
-				DEVELOPMENT_TEAM = BA7ZHP4963;
+				DEVELOPMENT_TEAM = 777258T3K8;
 				INFOPLIST_FILE = FreeAPSTests/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 14.4;
 				LD_RUNPATH_SEARCH_PATHS = (

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
FreeAPS/Resources/javascript/bundle/autosens.js


+ 9 - 4
FreeAPS/Resources/javascript/prepare/autosens.js

@@ -1,7 +1,11 @@
+// для settings/autosens.json параметры: monitor/glucose.json monitor/pumphistory-24h-zoned.json settings/basal_profile.json settings/profile.json monitor/carbhistory.json settings/temptargets.json
 var printLog = function(...args) {};
 var process = { stderr: { write: printLog } };
 
-function generate(pumphistory_data, profile_data, carb_data, glucose_data, basalprofile, temptarget_data) {
+function generate(glucose_data, pumphistory_data, basalprofile, profile_data, carb_data = {}, temptarget_data = {}) {
+    if (glucose_data.length < 72) {
+        return {"ratio": 1, "error": "not enough glucose data to calculate autosens"};
+    }
     var iob_inputs = {
         history: pumphistory_data,
         profile: profile_data
@@ -15,8 +19,9 @@ function generate(pumphistory_data, profile_data, carb_data, glucose_data, basal
         temptargets: temptarget_data
     };
     detection_inputs.deviations = 96;
-    var ratio8h = freeaps(detection_inputs);
+    var ratio8h = freeaps_autosens(detection_inputs);
     detection_inputs.deviations = 288;
-    var ratio24h = freeaps(detection_inputs);
-    return ratio8h.ratio < ratio24h.ratio ? ratio8h : ratio24h
+    var ratio24h = freeaps_autosens(detection_inputs);
+    var lowestRatio = ratio8h.ratio < ratio24h.ratio ? ratio8h : ratio24h;
+    return {"ratio": lowestRatio};
 }

+ 8 - 9
FreeAPS/Sources/APS/OpenAPS/OpenAPS.swift

@@ -83,14 +83,14 @@ final class OpenAPS {
                 let glucose = self.loadFileFromStorage(name: Monitor.glucose)
                 let profile = self.loadFileFromStorage(name: Settings.profile)
                 let basalProfile = self.loadFileFromStorage(name: Settings.basalProfile)
-
+                let tempTargets = self.loadFileFromStorage(name: Settings.tempTargets)
                 let autosensResult = self.autosense(
+                    glucose: glucose,
                     pumpHistory: pumpHistory,
+                    basalprofile: basalProfile,
                     profile: profile,
                     carbs: carbs,
-                    glucose: glucose,
-                    basalprofile: basalProfile,
-                    temptargets: RawJSON.null
+                    temptargets: tempTargets
                 )
 
                 debug(.openAPS, "AUTOSENS: \(autosensResult)")
@@ -283,26 +283,25 @@ final class OpenAPS {
     }
 
     private func autosense(
+        glucose: JSON,
         pumpHistory: JSON,
+        basalprofile: JSON,
         profile: JSON,
         carbs: JSON,
-        glucose: JSON,
-        basalprofile: JSON,
         temptargets: JSON
     ) -> RawJSON {
         dispatchPrecondition(condition: .onQueue(processQueue))
         return jsWorker.inCommonContext { worker in
             worker.evaluate(script: Script(name: Bundle.autosens))
             worker.evaluate(script: Script(name: Prepare.autosens))
-
             return worker.call(
                 function: Function.generate,
                 with: [
+                    glucose,
                     pumpHistory,
+                    basalprofile,
                     profile,
                     carbs,
-                    glucose,
-                    basalprofile,
                     temptargets
                 ]
             )