|
@@ -324,9 +324,9 @@ final class BaseAPSManager: APSManager, Injectable {
|
|
|
return nil
|
|
return nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- func autosens() async throws -> Bool {
|
|
|
|
|
- guard let autosens = await storage.retrieveAsync(OpenAPS.Settings.autosense, as: Autosens.self),
|
|
|
|
|
- (autosens.timestamp ?? .distantPast).addingTimeInterval(30.minutes.timeInterval) > Date()
|
|
|
|
|
|
|
+ func autosense() async throws -> Bool {
|
|
|
|
|
+ guard let autosense = await storage.retrieveAsync(OpenAPS.Settings.autosense, as: Autosens.self),
|
|
|
|
|
+ (autosense.timestamp ?? .distantPast).addingTimeInterval(30.minutes.timeInterval) > Date()
|
|
|
else {
|
|
else {
|
|
|
let result = try await openAPS.autosense()
|
|
let result = try await openAPS.autosense()
|
|
|
return result != nil
|
|
return result != nil
|
|
@@ -373,11 +373,17 @@ final class BaseAPSManager: APSManager, Injectable {
|
|
|
|
|
|
|
|
do {
|
|
do {
|
|
|
let now = Date()
|
|
let now = Date()
|
|
|
- let temp = await fetchCurrentTempBasal(date: now)
|
|
|
|
|
- _ = try await makeProfiles()
|
|
|
|
|
- _ = try await autosens()
|
|
|
|
|
- _ = try await dailyAutotune()
|
|
|
|
|
- let determination = try await openAPS.determineBasal(currentTemp: temp, clock: now)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // Start fetching asynchronously
|
|
|
|
|
+ let (currentTemp, profiles, autosense, dailyAutotune) = try await (
|
|
|
|
|
+ fetchCurrentTempBasal(date: now),
|
|
|
|
|
+ makeProfiles(),
|
|
|
|
|
+ autosense(),
|
|
|
|
|
+ dailyAutotune()
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ // Determine basal using the fetched temp and current time
|
|
|
|
|
+ let determination = try await openAPS.determineBasal(currentTemp: currentTemp, clock: now)
|
|
|
|
|
|
|
|
if let determination = determination {
|
|
if let determination = determination {
|
|
|
DispatchQueue.main.async {
|
|
DispatchQueue.main.async {
|