diff --git a/FreeAPS.xcodeproj/project.pbxproj b/FreeAPS.xcodeproj/project.pbxproj index 1a63abeef..34d6fbee6 100644 --- a/FreeAPS.xcodeproj/project.pbxproj +++ b/FreeAPS.xcodeproj/project.pbxproj @@ -1958,7 +1958,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 0.1.0; + MARKETING_VERSION = 0.1.1; PRODUCT_BUNDLE_IDENTIFIER = ru.artpancreas.FreeAPS; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -1983,7 +1983,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 0.1.0; + MARKETING_VERSION = 0.1.1; PRODUCT_BUNDLE_IDENTIFIER = ru.artpancreas.FreeAPS; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; diff --git a/FreeAPS/Resources/Config.xcconfig b/FreeAPS/Resources/Config.xcconfig index 84bf72cf8..e216845e3 100644 --- a/FreeAPS/Resources/Config.xcconfig +++ b/FreeAPS/Resources/Config.xcconfig @@ -1 +1 @@ -CURRENT_PROJECT_VERSION = 0.1.0 +CURRENT_PROJECT_VERSION = 0.1.1 diff --git a/FreeAPS/Resources/Info.plist b/FreeAPS/Resources/Info.plist index a28bc49d2..e3d468dfd 100644 --- a/FreeAPS/Resources/Info.plist +++ b/FreeAPS/Resources/Info.plist @@ -17,7 +17,7 @@ CFBundleShortVersionString $(MARKETING_VERSION) CFBundleVersion - 248 + 259 LSApplicationQueriesSchemes dexcomg6 diff --git a/FreeAPS/Resources/javascript/prepare/determine-basal.js b/FreeAPS/Resources/javascript/prepare/determine-basal.js index 1bece1ae7..46a28f0dd 100644 --- a/FreeAPS/Resources/javascript/prepare/determine-basal.js +++ b/FreeAPS/Resources/javascript/prepare/determine-basal.js @@ -3,7 +3,7 @@ var printLog = function(...args) {}; var process = { stderr: { write: printLog } }; -function generate(iob_data, currenttemp, glucose_data, profile, autosens_input = false, meal_input = false, microbolus = false, reservoir_input = false, clock = null){ +function generate(iob_data, currenttemp, glucose_data, profile, autosens_input = false, meal_input = false, microbolus = false, reservoir_input = false, clock = new Date()){ var glucose_status = freeaps_glucoseGetLast(glucose_data); var autosens_data = null; diff --git a/FreeAPS/Resources/json/defaults/monitor/reservoir.json b/FreeAPS/Resources/json/defaults/monitor/reservoir.json new file mode 100644 index 000000000..697cb3a26 --- /dev/null +++ b/FreeAPS/Resources/json/defaults/monitor/reservoir.json @@ -0,0 +1 @@ +300 diff --git a/FreeAPS/Sources/APS/APSManager.swift b/FreeAPS/Sources/APS/APSManager.swift index eb7f7e99c..8e5f770ad 100644 --- a/FreeAPS/Sources/APS/APSManager.swift +++ b/FreeAPS/Sources/APS/APSManager.swift @@ -156,7 +156,7 @@ final class BaseAPSManager: APSManager, Injectable { .eraseToAnyPublisher() } - return Just(true).eraseToAnyPublisher() + return Just(false).eraseToAnyPublisher() } func determineBasal() -> AnyPublisher { diff --git a/FreeAPS/Sources/APS/GlucoseManager.swift b/FreeAPS/Sources/APS/GlucoseManager.swift index a8035e113..a44de23d9 100644 --- a/FreeAPS/Sources/APS/GlucoseManager.swift +++ b/FreeAPS/Sources/APS/GlucoseManager.swift @@ -23,14 +23,14 @@ final class BaseGlucoseManager: GlucoseManager, Injectable { timer.publisher .receive(on: processQueue) .flatMap { date -> AnyPublisher<[BloodGlucose], Never> in - guard self.glucoseStogare.syncDate().timeIntervalSince1970 + 4.minutes.timeInterval <= date.timeIntervalSince1970 + guard self.glucoseStogare.syncDate().timeIntervalSince1970 <= date.timeIntervalSince1970 else { return Just([]).eraseToAnyPublisher() } return self.nightscoutManager.fetchGlucose() } .sink { glucose in - if !glucose.isEmpty { + if !self.glucoseStogare.filterTooFrequentGlucose(glucose).isEmpty { self.apsManager.heartbeatNow() } } diff --git a/FreeAPS/Sources/APS/Storage/GlucoseStorage.swift b/FreeAPS/Sources/APS/Storage/GlucoseStorage.swift index 3b689b645..cfe529c11 100644 --- a/FreeAPS/Sources/APS/Storage/GlucoseStorage.swift +++ b/FreeAPS/Sources/APS/Storage/GlucoseStorage.swift @@ -6,6 +6,7 @@ protocol GlucoseStorage { func storeGlucose(_ glucose: [BloodGlucose]) func recent() -> [BloodGlucose] func syncDate() -> Date + func filterTooFrequentGlucose(_ glucose: [BloodGlucose]) -> [BloodGlucose] } final class BaseGlucoseStorage: GlucoseStorage, Injectable { @@ -13,15 +14,20 @@ final class BaseGlucoseStorage: GlucoseStorage, Injectable { @Injected() private var storage: FileStorage! @Injected() private var broadcaster: Broadcaster! + private enum Config { + static let filterTime: TimeInterval = 4.75 * 60 + } + init(resolver: Resolver) { injectServices(resolver) } func storeGlucose(_ glucose: [BloodGlucose]) { processQueue.sync { + let filtered = self.filterTooFrequentGlucose(glucose) let file = OpenAPS.Monitor.glucose self.storage.transaction { storage in - storage.append(glucose, to: file, uniqBy: \.dateString) + storage.append(filtered, to: file, uniqBy: \.dateString) let uniqEvents = storage.retrieve(file, as: [BloodGlucose].self)? .filter { $0.dateString.addingTimeInterval(1.days.timeInterval) > Date() } .sorted { $0.dateString > $1.dateString } ?? [] @@ -43,12 +49,27 @@ final class BaseGlucoseStorage: GlucoseStorage, Injectable { else { return Date().addingTimeInterval(-1.days.timeInterval) } - return recent.dateString.addingTimeInterval(1.minutes.timeInterval) + return recent.dateString.addingTimeInterval(Config.filterTime) } func recent() -> [BloodGlucose] { storage.retrieve(OpenAPS.Monitor.glucose, as: [BloodGlucose].self)?.reversed() ?? [] } + + func filterTooFrequentGlucose(_ glucose: [BloodGlucose]) -> [BloodGlucose] { + var lastDate = recent().first?.dateString ?? .distantPast + var filtered: [BloodGlucose] = [] + + for entry in glucose.reversed() { + guard entry.dateString.addingTimeInterval(-Config.filterTime) > lastDate else { + continue + } + filtered.append(entry) + lastDate = entry.dateString + } + + return filtered + } } protocol GlucoseObserver { diff --git a/FreeAPS/Sources/Models/BloodGlucose.swift b/FreeAPS/Sources/Models/BloodGlucose.swift index b42f4703d..7f225bf51 100644 --- a/FreeAPS/Sources/Models/BloodGlucose.swift +++ b/FreeAPS/Sources/Models/BloodGlucose.swift @@ -23,7 +23,7 @@ struct BloodGlucose: JSON, Identifiable, Hashable { var sgv: Int? let direction: Direction? - let date: UInt64 + let date: Decimal let dateString: Date let filtered: Double? let noise: Int? diff --git a/FreeAPS/Sources/Modules/AutotuneConfig/AutotuneConfigViewModel.swift b/FreeAPS/Sources/Modules/AutotuneConfig/AutotuneConfigViewModel.swift index 42e66199a..6705561ea 100644 --- a/FreeAPS/Sources/Modules/AutotuneConfig/AutotuneConfigViewModel.swift +++ b/FreeAPS/Sources/Modules/AutotuneConfig/AutotuneConfigViewModel.swift @@ -37,6 +37,9 @@ extension AutotuneConfig { func delete() { provider.deleteAutotune() autotune = nil + apsManager.makeProfiles() + .sink { _ in } + .store(in: &lifetime) } } } diff --git a/FreeAPS/Sources/Modules/Home/View/Chart/MainChartView.swift b/FreeAPS/Sources/Modules/Home/View/Chart/MainChartView.swift index 58528b8a6..62f328605 100644 --- a/FreeAPS/Sources/Modules/Home/View/Chart/MainChartView.swift +++ b/FreeAPS/Sources/Modules/Home/View/Chart/MainChartView.swift @@ -238,6 +238,9 @@ struct MainChartView: View { .onChange(of: didAppearTrigger) { _ in update(fullSize: fullSize) } + .onReceive(Foundation.NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)) { _ in + update(fullSize: fullSize) + } } private func bolusView(fullSize: CGSize) -> some View { @@ -329,9 +332,6 @@ struct MainChartView: View { .onChange(of: suggestion) { _ in update(fullSize: fullSize) } - .onChange(of: didAppearTrigger) { _ in - update(fullSize: fullSize) - } } } diff --git a/README.md b/README.md index e9058090f..8977d29c6 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ FreeAPS X is in an active development state If you want to test it, there is a beta-version available -## Implemented in version 0.1.0 (Beta) +## Implemented - All base functions of oref0 - All base functions of oref1 (SMB, UAM and others) @@ -60,3 +60,8 @@ If you want to test it, there is a beta-version available *In progress* +## Community + +- [English Telegram group](https://t.me/freeapsx_eng) +- [Russian Telegram group](https://t.me/freeapsx) + diff --git a/README_RU.md b/README_RU.md index f2d5b2c11..ca0510c4a 100644 --- a/README_RU.md +++ b/README_RU.md @@ -31,7 +31,7 @@ FreeAPS X находится в состоянии активной разраб Для тестирования на текущий момент доступна бета-версия приложения -## Реализовано в версия 0.1.0 (Beta) +## Реализовано - Все базовые функции oref0 - Все базовые функции oref1 (SMB, UAM и другие) @@ -60,4 +60,7 @@ FreeAPS X находится в состоянии активной разраб *В разработке* +## Сообщество +- [Английская Telegram группа](https://t.me/freeapsx_eng) +- [Русская Telegram группа](https://t.me/freeapsx) diff --git a/scripts/build-number-update.swift b/scripts/build-number-update.swift index 5a1f32e5d..67c39d7d8 100755 --- a/scripts/build-number-update.swift +++ b/scripts/build-number-update.swift @@ -177,13 +177,13 @@ func checkdSYM(buildNumber: String?) { // MARK: Implementation guard let currentBranch = execute(command: "/usr/bin/git", args: ["rev-parse", "--abbrev-ref", "HEAD"]).map(Branch.init) else { - print("error: Can't determine current branch!") - exit(1) + print("Can't determine current branch! Skiping...") + exit(0) } guard let commitsCount = execute(command: "/usr/bin/git", args: ["rev-list", "--count", "HEAD"]), !commitsCount.isEmpty else { - print("error: Can't determine commits count!") - exit(1) + print("Can't determine commits count! Skiping..") + exit(0) } guard let targetBuildDir = ProcessInfo.processInfo.environment["TARGET_BUILD_DIR"], !targetBuildDir.isEmpty else {