Initial commit
This commit is contained in:
+39
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// SetTimeController.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 15/9/27.
|
||||
// Copyright © 2015年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "AsyncSocket.h"
|
||||
#import "FatherController.h"
|
||||
#import "Socketsingleton.h"
|
||||
/**
|
||||
* 三控 时间设置界面
|
||||
*/
|
||||
@interface SetTimeController : FatherController
|
||||
{
|
||||
BOOL _isHidden;
|
||||
BOOL mySwitchIsOn;
|
||||
|
||||
}
|
||||
|
||||
@property(nonatomic,strong)NSArray*timeArr;
|
||||
@property(nonatomic,strong)NSArray*titleArr;
|
||||
@property(nonatomic)BOOL isAuto;// 自动模式
|
||||
@property(nonatomic)UIActivityIndicatorView*indicatorView;
|
||||
|
||||
-(void)addAlertView;
|
||||
|
||||
|
||||
@property(nonatomic)int percent;
|
||||
|
||||
|
||||
@property(nonatomic,strong) DeviceModel* currentdevice;
|
||||
|
||||
|
||||
|
||||
@end
|
||||
+1502
File diff suppressed because it is too large
Load Diff
+23
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// ThreeControlCenterViewController.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/4/18.
|
||||
// Copyright © 2016年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "CenterViewController.h"
|
||||
|
||||
@interface ThreeControlCenterViewController : CenterViewController
|
||||
@property(nonatomic,strong) UIButton *button;
|
||||
@property(nonatomic,strong) UIButton *light1Button;
|
||||
@property(nonatomic,strong) UIButton *light2Button;
|
||||
@property(nonatomic,strong) UIButton *pumpButton;
|
||||
|
||||
@property(nonatomic,strong)UILabel *buttonNameLabel;
|
||||
@property(nonatomic,strong)UILabel *light1name;
|
||||
@property(nonatomic,strong)UILabel *light2name;
|
||||
@property(nonatomic,strong)UILabel *pumpname;
|
||||
|
||||
|
||||
@end
|
||||
+629
@@ -0,0 +1,629 @@
|
||||
//
|
||||
// ThreeControlCenterViewController.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/4/18.
|
||||
// Copyright © 2016年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ThreeControlCenterViewController.h"
|
||||
#import "manulswitchMSModel.h"
|
||||
#import "SetTimeController.h"
|
||||
#define LIGHT1_TAG 201
|
||||
#define LIGHT2_TAG 202
|
||||
#define PUMP_TAG 203
|
||||
#import "ThreeControlName.h"
|
||||
#import "ThreeControlNameViewController.h"
|
||||
#import "UserExtendataArchaver.h"
|
||||
//三控 返回消息类型
|
||||
typedef NS_ENUM(NSInteger,ThreeControBackMsgTape){
|
||||
|
||||
// 三控六定时器 返回消息类型71字节
|
||||
|
||||
ThreeControlBackmsgTapeSenventyOneByte,
|
||||
|
||||
// 三控六定时器 返回消息类型 99 字节 (最早陈工)
|
||||
ThreeControlBackmsgTapeNinetyNineByte
|
||||
|
||||
};
|
||||
|
||||
|
||||
@interface ThreeControlCenterViewController ()
|
||||
|
||||
@property(nonatomic,strong) SetTimeController*SetTimeVC;
|
||||
|
||||
@property(nonatomic,assign) ThreeControBackMsgTape threeControltype;
|
||||
|
||||
@property(nonatomic,strong) BackmassegeModel*backmodel;
|
||||
@property (nonatomic,strong) ThreeControlNameViewController *changeNameVC ;
|
||||
@end
|
||||
|
||||
@implementation ThreeControlCenterViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
//主界面按钮事件分离
|
||||
_backmodel=[[BackmassegeModel alloc] init];
|
||||
[Socketsingleton sharedInstance].communiteDelegate = self;
|
||||
|
||||
|
||||
[self.SetTimeButton addTarget:self action:@selector(threeControlSetBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.setbackBtn addTarget:self action:@selector(threeControlSetBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
|
||||
UITapGestureRecognizer*tapgestureRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(threeCenterViewSetTap)];
|
||||
[self.setImag addGestureRecognizer:tapgestureRecognizer];
|
||||
|
||||
UITapGestureRecognizer*tapGesture=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(threeControlViewclockViewClick)];
|
||||
self.clockView.userInteractionEnabled=YES;
|
||||
[self.clockView addGestureRecognizer:tapGesture];
|
||||
|
||||
[self initThreeControlButton];
|
||||
|
||||
}
|
||||
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
|
||||
[self creatFishAnimation];
|
||||
|
||||
}
|
||||
|
||||
-(void)viewDidAppear:(BOOL)animated{
|
||||
|
||||
|
||||
|
||||
}
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
#pragma mark - 初始化三控按钮
|
||||
|
||||
-(void)initThreeControlButton{
|
||||
|
||||
NSArray*nomalarr=@[@"PFLight1_off.png",@"PFLight1_off.png",@"ChongLang_off.png"];
|
||||
|
||||
CGFloat btnControlWith = kScreenSize.width*7/32;
|
||||
CGFloat btnControlPlace = (kScreenSize.width - 3*btnControlWith * 105 / 122 )/4;
|
||||
|
||||
for (int i=0; i<nomalarr.count; i++) {
|
||||
self.button=[UIButton buttonWithType:UIButtonTypeCustom];
|
||||
self.button.layer.masksToBounds=YES;
|
||||
self.button.layer.cornerRadius=8;
|
||||
|
||||
self.button.tag=201+i;
|
||||
|
||||
|
||||
|
||||
self.button.frame=CGRectMake(btnControlPlace +i*(btnControlPlace + btnControlWith * 105 / 122), kScreenSize.height - (btnControlPlace - 10) - btnControlWith -10 -64 , btnControlWith * 105 / 122, btnControlWith );
|
||||
|
||||
|
||||
//self.button.frame=CGRectMake1(wSpace1+(i%3)*(60+wSpace1), kScreenSize.height-80-64,60, 60);
|
||||
[self.button setImage:[UIImage imageNamed:nomalarr[i]] forState:UIControlStateNormal];
|
||||
|
||||
[self.button addTarget:self action:@selector(selctBtnCilck:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
[self.tableView addSubview:self.button];
|
||||
if (i==0) {
|
||||
_light1Button=self.button;
|
||||
|
||||
}else if (i==1){
|
||||
_light2Button=self.button;
|
||||
|
||||
}else if (i==2){
|
||||
_pumpButton=self.button;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
NSArray*arry=@[@"灯1",@"灯2",@"UV/冲浪"];
|
||||
|
||||
for (int j=0; j<nomalarr.count; j++){
|
||||
|
||||
self.buttonNameLabel=[[UILabel alloc]initWithFrame:CGRectMake(btnControlPlace +j*(btnControlPlace + btnControlWith * 105 / 122), kScreenSize.height - (btnControlPlace - 10) - 20 -64, btnControlWith * 7 / 8, btnControlPlace -10)];
|
||||
|
||||
|
||||
// self.timeLabel=[[UILabel alloc]initWithFrame:CGRectMake1(wSpace+(i%3)*(60+wSpace), kScreenSize.height-30-64,60, 20)];
|
||||
self.buttonNameLabel.text=arry[j];
|
||||
self.buttonNameLabel.font=[UIFont systemFontOfSize:15];
|
||||
self.buttonNameLabel.textColor=[UIColor whiteColor];
|
||||
self.buttonNameLabel.textAlignment=NSTextAlignmentCenter;
|
||||
self.buttonNameLabel.tag=230+j;
|
||||
self.buttonNameLabel.textColor=[UIColor colorWithRed:101/255.0f green:103/255.0f blue:103/254.0f alpha:1];
|
||||
self.buttonNameLabel.font = [UIFont boldSystemFontOfSize:13];
|
||||
[self.tableView addSubview:self.buttonNameLabel];
|
||||
|
||||
|
||||
if (j==0) {
|
||||
_light1name=self.buttonNameLabel;
|
||||
|
||||
}else if (j==1){
|
||||
_light2name=self.buttonNameLabel;
|
||||
|
||||
}else if (j==2){
|
||||
_pumpname=self.buttonNameLabel;
|
||||
}
|
||||
}
|
||||
[self initCHNames];
|
||||
}
|
||||
|
||||
#pragma mark 三控按钮事件
|
||||
-(void)selctBtnCilck:(UIButton*)btn{
|
||||
|
||||
BackmassegeModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackInfo"];
|
||||
|
||||
if (!self.currentDevice.isWorkModel) {
|
||||
[self.view makeToast:@"无isWorkModel字段"];
|
||||
return;
|
||||
}
|
||||
|
||||
if (backmodel) {
|
||||
|
||||
if ([self.currentDevice.isWorkModel isEqualToString:@"1"]){
|
||||
|
||||
if ([backmodel.yunxingmoshi isEqualToString:@"01"]){
|
||||
|
||||
[self showLableAction:@"请先关闭定时模式"];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
|
||||
[self.indicatorView stopAnimating];
|
||||
[self deviceNotOnlineState];
|
||||
[self showLableAction:@"设备已离线"];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ([self.currentDevice.isWorkModel isEqualToString:@"1"]) {
|
||||
//有工作模式
|
||||
manulswitchMSModel*manulModel=[[manulswitchMSModel alloc]init];
|
||||
//设置指令mac地址
|
||||
[[Socketsingleton sharedInstance] setSoketLightDataWith:manulModel];
|
||||
NSString*switchString1=manulModel.description;
|
||||
if (btn.selected) {
|
||||
manulModel.switchBtn=@"00";//手动模式开
|
||||
btn.selected=NO;
|
||||
|
||||
}else {
|
||||
manulModel.switchBtn=@"01";// 手动模式关
|
||||
btn.selected=YES;
|
||||
}
|
||||
manulModel.crc16Str=@"0000";// CRC16验证码
|
||||
switch (btn.tag) {
|
||||
case LIGHT1_TAG:
|
||||
{
|
||||
|
||||
|
||||
if ([backmodel.yunxingmoshi isEqualToString:@"00"]) {
|
||||
btn.userInteractionEnabled=YES;
|
||||
[btn setImage:[UIImage imageNamed:@"PFLight1_on.png"] forState:UIControlStateSelected];
|
||||
manulModel.lightNumber=@"01";// 00 --灯1
|
||||
NSString*switchString2=[NSString stringWithFormat:@"%@%@%@%@",switchString1,manulModel.lightNumber,manulModel.switchBtn,manulModel.crc16Str];
|
||||
NSData*manulData=[dataContorl stringToHexData:switchString2];
|
||||
|
||||
[[Socketsingleton sharedInstance] soketWriteData:manulData];
|
||||
|
||||
if ([Socketsingleton sharedInstance].clientSocket.isConnected) {
|
||||
//soket 未断开时显示
|
||||
[self initHUD];
|
||||
[self.myhud myhudstart];
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
if ([manulModel.switchBtn isEqualToString:@"00"]) {
|
||||
btn.selected=YES;
|
||||
}else{
|
||||
btn.selected=NO;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LIGHT2_TAG:
|
||||
{
|
||||
if ([backmodel.yunxingmoshi isEqualToString:@"00"]) {
|
||||
btn.userInteractionEnabled=YES;
|
||||
[btn setImage:[UIImage imageNamed:@"PFLight1_on.png"] forState:UIControlStateSelected];
|
||||
manulModel.lightNumber=@"02";// 01 --灯2
|
||||
NSString*switchString2=[NSString stringWithFormat:@"%@%@%@%@",switchString1,manulModel.lightNumber,manulModel.switchBtn,manulModel.crc16Str];
|
||||
NSData*manulData=[dataContorl stringToHexData:switchString2];
|
||||
|
||||
[[Socketsingleton sharedInstance] soketWriteData:manulData];
|
||||
|
||||
if ([Socketsingleton sharedInstance].clientSocket.isConnected) {
|
||||
//soket 未断开时显示
|
||||
[self initHUD];
|
||||
[self.myhud myhudstart];
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
if ([manulModel.switchBtn isEqualToString:@"00"]) {
|
||||
btn.selected=YES;
|
||||
}else{
|
||||
btn.selected=NO;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PUMP_TAG:
|
||||
|
||||
{
|
||||
if ([backmodel.yunxingmoshi isEqualToString:@"00"]) {
|
||||
btn.userInteractionEnabled=YES;
|
||||
[btn setImage:[UIImage imageNamed:@"ChongLang_on.png"] forState:UIControlStateSelected];
|
||||
manulModel.lightNumber=@"03";// 02 --水泵
|
||||
NSString*switchString2=[NSString stringWithFormat:@"%@%@%@%@",switchString1,manulModel.lightNumber,manulModel.switchBtn,manulModel.crc16Str];
|
||||
NSData*manulData=[dataContorl stringToHexData:switchString2];
|
||||
|
||||
[[Socketsingleton sharedInstance] soketWriteData:manulData];
|
||||
|
||||
if ([Socketsingleton sharedInstance].clientSocket.isConnected) {
|
||||
//soket 未断开时显示
|
||||
[self initHUD];
|
||||
[self.myhud myhudstart];
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
if ([manulModel.switchBtn isEqualToString:@"00"]) {
|
||||
btn.selected=YES;
|
||||
}else{
|
||||
btn.selected=NO;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}else{
|
||||
//无工作模式
|
||||
|
||||
manulswitchMSModel*manulModel=[[manulswitchMSModel alloc]init];
|
||||
//设置指令mac地址
|
||||
[[Socketsingleton sharedInstance] setSoketLightDataWith:manulModel];
|
||||
NSString*switchString1=manulModel.description;
|
||||
if (btn.selected) {
|
||||
manulModel.switchBtn=@"00";//手动模式开
|
||||
btn.selected=NO;
|
||||
|
||||
}else {
|
||||
manulModel.switchBtn=@"01";// 手动模式关
|
||||
btn.selected=YES;
|
||||
}
|
||||
manulModel.crc16Str=@"0000";// CRC16验证码
|
||||
switch (btn.tag) {
|
||||
case LIGHT1_TAG:
|
||||
{
|
||||
|
||||
|
||||
|
||||
btn.userInteractionEnabled=YES;
|
||||
[btn setImage:[UIImage imageNamed:@"PFLight1_on.png"] forState:UIControlStateSelected];
|
||||
manulModel.lightNumber=@"01";// 00 --灯1
|
||||
NSString*switchString2=[NSString stringWithFormat:@"%@%@%@%@",switchString1,manulModel.lightNumber,manulModel.switchBtn,manulModel.crc16Str];
|
||||
NSData*manulData=[dataContorl stringToHexData:switchString2];
|
||||
|
||||
[[Socketsingleton sharedInstance] soketWriteData:manulData];
|
||||
|
||||
if ([Socketsingleton sharedInstance].clientSocket.isConnected) {
|
||||
//soket 未断开时显示
|
||||
[self initHUD];
|
||||
[self.myhud myhudstart];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case LIGHT2_TAG:
|
||||
{
|
||||
|
||||
btn.userInteractionEnabled=YES;
|
||||
[btn setImage:[UIImage imageNamed:@"PFLight1_on.png"] forState:UIControlStateSelected];
|
||||
manulModel.lightNumber=@"02";// 01 --灯2
|
||||
NSString*switchString2=[NSString stringWithFormat:@"%@%@%@%@",switchString1,manulModel.lightNumber,manulModel.switchBtn,manulModel.crc16Str];
|
||||
NSData*manulData=[dataContorl stringToHexData:switchString2];
|
||||
|
||||
[[Socketsingleton sharedInstance] soketWriteData:manulData];
|
||||
|
||||
if ([Socketsingleton sharedInstance].clientSocket.isConnected) {
|
||||
//soket 未断开时显示
|
||||
[self initHUD];
|
||||
[self.myhud myhudstart];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case PUMP_TAG:
|
||||
|
||||
{
|
||||
|
||||
btn.userInteractionEnabled=YES;
|
||||
[btn setImage:[UIImage imageNamed:@"ChongLang_on.png"] forState:UIControlStateSelected];
|
||||
manulModel.lightNumber=@"03";// 02 --水泵
|
||||
NSString*switchString2=[NSString stringWithFormat:@"%@%@%@%@",switchString1,manulModel.lightNumber,manulModel.switchBtn,manulModel.crc16Str];
|
||||
NSData*manulData=[dataContorl stringToHexData:switchString2];
|
||||
|
||||
[[Socketsingleton sharedInstance] soketWriteData:manulData];
|
||||
|
||||
if ([Socketsingleton sharedInstance].clientSocket.isConnected) {
|
||||
//soket 未断开时显示
|
||||
[self initHUD];
|
||||
[self.myhud myhudstart];
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - 三控界面设置btn点击事件
|
||||
|
||||
-(void)threeControlSetBtnAction:(UIButton*)btn{
|
||||
|
||||
NSLog(@"点击了设置");
|
||||
if (self.binddeviceArr.count ==0) {
|
||||
[self.view makeToast:@"暂未绑定设备"];
|
||||
}else{
|
||||
BackmassegeModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackInfo"];
|
||||
if (backmodel) {
|
||||
[self pushSetTimeVC];
|
||||
}else{
|
||||
[self deviceNotOnlineState];
|
||||
|
||||
[self showLableAction:@"设备已离线"];
|
||||
|
||||
[self.indicatorView stopAnimating];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - 设置图片点击事件
|
||||
|
||||
-(void)threeCenterViewSetTap{
|
||||
|
||||
NSLog(@"点击了图片");
|
||||
if (self.binddeviceArr.count ==0) {
|
||||
[self.view makeToast:@"暂未绑定设备"];
|
||||
}else{
|
||||
|
||||
|
||||
BackmassegeModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackInfo"];
|
||||
if (backmodel) {
|
||||
[self pushSetTimeVC];
|
||||
}else{
|
||||
[self showLableAction:@"设备已离线"];
|
||||
[self deviceNotOnlineState];
|
||||
[self.indicatorView stopAnimating];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - 锁屏图片点击事件
|
||||
|
||||
-(void)threeControlViewclockViewClick{
|
||||
|
||||
[self pushSetTimeVC];
|
||||
}
|
||||
|
||||
#pragma mark - 转跳设置界面
|
||||
|
||||
-(void)pushSetTimeVC{
|
||||
|
||||
_SetTimeVC=[[SetTimeController alloc]init];
|
||||
//_SetTimeVC.clientSocket= self.singletonSocket.clientSocket;
|
||||
_SetTimeVC.currentdevice=self.currentDevice;
|
||||
[self.navigationController pushViewController:_SetTimeVC animated:YES];
|
||||
|
||||
|
||||
//self.navigationBarHidden=NO;
|
||||
|
||||
}
|
||||
|
||||
#pragma mark 登陆成功后收到服务端的回执之后,调用的代理方法
|
||||
-(void)socketDidGetBackmsgData:(NSData *)data onsoket:(AsyncSocket *)sock{
|
||||
|
||||
NSLog(@"登陆成功后收收到服务器的回执--->%@",data);
|
||||
|
||||
//[sock readDataWithTimeout:-1 tag:0];
|
||||
NSString*string1=[dataContorl dataToHexString:data];
|
||||
|
||||
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 (_SetTimeVC.indicatorView) {
|
||||
[_SetTimeVC.indicatorView stopAnimating];
|
||||
}
|
||||
|
||||
|
||||
|
||||
self.dataLength=string1.length;
|
||||
|
||||
if (string1.length==IFISH_BACKMASGTYAP99) {
|
||||
//99 字节 全用BackmassegeModel
|
||||
|
||||
//三控 6定时器 99字节两控
|
||||
self.threeControltype = ThreeControlBackmsgTapeNinetyNineByte;
|
||||
[DeviceCommunicateDataUnity readSoketbackMassageOfThreeControlData:data WithModel:_backmodel];
|
||||
|
||||
if ([_backmodel.yunxingmoshi isEqualToString:@"00"]) {
|
||||
self.waringLabel.hidden=YES;
|
||||
self.clockView.hidden=YES;
|
||||
}else{
|
||||
self.clockView.hidden=NO;
|
||||
self.waringLabel.hidden=NO;
|
||||
}
|
||||
|
||||
if ([_backmodel.baojingSwitch isEqualToString:@"01"]) {
|
||||
|
||||
self.temperaturebackImg.hidden=NO;
|
||||
|
||||
}else{
|
||||
|
||||
self.temperaturebackImg.hidden=YES;
|
||||
|
||||
}
|
||||
|
||||
}else if (string1.length==IFISH_BACKMASGTYAP71){
|
||||
|
||||
self.threeControltype = ThreeControlBackmsgTapeSenventyOneByte;
|
||||
[DeviceCommunicateDataUnity readSoketThreeControlBackMassageData:data WithModel:_backmodel];
|
||||
|
||||
if ([_backmodel.yunxingmoshi isEqualToString:@"00"]) {
|
||||
self.waringLabel.hidden=YES;
|
||||
self.clockView.hidden=YES;
|
||||
}else{
|
||||
self.clockView.hidden=NO;
|
||||
self.waringLabel.hidden=NO;
|
||||
}
|
||||
|
||||
//背景图片状态
|
||||
|
||||
if ([_backmodel.baojingSwitch isEqualToString:@"01"]) {
|
||||
|
||||
self.temperaturebackImg.hidden=NO;
|
||||
// self.shuixiangwendu.hidden=YES;
|
||||
|
||||
}else{
|
||||
|
||||
self.temperaturebackImg.hidden=YES;
|
||||
//self.shuixiangwendu.hidden=NO;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//按钮状态
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
|
||||
switch (self.threeControltype) {
|
||||
|
||||
case ThreeControlBackmsgTapeSenventyOneByte:
|
||||
{
|
||||
|
||||
[DeviceCommunicateDataUnity resetThreeControlButtonState:_light1Button addlight2:_light2Button addpump:_pumpButton withBackModel:_backmodel];
|
||||
// 实时刷新设置界面 时间设置
|
||||
_SetTimeVC.timeArr=[DeviceCommunicateDataUnity refreshThreeControlTimerAddTemperatureWithBackMassageModel:_backmodel];
|
||||
[_SetTimeVC.tableView reloadData];
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case ThreeControlBackmsgTapeNinetyNineByte:
|
||||
{
|
||||
[DeviceCommunicateDataUnity resetThreeControlButtonState:_light1Button addlight2:_light2Button addpump:_pumpButton withBackModel:_backmodel];
|
||||
// 实时刷新设置界面 时间设置
|
||||
_SetTimeVC.timeArr=[DeviceCommunicateDataUnity refreshThreeControlTimerAddTemperatureWithBackMassageModel:_backmodel];
|
||||
[_SetTimeVC.tableView reloadData];
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//温度label
|
||||
[DeviceCommunicateDataUnity setTemperaturelabel:self.temperature addTemperaturebackImg:self.temperaturebackImg addbubleImge:self.bubble WithBackData:data addWithBackMassageModel:_backmodel addWithTableview:self.tableView] ;
|
||||
|
||||
[self endRefreshing];
|
||||
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
//设备登陆成功
|
||||
-(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 = [[ThreeControlNameViewController 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{
|
||||
|
||||
ThreeControlName *name = [UserExtendataArchaver currentThreeControlName:self.currentDevice.macAddress];
|
||||
self.light1name.text = name.light1Name;
|
||||
self.light2name.text = name.light2Name;
|
||||
|
||||
self.pumpname.text = name.pumpName;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// ThreeControlName.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 2017/6/15.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface ThreeControlName : NSObject
|
||||
@property(nonatomic,copy) NSString *light1Name;
|
||||
@property(nonatomic,copy) NSString *light2Name;
|
||||
@property(nonatomic,copy) NSString *pumpName;
|
||||
@property(nonatomic,copy) NSString *macAddress;
|
||||
@end
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// ThreeControlName.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 2017/6/15.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ThreeControlName.h"
|
||||
|
||||
@implementation ThreeControlName
|
||||
-(void)encodeWithCoder:(NSCoder*)aCoder{
|
||||
|
||||
[aCoder encodeObject:_light1Name forKey:@"light1Name"];
|
||||
[aCoder encodeObject:_light2Name forKey:@"light2Name"];
|
||||
[aCoder encodeObject:_pumpName forKey:@"pumpName"];
|
||||
[aCoder encodeObject:_macAddress forKey:@"macAddress"];
|
||||
|
||||
}
|
||||
|
||||
-(id)initWithCoder:(NSCoder*)aDecoder{
|
||||
if (self=[super init]) {
|
||||
|
||||
self.light1Name=[aDecoder decodeObjectForKey:@"light1Name"];
|
||||
self.light2Name=[aDecoder decodeObjectForKey:@"light2Name"];
|
||||
self.pumpName=[aDecoder decodeObjectForKey:@"pumpName"];
|
||||
self.macAddress = [aDecoder decodeObjectForKey:@"macAddress"];
|
||||
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// ThreeControlNameViewController.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 2017/6/15.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "IfishDeviceControlNameBaseController.h"
|
||||
|
||||
@interface ThreeControlNameViewController : IfishDeviceControlNameBaseController
|
||||
|
||||
@end
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
//
|
||||
// ThreeControlNameViewController.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 2017/6/15.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "ThreeControlNameViewController.h"
|
||||
#import "RuSunChangeNameTextViewCell.h"
|
||||
#import "ThreeControlName.h"
|
||||
#import "UserExtendataArchaver.h"
|
||||
#define THREECHCELL_LIANGHT1 30000
|
||||
#define THREECHCELL_LIANGHT2 30001
|
||||
#define THREECHCELL_PUMP 30002
|
||||
|
||||
@interface ThreeControlNameViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation ThreeControlNameViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
self.tableView.dataSource =self;
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||||
|
||||
if (section==0) {
|
||||
|
||||
return 1;
|
||||
|
||||
}else{
|
||||
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
|
||||
if (indexPath.section==0) {
|
||||
|
||||
return [super baseViewLoadDeviceNameCell:indexPath intable:tableView];
|
||||
}
|
||||
|
||||
RuSunChangeNameTextViewCell*cell=[tableView dequeueReusableCellWithIdentifier:@"RuSunChangeNameTextViewCell"];
|
||||
if (cell==nil) {
|
||||
cell= [[[NSBundle mainBundle]loadNibNamed:@"RuSunChangeNameTextViewCell" owner:self options:nil]lastObject];
|
||||
|
||||
}
|
||||
|
||||
//控制原名
|
||||
if (indexPath.row==2&&indexPath.section==1) {
|
||||
cell.lineImgView.image = [UIImage imageNamed:@"redact_line_last"];
|
||||
|
||||
}
|
||||
NSArray *titles= @[@"灯1",@"灯2",@"UV/冲浪"];
|
||||
if (indexPath.section==1) {
|
||||
cell.chTitle.text = titles[indexPath.row];
|
||||
}
|
||||
|
||||
//自定义名字
|
||||
ThreeControlName *name = [UserExtendataArchaver currentThreeControlName:self.device.macAddress];
|
||||
if (indexPath.section==1&&indexPath.row==0) {
|
||||
cell.chName.text = name.light1Name;
|
||||
|
||||
}else if (indexPath.section==1&&indexPath.row==1){
|
||||
cell.chName.text = name.light2Name;
|
||||
|
||||
}else if (indexPath.section==1&&indexPath.row==2){
|
||||
cell.chName.text = name.pumpName;
|
||||
}
|
||||
cell.chName.delegate = self;
|
||||
cell.tag = 30000 + indexPath.row;
|
||||
return cell;
|
||||
}
|
||||
|
||||
-(void)sureAction
|
||||
{
|
||||
|
||||
|
||||
//RunSunCHNameCustom 本地处理 保存按钮名称 不与服务器交互
|
||||
ThreeControlName *name = [[ThreeControlName alloc] init];
|
||||
RuSunChangeNameTextViewCell*cell1 = [self.view viewWithTag:THREECHCELL_LIANGHT1];
|
||||
if (cell1.chName.text.length>3) {
|
||||
[self.view makeToast:@"灯1不能超过3个字"];
|
||||
return;
|
||||
}
|
||||
if (cell1.chName.text.length==0) {
|
||||
[self.view makeToast:@"灯1不能为空"];
|
||||
return;
|
||||
}
|
||||
name.light1Name = cell1.chName.text;
|
||||
|
||||
RuSunChangeNameTextViewCell*cell2 = [self.view viewWithTag:THREECHCELL_LIANGHT2];
|
||||
if (cell2.chName.text.length>3) {
|
||||
[self.view makeToast:@"灯2不能超过3个字"];
|
||||
return;
|
||||
}
|
||||
if (cell2.chName.text.length==0) {
|
||||
[self.view makeToast:@"灯2不能为空"];
|
||||
return;
|
||||
}
|
||||
name.light2Name = cell2.chName.text;
|
||||
|
||||
|
||||
RuSunChangeNameTextViewCell*cell3 = [self.view viewWithTag:THREECHCELL_PUMP];
|
||||
if (cell3.chName.text.length>3) {
|
||||
[self.view makeToast:@"水泵不能超过3个字"];
|
||||
return;
|
||||
}
|
||||
if (cell3.chName.text.length==0) {
|
||||
[self.view makeToast:@"水泵不能为空"];
|
||||
return;
|
||||
}
|
||||
name.pumpName = cell3.chName.text;
|
||||
|
||||
name.macAddress = self.device.macAddress;
|
||||
[UserExtendataArchaver saveThreeControlName:name];
|
||||
|
||||
[self upLoadDeviceName];
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
#pragma mark - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
// Get the new view controller using [segue destinationViewController].
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user