Просмотр исходного кода

add autotune (bad way, rework later)

Den 5 лет назад
Родитель
Сommit
3892ac266c

+ 2 - 2
FreeAPS.xcodeproj/project.pbxproj

@@ -966,7 +966,7 @@
 				CODE_SIGN_ENTITLEMENTS = FreeAPS/Resources/FreeAPS.entitlements;
 				CODE_SIGN_STYLE = Automatic;
 				DEVELOPMENT_ASSET_PATHS = "\"FreeAPS/Preview Content\"";
-				DEVELOPMENT_TEAM = BA7ZHP4963;
+				DEVELOPMENT_TEAM = 777258T3K8;
 				ENABLE_PREVIEWS = YES;
 				INFOPLIST_FILE = FreeAPS/Resources/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 14.0;
@@ -989,7 +989,7 @@
 				CODE_SIGN_ENTITLEMENTS = FreeAPS/Resources/FreeAPS.entitlements;
 				CODE_SIGN_STYLE = Automatic;
 				DEVELOPMENT_ASSET_PATHS = "\"FreeAPS/Preview Content\"";
-				DEVELOPMENT_TEAM = BA7ZHP4963;
+				DEVELOPMENT_TEAM = 777258T3K8;
 				ENABLE_PREVIEWS = YES;
 				INFOPLIST_FILE = FreeAPS/Resources/Info.plist;
 				IPHONEOS_DEPLOYMENT_TARGET = 14.0;

Разница между файлами не показана из-за своего большого размера
+ 1 - 0
FreeAPS/Resources/javascript/bundle/autotune-core.js


Разница между файлами не показана из-за своего большого размера
+ 2 - 0
FreeAPS/Resources/javascript/bundle/autotune-prep.js


+ 57 - 0
FreeAPS/Sources/APS/OpenAPS/OpenAPS.swift

@@ -64,6 +64,25 @@ final class OpenAPS {
                 tsMilliseconds: tsMilliseconds
             )
             print("SUGGESTED: \(suggested)")
+
+            let autotunePreppedGlucose = self.autotunePrepare(
+                pumphistory: pumphistory,
+                profile: profile,
+                glucose: glucose,
+                pumpprofile: profile,
+                categorizeUamAsBasal: true,
+                tuneInsulinCurve: false
+            )
+            print("AUTOTUNE PREP: \(autotunePreppedGlucose)")
+
+            let autotuneResult = self.autotuneRun(
+                autotuneprepareddata: autotunePreppedGlucose,
+                previousautotuneresult: profile,
+                pumpprofile: profile
+            )
+
+            print("AUTOTUNE RESULT: \(autotuneResult)")
+
             let finishDate = Date()
             print("FINISH at \(finishDate), duration \(finishDate.timeIntervalSince(now)) s")
         }
@@ -100,6 +119,44 @@ final class OpenAPS {
         }
     }
 
+    private func autotunePrepare(
+        pumphistory: JSON,
+        profile: JSON,
+        glucose: JSON,
+        pumpprofile: JSON,
+        categorizeUamAsBasal: Bool,
+        tuneInsulinCurve: Bool
+    ) -> JSON {
+        dispatchPrecondition(condition: .onQueue(processQueue))
+        return jsWorker.inCommonContext { worker in
+            worker.evaluate(script: Script(name: "bundle/autotune-prep"))
+            return worker.call(function: "freeaps", with: [
+                pumphistory,
+                profile,
+                glucose,
+                pumpprofile,
+                categorizeUamAsBasal,
+                tuneInsulinCurve
+            ])
+        }
+    }
+
+    private func autotuneRun(
+        autotuneprepareddata: JSON,
+        previousautotuneresult: JSON,
+        pumpprofile: JSON
+    ) -> JSON {
+        dispatchPrecondition(condition: .onQueue(processQueue))
+        return jsWorker.inCommonContext { worker in
+            worker.evaluate(script: Script(name: "bundle/autotune-core"))
+            return worker.call(function: "freeaps", with: [
+                autotuneprepareddata,
+                previousautotuneresult,
+                pumpprofile
+            ])
+        }
+    }
+
     private func glucoseGetLast(glucose: JSON) -> JSON {
         dispatchPrecondition(condition: .onQueue(processQueue))
         return jsWorker.inCommonContext { worker in