读取一键喂鱼
This commit is contained in:
parent
76e8cf7561
commit
50628a8404
|
|
@ -13,6 +13,12 @@
|
|||
+(NSData *) stringToHexData:(NSString*)string;
|
||||
+(NSString *)hexStringFromString:(NSString *)string;
|
||||
+(NSString *)ToHex:(long long int)tmpid;
|
||||
/// 十进制转二进制,补全,截取特定位置
|
||||
/// @param decimal 十进制
|
||||
/// @param location 截取位数从末尾开始1,2,3...
|
||||
/// @param totalLength 补全位数,例如8位,4位,传0不会处理
|
||||
+ (NSString *)getBinaryByDecimal:(NSInteger)decimal location:(NSInteger)location totalLength:(NSInteger)totalLength;
|
||||
|
||||
+(UInt64)hexToTen:(NSString*)str;
|
||||
+(NSString *)groupNumberTohex:(NSInteger)number;
|
||||
+(NSString *)stringFromHexString:(NSString *)hexString;
|
||||
|
|
|
|||
|
|
@ -109,7 +109,38 @@
|
|||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
+ (NSString *)getBinaryByDecimal:(NSInteger)decimal location:(NSInteger)location totalLength:(NSInteger)totalLength {
|
||||
NSString *binary = @"";
|
||||
if (decimal != 0) {
|
||||
while (decimal) {
|
||||
binary = [[NSString stringWithFormat:@"%ld", decimal % 2] stringByAppendingString:binary];
|
||||
if (decimal / 2 < 1) {
|
||||
break;
|
||||
}
|
||||
decimal = decimal / 2 ;
|
||||
}
|
||||
// 根据需求传位数
|
||||
if (totalLength > 0) {
|
||||
if (binary.length % totalLength != 0) {
|
||||
NSMutableString *mStr = [[NSMutableString alloc]init];
|
||||
for (int i = 0; i < totalLength - binary.length % totalLength; i++) {
|
||||
[mStr appendString:@"0"];
|
||||
}
|
||||
binary = [mStr stringByAppendingString:binary];
|
||||
}
|
||||
}
|
||||
// 保护
|
||||
if (binary.length > 0 && binary.length >= location) {
|
||||
// 截取特定位置的二进制字符
|
||||
binary = [binary substringWithRange:NSMakeRange(binary.length-location, 1)];
|
||||
} else {
|
||||
binary = @"0";
|
||||
}
|
||||
} else {
|
||||
binary = @"0";
|
||||
}
|
||||
return binary;
|
||||
}
|
||||
/// 1 - 10组
|
||||
+(NSString *)groupNumberTohex:(NSInteger)number{
|
||||
NSString *str = @"";
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -52,6 +52,9 @@
|
|||
else if ([self.type isEqualToString:@"temp"]) {
|
||||
title.text=@"恒温设置";
|
||||
}
|
||||
else if ([self.type isEqualToString:@"feed"]) {
|
||||
title.text=@"喂鱼时长";
|
||||
}
|
||||
else if ([self.type isEqualToString:@"cycle"]) {
|
||||
title.text=@"杀菌持续时长";
|
||||
}
|
||||
|
|
@ -125,6 +128,11 @@ _picArr=@[@[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"13"
|
|||
{
|
||||
_picArr=@[@[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23",@"24",@"25",@"26",@"27",@"28",@"29",@"30"]];
|
||||
}
|
||||
else if ([self.type isEqualToString:@"feed"])
|
||||
{
|
||||
_picArr=@[@[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",@"20",@"21",@"22",@"23",@"24",@"25",@"26",@"27",@"28",@"29",@"30",@"31",@"32",@"33",@"34",@"35",@"36",@"37",@"38",@"39",@"40",@"41",@"42",@"43",@"44",@"45",@"46",@"47",@"48",@"49",@"50",@"51",@"52",@"53",@"54",@"55",@"56",@"57",@"58",@"59",@"60"]];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue