From 76e8cf75615ef0c264d45d05d8b10e54211810a8 Mon Sep 17 00:00:00 2001 From: kai60 Date: Sat, 21 May 2022 16:34:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E6=81=A2=E5=A4=8D=E5=AE=9A=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../XuTo/XuanduoSettingController.m | 4 +- .../XuTo/XuanduoTimerListViewController.m | 20 +- .../XuTo/XuanduoTimerSettingViewController.h | 5 + .../XuTo/XuanduoTimerSettingViewController.m | 273 ++++++------------ .../XuTo/XuanduofishFeedViewController.m | 1 + 5 files changed, 111 insertions(+), 192 deletions(-) diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoSettingController.m b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoSettingController.m index 3f07eb8..56122d5 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoSettingController.m +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoSettingController.m @@ -127,9 +127,9 @@ static NSString *setTimerflag = @"SetTimerCell"; - (void)setupTable { - _titieArr = @[@"定时设置",@"喂鱼设置",@"温度校准",@"功能说明"]; + _titieArr = @[@"定时设置",@"喂鱼设置",@"温度校准"]; - _imgArr = @[@"定时",@"喂鱼",@"温度校准",@"功能说明 "]; + _imgArr = @[@"定时",@"喂鱼",@"温度校准"]; diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerListViewController.m b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerListViewController.m index fde8d3f..ba555fc 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerListViewController.m +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerListViewController.m @@ -44,7 +44,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell"; @interface XuanduoTimerListViewController () @property(nonatomic,strong) setRemindWaterModel *waterInfmodel; @property(nonatomic,strong) Xuanduo2TimerModel *timerModel; -@property(nonatomic,strong) XuanduoTimerTypeModel *timerType; +@property(nonatomic,strong) XuanduoTimerTypeModel *timerTypeModel; @property(nonatomic,strong) XuanduoCycleModel *cycleModel; @@ -178,6 +178,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell"; _settingVC.currentdevice = self.currentdevice; _settingVC.dataModel = self.dataModel; _settingVC.readMode=self.readMode; + _settingVC.timerTypeModel=self.timerTypeModel ; _settingVC.timerType=type; [self.navigationController pushViewController:_settingVC animated:YES]; } @@ -353,13 +354,14 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell"; cell.recoverybtn.selected=NO; cell.cyclebtn.selected=NO; - if ([_timerType.type isEqualToString:@"08"]) { + //X: 8,定时 4,循环 2,自恢复 1,全天恢复 0 ,无设置 + if ([_timerTypeModel.type isEqualToString:@"08"]) { cell.timerbtn.selected=YES; } - else if ([_timerType.type isEqualToString:@"04"]) { + else if ([_timerTypeModel.type isEqualToString:@"04"]) { cell.cyclebtn.selected=YES; } - else if ([_timerType.type isEqualToString:@"02"]||[_timerType.type isEqualToString:@"01"]) + else if ([_timerTypeModel.type isEqualToString:@"02"]||[_timerTypeModel.type isEqualToString:@"01"]) { cell.recoverybtn.selected=YES; } @@ -416,7 +418,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell"; }else if (indexPath.section - 2 <_titieArr.count) { NSArray *dataArr = [self.timeDic objectForKey:_titieArr[indexPath.section-2]]; BOOL havePlus = [dataArr containsObject:plusflag]; - if (_selectSection == indexPath.section&&_timerType) { + if (_selectSection == indexPath.section&&_timerTypeModel) { if (havePlus && indexPath.row == dataArr.count - 1) { return 40; }else{ @@ -631,7 +633,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell"; - (void)foldAction:(UIButton *)btn { if (_selectSection == btn.tag - kBtnTag) { _selectSection = -1; - _timerType=nil; + _timerTypeModel=nil; [self.tableView reloadData]; }else { //读取开关定时 @@ -1603,9 +1605,9 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell"; //定时模式 if ([lightNumber.uppercaseString containsString:@"F"]) { - _timerType=[[XuanduoTimerTypeModel alloc]init]; - _timerType.lightNumber=lightNumber; - _timerType.type=[string1 substringWithRange:NSMakeRange(32, 2)]; + _timerTypeModel=[[XuanduoTimerTypeModel alloc]init]; + _timerTypeModel.lightNumber=lightNumber; + _timerTypeModel.type=[string1 substringWithRange:NSMakeRange(32, 2)]; NSMutableArray *dataArr = [self.timeDic objectForKey:_titieArr[_selectSection-2]]; [dataArr removeAllObjects]; [dataArr addObject:plusflag]; diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.h b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.h index b924863..575c54d 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.h +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.h @@ -11,6 +11,7 @@ #include "xuanduo3fModel.h" #import "ReadTimerModel.h" #import "UIView+Frame.h" +#import "Xuanduo2TimerModel.h" NS_ASSUME_NONNULL_BEGIN @@ -24,7 +25,11 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic,strong) DeviceModel* currentdevice; @property (nonatomic, strong) ReadTimerModel *readMode; @property (nonatomic, assign) NSInteger timerType; //1,定时 2,循环 3,自恢复 +//原始model +@property(nonatomic,strong) XuanduoTimerTypeModel *timerTypeModel; + @property(nonatomic,strong)NSString*lightNumber; + - (void)refreshWithData:(id)model; @end diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.m b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.m index 1303b59..2c5a065 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.m +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.m @@ -285,7 +285,7 @@ static NSString *cycleTimerflag = @"CycleTimerCell"; return cell; } } - else if (self.timerType==3) {//自恢复开关 + else if (self.timerType==3) { NSArray *dataArr = [self.timeDic objectForKey:_titieArr[indexPath.section]]; BOOL havePlus = [dataArr containsObject:plusflag]; if (havePlus && (indexPath.row == dataArr.count-1)) { @@ -295,19 +295,35 @@ static NSString *cycleTimerflag = @"CycleTimerCell"; return cell; }else { - CycleTimerCell *cell = [tableView dequeueReusableCellWithIdentifier:cycleTimerflag forIndexPath:indexPath]; - - - cell.model=_cycleModel; - if (_cycleModel) + SetTimerCell *cell = [tableView dequeueReusableCellWithIdentifier:setTimerflag forIndexPath:indexPath]; + cell.switchBtn.tag = kSwitchBtnTag + indexPath.row; + [cell.switchBtn addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventTouchUpInside]; + XuanduoTimerGroup *group = [dataArr objectAtIndex:havePlus?indexPath.row+1:indexPath.row]; + cell.model=group; + if ([group isKindOfClass:[XuanduoTimerGroup class]]) { - NSString*hexDateString1=[dataContorl dateStringToHexString:_cycleModel.openTime]; - NSString*hexDateString2=[dataContorl dateStringToHexString:_cycleModel.closeTime]; + BOOL isOn = NO; + if ([group.status isEqualToString:@"01"]) { + isOn = YES; + } + [cell configTitleLabel:[NSString stringWithFormat:@"时段%@",group.groupNumber] timer:group.time switchStatus:isOn]; + cell.selectionStyle = UITableViewCellSelectionStyleNone; + + } + else if([group isKindOfClass:[XuanduoCycleModel class]]) + { + XuanduoCycleModel*model=group; + BOOL isOn = NO; + if ([model.status isEqualToString:@"00"]) { + isOn = YES; + } + + + + [cell configTitleLabel:@"循环开关" timer:[NSString stringWithFormat:@"持续时长%d分钟",[dataContorl hexToTen:model.lastTime]] switchStatus:isOn]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } - - return cell; } } @@ -367,6 +383,16 @@ static NSString *cycleTimerflag = @"CycleTimerCell"; UIButton*swichBtn=[UIButton buttonWithType:UIButtonTypeCustom]; [swichBtn setBackgroundImage:[UIImage imageNamed:@"graybtn_big.png"] forState:UIControlStateNormal]; [swichBtn setBackgroundImage:[UIImage imageNamed:@"greenbtn_big"] forState:UIControlStateSelected]; + if ([self.timerTypeModel.type isEqualToString:@"01"]) + { + swichBtn.selected=YES; + } + else + { + swichBtn.selected=NO; + + } + [swichBtn addTarget:self action:@selector(allDayModesSwitchAction:) forControlEvents:UIControlEventTouchUpInside]; swichBtn.frame=CGRectMake(CGRectGetWidth(imageView.frame)-8-60, (CGRectGetHeight(imageView.frame)-33)/2.0, 60, 33); [imageView addSubview:swichBtn]; @@ -563,56 +589,7 @@ static NSString *cycleTimerflag = @"CycleTimerCell"; readModel.sendmacId =self.currentdevice.macAddress; readModel.resavemacId = self.currentdevice.macAddress; readModel.crc16str=@"0000"; - switch (_selectSection ) { - case 0: //循环泵 - { - timerModel.selectorNumber = @"04"; - if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F]) - { - timerModel.selectorNumber=@"01"; - } - } - break; - case 1: //增氧 - { - timerModel.selectorNumber = @"01"; - - if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F]) - { - timerModel.selectorNumber=@"02"; - } - - } - break; - case 2: //灯光1 - { - timerModel.selectorNumber = @"02"; - - if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F]) - { - timerModel.selectorNumber=@"03"; - } - - } - break; - case 3: //灯光2 - { - timerModel.selectorNumber = @"03"; - } - break; - case 4: //造浪泵 - { - timerModel.selectorNumber = @"06"; - } - break; - case 5: //杀菌灯 - { - timerModel.selectorNumber = @"05"; - } - break; - default: - break; - } + readModel.selectorNumber=self.lightNumber; NSString*selectorString=[NSString stringWithFormat:@"%@%@%@%@%@%@",timerModel.description,timerModel.selectorNumber,timerModel.groupNumber,timerModel.isOn,timerModel.selectorTime,timerModel.crc16str]; NSData*selctorData=[dataContorl stringToHexData:selectorString]; @@ -663,83 +640,57 @@ static NSString *cycleTimerflag = @"CycleTimerCell"; } } +//全天自恢复 - (void)allDayModesSwitchAction:(UIButton *)btn { - btn.selected=!btn.selected; - return; - NSInteger index = btn.tag - kSwitchBtnTag; - - NSArray *dataArr = [self.timeDic objectForKey:_titieArr[_selectSection]]; - BOOL havePlus = [dataArr containsObject:plusflag]; - SetTimerModel *timerModel = [[SetTimerModel alloc] init]; - timerModel.sendmacId =self.currentdevice.macAddress; - timerModel.resavemacId = self.currentdevice.macAddress; - timerModel.crc16str=@"0000"; - XuanduoTimerGroup *group = [dataArr objectAtIndex:(havePlus?index+1:index)]; - if ([group isKindOfClass: [XuanduoTimerGroup class] ]) { - NSString*hexDateString1=[dataContorl dateStringToHexString:group.startTime]; - NSString*hexDateString2=[dataContorl dateStringToHexString:group.endTime]; - timerModel.selectorTime=[NSString stringWithFormat:@"%@%@",hexDateString1,hexDateString2]; - timerModel.groupNumber = [dataContorl groupNumberTohex:group.groupNumber.integerValue]; - if ([group.status isEqualToString:@"01"]) { - timerModel.isOn = @"00"; - }else { - timerModel.isOn = @"01"; - } + UIAlertController*alert=[UIAlertController alertControllerWithTitle:@"提示" message:@"确认开启全天自恢复模式吗?开启此模式后,当手动关闭该设备时,10分钟后该设备将自动打开" preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction*okaction=[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + btn.selected=!btn.selected; + SetTimerModel *timerModel = [[SetTimerModel alloc] init]; + timerModel.sendmacId =self.currentdevice.macAddress; + timerModel.resavemacId = self.currentdevice.macAddress; + timerModel.crc16str=@"0000"; + timerModel.selectorNumber=self.lightNumber; + timerModel.groupNumber=@"00"; + timerModel.selectorTime=@"00000000"; + if (!btn.selected) { + timerModel.isOn = @"00"; + }else { + timerModel.isOn = @"01"; + } + + NSString*selectorString=[NSString stringWithFormat:@"%@%@%@%@%@%@",timerModel.description,timerModel.selectorNumber,timerModel.groupNumber,timerModel.isOn,timerModel.selectorTime,timerModel.crc16str]; + NSData*selctorData=[dataContorl stringToHexData:selectorString]; + [[Socketsingleton sharedInstance] soketWriteData:selctorData]; + + - ReadTimerModel *readModel = [[ReadTimerModel alloc] init]; - readModel.sendmacId =self.currentdevice.macAddress; - readModel.resavemacId = self.currentdevice.macAddress; - readModel.crc16str=@"0000"; - readModel.selectorNumber=@""; - NSString*selectorString=[NSString stringWithFormat:@"%@%@%@%@%@%@",timerModel.description,timerModel.selectorNumber,timerModel.groupNumber,timerModel.isOn,timerModel.selectorTime,timerModel.crc16str]; + ReadTimerModel *readModel = [[ReadTimerModel alloc] init]; + - NSData*selctorData=[dataContorl stringToHexData:selectorString]; - [[Socketsingleton sharedInstance] soketWriteData:selctorData]; - // [_indicatorView startAnimating]; - - readModel.selectorNumber = timerModel.selectorNumber; - NSString*readString=[NSString stringWithFormat:@"%@%@%@",readModel.description,readModel.selectorNumber,readModel.crc16str]; - NSLog(@"read str = %@",readString); - NSData*readData=[dataContorl stringToHexData:readString]; - [[Socketsingleton sharedInstance] soketWriteData:readData]; - ; - } - else if ([group isKindOfClass: [XuanduoCycleModel class] ]) - { - baseModel*tempModel=[[baseModel alloc]init]; - tempModel.sendmacId =self.currentdevice.macAddress; - tempModel.resavemacId =self.currentdevice.macAddress; - tempModel.functionCode=@"18"; - tempModel.massagelegth=@"17"; - - - - if ([_cycleModel.status isEqualToString:@"01"]) { - _cycleModel.status = @"00"; - }else { - _cycleModel.status = @"01"; - } - - - NSString*minString=[NSString stringWithFormat:@"%@%@%@%@%@%@",tempModel.description,_cycleModel.lightNumber,_cycleModel.lastTime,_cycleModel.gapTime,_cycleModel.status,@"0000"]; - - NSData*tempData=[dataContorl stringToHexData:minString]; - [[Socketsingleton sharedInstance] soketWriteData:tempData]; + readModel.functionCode=@"16"; - - - baseModel*readModel=[[baseModel alloc]init]; - readModel.sendmacId =self.currentdevice.macAddress; - readModel.resavemacId =self.currentdevice.macAddress; - readModel.functionCode=@"19"; - readModel.massagelegth=@"12"; - - NSString*readString=[NSString stringWithFormat:@"%@%@%@%@%@%@",readModel.description,_cycleModel.lightNumber,@"0000"]; - + readModel.sendmacId =self.currentdevice.macAddress; + readModel.resavemacId = self.currentdevice.macAddress; + readModel.crc16str=@"0000"; + readModel.selectorNumber=[self.lightNumber stringByReplacingOccurrencesOfString:@"d" withString:@"f"]; + NSString*readString=[NSString stringWithFormat:@"%@%@%@",readModel.description,readModel.selectorNumber,readModel.crc16str]; NSData*readData=[dataContorl stringToHexData:readString]; [[Socketsingleton sharedInstance] soketWriteData:readData]; - } + + [_indicatorView startAnimating]; + + }]; + UIAlertAction*cancelAction=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { + + }]; + [alert addAction:okaction]; + [alert addAction:cancelAction]; + + [self presentViewController:alert animated:YES completion:nil]; + + + } @@ -947,57 +898,7 @@ static NSString *cycleTimerflag = @"CycleTimerCell"; } } - switch (index) { - case 0: //循环泵 - { - timerModel.selectorNumber = @"04"; - - if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F]) - { - timerModel.selectorNumber=@"01"; - } - - } - break; - case 1: //增氧 - { - timerModel.selectorNumber = @"01"; - - if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F]) - { - timerModel.selectorNumber=@"02"; - } - - } - break; - case 2: //灯光1 - { - timerModel.selectorNumber = @"02"; - if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F]) - { - timerModel.selectorNumber=@"03"; - } - } - break; - case 3: //灯光2 - { - timerModel.selectorNumber = @"03"; - } - break; - case 4: //造浪泵 - { - timerModel.selectorNumber = @"06"; - } - break; - case 5: //杀菌灯 - { - timerModel.selectorNumber = @"05"; - } - break; - - default: - break; - } + timerModel.selectorNumber=self.lightNumber; NSString*selectorString=[NSString stringWithFormat:@"%@%@%@%@%@%@",timerModel.description,timerModel.selectorNumber,timerModel.groupNumber,timerModel.isOn,timerModel.selectorTime,timerModel.crc16str]; NSData*selctorData=[dataContorl stringToHexData:selectorString]; @@ -1738,7 +1639,17 @@ static NSString *cycleTimerflag = @"CycleTimerCell"; NSLog(@"dataarr.count = %ld",dataArr.count); + }//读取定时模式 + else if (self.timerType==3&&[lightNumber.uppercaseString containsString:@"F"]) + { + _timerTypeModel=[[XuanduoTimerTypeModel alloc]init]; + _timerTypeModel.lightNumber=lightNumber; + _timerTypeModel.type=[string1 substringWithRange:NSMakeRange(32, 2)]; + + + } + } else if (_selectSection<_titieArr.count && _selectSection>=0 && [readTimer isEqualToString:@"0119"]) { diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduofishFeedViewController.m b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduofishFeedViewController.m index 405315e..29c7ba2 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduofishFeedViewController.m +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduofishFeedViewController.m @@ -165,6 +165,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell"; tableView.delegate=self; tableView.dataSource=self; self.tableView=tableView; + [self.view addSubview:tableView]; self.tableView.backgroundColor=COLOR_MIAN; self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone; [self.tableView registerNib:[UINib nibWithNibName:temperatureCellid bundle:nil] forCellReuseIdentifier:temperatureCellid];