diff --git a/Ifish/controllers/ConnectAauariumVC/ConnectingAquarVC.m b/Ifish/controllers/ConnectAauariumVC/ConnectingAquarVC.m
index 04b4ec7..ab3b55b 100644
--- a/Ifish/controllers/ConnectAauariumVC/ConnectingAquarVC.m
+++ b/Ifish/controllers/ConnectAauariumVC/ConnectingAquarVC.m
@@ -505,6 +505,14 @@ Copy NSString *deviceId;
self.HUD.labelText = @"绑定失败";
[self.HUD hide:YES afterDelay:2];
}
+ else
+ {
+ [self appendTrakContent:@"绑定返回状态码错误。设备信息为:%@"];
+
+ self.bakbutton.userInteractionEnabled=YES;
+ self.HUD.labelText = [NSString stringWithFormat:@"绑定失败:%@",resultDic[@"result"]];
+ [self.HUD hide:YES afterDelay:2];
+ }
} failure:^(NSError *err) {
diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2DataUtility.h b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2DataUtility.h
index e725d98..5352877 100644
--- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2DataUtility.h
+++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2DataUtility.h
@@ -13,7 +13,8 @@
#import "xuanduo3fModel.h"
NS_ASSUME_NONNULL_BEGIN
-
+
+typedef void (^SocketAckBlock) (NSString*ack,NSString*funcCode,NSString* header,NSInteger length);
@interface Xuanduo2DataUtility : NSObject
+(void)readSocketDataWithBackMsgModel:(id)xuanduoModel addWithBackData:(NSData*)data type:(NSString*)type;
diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2TimerModel.h b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2TimerModel.h
index b0bc701..ae5fc22 100644
--- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2TimerModel.h
+++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2TimerModel.h
@@ -63,5 +63,14 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, strong) NSString *gapTime;
@property (nonatomic, strong) NSString *status;
+@end
+@interface XuanduoTimerTypeModel : NSObject
+
+/// 灯的序号
+@property (nonatomic, strong) NSString *lightNumber;
+//定时模式
+@property (nonatomic, strong) NSString *type;
+
+
@end
NS_ASSUME_NONNULL_END
diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2TimerModel.m b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2TimerModel.m
index 358f081..a6b7ca4 100644
--- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2TimerModel.m
+++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2TimerModel.m
@@ -18,5 +18,15 @@
@implementation XuanduoCycleModel
+@end
+@implementation XuanduoRecoveryModel
+
+
+
+@end
+@implementation XuanduoTimerTypeModel
+
+
+
@end
diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2fController.m b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2fController.m
index 6351939..53299e1 100644
--- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2fController.m
+++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/Xuanduo2fController.m
@@ -610,7 +610,7 @@
_wenduPicview.wenDuPicviewDelegate = self;
NSString *stateStr =nil;
NSString*status;
- if ([self.currentDevice.type isEqualToString:DECICE_TYPE_XUANDUO2F])
+ if ([self.currentDevice.type isEqualToString:DECICE_TYPE_XUANDUO2F]||[self.currentDevice.type isEqualToString:DECICE_TYPE_XUANDUO4F]||[self.currentDevice.type isEqualToString:DECICE_TYPE_XUANDUO5F])
{
status=((Xuanduo2Model*)self.dataModel).status;
}
diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoSelectHeader.h b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoSelectHeader.h
index a3be72c..0fc6a87 100644
--- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoSelectHeader.h
+++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoSelectHeader.h
@@ -14,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (instancetype)shareHeaderView;
@property (weak, nonatomic) IBOutlet UIButton *controlBtn;
+//一键喂鱼开关状态按钮
+@property (weak, nonatomic) IBOutlet UIButton *statusBtn;
@property (weak, nonatomic) IBOutlet UIImageView *backImageView;
- (void)configWithImageName:(NSString *)name labelName:(NSString *)labelName;
diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoSelectHeader.m b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoSelectHeader.m
index c0d0c51..9c1683b 100644
--- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoSelectHeader.m
+++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoSelectHeader.m
@@ -24,6 +24,9 @@
{
self.userInteractionEnabled=YES;
+ [self.statusBtn setTitle:@"关闭" forState:UIControlStateNormal];
+ [self.statusBtn setTitle:@"打开" forState:UIControlStateNormal];
+
}
- (void)configWithImageName:(NSString *)name labelName:(NSString *)labelName {
self.imageView.image = [UIImage imageNamed:name];
diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoSelectHeader.xib b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoSelectHeader.xib
index 2d00bf2..f913ecd 100644
--- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoSelectHeader.xib
+++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoSelectHeader.xib
@@ -39,6 +39,14 @@
+
@@ -61,6 +69,7 @@
+
diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerListViewController.m b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerListViewController.m
index 6244143..1d93135 100644
--- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerListViewController.m
+++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerListViewController.m
@@ -44,11 +44,15 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
@interface XuanduoTimerListViewController ()
@property(nonatomic,strong) setRemindWaterModel *waterInfmodel;
@property(nonatomic,strong) Xuanduo2TimerModel *timerModel;
+@property(nonatomic,strong) XuanduoTimerTypeModel *timerType;
+
@property(nonatomic,strong) XuanduoCycleModel *cycleModel;
@property (nonatomic,strong) NSMutableDictionary *timeDic;
@property(nonatomic,copy) NSString *nextChangeDateLabel;
@property(nonatomic,strong) MyHud *XuTohud;
+//SOCKET交互block
+@property(nonatomic,strong) NSMutableDictionary *blockDict;
@end
@@ -123,7 +127,10 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
float formatheigh = heighten/10;
_wenduString = [NSString stringWithFormat:@"%.0f~%.0f°C",formatlow,formatheigh];
}
-
+-(void)setupData
+{
+ self.blockDict=[[NSMutableDictionary alloc]init];
+}
- (void)setupTable {
XuToControlName *name = [UserExtendataArchaver currentNewXuToControlName:self.currentdevice.macAddress];
@@ -342,6 +349,21 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
if (!cell) {
cell=[[TimerTypeTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:timerTypeFlag];
}
+ cell.timerbtn.selected=NO;
+ cell.recoverybtn.selected=NO;
+
+ cell.cyclebtn.selected=NO;
+ if ([_timerType.type isEqualToString:@"08"]) {
+ cell.timerbtn.selected=YES;
+ }
+ else if ([_timerType.type isEqualToString:@"04"]) {
+ cell.cyclebtn.selected=YES;
+ }
+ else if ([_timerType.type isEqualToString:@"02"]||[_timerType.type isEqualToString:@"01"]||[_timerType.type isEqualToString:@"00"])
+ {
+ cell.recoverybtn.selected=YES;
+ }
+
cell.delegate=self;
return cell;
}else {
@@ -605,51 +627,38 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
_selectSection = -1;
[self.tableView reloadData];
}else {
+ //读取开关定时
_selectSection = btn.tag - kBtnTag;
ReadTimerModel *readModel = [[ReadTimerModel alloc] init];
//杀菌不定时
readModel.selectorName=_titieArr[_selectSection - 2];
- if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F]&&(_selectSection - 2)==2)
- {
- readModel.functionCode=@"19";//读取
- }
- else
- {
- readModel.functionCode=@"16";
- }
+
+ readModel.functionCode=@"16";
+
readModel.sendmacId =self.currentdevice.macAddress;
readModel.resavemacId = self.currentdevice.macAddress;
readModel.crc16str=@"0000";
switch (_selectSection - 2) {
case 0: //循环泵 或 照明
- readModel.selectorNumber = @"04";
- if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
- {
- readModel.selectorNumber=@"01";
- }
+ readModel.selectorNumber = @"f4";
+
break;
case 1: //增氧
- readModel.selectorNumber = @"01";
- if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
- {
- readModel.selectorNumber=@"02";
- }
+ readModel.selectorNumber = @"f1";
+
break;
case 2: //灯光1
- readModel.selectorNumber = @"02";
- if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
- {
- readModel.selectorNumber=@"03";
- }
+ readModel.selectorNumber = @"f2";
+
break;
case 3: //灯光2
- readModel.selectorNumber = @"03";
+ readModel.selectorNumber = @"f3";
break;
case 4: //造浪泵
- readModel.selectorNumber = @"06";
+ readModel.selectorNumber = @"f6";
break;
case 5: // 杀菌灯
- readModel.selectorNumber = @"05";
+ readModel.selectorNumber = @"f5";
break;
default:
break;
@@ -1582,24 +1591,51 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
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];
+ NSString*lightNumber=[string1 substringWithRange:NSMakeRange(30, 2)];
+
+ //定时模式
+ if ([lightNumber.uppercaseString containsString:@"F"])
+ {
+ _timerType=[[XuanduoTimerTypeModel alloc]init];
+ _timerType.lightNumber=lightNumber;
+ _timerType.type=[string1 substringWithRange:NSMakeRange(32, 2)];
+ NSMutableArray *dataArr = [self.timeDic objectForKey:_titieArr[_selectSection-2]];
+ [dataArr removeAllObjects];
+ [dataArr addObject:plusflag];
+
+ BOOL havePlus = [dataArr containsObject:plusflag];
+ if (havePlus && dataArr.count > 10) {
+ [dataArr removeObjectAtIndex:0];
+ }else if (!havePlus && dataArr.count < 10){
+ [dataArr insertObject:plusflag atIndex:0];
+ }
+
+
}
- [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];
+ else if (0)
+ {
+ 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);
+
}
- NSLog(@"dataarr.count = %ld",dataArr.count);
+
+
}
@@ -1615,6 +1651,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
}
+
if ([readTimer isEqualToString:@"0108"] || [readTimer isEqualToString:@"0105"]) {
[Xuanduo2DataUtility readSocketDataWithBackMsgModel:self.dataModel addWithBackData:data type:self.currentdevice.type];
[self refreshWithData:self.dataModel];
diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.m b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.m
index de648d5..94d1733 100644
--- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.m
+++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoTimerSettingViewController.m
@@ -132,7 +132,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
}
else if(self.timerType==3)
{
- type=@"自恢复模式";
+ type=@"定时自恢复模式";
}
_titieArr = @[type];
@@ -186,7 +186,8 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
NSArray *dataArr = [self.timeDic objectForKey:_titieArr[0]];
return dataArr.count;
}
- else{
+ else
+ {
return 0;
}
}
@@ -347,7 +348,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
CGFloat height=0;
- height=section==0?50:40;
+ height=(section==0?50:40);
return height;
}
@@ -378,6 +379,21 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
return nil;
}
+-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
+{
+ CGFloat height=0;
+ if (section==0)
+ {
+ height=40;
+ }
+ return height;
+}
+- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
+{
+ UIView *oneHeader = [[UIView alloc] init];
+ oneHeader.backgroundColor = COLOR_MIAN;
+ return oneHeader;
+}
#pragma mark tableView 点击事件
diff --git a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduofishFeedViewController.m b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduofishFeedViewController.m
index 0ac18b2..31da30f 100644
--- a/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduofishFeedViewController.m
+++ b/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduofishFeedViewController.m
@@ -443,10 +443,16 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
}else if(section == 2){
XuanduoSelectHeader *headerView = [XuanduoSelectHeader shareHeaderView];
headerView.controlBtn.tag = kBtnTag + section;
+ headerView.statusBtn.tag = kBtnTag + section;
+ [headerView.controlBtn setImage:[UIImage imageNamed:@"normalImage"] forState:UIControlStateNormal];
+ [headerView.controlBtn setImage:[UIImage imageNamed:@"selectedImage"] forState:UIControlStateNormal];
+
+ headerView.statusBtn.hidden=NO;
if (_selectSection == section) {
headerView.controlBtn.selected = YES;
}
[headerView.controlBtn addTarget:self action:@selector(foldAction:) forControlEvents:UIControlEventTouchUpInside];
+ [headerView.controlBtn addTarget:self action:@selector(statusChangeAction:) forControlEvents:UIControlEventTouchUpInside];
[headerView configWithImageName:_imgArr[section-2] labelName:_titieArr[section-2]];
return headerView;
}else if(section == 3){
@@ -661,6 +667,69 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
[_indicatorView startAnimating];
}
}
+//改变一键喂鱼的开关状态
+-(void)statusChangeAction:(UIButton*)btn
+{
+ if (_selectSection == btn.tag - kBtnTag) {
+ _selectSection = -1;
+ [self.tableView reloadData];
+ }else {
+ _selectSection = btn.tag - kBtnTag;
+ ReadTimerModel *readModel = [[ReadTimerModel alloc] init];
+ //杀菌不定时
+ readModel.selectorName=_titieArr[_selectSection - 2];
+ if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F]&&(_selectSection - 2)==2)
+ {
+ readModel.functionCode=@"19";//读取
+ }
+ else
+ {
+ readModel.functionCode=@"16";
+ }
+ readModel.sendmacId =self.currentdevice.macAddress;
+ readModel.resavemacId = self.currentdevice.macAddress;
+ readModel.crc16str=@"0000";
+ switch (_selectSection - 2) {
+ case 0: //循环泵 或 照明
+ readModel.selectorNumber = @"04";
+ if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
+ {
+ readModel.selectorNumber=@"01";
+ }
+ break;
+ case 1: //增氧
+ readModel.selectorNumber = @"01";
+ if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
+ {
+ readModel.selectorNumber=@"02";
+ }
+ break;
+ case 2: //灯光1
+ readModel.selectorNumber = @"02";
+ if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
+ {
+ readModel.selectorNumber=@"03";
+ }
+ break;
+ case 3: //灯光2
+ readModel.selectorNumber = @"03";
+ break;
+ case 4: //造浪泵
+ readModel.selectorNumber = @"06";
+ break;
+ case 5: // 杀菌灯
+ readModel.selectorNumber = @"05";
+ break;
+ default:
+ break;
+ }
+ NSString*readString=[NSString stringWithFormat:@"%@%@%@",readModel.description,readModel.selectorNumber,readModel.crc16str];
+ NSData*readData=[dataContorl stringToHexData:readString];
+ [[Socketsingleton sharedInstance] soketWriteData:readData];
+ self.readMode=readModel;
+ [_indicatorView startAnimating];
+ }
+}
- (void)switchAction:(UIButton *)btn {
NSInteger index = btn.tag - kSwitchBtnTag;