diff --git a/Ifish/Utinitys/dataUnity/dataContorl.m b/Ifish/Utinitys/dataUnity/dataContorl.m index e5b4b5b..ab940ec 100644 --- a/Ifish/Utinitys/dataUnity/dataContorl.m +++ b/Ifish/Utinitys/dataUnity/dataContorl.m @@ -337,11 +337,11 @@ } if (sec<=9) { - miaoString=[NSString stringWithFormat:@"0%llu",fen + miaoString=[NSString stringWithFormat:@"0%llu",sec ]; // NSLog(@"str3 %@",fenString); }else{ - miaoString=[NSString stringWithFormat:@"%llu",fen + miaoString=[NSString stringWithFormat:@"%llu",sec ]; // NSLog(@"str4 %@",fenString); } @@ -351,7 +351,7 @@ NSString*formatString=[NSString stringWithFormat:@"%@:%@",shiString,fenString]; if (miaoString.length) { - [formatString stringByAppendingFormat:@":%@",miaoString]; + formatString = [formatString stringByAppendingFormat:@":%@",miaoString]; } //NSLog(@"str5 %@",formatString); diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/CycleTimerCell.m b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/CycleTimerCell.m index 8696eae..160e823 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/CycleTimerCell.m +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/CycleTimerCell.m @@ -13,6 +13,7 @@ - (void)awakeFromNib { [super awakeFromNib]; // Initialization code + } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerListViewController.m b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerListViewController.m index 8e23542..fde8d3f 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerListViewController.m +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerListViewController.m @@ -359,7 +359,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell"; else if ([_timerType.type isEqualToString:@"04"]) { cell.cyclebtn.selected=YES; } - else if ([_timerType.type isEqualToString:@"02"]||[_timerType.type isEqualToString:@"01"]||[_timerType.type isEqualToString:@"00"]) + else if ([_timerType.type isEqualToString:@"02"]||[_timerType.type isEqualToString:@"01"]) { cell.recoverybtn.selected=YES; } diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.h b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.h index 47b0d14..b924863 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.h +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.h @@ -24,6 +24,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic,strong) DeviceModel* currentdevice; @property (nonatomic, strong) ReadTimerModel *readMode; @property (nonatomic, assign) NSInteger timerType; //1,定时 2,循环 3,自恢复 +@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 0aa3277..1303b59 100644 --- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.m +++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.m @@ -138,7 +138,26 @@ static NSString *cycleTimerflag = @"CycleTimerCell"; } _titieArr = @[type]; - + //读取具体开关定时 + ReadTimerModel*readModel=self.readMode; + if (readModel) { + if (self.timerType==1)//灯编为原始 + { + + readModel.selectorNumber=[readModel.selectorNumber stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:@"0"]; + } + else if (self.timerType==2)//灯编号为e + { + + readModel.selectorNumber=[readModel.selectorNumber stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:@"e"]; + } + else if (self.timerType==3)//灯编号为d + { + + readModel.selectorNumber=[readModel.selectorNumber stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:@"d"]; + } + self.lightNumber=readModel.selectorNumber; + } _selectSection = 0; if (self.timerType==1||self.timerType==3||self.timerType==2) @@ -245,15 +264,15 @@ static NSString *cycleTimerflag = @"CycleTimerCell"; NSArray *dataArr = [self.timeDic objectForKey:_titieArr[indexPath.section]]; BOOL havePlus = [dataArr containsObject:plusflag]; { - CycleTimerCell *cell = [tableView dequeueReusableCellWithIdentifier:setTimerflag forIndexPath:indexPath]; + CycleTimerCell *cell = [tableView dequeueReusableCellWithIdentifier:cycleTimerflag forIndexPath:indexPath]; - + cell.model=_cycleModel; if([_cycleModel isKindOfClass:[XuanduoCycleModel class]]) { - cell.openTilmeLabel.text=[dataContorl hexStringToDateString:_cycleModel.openTime]; - cell.closeTimeLabel.text=[dataContorl hexStringToDateString:_cycleModel.closeTime]; + cell.openTilmeLabel.text= [NSString stringWithFormat:@"开启:%@",[dataContorl hexStringToDateString:_cycleModel.openTime]]; + cell.closeTimeLabel.text=[NSString stringWithFormat:@"关闭:%@",[dataContorl hexStringToDateString:_cycleModel.closeTime]]; cell.selectionStyle = UITableViewCellSelectionStyleNone; @@ -739,9 +758,9 @@ static NSString *cycleTimerflag = @"CycleTimerCell"; [self.view.window addSubview:_mydatepicView]; } - (void)addCycleTimer:(UIButton *)btn { - _mydatepicView=[[MydatePickerView alloc]init]; + _mydatepicView=[[MydatePickerView alloc]initWithFrame:CGRectMake(0,0,kScreenSize.width,kScreenSize.height)]; _mydatepicView.pickerType = @"cycleType"; - _mydatepicView.frame=CGRectMake(0,0,kScreenSize.width,kScreenSize.height); + // _mydatepicView.frame=CGRectMake(0,0,kScreenSize.width,kScreenSize.height); [_mydatepicView.sureButton addTarget:self action:@selector(doneButtonClick) forControlEvents:UIControlEventTouchUpInside]; [_mydatepicView.cancleButton addTarget:self action:@selector(deleteButtonClick) forControlEvents:UIControlEventTouchUpInside]; if (!btn) { @@ -762,7 +781,9 @@ static NSString *cycleTimerflag = @"CycleTimerCell"; XuanduoTimerGroup *model = nil; if ([_mydatepicView.pickerType isEqualToString:@"cycleType"]) { - + startArr = [[dataContorl hexStringToDateString:_cycleModel.openTime] componentsSeparatedByString:@":"]; + endArr = [[dataContorl hexStringToDateString:_cycleModel.closeTime] componentsSeparatedByString:@":"]; + NSLog(@"stat %@ end %@",startArr,endArr); } else { @@ -993,7 +1014,7 @@ static NSString *cycleTimerflag = @"CycleTimerCell"; } } } - else if ([_mydatepicView.pickerType isEqualToString:@"cyccleType"]) + else if ([_mydatepicView.pickerType isEqualToString:@"cycleType"]) { NSLog(@"点击了加号"); // 需要判断之前的时间段是否重叠 @@ -1003,7 +1024,12 @@ static NSString *cycleTimerflag = @"CycleTimerCell"; if([startTime isEqualToString:endTime]){ [self showTitle:@"" messsage:@"开始时间不能等于结束时间"]; return; - }else{ + } + if([startTime isEqualToString:@"00:00:00"]||[endTime isEqualToString:@"00:00:00"]){ + [self showTitle:@"" messsage:@"不能为0"]; + return; + } + else{ _mydatepicView.resultString=[NSString stringWithFormat:@"%@~%@",startTime,endTime]; NSString*hexDateString1=[dataContorl dateStringToHexString:startTime]; @@ -1013,6 +1039,7 @@ static NSString *cycleTimerflag = @"CycleTimerCell"; timerModel.resavemacId = self.currentdevice.macAddress; timerModel.crc16str=@"0000"; timerModel.isOn = @"01"; + timerModel.selectorNumber=self.lightNumber; timerModel.selectorTime=[NSString stringWithFormat:@"%@%@",hexDateString1,hexDateString2]; [_mydatepicView removeFromSuperview]; @@ -1024,85 +1051,12 @@ static NSString *cycleTimerflag = @"CycleTimerCell"; NSInteger index = _selectSection ; if (index < _titieArr.count) { NSMutableArray *dataArr = [self.timeDic objectForKey:_titieArr[index]]; - NSInteger groupNumber = 1; - for (int i = 0 ; i < dataArr.count; i++) { - if ([dataArr[i] isKindOfClass:[XuanduoTimerGroup class]] && - ((XuanduoTimerGroup *)dataArr[i]).groupNumber.integerValue == groupNumber) { - groupNumber++; - } - } - NSLog(@"indexgroup = %d",groupNumber); - timerModel.groupNumber = [dataContorl groupNumberTohex:groupNumber]; - XuanduoTimerGroup *group; + BOOL havePlus = NO; - if (_mydatepicView.haveDelected) { - havePlus = [dataArr containsObject:plusflag]; - group = [dataArr objectAtIndex:havePlus?(_indexPath.row+1):_indexPath.row]; - timerModel.groupNumber = [dataContorl groupNumberTohex:group.groupNumber.integerValue];; - NSLog(@"realgroup = %ld",group.groupNumber.integerValue); - timerModel.isOn = group.status; - [dataArr removeObject:group]; - if (![self isValidTimer:startTime withEndTime:endTime]) { - [self showTitle:@"" messsage:@"添加的时间段与之前的重叠"]; - [dataArr insertObject:group atIndex:havePlus?(_indexPath.row+1):_indexPath.row]; - return; - }else { - [dataArr insertObject:group atIndex:havePlus?(_indexPath.row+1):_indexPath.row]; - } - } + - 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; - } - NSString*selectorString=[NSString stringWithFormat:@"%@%@%@%@%@%@",timerModel.description,timerModel.selectorNumber,timerModel.groupNumber,timerModel.isOn,timerModel.selectorTime,timerModel.crc16str]; + + NSString*selectorString=[NSString stringWithFormat:@"%@%@%@%@",timerModel.description,timerModel.selectorNumber,timerModel.selectorTime,timerModel.crc16str]; NSData*selctorData=[dataContorl stringToHexData:selectorString]; [[Socketsingleton sharedInstance] soketWriteData:selctorData]; @@ -1122,6 +1076,8 @@ static NSString *cycleTimerflag = @"CycleTimerCell"; /// 删除时间段 - (void)deleteButtonClick{ + if ([_mydatepicView.pickerType isEqualToString:@"xuanduo"]) + { NSString*hexDateString1=[dataContorl dateStringToHexString:@"00:00"]; NSString*hexDateString2=[dataContorl dateStringToHexString:@"00:00"]; SetTimerModel *timerModel = [[SetTimerModel alloc] init]; @@ -1205,6 +1161,11 @@ static NSString *cycleTimerflag = @"CycleTimerCell"; [[Socketsingleton sharedInstance] soketWriteData:readData]; [_indicatorView startAnimating]; } + } + else + { + [_mydatepicView removeFromSuperview]; + } } /// 时间重叠则添加无效 @@ -1811,21 +1772,8 @@ static NSString *cycleTimerflag = @"CycleTimerCell"; ReadTimerModel*readModel=self.readMode; readModel.functionCode=@"16"; if (readModel) { - if (self.timerType==1)//灯编为原始 - { - - readModel.selectorNumber=[readModel.selectorNumber stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:@"0"]; - } - else if (self.timerType==2)//灯编号为e - { - - readModel.selectorNumber=[readModel.selectorNumber stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:@"e"]; - } - else if (self.timerType==3)//灯编号为d - { - - readModel.selectorNumber=[readModel.selectorNumber stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:@"d"]; - } + + NSString*readString=[NSString stringWithFormat:@"%@%@%@",readModel.description,readModel.selectorNumber,readModel.crc16str]; NSData*readData=[dataContorl stringToHexData:readString]; diff --git a/Ifish/views/mypicView/MydatePickerView.m b/Ifish/views/mypicView/MydatePickerView.m index e25b646..acda4e8 100644 --- a/Ifish/views/mypicView/MydatePickerView.m +++ b/Ifish/views/mypicView/MydatePickerView.m @@ -15,10 +15,10 @@ self=[super initWithFrame:frame]; if (self) { - CGFloat imgWid= kScreenSize.width - 40*2; + CGFloat imgWid= kScreenSize.width - 10*2; CGFloat imHeight= kScreenSize.width - 60; self.backgroundColor=[UIColor colorWithWhite:0 alpha:0.5]; - _backgroundImage=[[UIImageView alloc]initWithFrame:CGRectMake(40,kScreenSize.height/2-(kScreenSize.width -30)/2, imgWid, imHeight)]; + _backgroundImage=[[UIImageView alloc]initWithFrame:CGRectMake(10,kScreenSize.height/2-(kScreenSize.width -30)/2, imgWid, imHeight)]; _backgroundImage.image=[UIImage imageNamed:@"Box"]; _backgroundImage.userInteractionEnabled=YES; @@ -33,6 +33,7 @@ _startLabel=[[UILabel alloc] initWithFrame:CGRectMake(10,title.frame.size.height+20, _backgroundImage.frame.size.width/2, 20)]; _startLabel.text=@"开始时间"; + _startLabel.font=[UIFont systemFontOfSize:15]; _startLabel.textAlignment=NSTextAlignmentCenter; [_backgroundImage addSubview:_startLabel]; @@ -44,7 +45,7 @@ [_backgroundImage addSubview:_endLabel]; _startString = _startString1 =_startSecondString= _endString = _endString1 = _endSecondString= @"00"; - _picView=[[UIPickerView alloc]initWithFrame:CGRectMake(10,_startLabel.frame.origin.y + 20,imgWid - 20,imHeight -30 - 40- 20)]; + _picView=[[UIPickerView alloc]initWithFrame:CGRectMake(0,_startLabel.frame.origin.y + 20,imgWid,imHeight -30 - 40- 20)]; _picView.dataSource=self; _picView.delegate=self; @@ -53,7 +54,7 @@ _cancleButton=[UIButton buttonWithType:UIButtonTypeCustom]; _cancleButton.backgroundColor=[UIColor lightGrayColor]; - CGFloat wdspace=40; + CGFloat wdspace=10; _sureButton =[UIButton buttonWithType:UIButtonTypeCustom]; @@ -105,28 +106,72 @@ } - (void)setPickerType:(NSString *)pickerType { + _pickerType = pickerType; - UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(12,_startLabel.frame.origin.y+30, _picView.frame.size.width/4, 20)]; - label1.text=@"小时"; - label1.font=[UIFont systemFontOfSize:15]; - label1.textAlignment=NSTextAlignmentCenter; - [_backgroundImage addSubview:label1]; - UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(12+label1.frame.size.width+2,_startLabel.frame.origin.y+30, _picView.frame.size.width/4, 20)]; - label2.text=@"分钟"; - label2.font=[UIFont systemFontOfSize:15]; - label2.textAlignment=NSTextAlignmentCenter; - [_backgroundImage addSubview:label2]; - UILabel *label3 = [[UILabel alloc] initWithFrame:CGRectMake(label2.frame.origin.x+label2.frame.size.width+ 4,_startLabel.frame.origin.y+30, _picView.frame.size.width/4, 20)]; - label3.text=@"小时"; - label3.font=[UIFont systemFontOfSize:15]; - label3.textAlignment=NSTextAlignmentCenter; - [_backgroundImage addSubview:label3]; - UILabel *label4 = [[UILabel alloc] initWithFrame:CGRectMake(label3.frame.origin.x+label3.frame.size.width+2,_startLabel.frame.origin.y+30, _picView.frame.size.width/4, 20)]; - label4.text=@"分钟"; - label4.font=[UIFont systemFontOfSize:15]; - label4.textAlignment=NSTextAlignmentCenter; - [_backgroundImage addSubview:label4]; [self initData]; + if ([self.pickerType isEqualToString:@"xuanduo"]) + { + UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(12,_startLabel.frame.origin.y+30, _picView.frame.size.width/4, 20)]; + label1.text=@"小时"; + label1.font=[UIFont systemFontOfSize:15]; + label1.textAlignment=NSTextAlignmentCenter; + [_backgroundImage addSubview:label1]; + UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(12+label1.frame.size.width+2,_startLabel.frame.origin.y+30, _picView.frame.size.width/4, 20)]; + label2.text=@"分钟"; + label2.font=[UIFont systemFontOfSize:15]; + label2.textAlignment=NSTextAlignmentCenter; + [_backgroundImage addSubview:label2]; + UILabel *label3 = [[UILabel alloc] initWithFrame:CGRectMake(label2.frame.origin.x+label2.frame.size.width+ 4,_startLabel.frame.origin.y+30, _picView.frame.size.width/4, 20)]; + label3.text=@"小时"; + label3.font=[UIFont systemFontOfSize:15]; + label3.textAlignment=NSTextAlignmentCenter; + [_backgroundImage addSubview:label3]; + UILabel *label4 = [[UILabel alloc] initWithFrame:CGRectMake(label3.frame.origin.x+label3.frame.size.width+2,_startLabel.frame.origin.y+30, _picView.frame.size.width/4, 20)]; + label4.text=@"分钟"; + label4.font=[UIFont systemFontOfSize:15]; + label4.textAlignment=NSTextAlignmentCenter; + [_backgroundImage addSubview:label4]; + } + else + { + _startLabel.text=@"开启时间"; + _endLabel.text=@"关闭时间"; + [_cancleButton setTitle:@"取消" forState:UIControlStateNormal]; + UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(12,_startLabel.frame.origin.y+30, _picView.frame.size.width/6, 20)]; + label1.text=@"时"; + label1.font=[UIFont systemFontOfSize:15]; + label1.textAlignment=NSTextAlignmentCenter; + [_backgroundImage addSubview:label1]; + UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(label1.frame),_startLabel.frame.origin.y+30, _picView.frame.size.width/6, 20)]; + label2.text=@"分"; + label2.font=[UIFont systemFontOfSize:15]; + label2.textAlignment=NSTextAlignmentCenter; + [_backgroundImage addSubview:label2]; + UILabel *label3 = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(label2.frame),_startLabel.frame.origin.y+30, _picView.frame.size.width/6, 20)]; + label3.text=@"秒"; + label3.font=[UIFont systemFontOfSize:15]; + label3.textAlignment=NSTextAlignmentCenter; + [_backgroundImage addSubview:label3]; + UILabel *label4 = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(label3.frame),_startLabel.frame.origin.y+30, _picView.frame.size.width/6, 20)]; + label4.text=@"时"; + label4.font=[UIFont systemFontOfSize:15]; + label4.textAlignment=NSTextAlignmentCenter; + [_backgroundImage addSubview:label4]; + + UILabel *label5 = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(label4.frame),_startLabel.frame.origin.y+30, _picView.frame.size.width/6, 20)]; + label5.text=@"分"; + label5.font=[UIFont systemFontOfSize:15]; + label5.textAlignment=NSTextAlignmentCenter; + [_backgroundImage addSubview:label5]; + + UILabel *label6 = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(label5.frame),_startLabel.frame.origin.y+30, _picView.frame.size.width/6, 20)]; + label6.text=@"秒"; + label6.font=[UIFont systemFontOfSize:15]; + label6.textAlignment=NSTextAlignmentCenter; + [_backgroundImage addSubview:label6]; + } + + [_picView reloadAllComponents]; } - (void)setHaveDelected:(BOOL)haveDelected {