新版本
This commit is contained in:
@@ -12,29 +12,127 @@
|
||||
#import "IFishWaterChangeView.h"
|
||||
#import "UIView+GetView.h"
|
||||
#import "IfishHistoryView.h"
|
||||
#import "AFHttpTool.h"
|
||||
#import "IfishHotBarVc.h"
|
||||
#import "MJExtension.h"
|
||||
#import "Socketsingleton.h"
|
||||
#import "IfishHotBarPackegeVo.h"
|
||||
#import "Toast+UIView.h"
|
||||
#import "IfishHotBarModifyNameVc.h"
|
||||
#import "searchDeviceModel.h"
|
||||
#import "IfishHotBarHeader.h"
|
||||
#import "IfishCameraModel.h"
|
||||
#import "SVProgressHUD.h"
|
||||
|
||||
#define HOTBARCELL @"hotBarCell"
|
||||
|
||||
|
||||
@interface IfishHotBarVc ()<UITableViewDelegate,UITableViewDataSource,ChangeWaterDelegate>
|
||||
@property (weak, nonatomic) IBOutlet UITableView *tableView;
|
||||
@interface IfishHotBarVc ()<UITableViewDelegate,UITableViewDataSource,ChangeWaterDelegate,IfishHistoryViewBottomBarDelete>
|
||||
@property (weak, nonatomic) IBOutlet UITableView *mainTableView;
|
||||
@property(nonatomic,strong)NSMutableArray*datas;
|
||||
@property(nonatomic,strong)IFishWaterChangeView*changeWaterView;
|
||||
@property(nonatomic,strong)IfishHistoryView*historyView;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *templetrueLable;
|
||||
@property(nonatomic,strong)IfishHotBarVo*vo;
|
||||
@property(nonatomic,strong)IfishHotBarHeader*header;
|
||||
@property(nonatomic,assign)NSInteger curDay;
|
||||
@end
|
||||
|
||||
@implementation IfishHotBarVc
|
||||
|
||||
-(IfishHotBarHeader *)header{
|
||||
if(_header==nil){
|
||||
_header=[IfishHotBarHeader getView];
|
||||
_header.frame=CGRectMake(0, 0, SCREEN_WIDTH, 207);
|
||||
_header.tag=100;
|
||||
UIView*view=[[UIView alloc]initWithFrame:_header.frame];
|
||||
[view addSubview:_header];
|
||||
self.mainTableView.tableHeaderView=view;
|
||||
}
|
||||
return _header;
|
||||
}
|
||||
|
||||
-(void)initUI{
|
||||
}
|
||||
|
||||
-(void)wenduRequest{// 查询设备状态信息
|
||||
|
||||
searchDeviceModel*xinxiModel=[[searchDeviceModel alloc]init];
|
||||
xinxiModel.resavemacId = self.devicemodel.macAddress;
|
||||
xinxiModel.sendmacId = self.devicemodel.macAddress;
|
||||
|
||||
NSString*requestStr=xinxiModel.description;
|
||||
NSData*data1=[dataContorl stringToHexData:requestStr];
|
||||
[[Socketsingleton sharedInstance].clientSocket writeData:data1 withTimeout:-1 tag:0];
|
||||
[[Socketsingleton sharedInstance].clientSocket readDataWithTimeout:-1 tag:0];
|
||||
|
||||
[self getHotBarInfo];
|
||||
}
|
||||
|
||||
-(IfishHistoryView *)historyView{
|
||||
if (_historyView==nil) {
|
||||
_historyView=[IfishHistoryView getView];
|
||||
_historyView.frame=self.view.bounds;
|
||||
_historyView.myDeleget=self;
|
||||
[self.view addSubview:_historyView];
|
||||
}
|
||||
_historyView.hidden=NO;
|
||||
// _historyView.hidden=NO;
|
||||
return _historyView;
|
||||
}
|
||||
|
||||
-(void)clickBottomBarWithIdx:(NSInteger)idx{
|
||||
if (idx==10) {
|
||||
self.curDay++;
|
||||
if (self.curDay>7) {
|
||||
[SVProgressHUD showInfoWithStatus:@"只能查询前七天数据!"];
|
||||
self.curDay=7;
|
||||
return;
|
||||
}
|
||||
|
||||
}else{
|
||||
self.curDay--;
|
||||
if(self.curDay<0){
|
||||
[SVProgressHUD showInfoWithStatus:@"只能查询前七天数据!"];
|
||||
self.curDay=0;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NSDate *curDate = [NSDate dateWithTimeInterval:self.curDay*60*60*-24 sinceDate:[NSDate date]];
|
||||
NSDateFormatter *dateFormatter=[[NSDateFormatter alloc]init];//创建一个日期格式化器
|
||||
|
||||
dateFormatter.dateFormat=@"yyyy-MM-dd";//指定转date得日期格式化形式
|
||||
|
||||
NSLog(@"%@",[dateFormatter stringFromDate:curDate]);//2015-11-20 08:24:04
|
||||
NSString*curDateStr=[dateFormatter stringFromDate:curDate];
|
||||
// __block NSString*b_dateStr=curDateStr;
|
||||
[SVProgressHUD showWithMaskType:SVProgressHUDMaskTypeBlack];
|
||||
NSDictionary*para=@{@"heaterMacAddress":self.devicemodel.macAddress,@"date":curDateStr};//yyyy-mm-dd
|
||||
self.historyView.curdateStr=curDateStr;
|
||||
[AFHttpTool requestWihtMethod:RequestMethodTypePost url:getHotBarHistory params:para success:^(id response) {
|
||||
NSLog(@"-----------%@",response);
|
||||
NSDictionary*dict=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||||
NSString*result=dict[@"result"];
|
||||
[SVProgressHUD dismiss];
|
||||
if ([result integerValue]==100) {
|
||||
IfishHotBarVo*vo= [IfishHotBarVo mj_objectWithKeyValues:dict[@"data"]];
|
||||
if (vo.phs.count<1) {
|
||||
[SVProgressHUD showInfoWithStatus:@"暂无数据"];
|
||||
}else{
|
||||
self.historyView.datas=vo.phs;
|
||||
}
|
||||
}else{
|
||||
[SVProgressHUD showInfoWithStatus:@"暂无数据"];
|
||||
}
|
||||
} failure:^(NSError *err) {
|
||||
[SVProgressHUD dismiss];
|
||||
[SVProgressHUD showInfoWithStatus:@"网络在开小差,请稍后!"];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark----设置参数代理---
|
||||
|
||||
-(IFishWaterChangeView *)changeWaterView{
|
||||
if(_changeWaterView==nil){
|
||||
_changeWaterView=[IFishWaterChangeView getView];
|
||||
@@ -48,12 +146,65 @@
|
||||
}
|
||||
|
||||
-(void)didSelectRow1:(NSString *)v andRow2:(NSString *)v2{
|
||||
NSString*str=[NSString stringWithFormat:@"换水周期 %@ 天 %@",v,v2];
|
||||
v=[v stringByReplacingOccurrencesOfString:@"天" withString:@""];
|
||||
v2=[v2 stringByReplacingOccurrencesOfString:@":00" withString:@""];
|
||||
NSString*str=[NSString stringWithFormat:@"换水周期 %@天 %@:00",v,v2];
|
||||
if (v2.length==0) {
|
||||
str=[NSString stringWithFormat:@"换水周期 %@天",v];
|
||||
}
|
||||
IfishHotBarVo*vo=self.datas[4];
|
||||
vo.title=str;
|
||||
[self.tableView reloadData];
|
||||
|
||||
self.vo.heater.heaterCycle=v;
|
||||
self.vo.heater.heaterReminderTime=v2;
|
||||
[self setTeampleture];
|
||||
[self.mainTableView reloadData];
|
||||
}
|
||||
|
||||
-(void)submitText:(NSString *)w andh:(NSString *)h andV:(NSString *)v{
|
||||
IfishHotBarVo*vo=self.datas[1];
|
||||
float heaterVolume;
|
||||
if (w&&h&&v) {
|
||||
heaterVolume=[w integerValue]*[h integerValue]*[v integerValue]*0.001;
|
||||
self.vo.heater.heaterVolume=[NSString stringWithFormat:@"%0.1f",heaterVolume];
|
||||
self.vo.heater.heaterLong=v;
|
||||
self.vo.heater.heaterWidth=w;
|
||||
self.vo.heater.heaterHeight=h;
|
||||
}
|
||||
if (self.vo.heater.heaterVolume.length) {
|
||||
vo.title=[NSString stringWithFormat:@"鱼缸容量 %@L",self.vo.heater.heaterVolume];
|
||||
vo.subTitle=[NSString stringWithFormat:@"推荐流量:%.1fL--%.1fL",[self.vo.heater.heaterVolume intValue]*1.5,[self.vo.heater.heaterVolume intValue]*2.0];
|
||||
[self.mainTableView reloadData];
|
||||
}
|
||||
[self setHeigh:h andW:w andLong:v];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
-(void)didSelectTeamptrue:(NSString *)up andDown:(NSString *)down andT:(NSString *)t andWarnCode:(NSString *)code{
|
||||
up=[up stringByReplacingOccurrencesOfString:@"°c" withString:@""];
|
||||
down=[down stringByReplacingOccurrencesOfString:@"°c" withString:@""];
|
||||
t=[t stringByReplacingOccurrencesOfString:@"°c" withString:@""];
|
||||
|
||||
// [self setHeatTeapWith:t];
|
||||
IfishHotBarVo*vo=self.datas[0];
|
||||
self.vo.heaterNum=[NSString stringWithFormat:@"%f",t.floatValue];
|
||||
|
||||
vo.title=[NSString stringWithFormat:@"设置温度 %.1f°c",[self.vo.heaterNum floatValue]];
|
||||
[self.mainTableView reloadData];
|
||||
self.vo.wornCode=code;
|
||||
// self.vo.wornCode=[NSString stringWithFormat:@"%llu",[dataContorl hexToTen:self.vo.wornCode]];
|
||||
|
||||
self.vo.upTeamp=up;
|
||||
|
||||
self.vo.downTeamp=down;
|
||||
|
||||
[self setHeatTeapWith:t];
|
||||
// [self setTeampletureWithUp:self.vo.upTeamp andDown:self.vo.downTeamp andHnum:0 andWarmC:self.vo.wornCode];
|
||||
}
|
||||
|
||||
|
||||
|
||||
-(NSMutableArray *)datas{
|
||||
if (_datas==nil) {
|
||||
@@ -66,7 +217,7 @@
|
||||
[_datas addObject:vo];
|
||||
|
||||
IfishHotBarVo*vo1=[[IfishHotBarVo alloc]init];
|
||||
vo1.title=@"鱼缸容量 1000L";
|
||||
vo1.title=@"鱼缸容量 ";
|
||||
vo1.iconUrl=@"容积图标";
|
||||
vo1.isShowArrow=YES;
|
||||
vo1.subTitle=@"";
|
||||
@@ -75,16 +226,16 @@
|
||||
vo2.title=@"水泵流量";
|
||||
vo2.iconUrl=@"流量标";
|
||||
vo2.isShowArrow=NO;
|
||||
vo2.subTitle=@"流量:合适";
|
||||
vo2.subTitle=@"";
|
||||
[_datas addObject:vo2];
|
||||
IfishHotBarVo*vo3=[[IfishHotBarVo alloc]init];
|
||||
vo3.title=@"历史趋势";
|
||||
vo3.iconUrl=@"趋势图标";
|
||||
vo3.iconUrl=@"走势图标";
|
||||
vo3.isShowArrow=YES;
|
||||
vo3.subTitle=@"";
|
||||
[_datas addObject:vo3];
|
||||
IfishHotBarVo*vo4=[[IfishHotBarVo alloc]init];
|
||||
vo4.title=@"换水周期 5 天 7:00";
|
||||
vo4.title=@"换水周期 ";
|
||||
vo4.iconUrl=@"换水图标";
|
||||
vo4.isShowArrow=YES;
|
||||
vo4.subTitle=@"";
|
||||
@@ -96,13 +247,234 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view from its nib.
|
||||
[self.tableView registerNib:[UINib nibWithNibName:@"IFishHotBarCell" bundle:nil] forCellReuseIdentifier:HOTBARCELL];
|
||||
self.tableView.rowHeight=70;
|
||||
[self.mainTableView registerNib:[UINib nibWithNibName:@"IFishHotBarCell" bundle:nil] forCellReuseIdentifier:HOTBARCELL];
|
||||
self.mainTableView.rowHeight=70;
|
||||
self.mainTableView.dataSource=self;
|
||||
self.mainTableView.delegate=self;
|
||||
[self.mainTableView reloadData];
|
||||
[self getHotBarInfo];
|
||||
self.tableView=self.mainTableView;
|
||||
[self creatRefreshView];
|
||||
[self header];
|
||||
//
|
||||
UIImage *hamburger = [[UIImage imageNamed:@"back_btn"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
||||
self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithImage:hamburger style:0 target:self action:@selector(clickBack)];
|
||||
self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"ifishnav_dropview_list"] style:0 target:self action:@selector(clickMoreBtn)];
|
||||
}
|
||||
|
||||
//-(void)updateNameInLocal{
|
||||
// NSArray* deviceArr =[dataContorl getallDevices];
|
||||
// for (DeviceModel *device in deviceArr) {
|
||||
// if (device.deviceId==self.devicemodel.deviceId) {
|
||||
// device.defaultShowName=self.title;
|
||||
// [[DataCenter defaultDtacenter]setValue:deviceArr forKey:@"deviceInfo"];
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
||||
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
[super viewWillAppear:animated];
|
||||
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"blackbar.png"] forBarMetrics:UIBarMetricsDefault];
|
||||
NSString*dTitle=[[NSUserDefaults standardUserDefaults] valueForKey:@"dTitle"];
|
||||
self.title=self.devicemodel.showName;
|
||||
// [self updateNameInLocal];
|
||||
}
|
||||
|
||||
|
||||
-(void)clickMoreBtn{
|
||||
[self presentPopView];
|
||||
}
|
||||
|
||||
-(void)deleteDeviceRequset{
|
||||
[super deleteDeviceRequset];
|
||||
}
|
||||
|
||||
-(void)deleteDeviceRequsetSus{
|
||||
[self deleteHotBarInfo];
|
||||
}
|
||||
|
||||
-(void)clickBack{
|
||||
[self.navigationController popToRootViewControllerAnimated:YES];
|
||||
[self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
|
||||
}
|
||||
|
||||
-(void)shezhiMingCheng{
|
||||
IfishHotBarModifyNameVc*mVc=[[IfishHotBarModifyNameVc alloc]init];
|
||||
mVc.devicemodel=self.devicemodel;
|
||||
[self.navigationController pushViewController:mVc animated:YES];
|
||||
}
|
||||
|
||||
#pragma mark------请求服务器-------
|
||||
|
||||
-(void)setHeigh:(NSString*)h andW:(NSString*)w andLong:(NSString*)l{
|
||||
// 参数名称 参数类型 是否必须 说明描述
|
||||
// heaterId Integer 是 保存信息此字段为空
|
||||
// 修改信息此字段有值
|
||||
// heaterMacAddress String 是 加热棒mac地址
|
||||
// heaterVolume String 是 鱼缸容积
|
||||
// heaterLong String 是 鱼缸长
|
||||
// heaterWidth String 是 鱼缸宽
|
||||
// heaterHeight String 是 鱼缸高
|
||||
// heaterCycle String 是 换水提醒周期
|
||||
// c String 是 提醒时间
|
||||
if ([l isEqualToString:@""]) {
|
||||
[self.view makeToast:@"请输入鱼缸长"];
|
||||
return;
|
||||
}else if ([w isEqualToString:@""]){
|
||||
[self.view makeToast:@"请输入鱼缸宽"];
|
||||
return;
|
||||
}else if([h isEqualToString:@""])
|
||||
{
|
||||
[self.view makeToast:@"请输入鱼缸高"];
|
||||
return;
|
||||
}
|
||||
NSString*v=@"";
|
||||
NSString*r=@"";
|
||||
NSString*c=@"";
|
||||
NSString*heaterId=@"";
|
||||
if (self.vo.heater) {
|
||||
v=self.vo.heater.heaterVolume;
|
||||
c=self.vo.heater.heaterCycle;
|
||||
r=self.vo.heater.heaterReminderTime;
|
||||
heaterId=self.vo.heater.heaterId;
|
||||
}
|
||||
|
||||
NSDictionary*para=@{
|
||||
@"heaterId":heaterId,
|
||||
@"heaterMacAddress":self.devicemodel.macAddress,
|
||||
@"heaterVolume":v,
|
||||
@"heaterLong":l,
|
||||
@"heaterWidth":w,
|
||||
@"heaterHeight":h,
|
||||
@"heaterCycle":c,
|
||||
@"heaterRemindTime":r
|
||||
};
|
||||
[SVProgressHUD showWithMaskType:SVProgressHUDMaskTypeBlack];
|
||||
[AFHttpTool requestWihtMethod:RequestMethodTypePost url:SaveHotBarInfo params:para success:^(id response) {
|
||||
NSLog(@"-----------%@",response);
|
||||
NSDictionary*dict=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||||
NSString*result=dict[@"result"];
|
||||
if ([result integerValue]==100) {
|
||||
// self.vo=[IfishHotBarVo mj_objectWithKeyValues:dict[@"data"]];
|
||||
[SVProgressHUD dismiss];
|
||||
[self showLableAction:@"修改成功"];
|
||||
}
|
||||
} failure:^(NSError *err) {
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
-(void)deleteHotBarInfo{
|
||||
|
||||
NSDictionary*para=@{
|
||||
@"heaterMacAddress":self.devicemodel.macAddress
|
||||
};
|
||||
[AFHttpTool requestWihtMethod:RequestMethodTypePost url:DeleteHotBar params:para success:^(id response) {
|
||||
NSLog(@"-----------%@",response);
|
||||
NSDictionary*dict=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||||
NSString*result=dict[@"result"];
|
||||
if ([result integerValue]==100) {
|
||||
// self.vo=[IfishHotBarVo mj_objectWithKeyValues:dict[@"data"]];
|
||||
[self.view makeToast:@"删除成功"];
|
||||
|
||||
}else{
|
||||
[self.view makeToast:@"删除失败"];
|
||||
}
|
||||
//发送删除消息
|
||||
//重置数据库
|
||||
NSArray*deviceArry=[[DataCenter defaultDtacenter]valueForKey:@"deviceInfo"];
|
||||
NSMutableArray *newArr = [NSMutableArray arrayWithArray:deviceArry];
|
||||
|
||||
for (DeviceModel *model in deviceArry) {
|
||||
|
||||
if ([model.deviceId isEqual:self.devicemodel.deviceId]) {
|
||||
|
||||
[newArr removeObject:model];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[[DataCenter defaultDtacenter] setValue: newArr forKey:@"deviceInfo"];
|
||||
|
||||
if ([newArr count]==0) {
|
||||
|
||||
NSArray *cameraArr= [[DataCenter defaultDtacenter] valueForKey:@"cameraArr"];
|
||||
if ([cameraArr count]!=0) {
|
||||
[[Socketsingleton sharedInstance] cutOffSocket];
|
||||
}else{
|
||||
//两种设备都
|
||||
[[Socketsingleton sharedInstance] cutOffSocket];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
} failure:^(NSError *err) {
|
||||
[self.view makeToast:@"删除失败"];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
|
||||
-(void)getHotBarInfo{
|
||||
NSDictionary*para=@{@"heaterMacAddress":self.devicemodel.macAddress};
|
||||
[SVProgressHUD showWithMaskType:SVProgressHUDMaskTypeBlack];
|
||||
[AFHttpTool requestWihtMethod:RequestMethodTypePost url:GetHotBarInfo params:para success:^(id response) {
|
||||
NSLog(@"-----------%@",response);
|
||||
NSDictionary*dict=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||||
NSString*result=dict[@"result"];
|
||||
[SVProgressHUD dismiss];
|
||||
if ([result integerValue]==100) {
|
||||
self.vo=[IfishHotBarVo mj_objectWithKeyValues:dict[@"data"]];
|
||||
|
||||
if (self.vo.phs.count>0) {
|
||||
NSDate *curDate = [NSDate dateWithTimeInterval:self.curDay*60*60*-24 sinceDate:[NSDate date]];
|
||||
NSDateFormatter *dateFormatter=[[NSDateFormatter alloc]init];//创建一个日期格式化器
|
||||
dateFormatter.dateFormat=@"yyyy-MM-dd";//指定转date得日期格式化形式
|
||||
|
||||
NSLog(@"%@",[dateFormatter stringFromDate:curDate]);//2015-11-20 08:24:04
|
||||
NSString*curDateStr=[dateFormatter stringFromDate:curDate];
|
||||
self.historyView.curdateStr=curDateStr;
|
||||
self.historyView.datas=self.vo.phs;
|
||||
self.historyView.hidden=YES;
|
||||
}
|
||||
|
||||
IfishHotBarVo*vo=self.datas[1];
|
||||
if (self.vo.heater.heaterVolume.length) {
|
||||
vo.title=[NSString stringWithFormat:@"鱼缸容量 %@L",self.vo.heater.heaterVolume];
|
||||
vo.subTitle=[NSString stringWithFormat:@"推荐流量:%.1fL--%.1fL",[self.vo.heater.heaterVolume intValue]*1.5,[self.vo.heater.heaterVolume intValue]*2.0];
|
||||
}
|
||||
IfishHotBarVo*vo1=self.datas[4];
|
||||
if (self.vo.heater.heaterCycle.length) {
|
||||
if (self.vo.heater.heaterReminderTime.length) {
|
||||
vo1.title=[NSString stringWithFormat:@"换水周期 %@天 %@:00",self.vo.heater.heaterCycle,self.vo.heater.heaterReminderTime];
|
||||
}else{
|
||||
vo1.title=[NSString stringWithFormat:@"换水周期 %@天",self.vo.heater.heaterCycle];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[self.mainTableView reloadData];
|
||||
}else{
|
||||
[SVProgressHUD showInfoWithStatus:@"暂无数据"];
|
||||
}
|
||||
} failure:^(NSError *err) {
|
||||
[SVProgressHUD dismiss];
|
||||
[SVProgressHUD showInfoWithStatus:@"网络错误,请稍后"];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
|
||||
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||||
return self.datas.count;
|
||||
@@ -117,11 +489,267 @@
|
||||
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
if (indexPath.row==3) {
|
||||
self.historyView.hidden=NO;
|
||||
}else{
|
||||
[self changeWaterView];
|
||||
self.changeWaterView.viewType=indexPath.row;
|
||||
// self.historyView.datas=self.vo.phs;
|
||||
}else if (indexPath.row==2){
|
||||
|
||||
}
|
||||
else{
|
||||
// [self wenduRequest];
|
||||
[self changeWaterView];
|
||||
self.changeWaterView.hotVo=self.vo;
|
||||
self.changeWaterView.viewType=indexPath.row;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma mark----socket返回----
|
||||
|
||||
-(void)ifishDeviceLogInFail{
|
||||
// self.mainTableView.userInteractionEnabled=NO;
|
||||
}
|
||||
|
||||
-(void)socketDidGetBackmsgData:(NSData *)data onsoket:(AsyncSocket *)sock{
|
||||
self.mainTableView.userInteractionEnabled=YES;
|
||||
NSLog(@"TwoControlView收到服务器的回执--->%@",data);
|
||||
NSLog(@"TwoControlView收到服务器的回执--->%@",[NSThread currentThread]);
|
||||
|
||||
NSString*string1=[dataContorl dataToHexString:data];
|
||||
NSLog(@"TwoControlView收到服务器的回执--->%@",string1);
|
||||
NSString*functionCode=[string1 substringWithRange:NSMakeRange(2, 2)];
|
||||
if ([functionCode isEqualToString:@"08"]) {
|
||||
[self updateUiWithInfo:string1];
|
||||
}else if([functionCode isEqualToString:@"05"]){
|
||||
// [self setHeatTeapWith:self.vo.heaterNum];
|
||||
}else if([functionCode isEqualToString:@"0e"]){
|
||||
[self setTeampletureWithUp:self.vo.upTeamp andDown:self.vo.downTeamp andHnum:0 andWarmC:self.vo.wornCode];
|
||||
}else if([functionCode isEqualToString:@"06"]){
|
||||
[self updateUiWithInfo:string1];
|
||||
[self endRefreshing];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)updateUiWithInfo:(NSString*)info{
|
||||
NSString*templeture=[info substringWithRange:NSMakeRange(36, 4)];
|
||||
// templeture=[NSString stringWithFormat:@"0x%@",templeture];
|
||||
UInt64 temp=[dataContorl hexToTen:templeture];
|
||||
float tempFloat=temp*0.1;
|
||||
// self.templetrueLable.text=[NSString stringWithFormat:@"%llu°c",temp];
|
||||
self.header.degreeLable.text=[NSString stringWithFormat:@"%0.1f°c",tempFloat];
|
||||
//流量 46
|
||||
NSString*ph=[info substringWithRange:NSMakeRange(46, 4)];
|
||||
UInt64 phV=[dataContorl hexToTen:ph];
|
||||
IfishHotBarVo*vo2=self.datas[2];
|
||||
// phV=0;
|
||||
vo2.phv=phV;
|
||||
vo2.title=[NSString stringWithFormat:@"水循环 %lluL",phV];
|
||||
if (phV<=120) {
|
||||
vo2.subTitle=@"流量警告:加热器停止加热,进入保护状态";
|
||||
}else{
|
||||
vo2.subTitle=@"";
|
||||
}
|
||||
|
||||
self.vo.heaterNum=[info substringWithRange:NSMakeRange(40, 4)];
|
||||
UInt64 heaterNum= [dataContorl hexToTen:self.vo.heaterNum];
|
||||
float num=heaterNum*1.0;
|
||||
if (heaterNum>100) {
|
||||
num=heaterNum*0.1;
|
||||
}
|
||||
self.vo.heaterNum=[NSString stringWithFormat:@"%f",num];
|
||||
|
||||
IfishHotBarVo*vo=self.datas[0];
|
||||
vo.title=[NSString stringWithFormat:@"设置温度 %.1f°c",[self.vo.heaterNum floatValue]];
|
||||
|
||||
|
||||
self.vo.wornCode=[info substringWithRange:NSMakeRange(44, 2)];
|
||||
// self.vo.wornCode=[NSString stringWithFormat:@"%llu",[dataContorl hexToTen:self.vo.wornCode]];
|
||||
|
||||
self.vo.upTeamp=[info substringWithRange:NSMakeRange(54, 4)];
|
||||
self.vo.upTeamp=[NSString stringWithFormat:@"%f",[dataContorl hexToTen:self.vo.upTeamp]*0.1];
|
||||
|
||||
self.vo.downTeamp=[info substringWithRange:NSMakeRange(50, 4)];
|
||||
self.vo.downTeamp=[NSString stringWithFormat:@"%f",[dataContorl hexToTen:self.vo.downTeamp]*0.1];
|
||||
|
||||
|
||||
|
||||
[self.mainTableView reloadData];
|
||||
|
||||
}
|
||||
|
||||
|
||||
#pragma mark----UDP-----
|
||||
|
||||
|
||||
//
|
||||
//数据包头(15字节) 1 "发送消息类型填充00,回复类型填充01
|
||||
//"
|
||||
//1 功能码
|
||||
//6 发送方MAC地址
|
||||
//6 接收方MAC地址
|
||||
//1 消息长度,包长度(15+*的长度)
|
||||
|
||||
//
|
||||
//设置报警温度指令(22字节) 15 数据包头
|
||||
//1 开启关闭报警,00关,01开
|
||||
//2 最低报警温度,关闭报警时传0
|
||||
//2 最高报警温度,关闭报警时传0
|
||||
//2 CRC16校验码
|
||||
-(void)setTeampleture{
|
||||
if (!self.vo.heater.heaterCycle||!self.vo.heater.heaterReminderTime) {
|
||||
return;
|
||||
}
|
||||
self.vo.heater.heaterCycle=[self.vo.heater.heaterCycle stringByReplacingOccurrencesOfString:@"天" withString:@""];
|
||||
self.vo.heater.heaterReminderTime=[self.vo.heater.heaterReminderTime stringByReplacingOccurrencesOfString:@":00" withString:@""];
|
||||
NSString*longNum=@"";
|
||||
NSString*heaterWidth=@"";
|
||||
NSString*heaterHeight=@"";
|
||||
NSString*heaterId=@"";
|
||||
NSString*heaterVolume=@"";
|
||||
if (self.vo.heater) {
|
||||
longNum=self.vo.heater.heaterLong;
|
||||
heaterWidth=self.vo.heater.heaterWidth;
|
||||
heaterHeight=self.vo.heater.heaterHeight;
|
||||
heaterId=self.vo.heater.heaterId;
|
||||
heaterVolume=self.vo.heater.heaterVolume;
|
||||
}
|
||||
|
||||
NSDictionary*para=@{
|
||||
@"heaterId":heaterId,
|
||||
@"heaterMacAddress":self.devicemodel.macAddress,
|
||||
@"heaterVolume":heaterVolume,
|
||||
@"heaterLong":longNum,
|
||||
@"heaterWidth":heaterWidth,
|
||||
@"heaterHeight":heaterHeight,
|
||||
@"heaterCycle":self.vo.heater.heaterCycle,
|
||||
@"heaterReminderTime":self.vo.heater.heaterReminderTime
|
||||
};
|
||||
[AFHttpTool requestWihtMethod:RequestMethodTypePost url:SaveHotBarInfo params:para success:^(id response) {
|
||||
NSLog(@"-----------%@",response);
|
||||
NSDictionary*dict=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||||
NSString*result=dict[@"result"];
|
||||
if ([result integerValue]==100) {
|
||||
// self.vo=[IfishHotBarVo mj_objectWithKeyValues:dict[@"data"]];
|
||||
[self showLableAction:@"修改成功"];
|
||||
}
|
||||
} failure:^(NSError *err) {
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark-----打开开关----
|
||||
-(void)clickWormCode:(NSString *)code{
|
||||
IfishHotBarPackegeVo*pvo=[[IfishHotBarPackegeVo alloc]init];
|
||||
|
||||
pvo.msgType=@"00";
|
||||
pvo.funcCode=@"05";
|
||||
pvo.sendAdr=self.devicemodel.macAddress;
|
||||
pvo.reciceAdr=self.devicemodel.macAddress;
|
||||
pvo.lenth=@"16";
|
||||
|
||||
pvo.warnCode=code;
|
||||
|
||||
pvo.downTeamptrue=@"0000";
|
||||
pvo.upTeamptrue=@"0000";
|
||||
|
||||
|
||||
|
||||
|
||||
pvo.crcCode=@"0000";
|
||||
|
||||
|
||||
NSString*stateString=[pvo description];
|
||||
|
||||
NSData*selctorData=[dataContorl stringToHexData:stateString];
|
||||
[[Socketsingleton sharedInstance].clientSocket writeData:selctorData withTimeout:-1 tag:0];
|
||||
[[Socketsingleton sharedInstance].clientSocket readDataWithTimeout:-1 tag:0];
|
||||
}
|
||||
|
||||
-(void)setTeampletureWithUp:(NSString*)up andDown:(NSString*)down andHnum:(NSString*)num andWarmC:(NSString*)code{
|
||||
if(!up||!down){
|
||||
// [self.view makeToast:@"请选择最高温度或最低温度"];
|
||||
[self setHeatTeapWith:num];
|
||||
return;
|
||||
}
|
||||
IfishHotBarPackegeVo*pvo=[[IfishHotBarPackegeVo alloc]init];
|
||||
|
||||
pvo.msgType=@"00";
|
||||
pvo.funcCode=@"05";
|
||||
pvo.sendAdr=self.devicemodel.macAddress;
|
||||
pvo.reciceAdr=self.devicemodel.macAddress;
|
||||
pvo.lenth=@"16";
|
||||
|
||||
pvo.warnCode=code;
|
||||
|
||||
if([code isEqualToString:@"00"]){
|
||||
pvo.downTeamptrue=@"0000";
|
||||
pvo.upTeamptrue=@"0000";
|
||||
}else{
|
||||
pvo.warnCode=@"02";
|
||||
pvo.downTeamptrue=[dataContorl ToHex:down.longLongValue*10];
|
||||
if (pvo.downTeamptrue.length<4) {
|
||||
pvo.downTeamptrue=[dataContorl leftAddZero:4 andStr:pvo.downTeamptrue];
|
||||
}
|
||||
pvo.upTeamptrue=[dataContorl ToHex:up.longLongValue*10];
|
||||
if (pvo.upTeamptrue.length<4) {
|
||||
pvo.upTeamptrue=[dataContorl leftAddZero:4 andStr:pvo.upTeamptrue];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
pvo.crcCode=@"0000";
|
||||
|
||||
|
||||
NSString*stateString=[pvo description];
|
||||
|
||||
NSData*selctorData=[dataContorl stringToHexData:stateString];
|
||||
self.vo.heaterNum=num;
|
||||
[[Socketsingleton sharedInstance].clientSocket writeData:selctorData withTimeout:-1 tag:0];
|
||||
[[Socketsingleton sharedInstance].clientSocket readDataWithTimeout:-1 tag:0];
|
||||
// [self showLableAction:@"发送成功"];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//"设置加热温度
|
||||
//(19字节)" 15 数据包头
|
||||
//2 加热温度,如设置为27.1℃0x10F转成16进制则为0x10F
|
||||
//2 CRC16校验码
|
||||
|
||||
-(void)setHeatTeapWith:(NSString*)num{
|
||||
if(!num){
|
||||
// [self.view makeToast:@"请选择加热温度"];
|
||||
|
||||
// self.vo.wornCode=[NSString stringWithFormat:@"%llu",[dataContorl hexToTen:self.vo.wornCode]];
|
||||
|
||||
[self setTeampletureWithUp:self.vo.upTeamp andDown:self.vo.downTeamp andHnum:0 andWarmC:self.vo.wornCode];
|
||||
return;
|
||||
}
|
||||
IfishPackageHeaderVo*header=[[IfishPackageHeaderVo alloc]init];
|
||||
header.msgType=@"00";
|
||||
header.funcCode=@"0e";
|
||||
header.sendAdr=self.devicemodel.macAddress;
|
||||
header.reciceAdr=self.devicemodel.macAddress;
|
||||
header.lenth=@"13";
|
||||
|
||||
// NSString*str=[NSString stringWithFormat:@"%@0",num];
|
||||
|
||||
NSString*crc=@"0000";
|
||||
num=[dataContorl ToHex:num.longLongValue*10];
|
||||
if (num.length<4) {
|
||||
num=[dataContorl leftAddZero:4 andStr:num];
|
||||
}
|
||||
NSString*stateString=[NSString stringWithFormat:@"%@%@%@",[header getHeader],num,crc];
|
||||
|
||||
NSData*selctorData=[dataContorl stringToHexData:stateString];
|
||||
[[Socketsingleton sharedInstance].clientSocket writeData:selctorData withTimeout:-1 tag:0];
|
||||
[[Socketsingleton sharedInstance].clientSocket readDataWithTimeout:-1 tag:0];
|
||||
[self showLableAction:@"发送成功"];
|
||||
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user