// // FourControlNormalCenterController.m // Ifish // // Created by imac on 16/5/24. // Copyright © 2016年 imac. All rights reserved. // #import "FourControlNormalCenterController.h" #import "FourControlSetViewController.h" #import "FourControlbackMassge.h" #define FOURCONTROLNORMAL_LIGR1TAG 231 #define FOURCONTROLNORMAL_LIGR2TAG 232 #define FOURCONTROLNORMAL_LIGR3TAG 233 #define FOURCONTROLNORMAL_PUMPTAG 234 #import "manulswitchMSModel.h" #import "FourControlDataUnity.h" #import "FourControlNameViewController.h" #import "UserExtendataArchaver.h" #import "FourControlName.h" @interface FourControlNormalCenterController () @property(nonatomic,strong) FourControlSetViewController *forControlSetVC; @property(nonatomic,strong) FourControlbackMassge *backmodel; @property(nonatomic,strong) FourControlNameViewController *changeNameVC; @end @implementation FourControlNormalCenterController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. _backmodel=[[FourControlbackMassge alloc] init]; [Socketsingleton sharedInstance].communiteDelegate=self; UITapGestureRecognizer*tapgestureRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(fourControrlCenterViewSetTap)]; [self.setImag addGestureRecognizer:tapgestureRecognizer]; [self.setbackBtn addTarget:self action:@selector(fourControrlCenterViewSetTap) forControlEvents:UIControlEventTouchUpInside]; [self.SetTimeButton addTarget:self action:@selector(fourControrlCenterViewSetTap) forControlEvents:UIControlEventTouchUpInside]; [self initFourControlNormalBtn]; } #pragma mark -转跳设置界面 -(void)fourControrlCenterViewSetTap{ if (self.binddeviceArr.count ==0) { [self.view makeToast:@"暂未绑定设备"]; }else{ // BackmassegeModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"FourControlMassgeInfo"]; // if (backmodel) { [self pushFourSetvc]; // }else{ // [self showLableAction:@"设备已离线"]; // [self deviceNotOnlineState]; // [self.indicatorView stopAnimating]; // } } } -(void)pushFourSetvc{ _forControlSetVC=[[FourControlSetViewController alloc]init]; _forControlSetVC.currentdevice=self.currentDevice; [self.navigationController pushViewController:_forControlSetVC animated:YES]; //self.navigationBarHidden=NO; } -(void)initFourControlNormalBtn{ NSArray*nomalarr=@[@"PFLight1_off.png",@"PFLight1_off.png",@"PFkilLlight_off.png",@"ChongLang_off.png"]; CGFloat wspace=25; CGFloat btnwidth= (kScreenSize.width-wspace * 5)/4; for (int i=0; i%@",data); NSString*string1=[dataContorl dataToHexString:data]; //self.offlineLabel.hidden=YES; [self endRefreshing]; self.temperature.hidden=NO; //设备在线显示与设备离线相对应 self.dulabel.hidden=NO; //设备在线显示与设备离线相对应 收到返回数据改变显示状态 self.notOnLineLabel.hidden = YES; self.temperaturebackImg.hidden=NO; [self.indicatorView stopAnimating]; //[_HUD hide:YES]; [self.myhud hidmyHud]; if (_forControlSetVC.indicatorView) { [_forControlSetVC.indicatorView stopAnimating]; } NSLog(@"收到服务器的回执2--->%@",data); self.dataLength=string1.length; //存储 [FourControlDataUnity readSoketbackMassageOfFourControlData:data WithModel:_backmodel]; //按钮状态 dispatch_async(dispatch_get_main_queue(), ^{ [FourControlDataUnity resetFourControlButtonState:self.light1Button addlight2:self.light2Button addlight3:self.light3Button addpump:self.pumpButton withBackModel:_backmodel]; //setView _forControlSetVC.timeArr = [FourControlDataUnity refreshFourControlTimerWithBackMassageModel:_backmodel]; [_forControlSetVC.tableView reloadData]; }); //温度label [FourControlDataUnity setTemperaturelabel:self.temperature addbubleImge:self.bubble WithBackData:data addWithBackMassageModel:_backmodel addWithTableview:self.tableView]; } -(void)ifishDeviceLogInSuccees{ self.isconnect=YES; NSLog(@"app登录成功"); } -(void)ifishDeviceLogInFail{ [self endRefreshing]; [self.indicatorView stopAnimating]; dispatch_async(dispatch_get_main_queue(), ^{ [self deviceNotOnlineState];//设备离线 }); } #pragma mark -父类方法 -(void)shezhiMingCheng { _changeNameVC = [[FourControlNameViewController alloc] init]; _changeNameVC.name = self.name.text; _changeNameVC.device = self.currentDevice; __weak typeof (self)wself = self; _changeNameVC.NameWithBlock = ^(NSString *nameStr){ wself.name.text = nameStr; [wself initCHNames]; }; [ wself.navigationController pushViewController: _changeNameVC animated:YES]; } -(void)initCHNames{ FourControlName *name = [UserExtendataArchaver currentFourControlName:self.currentDevice.macAddress]; self.light1Name.text = name.light1; self.light2Name.text = name.light2; self.uVName.text = name.uvName; self.pumpName.text = name.pumpName; } @end