diff --git a/Ifish.xcodeproj/project.pbxproj b/Ifish.xcodeproj/project.pbxproj index 45ceefa..2c04574 100644 --- a/Ifish.xcodeproj/project.pbxproj +++ b/Ifish.xcodeproj/project.pbxproj @@ -2714,6 +2714,8 @@ FA0892EE226C15000084A609 /* Xuanduo2DataUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = FA0892EC226C15000084A609 /* Xuanduo2DataUtility.m */; }; FA0892F1226CA3920084A609 /* NSString+Add.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0892EF226CA3920084A609 /* NSString+Add.h */; }; FA0892F2226CA3920084A609 /* NSString+Add.m in Sources */ = {isa = PBXBuildFile; fileRef = FA0892F0226CA3920084A609 /* NSString+Add.m */; }; + FA0892F52270BED00084A609 /* XuanduoHuliModel.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0892F32270BED00084A609 /* XuanduoHuliModel.h */; }; + FA0892F62270BED00084A609 /* XuanduoHuliModel.m in Sources */ = {isa = PBXBuildFile; fileRef = FA0892F42270BED00084A609 /* XuanduoHuliModel.m */; }; FAB3721122619DB70051E107 /* Xuanduo2fController.h in Headers */ = {isa = PBXBuildFile; fileRef = FAB3720E22619DB70051E107 /* Xuanduo2fController.h */; }; FAB3721222619DB70051E107 /* Xuanduo2fController.m in Sources */ = {isa = PBXBuildFile; fileRef = FAB3720F22619DB70051E107 /* Xuanduo2fController.m */; }; FAB3721322619DB70051E107 /* Xuanduo2fController.xib in Resources */ = {isa = PBXBuildFile; fileRef = FAB3721022619DB70051E107 /* Xuanduo2fController.xib */; }; @@ -6652,6 +6654,8 @@ FA0892EC226C15000084A609 /* Xuanduo2DataUtility.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Xuanduo2DataUtility.m; sourceTree = ""; }; FA0892EF226CA3920084A609 /* NSString+Add.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Add.h"; sourceTree = ""; }; FA0892F0226CA3920084A609 /* NSString+Add.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Add.m"; sourceTree = ""; }; + FA0892F32270BED00084A609 /* XuanduoHuliModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XuanduoHuliModel.h; sourceTree = ""; }; + FA0892F42270BED00084A609 /* XuanduoHuliModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XuanduoHuliModel.m; sourceTree = ""; }; FAB3720E22619DB70051E107 /* Xuanduo2fController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Xuanduo2fController.h; sourceTree = ""; }; FAB3720F22619DB70051E107 /* Xuanduo2fController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Xuanduo2fController.m; sourceTree = ""; }; FAB3721022619DB70051E107 /* Xuanduo2fController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = Xuanduo2fController.xib; sourceTree = ""; }; @@ -10328,6 +10332,8 @@ 883E76A51D48A5E50030E075 /* XuToCenterViewController.m */, 883E76A61D48A5E50030E075 /* XuToLightModel.h */, 883E76A71D48A5E50030E075 /* XuToLightModel.m */, + FA0892F32270BED00084A609 /* XuanduoHuliModel.h */, + FA0892F42270BED00084A609 /* XuanduoHuliModel.m */, 883E76A81D48A5E50030E075 /* XuToSetViewController.h */, 883E76A91D48A5E50030E075 /* XuToSetViewController.m */, 883E76AA1D48A5E50030E075 /* XuToSoketBackMsgDataUnity.h */, @@ -14546,6 +14552,7 @@ 3D1C513F221A9EE10096AE43 /* FishControlThreedViewCell.h in Headers */, 3D1C5062221A9EDF0096AE43 /* bprint.h in Headers */, 3D1C505C221A9EDF0096AE43 /* cpu.h in Headers */, + FA0892F52270BED00084A609 /* XuanduoHuliModel.h in Headers */, 3D1C5051221A9EDF0096AE43 /* timecode.h in Headers */, 3D1C50C7221A9EE00096AE43 /* LocalDevice.h in Headers */, 3D1C50A0221A9EDF0096AE43 /* TouchButton.h in Headers */, @@ -17166,6 +17173,7 @@ 3D1C50C8221A9EE00096AE43 /* Alarm.m in Sources */, 886028711E10BB1100F3DB5D /* NSNumberFormatter+CTAssetsPickerController.m in Sources */, 881671A61EA5DE2B00BEBF23 /* UMComLocationListDataController.m in Sources */, + FA0892F62270BED00084A609 /* XuanduoHuliModel.m in Sources */, 3D1C5106221A9EE00096AE43 /* CameraNoParyBackVideoView.m in Sources */, 881671AD1EA5DE2B00BEBF23 /* UMComUserListDataController.m in Sources */, 88653CA21E7671F900FF973E /* MineHeaderNewItemsCell.m in Sources */, diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2DataUtility.m b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2DataUtility.m index da3d92f..db615fa 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2DataUtility.m +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2DataUtility.m @@ -74,9 +74,9 @@ } NSString *stateString7 = [backModel.waterPump substringWithRange:NSMakeRange(2, 2)]; if ([stateString7 isEqualToString:@"01"]) { - waveLightBtn.selected = YES; + waterLightBtn.selected = YES; }else{ - waveLightBtn.selected = NO; + waterLightBtn.selected = NO; } NSString *stateString8 = backModel.heatStatus; if ([stateString8 isEqualToString:@"01"]) { diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2fController.m b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2fController.m index 47bd935..76e4345 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2fController.m +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2fController.m @@ -19,6 +19,7 @@ #import "UserExtendataArchaver.h" #import "UIButton+WebCache.h" #import "NSString+Add.h" +#import "XuanduoHuliModel.h" #import "Xuanduo2DataUtility.h" #define kBtnTag 100 @@ -48,6 +49,8 @@ @property (weak, nonatomic) IBOutlet UIButton *huliLight; @property (weak, nonatomic) IBOutlet UIButton *waterLight; @property (weak, nonatomic) IBOutlet UIButton *heatLight; +@property(nonatomic,copy) UIActivityIndicatorView *indicatorView; +@property(nonatomic,strong) MyHud *XuTohud; @end @@ -147,6 +150,8 @@ //communiteDelegate -(void)socketDidGetBackmsgData:(NSData *)data onsoket:(AsyncSocket *)sock{ + //[_HUD hide:YES]; + [self.XuTohud hidmyHud]; [Xuanduo2DataUtility readSocketDataWithBackMsgModel:self.dataModel addWithBackData:data]; if ([self.tipLabel.text isEqualToString:@"鱼缸温度"]) { [self setTemperature]; @@ -168,18 +173,97 @@ #pragma mark -- actions -- -- (IBAction)btnActions:(UIButton *)sender { - sender.selected = !sender.selected; - switch (sender.tag) { +- (IBAction)btnActions:(UIButton *)btn { + if (self.dataModel) { + + }else{ + [self showLableAction:@"设备已离线"]; + } + XuToLightModel * lightModel= [[XuToLightModel alloc] init]; + lightModel.sendmacId = self.currentDevice.macAddress; + lightModel.resavemacId = self.currentDevice.macAddress; + NSString*switchString1=lightModel.description; + if (btn.selected) {//开 + lightModel.switchBtn = @"00"; + }else {// 关 + lightModel.switchBtn = @"01"; + } + lightModel.crc16Str=@"0000";// CRC16验证码 + switch (btn.tag) { case kBtnTag: //杀菌灯 - + { + [self changLightStatus:lightModel withLightNumber:@"05" dataStr:switchString1]; + } break; - case kBtnTag + 1: + case kBtnTag + 1: //增氧 + { + [self changLightStatus:lightModel withLightNumber:@"01" dataStr:switchString1]; + } + break; + case kBtnTag + 2: //灯光1 + { + [self changLightStatus:lightModel withLightNumber:@"02" dataStr:switchString1]; + } + break; + case kBtnTag + 3: //灯光2 + { + [self changLightStatus:lightModel withLightNumber:@"03" dataStr:switchString1]; + } + break; + case kBtnTag + 4: //造浪泵 + { + [self changLightStatus:lightModel withLightNumber:@"06" dataStr:switchString1]; + } + break; + case kBtnTag + 5: //护理灯 单独处理 + { + XuanduoHuliModel *huliModel = [[XuanduoHuliModel alloc] init]; + huliModel.sendmacId = self.currentDevice.macAddress; + huliModel.resavemacId = self.currentDevice.macAddress; + NSString *switchString = huliModel.description; + if (btn.selected) {//开 + huliModel.switchBtn = @"00"; + }else {// 关 + huliModel.switchBtn = @"01"; + } + huliModel.crc16Str=@"0000";// CRC16验证码 + NSString *switchString2 = [NSString stringWithFormat:@"%@%@%@",switchString,huliModel.switchBtn,huliModel.crc16Str]; + NSData *manulData=[dataContorl stringToHexData:switchString2]; + [[Socketsingleton sharedInstance] soketWriteData:manulData]; + if ([Socketsingleton sharedInstance].clientSocket.isConnected) { + //soket 未断开时显示 + [self creatXuToindicaterView]; + [self.XuTohud myhudstart]; + } + } + break; + case kBtnTag + 6: //循环泵 + { + [self changLightStatus:lightModel withLightNumber:@"04" dataStr:switchString1]; + } + break; + case kBtnTag + 7: //加热棒 + { + [self changLightStatus:lightModel withLightNumber:@"" dataStr:switchString1]; + } + break; default: break; } } +- (void)changLightStatus:(XuToLightModel *)lightModel withLightNumber:(NSString *)number dataStr:(NSString *)switchString1 { + lightModel.lightNumber = number; + NSString *switchString2 = [NSString stringWithFormat:@"%@%@%@%@",switchString1,lightModel.lightNumber,lightModel.switchBtn,lightModel.crc16Str]; + NSData *manulData=[dataContorl stringToHexData:switchString2]; + [[Socketsingleton sharedInstance] soketWriteData:manulData]; + if ([Socketsingleton sharedInstance].clientSocket.isConnected) { + //soket 未断开时显示 + [self creatXuToindicaterView]; + [self.XuTohud myhudstart]; + } +} + - (IBAction)brandClick:(id)sender { SongBaoViewController *brand = [[SongBaoViewController alloc]init]; brand.brandIntroduce = self.currentDevice.brandIntroduce; @@ -245,6 +329,20 @@ } +-(void)creatXuToindicaterView{ + + self.XuTohud = [[MyHud alloc]init]; + self.XuTohud.frame=CGRectMake(0, kScreenSize.height/3, kScreenSize.width,kScreenSize.height*2/3 ); + + [self.XuTohud myhudtimeOut]; + //self.XuTohud.backgroundColor=[UIColor redColor]; + + [self.view addSubview:self.XuTohud]; + NSLog(@"**********绚多加载***********"); + +} + + #pragma mark - PopViewDelagate -(void)disSelectedPopViewIndex:(NSIndexPath *)Index{ @@ -276,7 +374,7 @@ UInt64 mac = [dataContorl hexToTen:self.dataModel.waterTemperature]; NSLog(@"%llu",mac); //float TPlabel=mac/10+(mac%10)*0.1; - float temp = mac/10; + float temp = mac/10.0; NSString *stringTemp = [NSString stringWithFormat:@"%.1f℃",temp]; [self.tempLabel setAttributedText:[NSString ls_changeFontAndColor:[UIFont systemFontOfSize:15] Color:nil TotalString:stringTemp SubStringArray:@[@"℃"]]]; } @@ -455,6 +553,26 @@ return _dataModel; } +- (void)showLableAction:(NSString *)str{ + UILabel *laberAction =[[UILabel alloc]init]; + laberAction.frame =CGRectMake((kScreenSize.width/2) - 50, kScreenSize.height/2 , 100, 50); + laberAction.clipsToBounds =YES; + laberAction.layer.cornerRadius =5; + laberAction.alpha =1; + laberAction.text =str; + laberAction.textAlignment =NSTextAlignmentCenter; + laberAction.backgroundColor =IndicatorBack_COLOR; + laberAction.font=[UIFont systemFontOfSize:12]; + laberAction.textColor=[UIColor whiteColor]; + + [UIView animateWithDuration:2.0 animations:^{ + laberAction.alpha =0; + }completion:^(BOOL finished) { + [laberAction removeFromSuperview]; + }]; + [self.view addSubview:laberAction]; +} + - (void)dealloc { } diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2fController.xib b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2fController.xib index 9563727..72c927f 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2fController.xib +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2fController.xib @@ -30,7 +30,7 @@ - + @@ -81,7 +81,7 @@ - - - - -