|
@@ -19,6 +19,10 @@ final class OpenAPS {
|
|
|
let reservoir = 100
|
|
let reservoir = 100
|
|
|
let tsMilliseconds: Double = 1_527_924_300_000
|
|
let tsMilliseconds: Double = 1_527_924_300_000
|
|
|
|
|
|
|
|
|
|
+ let preferences = self.exportDefaultPreferences()
|
|
|
|
|
+
|
|
|
|
|
+ print("DEFAULT PREFERENCES: \(preferences)")
|
|
|
|
|
+
|
|
|
let autosensResult = self.autosense(
|
|
let autosensResult = self.autosense(
|
|
|
pumpHistory: pumphistory,
|
|
pumpHistory: pumphistory,
|
|
|
profile: profile,
|
|
profile: profile,
|
|
@@ -230,6 +234,48 @@ final class OpenAPS {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private func exportDefaultPreferences() -> JSON {
|
|
|
|
|
+ dispatchPrecondition(condition: .onQueue(processQueue))
|
|
|
|
|
+ return jsWorker.inCommonContext { worker in
|
|
|
|
|
+ worker.evaluate(script: Script(name: "bundle/profile"))
|
|
|
|
|
+ worker.evaluate(script: Script(name: "prepare/profile"))
|
|
|
|
|
+ return worker.call(function: "exportDefaults", with: [])
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private func makeProfile(
|
|
|
|
|
+ preferences: JSON,
|
|
|
|
|
+ pumpSettings: JSON,
|
|
|
|
|
+ bgTargets: JSON,
|
|
|
|
|
+ basalProfile: JSON,
|
|
|
|
|
+ isf: JSON,
|
|
|
|
|
+ carbRatio: JSON,
|
|
|
|
|
+ tempTargets: JSON,
|
|
|
|
|
+ model: JSON,
|
|
|
|
|
+ autotune: JSON
|
|
|
|
|
+ ) -> JSON {
|
|
|
|
|
+ dispatchPrecondition(condition: .onQueue(processQueue))
|
|
|
|
|
+ return jsWorker.inCommonContext { worker in
|
|
|
|
|
+ worker.evaluate(script: Script(name: "bundle/profile"))
|
|
|
|
|
+ worker.evaluate(script: Script(name: "prepare/profile"))
|
|
|
|
|
+
|
|
|
|
|
+ return worker.call(
|
|
|
|
|
+ function: "generate",
|
|
|
|
|
+ with: [
|
|
|
|
|
+ preferences,
|
|
|
|
|
+ pumpSettings,
|
|
|
|
|
+ bgTargets,
|
|
|
|
|
+ basalProfile,
|
|
|
|
|
+ isf,
|
|
|
|
|
+ carbRatio,
|
|
|
|
|
+ tempTargets,
|
|
|
|
|
+ model,
|
|
|
|
|
+ autotune
|
|
|
|
|
+ ]
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private func loadJSON(name: String) -> String {
|
|
private func loadJSON(name: String) -> String {
|
|
|
try! String(contentsOf: Bundle.main.url(forResource: "json/\(name)", withExtension: "json")!)
|
|
try! String(contentsOf: Bundle.main.url(forResource: "json/\(name)", withExtension: "json")!)
|
|
|
}
|
|
}
|