读取一键喂鱼

This commit is contained in:
kai60
2022-05-21 21:36:04 +08:00
parent 76e8cf7561
commit 50628a8404
6 changed files with 98 additions and 64 deletions
@@ -60,6 +60,18 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, strong) NSString *closeTime;
@end
@interface XuanduoFishFeedModel : NSObject
/// 6路灯的选择,11111100 从高到低 表示是否选择 二进制
@property (nonatomic, strong) NSString *lightChooseStatus;
//表示时间1~60
@property (nonatomic, strong) NSString *feedTime;
//6路灯的控制状态 11111100 从高到低 0关,1开。 二进制
@property (nonatomic, strong) NSString *lightOpenStatus;
@end
@interface XuanduoRecoveryModel : NSObject
@@ -29,4 +29,10 @@
@end
@implementation XuanduoFishFeedModel
@end
@@ -49,6 +49,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
@property (nonatomic,strong) NSMutableDictionary *timeDic;
@property(nonatomic,copy) NSString *nextChangeDateLabel;
@property(nonatomic,strong) MyHud *XuTohud;
@property(nonatomic,strong)XuanduoFishFeedModel*fishFeedModel;
@end
@@ -228,9 +229,9 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
cell.titleLabel.text = model.title;
NSLog(@"wendu str = %@",_wenduString);
model.temperatureLabel = _wenduString;
cell.temperaturelabel.text = model.temperatureLabel;
cell.temperaturelabel.text = [NSString stringWithFormat:@"%ld分钟",(self.fishFeedModel?[dataContorl hexToTen:self.fishFeedModel.feedTime]:0)];
[cell.temPSwitch addTarget:self action:@selector(xuTotempSwitchAction:) forControlEvents:UIControlEventTouchUpInside];
cell.temperaturelabel.hidden=YES;
// cell.temperaturelabel.hidden=YES;
cell.temPSwitch.hidden=YES;
cell.icon.hidden=NO;
cell.icon.image=[UIImage imageNamed:@"喂鱼"];
@@ -484,54 +485,15 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
_indexPath = indexPath;
if (indexPath.section==0) {
// _mypicView=[[MyPickerView alloc]init];
//
// _mypicView.frame=CGRectMake(0, 0, kScreenSize.width, kScreenSize.height);
// [self.view.window addSubview:_mypicView];
// [_mypicView.sureButton addTarget:self action:@selector(mypicViewRemoveByDone) forControlEvents:UIControlEventTouchUpInside];
// [self temperatureMainQueue];
}else if (indexPath.section==1){
if (indexPath.section==0&&indexPath.row==0){
//换水提醒日期选择
_remindPic=[[remindCyclePic alloc]initWithFrame:CGRectMake(0, 0, kScreenSize.width, kScreenSize.height) type:self.currentdevice.type];
_remindPic.type=@"temp";
_remindPic.frame=CGRectMake(0, 0, kScreenSize.width, kScreenSize.height);
_remindPic.type=self.currentdevice.type;
[self.view.window addSubview:_remindPic];
[_remindPic.sureBtn addTarget:self action:@selector(xuToremindCyclePicDone) forControlEvents:UIControlEventTouchUpInside];
[self huanShuiMainQueue];
}else if(indexPath.section-2==_titieArr.count){
//恒温设置
_remindPic=[[remindCyclePic alloc]initWithFrame:CGRectMake(0, 0, kScreenSize.width, kScreenSize.height) type:@"temp"];
_remindPic.type=@"temp";
_remindPic.frame=CGRectMake(0, 0, kScreenSize.width, kScreenSize.height);
[self.view.window addSubview:_remindPic];
[_remindPic.sureBtn addTarget:self action:@selector(xuToremindCyclePicDone) forControlEvents:UIControlEventTouchUpInside];
[self huanShuiMainQueue];
}else {
SetTimerCell *cell = [self.tableView cellForRowAtIndexPath:_indexPath];
if ([cell isKindOfClass:[PlusTableViewCell class]]) {
return;
}
else if([cell isKindOfClass:[SetTimerCell class]]&&[cell.model isKindOfClass:[XuanduoCycleModel class]])
{
//恒温设置
_cycleModel=cell.model;
_remindPic=[[remindCyclePic alloc]initWithFrame:CGRectMake(0, 0, kScreenSize.width, kScreenSize.height) type:@"cycle"];
_remindPic.type=@"cycle";
_remindPic.frame=CGRectMake(0, 0, kScreenSize.width, kScreenSize.height);
[self.view.window addSubview:_remindPic];
[_remindPic.sureBtn addTarget:self action:@selector(xuToremindCyclePicDone) forControlEvents:UIControlEventTouchUpInside];
[self huanShuiMainQueue];
}
else
{
[self addTimer:nil];
}
}
}
@@ -1610,27 +1572,21 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
NSString*string1=[dataContorl dataToHexString:data];
NSLog(@"return str == %@",string1);
NSString *readTimer = [string1 substringToIndex:4];
if (_selectSection-2<_titieArr.count && _selectSection-2>=0 && [readTimer isEqualToString:@"0116"]) {
if (!_timerModel) {
_timerModel = [[Xuanduo2TimerModel alloc] init];
_timerModel.groupModelArr = [NSMutableArray array];
}else {
[_timerModel.groupModelArr removeAllObjects];
}
[Xuanduo2DataUtility readTimerSocketDataWithBackMsgModel:_timerModel addWithBackStr:string1 type:self.currentdevice.type];
NSMutableArray *dataArr = [self.timeDic objectForKey:_titieArr[_selectSection-2]];
[dataArr removeAllObjects];
[dataArr addObject:plusflag];
[dataArr addObjectsFromArray:_timerModel.groupModelArr];
BOOL havePlus = [dataArr containsObject:plusflag];
if (havePlus && dataArr.count > 10) {
[dataArr removeObjectAtIndex:0];
}else if (!havePlus && dataArr.count < 10){
[dataArr insertObject:plusflag atIndex:0];
}
NSLog(@"dataarr.count = %ld",dataArr.count);
if ([readTimer isEqualToString:@"0116"])
{
NSString*lightNumber=[string1 substringWithRange:NSMakeRange(30, 2)];
if ([lightNumber isEqualToString:@"09"])//定时
{
XuanduoFishFeedModel*fishFeedModel=[[XuanduoFishFeedModel alloc]init];
fishFeedModel.feedTime=[string1 substringWithRange:NSMakeRange(32, 2)];
fishFeedModel.lightChooseStatus=[string1 substringWithRange:NSMakeRange(34, 1)];
fishFeedModel.lightOpenStatus=[string1 substringWithRange:NSMakeRange(35, 1)];
self.fishFeedModel=fishFeedModel;
}
}
else if (_selectSection-2<_titieArr.count && _selectSection-2>=0 && [readTimer isEqualToString:@"0119"]) {
@@ -1660,6 +1616,21 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
-(void)ifishDeviceLogInSuccees{
//读取一键喂鱼状态
ReadTimerModel *readModel = [[ReadTimerModel alloc] init];
readModel.sendmacId =self.currentdevice.macAddress;
readModel.resavemacId = self.currentdevice.macAddress;
readModel.crc16str=@"0000";
readModel.selectorNumber=@"09";
NSString*readString=[NSString stringWithFormat:@"%@%@%@",readModel.description,readModel.selectorNumber,readModel.crc16str];
NSData*readData=[dataContorl stringToHexData:readString];
[[Socketsingleton sharedInstance] soketWriteData:readData];
[_indicatorView startAnimating];
}
-(void)ifishSocket:(AsyncSocket *)sock didAcceptNewSocket:(AsyncSocket *)newSocket{