| | |
| | | #import <BaiduMapAPI_Location/BMKLocationComponent.h> |
| | | #import<BaiduMapAPI_Search/BMKPoiSearchType.h> |
| | | #import "DataModel.h" |
| | | #import "UIImage+animatedGIF.h" |
| | | #import "UploadData.h" |
| | | #import "AdNoticeView.h" |
| | | #import "NoticeModel.h" |
| | | #import "MusicModel.h" |
| | | #import "CSAudioManager.h" |
| | | |
| | | @interface RadiaDetectionPage ()<ASValueTrackingSliderDelegate,ASValueTrackingSliderDataSource,cbCharacteristicManagerDelegate,BMKMapViewDelegate,BMKLocationServiceDelegate> |
| | | { |
| | |
| | | CLLocationDegrees longitude; |
| | | |
| | | NSMutableArray * dataModelArr; |
| | | NSTimer * myTimer; |
| | | NSTimer * myTimer; // 上传数据定时器 |
| | | NSString * myTimeInterval; |
| | | NSString * is_open_upload; // 1 可以 0 禁止 |
| | | |
| | | NSTimer * myScanTimer; // 蓝牙重连定时器 |
| | | |
| | | GloriaLabel* _AnquanStatustLabel; |
| | | UIImageView * icon_anquan; |
| | | UIImageView * ic_zhishu_bk; |
| | | UIImageView * ic_weixin_tips; |
| | | UIImageView * ic_dianyuan; |
| | | BOOL bOpenConnectBLE; |
| | | MusicModel * model1; |
| | | MusicModel * model2; |
| | | MusicModel * model3; |
| | | } |
| | | |
| | | @property (nonatomic, strong) AdNoticeView * adNoticeView; // 广告控件 |
| | | @property (nonatomic,strong) CSAudioManager *csManager; |
| | | @property (nonatomic,strong) NSData *mp3Data; |
| | | @property (nonatomic, strong) NSMutableArray *modelArray; |
| | | @end |
| | | |
| | | |
| | |
| | | |
| | | deviceStstaus = 2; |
| | | deviceStatusLabel.text = @"检测中"; |
| | | if (myTimer == nil) |
| | | myTimer = [NSTimer scheduledTimerWithTimeInterval:[myTimeInterval doubleValue] target:self selector:@selector(data_upload) userInfo:nil repeats:YES]; |
| | | else |
| | | //开启定时器 |
| | | [myTimer setFireDate:[NSDate distantPast]]; |
| | | if ([is_open_upload intValue] == 1) |
| | | { |
| | | if (myTimer == nil) |
| | | myTimer = [NSTimer scheduledTimerWithTimeInterval:[myTimeInterval doubleValue] target:self selector:@selector(data_upload) userInfo:nil repeats:YES]; |
| | | else |
| | | //开启定时器 |
| | | [myTimer setFireDate:[NSDate distantPast]]; |
| | | } |
| | | //每myTimeInterval秒运行一次data_upload方法。 |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | -(void)peripheral:(CBPeripheral *)peripheral didUpdateValueForDescriptor:(CBDescriptor *)descriptor error:(NSError *)error |
| | | { |
| | | if (error) |
| | | { |
| | | [Utilities logDataWithService:[ResourceHandler getServiceNameForUUID:descriptor.characteristic.service.UUID] characteristic:[ResourceHandler getCharacteristicNameForUUID:descriptor.characteristic.UUID] descriptor:[Utilities getDiscriptorNameForUUID:descriptor.UUID] operation:[NSString stringWithFormat:@"%@- %@%@",READ_RESPONSE,READ_ERROR,[error.userInfo objectForKey:NSLocalizedDescriptionKey]]]; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /*! |
| | | *@Method Notify Read Indicate options result return |
| | | * 蓝牙消息监听回调 |
| | |
| | | |
| | | if( receiveHexValue.length == 40 ) |
| | | { |
| | | //16进制转10进制 |
| | | NSString * shishiStr = [receiveHexValue substringWithRange:NSMakeRange(24,4)]; |
| | | NSString * leijiStr = [receiveHexValue substringWithRange:NSMakeRange(28,8)]; |
| | | |
| | | NSString * shishiValue = [NSString stringWithFormat:@"%lu",strtoul([shishiStr UTF8String],0,16)]; |
| | | NSString * leijiValue = [NSString stringWithFormat:@"%lu",strtoul([leijiStr UTF8String],0,16)]; |
| | | |
| | | if( leijiValue.length >= 6) |
| | | { |
| | | _JiliangNumLabel.text = [NSString stringWithFormat:@"%.1f",[leijiValue floatValue]*0.10]; |
| | | } |
| | | else |
| | | _JiliangNumLabel.text = [NSString stringWithFormat:@"%.3f",[leijiValue floatValue]*0.10]; |
| | | |
| | | _BiaozhunJiliangNumLabel.text = [NSString stringWithFormat:@"%.3f",([shishiValue floatValue]-45)/10.0*0.10]; |
| | | |
| | | |
| | | //dataModelArr |
| | | DataModel * model = [[DataModel alloc]init]; |
| | | model.value = _BiaozhunJiliangNumLabel.text; |
| | | model.time = [DateUtil stringFromDateYMD:[NSDate date]]; |
| | | [dataModelArr addObject:model]; |
| | | |
| | | circle3.progress = ([leijiValue floatValue]/FUSHE_MAX_VALUE)*100; |
| | | [_trackingSlider setValue:circle3.progress]; |
| | | [self setGaugeValue:circle3.progress animation:NO]; |
| | | |
| | | // 获取包头信息 |
| | | NSString * baoTouStr = [receiveHexValue substringWithRange:NSMakeRange(0,2)]; |
| | | if( [baoTouStr isEqualToString: @"5A"]) |
| | | { |
| | | //获取充电状态 0 没有充电 1 在充电 2充满 |
| | | NSString * chargeStatusStr = [receiveHexValue substringWithRange:NSMakeRange(6,2)]; |
| | | //获取电量 4为4格电 3为3格电 2为2格电 1为1格电 0为馈电状态 |
| | | NSString * dianLiangStr = [receiveHexValue substringWithRange:NSMakeRange(12,2)]; |
| | | // 16进制转10进制 |
| | | NSString * chargeStatusValue = [NSString stringWithFormat:@"%lu",strtoul([chargeStatusStr UTF8String],0,16)]; |
| | | NSString * dianLiangValue = [NSString stringWithFormat:@"%lu",strtoul([dianLiangStr UTF8String],0,16)]; |
| | | |
| | | // 设置电量标志 |
| | | [ic_dianyuan setHidden:NO]; |
| | | switch ([chargeStatusValue intValue]) { |
| | | case 0: |
| | | { |
| | | NSString * imageName = [NSString stringWithFormat:@"icon_b0%d",[dianLiangValue intValue] ]; |
| | | ic_dianyuan.image = [UIImage imageNamed:imageName]; |
| | | } |
| | | break; |
| | | case 1: |
| | | [ic_dianyuan setImage:[UIImage animatedImageWithAnimatedGIFURL:[[NSBundle mainBundle] URLForResource:@"icon_chong" withExtension:@"gif"]]]; |
| | | break; |
| | | case 2: |
| | | ic_dianyuan.image = [UIImage imageNamed:@"icon_full"]; |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | //16进制转10进制 |
| | | NSString * shishiStr = [receiveHexValue substringWithRange:NSMakeRange(24,4)]; |
| | | NSString * leijiStr = [receiveHexValue substringWithRange:NSMakeRange(28,8)]; |
| | | |
| | | |
| | | NSString * shishiValue = [NSString stringWithFormat:@"%lu",strtoul([shishiStr UTF8String],0,16)]; |
| | | NSString * leijiValue = [NSString stringWithFormat:@"%lu",strtoul([leijiStr UTF8String],0,16)]; |
| | | |
| | | if( leijiValue.length >= 6) |
| | | { |
| | | _JiliangNumLabel.text = [NSString stringWithFormat:@"%.1f",[leijiValue floatValue]*0.001]; |
| | | } |
| | | else |
| | | _JiliangNumLabel.text = [NSString stringWithFormat:@"%.3f",[leijiValue floatValue]*0.001]; |
| | | |
| | | _BiaozhunJiliangNumLabel.text = [NSString stringWithFormat:@"%.3f",[shishiValue floatValue]*0.001]; |
| | | |
| | | |
| | | //dataModelArr |
| | | DataModel * model = [[DataModel alloc]init]; |
| | | model.value = _BiaozhunJiliangNumLabel.text; |
| | | model.time = [DateUtil stringFromDateYMDHMS:[NSDate date]]; |
| | | model.type = @"0"; |
| | | model.is_warn = @"0"; |
| | | |
| | | if([model.value floatValue] < 0.16) |
| | | { |
| | | [self.csManager stopAllMusic]; |
| | | // 100 |
| | | circle3.progress = [model.value floatValue]*100; |
| | | _currentShuziTipsLabel.text = @"当前位置安全"; |
| | | _currentTipsLabel.textColor = RgbColor(64, 159, 252); |
| | | _currentTipsLabel.text = @"您所处位置辐射安全,\n 您处于安全区域,可以长时间逗留!"; |
| | | |
| | | // _AnquanStatustLabel.text = @"安全"; |
| | | // _AnquanStatustLabel.textColor = kUIColorFromRGB(0x07cb5a); |
| | | // icon_anquan.image = [UIImage imageNamed:@"icon_anquan"]; |
| | | // ic_anquan_status.image = [UIImage imageNamed:@"ic_anquan_bk"]; |
| | | // ic_weixin_tips.image = [UIImage imageNamed:@"ic_anquan_tips"]; |
| | | // ic_zhishu_bk.image = [UIImage imageNamed:@"bt_green"]; |
| | | // _currentTipsLabel.textColor = kUIColorFromRGB(0x848787); |
| | | |
| | | if( [shishiValue intValue] < FUSHE_SAFE_VALUE ) |
| | | { |
| | | _currentShuziTipsLabel.text = @"当前位置安全"; |
| | | _currentTipsLabel.textColor = RgbColor(64, 159, 252); |
| | | _currentTipsLabel.text = @"您所处位置辐射安全,\n 您处于安全区域,可以长时间逗留!"; |
| | | } |
| | | else if([model.value floatValue] >= 0.16 && [model.value floatValue] < 0.8) |
| | | { |
| | | [self.csManager stopAllMusic]; |
| | | // 100 |
| | | float tempValue = [model.value floatValue]; |
| | | if(tempValue > 0.50) |
| | | tempValue = 0.50; |
| | | |
| | | circle3.progress = tempValue*100; |
| | | _currentShuziTipsLabel.text = @"当前位置有轻微辐射"; |
| | | _currentTipsLabel.textColor = RgbColor(64, 159, 252); |
| | | _currentTipsLabel.text = @"您所处位置辐射轻微,\n 不利于您的健康,请远离到安全区域!"; |
| | | model.is_warn = @"1"; |
| | | |
| | | _AnquanStatustLabel.text = @"轻微"; |
| | | _AnquanStatustLabel.textColor = kUIColorFromRGB(0x0d95fe); |
| | | icon_anquan.image = [UIImage imageNamed:@"icon_head_qingwei"]; |
| | | ic_anquan_status.image = [UIImage imageNamed:@"bg_corner_blue"]; |
| | | ic_weixin_tips.image = [UIImage imageNamed:@"icon_qingwei"]; |
| | | ic_zhishu_bk.image = [UIImage imageNamed:@"ic_zhishu_bk"]; |
| | | _currentTipsLabel.textColor = kUIColorFromRGB(0x848787); |
| | | |
| | | MusicModel * model = [self.modelArray objectAtIndex:0]; |
| | | |
| | | if( model.musicStatus == 0 ) |
| | | { |
| | | [self.csManager playingMusicWithURL:[NSURL URLWithString:model.musicUrl] playID:model.user_id]; |
| | | } |
| | | else |
| | | { |
| | | self.mp3Data = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:model.musicUrl]]; |
| | | //播放音频 |
| | | [self.csManager playingMusicWithData:self.mp3Data playID:model.user_id]; |
| | | } |
| | | } |
| | | else if([model.value floatValue] >= 0.8 && [model.value floatValue] < 2) |
| | | { |
| | | [self.csManager stopAllMusic]; |
| | | |
| | | // 264 |
| | | float tempValue = ([model.value floatValue]*100)/266; |
| | | if(tempValue <= 0.50) |
| | | tempValue = 0.51; |
| | | |
| | | circle3.progress = tempValue*100; |
| | | _currentShuziTipsLabel.text = @"当前位置有较高辐射"; |
| | | _currentTipsLabel.textColor = RgbColor(252, 80, 84); |
| | | _currentTipsLabel.text = @"您所处位置辐射偏高,\n 不利于您的健康,请远离到安全区域!"; |
| | | model.is_warn = @"1"; |
| | | |
| | | _AnquanStatustLabel.text = @"中度"; |
| | | _AnquanStatustLabel.textColor = kUIColorFromRGB(0xc240ff); |
| | | icon_anquan.image = [UIImage imageNamed:@"icon_head_zhongfu"]; |
| | | ic_anquan_status.image = [UIImage imageNamed:@"bg_corner_zise"]; |
| | | ic_weixin_tips.image = [UIImage imageNamed:@"icon_zhongdu"]; |
| | | ic_zhishu_bk.image = [UIImage imageNamed:@"bt_zise"]; |
| | | _currentTipsLabel.textColor = kUIColorFromRGB(0x848787); |
| | | |
| | | MusicModel * model = [self.modelArray objectAtIndex:1]; |
| | | |
| | | if( model.musicStatus == 0 ) |
| | | { |
| | | [self.csManager playingMusicWithURL:[NSURL URLWithString:model.musicUrl] playID:model.user_id]; |
| | | } |
| | | else |
| | | { |
| | | self.mp3Data = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:model.musicUrl]]; |
| | | //播放音频 |
| | | [self.csManager playingMusicWithData:self.mp3Data playID:model.user_id]; |
| | | } |
| | | } |
| | | else if([model.value floatValue] >2) |
| | | { |
| | | [self.csManager stopAllMusic]; |
| | | // 400 |
| | | float tempValue = ([model.value floatValue]*100)/400; |
| | | if(tempValue <= 0.75) |
| | | tempValue = 0.76; |
| | | |
| | | circle3.progress = tempValue*100; |
| | | |
| | | _currentShuziTipsLabel.text = @"当前位置有很严重辐射"; |
| | | _currentTipsLabel.textColor = RgbColor(252, 80, 84); |
| | | _currentTipsLabel.text = @"您所处位置辐射辐射,\n 不利于您的健康,请远离到安全区域!"; |
| | | model.is_warn = @"1"; |
| | | |
| | | _AnquanStatustLabel.text = @"危险"; |
| | | _AnquanStatustLabel.textColor = kUIColorFromRGB(0xff4e63); |
| | | icon_anquan.image = [UIImage imageNamed:@"icon_weixian"]; |
| | | ic_anquan_status.image = [UIImage imageNamed:@"ic_weixian_bk"]; |
| | | ic_weixin_tips.image = [UIImage imageNamed:@"icon_yanzhong"]; |
| | | ic_zhishu_bk.image = [UIImage imageNamed:@"ic_yanzhong_tips"]; |
| | | _currentTipsLabel.textColor = kUIColorFromRGB(0x848787); |
| | | |
| | | MusicModel * model = [self.modelArray objectAtIndex:2]; |
| | | |
| | | if( model.musicStatus == 0 ) |
| | | { |
| | | [self.csManager playingMusicWithURL:[NSURL URLWithString:model.musicUrl] playID:model.user_id]; |
| | | } |
| | | else |
| | | { |
| | | self.mp3Data = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:model.musicUrl]]; |
| | | //播放音频 |
| | | [self.csManager playingMusicWithData:self.mp3Data playID:model.user_id]; |
| | | } |
| | | } |
| | | |
| | | [_trackingSlider setValue:circle3.progress]; |
| | | [self setGaugeValue:circle3.progress animation:NO]; |
| | | |
| | | [dataModelArr addObject:model]; |
| | | } |
| | | else if ( [shishiValue intValue] < FUSHE_GOOD_VALUE) |
| | | } |
| | | else if(receiveHexValue.length == 8 ) |
| | | { |
| | | // 获取包头信息 |
| | | NSString * baoTouStr = [receiveHexValue substringWithRange:NSMakeRange(0,2)]; |
| | | if( [baoTouStr isEqualToString: @"7A"]) |
| | | { |
| | | _currentShuziTipsLabel.text = @"当前位置有轻微辐射"; |
| | | _currentTipsLabel.textColor = RgbColor(64, 159, 252); |
| | | _currentTipsLabel.text = @"您所处位置辐射轻微,\n 不利于您的健康,请远离到安全区域!"; |
| | | NSString * timeValueStr = [receiveHexValue substringWithRange:NSMakeRange(2,8)]; |
| | | //dataModelArr |
| | | DataModel * model = [[DataModel alloc]init]; |
| | | model.value = timeValueStr; |
| | | model.time = [DateUtil stringFromDateYMDHMS:[NSDate date]]; |
| | | model.type = @"1"; |
| | | model.is_warn = @"0"; |
| | | |
| | | [dataModelArr addObject:model]; |
| | | } |
| | | else if ( [shishiValue intValue] < FUSHE_CHA_VALUE) |
| | | { |
| | | _currentShuziTipsLabel.text = @"当前位置辐射超标"; |
| | | _currentTipsLabel.textColor = RgbColor(252, 80, 84); |
| | | _currentTipsLabel.text = @"您所处位置辐射超标,\n 不利于您的健康,请远离到安全区域!"; |
| | | } |
| | | else if ( [shishiValue intValue] < FUSHE_DANGER_VALUE) |
| | | { |
| | | _currentShuziTipsLabel.text = @"当前位置有较高辐射"; |
| | | _currentTipsLabel.textColor = RgbColor(252, 80, 84); |
| | | _currentTipsLabel.text = @"您所处位置辐射偏高,\n 不利于您的健康,请远离到安全区域!"; |
| | | } |
| | | else if ( [shishiValue intValue] < FUSHE_MAX_VALUE) |
| | | { |
| | | _currentShuziTipsLabel.text = @"当前位置有很高辐射"; |
| | | _currentTipsLabel.textColor = RgbColor(252, 80, 84); |
| | | _currentTipsLabel.text = @"您所处位置辐射偏高,\n 不利于您的健康,请远离到安全区域!"; |
| | | } |
| | | else |
| | | { |
| | | _currentShuziTipsLabel.text = @"当前位置有很高辐射"; |
| | | _currentTipsLabel.textColor = RgbColor(252, 80, 84); |
| | | _currentTipsLabel.text = @"您所处位置辐射很高,\n 不利于您的健康,请远离到安全区域!"; |
| | | } |
| | | |
| | | } |
| | | else if(receiveHexValue.length == 16 ) |
| | | { |
| | | // 获取包头信息 |
| | | NSString * baoTouStr = [receiveHexValue substringWithRange:NSMakeRange(0,2)]; |
| | | if( [baoTouStr isEqualToString: @"3A"]) |
| | | { |
| | | NSString * yearValueStr = [receiveHexValue substringWithRange:NSMakeRange(2,2)]; |
| | | NSString * mounthValueStr = [receiveHexValue substringWithRange:NSMakeRange(4,2)]; |
| | | NSString * dayValueStr = [receiveHexValue substringWithRange:NSMakeRange(6,2)]; |
| | | NSString * hourValueStr = [receiveHexValue substringWithRange:NSMakeRange(8,2)]; |
| | | NSString * dataValueStr = [receiveHexValue substringWithRange:NSMakeRange(10,4)]; |
| | | |
| | | NSString * yearValue = [NSString stringWithFormat:@"%lu",strtoul([yearValueStr UTF8String],0,16)]; |
| | | NSString * mounthValue = [NSString stringWithFormat:@"%lu",strtoul([mounthValueStr UTF8String],0,16)]; |
| | | NSString * dayValue = [NSString stringWithFormat:@"%lu",strtoul([dayValueStr UTF8String],0,16)]; |
| | | NSString * hourValue = [NSString stringWithFormat:@"%lu",strtoul([hourValueStr UTF8String],0,16)]; |
| | | |
| | | NSString * timeFormatValue = [NSString stringWithFormat:@"20%@-%02d-%02d %02d:00",yearValue,[mounthValue intValue],[dayValue intValue],[hourValue intValue]]; |
| | | |
| | | NSString * dataValue = [NSString stringWithFormat:@"%lu",strtoul([dataValueStr UTF8String],0,16)]; |
| | | |
| | | //dataModelArr |
| | | DataModel * model = [[DataModel alloc]init]; |
| | | model.value = [NSString stringWithFormat:@"%.1f",[dataValue floatValue]*0.01];; |
| | | model.time = timeFormatValue; |
| | | model.type = @"1"; |
| | | model.is_warn = @"0"; |
| | | |
| | | [dataModelArr addObject:model]; |
| | | |
| | | [self data_upload]; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //NSString * shishiStr = [receiveHexValue substringWithRange:NSMakeRange(0,4)]; |
| | | } |
| | | |
| | | //NSString *ASCIIValue = [[NSString alloc]initWithData:characteristic.value encoding:NSASCIIStringEncoding]; |
| | |
| | | } |
| | | } |
| | | |
| | | -(void)GetNoticeInfo |
| | | { |
| | | //[UserDefault stringForKey:@"user_id"] |
| | | NSString *path = [[NSString alloc] initWithFormat:GET_NOTICE]; |
| | | |
| | | NSMutableDictionary * params = [[NSMutableDictionary alloc] init]; |
| | | |
| | | MPWeakSelf(self); |
| | | [NetworkSingleton networkingGetMethod:params urlName:path success:^(id responseBody) |
| | | { |
| | | MPStrongSelf(self); |
| | | BaseResModel * resModel = [Global toBaseModel:responseBody]; |
| | | |
| | | if(resModel.code == 0) |
| | | { |
| | | //[UserDefault setObject:self.is_open_upload forKey:@"is_open_upload"]; |
| | | [UserDefault synchronize]; |
| | | |
| | | |
| | | NoticeModel * model = [NoticeModel mj_objectWithKeyValues:resModel.content]; |
| | | |
| | | if (self.adNoticeView == nil) |
| | | { |
| | | self.adNoticeView = [[AdNoticeView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) dataModel:model]; |
| | | //self.adNoticeView.delegate = self; |
| | | [self.view addSubview:self.adNoticeView]; |
| | | } |
| | | else |
| | | { |
| | | [self.adNoticeView setUIView:model]; |
| | | } |
| | | |
| | | [UserDefault setObject:[DateUtil stringFromDateYMD:[NSDate date]] forKey:@"NoticeTime"]; |
| | | } |
| | | else |
| | | { |
| | | //[Global alertMessageEx:resModel.desc title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self]; |
| | | } |
| | | } |
| | | failure:^(NSString *error) |
| | | { |
| | | |
| | | [Global alertMessageEx:error title:@"获取失败" okTtitle:nil cancelTitle:@"OK" delegate:self]; |
| | | }]; |
| | | } |
| | | |
| | | /*! |
| | | * @method UUIDArray: |
| | | * |
| | |
| | | //关闭定时器 |
| | | if(myTimer) |
| | | [myTimer setFireDate:[NSDate distantFuture]]; |
| | | |
| | | //关闭定时器 |
| | | if(myScanTimer) |
| | | [myScanTimer setFireDate:[NSDate distantFuture]]; |
| | | } |
| | | |
| | | -(void)viewWillAppear:(BOOL)animated |
| | | { |
| | | |
| | | bleCurrentUUID = [UserDefault objectForKey:@"bleUUID"]; |
| | | NSString *bleName = [UserDefault objectForKey:@"bleName"]; |
| | | //NSString *bleName = [UserDefault objectForKey:@"bleName"]; |
| | | |
| | | //_mapView.delegate = self; // 此处记得不用的时候需要置nil,否则影响内存的释放 |
| | | _locService.delegate = self; |
| | |
| | | { |
| | | deviceStstaus = 1; |
| | | deviceStatusLabel.text = @"已连接"; |
| | | |
| | | //关闭定时器 连接成功 |
| | | if(myScanTimer) |
| | | [myScanTimer setFireDate:[NSDate distantFuture]]; |
| | | |
| | | [self onLineSet]; |
| | | |
| | | // 连接成功设置服务 |
| | | NSArray *allService = [self UUIDArray:[[[CBMoralManager sharedManager] serviceUUIDDict] allKeys]]; |
| | |
| | | //[[CBMoralManager sharedManager] disconnectPeripheral:[[CBMoralManager sharedManager] myPeripheral]]; |
| | | [[CBMoralManager sharedManager] setCbDiscoveryDelegate:self]; |
| | | [[CBMoralManager sharedManager] startScanning]; |
| | | [self performSelector:@selector(stopScanning) withObject:nil afterDelay:3.0f]; |
| | | [self performSelector:@selector(stopScanning2) withObject:nil afterDelay:3.0f]; |
| | | } |
| | | |
| | | } |
| | | |
| | | [self setMusicConfig]; |
| | | } |
| | | |
| | | -(void)setMusicConfig |
| | | { |
| | | // 0 默认 1 自定义 |
| | | NSInteger musicStatus1 = [UserDefault integerForKey:@"musicStatus1"]; |
| | | NSInteger musicStatus2 = [UserDefault integerForKey:@"musicStatus2"]; |
| | | NSInteger musicStatus3 = [UserDefault integerForKey:@"musicStatus3"]; |
| | | |
| | | if( musicStatus1 == 0 ) |
| | | { |
| | | if(model1 == nil) |
| | | { |
| | | model1 = [[MusicModel alloc] init]; |
| | | } |
| | | |
| | | model1.username = [NSString stringWithFormat:@"%@",@"轻微铃声"]; |
| | | model1.user_id = [NSString stringWithFormat:@"%@",@"ID0001"]; |
| | | model1.musicName = [NSString stringWithFormat:@"%@",@"默认"]; |
| | | model1.musicStatus = 0; |
| | | model1.musicUrl = [NSString stringWithFormat:@"%@",@"http://yfsapi.7drlb.com/video/music.mp3"]; |
| | | [self.modelArray addObject:model1]; |
| | | } |
| | | else |
| | | { |
| | | if(model1 == nil) |
| | | { |
| | | model1 = [[MusicModel alloc] init]; |
| | | } |
| | | |
| | | model1.username = [NSString stringWithFormat:@"%@",@"轻微铃声"]; |
| | | model1.user_id = [NSString stringWithFormat:@"%@",@"ID0001"]; |
| | | model1.musicName = [UserDefault stringForKey:@"ID0001Name"]; |
| | | model1.musicStatus = 1; |
| | | model1.musicUrl = [UserDefault stringForKey:@"ID0001PATH"]; |
| | | [self.modelArray addObject:model1]; |
| | | } |
| | | |
| | | |
| | | if( musicStatus2 == 0 ) |
| | | { |
| | | if(model2 == nil) |
| | | { |
| | | model2 = [[MusicModel alloc] init]; |
| | | } |
| | | |
| | | model2.username = [NSString stringWithFormat:@"%@",@"中度铃声"]; |
| | | model2.user_id = [NSString stringWithFormat:@"%@",@"ID0002"]; |
| | | model2.musicName = [NSString stringWithFormat:@"%@",@"默认"]; |
| | | model2.musicStatus = 0; |
| | | model2.musicUrl = [NSString stringWithFormat:@"%@",@"http://yfsapi.7drlb.com/video/music1.mp3"]; |
| | | [self.modelArray addObject:model2]; |
| | | } |
| | | else |
| | | { |
| | | if(model2 == nil) |
| | | { |
| | | model2 = [[MusicModel alloc] init]; |
| | | } |
| | | |
| | | model2.username = [NSString stringWithFormat:@"%@",@"中度铃声"]; |
| | | model2.user_id = [NSString stringWithFormat:@"%@",@"ID0002"]; |
| | | model2.musicName = [UserDefault stringForKey:@"ID0002Name"]; |
| | | model2.musicStatus = 1; |
| | | model2.musicUrl = [UserDefault stringForKey:@"ID0002PATH"]; |
| | | [self.modelArray addObject:model2]; |
| | | } |
| | | |
| | | if( musicStatus3 == 0 ) |
| | | { |
| | | if(model3 == nil) |
| | | { |
| | | model3 = [[MusicModel alloc] init]; |
| | | } |
| | | |
| | | model3.username = [NSString stringWithFormat:@"%@",@"严重铃声"]; |
| | | model3.user_id = [NSString stringWithFormat:@"%@",@"ID0003"]; |
| | | model3.musicName = [NSString stringWithFormat:@"%@",@"默认"]; |
| | | model3.musicStatus = 0; |
| | | model3.musicUrl = [NSString stringWithFormat:@"%@",@"http://yfsapi.7drlb.com/video/music2.mp3"]; |
| | | [self.modelArray addObject:model3]; |
| | | } |
| | | else |
| | | { |
| | | if(model3 == nil) |
| | | { |
| | | model3 = [[MusicModel alloc] init]; |
| | | } |
| | | |
| | | model3.username = [NSString stringWithFormat:@"%@",@"严重铃声"]; |
| | | model3.user_id = [NSString stringWithFormat:@"%@",@"ID0003"]; |
| | | model3.musicName = [UserDefault stringForKey:@"ID0003Name"]; |
| | | model3.musicStatus = 1; |
| | | model3.musicUrl = [UserDefault stringForKey:@"ID0003PATH"]; |
| | | [self.modelArray addObject:model3]; |
| | | } |
| | | } |
| | | |
| | | -(void)stopScanning2 |
| | | { |
| | | [[CBMoralManager sharedManager]stopScanning]; |
| | | |
| | | // 判断是否开启重连定时 |
| | | if(_bConnectSuccess == NO) |
| | | { |
| | | if(bOpenConnectBLE == NO) |
| | | { |
| | | bOpenConnectBLE = YES; |
| | | |
| | | if (myScanTimer == nil) |
| | | myScanTimer = [NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:@selector(continueScanning) userInfo:nil repeats:YES]; |
| | | else |
| | | //开启定时器 |
| | | [myScanTimer setFireDate:[NSDate distantPast]]; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | -(void)stopScanning |
| | | { |
| | | [[CBMoralManager sharedManager]stopScanning]; |
| | | } |
| | | |
| | | -(void)continueScanning |
| | | { |
| | | [[CBMoralManager sharedManager] startScanning]; |
| | | [self performSelector:@selector(stopScanning) withObject:nil afterDelay:3.0f]; |
| | | } |
| | | |
| | | #pragma mark - BlueTooth Turned Off Delegate |
| | |
| | | isBluetoothON = state; |
| | | |
| | | // 提示打开蓝牙设备 |
| | | |
| | | if(isBluetoothON == NO) |
| | | { |
| | | [Global alertMessageEx:@"蓝牙功能未开启,请开启蓝牙功能!" title:@"温馨提示" okTtitle:nil cancelTitle:@"OK" delegate:self]; |
| | | // 判断是否开启重连定时 |
| | | if(_bConnectSuccess == YES) |
| | | { |
| | | //关闭上传数据定时器 |
| | | if(myTimer) |
| | | [myTimer setFireDate:[NSDate distantFuture]]; |
| | | |
| | | [self offLineSet]; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | // 判断是否开启重连定时 |
| | | if(_bConnectSuccess == NO) |
| | | { |
| | | if(bOpenConnectBLE == NO) |
| | | { |
| | | bOpenConnectBLE = YES; |
| | | |
| | | if (myScanTimer == nil) |
| | | myScanTimer = [NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:@selector(continueScanning) userInfo:nil repeats:YES]; |
| | | else |
| | | //开启定时器 |
| | | [myScanTimer setFireDate:[NSDate distantPast]]; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | *This method invoke after a new peripheral found. |
| | | *This method invoke after a new peripheral found. 蓝牙检索成功 开始连接 |
| | | */ |
| | | -(void)discoveryDidRefresh |
| | | { |
| | |
| | | { |
| | | if(success) |
| | | { |
| | | //关闭定时器 连接成功 |
| | | if(myScanTimer) |
| | | [myScanTimer setFireDate:[NSDate distantFuture]]; |
| | | |
| | | [self onLineSet]; |
| | | |
| | | deviceStstaus = 1; |
| | | deviceStatusLabel.text = @"已连接"; |
| | | |
| | |
| | | |
| | | #define MAXOFFSETANGLE 152.0f |
| | | #define MAXVALUE 100.0f |
| | | //将要消失 |
| | | -(void)viewWillDisappear:(BOOL)animated |
| | | { |
| | | [super viewWillDisappear:animated]; |
| | | [self.csManager stopAllMusic]; |
| | | } |
| | | |
| | | - (void)viewDidLoad { |
| | | [super viewDidLoad]; |
| | |
| | | scale = 0.8; |
| | | pointerOffset = 5; |
| | | } |
| | | // else if(IsiPhoneX) |
| | | // { |
| | | // unitFontSize = 12; |
| | | // jiliangFontSize = 12; |
| | | // numFontSize = 14; |
| | | // tipsFontSize = 13; |
| | | // scale = 0.8; |
| | | // pointerOffset = 5; |
| | | // } |
| | | |
| | | UIImageView * ic_head_bg = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH-20, 66*scale)]; |
| | | ic_head_bg.image = [UIImage imageNamed:@"ic_head_bg"]; |
| | |
| | | ic_anquan_status.image = [UIImage imageNamed:@"ic_anquan_bk"]; |
| | | [ic_head_bg addSubview:ic_anquan_status]; |
| | | |
| | | ic_dianyuan = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-40-ic_anquan_status.frame.size.width/2, 44*scale + 40, 40, 40)]; |
| | | //ic_dianyuan.image = [UIImage imageNamed:@"icon_b04"]; |
| | | [ic_dianyuan setImage:[UIImage animatedImageWithAnimatedGIFURL:[[NSBundle mainBundle] URLForResource:@"icon_chong" withExtension:@"gif"]]]; |
| | | [ic_dianyuan setHidden:YES]; |
| | | [self.view addSubview:ic_dianyuan]; |
| | | |
| | | UIImageView * ic_line = [[UIImageView alloc] initWithFrame:CGRectMake(ic_head_bg.frame.size.width/2, 13*scale, 1, 40*scale)]; |
| | | ic_line.image = [UIImage imageNamed:@"ic_line"]; |
| | | [ic_head_bg addSubview:ic_line]; |
| | |
| | | [ic_head_bg addSubview:_BiaozhunJiliangNumLabel]; |
| | | |
| | | |
| | | UIImageView * icon_anquan = [[UIImageView alloc] initWithFrame:CGRectMake(19*scale, 10*scale, 22*scale, 22*scale)]; |
| | | icon_anquan.image = [UIImage imageNamed:@"icon_anquan"]; |
| | | icon_anquan = [[UIImageView alloc] initWithFrame:CGRectMake(19*scale, 10*scale, 22*scale, 22*scale)]; |
| | | icon_anquan.image = [UIImage imageNamed:@"icon_head_offline"]; |
| | | [ic_anquan_status addSubview:icon_anquan]; |
| | | |
| | | |
| | | GloriaLabel* _AnquanStatustLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(0, 35*scale,60*scale, 20*scale)]; |
| | | _AnquanStatustLabel = [[GloriaLabel alloc] initWithFrame:CGRectMake(0, 35*scale,60*scale, 20*scale)]; |
| | | _AnquanStatustLabel.font = [UIFont systemFontOfSize:unitFontSize]; |
| | | _AnquanStatustLabel.textAlignment = UITextAlignmentCenter; |
| | | _AnquanStatustLabel.textColor = kUIColorFromRGB(0x07cb5a); |
| | |
| | | [ic_anquan_status addSubview:_AnquanStatustLabel]; |
| | | |
| | | |
| | | UIImageView * ic_zhishu_bk = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-245*scale)/2, (66+20+292+20)*scale, 245*scale, 48*scale)]; |
| | | ic_zhishu_bk = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-245*scale)/2, (66+20+292+20)*scale, 245*scale, 48*scale)]; |
| | | ic_zhishu_bk.image = [UIImage imageNamed:@"ic_zhishu_bk"]; |
| | | [self.view addSubview:ic_zhishu_bk]; |
| | | |
| | |
| | | _currentShuziTipsLabel.text = @"未开始检测"; |
| | | [ic_zhishu_bk addSubview:_currentShuziTipsLabel]; |
| | | |
| | | UIImageView * ic_bottom_bg = [[UIImageView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-64-88*scale-44, SCREEN_WIDTH, 88*scale)]; |
| | | UIImageView * ic_bottom_bg = [[UIImageView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-NavBar_Height-88*scale-TabbarHeight, SCREEN_WIDTH, 88*scale)]; |
| | | ic_bottom_bg.image = [UIImage imageNamed:@"ic_radia_bottom_bg"]; |
| | | [self.view addSubview:ic_bottom_bg]; |
| | | |
| | |
| | | _currentTipsLabel.text = @"未开始检测"; |
| | | [ic_bottom_bg addSubview:_currentTipsLabel]; |
| | | |
| | | UIImageView * ic_weixin_tips = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-34*scale)/2, -17*scale, 34*scale, 34*scale)]; |
| | | ic_weixin_tips = [[UIImageView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-34*scale)/2, -17*scale, 34*scale, 34*scale)]; |
| | | ic_weixin_tips.image = [UIImage imageNamed:@"ic_weixin_tips"]; |
| | | [ic_bottom_bg addSubview:ic_weixin_tips]; |
| | | |
| | |
| | | circle3.reduceValue = 72; |
| | | circle3.increaseFromLast = YES; |
| | | circle3.pointImage = [UIImage imageNamed:@"test_point"]; |
| | | circle3.progress = ((float)850/FUSHE_MAX_VALUE); |
| | | //circle3.progress = 0; |
| | | //circle3.progress = ((float)850/FUSHE_MAX_VALUE); |
| | | circle3.progress = 0; |
| | | circle3.showProgressText = NO; |
| | | circle3.userInteractionEnabled = NO; |
| | | [ic_zhuanpan_bkBtn addSubview:circle3]; |
| | |
| | | { |
| | | self.navigationController.navigationBar.translucent = NO; |
| | | } |
| | | _locService = [[BMKLocationService alloc]init]; |
| | | |
| | | _locService.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; |
| | | |
| | | [self startLocation]; |
| | | //_locService = [[BMKLocationService alloc]init]; |
| | | //_locService.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; |
| | | //[self startLocation]; |
| | | |
| | | dataModelArr = [[NSMutableArray alloc] init]; |
| | | |
| | | // for (int i = 0; i < 10; i++) { |
| | | // DataModel * model = [[DataModel alloc] init]; |
| | | // model.time = [DateUtil stringFromDateYMDHMS:[NSDate date]]; |
| | | // model.type = @"1"; |
| | | // model.is_warn = @"0"; |
| | | // model.value = @"0.012"; |
| | | // [dataModelArr addObject:[model mj_JSONString]]; |
| | | // } |
| | | // |
| | | // |
| | | // NSDictionary * tempDic = [dataModelArr mj_keyValues]; |
| | | // |
| | | // NSString * tempStr = [Global convertToJsonData:tempDic]; |
| | | myTimeInterval = [UserDefault stringForKey:@"refresh_frequency"]; |
| | | is_open_upload = [UserDefault stringForKey:@"is_open_upload"]; |
| | | |
| | | bOpenConnectBLE = false; |
| | | |
| | | [self offLineSet]; |
| | | |
| | | // 广告每天弹出一次 |
| | | NSString* NoticeTime = [UserDefault stringForKey:@"NoticeTime"]; |
| | | BOOL bGetNotice = NO; |
| | | if (NoticeTime == nil) |
| | | { |
| | | bGetNotice = YES; |
| | | } |
| | | else |
| | | { |
| | | bGetNotice = YES; |
| | | if([DateUtil isToday:NoticeTime]) |
| | | bGetNotice = NO; |
| | | } |
| | | |
| | | //[UserDefault setObject:[DateUtil stringFromDateYMD:[NSDate date]] forKey:@"NoticeTime"]; |
| | | if(bGetNotice == YES) |
| | | { |
| | | [self GetNoticeInfo]; |
| | | } |
| | | |
| | | self.csManager = [CSAudioManager defaultManager]; |
| | | self.mp3Data = nil; |
| | | |
| | | self.modelArray = [[NSMutableArray alloc] init]; |
| | | |
| | | MPWeakSelf(self); |
| | | [self.csManager setBlockPlayerStartPlay:^{ |
| | | NSLog(@"控制器-要开始播放了"); |
| | | }]; |
| | | |
| | | [self.csManager setBlockPlayerStopPlay:^{ |
| | | NSLog(@"控制器-要停止播放了"); |
| | | }]; |
| | | |
| | | [self.csManager setBlockPlayerDidFinishPlaying:^{ |
| | | NSLog(@"控制器-知道播放结束了"); |
| | | }]; |
| | | [self setMusicConfig]; |
| | | //myTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(function:) userInfo:nil repeats:YES]; |
| | | //每1秒运行一次function方法。 |
| | | |
| | | } |
| | | |
| | | -(void)offLineSet |
| | | { |
| | | _AnquanStatustLabel.text = @"离线"; |
| | | _AnquanStatustLabel.textColor = kUIColorFromRGB(0x848787); |
| | | deviceStatusLabel.text = @"未连接"; |
| | | deviceStatusLabel.textColor = kUIColorFromRGB(0x848787); |
| | | icon_anquan.image = [UIImage imageNamed:@"icon_head_offline"]; |
| | | ic_anquan_status.image = [UIImage imageNamed:@"bg_corner_gray"]; |
| | | ic_weixin_tips.image = [UIImage imageNamed:@"icon_offline"]; |
| | | ic_zhishu_bk.image = [UIImage imageNamed:@"bt_offline"]; |
| | | _currentTipsLabel.textColor = kUIColorFromRGB(0x848787); |
| | | } |
| | | |
| | | -(void)onLineSet |
| | | { |
| | | deviceStatusLabel.textColor = RgbColor(64, 159, 252); |
| | | _AnquanStatustLabel.text = @"安全"; |
| | | _AnquanStatustLabel.textColor = kUIColorFromRGB(0x07cb5a); |
| | | icon_anquan.image = [UIImage imageNamed:@"icon_anquan"]; |
| | | ic_anquan_status.image = [UIImage imageNamed:@"ic_anquan_bk"]; |
| | | ic_weixin_tips.image = [UIImage imageNamed:@"ic_anquan_tips"]; |
| | | ic_zhishu_bk.image = [UIImage imageNamed:@"bt_green"]; |
| | | _currentTipsLabel.textColor = kUIColorFromRGB(0x848787); |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | -(void)storyAticon |
| | | { |
| | | //关闭定时器 |
| | | if(myTimer) |
| | | [myTimer setFireDate:[NSDate distantFuture]]; |
| | | |
| | | //关闭定时器 |
| | | if(myScanTimer) |
| | | [myScanTimer setFireDate:[NSDate distantFuture]]; |
| | | |
| | | HistoryRecordPage* page = [[HistoryRecordPage alloc] initIsFirstPage:NO]; |
| | | |
| | | BaseNaviController *baseNav = [[BaseNaviController alloc] initWithRootViewController:page]; |
| | |
| | | |
| | | -(void)data_upload |
| | | { |
| | | // 没有接收到数据不上传 |
| | | if ([dataModelArr count] == 0 ) |
| | | return; |
| | | |
| | | //[UserDefault stringForKey:@"user_id"] |
| | | NSString *path = [[NSString alloc] initWithFormat:DATA_UPLOAD]; |
| | | |
| | | UploadModel *model = [[UploadModel alloc] init]; |
| | | |
| | | model.data = [[UploadData alloc] init]; |
| | | //['refresh_frequency', 'video', 'is_open_upload'] |
| | | //[param setValue:[UserDefault stringForKey:@"user_id"] forKey:@"user_id"]; |
| | | address = @"测试地址"; |
| | | |
| | | model.lat = [NSString stringWithFormat:@"%lf",latitude]; |
| | | model.lon = [NSString stringWithFormat:@"%lf",longitude]; |
| | | model.userid = [UserDefault stringForKey:@"user_id"]; |
| | | model.address = address; |
| | | model.modelArray = [[NSMutableArray alloc] init]; |
| | | [model.modelArray addObjectsFromArray:dataModelArr]; |
| | | model.data.lat = [NSString stringWithFormat:@"%lf",latitude]; |
| | | model.data.lon = [NSString stringWithFormat:@"%lf",longitude]; |
| | | model.data.userid = [UserDefault stringForKey:@"user_id"]; |
| | | model.data.address = address; |
| | | |
| | | model.data.data = [[NSMutableArray alloc] init]; |
| | | [model.data.data addObjectsFromArray:dataModelArr]; |
| | | |
| | | //NSString * tempString = [Global convertToJsonData:model.toDic]; |
| | | MPWeakSelf(self); |
| | | [NetworkSingleton networkingGetMethod:model.toDic urlName:path success:^(id responseBody) |
| | | [NetworkSingleton networkingPostMethod:model.toDic urlName:path success:^(id responseBody) |
| | | { |
| | | MPStrongSelf(self); |
| | | BaseResModel * resModel = [Global toBaseModel:responseBody]; |
| | |
| | | failure:^(NSString *error) |
| | | { |
| | | |
| | | [Global alertMessageEx:error title:@"获取失败" okTtitle:nil cancelTitle:@"OK" delegate:self]; |
| | | [Global alertMessageEx:error title:@"提示信息" okTtitle:nil cancelTitle:@"OK" delegate:self]; |
| | | }]; |
| | | } |
| | | |