From de10895d5e86225f158343cc8064c22efb14bd3e Mon Sep 17 00:00:00 2001 From: Yuuki Nishiyama Date: Fri, 22 Nov 2019 21:25:45 +0900 Subject: [PATCH] Fixed a minor issue regarding `-syncAllSensorsForcefully` --- .../Classes/Core/Sensor/AWARESensorManager.m | 10 ++++++++-- .../Classes/Core/Storage/SQLite/SQLiteStorage.m | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/AWAREFramework/Classes/Core/Sensor/AWARESensorManager.m b/AWAREFramework/Classes/Core/Sensor/AWARESensorManager.m index a8d99a8..0dbab27 100644 --- a/AWAREFramework/Classes/Core/Sensor/AWARESensorManager.m +++ b/AWAREFramework/Classes/Core/Sensor/AWARESensorManager.m @@ -497,13 +497,19 @@ - (void)syncAllSensorsForcefully{ [AWAREEventLogger.shared logEvent:@{@"class":@"AWARESensorManager",@"event":@"sync: syncAllSensorsForcefully"}]; if (awareStudy.isDebug) NSLog(@"[AWARESensorManager] Start SyncDB forcefully"); + + int delaySec = 0; for (AWARESensor * sensor in awareSensors ) { - if (awareStudy.isDebug) NSLog(@"%@",sensor.getSensorName); + // if (awareStudy.isDebug) NSLog(@"%@",sensor.getSensorName); NSString * name = sensor.getSensorName; if (name != nil){ [AWAREEventLogger.shared logEvent:@{@"class":@"AWARESensorManager", @"event":@"sync", @"sensor":name}]; } - [sensor startSyncDB]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delaySec * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [sensor startSyncDB]; + if (self->awareStudy.isDebug) { NSLog(@"[AWARESensorManager|%@] sync + %d", name, delaySec); } + }); + delaySec = delaySec + 1; } } diff --git a/AWAREFramework/Classes/Core/Storage/SQLite/SQLiteStorage.m b/AWAREFramework/Classes/Core/Storage/SQLite/SQLiteStorage.m index 3ffd71c..1a98f6f 100644 --- a/AWAREFramework/Classes/Core/Storage/SQLite/SQLiteStorage.m +++ b/AWAREFramework/Classes/Core/Storage/SQLite/SQLiteStorage.m @@ -193,7 +193,7 @@ - (void)startSyncStorageWithCallBack:(SyncProcessCallBack)callback{ - (void)startSyncStorage { - if(self->isUploading){ + if(isUploading){ NSString * message= [NSString stringWithFormat:@"[%@] Now sendsor data is uploading.", self.sensorName]; NSLog(@"%@", message); return; @@ -201,7 +201,7 @@ - (void)startSyncStorage { [self setRepetationCountAfterStartToSyncDB:[self getTimeMark]]; if (self.isDebug) NSLog(@"[SQLiteStorage:%@] start sync process ", self.sensorName); - self-> isUploading = YES; + isUploading = YES; }