Initial commit
This commit is contained in:
+66
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// TwoControlBackMsgDataUtil.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/4/19.
|
||||
// Copyright © 2016年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "BackmassegeModel.h"
|
||||
@interface TwoControlBackMsgDataUtil : NSObject
|
||||
|
||||
/**
|
||||
* 99字节 2控四定时器界面
|
||||
*
|
||||
* @param backModel
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
//+(NSArray*)refreshTwoControlSetViewWithBackMassageModel:(BackmassegeModel*)backModel;
|
||||
|
||||
|
||||
//****两控协议部分****//
|
||||
/**
|
||||
*注两控又分为 两控四定时器和两控零定时器。。。根据设备model controlAmount 和timerAmount 可做区分
|
||||
*/
|
||||
/**
|
||||
* 实时更新设置界面时间与温度显示 四定时器
|
||||
*
|
||||
* @param backModel backModel description
|
||||
*
|
||||
* @return return value description
|
||||
*/
|
||||
|
||||
//+(NSArray*)refreshTwoControlTimerAddTemperatureWithBackMassageModel:(TwoControlBackmsgmodel*)backModel;
|
||||
/**
|
||||
* 实时更新设置界面时间与温度显示 零定时器
|
||||
*
|
||||
* @param backModel
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
//+(NSArray*)refreshTwoControlTimerWithBackMassageModel:(TwoControlBackmsgmodel*)backModel;
|
||||
|
||||
/**
|
||||
* 根据返回信息重置 两控按钮状态
|
||||
*
|
||||
* @param light1 light1 description
|
||||
* @param pump pump description
|
||||
* @param backModel backModel description
|
||||
*/
|
||||
|
||||
//+(void)resetTwoControlButtonState:(UIButton*)light1 addpump:(UIButton*)pump withBackModel:(TwoControlBackmsgmodel*)backModel;
|
||||
/**
|
||||
* 读取soket返回信息2控
|
||||
*
|
||||
* @param data
|
||||
* @param backModel
|
||||
*/
|
||||
//+(void)readSoketbackMassageOfTwoControlData:(NSData*)data WithModel:(TwoControlBackmsgmodel*)backModel;
|
||||
|
||||
|
||||
//+(void)setTwoControlTemperaturelabel:(UILabel*)temperaturelabel addTemperaturebackImg:(UIImageView*)temperaturebackImg addshuixiangwenduLabel:(UILabel*)shuixiangwenduLabel WithBackData:(NSData*)data addWithBackMassageModel:(TwoControlBackmsgmodel*)backModel addWithTableview:(UITableView*)tableview;
|
||||
|
||||
@end
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// TwoControlBackMsgDataUtil.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/4/19.
|
||||
// Copyright © 2016年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TwoControlBackMsgDataUtil.h"
|
||||
//两控 soket 返回信息解析类
|
||||
|
||||
@implementation TwoControlBackMsgDataUtil
|
||||
|
||||
|
||||
@end
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// TwoControlCenterController.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/4/8.
|
||||
// Copyright © 2016年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "CenterViewController.h"
|
||||
#import "AsyncSocket.h"
|
||||
/*
|
||||
两控主界面 0b 普通 0d 闽江 两种
|
||||
*/
|
||||
@interface TwoControlCenterController : CenterViewController
|
||||
|
||||
|
||||
@property(nonatomic,strong)UIButton*button;
|
||||
@property(nonatomic,strong)UIButton*light1Button;
|
||||
@property(nonatomic,strong)UIButton*pumpButton;
|
||||
|
||||
@property(nonatomic,strong)UILabel*buttonNameLabel;
|
||||
@property(nonatomic,strong)UILabel*light1name;
|
||||
@property(nonatomic,strong)UILabel*pumpname;
|
||||
|
||||
@end
|
||||
+649
@@ -0,0 +1,649 @@
|
||||
//
|
||||
// TwoControlCenterController.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/4/8.
|
||||
// Copyright © 2016年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TwoControlCenterController.h"
|
||||
#import "BackmassegeModel.h"
|
||||
#import "manulswitchMSModel.h"
|
||||
#define TWOC_PUMP 211
|
||||
#define TWOC_LIGHT 210
|
||||
#import "TwoControlSetTimeViewController.h"
|
||||
#import "TwoControlnoneTimerViewController.h"
|
||||
#import "TwoControlNinetyninebiteViewController.h"
|
||||
#import "TwoControlName.h"
|
||||
#import "TwoControlNameViewController.h"
|
||||
#import "UserExtendataArchaver.h"
|
||||
//两控 返回消息类型
|
||||
typedef NS_ENUM(NSInteger,TwoControBackMsgTape){
|
||||
//两控四定时器 返回消息类型57字节
|
||||
TwoControlBackmsgTapeFiftySevenByteAddFourTimer,
|
||||
//两控零定时器 返回消息类型57字节
|
||||
TwoControlBackmsgTapeFiftySevenByteAddZoreTimer,
|
||||
// 零控四定时器 返回消息类型 99 字节
|
||||
TwoControlBackmsgTapeNinetyNineByteAddFourTimer
|
||||
|
||||
};
|
||||
|
||||
@interface TwoControlCenterController ()
|
||||
|
||||
@property (nonatomic ,assign) TwoControBackMsgTape BackMsgTape;
|
||||
|
||||
|
||||
@property(nonatomic,strong)BackmassegeModel*backmodel;
|
||||
|
||||
@property(nonatomic,strong)TwoControlBackmsgmodel*twoControlBackModel;
|
||||
|
||||
@property(nonatomic,strong) TwoControlSetTimeViewController *twoControlSetTimeVC;
|
||||
@property(nonatomic,strong) TwoControlnoneTimerViewController *twocontrolNonetimerVC;
|
||||
@property(nonatomic,strong) TwoControlNinetyninebiteViewController * twoControlNinetyninebiteVC;
|
||||
@property (nonatomic,strong) TwoControlNameViewController *changeNameVC ;
|
||||
@end
|
||||
|
||||
@implementation TwoControlCenterController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
|
||||
|
||||
[Socketsingleton sharedInstance].communiteDelegate=self;
|
||||
|
||||
_backmodel=[[BackmassegeModel alloc]init];
|
||||
|
||||
_twoControlBackModel=[[TwoControlBackmsgmodel alloc]init];
|
||||
|
||||
|
||||
//主界面按钮事件分离
|
||||
[self.setbackBtn addTarget:self action:@selector(twoControlSetBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.SetTimeButton addTarget:self action:@selector(twoControlSetBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
UITapGestureRecognizer*tapgestureRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(twoCenterViewSetTap)];
|
||||
[self.setImag addGestureRecognizer:tapgestureRecognizer];
|
||||
|
||||
UITapGestureRecognizer*tapGesture=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(TwoControlViewclockViewClick)];
|
||||
self.clockView.userInteractionEnabled=YES;
|
||||
[self.clockView addGestureRecognizer:tapGesture];
|
||||
|
||||
|
||||
|
||||
[self initTwoControlButton];
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - 两控界面设置btn点击事件
|
||||
|
||||
-(void)twoControlSetBtnAction:(UIButton*)btn{
|
||||
NSLog(@"点击了设置");
|
||||
|
||||
if ([self.binddeviceArr count]==0) {
|
||||
|
||||
[self pushWiFiConnectVC];
|
||||
|
||||
}else{
|
||||
|
||||
[self pushSetTimeVC];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - 设置图片点击事件
|
||||
|
||||
-(void)twoCenterViewSetTap{
|
||||
|
||||
NSLog(@"点击了图片");
|
||||
if ([self.binddeviceArr count]==0) {
|
||||
|
||||
[self pushWiFiConnectVC];
|
||||
|
||||
}else{
|
||||
|
||||
[self pushSetTimeVC];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - 锁屏图片点击事件
|
||||
|
||||
-(void)TwoControlViewclockViewClick{
|
||||
|
||||
[self pushSetTimeVC];
|
||||
}
|
||||
|
||||
#pragma mark - 转跳设置界面
|
||||
|
||||
-(void)pushSetTimeVC{
|
||||
|
||||
|
||||
switch (self.BackMsgTape) {
|
||||
|
||||
case TwoControlBackmsgTapeNinetyNineByteAddFourTimer:
|
||||
{
|
||||
BackmassegeModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackInfo"];
|
||||
if (backmodel) {
|
||||
|
||||
|
||||
|
||||
_twoControlNinetyninebiteVC=[[TwoControlNinetyninebiteViewController alloc]init];
|
||||
|
||||
_twoControlNinetyninebiteVC.currentdevice=self.currentDevice;
|
||||
[self.navigationController pushViewController:_twoControlNinetyninebiteVC animated:YES];
|
||||
//self.navigationBarHidden=NO;
|
||||
|
||||
|
||||
|
||||
}else{
|
||||
[self showLableAction:@"设备已离线"];
|
||||
[self deviceNotOnlineState];
|
||||
[self.indicatorView stopAnimating];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
case TwoControlBackmsgTapeFiftySevenByteAddFourTimer:
|
||||
{
|
||||
TwoControlBackmsgmodel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackTwoControlInfo"];
|
||||
|
||||
if (backmodel) {
|
||||
|
||||
|
||||
_twoControlSetTimeVC=[[TwoControlSetTimeViewController alloc]init];
|
||||
|
||||
|
||||
_twoControlSetTimeVC.currentdevice=self.currentDevice;
|
||||
|
||||
[self.navigationController pushViewController:_twoControlSetTimeVC animated:YES];
|
||||
//self.navigationBarHidden=NO;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}else{
|
||||
[self.indicatorView stopAnimating];
|
||||
[self deviceNotOnlineState];
|
||||
[self showLableAction:@"设备已离线"];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case TwoControlBackmsgTapeFiftySevenByteAddZoreTimer:
|
||||
{
|
||||
TwoControlBackmsgmodel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackTwoControlInfo"];
|
||||
|
||||
if (backmodel) {
|
||||
|
||||
|
||||
_twocontrolNonetimerVC=[[TwoControlnoneTimerViewController alloc]init];
|
||||
|
||||
_twocontrolNonetimerVC.currentdevice=self.currentDevice;
|
||||
|
||||
[self.navigationController pushViewController:_twocontrolNonetimerVC animated:YES];
|
||||
// self.navigationBarHidden=NO;
|
||||
|
||||
}else{
|
||||
|
||||
[self.indicatorView stopAnimating];
|
||||
[self deviceNotOnlineState];
|
||||
[self showLableAction:@"设备已离线"];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - 初始化两控按钮
|
||||
|
||||
-(void)initTwoControlButton{
|
||||
if (self.button) {
|
||||
self.button=nil;
|
||||
}
|
||||
// AppDelegate*mydelegate=(AppDelegate*)[[UIApplication sharedApplication]delegate];
|
||||
NSArray*twoControlNormalImgArr=@[@"PFLight1_off.png",@"ChongLang_off.png"];
|
||||
|
||||
CGFloat buttonSize=kScreenSize.width*7/32;
|
||||
CGFloat space=(kScreenSize.width-2*buttonSize)/3;
|
||||
|
||||
|
||||
for (int i=0; i<twoControlNormalImgArr.count; i++) {
|
||||
self.button=[UIButton buttonWithType:UIButtonTypeCustom];
|
||||
|
||||
self.button.frame = CGRectMake(space+i*(buttonSize+space) + 10 ,kScreenSize.height - buttonSize - 20 - 64 - 20 , buttonSize * 105 / 122 , buttonSize );
|
||||
|
||||
|
||||
[self.button setImage:[UIImage imageNamed:twoControlNormalImgArr[i]] forState:UIControlStateNormal];
|
||||
[self.button addTarget:self action:@selector(TwoControlButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
// self.button.backgroundColor = [UIColor blackColor];
|
||||
self.button.tag=210+i;
|
||||
|
||||
[self.tableView addSubview:self.button];
|
||||
|
||||
if (i==0) {
|
||||
|
||||
self.light1Button=self.button;
|
||||
|
||||
}else if (i==1){
|
||||
|
||||
self.pumpButton=self.button;
|
||||
}
|
||||
}
|
||||
|
||||
// CGFloat wSpace=(kScreenSize.width-wSpace2*2-2*60)/2;
|
||||
NSArray*arry=@[@"灯",@"水泵"];
|
||||
|
||||
for (int j=0; j<arry.count; j++){
|
||||
|
||||
self.buttonNameLabel=[[UILabel alloc]initWithFrame:CGRectMake(space+j*(buttonSize+space) + 10, kScreenSize.height - 20 - 64 - 30 , buttonSize * 105 / 122, 20)];
|
||||
|
||||
|
||||
|
||||
self.buttonNameLabel.text=arry[j];
|
||||
self.buttonNameLabel.font=[UIFont systemFontOfSize:15];
|
||||
self.buttonNameLabel.textAlignment=NSTextAlignmentCenter;
|
||||
self.buttonNameLabel.tag=220+j;
|
||||
self.buttonNameLabel.textColor=[UIColor colorWithRed:101/255.0f green:103/255.0f blue:103/254.0f alpha:1];
|
||||
|
||||
[self.tableView addSubview:self.buttonNameLabel];
|
||||
|
||||
if (j==0) {
|
||||
self.light1name=self.buttonNameLabel;
|
||||
|
||||
|
||||
}else if (j==1){
|
||||
|
||||
self.pumpname=self.buttonNameLabel;
|
||||
}
|
||||
}
|
||||
|
||||
[self initCHNames];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark 两控按钮点击事件
|
||||
|
||||
-(void)TwoControlButtonClick:(UIButton*)btn{
|
||||
|
||||
if (self.dataLength==198) {
|
||||
BackmassegeModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackInfo"];
|
||||
if (backmodel) {
|
||||
|
||||
}else{
|
||||
[self showLableAction:@"设备已离线"];
|
||||
[self.indicatorView stopAnimating];
|
||||
}
|
||||
|
||||
manulswitchMSModel*manulModel=[[manulswitchMSModel alloc]init];
|
||||
[[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 TWOC_PUMP:
|
||||
{
|
||||
btn.userInteractionEnabled=YES;
|
||||
[btn setImage:[UIImage imageNamed:@"ChongLang_on.png"] forState:UIControlStateSelected];
|
||||
manulModel.lightNumber=@"02";// 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;
|
||||
case TWOC_LIGHT:
|
||||
{
|
||||
|
||||
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;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}else if (self.dataLength==114){
|
||||
TwoControlBackmsgmodel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackTwoControlInfo"];
|
||||
if (backmodel) {
|
||||
|
||||
}else{
|
||||
[self showLableAction:@"设备已离线"];
|
||||
[self.indicatorView stopAnimating];
|
||||
}
|
||||
|
||||
|
||||
manulswitchMSModel*manulModel=[[manulswitchMSModel alloc]init];
|
||||
[[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 TWOC_PUMP:
|
||||
{
|
||||
|
||||
btn.userInteractionEnabled=YES;
|
||||
[btn setImage:[UIImage imageNamed:@"ChongLang_on.png"] forState:UIControlStateSelected];
|
||||
manulModel.lightNumber=@"02";// 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;
|
||||
case TWOC_LIGHT:
|
||||
{
|
||||
|
||||
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;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma mark 登陆成功后收到服务端的回执之后,调用的代理方法
|
||||
-(void)socketDidGetBackmsgData:(NSData *)data onsoket:(AsyncSocket *)sock{
|
||||
|
||||
NSLog(@"TwoControlView收到服务器的回执--->%@",data);
|
||||
|
||||
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 (_twoControlSetTimeVC.indicatorView) {
|
||||
[_twoControlSetTimeVC.indicatorView stopAnimating];
|
||||
}
|
||||
|
||||
if (_twocontrolNonetimerVC.indicatorView) {
|
||||
[_twocontrolNonetimerVC.indicatorView stopAnimating];
|
||||
}
|
||||
if (_twoControlNinetyninebiteVC.indicatorView) {
|
||||
[_twoControlNinetyninebiteVC.indicatorView stopAnimating];
|
||||
}
|
||||
|
||||
NSLog(@"收到服务器的回执2--->%@",data);
|
||||
|
||||
self.dataLength=string1.length;
|
||||
|
||||
int timerAmount=[self.currentDevice.timerAmount intValue];
|
||||
|
||||
if (string1.length==IFISH_BACKMASGTYAP99) {
|
||||
//99 字节 全用BackmassegeModel
|
||||
|
||||
// 99字节两控 4定时器
|
||||
self.BackMsgTape = TwoControlBackmsgTapeNinetyNineByteAddFourTimer;
|
||||
[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;
|
||||
// self.shuixiangwendu.hidden=YES;
|
||||
|
||||
}else{
|
||||
self.temperaturebackImg.hidden=YES;
|
||||
//self.shuixiangwendu.hidden=NO;
|
||||
}
|
||||
|
||||
}else if (string1.length==IFISH_BACKMASGTYAP57){
|
||||
|
||||
|
||||
[DeviceCommunicateDataUnity readSoketbackMassageOfTwoControlData:data WithModel:_twoControlBackModel];
|
||||
if ( timerAmount == 0) {
|
||||
self.BackMsgTape = TwoControlBackmsgTapeFiftySevenByteAddZoreTimer;
|
||||
self.waringLabel.hidden=YES;
|
||||
self.clockView.hidden=YES;
|
||||
self.light1Button.userInteractionEnabled=YES;
|
||||
self.pumpButton.userInteractionEnabled=YES;
|
||||
if ([_twoControlBackModel.baojingSwitch isEqualToString:@"01"]) {
|
||||
|
||||
self.temperaturebackImg.hidden=NO;
|
||||
// self.shuixiangwendu.hidden=YES;
|
||||
|
||||
}else{
|
||||
self.temperaturebackImg.hidden=YES;
|
||||
// self.shuixiangwendu.hidden=NO;
|
||||
}
|
||||
|
||||
|
||||
}else if (timerAmount == 4){
|
||||
self.BackMsgTape = TwoControlBackmsgTapeFiftySevenByteAddFourTimer;
|
||||
if ([_twoControlBackModel.yunxingmoshi isEqualToString:@"00"]) {
|
||||
self.waringLabel.hidden=YES;
|
||||
self.clockView.hidden=YES;
|
||||
}else{
|
||||
self.clockView.hidden=NO;
|
||||
self.waringLabel.hidden=NO;
|
||||
}
|
||||
//背景图片状态
|
||||
if ([_twoControlBackModel.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.BackMsgTape) {
|
||||
|
||||
case TwoControlBackmsgTapeFiftySevenByteAddZoreTimer:
|
||||
{
|
||||
//两控零定时器 //暂适配闽江
|
||||
[DeviceCommunicateDataUnity resetTwoControlButtonState:self.light1Button addpump:self.pumpButton withBackModel:_twoControlBackModel];
|
||||
// 实时刷新设置界面 时间设置
|
||||
_twocontrolNonetimerVC.timeArr=[DeviceCommunicateDataUnity refreshTwoControlTimerWithBackMassageModel:_twoControlBackModel];
|
||||
|
||||
[_twocontrolNonetimerVC.tableView reloadData];
|
||||
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case TwoControlBackmsgTapeFiftySevenByteAddFourTimer:
|
||||
{
|
||||
//57字节两控四定时器按钮状态
|
||||
[DeviceCommunicateDataUnity resetTwoControlButtonState:_light1Button addpump:_pumpButton withBackModel:_twoControlBackModel];
|
||||
// 实时刷新设置界面 时间设置
|
||||
_twoControlSetTimeVC.timeArr=[DeviceCommunicateDataUnity refreshTwoControlTimerAddTemperatureWithBackMassageModel:_twoControlBackModel];
|
||||
[_twoControlSetTimeVC.tableView reloadData];
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case TwoControlBackmsgTapeNinetyNineByteAddFourTimer:
|
||||
{
|
||||
//99字节两控四定时器按钮状态
|
||||
[DeviceCommunicateDataUnity resettwoControlbutton:_light1Button addpump:_pumpButton withbackmsgModel:_backmodel];
|
||||
//对应设置界面刷新UI
|
||||
_twoControlNinetyninebiteVC.timeArr=[DeviceCommunicateDataUnity refreshTwoControlSetViewWithBackMassageModel:_backmodel];
|
||||
[_twoControlNinetyninebiteVC.tableView reloadData];
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
//温度label
|
||||
|
||||
if (string1.length==IFISH_BACKMASGTYAP99) {
|
||||
|
||||
[DeviceCommunicateDataUnity setTemperaturelabel:self.temperature addTemperaturebackImg:self.temperaturebackImg addbubleImge:self.bubble WithBackData:data addWithBackMassageModel:_backmodel addWithTableview:self.tableView];
|
||||
|
||||
}else if (string1.length==IFISH_BACKMASGTYAP57){
|
||||
[DeviceCommunicateDataUnity setTwoControlTemperaturelabel:self.temperature addTemperaturebackImg:self.temperaturebackImg addbubleImg:self.bubble WithBackData:data addWithBackMassageModel:_twoControlBackModel 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 = [[TwoControlNameViewController 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{
|
||||
|
||||
TwoControlName *name = [UserExtendataArchaver currentTwoControlName:self.currentDevice.macAddress];
|
||||
self.light1name.text = name.lightName;
|
||||
self.pumpname.text = name.pumpName;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// TwoControlName.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 2017/6/14.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface TwoControlName : NSObject
|
||||
@property (nonatomic,copy) NSString *lightName;
|
||||
@property (nonatomic,copy) NSString *pumpName;
|
||||
@property (nonatomic,copy) NSString *macAddress;
|
||||
|
||||
@end
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// TwoControlName.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 2017/6/14.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TwoControlName.h"
|
||||
|
||||
@implementation TwoControlName
|
||||
-(void)encodeWithCoder:(NSCoder*)aCoder{
|
||||
|
||||
[aCoder encodeObject:_lightName forKey:@"lightName"];
|
||||
[aCoder encodeObject:_pumpName forKey:@"pumpName"];
|
||||
[aCoder encodeObject:_macAddress forKey:@"macAddress"];
|
||||
}
|
||||
|
||||
-(id)initWithCoder:(NSCoder*)aDecoder{
|
||||
if (self=[super init]) {
|
||||
|
||||
self.lightName=[aDecoder decodeObjectForKey:@"lightName"];
|
||||
self.pumpName=[aDecoder decodeObjectForKey:@"pumpName"];
|
||||
self.macAddress = [aDecoder decodeObjectForKey:@"macAddress"];
|
||||
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// TwoControlNameViewController.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 2017/6/14.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "IfishDeviceControlNameBaseController.h"
|
||||
//普通两空 和 闽江两空 修改名字界面
|
||||
@interface TwoControlNameViewController : IfishDeviceControlNameBaseController
|
||||
|
||||
@end
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
//
|
||||
// TwoControlNameViewController.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 2017/6/14.
|
||||
// Copyright © 2017年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TwoControlNameViewController.h"
|
||||
#import "RuSunChangeNameTextViewCell.h"
|
||||
#import "TwoControlName.h"
|
||||
#import "UserExtendataArchaver.h"
|
||||
#define TWOCHCELL_LIANGHT 20000
|
||||
#define TWOCHCELL_PUMP 20001
|
||||
@interface TwoControlNameViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation TwoControlNameViewController
|
||||
|
||||
- (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 2;
|
||||
}
|
||||
}
|
||||
|
||||
-(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==1&&indexPath.section==1) {
|
||||
cell.lineImgView.image = [UIImage imageNamed:@"redact_line_last"];
|
||||
|
||||
}
|
||||
NSArray *titles= @[@"灯1",@"水泵"];
|
||||
if (indexPath.section==1) {
|
||||
cell.chTitle.text = titles[indexPath.row];
|
||||
}
|
||||
|
||||
//自定义名字
|
||||
TwoControlName *name = [UserExtendataArchaver currentTwoControlName:self.device.macAddress];
|
||||
if (indexPath.section==1&&indexPath.row==0) {
|
||||
cell.chName.text = name.lightName;
|
||||
|
||||
}else if (indexPath.section==1&&indexPath.row==1){
|
||||
cell.chName.text = name.pumpName;
|
||||
}
|
||||
cell.chName.delegate = self;
|
||||
cell.tag = 20000 + indexPath.row;
|
||||
return cell;
|
||||
}
|
||||
|
||||
-(void)sureAction
|
||||
{
|
||||
|
||||
|
||||
//RunSunCHNameCustom 本地处理 保存按钮名称 不与服务器交互
|
||||
TwoControlName *name = [[TwoControlName alloc] init];
|
||||
RuSunChangeNameTextViewCell*cell1 = [self.view viewWithTag:TWOCHCELL_LIANGHT];
|
||||
if (cell1.chName.text.length>3) {
|
||||
[self.view makeToast:@"灯1不能超过3个字"];
|
||||
return;
|
||||
}
|
||||
if (cell1.chName.text.length==0) {
|
||||
[self.view makeToast:@"灯1不能为空"];
|
||||
return;
|
||||
}
|
||||
name.lightName = cell1.chName.text;
|
||||
|
||||
RuSunChangeNameTextViewCell*cell2 = [self.view viewWithTag:TWOCHCELL_PUMP];
|
||||
if (cell2.chName.text.length>3) {
|
||||
[self.view makeToast:@"水泵不能超过3个字"];
|
||||
return;
|
||||
}
|
||||
if (cell2.chName.text.length==0) {
|
||||
[self.view makeToast:@"水泵不能为空"];
|
||||
return;
|
||||
}
|
||||
name.pumpName = cell2.chName.text;
|
||||
|
||||
name.macAddress = self.device.macAddress;
|
||||
[UserExtendataArchaver saveTwoControlName: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
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// TwoControlNinetyninebiteViewController.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/3/7.
|
||||
// Copyright © 2016年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "FatherController.h"
|
||||
/*
|
||||
张工 两控 soket返回99 字节
|
||||
*/
|
||||
#import "Socketsingleton.h"
|
||||
@interface TwoControlNinetyninebiteViewController : FatherController
|
||||
{
|
||||
BOOL _isHidden;
|
||||
BOOL mySwitchIsOn;
|
||||
|
||||
}
|
||||
|
||||
@property(nonatomic,strong)NSArray*timeArr;
|
||||
@property(nonatomic,strong)NSArray*titleArr;
|
||||
@property(nonatomic)BOOL isAuto;// 自动模式
|
||||
|
||||
|
||||
@property(nonatomic,strong)NSMutableArray*switchCellArr;
|
||||
@property(nonatomic,strong)NSMutableArray*mySwitchButtonArry;
|
||||
@property(nonatomic,strong)UIButton*mySwitchButton;
|
||||
@property(nonatomic,strong)NSMutableArray*indexpatchArr;
|
||||
@property(nonatomic,strong)NSArray*selcterTimerArr;
|
||||
@property(nonatomic,strong)NSArray*selectorSwitchArr;// 时间段开关数组
|
||||
@property(nonatomic)UIActivityIndicatorView*indicatorView;
|
||||
-(void)addAlertView;
|
||||
|
||||
@property(nonatomic)int percent;
|
||||
@property(nonatomic,strong) DeviceModel* currentdevice;
|
||||
@end
|
||||
+1501
File diff suppressed because it is too large
Load Diff
+36
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// TwoControlSetTimeViewController.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/1/27.
|
||||
// Copyright © 2016年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "FatherController.h"
|
||||
|
||||
#import "Socketsingleton.h"
|
||||
//两控四定时器
|
||||
|
||||
@interface TwoControlSetTimeViewController : 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
|
||||
+1505
File diff suppressed because it is too large
Load Diff
+33
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// TwoControlnoneTimerViewController.h
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/2/26.
|
||||
// Copyright © 2016年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "FatherController.h"
|
||||
//两控 零定时器
|
||||
#import "Socketsingleton.h"
|
||||
@interface TwoControlnoneTimerViewController : FatherController
|
||||
{
|
||||
BOOL _isHidden;
|
||||
BOOL mySwitchIsOn;
|
||||
|
||||
}
|
||||
|
||||
@property(nonatomic,strong)NSArray*timeArr;
|
||||
|
||||
@property(nonatomic,strong)NSArray*titleArr;
|
||||
|
||||
@property(nonatomic,strong)UIButton*mySwitchButton;
|
||||
|
||||
@property(nonatomic)UIActivityIndicatorView*indicatorView;
|
||||
|
||||
-(void)addAlertView;
|
||||
|
||||
@property(nonatomic)int percent;
|
||||
|
||||
@property(nonatomic,strong) DeviceModel* currentdevice;
|
||||
|
||||
@end
|
||||
+886
@@ -0,0 +1,886 @@
|
||||
//
|
||||
// TwoControlnoneTimerViewController.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by imac on 16/2/26.
|
||||
// Copyright © 2016年 imac. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TwoControlnoneTimerViewController.h"
|
||||
#import "SetTimeCell.h"
|
||||
#import "SecondSetTimeCell.h"
|
||||
#import "SetTimeModel.h"
|
||||
#import "SetSelectorTime.h"
|
||||
//#import "AsyncSocket.h"
|
||||
#import "setWaringTpModel.h"
|
||||
#import "appLogin.h"
|
||||
#import "workTypeModel.h"
|
||||
#import "SetSelectorTime.h"
|
||||
|
||||
#define TIME_TAG 300
|
||||
#import "MyPickerView.h"
|
||||
#import "searchDeviceModel.h"
|
||||
|
||||
#import "MydatePickerView.h"
|
||||
#define SET_CELL_TAG 2200
|
||||
#define MYSWITCH_TAG 3200
|
||||
#import "CenterViewController.h"
|
||||
#import "TimerSateModel.h"
|
||||
#import "TemperatureSetCell.h"
|
||||
#import "TemperatureSetModel.h"
|
||||
#import "TwoControlBackmsgmodel.h"
|
||||
|
||||
#import "BrightnessCell.h"
|
||||
#import "GuiDengViewCell.h"
|
||||
#import "ChangeWaterCell.h"
|
||||
#import "GuidengKaiGuanModel.h"
|
||||
#import "BrightnessModel.h"
|
||||
#import "remindCyclePic.h"
|
||||
#import "setRemindWaterModel.h"
|
||||
|
||||
#import "CreatErWeiMaController.h"
|
||||
// 两控 无控制器
|
||||
|
||||
@interface TwoControlnoneTimerViewController ()
|
||||
{
|
||||
|
||||
MydatePickerView*_mydatepicView;
|
||||
MyPickerView* _mypicView;
|
||||
remindCyclePic*_remindPic;
|
||||
BOOL _huanshuiSwitchIsOn;
|
||||
dispatch_queue_t _mainQueue;
|
||||
}
|
||||
@property(nonatomic,strong)NSIndexPath*indexpath;
|
||||
|
||||
@property(nonatomic,copy)NSString*statString;
|
||||
@property(nonatomic,copy)NSString*endString;
|
||||
|
||||
@property(nonatomic,copy)NSString*nextChangeDateLabel;
|
||||
@property(nonatomic,strong)setRemindWaterModel*waterInfmodel;
|
||||
@end
|
||||
|
||||
@implementation TwoControlnoneTimerViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
_waterInfmodel=[[setRemindWaterModel alloc]init];
|
||||
|
||||
_mainQueue = dispatch_get_main_queue();
|
||||
self.navigationController.navigationBar.backItem.title=@"";
|
||||
[self addTitleViewWithTitle:@"设置"];
|
||||
[self initData];
|
||||
self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
|
||||
[self creatIndicatorView];
|
||||
|
||||
self.tableView.backgroundColor=COLOR_MIAN;
|
||||
self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
|
||||
|
||||
// if ([self.currentdevice.isMaster isEqualToString:@"1"]) {
|
||||
// UIBarButtonItem*rightItem=[[UIBarButtonItem alloc]initWithTitle:@"分享设备" style: UIBarButtonItemStyleDone target:self action:@selector(twoNoneItemClick)];
|
||||
// rightItem.tintColor=[UIColor whiteColor];
|
||||
// self.navigationItem.rightBarButtonItem=rightItem;
|
||||
// }
|
||||
//
|
||||
}
|
||||
-(void)twoNoneItemClick{
|
||||
CreatErWeiMaController*vc=[[CreatErWeiMaController alloc]init]
|
||||
;
|
||||
vc.erdevicemodel=self.currentdevice;
|
||||
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
|
||||
}
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
-(void)initData{
|
||||
self.titleArr=@[@"预警设置",@"柜灯开关",@"背光亮度",@"换水提醒",@"定时模式"];
|
||||
|
||||
TwoControlBackmsgmodel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackTwoControlInfo"];
|
||||
if (backmodel) {
|
||||
NSString*low=backmodel.miniTp;
|
||||
NSString*heigh=backmodel.maxTp;
|
||||
UInt64 lowten=[dataContorl hexToTen:low];
|
||||
UInt64 heighten=[dataContorl hexToTen:heigh];
|
||||
float formatlow=lowten/10;
|
||||
float formatheigh=heighten/10;
|
||||
|
||||
NSString*wenduString=[NSString stringWithFormat:@"%.0f~%.0f°C",formatlow,formatheigh];
|
||||
|
||||
self.timeArr=@[wenduString];
|
||||
|
||||
}else{
|
||||
|
||||
[self showTitle:@"" messsage:@"设备已离线"];
|
||||
self.timeArr=@[@"20~30°C"];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Table view data source
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
|
||||
return 5;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
TwoControlBackmsgmodel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackTwoControlInfo"];
|
||||
|
||||
static NSString *cellID=@"kongCell";
|
||||
UITableViewCell *kongCell=[tableView dequeueReusableCellWithIdentifier:cellID];
|
||||
|
||||
if (kongCell==nil) {
|
||||
|
||||
kongCell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
|
||||
}
|
||||
|
||||
|
||||
if (indexPath.row==0){
|
||||
TemperatureSetCell*cell=[tableView dequeueReusableCellWithIdentifier:@"TemperatureSetCell"];
|
||||
if (cell==nil) {
|
||||
cell=[[[NSBundle mainBundle]loadNibNamed:@"TemperatureSetCell" owner:self options:nil]lastObject];
|
||||
}
|
||||
cell.tag=indexPath.row +SET_CELL_TAG+indexPath.section*10;
|
||||
TemperatureSetModel*model=[[TemperatureSetModel alloc]init];
|
||||
model.title=self.titleArr[indexPath.section][indexPath.row];
|
||||
|
||||
cell.titleLabel.text=model.title;
|
||||
model.temperatureLabel=self.timeArr[indexPath.section][indexPath.row];
|
||||
cell.temperaturelabel.text=model.temperatureLabel;
|
||||
[cell.temPSwitch addTarget:self action:@selector(tempSwitchAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
if ([backmodel.baojingSwitch isEqualToString:@"01"]) {
|
||||
[cell.temPSwitch setBackgroundImage:[UIImage imageNamed:@"greenbtn_big"] forState:UIControlStateNormal];
|
||||
|
||||
cell.temPSwitch.selected = NO;
|
||||
}else{
|
||||
[cell.temPSwitch setBackgroundImage:[UIImage imageNamed:@"graybtn_big"] forState:UIControlStateNormal];
|
||||
|
||||
cell.temPSwitch.selected = YES;
|
||||
}
|
||||
|
||||
return cell;
|
||||
|
||||
}else if (indexPath.section==0&&indexPath.row==2){
|
||||
//背光
|
||||
//背光
|
||||
BrightnessCell*cell=[tableView dequeueReusableCellWithIdentifier:@"BrightnessCell"];
|
||||
if (cell==nil) {
|
||||
cell=[[[NSBundle mainBundle]loadNibNamed:@"BrightnessCell" owner:self options:nil]lastObject];
|
||||
}
|
||||
|
||||
if (![_currentdevice.isLightness isEqual:[NSNull null]]) {
|
||||
if ([_currentdevice.isLightness isEqualToString:@"1"]) {
|
||||
//有背光
|
||||
cell.brightTitleLabel.text=_titleArr[indexPath.section][indexPath.row];
|
||||
// 系统默认YES 这里拖拽结束时再传值需设为NO
|
||||
cell.btightnessSlider.continuous=NO;
|
||||
if (backmodel) {
|
||||
|
||||
UInt64 lightTen=[dataContorl hexToTen:backmodel.brightness];
|
||||
|
||||
[cell.btightnessSlider setValue:lightTen animated:YES];
|
||||
// int sliderValue=(int)(lightTen+0.5);
|
||||
// int percent=(sliderValue*100)/250;
|
||||
// cell.persentLabel.text=[NSString stringWithFormat:@"%d%",percent];
|
||||
// cell.persentLabel.textColor=COLOR_LABEL_TITLE;
|
||||
}
|
||||
|
||||
[cell.btightnessSlider addTarget:self action:@selector(twobtightnessSlider:) forControlEvents:UIControlEventValueChanged];
|
||||
|
||||
cell.brightTitleLabel.hidden=NO;
|
||||
cell.btightnessSlider.hidden=NO;
|
||||
cell.persentLabel.hidden=NO;
|
||||
|
||||
return cell;
|
||||
}else{
|
||||
//无背光
|
||||
|
||||
|
||||
return kongCell;
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
return kongCell;
|
||||
}
|
||||
|
||||
}else if (indexPath.section==0&&indexPath.row==1){
|
||||
// 柜灯
|
||||
GuiDengViewCell*cell=[tableView dequeueReusableCellWithIdentifier:@"GuiDengViewCell"];
|
||||
if (cell==nil) {
|
||||
cell=[[[NSBundle mainBundle]loadNibNamed:@"GuiDengViewCell" owner:self options:nil]lastObject];
|
||||
}
|
||||
|
||||
if (![_currentdevice.isSarkLamp isEqual:[NSNull null]]) {
|
||||
if ([_currentdevice.isSarkLamp isEqualToString:@"1"]) {
|
||||
cell.guidengtitle=_titleArr[indexPath.section][indexPath.row];
|
||||
|
||||
[cell.guidengSwitch addTarget:self action:@selector(twoguidengSwitchAtion:) forControlEvents:UIControlEventTouchUpInside];
|
||||
if ([backmodel.tankLight isEqualToString:@"01"]) {
|
||||
//[cell.guidengSwitch setOn:YES];
|
||||
[cell.guidengSwitch setBackgroundImage:[UIImage imageNamed:@"greenbtn_big"] forState:UIControlStateNormal];
|
||||
cell.guidengSwitch.selected = NO;
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
[cell.guidengSwitch setBackgroundImage:[UIImage imageNamed:@"graybtn_big"] forState:UIControlStateNormal];
|
||||
cell.guidengSwitch.selected = YES;
|
||||
//[cell.guidengSwitch setOn:NO];
|
||||
}
|
||||
|
||||
return cell;
|
||||
|
||||
}else{
|
||||
|
||||
return kongCell;
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
return kongCell;
|
||||
|
||||
}
|
||||
|
||||
}else if (indexPath.row==3){
|
||||
// 换水提醒
|
||||
|
||||
ChangeWaterCell*cell=[tableView dequeueReusableCellWithIdentifier:@"ChangeWaterCell"];
|
||||
if (cell==nil) {
|
||||
cell=[[[NSBundle mainBundle]loadNibNamed:@"ChangeWaterCell" owner:self options:nil]lastObject];
|
||||
}
|
||||
|
||||
[cell.ChangeWaterSwitch addTarget:self action:@selector(twochangeWaterSwitch:) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
|
||||
|
||||
|
||||
if (![self.currentdevice.waterRemind isEqual:[NSNull null]]) {
|
||||
|
||||
if ([self.waterInfmodel.waterremind isEqualToString:@"1"]) {
|
||||
//[cell.ChangeWaterSwitch setOn:YES];
|
||||
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"firstSetCell"]];
|
||||
cell.ChangeWaterSwitch.selected = NO;
|
||||
[cell.ChangeWaterSwitch setBackgroundImage:[UIImage imageNamed:@"greenbtn_big"] forState:UIControlStateNormal];
|
||||
|
||||
_huanshuiSwitchIsOn=YES;
|
||||
}else{
|
||||
// [cell.ChangeWaterSwitch setOn:NO];
|
||||
_huanshuiSwitchIsOn=NO;
|
||||
|
||||
cell.ChangeWaterSwitch.selected = YES;
|
||||
[cell.ChangeWaterSwitch setBackgroundImage:[UIImage imageNamed:@"graybtn_big"] forState:UIControlStateNormal];
|
||||
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"set_cellBack"]];
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (self.waterInfmodel.remindcycle == 0) {
|
||||
//在未获取换水信息时暂时显示
|
||||
cell.huanshuiDaylabel.text=@"换水时间";
|
||||
}else{
|
||||
cell.huanshuiDaylabel.text=[NSString stringWithFormat:@"%ld天",(long)self.waterInfmodel.remindcycle];
|
||||
}
|
||||
|
||||
NSLog(@"你");
|
||||
return cell;
|
||||
|
||||
}else{
|
||||
|
||||
kongCell.textLabel.text =@"错误信息 waterRemind null";
|
||||
return kongCell;
|
||||
|
||||
}
|
||||
|
||||
}else if(indexPath.row==4){
|
||||
|
||||
static NSString*nextHuanShuiLablecellId=@"labelcell";
|
||||
UITableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:nextHuanShuiLablecellId];
|
||||
if (cell==nil) {
|
||||
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nextHuanShuiLablecellId];
|
||||
}
|
||||
if (_huanshuiSwitchIsOn) {
|
||||
cell.backgroundColor=COLOR_BACK_;
|
||||
cell.textLabel.text=[NSString stringWithFormat:@"下次换水时间:%@",self.waterInfmodel.remindDate];
|
||||
cell.textLabel.font=[UIFont systemFontOfSize:12];
|
||||
[cell.textLabel sizeToFit];
|
||||
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"secondSetCell"]];
|
||||
}else{
|
||||
cell.textLabel.text=@"";
|
||||
}
|
||||
cell.userInteractionEnabled = NO;
|
||||
return cell;
|
||||
|
||||
}else{
|
||||
return nil;
|
||||
}
|
||||
|
||||
}
|
||||
#pragma mark 开启关闭报警
|
||||
-(void)tempSwitchAction:(UIButton*)temperatureSwitch{
|
||||
TwoControlBackmsgmodel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackTwoControlInfo"];
|
||||
setWaringTpModel*warModel1=[[setWaringTpModel alloc]init];
|
||||
warModel1.resavemacId = self.currentdevice.macAddress;
|
||||
warModel1.sendmacId = self.currentdevice.macAddress;
|
||||
|
||||
if (temperatureSwitch.selected == YES) {
|
||||
NSLog(@"开");
|
||||
temperatureSwitch.selected = NO;
|
||||
warModel1.kaiguan=@"01";// 开
|
||||
warModel1.miniwaterTp=@"0000"; // 0
|
||||
warModel1.maxwaterTp=@"0000";//0
|
||||
}else{
|
||||
temperatureSwitch.selected = YES;
|
||||
warModel1.kaiguan=@"00";// 关
|
||||
warModel1.miniwaterTp=@"0000"; // 0
|
||||
warModel1.maxwaterTp=@"0000";//0
|
||||
NSLog(@"关");
|
||||
}
|
||||
[self setTmperatureStateWithModel:warModel1 addBackModel:backmodel];
|
||||
|
||||
}
|
||||
-(void)setTmperatureStateWithModel:(setWaringTpModel*)waringModel addBackModel:(TwoControlBackmsgmodel*)backModel{
|
||||
NSString*maxminTpString=waringModel.description;
|
||||
waringModel.crc16Ing=@"0000";
|
||||
NSString*minString=[NSString stringWithFormat:@"%@%@%@%@%@",maxminTpString,waringModel.kaiguan,waringModel.miniwaterTp,waringModel.maxwaterTp,waringModel.crc16Ing];
|
||||
NSData*minwenDuData=[dataContorl stringToHexData:minString];
|
||||
[[Socketsingleton sharedInstance] soketWriteData:minwenDuData];
|
||||
|
||||
[_indicatorView startAnimating];
|
||||
backModel.miniTp=waringModel.miniwaterTp;
|
||||
backModel.maxTp=waringModel.maxwaterTp;
|
||||
|
||||
}
|
||||
#pragma mark tableView 行高
|
||||
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
|
||||
if (indexPath.section==0&&indexPath.row==4) {
|
||||
|
||||
//ChangeWaterCell*cell=(ChangeWaterCell*)[self tableView:tableView cellForRowAtIndexPath:indexPath];
|
||||
|
||||
|
||||
if (_huanshuiSwitchIsOn) {
|
||||
|
||||
return 50;
|
||||
}else{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}else if (indexPath.section==0&&indexPath.row==0){
|
||||
|
||||
if (![_currentdevice.isPushWendu isEqual:[NSNull null]]) {
|
||||
|
||||
if ([_currentdevice.isPushWendu isEqualToString:@"1"]) {
|
||||
|
||||
return 50;
|
||||
}else{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}else if (indexPath.section==0&&indexPath.row==2){
|
||||
|
||||
if (![_currentdevice.isLightness isEqual:[NSNull null]]) {
|
||||
|
||||
if ([_currentdevice.isLightness isEqualToString:@"1"]) {
|
||||
|
||||
return 100;
|
||||
|
||||
}else{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}else if (indexPath.section==0&&indexPath.row==1){
|
||||
//
|
||||
|
||||
if (![_currentdevice.isSarkLamp isEqual:[NSNull null]]) {
|
||||
|
||||
if ([_currentdevice.isSarkLamp isEqualToString:@"1"]) {
|
||||
return 50;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
}else if (indexPath.section==0&&indexPath.row==3){
|
||||
|
||||
if (![_currentdevice.waterRemind isEqual:[NSNull null]]) {
|
||||
|
||||
return 50;
|
||||
|
||||
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}else if (indexPath.section==0&&indexPath.row==0){
|
||||
//会否有 预警
|
||||
if (![_currentdevice.isPushWendu isEqual:[NSNull null]]) {
|
||||
|
||||
|
||||
if ([_currentdevice.isPushWendu isEqualToString:@"1"]) {
|
||||
return 50;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
return 50;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#pragma mark tableView 点击事件
|
||||
|
||||
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
_indexpath=indexPath;
|
||||
if (indexPath.row==0&&indexPath.section==0) {
|
||||
|
||||
_mypicView=[[MyPickerView alloc]init];
|
||||
|
||||
_mypicView.frame=CGRectMake(0, 0, kScreenSize.width, kScreenSize.height);
|
||||
[self.view.window addSubview:_mypicView];
|
||||
[_mypicView.cancleButton addTarget:self action:@selector(mypicviewRemoveByCancle) forControlEvents:UIControlEventTouchUpInside];
|
||||
[_mypicView.sureButton addTarget:self action:@selector(mypicViewRemoveByDone) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self temperatureMainQueue];
|
||||
|
||||
}else if (indexPath.section==0&&indexPath.row==3){
|
||||
//换水提醒日期选择
|
||||
_remindPic=[[remindCyclePic alloc]init];
|
||||
|
||||
_remindPic.frame=CGRectMake(0, 0, kScreenSize.width, kScreenSize.height);
|
||||
[self.view.window addSubview:_remindPic];
|
||||
[_remindPic.cancleBtn addTarget:self action:@selector(tworemindCyclePicRemove) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
[_remindPic.sureBtn addTarget:self action:@selector(tworemindCyclePicDone) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self huanShuiMainQueue];
|
||||
|
||||
}
|
||||
}
|
||||
#pragma mark 移除换水时间选择器
|
||||
|
||||
-(void)tworemindCyclePicRemove{
|
||||
[_remindPic removeFromSuperview];
|
||||
|
||||
}
|
||||
|
||||
#pragma mark 换水时间设置
|
||||
|
||||
-(void)tworemindCyclePicDone{
|
||||
if (_indexpath.section==0&&_indexpath.row==3) {
|
||||
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];
|
||||
[_remindPic makeToast:@"请设置换水天数"];
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
cell.huanshuiDaylabel.text=[NSString stringWithFormat:@"%@天",str];
|
||||
//设置换水日期
|
||||
[IFISHHTTPTOOL setRemindWaterInfWith:self.currentdevice.deviceId
|
||||
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:@"picResult"];
|
||||
|
||||
[defuat synchronize];
|
||||
|
||||
[_remindPic removeFromSuperview];
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma mark 默认换水时间
|
||||
-(void)huanShuiMainQueue{
|
||||
|
||||
if (_remindPic.picViewResultString !=nil || (_remindPic.picViewResultString ==nil && self.waterInfmodel.remindcycle !=0 )) {
|
||||
|
||||
|
||||
|
||||
NSArray*shijianArr=[_remindPic.picArr objectAtIndex:0];
|
||||
dispatch_async(_mainQueue, ^{
|
||||
NSLog(@"a");
|
||||
for (NSInteger k=0; k<shijianArr.count; k++) {
|
||||
ChangeWaterCell*cell=(ChangeWaterCell*)[self tableView:self.tableView cellForRowAtIndexPath:_indexpath];
|
||||
|
||||
NSString*dateString=cell.huanshuiDaylabel.text;
|
||||
NSString*start=nil;
|
||||
if (self.waterInfmodel.remindcycle == 0) {
|
||||
//未设置换水时间时 默认为1
|
||||
start = @"1";
|
||||
}else{
|
||||
|
||||
NSRange range=[dateString rangeOfString:@"天"];
|
||||
start=[dateString substringToIndex:range.location];
|
||||
}
|
||||
|
||||
//判断数据源数组小于十的情况
|
||||
//_remindPic.picViewResultString=dateString;
|
||||
NSString*picString=shijianArr[k];
|
||||
|
||||
if ([picString isEqualToString:start] ) {
|
||||
|
||||
[_remindPic.pic selectRow:k inComponent:0 animated:NO];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
-(void)temperatureMainQueue{
|
||||
NSArray*lowArr=[_mypicView.picArr objectAtIndex:0];
|
||||
NSArray*heighArr=[_mypicView.picArr objectAtIndex:2];
|
||||
|
||||
dispatch_async(_mainQueue, ^{
|
||||
for (NSInteger i=0; i<lowArr.count; i++) {
|
||||
NSString*tempretureString=_timeArr[_indexpath.row];
|
||||
NSString*tempretureString1=[tempretureString substringWithRange:NSMakeRange(0, tempretureString.length-2)];
|
||||
|
||||
NSRange range=[tempretureString1 rangeOfString:@"~"];
|
||||
NSString*start=[tempretureString1 substringToIndex:range.location];
|
||||
|
||||
|
||||
NSString*startpicString=lowArr[i];
|
||||
|
||||
if ([startpicString isEqualToString:start ] ) {
|
||||
|
||||
[_mypicView.picView selectRow:i inComponent:0 animated:NO];
|
||||
_mypicView.lowindex=i;
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
dispatch_async(_mainQueue, ^{
|
||||
for (NSInteger j=0; j<heighArr.count; j++) {
|
||||
NSString*tempretureString=_timeArr[_indexpath.row];
|
||||
NSString*tempretureString1=[tempretureString substringWithRange:NSMakeRange(0, tempretureString.length-2)];
|
||||
|
||||
NSRange range=[tempretureString1 rangeOfString:@"~"];
|
||||
NSString*start=[tempretureString1 substringFromIndex:range.location+1];
|
||||
|
||||
NSString*startpicString=heighArr[j];
|
||||
|
||||
if ([startpicString isEqualToString:start ] ) {
|
||||
|
||||
[_mypicView.picView selectRow:j inComponent:2 animated:NO];
|
||||
_mypicView.heighindex=j;
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
-(void)mypicviewRemoveByCancle{
|
||||
[_mypicView removeFromSuperview];
|
||||
|
||||
}
|
||||
|
||||
//温度设置
|
||||
#pragma mark 温度设置
|
||||
-(void)mypicViewRemoveByDone{
|
||||
|
||||
if (_mypicView.picViewResultString==nil) {
|
||||
[_mypicView removeFromSuperview];
|
||||
|
||||
}else{
|
||||
if (_indexpath.section==0&&_indexpath.row==0) {
|
||||
|
||||
TemperatureSetCell*cell=[self.tableView cellForRowAtIndexPath:_indexpath];
|
||||
cell.temperaturelabel.text=[NSString stringWithFormat:@"%@°C",_mypicView.picViewResultString];
|
||||
}
|
||||
TwoControlBackmsgmodel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackTwoControlInfo"];
|
||||
// 低温
|
||||
setWaringTpModel*warModel1=[[setWaringTpModel alloc]init];
|
||||
warModel1.resavemacId = self.currentdevice.macAddress;
|
||||
warModel1.sendmacId = self.currentdevice.macAddress;
|
||||
|
||||
warModel1.crc16Ing=@"0000";
|
||||
warModel1.kaiguan=@"02";//设置
|
||||
NSString*maxminTpString=warModel1.description;
|
||||
|
||||
NSRange range=[_mypicView.picViewResultString rangeOfString:@"~"];
|
||||
NSString*lowString=[_mypicView.picViewResultString substringToIndex:range.location];
|
||||
|
||||
int intlowString = [lowString intValue];
|
||||
int newIntlowString=intlowString*10;
|
||||
warModel1.miniwaterTp=[dataContorl tpIntStringToFourHex:newIntlowString]; // 转四位16进制
|
||||
//写入数据
|
||||
backmodel.miniTp=warModel1.miniwaterTp;
|
||||
|
||||
// 高温
|
||||
setWaringTpModel*warModel2=[[setWaringTpModel alloc]init];
|
||||
warModel2.resavemacId = self.currentdevice.macAddress;
|
||||
warModel2.sendmacId = self.currentdevice.macAddress;
|
||||
warModel2.crc16Ing=@"0000";
|
||||
warModel2.kaiguan=@"02";//设置
|
||||
NSString*heighString=[_mypicView.picViewResultString substringFromIndex:range.location+1];
|
||||
int intString = [heighString intValue];
|
||||
int newIntString=intString*10;
|
||||
|
||||
warModel2.maxwaterTp=[dataContorl tpIntStringToFourHex:newIntString];
|
||||
|
||||
if ([lowString intValue]<[heighString intValue]) {
|
||||
|
||||
backmodel.miniTp=warModel1.miniwaterTp;
|
||||
NSString*minString=[NSString stringWithFormat:@"%@%@%@%@%@",maxminTpString,warModel1.kaiguan,warModel1.miniwaterTp,warModel2.maxwaterTp,warModel1.crc16Ing];
|
||||
NSData*minwenDuData=[dataContorl stringToHexData:minString];
|
||||
[[Socketsingleton sharedInstance] soketWriteData:minwenDuData];
|
||||
|
||||
backmodel.maxTp=warModel2.maxwaterTp;
|
||||
|
||||
[_indicatorView startAnimating];
|
||||
[_mypicView removeFromSuperview];
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
[self showTitle:@"提醒" messsage:@"请正确设置温度"];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pragma mark 导航条 跳转时处理
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
self.navigationController.navigationBarHidden=NO;
|
||||
if (_currentdevice) {
|
||||
[IFISHHTTPTOOL getRemindWaterInfWith:_currentdevice.deviceId huishuiInfo:^(setRemindWaterModel *remindModel) {
|
||||
|
||||
self.waterInfmodel=remindModel;
|
||||
|
||||
NSUserDefaults*defuat=[NSUserDefaults standardUserDefaults];
|
||||
|
||||
[defuat setInteger:self.waterInfmodel.remindcycle forKey:@"twopicResult"];
|
||||
|
||||
[defuat synchronize];
|
||||
|
||||
[self.tableView reloadData];
|
||||
}];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-(void)viewWillDisappear:(BOOL)animated{
|
||||
|
||||
[_indicatorView stopAnimating];
|
||||
}
|
||||
#pragma mark alert 动态显示
|
||||
-(void)showAlert{
|
||||
NSString*title=nil;
|
||||
NSString*message=@"已经与服务器断开连接";
|
||||
NSTimeInterval dismissSeconds=2.0;
|
||||
UIAlertView*alertView=[[UIAlertView alloc]initWithTitle:title message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];
|
||||
[alertView show];
|
||||
[self performSelector:@selector(dismissAlert:) withObject:alertView afterDelay:dismissSeconds];
|
||||
}
|
||||
-(void)dismissAlert:(UIAlertView*)alertView{
|
||||
|
||||
[alertView dismissWithClickedButtonIndex:[alertView cancelButtonIndex] animated:YES];
|
||||
}
|
||||
//
|
||||
-(void)addAlertView{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self showAlert];
|
||||
});
|
||||
}
|
||||
#pragma mark 柜光灯开关Action
|
||||
|
||||
-(void)twoguidengSwitchAtion:(UIButton*)sender{
|
||||
UIButton *switchButton = (UIButton*)sender;
|
||||
//BOOL isButtonOn=[switchButton isOn];
|
||||
GuidengKaiGuanModel*guidengModel=[[GuidengKaiGuanModel alloc]init];
|
||||
guidengModel.resavemacId = self.currentdevice.macAddress;
|
||||
guidengModel.sendmacId = self.currentdevice.macAddress;
|
||||
guidengModel.crc16Str=@"0000";
|
||||
if (switchButton.selected ==YES) {
|
||||
NSLog(@"开");
|
||||
guidengModel.onOff=@"01";
|
||||
switchButton.selected = NO;
|
||||
|
||||
NSString* guidengOrder=[NSString stringWithFormat:@"%@%@%@",guidengModel.description,guidengModel.onOff,guidengModel.crc16Str];
|
||||
NSData*guidengData=[dataContorl stringToHexData:guidengOrder];
|
||||
[[Socketsingleton sharedInstance] soketWriteData:guidengData];
|
||||
|
||||
|
||||
TwoControlBackmsgmodel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackTwoControlInfo"];
|
||||
backmodel.tankLight=@"01";
|
||||
[_indicatorView startAnimating];
|
||||
}else{
|
||||
NSLog(@"关");
|
||||
switchButton.selected = YES;
|
||||
|
||||
guidengModel.onOff=@"00";
|
||||
|
||||
NSString* guidengOrder=[NSString stringWithFormat:@"%@%@%@",guidengModel.description,guidengModel.onOff,guidengModel.crc16Str];
|
||||
NSData*guidengData=[dataContorl stringToHexData:guidengOrder];
|
||||
[[Socketsingleton sharedInstance] soketWriteData:guidengData];
|
||||
TwoControlBackmsgmodel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackTwoControlInfo"];
|
||||
backmodel.tankLight=@"00";
|
||||
[_indicatorView startAnimating];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#pragma mark 背光灯亮度Action
|
||||
|
||||
-(void)twobtightnessSlider:(UISlider*)sender{
|
||||
UISlider*slider=(UISlider*)sender;
|
||||
NSLog(@"%f",slider.value);
|
||||
//这里 只传整数
|
||||
//1.强转四舍五入
|
||||
|
||||
int sliderValue=(int)(slider.value+0.5);
|
||||
// //2.高斯函数,向下取整
|
||||
// int sliderValue1=floor(slider.value);
|
||||
// //3. ceil 函数,向上取整
|
||||
// int sliderValue2=ceil(slider.value);
|
||||
|
||||
NSLog(@"%d",sliderValue);
|
||||
|
||||
self.percent=(sliderValue*100)/250;
|
||||
|
||||
NSString*hexString=[dataContorl ToHex:sliderValue];
|
||||
|
||||
if (hexString.length<2) {
|
||||
|
||||
hexString=[NSString stringWithFormat:@"0%@",hexString];
|
||||
}
|
||||
NSLog(@"%@",hexString);
|
||||
|
||||
BrightnessModel*brightModel=[[BrightnessModel alloc]init
|
||||
];
|
||||
brightModel.resavemacId = self.currentdevice.macAddress;
|
||||
brightModel.sendmacId = self.currentdevice.macAddress;
|
||||
|
||||
brightModel.liangdu=hexString;
|
||||
brightModel.crc16Code=@"0000";
|
||||
NSString*changeLightOder=[NSString stringWithFormat:@"%@%@%@",brightModel.description,brightModel.liangdu,brightModel.crc16Code];
|
||||
NSData*changeLghtData=[dataContorl stringToHexData:changeLightOder];
|
||||
[[Socketsingleton sharedInstance] soketWriteData:changeLghtData];
|
||||
[_indicatorView startAnimating];
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma mark 换水提醒Action
|
||||
-(void)twochangeWaterSwitch:(UIButton*)sender{
|
||||
|
||||
UIButton*huanShuiSwitch=(UIButton*)sender;
|
||||
// BOOL isButtonOn=[huanShuiSwitch isOn];
|
||||
|
||||
NSUserDefaults*defuat=[NSUserDefaults standardUserDefaults];
|
||||
NSString*picResult=[defuat valueForKey:@"twopicResult"];
|
||||
int pic = picResult.intValue;
|
||||
if (pic==0) {
|
||||
[self showTitle:@"" messsage:@"请设置提醒天数"];
|
||||
if (huanShuiSwitch.selected ==YES) {
|
||||
huanShuiSwitch.selected = NO;
|
||||
}else{
|
||||
huanShuiSwitch.selected = YES;
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
|
||||
if (huanShuiSwitch.selected ==YES) {
|
||||
//开
|
||||
huanShuiSwitch.selected = NO;
|
||||
[IFISHHTTPTOOL setRemindWaterInfWith:self.currentdevice.deviceId
|
||||
waterRemind:@"1" remindCycle:picResult
|
||||
huishuiShiJian:^(setRemindWaterModel *remindModel) {
|
||||
self.nextChangeDateLabel=remindModel.remindDate;
|
||||
|
||||
}];
|
||||
//更新选择状态 设置界面 在不断 刷新
|
||||
|
||||
self.waterInfmodel.waterremind=@"1";
|
||||
[self.tableView reloadData];
|
||||
|
||||
}else{
|
||||
//关
|
||||
huanShuiSwitch.selected = YES;
|
||||
[IFISHHTTPTOOL setRemindWaterInfWith:self.currentdevice.deviceId
|
||||
waterRemind:@"0" remindCycle:picResult
|
||||
huishuiShiJian:^(setRemindWaterModel *remindModel) {
|
||||
self.nextChangeDateLabel=remindModel.remindDate;
|
||||
|
||||
}];
|
||||
|
||||
self.waterInfmodel.waterremind=@"0";
|
||||
[self.tableView reloadData];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-(void)showTitle:(NSString*)title messsage:(NSString*)message{
|
||||
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:title message:message delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
|
||||
[alert show];
|
||||
}
|
||||
|
||||
-(void)creatIndicatorView{
|
||||
|
||||
_indicatorView=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
|
||||
// _indicatorView.center=CGPointMake(kScreenSize.width/2, kScreenSize.height/2+100);
|
||||
_indicatorView.frame=CGRectMake(kScreenSize.width/2-50,kScreenSize.height/2-100,100, 100);
|
||||
_indicatorView.backgroundColor=[UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
|
||||
_indicatorView.layer.masksToBounds=YES;
|
||||
_indicatorView.layer.cornerRadius=5;
|
||||
AppDelegate*delegate=[[UIApplication sharedApplication]delegate];
|
||||
[delegate.window addSubview:_indicatorView];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user