@@ -23,42 +23,76 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
23
23
func application( _ application: UIApplication , didFinishLaunchingWithOptions launchOptions: [ UIApplication . LaunchOptionsKey : Any ] ? ) -> Bool {
24
24
// Override point for customization after applicatio
25
25
// setup AWARECore
26
+
26
27
let core = AWARECore . shared ( )
27
28
core. requestPermissionForBackgroundSensing { ( status) in
28
29
core. requestPermissionForPushNotification ( completion: nil )
29
30
core. activate ( )
30
31
32
+ print ( cleanOldDataTypeDaily)
33
+ AWAREStudy . shared ( ) . setCleanOldDataType ( cleanOldDataTypeDaily)
34
+ AWAREStudy . shared ( ) . setDebug ( true )
35
+
36
+ AWAREStudy . shared ( ) . setStudyURL ( " https://yahoo-earable.an.r.appspot.com/index.php/webservice/index/1/hlkrKP13AB " )
37
+
38
+ print ( AWAREStudy . shared ( ) . getCleanOldDataType ( ) )
39
+
40
+ let study = AWAREStudy . shared ( )
31
41
// init sensors
32
- let accelerometer = Accelerometer ( )
33
- // let gyroscope = Gyroscope()
34
- // let battery = Battery()
35
- // let screen = Screen()
36
- // let call = Calls()
37
- // let ambientNoise = AmbientNoise()
38
- // let activity = IOSActivityRecognition()
39
- // let step = Pedometer()
40
- // let bluetooth = Bluetooth()
41
- // let cal = Calendar()
42
- // let healthKit = AWAREHealthKit()
43
- let weather = OpenWeather ( )
44
- self . sensorManager. add ( weather)
45
- weather. setSensorEventHandler { sensor, data in
46
- if let d = data {
47
- print ( d)
48
- }
49
- }
42
+ let accelerometer = Accelerometer ( awareStudy: study)
43
+ accelerometer. setSensingIntervalWithHz ( 100 )
44
+ accelerometer. setSavingIntervalWithSecond ( 5 )
45
+ ( accelerometer. storage as! SQLiteSeparatedStorage ) . fetchSizeAdjuster. setMaxFetchSize ( 2 ) ;
46
+ accelerometer. storage? . setDebug ( true )
47
+
48
+ let gyroscope = Gyroscope ( awareStudy: study)
49
+ gyroscope. setSensingIntervalWithHz ( 100 )
50
+ gyroscope. setSavingIntervalWithSecond ( 5 )
51
+ ( gyroscope. storage as! SQLiteSeparatedStorage ) . fetchSizeAdjuster. setMaxFetchSize ( 3 ) ;
52
+
53
+
54
+ let rotation = Rotation ( awareStudy: study)
55
+ rotation. setSensingIntervalWithHz ( 100 )
56
+ rotation. setSavingIntervalWithSecond ( 5 )
57
+ ( rotation. storage as! SQLiteSeparatedStorage ) . fetchSizeAdjuster. setMaxFetchSize ( 3 ) ;
58
+
59
+ let lAccelerometer = LinearAccelerometer ( awareStudy: study)
60
+ lAccelerometer. setSensingIntervalWithHz ( 100 )
61
+ lAccelerometer. setSavingIntervalWithSecond ( 5 )
62
+ ( lAccelerometer. storage as! SQLiteSeparatedStorage ) . fetchSizeAdjuster. setMaxFetchSize ( 3 ) ;
63
+
64
+ let mag = Magnetometer ( awareStudy: study)
65
+ mag. setSensingIntervalWithHz ( 100 )
66
+ mag. setSavingIntervalWithSecond ( 5 )
67
+ ( mag. storage as! SQLiteSeparatedStorage ) . fetchSizeAdjuster. setMaxFetchSize ( 3 ) ;
68
+
69
+ let headphone = HeadphoneMotion ( awareStudy: study)
70
+ headphone. setSensingIntervalWithHz ( 100 )
71
+ headphone. setSavingIntervalWithSecond ( 5 )
72
+ ( headphone. storage as! SQLiteSeparatedStorage ) . fetchSizeAdjuster. setMaxFetchSize ( 3 ) ;
73
+
74
+ // let battery = Battery()
75
+ // let screen = Screen()
76
+ // let call = Calls()
77
+ // let ambientNoise = AmbientNoise()
78
+ // let activity = IOSActivityRecognition()
79
+ // let step = Pedometer()
80
+ // let bluetooth = Bluetooth()
81
+ // let cal = Calendar()
82
+ // let healthKit = AWAREHealthKit()
50
83
51
84
// add the sensors into AWARESensorManager
52
- self . sensorManager. add ( accelerometer)
53
- // self.sensorManager.add([accelerometer, gyroscope, battery, screen, call, ambientNoise, activity, step, bluetooth, cal, healthKit])
85
+ self . sensorManager. add ( [ accelerometer, gyroscope, rotation, lAccelerometer, mag, headphone] )
86
+ // self.sensorManager.add(accelerometer)
87
+ // self.sensorManager.add([accelerometer, gyroscope, battery, screen, call, ambientNoise, activity, step, bluetooth, cal, healthKit])
54
88
self . sensorManager. startAllSensors ( )
55
-
89
+
56
90
// setup ESMs
57
91
// generate ESMItem
58
92
let pam = ESMItem ( asPAMESMWithTrigger: " pam " )
59
93
pam. setTitle ( " How do you feeling now? " )
60
94
pam. setInstructions ( " Please select an image. " )
61
-
95
+
62
96
// generate ESMSchedule
63
97
let esm = ESMSchedule ( )
64
98
esm. scheduleId = " schedule_1 "
@@ -68,11 +102,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
68
102
esm. expirationThreshold = 60
69
103
esm. addESM ( pam)
70
104
esm. notificationTitle = " Tap to answer the question. "
71
-
105
+
72
106
// add the ESMSchedules into ESMScheduleManager
73
107
let esmManager = ESMScheduleManager . shared ( )
74
108
esmManager. deleteAllSchedules ( withNotification: true )
75
109
esmManager. add ( esm, withNotification: true )
110
+
76
111
}
77
112
78
113
// monitoring battery consumption
0 commit comments