一键喂鱼

This commit is contained in:
kai60 2022-05-22 17:45:57 +08:00
parent 74076baf88
commit 2423e97bf8
7 changed files with 424 additions and 296 deletions

View File

@ -15,10 +15,13 @@
+(NSString *)ToHex:(long long int)tmpid;
/// 十进制转二进制,补全,截取特定位置
/// @param decimal 十进制
/// @param location 截取位数从末尾开始123...
/// @param location 截取位数从为开始0,12,3
/// @param totalLength 补全位数例如8位4位传0不会处理
+ (NSString *)getBinaryByDecimal:(NSInteger)decimal location:(NSInteger)location totalLength:(NSInteger)totalLength;
+ (NSString *)getBinaryByHex:(NSString*)decimal location:(NSInteger)location;
//+ (NSString *)getBinaryByDecimal:(NSInteger)num;
+ (NSString *)getBinaryByHex:(NSString *)hex;
+ (NSString *)getHexByBinary:(NSString *)binary;
//+ (NSString *)convertDecimalSystemFromBinarySystem:(NSString *)binary;
+(UInt64)hexToTen:(NSString*)str;
+(NSString *)groupNumberTohex:(NSInteger)number;
+(NSString *)stringFromHexString:(NSString *)hexString;

View File

@ -109,36 +109,14 @@
}
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";
+ (NSString *)getBinaryByHex:(NSString*)hex location:(NSInteger)location {
NSString *binary = @"0";
NSString*allBinary=[dataContorl getBinaryByHex:hex];
if (allBinary.length>=(location+1)) {
binary=[allBinary substringWithRange:NSMakeRange(location, 1)];
}
return binary;
}
/// 1 - 10
@ -201,6 +179,138 @@
return mac1;
}
/**
@param binary
@return
*/
+ (NSString *)convertDecimalSystemFromBinarySystem:(NSString *)binary
{
NSInteger ll = 0 ;
NSInteger temp = 0 ;
for (NSInteger i = 0; i < binary.length; i ++){
temp = [[binary substringWithRange:NSMakeRange(i, 1)] intValue];
temp = temp * powf(2, binary.length - i - 1);
ll += temp;
}
NSString * result = [NSString stringWithFormat:@"%ld",ll];
return result;
}
/**
@param decimal
@return
*/
+ (NSString *)getBinaryByDecimal:(NSInteger)decimal {
NSString *binary = @"";
while (decimal) {
binary = [[NSString stringWithFormat:@"%ld", (long)decimal % 2] stringByAppendingString:binary];
if (decimal / 2 < 1) {
break;
}
decimal = decimal / 2 ;
}
if (binary.length % 4 != 0) {
NSMutableString *mStr = [[NSMutableString alloc]init];;
for (int i = 0; i < 4 - binary.length % 4; i++) {
[mStr appendString:@"0"];
}
binary = [mStr stringByAppendingString:binary];
}
return binary;
}
/**
@param binary
@return
*/
+ (NSString *)getHexByBinary:(NSString *)binary {
NSMutableDictionary *binaryDic = [[NSMutableDictionary alloc] initWithCapacity:16];
[binaryDic setObject:@"0" forKey:@"0000"];
[binaryDic setObject:@"1" forKey:@"0001"];
[binaryDic setObject:@"2" forKey:@"0010"];
[binaryDic setObject:@"3" forKey:@"0011"];
[binaryDic setObject:@"4" forKey:@"0100"];
[binaryDic setObject:@"5" forKey:@"0101"];
[binaryDic setObject:@"6" forKey:@"0110"];
[binaryDic setObject:@"7" forKey:@"0111"];
[binaryDic setObject:@"8" forKey:@"1000"];
[binaryDic setObject:@"9" forKey:@"1001"];
[binaryDic setObject:@"A" forKey:@"1010"];
[binaryDic setObject:@"B" forKey:@"1011"];
[binaryDic setObject:@"C" forKey:@"1100"];
[binaryDic setObject:@"D" forKey:@"1101"];
[binaryDic setObject:@"E" forKey:@"1110"];
[binaryDic setObject:@"F" forKey:@"1111"];
if (binary.length % 4 != 0) {
NSMutableString *mStr = [[NSMutableString alloc]init];;
for (int i = 0; i < 4 - binary.length % 4; i++) {
[mStr appendString:@"0"];
}
binary = [mStr stringByAppendingString:binary];
}
NSString *hex = @"";
for (int i=0; i<binary.length; i+=4) {
NSString *key = [binary substringWithRange:NSMakeRange(i, 4)];
NSString *value = [binaryDic objectForKey:key];
if (value) {
hex = [hex stringByAppendingString:value];
}
}
return hex;
}
/**
@param hex
@return
*/
+ (NSString *)getBinaryByHex:(NSString *)hex {
NSMutableDictionary *hexDic = [[NSMutableDictionary alloc] initWithCapacity:16];
[hexDic setObject:@"0000" forKey:@"0"];
[hexDic setObject:@"0001" forKey:@"1"];
[hexDic setObject:@"0010" forKey:@"2"];
[hexDic setObject:@"0011" forKey:@"3"];
[hexDic setObject:@"0100" forKey:@"4"];
[hexDic setObject:@"0101" forKey:@"5"];
[hexDic setObject:@"0110" forKey:@"6"];
[hexDic setObject:@"0111" forKey:@"7"];
[hexDic setObject:@"1000" forKey:@"8"];
[hexDic setObject:@"1001" forKey:@"9"];
[hexDic setObject:@"1010" forKey:@"A"];
[hexDic setObject:@"1011" forKey:@"B"];
[hexDic setObject:@"1100" forKey:@"C"];
[hexDic setObject:@"1101" forKey:@"D"];
[hexDic setObject:@"1110" forKey:@"E"];
[hexDic setObject:@"1111" forKey:@"F"];
NSString *binary = @"";
for (int i=0; i<[hex length]; i++) {
NSString *key = [hex substringWithRange:NSMakeRange(i, 1)];
NSString *value = [hexDic objectForKey:key.uppercaseString];
if (value) {
binary = [binary stringByAppendingString:value];
}
}
return binary;
}
//
+ (NSString *)stringFromHexString:(NSString *)hexString { //
char *myBuffer = (char *)malloc((int)[hexString length] / 2 + 1);

View File

@ -39,11 +39,13 @@
<constraint firstAttribute="width" constant="30" id="wt7-Qr-eyY"/>
</constraints>
</imageView>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="UKV-VP-KnJ" userLabel="statusBtn">
<button hidden="YES" opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="UKV-VP-KnJ" userLabel="statusBtn">
<rect key="frame" x="154" y="2" width="67" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="关闭">
<backgroundConfiguration key="background"/>
<fontDescription key="titleFontDescription" type="system" pointSize="15"/>
</buttonConfiguration>
</button>

View File

@ -602,7 +602,10 @@ static NSString *cycleTimerflag = @"CycleTimerCell";
NSLog(@"read str = %@",readString);
NSData*readData=[dataContorl stringToHexData:readString];
[[Socketsingleton sharedInstance] soketWriteData:readData];
;
if (self.timerType==3)
{
[self readAllDayRecoveryMode];
}
}
else if ([group isKindOfClass: [XuanduoCycleModel class] ])
{
@ -644,8 +647,7 @@ static NSString *cycleTimerflag = @"CycleTimerCell";
//
- (void)allDayModesSwitchAction:(UIButton *)btn {
UIAlertController*alert=[UIAlertController alertControllerWithTitle:@"提示" message:@"确认开启全天自恢复模式吗?开启此模式后当手动关闭该设备时10分钟后该设备将自动打开" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction*okaction=[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
void(^switchModeBlock)(void)=^(void){
btn.selected=!btn.selected;
SetTimerModel *timerModel = [[SetTimerModel alloc] init];
timerModel.sendmacId =self.currentdevice.macAddress;
@ -663,24 +665,13 @@ static NSString *cycleTimerflag = @"CycleTimerCell";
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];
[self readAllDayRecoveryMode];
[self readTimer];
ReadTimerModel *readModel = [[ReadTimerModel alloc] init];
readModel.functionCode=@"16";
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];
};
UIAlertController*alert=[UIAlertController alertControllerWithTitle:@"提示" message:@"确认开启全天自恢复模式吗?开启此模式后当手动关闭该设备时10分钟后该设备将自动打开" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction*okaction=[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
switchModeBlock();
}];
UIAlertAction*cancelAction=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
@ -688,7 +679,15 @@ static NSString *cycleTimerflag = @"CycleTimerCell";
[alert addAction:okaction];
[alert addAction:cancelAction];
[self presentViewController:alert animated:YES completion:nil];
if (!btn.selected)//
{
[self presentViewController:alert animated:YES completion:nil];
}
else//
{
switchModeBlock();
}
@ -1679,6 +1678,11 @@ static NSString *cycleTimerflag = @"CycleTimerCell";
}
-(void)ifishDeviceLogInSuccees{
[self readTimer];//
}
-(void)readTimer
{
//
ReadTimerModel*readModel=self.readMode;
@ -1694,6 +1698,25 @@ static NSString *cycleTimerflag = @"CycleTimerCell";
}
}
-(void)readAllDayRecoveryMode
{
ReadTimerModel *readModel = [[ReadTimerModel alloc] init];
readModel.functionCode=@"16";
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];
}
-(void)ifishSocket:(AsyncSocket *)sock didAcceptNewSocket:(AsyncSocket *)newSocket{

View File

@ -236,6 +236,8 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
cell.icon.hidden=NO;
cell.icon.image=[UIImage imageNamed:@"喂鱼"];
cell.titileLabelLayout.constant=40;
cell.tempLabelLayout.constant=(kScreenWidth-38)/2.0-65-19;
cell.temperaturelabel.textAlignment=NSTextAlignmentCenter;
if (self.dataModel) {
Xuanduo2Model*model=self.dataModel;
if ([model.alarmSwitch isEqualToString:@"01"]) {
@ -414,13 +416,10 @@ 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) {
if (havePlus && indexPath.row == dataArr.count - 1) {
return 40;
}else{
return 50;
}
return 0;
}else {
return 0;
}
@ -466,14 +465,79 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
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.controlBtn setImage:[UIImage imageNamed:@"selectedImage"] forState:UIControlStateSelected];
[headerView.statusBtn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
[headerView.statusBtn setTitleColor:[UIColor grayColor] forState:UIControlStateSelected];
[headerView.statusBtn setBackgroundColor:[UIColor whiteColor]];
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.statusBtn addTarget:self action:@selector(statusChangeAction:) forControlEvents:UIControlEventTouchUpInside];
NSInteger location=0;
switch (section - 2) {
case 0: //
{
location = 3;
}
break;
case 1: //
{
location = 0;
}
break;
case 2: //1
{
location=1;
}
break;
case 3: //2
{
location = 2;
}
break;
case 4: //
{
location=5;
}
break;
case 5: //
{
location=4;
}
break;
default:
break;
}
NSString*choose=[dataContorl getBinaryByHex:self.fishFeedModel.lightChooseStatus location:location];
NSString*open=[dataContorl getBinaryByHex:self.fishFeedModel.lightOpenStatus location:location];
if ([open isEqualToString:@"1"])
{
headerView.statusBtn.selected=YES;
}
else
{
headerView.statusBtn.selected=NO;
}
if ([choose isEqualToString:@"1"])
{
headerView.controlBtn.selected=YES;
}
else
{
headerView.controlBtn.selected=NO;
}
[headerView configWithImageName:_imgArr[section-2] labelName:_titieArr[section-2]];
return headerView;
}
@ -487,10 +551,9 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
_indexPath = indexPath;
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=[[remindCyclePic alloc]initWithFrame:CGRectMake(0, 0, kScreenSize.width, kScreenSize.height) type:@"feed"];
_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];
@ -535,121 +598,143 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
#pragma mark - cell
//
- (void)foldAction:(UIButton *)btn {
_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)
_selectSection = btn.tag - kBtnTag;
btn.selected=!btn.selected;
NSInteger section= _selectSection;
NSInteger location=0;
switch (section - 2) {
case 0: //
{
readModel.functionCode=@"19";//
location = 3;
}
else
break;
case 1: //
{
readModel.functionCode=@"16";
location = 0;
}
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;
break;
case 2: //1
{
location=1;
}
NSString*readString=[NSString stringWithFormat:@"%@%@%@",readModel.description,readModel.selectorNumber,readModel.crc16str];
NSData*readData=[dataContorl stringToHexData:readString];
[[Socketsingleton sharedInstance] soketWriteData:readData];
self.readMode=readModel;
[_indicatorView startAnimating];
break;
case 3: //2
{
location = 2;
}
break;
case 4: //
{
location=5;
}
break;
case 5: //
{
location=4;
}
break;
default:
break;
}
NSString*binaryLightChooseStatus=[dataContorl getBinaryByHex:self.fishFeedModel.lightChooseStatus];
binaryLightChooseStatus =[binaryLightChooseStatus stringByReplacingCharactersInRange:NSMakeRange(location, 1) withString:btn.selected?@"1":@"0"];
NSString*hexLightChooseStatus=[dataContorl getHexByBinary:binaryLightChooseStatus];
self.fishFeedModel.lightChooseStatus=hexLightChooseStatus;
baseModel*readModel=[[baseModel alloc]init];
readModel.sendmacId =self.currentdevice.macAddress;
readModel.resavemacId =self.currentdevice.macAddress;
readModel.functionCode=@"15";
readModel.massagelegth=@"18";
NSString*readString=[NSString stringWithFormat:@"%@%@%@%@%@%@%@",readModel.description,@"09",self.fishFeedModel.feedTime,self.fishFeedModel.lightChooseStatus,self.fishFeedModel.lightOpenStatus,@"000000",@"0000"];
NSData*readData=[dataContorl stringToHexData:readString];
[[Socketsingleton sharedInstance] soketWriteData:readData];
[_indicatorView startAnimating];
[self readFishFeedModel];
}
//
-(void)statusChangeAction:(UIButton*)btn
{
_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)
_selectSection = btn.tag - kBtnTag;
btn.selected=!btn.selected;
NSInteger section= _selectSection;
NSInteger location=0;
switch (section - 2) {
case 0: //
{
readModel.functionCode=@"19";//
location = 3;
}
else
break;
case 1: //
{
readModel.functionCode=@"16";
location = 0;
}
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;
break;
case 2: //1
{
location=1;
}
NSString*readString=[NSString stringWithFormat:@"%@%@%@",readModel.description,readModel.selectorNumber,readModel.crc16str];
NSData*readData=[dataContorl stringToHexData:readString];
[[Socketsingleton sharedInstance] soketWriteData:readData];
self.readMode=readModel;
[_indicatorView startAnimating];
break;
case 3: //2
{
location = 2;
}
break;
case 4: //
{
location=5;
}
break;
case 5: //
{
location=4;
}
break;
default:
break;
}
NSString*binaryLightOpenStatus=[dataContorl getBinaryByHex:self.fishFeedModel.lightOpenStatus];
binaryLightOpenStatus =[binaryLightOpenStatus stringByReplacingCharactersInRange:NSMakeRange(location, 1) withString:btn.selected?@"1":@"0"];
NSString*hexBinaryLightOpenStatus=[dataContorl getHexByBinary:binaryLightOpenStatus];
self.fishFeedModel.lightOpenStatus=hexBinaryLightOpenStatus;
baseModel*readModel=[[baseModel alloc]init];
readModel.sendmacId =self.currentdevice.macAddress;
readModel.resavemacId =self.currentdevice.macAddress;
readModel.functionCode=@"15";
readModel.massagelegth=@"18";
NSString*readString=[NSString stringWithFormat:@"%@%@%@%@%@%@%@",readModel.description,@"09",self.fishFeedModel.feedTime,self.fishFeedModel.lightChooseStatus,self.fishFeedModel.lightOpenStatus,@"000000",@"0000"];
NSData*readData=[dataContorl stringToHexData:readString];
[[Socketsingleton sharedInstance] soketWriteData:readData];
[_indicatorView startAnimating];
[self readFishFeedModel];
}
@ -1189,13 +1274,12 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
#pragma mark
-(void)huanShuiMainQueue{
if (_indexPath.section-2==_titieArr.count)
if ([_remindPic.type isEqualToString:@"feed"])
{
Xuanduo3fModel*model3=self.dataModel;
int mac=[dataContorl hexToTen:model3.heatingTemperature];
//float TPlabel=mac/10+(mac%10)*0.1;
NSInteger temp = mac/10.0;
int temp=[dataContorl hexToTen:self.fishFeedModel.feedTime];
if (temp<1)
{
temp=1;
@ -1254,140 +1338,41 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
-(void)xuToremindCyclePicDone{
if (_indexPath.section==1) {
ChangeWaterCell*cell=[self.tableView cellForRowAtIndexPath:_indexPath];
NSString *str=_remindPic.picViewResultString;
if (str==nil) {
//str=@"1";
NSLog(@"ni hua dong tai kuai");
str=[NSString stringWithFormat:@"%ld",(long)self.waterInfmodel.remindcycle];
NSString*title=@"请设置换水天数";
if ([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
title=@"请设置杀菌天数";
}
[_remindPic makeToast:title];
return;
}
cell.huanshuiDaylabel.text=[NSString stringWithFormat:@"%@天",str];
//
[IFISHHTTPTOOL setRemindWaterInfWith:[NSString stringWithFormat:@"%@_%@",self.currentdevice.deviceId,self.currentdevice.type]
waterRemind:@"1" remindCycle:str
huishuiShiJian:^(setRemindWaterModel *remindModel) {
self.nextChangeDateLabel=remindModel.remindDate;
self.waterInfmodel.waterremind=@"1";
self.waterInfmodel.remindDate=remindModel.remindDate;
self.waterInfmodel.remindcycle = remindModel.remindcycle;
[self.tableView reloadData];
}];
NSUserDefaults*defuat=[NSUserDefaults standardUserDefaults];
[defuat setValue:str forKey:@"xuto2picResult"];
[defuat synchronize];
[_remindPic removeFromSuperview];
}
else if (_indexPath.section-2==_titieArr.count)
{
TemperatureSetCell*cell=[self.tableView cellForRowAtIndexPath:_indexPath];
NSString *str=_remindPic.picViewResultString;
if (str==nil) {
//str=@"1";
NSLog(@"ni hua dong tai kuai");
str=[NSString stringWithFormat:@"%ld",(long)self.waterInfmodel.remindcycle];
NSString*title=@"请设置换水天数";
if ([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
title=@"请设置杀菌天数";
}
NSString*title=@"请喂鱼时间";
[_remindPic makeToast:title];
return;
}
cell.temperaturelabel.text=[NSString stringWithFormat:@"%.1f℃",str.floatValue];
//
;
self.fishFeedModel.feedTime=[dataContorl leftAddZero:2 andStr:[dataContorl ToHex:str.integerValue]];
[_remindPic removeFromSuperview];
baseModel*tempModel=[[baseModel alloc]init];
tempModel.sendmacId =self.currentdevice.macAddress;
tempModel.resavemacId =self.currentdevice.macAddress;
tempModel.functionCode=@"0e";
tempModel.massagelegth=@"13";
cell.temperaturelabel.text=[NSString stringWithFormat:@"%ld分钟",(self.fishFeedModel?[dataContorl hexToTen:self.fishFeedModel.feedTime]:0)];
int intString = [str intValue];
int newIntString=intString*10;
NSString*temp =[dataContorl tpIntStringToFourHex:newIntString];
NSString*minString=[NSString stringWithFormat:@"%@%@%@",tempModel.description,temp,@"0000"];
NSLog(@"minstring = %@",minString);
NSData*tempData=[dataContorl stringToHexData:minString];
[[Socketsingleton sharedInstance] soketWriteData:tempData];
}
else if ([_remindPic.type isEqualToString:@"cycle"])
{
SetTimerCell*cell=[self.tableView cellForRowAtIndexPath:_indexPath];
NSString *str=_remindPic.picViewResultString;
if (str==nil) {
//str=@"1";
NSLog(@"ni hua dong tai kuai");
str=[NSString stringWithFormat:@"%ld",(long)self.waterInfmodel.remindcycle];
[_remindPic makeToast:@"请设置杀菌持续时间"];
return;
}
cell.timerLabel.text=[NSString stringWithFormat:@"%d分钟",str.intValue];
//
;
[_remindPic removeFromSuperview];
baseModel*tempModel=[[baseModel alloc]init];
tempModel.sendmacId =self.currentdevice.macAddress;
tempModel.resavemacId =self.currentdevice.macAddress;
tempModel.functionCode=@"18";
tempModel.massagelegth=@"17";
int intString = [str intValue];
NSString*hex=[dataContorl ToHex:intString];
NSString*temp =[dataContorl leftAddZero:4 andStr:hex];
_cycleModel.lastTime=temp;
NSString*minString=[NSString stringWithFormat:@"%@%@%@%@%@%@",tempModel.description,_cycleModel.lightNumber,_cycleModel.lastTime,_cycleModel.gapTime,_cycleModel.status,@"0000"];
NSLog(@"minstring = %@",minString);
NSData*tempData=[dataContorl stringToHexData:minString];
[[Socketsingleton sharedInstance] soketWriteData:tempData];
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.functionCode=@"15";
readModel.massagelegth=@"18";
NSString*readString=[NSString stringWithFormat:@"%@%@%@%@%@%@%@",readModel.description,@"09",self.fishFeedModel.feedTime,self.fishFeedModel.lightChooseStatus,self.fishFeedModel.lightOpenStatus,@"000000",@"0000"];
NSData*readData=[dataContorl stringToHexData:readString];
[[Socketsingleton sharedInstance] soketWriteData:readData];
;
[self readFishFeedModel];
}
}
#pragma mark
@ -1580,8 +1565,8 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
{
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)];
fishFeedModel.lightChooseStatus=[string1 substringWithRange:NSMakeRange(34, 2)];
fishFeedModel.lightOpenStatus=[string1 substringWithRange:NSMakeRange(36, 2)];
self.fishFeedModel=fishFeedModel;
@ -1590,12 +1575,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
}
else if (_selectSection-2<_titieArr.count && _selectSection-2>=0 && [readTimer isEqualToString:@"0119"]) {
_cycleModel=[[XuanduoCycleModel alloc]init];
[Xuanduo2DataUtility readCycleSocketDataWithBackMsgModel:_cycleModel addWithBackStr:string1 type:self.currentdevice.type];
NSMutableArray *dataArr = [self.timeDic objectForKey:_titieArr[_selectSection-2]];
[dataArr removeAllObjects];
[dataArr addObject:_cycleModel];
@ -1616,6 +1596,15 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
-(void)ifishDeviceLogInSuccees{
[self readFishFeedModel];
}
-(void)readFishFeedModel
{
if (!self.fishFeedModel)
{
self.fishFeedModel=[[XuanduoFishFeedModel alloc]init];
}
//
ReadTimerModel *readModel = [[ReadTimerModel alloc] init];
readModel.sendmacId =self.currentdevice.macAddress;
@ -1629,8 +1618,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
NSData*readData=[dataContorl stringToHexData:readString];
[[Socketsingleton sharedInstance] soketWriteData:readData];
[_indicatorView startAnimating];
}
-(void)ifishSocket:(AsyncSocket *)sock didAcceptNewSocket:(AsyncSocket *)newSocket{

View File

@ -13,6 +13,7 @@
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *temperaturelabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *tempLabelLayout;
//@property (weak, nonatomic) IBOutlet UISwitch *tempSwitch;
@property (weak, nonatomic) IBOutlet UIButton *temPSwitch;

View File

@ -64,6 +64,7 @@
<connections>
<outlet property="icon" destination="hEW-4g-UYf" id="8Q2-e9-cwD"/>
<outlet property="temPSwitch" destination="U9D-Nd-wVC" id="JR3-5b-l1R"/>
<outlet property="tempLabelLayout" destination="KiI-X3-nhs" id="mgA-Yw-Khc"/>
<outlet property="temperaturelabel" destination="ldH-Zi-Nv3" id="eg6-Cm-jgD"/>
<outlet property="titileLabelLayout" destination="vt1-8R-3pK" id="CaU-Jo-Ukd"/>
<outlet property="titleLabel" destination="0CU-uJ-mzK" id="xFm-He-KNJ"/>