liuzhenxing1118 1 жил өмнө
parent
commit
f77689cefa

+ 17 - 36
ChineseMedicine/ChineseMedicineSDK/Controller/DetectionViewController.m

@@ -6,7 +6,6 @@
 //
 
 #import "DetectionViewController.h"
-#import "YAKDevicesViewController.h"
 #import "HWCircleView.h"
 
 
@@ -14,6 +13,7 @@
 @property(nonatomic, strong) NSMutableArray *mPPGDatasArray;
 @property(nonatomic, assign) NSInteger mSpoValue;
 @property(nonatomic, strong) IBOutlet HWCircleView* mCircleView;
+@property(nonatomic, assign) BOOL isSubmiting;
 @end
 
 @implementation DetectionViewController {
@@ -35,6 +35,7 @@
     mTimerCount = 0;
     mErrorCount = 0;
     _mSpoValue = -1;
+    self.isSubmiting = NO;
     mPPGDatasCountMax = PPG_DATA_COUNT_MAX;
     _mPPGDatasArray = [[NSMutableArray alloc] init];
     
@@ -66,65 +67,42 @@
 }
 
 - (void)initPPGDatasBlock {
-#ifdef FUNCTION_B3BLE
-    __weak __typeof(self) weak_self = self;
     //ppg数据返回
-    [[YAKDeviceManager sharedInstance] setW035PPGOrginalDataDetailBlock:^(NSArray * _Nonnull ppgDataDetail) {
+    __weak __typeof(self) weak_self = self;
+    [SKDeviceManager shared].mPPGOrginalDataDetailBlock = ^(NSArray * _Nonnull ppgDataDetail) {
         [weak_self.mPPGDatasArray addObjectsFromArray:ppgDataDetail];
         NSLog(@"PPGDatasArray size:%lu", (unsigned long)weak_self.mPPGDatasArray.count);
-    }];
-#endif
+    };
 }
 
 - (void)openPPG {
-#ifdef FUNCTION_B3BLE
-    YAKDeviceW307 *device = [YAKDeviceManager sharedInstance].currentDevice;
     //开启PPG数据上传
-    [device controlTheCollectionOfPPGOriginalDataOnOrOff:YES WithResponse:^(BOOL success) {
-        NSLog(@"openPPG:%d", success ? 1:0);
-    }];
-#endif
+    [SKDeviceManager controlTheCollectionOfPPGOriginalDataOnOrOff:YES];
 }
 
 - (void)closePPG {
-#ifdef FUNCTION_B3BLE
-    YAKDeviceW307 *device = [YAKDeviceManager sharedInstance].currentDevice;
     //关闭PPG数据上传
-    [device controlTheCollectionOfPPGOriginalDataOnOrOff:NO WithResponse:^(BOOL success) {
-        NSLog(@"closePPG:%d", success ? 1:0);
-    }];
-#endif
+    [SKDeviceManager controlTheCollectionOfPPGOriginalDataOnOrOff:NO];
 }
 
 - (void)receiveSpoDatasBlock:(void(^)(void))callback {
-#ifdef FUNCTION_B3BLE
     __weak __typeof(self) weak_self = self;
-    [[YAKDeviceManager sharedInstance] setW035BloodOxyDataBlock:^(NSInteger oxy) {
+    [SKDeviceManager shared].mBloodOxyDataBlock = ^(NSInteger oxy) {
         NSLog(@"sendSpoDatasBlock:%ld", (long)oxy);
         if (oxy > 0) {
             weak_self.mSpoValue = oxy;
         }
         callback();
-    }];
-    
-    YAKDeviceW307 *device = [YAKDeviceManager sharedInstance].currentDevice;
-    [device sendBloodOxyDataWithResponse:nil];
-#endif
+    };
+    [SKDeviceManager sendBloodOxyData];
 }
 
 - (void)testBloodOxygen {
-#ifdef FUNCTION_B3BLE
-    YAKDeviceW307 *device = [YAKDeviceManager sharedInstance].currentDevice;
-    [device testBloodOxygen:1 WithResponse:nil];
-#endif
+    [SKDeviceManager testBloodOxygen:YES];
 }
 
 - (BOOL)checkDeviceStatus {
-#ifdef FUNCTION_B3BLE
-    YAKDeviceW307 *device = [YAKDeviceManager sharedInstance].currentDevice;
-    return device != nil && [device isConnected];
-#endif
-    return NO;
+    return [SKDeviceManager isBleConnected];
 }
 
 - (void)initTimer {
@@ -263,6 +241,9 @@
 }
 
 - (void)postWatchDatas {
+    if (self.isSubmiting)
+        return;
+    self.isSubmiting = YES;
     if (_mPPGDatasArray.count <= 0) {
         NSLog(@"Error postWatchDatas size:%lu", (unsigned long)_mPPGDatasArray.count);
         [self makeToastBottom:SK_NSLOCALIZED_STRING(@"error_datas", nil)];
@@ -298,7 +279,9 @@
             [self makeToast:result[KEY_MESSAGE]];
             [weak_self showBack];
         }
+        weak_self.isSubmiting = NO;
     } onFailure:^(NSError *error) {
+        weak_self.isSubmiting = NO;
         [MBProgressHUD hideHUDForView:weak_self.view animated:YES];
         [weak_self showBack];
     }];
@@ -337,7 +320,5 @@
 }
 
 - (void)bleDeviceScan:(id)sender {
-    UIViewController* controller = [[YAKDevicesViewController alloc] init];
-    [self.navigationController pushViewController:controller animated:YES];
 }
 @end