Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
0468f57
fix: Aggregate Javascript logs
mkellerman Jun 16, 2024
037656f
fix: refactored to a more generic log parsing method
mkellerman Jun 23, 2024
e64189f
fix: formatting
mkellerman Jun 23, 2024
01e0ffd
Fix: comments
mkellerman Jun 23, 2024
85bf02a
refactored to simpler formatter and cleanup autosens
mkellerman Jul 2, 2024
0415460
fix: output unknown outputs as regular log lines
mkellerman Jul 4, 2024
14f0b4a
chore: rename and cleanup some of the variables
mkellerman Jul 6, 2024
dd38115
fix: autosens logs to be evaluated line by line
mkellerman Jul 12, 2024
81cef4a
Merge remote-tracking branch 'upstream/dev' into fix-autosens-logs
mkellerman Jul 12, 2024
a77b123
fix regex to include u(x)
mkellerman Jul 19, 2024
5a33cd1
update submodule TidepoolSevice: align with LoopKit:dev version
marionbarker Jul 21, 2024
0354c35
chore: middleware to show the actual name being executed
mkellerman Jul 22, 2024
8d8ce50
Merge branch 'nightscout:dev' into fix-autosens-logs
mkellerman Jul 30, 2024
c560f9b
fix regex to include single exclamation point
mkellerman Jul 30, 2024
d4af108
fix remove middleware label
mkellerman Jul 30, 2024
e86fd4f
Merge remote-tracking branch 'upstream/dev' into fix-autosens-logs
mkellerman Aug 12, 2024
4b2d411
Merge branch 'nightscout:main' into fix-autosens-logs
mkellerman Aug 18, 2024
0d6bb18
update submodules OmniXXX: fix rare UI error for pod already paired
marionbarker Aug 19, 2024
cd25e6f
glucose rounding fix
MikePlante1 Aug 25, 2024
f608921
Merge pull request #388 from loopandlearn/fix/pod-already-paired
MikePlante1 Aug 25, 2024
633ae17
Merge pull request #398 from MikePlante1/round
dnzxy Aug 26, 2024
9c02c60
Fix Discord URL
tonypartridge Sep 20, 2024
b0f6d41
Fix Discord URL
tonypartridge Sep 20, 2024
4f2eada
update submodule LibreTransmitter: support libre 2 plus european sensors
marionbarker Sep 20, 2024
9be6a78
Merge pull request #413 from loopandlearn/libre_submodule_update
Sjoerd-Bo3 Sep 20, 2024
3792500
Merge pull request #357 from loopandlearn/submodule_update
Sjoerd-Bo3 Sep 20, 2024
b94606c
fix: use only the lastPathComponent of the script name
mkellerman Sep 22, 2024
d552f6e
Update README.md
tonypartridge Sep 23, 2024
daf6798
Update CODE_OF_CONDUCT.md
tonypartridge Sep 23, 2024
60fdea2
Merge pull request #412 from tonypartridge/main
MikePlante1 Sep 28, 2024
023642a
Merge pull request #420 from MikePlante1/fastlane-update
bjornoleh Sep 29, 2024
410a031
CGMBLEKit: SHA only, no code change
marionbarker Oct 3, 2024
5396a2b
G7SensorKit: Add ONE+ to the display name
marionbarker Oct 3, 2024
3f5da15
LibreTransmitter: Xcode 16 build speedup, fix notification
marionbarker Oct 3, 2024
d95ef4e
LoopKit: Xcode 16 build speedup
marionbarker Oct 3, 2024
8c2c24d
OmniBLE: Xcode 16 build speedup; fix/deactivate-sideways-pull
marionbarker Oct 3, 2024
dd3dc5a
OmniKit: Xcode 16 build speedup; fix/deactivate-sideways-pull
marionbarker Oct 3, 2024
ca463b9
LibreTransmitter: SHA only, no code change
marionbarker Oct 3, 2024
d12357a
LibreTransmitter: update SHA, no code change
marionbarker Oct 7, 2024
48e2fd9
LoopKit: improve visibility of items to select
marionbarker Oct 7, 2024
c5e7bb6
Merge pull request #424 from loopandlearn/update_submodules_fix_Xcode16
dnzxy Oct 8, 2024
3acfe1e
issue #40 : update glucose units when creating manager
Oct 10, 2024
f797d6f
issue #40 : update manager glucose units when changing trio preferences
Oct 10, 2024
eccd566
Merge pull request #345 from mkellerman/fix-autosens-logs
Sjoerd-Bo3 Oct 14, 2024
51f1e1b
Merge pull request #429 from dabear/dev+glucose-source-unit-change
Sjoerd-Bo3 Oct 18, 2024
c8e66a6
bump version to 0.2.2
Sjoerd-Bo3 Oct 18, 2024
e98a712
Merge pull request #435 from nightscout/release/0.2.2
Sjoerd-Bo3 Oct 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CGMBLEKit
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ representative at an online or offline event.
## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the Discord server admins. Please join our [Discord server](https://discord.gg/dbe5Twav8D) to contact
reported to the Discord server admins. Please join our [Discord server](http://discord.diy-trio.org) to contact
them directly for any enforcement issues. All complaints will be reviewed and
investigated promptly and fairly.

Expand Down
2 changes: 1 addition & 1 deletion Config.xcconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
APP_DISPLAY_NAME = Trio
APP_VERSION = 0.2.1
APP_VERSION = 0.2.2
APP_BUILD_NUMBER = 1
COPYRIGHT_NOTICE =
DEVELOPER_TEAM = ##TEAM_ID##
Expand Down
12 changes: 11 additions & 1 deletion FreeAPS/Sources/APS/FetchGlucoseManager.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Combine
import Foundation
import HealthKit
import LoopKit
import LoopKitUI
import SwiftDate
Expand Down Expand Up @@ -98,6 +99,14 @@ final class BaseFetchGlucoseManager: FetchGlucoseManager, Injectable {
settingsManager.settings.uploadGlucose = cgmM.shouldSyncToRemoteService
}

private func updateManagerUnits(_ manager: CGMManagerUI?) {
let units = settingsManager.settings.units
let managerName = cgmManager.map { "\(type(of: $0))" } ?? "nil"
let loopkitUnits: HKUnit = units == .mgdL ? .milligramsPerDeciliter : .millimolesPerLiter
print("manager: \(managerName) is changing units to: \(loopkitUnits.description) ")
manager?.unitDidChange(to: loopkitUnits)
}

func updateGlucoseSource(cgmGlucoseSourceType: CGMType, cgmGlucosePluginId: String, newManager: CGMManagerUI?) {
// if changed, remove all calibrations
if self.cgmGlucoseSourceType != cgmGlucoseSourceType || self.cgmGlucosePluginId != cgmGlucosePluginId {
Expand All @@ -120,6 +129,8 @@ final class BaseFetchGlucoseManager: FetchGlucoseManager, Injectable {
removeCalibrations()
} else if self.cgmGlucoseSourceType == .plugin, cgmManager == nil, let rawCGMManager = rawCGMManager {
cgmManager = cgmManagerFromRawValue(rawCGMManager)
updateManagerUnits(cgmManager)

} else {
saveConfigManager()
}
Expand Down Expand Up @@ -151,7 +162,6 @@ final class BaseFetchGlucoseManager: FetchGlucoseManager, Injectable {
else {
return nil
}

return Manager.init(rawState: rawState)
}

Expand Down
60 changes: 57 additions & 3 deletions FreeAPS/Sources/APS/OpenAPS/JavaScriptWorker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,32 @@ import JavaScriptCore

private let contextLock = NSRecursiveLock()

extension String {
var lowercasingFirst: String { prefix(1).lowercased() + dropFirst() }
var uppercasingFirst: String { prefix(1).uppercased() + dropFirst() }
var camelCased: String {
guard !isEmpty else { return "" }
let parts = components(separatedBy: .alphanumerics.inverted)
let first = parts.first!.lowercasingFirst
let rest = parts.dropFirst().map(\.uppercasingFirst)
return ([first] + rest).joined()
}

var pascalCased: String {
guard !isEmpty else { return "" }
let parts = components(separatedBy: .alphanumerics.inverted)
let first = parts.first!.uppercasingFirst
let rest = parts.dropFirst().map(\.uppercasingFirst)
return ([first] + rest).joined()
}
}

final class JavaScriptWorker {
private let processQueue = DispatchQueue(label: "DispatchQueue.JavaScriptWorker")
private let virtualMachine: JSVirtualMachine
@SyncAccess(lock: contextLock) private var commonContext: JSContext? = nil
private var consoleLogs: [String] = []
private var logContext: String = ""

init() {
virtualMachine = processQueue.sync { JSVirtualMachine()! }
Expand All @@ -20,18 +42,49 @@ final class JavaScriptWorker {
}
}
let consoleLog: @convention(block) (String) -> Void = { message in
debug(.openAPS, "JavaScript log: \(message)")
let trimmedMessage = message.trimmingCharacters(in: .whitespacesAndNewlines)
if !trimmedMessage.isEmpty {
self.consoleLogs.append("\(trimmedMessage)")
}
}

context.setObject(
consoleLog,
forKeyedSubscript: "_consoleLog" as NSString
)
return context
}

// New method to flush aggregated logs
private func outputLogs() {
var outputLogs = consoleLogs.joined(separator: "\n").trimmingCharacters(in: .whitespacesAndNewlines)
consoleLogs.removeAll()

if outputLogs.isEmpty { return }

if logContext == "autosens.js" {
outputLogs = outputLogs.split(separator: "\n").map { logLine in
logLine.replacingOccurrences(
of: "^[-+=x!]|u\\(|\\)|\\d{1,2}h$",
with: "",
options: .regularExpression
)
}.joined(separator: "\n")
}

if !outputLogs.isEmpty {
outputLogs.split(separator: "\n").forEach { logLine in
if !"\(logLine)".trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
debug(.openAPS, "\(logContext): \(logLine)")
}
}
}
}

@discardableResult func evaluate(script: Script) -> JSValue! {
evaluate(string: script.body)
logContext = URL(fileURLWithPath: script.name).lastPathComponent
let result = evaluate(string: script.body)
outputLogs()
return result
}

private func evaluate(string: String) -> JSValue! {
Expand All @@ -52,6 +105,7 @@ final class JavaScriptWorker {
commonContext = createContext()
defer {
commonContext = nil
outputLogs()
}
return execute(self)
}
Expand Down
4 changes: 2 additions & 2 deletions FreeAPS/Sources/APS/OpenAPS/OpenAPS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -635,11 +635,11 @@ final class OpenAPS {

private func middlewareScript(name: String) -> Script? {
if let body = storage.retrieveRaw(name) {
return Script(name: "Middleware", body: body)
return Script(name: name, body: body)
}

if let url = Foundation.Bundle.main.url(forResource: "javascript/\(name)", withExtension: "") {
return Script(name: "Middleware", body: try! String(contentsOf: url))
return Script(name: name, body: try! String(contentsOf: url))
}

return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extension DataTable {
formatter.minimumFractionDigits = 0
formatter.maximumFractionDigits = 1
}
formatter.roundingMode = .down
formatter.roundingMode = .halfUp
return formatter
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ protocol PreferencesEditorProvider: Provider {
var preferences: Preferences { get }
func savePreferences(_ preferences: Preferences)
func migrateUnits()
func updateManagerUnits()
}

protocol PreferencesSettable: AnyObject {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Foundation
import HealthKit

extension PreferencesEditor {
final class Provider: BaseProvider, PreferencesEditorProvider {
@Injected() private var settingsManager: SettingsManager!
@Injected() var fetchGlucoseManager: FetchGlucoseManager!
private let processQueue = DispatchQueue(label: "PreferencesEditorProvider.processQueue")

var preferences: Preferences {
Expand All @@ -17,6 +19,15 @@ extension PreferencesEditor {
}
}

func updateManagerUnits() {
var manager = fetchGlucoseManager.cgmManager
let managerName = manager.map { "\(type(of: $0))" } ?? "nil"
let units = settingsManager.settings.units
let loopkitUnits: HKUnit = units == .mgdL ? .milligramsPerDeciliter : .millimolesPerLiter
print("manager: \(managerName) is changing units to: \(loopkitUnits.description) ")
manager?.unitDidChange(to: loopkitUnits)
}

func migrateUnits() {
migrateTargets()
migrateISF()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extension PreferencesEditor {
subscribeSetting(\.units, on: $unitsIndex.map { $0 == 0 ? GlucoseUnits.mgdL : .mmolL }) {
unitsIndex = $0 == .mgdL ? 0 : 1
} didSet: { [weak self] _ in
self?.provider.updateManagerUnits()
self?.provider.migrateUnits()
}

Expand Down
2 changes: 1 addition & 1 deletion G7SensorKit
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Instructions in greater detail, but not Trio-specific:

# Documentation

[Discord Trio - Server ](https://discord.gg/KepAG6RdYZ)
[Discord Trio - Server ](http://discord.diy-trio.org)

[Trio documentation](https://docs.diy-trio.org/en/latest/)

Expand Down
2 changes: 1 addition & 1 deletion TidepoolService
Loading