@@ -25,54 +25,4 @@ extension DiagnosticLogger {
2525 func addError( _ message: Error , fromSource source: String ) {
2626 addError ( String ( describing: message) , fromSource: source)
2727 }
28-
29- func addLoopStatus( startDate: Date , endDate: Date , glucose: GlucoseValue , effects: [ String : [ GlucoseEffect ] ] , error: Error ? , prediction: [ GlucoseValue ] , predictionWithRetrospectiveEffect: Double , eventualBGWithRetrospectiveEffect: Double , eventualBGWithoutMomentum: Double , recommendedTempBasal: LoopDataManager . TempBasalRecommendation ? ) {
30-
31- let dateFormatter = DateFormatter . ISO8601StrictDateFormatter ( )
32- let unit = HKUnit . milligramsPerDeciliterUnit ( )
33-
34- var message : [ String : Any ] = [
35- " startDate " : dateFormatter. string ( from: startDate) ,
36- " duration " : endDate. timeIntervalSince ( startDate) ,
37- " glucose " : [
38- " startDate " : dateFormatter. string ( from: glucose. startDate) ,
39- " value " : glucose. quantity. doubleValue ( for: unit) ,
40- " unit " : unit. unitString
41- ] ,
42- " input " : effects. reduce ( [ : ] , { ( previous, item) -> [ String : Any ] in
43- var input = previous
44- input [ item. 0 ] = item. 1 . map {
45- [
46- " startDate " : dateFormatter. string ( from: $0. startDate) ,
47- " value " : $0. quantity. doubleValue ( for: unit) ,
48- " unit " : unit. unitString
49- ]
50- }
51- return input
52- } ) ,
53- " prediction " : prediction. map { ( value) -> [ String : Any ] in
54- [
55- " startDate " : dateFormatter. string ( from: value. startDate) ,
56- " value " : value. quantity. doubleValue ( for: unit) ,
57- " unit " : unit. unitString
58- ]
59- } ,
60- " prediction_retrospect_delta " : predictionWithRetrospectiveEffect,
61- " eventualBGWithRetrospectiveEffect " : eventualBGWithRetrospectiveEffect,
62- " eventualBGWithoutMomentum " : eventualBGWithoutMomentum
63- ]
64-
65- if let error = error {
66- message [ " error " ] = String ( describing: error)
67- }
68-
69- if let recommendedTempBasal = recommendedTempBasal {
70- message [ " recommendedTempBasal " ] = [
71- " rate " : recommendedTempBasal. rate,
72- " minutes " : recommendedTempBasal. duration. minutes
73- ]
74- }
75-
76- addMessage ( message, toCollection: " loop " )
77- }
7828}
0 commit comments