打开和关闭一键 喂鱼

This commit is contained in:
祝发冬 2022-05-29 18:41:35 +08:00
parent d00aff3ccd
commit fa81a11902
2 changed files with 91 additions and 12 deletions

View File

@ -30,6 +30,7 @@
#import "UIImage+WaterMark.h"
#import "XuanduoSettingController.h"
#import "XuanduoElectricityController.h"
#import "XuanduofishFeedViewController.h"
#define kBtnTag 100
@ -72,6 +73,7 @@
@property(nonatomic,assign) NSInteger heartCount;
@property (weak, nonatomic) IBOutlet UILabel *waterLever;
@property(nonatomic,strong)XuanduoFishFeedModel*fishFeedModel;
@ -340,6 +342,55 @@
uvsel=[uvsel imageWaterMarkWithString:stringTemp rect:CGRectMake(140, 60, 60, 60) attribute:@{NSForegroundColorAttributeName:[UIColor redColor],NSFontAttributeName:[UIFont systemFontOfSize:30]}];
// [self.light1 setImage:uvsel forState:UIControlStateSelected];
}
}else 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, 2)];
fishFeedModel.lightOpenStatus=[string1 substringWithRange:NSMakeRange(36, 2)];
self.fishFeedModel=fishFeedModel;
NSString*tips=@"";
if ([self.fishFeedModel.lightChooseStatus isEqualToString:@"00"]&&[self.fishFeedModel.lightOpenStatus isEqualToString:@"00"])
{
tips=@"请先添加喂鱼设置";
}
else if ([self.dataModel.fishFeedStatus isEqualToString:@"00"])
{
tips=@"您确定要立即喂鱼吗?";
}
else if ([self.dataModel.fishFeedStatus isEqualToString:@"01"])
{
tips=@"您确定要立即关闭喂鱼功能吗?";
}
UIAlertController*alert=[UIAlertController alertControllerWithTitle:@"提示" message:tips preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction*okaction=[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
if ([self.fishFeedModel.lightChooseStatus isEqualToString:@"00"]&&[self.fishFeedModel.lightOpenStatus isEqualToString:@"00"])
{
XuanduofishFeedViewController *_settingVC = [[XuanduofishFeedViewController alloc] init];
_settingVC.currentdevice = self.currentDevice;
_settingVC.dataModel = self.dataModel;
[self.navigationController pushViewController:_settingVC animated:YES];
}
else
{
[self changeFeedStatus];
}
}];
UIAlertAction*cancelAction=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}];
[alert addAction:okaction];
[alert addAction:cancelAction];
[self presentViewController:alert animated:YES completion:nil];
}
}
else
@ -444,6 +495,10 @@
[self readCycleWithNumber:@"03"];
self.heartCount=0;
}
else if ([self.currentDevice.type isEqualToString:DECICE_TYPE_XUANDUO4F]||[self.currentDevice.type isEqualToString:DECICE_TYPE_XUANDUO5F])
{
}
}
@ -517,19 +572,8 @@
if ([self.currentDevice.type isEqualToString:DECICE_TYPE_XUANDUO4F]||[self.currentDevice.type isEqualToString:DECICE_TYPE_XUANDUO5F])//
{
sender.selected=!sender.selected;
baseModel*readModel=[[baseModel alloc]init];
readModel.sendmacId =self.currentDevice.macAddress;
readModel.resavemacId =self.currentDevice.macAddress;
readModel.functionCode=@"0c";
readModel.massagelegth=@"12";
NSString*readString=[NSString stringWithFormat:@"%@%@%@",readModel.description,[self.dataModel.fishFeedStatus isEqualToString:@"00"]?@"01":@"00",@"0000"];
NSData*readData=[dataContorl stringToHexData:readString];
[[Socketsingleton sharedInstance] soketWriteData:readData];
[_indicatorView startAnimating];
[self readFishFeedModel];//
}
@ -549,6 +593,22 @@
}
}
}
//
-(void)changeFeedStatus
{
baseModel*readModel=[[baseModel alloc]init];
readModel.sendmacId =self.currentDevice.macAddress;
readModel.resavemacId =self.currentDevice.macAddress;
readModel.functionCode=@"0c";
readModel.massagelegth=@"12";
NSString*readString=[NSString stringWithFormat:@"%@%@%@",readModel.description,[self.dataModel.fishFeedStatus isEqualToString:@"00"]?@"01":@"00",@"0000"];
NSData*readData=[dataContorl stringToHexData:readString];
[[Socketsingleton sharedInstance] soketWriteData:readData];
[_indicatorView startAnimating];
}
- (IBAction)btnActions:(UIButton *)btn {
if (self.dataModel.gasPump) {
@ -692,6 +752,23 @@
}
}
-(void)readFishFeedModel
{
//
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];
}
#pragma mark - -
- (void)sureBtnClick:(UIButton *)btn {
NSLog(@"%@******** _wenduPicview.picViewResultString",_wenduPicview.picViewResultString);

View File

@ -159,6 +159,8 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
self.tableView.delegate=self;
self.tableView.dataSource=self;
self.tableView.backgroundColor=COLOR_MIAN;
self.tableView.layer.cornerRadius=8;
ElectricityView*header=[ElectricityView viewFromXib];
self.tableView.tableHeaderView=header;
self.headerView=header;