2379 lines
87 KiB
Objective-C
2379 lines
87 KiB
Objective-C
//
|
||
// FourControlCanChangeImgController.m
|
||
// Ifish
|
||
//
|
||
// Created by imac on 16/4/11.
|
||
// Copyright © 2016年 imac. All rights reserved.
|
||
//
|
||
|
||
#import "FourControlCanChangeImgController.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 "FourControlbackMassge.h"
|
||
#import "MydatePickerView.h"
|
||
#define SET_CELL_TAG 2000
|
||
#define MYSWITCH_TAG 3000
|
||
#import "CenterViewController.h"
|
||
#import "TimerSateModel.h"
|
||
#import "TemperatureSetCell.h"
|
||
#import "TemperatureSetModel.h"
|
||
#import "AppDelegate.h"
|
||
#import "BrightnessCell.h"
|
||
#import "GuidengKaiGuanModel.h"
|
||
#import "GuiDengViewCell.h"
|
||
#import "ChangeWaterCell.h"
|
||
#import "remindCyclePic.h"
|
||
#import "BrightnessModel.h"
|
||
#import "LYPhotoShowView.h"
|
||
#import "LYPhoto.h"
|
||
|
||
#import "Define.h"
|
||
#import "AFNetworking.h"
|
||
#import "UIImageView+WebCache.h"
|
||
#import "DeviceModel.h"
|
||
#define imageHigh 55
|
||
#define SectionHeadHigh 50
|
||
#define kplace ([UIScreen mainScreen].bounds.size.width - 4 * imageHigh)/5
|
||
#import "CreatErWeiMaController.h"
|
||
|
||
@interface FourControlCanChangeImgController ()
|
||
|
||
|
||
{
|
||
|
||
MydatePickerView*_mydatepicView;
|
||
|
||
MyPickerView* _mypicView;
|
||
|
||
remindCyclePic*_remindPic;
|
||
|
||
dispatch_queue_t _mainQueue;
|
||
|
||
BOOL _huanShuiSwitchIsOn;
|
||
}
|
||
|
||
@property(nonatomic,strong)NSIndexPath *indexpath;
|
||
|
||
@property(nonatomic,copy)NSString *statString;
|
||
|
||
@property(nonatomic,copy)NSString *endString;
|
||
|
||
@property(nonatomic,strong)UIView *lodingbackView;
|
||
|
||
@property(nonatomic,copy)NSString *nextChangeDateLabel;
|
||
|
||
@property(nonatomic,strong)setRemindWaterModel *waterInfmodel;
|
||
|
||
@property (nonatomic,strong) LYPhoto * photo;
|
||
@property (nonatomic,strong) LYPhotoShowView * showView;
|
||
@property (nonatomic,strong) LYPhotoShowView * showView2;
|
||
@property (nonatomic,strong) LYPhotoShowView * showView3;
|
||
@property (nonatomic,strong) LYPhotoShowView * showView4;
|
||
|
||
@property (nonatomic,strong) UIView * headView;
|
||
@property (nonatomic,strong) UIView * headView2;
|
||
@property (nonatomic,strong) UIView * headView3;
|
||
@property (nonatomic,strong) UIView * headView4;
|
||
|
||
@property (nonatomic,assign) CGFloat headHeight;
|
||
@property (nonatomic,assign) CGFloat headHeight2;
|
||
@property (nonatomic,assign) CGFloat headHeight3;
|
||
@property (nonatomic,assign) CGFloat headHeight4;
|
||
|
||
@property (nonatomic,strong) UIButton * btn;
|
||
@property (nonatomic,strong) UIButton * btn2;
|
||
@property (nonatomic,strong) UIButton * btn3;
|
||
@property (nonatomic,strong) UIButton * btn4;
|
||
|
||
|
||
@property (nonatomic ,strong) UIImageView * leftTop;
|
||
@property (nonatomic ,strong) UIImageView * leftTop2;
|
||
@property (nonatomic ,strong) UIImageView * leftTop3;
|
||
@property (nonatomic ,strong) UIImageView * leftTop4;
|
||
|
||
|
||
@property (nonatomic ,strong) UILabel * leftlabel;
|
||
@property (nonatomic ,strong) UILabel * leftlabel2;
|
||
@property (nonatomic ,strong) UILabel * leftlabel3;
|
||
@property (nonatomic ,strong) UILabel * leftlabel4;
|
||
|
||
@property (nonatomic,assign) NSInteger indexWithImage;
|
||
@property (nonatomic,assign) NSInteger indexWithImage2;
|
||
@property (nonatomic,assign) NSInteger indexWithImage3;
|
||
@property (nonatomic,assign) NSInteger indexWithImage4;
|
||
|
||
|
||
@property (nonatomic,strong) UILabel * nameLabel;
|
||
|
||
|
||
@property (nonatomic,strong) NSUserDefaults * userDefaultIndex;
|
||
|
||
@property (nonatomic,copy) NSString * picUrl;
|
||
@property (nonatomic,copy) NSString * picUrl2;
|
||
@property (nonatomic,copy) NSString * picUrl3;
|
||
@property (nonatomic,copy) NSString * picUrl4;
|
||
|
||
@end
|
||
|
||
@implementation FourControlCanChangeImgController
|
||
|
||
- (void)viewDidLoad {
|
||
|
||
[super viewDidLoad];
|
||
_switchCellArr=[[NSMutableArray alloc]init];
|
||
_mySwitchButtonArry=[[NSMutableArray alloc]init];
|
||
_indexpatchArr=[[NSMutableArray alloc]init];
|
||
_selcterTimerArr=[[NSArray alloc]init];
|
||
_selectorSwitchArr=[[NSArray alloc]init];
|
||
_waterInfmodel=[[setRemindWaterModel alloc]init];
|
||
|
||
// Do any additional setup after loading the view.
|
||
_mainQueue = dispatch_get_main_queue();
|
||
self.navigationController.navigationBar.backItem.title=@"";
|
||
[self addTitleViewWithTitle:@"设置"];
|
||
[self initData];
|
||
|
||
[self creatIndicatorView];
|
||
self.tableView.backgroundColor=COLOR_MIAN;
|
||
|
||
[self initSectionViews];
|
||
|
||
UIBarButtonItem*rightItem=[[UIBarButtonItem alloc]initWithTitle:@"分享设备" style: UIBarButtonItemStyleDone target:self action:@selector(fourItemClick)];
|
||
rightItem.tintColor=[UIColor whiteColor];
|
||
self.navigationItem.rightBarButtonItem=rightItem;
|
||
|
||
self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
|
||
[self.tableView registerNib:[UINib nibWithNibName:@"SetTimeCell" bundle:nil] forCellReuseIdentifier:@"SetTimeCell"];
|
||
|
||
// self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,64, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped];
|
||
|
||
//此设置可以在设置了tableView 的style 为UITableViewStyleGrouped 时让标头避免出现空白
|
||
|
||
// self.tableView.tableHeaderView=[[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, kScreenSize.width, 0.01f)];
|
||
|
||
|
||
}
|
||
|
||
-(void)fourItemClick{
|
||
CreatErWeiMaController*vc=[[CreatErWeiMaController alloc]init]
|
||
;
|
||
vc.erdevicemodel=self.currentdevice;
|
||
|
||
[self.navigationController pushViewController:vc animated:YES];
|
||
|
||
}
|
||
|
||
|
||
#pragma mark 头视图UI设置
|
||
|
||
|
||
-(void)initSectionViews{
|
||
|
||
_headHeight = SectionHeadHigh;
|
||
|
||
if (!_btn) {
|
||
_btn = [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width - 40 -24,SectionHeadHigh/2-20 , 40, 40)];
|
||
[_btn setTitle:@"更换" forState:UIControlStateNormal];
|
||
_btn.titleLabel.font=[UIFont systemFontOfSize:15];
|
||
[_btn setTitleColor: SECTIONVIEW_LABELCOLER forState:UIControlStateNormal];
|
||
|
||
[_btn addTarget:self action:@selector(fHeaderbtnClick1:) forControlEvents:UIControlEventTouchUpInside];
|
||
}
|
||
|
||
_headHeight2 = SectionHeadHigh;
|
||
if (!_btn2) {
|
||
_btn2 = [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width - 40 -24,SectionHeadHigh/2-20 , 40, 40)];
|
||
[_btn2 setTitle:@"更换" forState:UIControlStateNormal];
|
||
_btn2.titleLabel.font=[UIFont systemFontOfSize:15];
|
||
[_btn2 setTitleColor: SECTIONVIEW_LABELCOLER forState:UIControlStateNormal];
|
||
[_btn2 addTarget:self action:@selector(fHeaderbtnClick2:) forControlEvents:UIControlEventTouchUpInside];
|
||
}
|
||
|
||
_headHeight3 = SectionHeadHigh;
|
||
if (!_btn3) {
|
||
_btn3 = [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width - 40 -24,SectionHeadHigh/2-20 , 40, 40)];
|
||
[_btn3 setTitle:@"更换" forState:UIControlStateNormal];
|
||
_btn3.titleLabel.font=[UIFont systemFontOfSize:15];
|
||
[_btn3 setTitleColor: SECTIONVIEW_LABELCOLER forState:UIControlStateNormal];
|
||
[_btn3 addTarget:self action:@selector(fHeaderbtnClick3: ) forControlEvents:UIControlEventTouchUpInside];
|
||
}
|
||
|
||
_headHeight4 = SectionHeadHigh;
|
||
if (!_btn4) {
|
||
_btn4 = [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width - 40 -24,SectionHeadHigh/2-20 , 40, 40)];
|
||
[_btn4 setTitle:@"更换" forState:UIControlStateNormal];
|
||
_btn4.titleLabel.font=[UIFont systemFontOfSize:15];
|
||
[_btn4 setTitleColor: SECTIONVIEW_LABELCOLER forState:UIControlStateNormal];
|
||
[_btn4 addTarget:self action:@selector(fHeaderbtnClick4:) forControlEvents:UIControlEventTouchUpInside];
|
||
}
|
||
|
||
|
||
if (!_leftTop) {
|
||
|
||
_leftlabel = [[UILabel alloc] initWithFrame:CGRectMake(65, SectionHeadHigh/2-5, 100, 10)];
|
||
|
||
_leftlabel.font=[UIFont systemFontOfSize:15];
|
||
_leftlabel.textColor = SECTIONVIEW_LABELCOLER;
|
||
|
||
}
|
||
|
||
if (!_leftTop2) {
|
||
|
||
_leftlabel2 = [[UILabel alloc] initWithFrame:CGRectMake(65, SectionHeadHigh/2-5, 100, 10)];
|
||
_leftlabel2.font=[UIFont systemFontOfSize:15];
|
||
_leftlabel2.textColor = SECTIONVIEW_LABELCOLER;
|
||
|
||
}
|
||
|
||
if (!_leftTop3) {
|
||
|
||
_leftlabel3 = [[UILabel alloc] initWithFrame:CGRectMake(65, SectionHeadHigh/2-5, 100, 10)];
|
||
_leftlabel3.font=[UIFont systemFontOfSize:15];
|
||
_leftlabel3.textColor = SECTIONVIEW_LABELCOLER;
|
||
|
||
}
|
||
|
||
if (!_leftTop4) {
|
||
|
||
_leftlabel4 = [[UILabel alloc] initWithFrame:CGRectMake(65, SectionHeadHigh/2-5, 100, 10)];
|
||
_leftlabel4.font=[UIFont systemFontOfSize:15];
|
||
_leftlabel4.textColor = SECTIONVIEW_LABELCOLER;
|
||
|
||
}
|
||
|
||
NSUserDefaults *userdefaultsIndex = [NSUserDefaults standardUserDefaults];
|
||
|
||
NSString*index1= [userdefaultsIndex valueForKey:@"indexArrVlue1"];
|
||
NSString*index2= [userdefaultsIndex valueForKey:@"indexArrVlue2"];
|
||
NSString*index3= [userdefaultsIndex valueForKey:@"indexArrVlue3"];
|
||
NSString*index4= [userdefaultsIndex valueForKey:@"indexArrVlue4"];
|
||
|
||
NSArray *imageArrindex=[[NSMutableArray alloc] init];
|
||
NSArray *allShowName = [[NSMutableArray alloc] init];
|
||
|
||
NSArray*alliconnames=[self.currentdevice.allIconName componentsSeparatedByString:@","];
|
||
|
||
if (![self.currentdevice.customIconName isEqualToString:@""]){
|
||
imageArrindex=[self.currentdevice.customIconName componentsSeparatedByString:@","];
|
||
}else{
|
||
imageArrindex=[self.currentdevice.defaultIconName componentsSeparatedByString:@","];
|
||
}
|
||
|
||
if (![self.currentdevice.allShowName isEqualToString:@""]) {
|
||
allShowName = [self.currentdevice.allShowName componentsSeparatedByString:@","];
|
||
}else{
|
||
allShowName = [self.currentdevice.defaultShowName componentsSeparatedByString:@","];
|
||
}
|
||
|
||
|
||
if (index1 == nil) {
|
||
index1 = imageArrindex[0];
|
||
}
|
||
|
||
if (index2 == nil) {
|
||
|
||
index2 = imageArrindex[1];
|
||
}
|
||
if (index3 == nil) {
|
||
|
||
index3 = imageArrindex[2];
|
||
}
|
||
|
||
if (index4 == nil) {
|
||
|
||
index4 = imageArrindex[3];
|
||
}
|
||
|
||
if (!_leftTop ) {
|
||
|
||
_leftTop = [[UIImageView alloc] initWithFrame:CGRectMake(10,SectionHeadHigh/2-20, 40, 40)];
|
||
|
||
int firstindex=[index1 intValue];
|
||
|
||
NSString* imageurl = [NSString stringWithFormat:@"%@%@",self.currentdevice.iconLink,alliconnames[firstindex]];
|
||
|
||
[_leftTop sd_setImageWithURL:[NSURL URLWithString:imageurl] placeholderImage:[UIImage imageNamed:@"icon1"]];
|
||
|
||
_leftlabel.text = allShowName[firstindex];
|
||
|
||
[_headView addSubview:_leftTop];
|
||
}
|
||
|
||
|
||
if (!_leftTop2) {
|
||
_leftTop2 = [[UIImageView alloc] initWithFrame:CGRectMake(10,SectionHeadHigh/2-20, 40, 40)];
|
||
int secindex=[index2 intValue];
|
||
|
||
NSString* imageurl = [NSString stringWithFormat:@"%@%@",self.currentdevice.iconLink,alliconnames[secindex]];
|
||
[_leftTop2 sd_setImageWithURL:[NSURL URLWithString:imageurl] placeholderImage:[UIImage imageNamed:@"icon1"]];
|
||
|
||
_leftlabel2.text = allShowName[secindex];
|
||
|
||
[_headView2 addSubview:_leftTop2];
|
||
|
||
}
|
||
|
||
if (!_leftTop3) {
|
||
_leftTop3 = [[UIImageView alloc] initWithFrame:CGRectMake(10,SectionHeadHigh/2-20, 40, 40)];
|
||
int thredindex=[index3 intValue];
|
||
|
||
NSString* imageurl = [NSString stringWithFormat:@"%@%@",self.currentdevice.iconLink,alliconnames[thredindex]];
|
||
[_leftTop3 sd_setImageWithURL:[NSURL URLWithString:imageurl] placeholderImage:[UIImage imageNamed:@"icon1"]];
|
||
_leftlabel3.text = allShowName[thredindex];
|
||
[_headView3 addSubview:_leftTop3];
|
||
|
||
}
|
||
|
||
if (!_leftTop4) {
|
||
_leftTop4 = [[UIImageView alloc] initWithFrame:CGRectMake(10,SectionHeadHigh/2-20, 40, 40)];
|
||
|
||
int forindex=[index4 intValue];
|
||
|
||
NSString* imageurl = [NSString stringWithFormat:@"%@%@",self.currentdevice.iconLink,alliconnames[forindex]];
|
||
|
||
[_leftTop4 sd_setImageWithURL:[NSURL URLWithString:imageurl] placeholderImage:[UIImage imageNamed:@"icon1"]];
|
||
_leftlabel4.text = allShowName[forindex];
|
||
|
||
[_headView4 addSubview:_leftTop4];
|
||
|
||
}
|
||
}
|
||
|
||
-(void)initData{
|
||
self.titleArr=@[@[@"预警设置",@"柜灯开关",@"背光亮度",@"换水提醒",@"定时模式"],@[@"时段1",@"时段2"],@[@"时段1",@"时段2"],@[@"时段1",@"时段2",],@[@"时段1",@"时段2",@""]];
|
||
|
||
|
||
FourControlbackMassge *backmodel=[[DataCenter defaultDtacenter]valueForKey:@"FourControlMassgeInfo"];
|
||
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];
|
||
|
||
// 十六进制
|
||
NSString *startTimeHex1=[backmodel.timer1 substringWithRange:NSMakeRange(4, 4)];
|
||
NSString *endTimeHex1=[backmodel.timer1 substringWithRange:NSMakeRange(8, 4)];
|
||
|
||
|
||
// 十进制
|
||
NSString *startTimeTen1=[dataContorl hexStringToDateString:startTimeHex1];
|
||
NSString *endTimeTen1=[dataContorl hexStringToDateString:endTimeHex1];
|
||
NSString *setTim1=[NSString stringWithFormat:@"%@~%@",startTimeTen1,endTimeTen1];
|
||
// 十六进制
|
||
NSString *startTimeHex2=[backmodel.timer2 substringWithRange:NSMakeRange(4, 4)];
|
||
NSString *endTimeHex2=[backmodel.timer2 substringWithRange:NSMakeRange(8, 4)];
|
||
// 十进制
|
||
NSString *startTimeTen2=[dataContorl hexStringToDateString:startTimeHex2];
|
||
NSString *endTimeTen2=[dataContorl hexStringToDateString:endTimeHex2];
|
||
NSString *setTim2=[NSString stringWithFormat:@"%@~%@",startTimeTen2,endTimeTen2];
|
||
|
||
// 十六进制
|
||
NSString *startTimeHex3=[backmodel.timer3 substringWithRange:NSMakeRange(4, 4)];
|
||
NSString *endTimeHex3=[backmodel.timer3 substringWithRange:NSMakeRange(8, 4)];
|
||
// 十进制
|
||
NSString *startTimeTen3=[dataContorl hexStringToDateString:startTimeHex3];
|
||
NSString *endTimeTen3=[dataContorl hexStringToDateString:endTimeHex3];
|
||
NSString *setTim3=[NSString stringWithFormat:@"%@~%@",startTimeTen3,endTimeTen3];
|
||
|
||
// 十六进制
|
||
NSString *startTimeHex4=[backmodel.timer4 substringWithRange:NSMakeRange(4, 4)];
|
||
NSString *endTimeHex4=[backmodel.timer4 substringWithRange:NSMakeRange(8, 4)];
|
||
// 十进制
|
||
NSString *startTimeTen4=[dataContorl hexStringToDateString:startTimeHex4];
|
||
NSString *endTimeTen4=[dataContorl hexStringToDateString:endTimeHex4];
|
||
NSString *setTim4=[NSString stringWithFormat:@"%@~%@",startTimeTen4,endTimeTen4];
|
||
|
||
// 十六进制
|
||
NSString*startTimeHex5=[backmodel.timer5 substringWithRange:NSMakeRange(4, 4)];
|
||
NSString*endTimeHex5=[backmodel.timer5 substringWithRange:NSMakeRange(8, 4)];
|
||
// 十进制
|
||
NSString*startTimeTen5=[dataContorl hexStringToDateString:startTimeHex5];
|
||
NSString*endTimeTen5=[dataContorl hexStringToDateString:endTimeHex5];
|
||
NSString*setTim5=[NSString stringWithFormat:@"%@~%@",startTimeTen5,endTimeTen5];
|
||
|
||
// 十六进制
|
||
NSString*startTimeHex6=[backmodel.timer6 substringWithRange:NSMakeRange(4, 4)];
|
||
NSString*endTimeHex6=[backmodel.timer6 substringWithRange:NSMakeRange(8, 4)];
|
||
// 十进制
|
||
NSString*startTimeTen6=[dataContorl hexStringToDateString:startTimeHex6];
|
||
NSString*endTimeTen6=[dataContorl hexStringToDateString:endTimeHex6];
|
||
NSString*setTim6=[NSString stringWithFormat:@"%@~%@",startTimeTen6,endTimeTen6];
|
||
|
||
|
||
NSString*startTimeHex7=[backmodel.timer7 substringWithRange:NSMakeRange(4, 4)];
|
||
NSString*endTimeHex7=[backmodel.timer7 substringWithRange:NSMakeRange(8, 4)];
|
||
// 十进制
|
||
NSString*startTimeTen7=[dataContorl hexStringToDateString:startTimeHex7];
|
||
NSString*endTimeTen7=[dataContorl hexStringToDateString:endTimeHex7];
|
||
NSString*setTim7=[NSString stringWithFormat:@"%@~%@",startTimeTen7,endTimeTen7];
|
||
|
||
// 十六进制
|
||
NSString*startTimeHex8=[backmodel.timer8 substringWithRange:NSMakeRange(4, 4)];
|
||
NSString*endTimeHex8=[backmodel.timer8 substringWithRange:NSMakeRange(8, 4)];
|
||
// 十进制
|
||
NSString*startTimeTen8=[dataContorl hexStringToDateString:startTimeHex8];
|
||
NSString*endTimeTen8=[dataContorl hexStringToDateString:endTimeHex8];
|
||
NSString*setTim8=[NSString stringWithFormat:@"%@~%@",startTimeTen8,endTimeTen8];
|
||
|
||
// // 十六进制
|
||
// NSString*startTimeHex9=[backmodel.timer9 substringWithRange:NSMakeRange(4, 4)];
|
||
// NSString*endTimeHex9=[backmodel.timer9 substringWithRange:NSMakeRange(8, 4)];
|
||
// // 十进制
|
||
// NSString*startTimeTen9=[dataContorl hexStringToDateString:startTimeHex9];
|
||
// NSString*endTimeTen9=[dataContorl hexStringToDateString:endTimeHex9];
|
||
// NSString*setTim9=[NSString stringWithFormat:@"%@~%@",startTimeTen9,endTimeTen9];
|
||
|
||
|
||
NSString*switchButton1=[backmodel.timer1 substringWithRange:NSMakeRange(2, 2)];
|
||
NSString*switchButton2=[backmodel.timer2 substringWithRange:NSMakeRange(2, 2)];
|
||
NSString*switchButton3=[backmodel.timer3 substringWithRange:NSMakeRange(2, 2)];
|
||
NSString*switchButton4=[backmodel.timer4 substringWithRange:NSMakeRange(2, 2)];
|
||
NSString*switchButton5=[backmodel.timer5 substringWithRange:NSMakeRange(2, 2)];
|
||
NSString*switchButton6=[backmodel.timer6 substringWithRange:NSMakeRange(2, 2)];
|
||
NSString*switchButton7=[backmodel.timer7 substringWithRange:NSMakeRange(2, 2)];
|
||
NSString*switchButton8=[backmodel.timer8 substringWithRange:NSMakeRange(2, 2)];
|
||
// NSString*switchButton9=[backmodel.timer9 substringWithRange:NSMakeRange(2, 2)];
|
||
|
||
|
||
_selectorSwitchArr=@[switchButton1,switchButton2,switchButton3,switchButton4,switchButton5,switchButton6,switchButton7,switchButton8];
|
||
_selcterTimerArr=@[setTim1,setTim2,setTim3,setTim4,setTim5,setTim6,setTim7,setTim8];
|
||
self.timeArr=@[@[wenduString,@"设置时段"],@[setTim1,setTim2],@[setTim3,setTim4],@[setTim5,setTim6],@[setTim7,setTim8,@""]];
|
||
|
||
}else{
|
||
[self showTitle:@"" messsage:@"设备已离线"];
|
||
self.timeArr=@[@[@"20~30°C",@"2:00~5:00"],@[@"2:00~5:00",@"2:00~5:00"],@[@"2:00~5:00",@"2:00~5:00"],@[@"2:00~5:00",@"2:00~5:00"],@[@"2:00~5:00",@"2:00~5:00",@""]];
|
||
_selcterTimerArr=@[@"2:00~5:00",@"2:00~5:00",@"2:00~5:00",@"2:00~5:00",@"2:00~5:00",@"2:00~5:00",@"2:00~5:00",@"2:00~5:00"];//防crash
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|
||
#pragma mark - Table view data source
|
||
|
||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||
|
||
return 5;
|
||
}
|
||
|
||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||
if (section==0) {
|
||
return 5;
|
||
}else if (section == 4){
|
||
|
||
return 3;
|
||
|
||
}else{
|
||
return 2;
|
||
}
|
||
|
||
}
|
||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||
|
||
FourControlbackMassge *backmodel=[[DataCenter defaultDtacenter]valueForKey:@"FourControlMassgeInfo"];
|
||
|
||
static NSString *cellID=@"kongCell";
|
||
UITableViewCell *kongCell=[tableView dequeueReusableCellWithIdentifier:cellID];
|
||
|
||
if (kongCell==nil) {
|
||
|
||
kongCell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
|
||
}
|
||
|
||
|
||
if (indexPath.section==0&&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(normalFourtempSwitchAction:) 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(normalFourbtightnessSlider:) forControlEvents:UIControlEventValueChanged];
|
||
|
||
cell.brightTitleLabel.hidden=NO;
|
||
cell.btightnessSlider.hidden=NO;
|
||
cell.persentLabel.hidden=NO;
|
||
|
||
return cell;
|
||
}else{
|
||
//无背光
|
||
|
||
return kongCell;
|
||
}
|
||
|
||
}else{
|
||
cell.brightTitleLabel.hidden=YES;
|
||
cell.btightnessSlider.hidden=YES;
|
||
cell.persentLabel.hidden=YES;
|
||
|
||
return cell;
|
||
}
|
||
|
||
|
||
}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(normalFourguidengSwitchAtion:) 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.section==0&&indexPath.row==3){
|
||
// 换水提醒
|
||
|
||
|
||
if (![self.currentdevice.waterRemind isEqual:[NSNull null]]) {
|
||
ChangeWaterCell*cell=[tableView dequeueReusableCellWithIdentifier:@"ChangeWaterCell"];
|
||
if (cell==nil) {
|
||
cell=[[[NSBundle mainBundle]loadNibNamed:@"ChangeWaterCell" owner:self options:nil]lastObject];
|
||
}
|
||
|
||
[cell.ChangeWaterSwitch addTarget:self action:@selector(normalFourchangeWaterSwitch:) forControlEvents:UIControlEventTouchUpInside];
|
||
|
||
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(@"ce;;%@",cell.huanshuiDaylabel.text);
|
||
|
||
NSLog(@"222");
|
||
}
|
||
|
||
|
||
return cell;
|
||
|
||
}else{
|
||
|
||
kongCell.textLabel.text =@"错误信息 waterRemind null";
|
||
return kongCell;
|
||
|
||
}
|
||
|
||
|
||
}else if (indexPath.section==0&&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];
|
||
if (!self.waterInfmodel.remindDate) {
|
||
cell.textLabel.text=[NSString stringWithFormat:@"下次换水时间:%@",self.nextChangeDateLabel];
|
||
}
|
||
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{
|
||
|
||
if (indexPath.section==4&&indexPath.row==2) {
|
||
//最后插入一个cell达到 椭圆底效果
|
||
static NSString*cellId=@"lastSectlastcell";
|
||
UITableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:cellId];
|
||
if (cell==nil) {
|
||
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellId];
|
||
}
|
||
|
||
cell.backgroundView =[ [UIImageView alloc] initWithImage:[UIImage imageNamed:@"secondSetCell"]];
|
||
cell.userInteractionEnabled = NO;
|
||
|
||
return cell;
|
||
|
||
}else{
|
||
|
||
|
||
SetTimeCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SetTimeCell"];
|
||
if (cell==nil) {
|
||
//cell=[[[NSBundle mainBundle]loadNibNamed:@"SetTimeCell" owner:self options:nil]lastObject];
|
||
cell = [[SetTimeCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"SetTimeCell"];
|
||
|
||
|
||
}
|
||
|
||
SetTimeModel*model=[[SetTimeModel alloc]init];
|
||
model.title=self.titleArr[indexPath.section][indexPath.row];
|
||
cell.titleLabel.text=model.title;
|
||
model.timestring=self.timeArr[indexPath.section][indexPath.row];
|
||
cell.timeLabel.text=model.timestring;
|
||
cell.timeLabel.tag=TIME_TAG+indexPath.section*10+indexPath.row;
|
||
|
||
[cell SetEightTimerBackAtIndex:indexPath];
|
||
|
||
if (indexPath.section!=0 && !(indexPath.section==3&&indexPath.row==2)) {
|
||
cell.tag=indexPath.row +SET_CELL_TAG+indexPath.section*10;
|
||
|
||
cell.mySwitchButton.tag=indexPath.row +MYSWITCH_TAG+indexPath.section*10;
|
||
|
||
[_indexpatchArr addObject:indexPath];
|
||
[_mySwitchButtonArry addObject:cell.mySwitchButton];
|
||
[_switchCellArr addObject:cell];
|
||
}
|
||
|
||
if (indexPath.section!=0 && !(indexPath.section==4&&indexPath.row==2)) {
|
||
|
||
|
||
[cell SetEightTimerSwitchAtIndex:indexPath WithBacmodel:backmodel];
|
||
if (indexPath.section ==1 ) {
|
||
[cell.setHeaderBtn addTarget:self action:@selector(fHeaderbtnClick1:) forControlEvents:UIControlEventTouchUpInside];
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
[cell.mySwitchButton addTarget:self action:@selector(changeImageFourbtnCliCk:) forControlEvents:UIControlEventTouchUpInside];
|
||
|
||
if ([self.currentdevice.isWorkModel isEqualToString:@"1"]) {
|
||
//有自动模式
|
||
if ([backmodel.yunxingmoshi isEqualToString:@"01"]) {// 自动模式下
|
||
|
||
cell.mySwitchButton.userInteractionEnabled=YES;
|
||
|
||
|
||
}else{
|
||
cell.mySwitchButton.userInteractionEnabled=NO;
|
||
}
|
||
|
||
}else{
|
||
//无自动模式
|
||
cell.mySwitchButton.userInteractionEnabled=YES;
|
||
}
|
||
|
||
[cell bringSubviewToFront:cell.mySwitchButton];
|
||
|
||
|
||
return cell;
|
||
|
||
}
|
||
}
|
||
|
||
}
|
||
-(void)changeImageFourbtnCliCk:(UIButton*)btn{
|
||
TimerSateModel*stateModel=[[TimerSateModel alloc]init];
|
||
stateModel.crc16String=@"0000";
|
||
|
||
FourControlbackMassge *backmodel=[[DataCenter defaultDtacenter]valueForKey:@"FourControlMassgeInfo"];
|
||
|
||
NSString*backState=nil;
|
||
// SetSelectorTime*selectorTimeModel=[[SetSelectorTime alloc]init];
|
||
if (btn.tag==3010) {
|
||
backState=[backmodel.timer1 substringWithRange:NSMakeRange(2, 2)];
|
||
_indexpath=[_indexpatchArr objectAtIndex:0];
|
||
|
||
|
||
stateModel.timerNumber=@"01";
|
||
// stateModel.timerState=[backmodel.timer1 substringWithRange:NSMakeRange(2, 2)];
|
||
|
||
|
||
}else if (btn.tag==3011){
|
||
backState=[backmodel.timer2 substringWithRange:NSMakeRange(2, 2)];
|
||
_indexpath=[_indexpatchArr objectAtIndex:1];
|
||
|
||
|
||
|
||
stateModel.timerNumber=@"02";
|
||
// stateModel.timerState=[backmodel.timer2 substringWithRange:NSMakeRange(2, 2)];
|
||
|
||
}else if (btn.tag==3020){
|
||
|
||
backState=[backmodel.timer3 substringWithRange:NSMakeRange(2, 2)];
|
||
_indexpath=[_indexpatchArr objectAtIndex:2];
|
||
|
||
stateModel.timerNumber=@"03";
|
||
// stateModel.timerState=[backmodel.timer3 substringWithRange:NSMakeRange(2, 2)];
|
||
}else if (btn.tag==3021){
|
||
backState=[backmodel.timer4 substringWithRange:NSMakeRange(2, 2)];
|
||
_indexpath=[_indexpatchArr objectAtIndex:3];
|
||
|
||
|
||
stateModel.timerNumber=@"04";
|
||
// stateModel.timerState=[backmodel.timer4 substringWithRange:NSMakeRange(2, 2)];
|
||
|
||
}else if (btn.tag==3030){
|
||
backState=[backmodel.timer5 substringWithRange:NSMakeRange(2, 2)];
|
||
_indexpath=[_indexpatchArr objectAtIndex:4];
|
||
|
||
|
||
stateModel.timerNumber=@"05";
|
||
//stateModel.timerState=[backmodel.timer5 substringWithRange:NSMakeRange(2, 2)];
|
||
|
||
|
||
}else if (btn.tag==3031){
|
||
backState=[backmodel.timer6 substringWithRange:NSMakeRange(2, 2)];
|
||
_indexpath=[_indexpatchArr objectAtIndex:5];
|
||
|
||
|
||
stateModel.timerNumber=@"06";
|
||
}else if (btn.tag==3040){
|
||
backState=[backmodel.timer7 substringWithRange:NSMakeRange(2, 2)];
|
||
_indexpath=[_indexpatchArr objectAtIndex:5];
|
||
|
||
|
||
stateModel.timerNumber=@"07";
|
||
}else if (btn.tag==3041){
|
||
backState=[backmodel.timer8 substringWithRange:NSMakeRange(2, 2)];
|
||
_indexpath=[_indexpatchArr objectAtIndex:5];
|
||
|
||
|
||
stateModel.timerNumber=@"08";
|
||
}
|
||
|
||
|
||
if ([backState isEqualToString:@"01"]) {
|
||
// mySwitchIsOn=YES;
|
||
// }else{
|
||
// mySwitchIsOn=NO;
|
||
stateModel.timerState=@"00";// 关
|
||
NSString*stateString=[NSString stringWithFormat:@"%@%@%@%@",stateModel.description,stateModel.timerNumber,stateModel.timerState,stateModel.crc16String];
|
||
|
||
NSData*selctorData=[dataContorl stringToHexData:stateString];
|
||
[self.clientSocket writeData:selctorData withTimeout:-1 tag:1];
|
||
[self.clientSocket readDataWithTimeout:-1 tag:1];
|
||
[_indicatorView startAnimating];
|
||
[btn setImage:[UIImage imageNamed:@"Switch-Off"] forState:UIControlStateNormal];
|
||
|
||
|
||
|
||
}else{
|
||
stateModel.timerState=@"01";// 开
|
||
NSString*selectorString=[NSString stringWithFormat:@"%@%@%@%@",stateModel.description,stateModel.timerNumber,stateModel.timerState,stateModel.crc16String];
|
||
|
||
NSData*selctorData=[dataContorl stringToHexData:selectorString];
|
||
[self.clientSocket writeData:selctorData withTimeout:-1 tag:1];
|
||
[self.clientSocket readDataWithTimeout:-1 tag:1];
|
||
[_indicatorView startAnimating];
|
||
[btn setImage:[UIImage imageNamed:@"Switch-On"] forState:UIControlStateNormal];
|
||
|
||
}
|
||
|
||
}
|
||
#pragma mark 开启关闭报警
|
||
-(void)normalFourtempSwitchAction:(UIButton*)temperatureSwitch{
|
||
FourControlbackMassge *backmodel=[[DataCenter defaultDtacenter]valueForKey:@"FourControlMassgeInfo"];
|
||
setWaringTpModel*warModel1=[[setWaringTpModel alloc]init];
|
||
//BOOL isOn=[temperatureSwitch isOn];
|
||
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:(FourControlbackMassge*)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];
|
||
[self.clientSocket writeData:minwenDuData withTimeout:-1 tag:1];
|
||
[self.clientSocket readDataWithTimeout:-1 tag:1];
|
||
[_indicatorView startAnimating];
|
||
backModel.miniTp=waringModel.miniwaterTp;
|
||
backModel.maxTp=waringModel.maxwaterTp;
|
||
|
||
}
|
||
|
||
|
||
#pragma mark 柜光灯开关Action
|
||
|
||
-(void)normalFourguidengSwitchAtion:(UIButton*)sender{
|
||
UIButton *switchButton = (UIButton*)sender;
|
||
//BOOL isButtonOn=[switchButton isOn];
|
||
GuidengKaiGuanModel*guidengModel=[[GuidengKaiGuanModel alloc]init];
|
||
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];
|
||
[self.clientSocket writeData:guidengData withTimeout:-1 tag:0];
|
||
[self.clientSocket readDataWithTimeout:-1 tag:0];
|
||
FourControlbackMassge *backmodel=[[DataCenter defaultDtacenter]valueForKey:@"FourControlMassgeInfo"];
|
||
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];
|
||
[self.clientSocket writeData:guidengData withTimeout:-1 tag:0];
|
||
[self.clientSocket readDataWithTimeout:-1 tag:0];
|
||
FourControlbackMassge *backmodel=[[DataCenter defaultDtacenter]valueForKey:@"FourControlMassgeInfo"];
|
||
backmodel.tankLight=@"00";
|
||
[_indicatorView startAnimating];
|
||
|
||
}
|
||
|
||
}
|
||
|
||
#pragma mark 背光灯亮度Action
|
||
|
||
-(void)normalFourbtightnessSlider:(UISlider*)sender{
|
||
UISlider*slider=(UISlider*)sender;
|
||
NSLog(@"%f",slider.value);
|
||
//这里 只传整数
|
||
//1.强转四舍五入
|
||
|
||
int sliderValue=(int)(slider.value+0.5);
|
||
|
||
|
||
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.liangdu=hexString;
|
||
brightModel.crc16Code=@"0000";
|
||
NSString*changeLightOder=[NSString stringWithFormat:@"%@%@%@",brightModel.description,brightModel.liangdu,brightModel.crc16Code];
|
||
NSData*changeLghtData=[dataContorl stringToHexData:changeLightOder];
|
||
[self.clientSocket writeData:changeLghtData withTimeout:-1 tag:0];
|
||
[self.clientSocket readDataWithTimeout:-1 tag:0];
|
||
[_indicatorView startAnimating];
|
||
|
||
|
||
}
|
||
|
||
#pragma mark 换水提醒Action
|
||
-(void)normalFourchangeWaterSwitch:(UIButton*)sender{
|
||
|
||
UIButton*huanShuiSwitch=(UIButton*)sender;
|
||
|
||
|
||
NSUserDefaults*defuat=[NSUserDefaults standardUserDefaults];
|
||
NSString*picResult=[defuat valueForKey:@"normalSikongpicResult"];
|
||
|
||
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=remindModel;
|
||
|
||
}];
|
||
|
||
self.waterInfmodel.waterremind=@"0";
|
||
|
||
[self.tableView reloadData];
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
#pragma mark tableView 头视图和脚视图
|
||
|
||
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||
|
||
if (indexPath.section==0&&indexPath.row==4) {
|
||
|
||
|
||
if (_huanShuiSwitchIsOn) {
|
||
|
||
return 50;
|
||
}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;
|
||
}
|
||
|
||
|
||
}
|
||
|
||
-(void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section{
|
||
|
||
|
||
}
|
||
-(void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section{
|
||
|
||
|
||
}
|
||
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
|
||
|
||
return 0;
|
||
}
|
||
|
||
#pragma mark 设置tableview头视图
|
||
|
||
//-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
||
//
|
||
// if (section == 1) {
|
||
//
|
||
// return _headHeight;
|
||
//
|
||
// }else if (section == 2){
|
||
//
|
||
// return _headHeight2;
|
||
//
|
||
// }else if (section == 3){
|
||
//
|
||
// return _headHeight3;
|
||
//
|
||
// }else if (section == 4){
|
||
//
|
||
// return _headHeight4;
|
||
//
|
||
// }else if(section == 0 ){
|
||
//
|
||
// return 0.0001;
|
||
// }
|
||
//
|
||
// return 0;
|
||
//
|
||
//}
|
||
|
||
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
||
|
||
if (section == 1) {
|
||
return 50;
|
||
|
||
}else if (section ==0){
|
||
return 5;
|
||
}else {
|
||
return 0;
|
||
}
|
||
|
||
}
|
||
|
||
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
||
|
||
|
||
// if (section == 1) {
|
||
//
|
||
// if (!_headView) {
|
||
// _headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, _headHeight)];
|
||
// _headView.backgroundColor = [UIColor colorWithRed:160/255.0f green:160/255.0f blue:160/255.0f alpha:1];
|
||
// }
|
||
// [self.view addSubview:_headView];
|
||
// [_headView addSubview:_btn];
|
||
//
|
||
// [_headView addSubview:_leftTop];
|
||
// [_headView addSubview:_leftlabel];
|
||
//
|
||
// return _headView;
|
||
//
|
||
// }else if(section == 2){
|
||
//
|
||
// if (!_headView2) {
|
||
// _headView2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, _headHeight2)];
|
||
// _headView2.backgroundColor = [UIColor colorWithRed:160/255.0f green:160/255.0f blue:160/255.0f alpha:1];
|
||
// }
|
||
//
|
||
// [self.view addSubview:_headView2];
|
||
// [_headView2 addSubview:_btn2];
|
||
// [_headView2 addSubview:_leftTop2];
|
||
// [_headView2 addSubview:_leftlabel2];
|
||
//
|
||
// return _headView2;
|
||
//
|
||
// }else if(section ==3){
|
||
//
|
||
// if (!_headView3) {
|
||
//
|
||
// _headView3 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, _headHeight3)];
|
||
//
|
||
// _headView3.backgroundColor =[UIColor colorWithRed:160/255.0f green:160/255.0f blue:160/255.0f alpha:1];
|
||
// }
|
||
//
|
||
// [self.view addSubview:_headView3];
|
||
// [_headView3 addSubview:_btn3];
|
||
// [_headView3 addSubview:_leftTop3];
|
||
// [_headView3 addSubview:_leftlabel3];
|
||
//
|
||
// return _headView3;
|
||
//
|
||
//
|
||
// }else if(section == 4){
|
||
//
|
||
// if (!_headView4) {
|
||
// _headView4 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, _headHeight4)];
|
||
// _headView4.backgroundColor = [UIColor colorWithRed:160/255.0f green:160/255.0f blue:160/255.0f alpha:1];
|
||
// }
|
||
//
|
||
// [self.view addSubview:_headView4];
|
||
// [_headView4 addSubview:_btn4];
|
||
// [_headView4 addSubview:_leftTop4];
|
||
// [_headView4 addSubview:_leftlabel4];
|
||
//
|
||
// return _headView4;
|
||
//
|
||
// }else{
|
||
//
|
||
// //零区
|
||
// return nil;
|
||
// }
|
||
|
||
if (section==1) {
|
||
FourControlbackMassge *backmodel=[[DataCenter defaultDtacenter]valueForKey:@"FourControlMassgeInfo"];
|
||
UIImageView*secondSectionHeader=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"firstSetCell"]];
|
||
secondSectionHeader.userInteractionEnabled = YES;
|
||
UILabel *label=[[UILabel alloc] init];
|
||
label.text=@"定时模式";
|
||
label.font = [UIFont systemFontOfSize:15];
|
||
label.frame=CGRectMake(18, 5, 100, 40);
|
||
[secondSectionHeader addSubview:label];
|
||
|
||
//UISwitch *swich=[[UISwitch alloc] init];
|
||
UIButton *swBtn=[UIButton buttonWithType:UIButtonTypeCustom];
|
||
|
||
swBtn.frame=CGRectMake(kScreenSize.width- 24 - 49, 8, 60, 33);
|
||
|
||
[swBtn addTarget:self action:@selector(normalFourControlSwitchClick:) forControlEvents:UIControlEventTouchUpInside];
|
||
|
||
if ([backmodel.yunxingmoshi isEqualToString:@"01"]) {
|
||
[swBtn setBackgroundImage:[UIImage imageNamed:@"greenbtn_big"] forState:UIControlStateNormal];
|
||
swBtn.selected = NO;
|
||
}else{
|
||
[swBtn setBackgroundImage:[UIImage imageNamed:@"graybtn_big"] forState:UIControlStateNormal];
|
||
swBtn.selected = YES;
|
||
|
||
}
|
||
if (![_currentdevice.isWorkModel isEqual:[NSNull null]]) {
|
||
if ([_currentdevice.isWorkModel isEqualToString:@"1"]) {
|
||
|
||
[swBtn setHidden:NO];
|
||
|
||
}else{
|
||
|
||
[swBtn setHidden:YES];
|
||
}
|
||
|
||
|
||
}else{
|
||
|
||
[swBtn setHidden:YES];
|
||
}
|
||
|
||
|
||
[secondSectionHeader addSubview:swBtn];
|
||
|
||
|
||
return secondSectionHeader;
|
||
|
||
|
||
}else if (section == 0){
|
||
UIView*oneHeader=[[UIView alloc] init];
|
||
oneHeader.backgroundColor=COLOR_MIAN;
|
||
return oneHeader;
|
||
|
||
}else{
|
||
return nil;
|
||
}
|
||
|
||
}
|
||
|
||
|
||
//-(void)lastIndex{
|
||
//
|
||
//// NSUserDefaults *userSelectLast = [NSUserDefaults standardUserDefaults];
|
||
//// NSInteger lastIndex = [[userSelectLast objectForKey:@"indexArrVlue1"] integerValue];
|
||
// // _line1.frame = CGRectMake(kplace + lastIndex * (imageHigh + kplace), imageHigh + imageHigh + 3 + 10, imageHigh, 3) ;
|
||
//
|
||
//}
|
||
//
|
||
#pragma mark 第一个更换按钮
|
||
-(void)fHeaderbtnClick1:(UIButton *)sender{
|
||
|
||
|
||
// [_line1 setHidden:YES];
|
||
if (sender.selected == NO) {
|
||
|
||
//展开状态
|
||
if (!_headView) {
|
||
_headView = [[UIView alloc] initWithFrame:CGRectMake(0,200, self.view.frame.size.width, 100)];
|
||
_headView.backgroundColor = [UIColor colorWithRed:160/255.0f green:160/255.0f blue:160/255.0f alpha:1];
|
||
}
|
||
[self.tableView addSubview:_headView];
|
||
sender.selected = YES;
|
||
|
||
[self showPhoto];
|
||
|
||
//[self.tableView reloadData];
|
||
|
||
}else if(sender.selected == YES){
|
||
|
||
//未展开状态
|
||
// [sender setTitle:@"更换" forState:UIControlStateNormal];
|
||
// _headHeight = SectionHeadHigh;
|
||
// _headView.frame = CGRectMake(0, 0, self.view.frame.size.width, _headHeight ) ;
|
||
// _headView.backgroundColor = [UIColor colorWithRed:160/255.0f green:160/255.0f blue:160/255.0f alpha:1];
|
||
|
||
sender.selected = NO;
|
||
|
||
//_headView.alpha = 1;
|
||
[_headView removeFromSuperview];
|
||
[_showView dismiss];
|
||
//保存自定义图标
|
||
|
||
//[self loadData];
|
||
|
||
//[self.tableView reloadData];
|
||
|
||
|
||
}
|
||
|
||
}
|
||
|
||
#pragma mark 展示第一个头视图
|
||
|
||
-(void)showPhoto
|
||
{
|
||
|
||
// _line1 = [[UIView alloc] initWithFrame:CGRectMake(kplace + _indexWithImage * (imageHigh + kplace), imageHigh + 3 + 50, imageHigh, 3)];
|
||
//
|
||
// _line1.backgroundColor = [UIColor orangeColor];
|
||
|
||
NSMutableArray * images= [NSMutableArray array];
|
||
|
||
NSArray*deviceArr=[[DataCenter defaultDtacenter] valueForKey:@"deviceInfo"];
|
||
if (deviceArr==nil) {
|
||
|
||
[self showTitle:@"" messsage:@"请绑定设备"];
|
||
|
||
[self.navigationController popViewControllerAnimated:YES];
|
||
|
||
|
||
}else{
|
||
|
||
DeviceModel*devicemodel=self.currentdevice;
|
||
|
||
NSArray *strArr = [devicemodel.allIconName componentsSeparatedByString:@","];
|
||
NSArray *nameArr = [devicemodel.allShowName componentsSeparatedByString:@","];
|
||
for (int i = 0 ; i <strArr.count ; i ++) {
|
||
|
||
NSString *picUrl = [NSString stringWithFormat:@"%@%@",devicemodel.iconLink,strArr[i]];
|
||
|
||
|
||
[images addObject:picUrl];
|
||
|
||
};
|
||
|
||
|
||
_showView = [[LYPhotoShowView alloc] initWithFrame:CGRectMake(0, 0,kScreenSize.width, 100)];
|
||
|
||
[_showView setImages:images nameLabels:nameArr];
|
||
|
||
__weak typeof (self) weaself =self;
|
||
_showView.photoActionCallback = ^(NSInteger index){
|
||
|
||
_picUrl = images[index];
|
||
|
||
[weaself.leftTop sd_setImageWithURL:[NSURL URLWithString:weaself.picUrl] placeholderImage:[UIImage imageNamed:@"icon1"]];
|
||
weaself.leftlabel.text = nameArr[index];
|
||
|
||
_indexWithImage = index;
|
||
|
||
|
||
//[weaself Bloack:weaself.indexWithImage :weaself.indexWithImage2 :weaself.indexWithImage3 :weaself.indexWithImage4];
|
||
//存储下标
|
||
NSUserDefaults *userDict = [NSUserDefaults standardUserDefaults];
|
||
NSString *indexWithImage=[NSString stringWithFormat:@"%ld",(long)index];
|
||
[userDict setObject:indexWithImage forKey:@"indexArrVlue1"];
|
||
|
||
[userDict synchronize];
|
||
//上传设置
|
||
[weaself loadData];
|
||
|
||
|
||
};
|
||
|
||
_showView.backgroundColor = SECTHEADER_VIEWCOLOUR;
|
||
|
||
[_headView addSubview: _showView];
|
||
|
||
|
||
NSUserDefaults *userSelectLast = [NSUserDefaults standardUserDefaults];
|
||
NSInteger lastIndex = [[userSelectLast objectForKey:@"indexArrVlue1"] integerValue];
|
||
if (lastIndex) {
|
||
_showView.line.frame=CGRectMake( lastIndex * (kplace + imageHigh) + (kplace +imageHigh) - imageHigh ,imageHigh*3/2,imageHigh,3.0f);
|
||
}
|
||
|
||
[_showView show];
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|
||
#pragma mark 第二个更换按钮
|
||
|
||
-(void)fHeaderbtnClick2:(UIButton *)sender{
|
||
|
||
|
||
|
||
if (sender.selected == NO) {
|
||
[sender setTitle:@"更换" forState:UIControlStateNormal];
|
||
_headHeight2 = SectionHeadHigh + imageHigh + imageHigh/2 +3;
|
||
_headView2.frame = CGRectMake(0, 0, self.view.frame.size.width, _headHeight2 ) ;
|
||
_headView2.backgroundColor = SECTHEADER_VIEWCOLOUR;
|
||
|
||
sender.selected = YES;
|
||
|
||
[self showPhoto2];
|
||
[self.tableView reloadData];
|
||
|
||
}else if(sender.selected == YES){
|
||
[sender setTitle:@"更换" forState:UIControlStateNormal];
|
||
_headHeight2= SectionHeadHigh;
|
||
_headView2.frame = CGRectMake(0, 0, self.view.frame.size.width, _headHeight2 ) ;
|
||
_headView2.backgroundColor = SECTHEADER_VIEWCOLOUR;
|
||
|
||
sender.selected = NO;
|
||
|
||
_headView2.alpha = 1;
|
||
|
||
[_showView2 dismiss];
|
||
[self.tableView reloadData];
|
||
|
||
}
|
||
|
||
}
|
||
|
||
#pragma mark 第三个更换按钮
|
||
|
||
-(void)fHeaderbtnClick3:(UIButton *)sender{
|
||
|
||
|
||
|
||
if (sender.selected == NO) {
|
||
[sender setTitle:@"更换" forState:UIControlStateNormal];
|
||
_headHeight3 = SectionHeadHigh + imageHigh + imageHigh/2 +3;
|
||
_headView3.frame = CGRectMake(0, 0, self.view.frame.size.width, _headHeight3 ) ;
|
||
_headView3.backgroundColor = SECTHEADER_VIEWCOLOUR;
|
||
sender.selected = YES;
|
||
|
||
[self showPhoto3];
|
||
[self.tableView reloadData];
|
||
|
||
}else if(sender.selected == YES){
|
||
[sender setTitle:@"更换" forState:UIControlStateNormal];
|
||
_headHeight3= SectionHeadHigh;
|
||
_headView3.frame = CGRectMake(0, 0, self.view.frame.size.width, _headHeight3) ;
|
||
_headView3.backgroundColor = SECTHEADER_VIEWCOLOUR;
|
||
sender.selected = NO;
|
||
|
||
_headView3.alpha = 1;
|
||
|
||
[_showView3 dismiss];
|
||
|
||
[self.tableView reloadData];
|
||
|
||
}
|
||
|
||
}
|
||
|
||
#pragma mark 第四个更换按钮
|
||
|
||
-(void)fHeaderbtnClick4:(UIButton *)sender{
|
||
|
||
|
||
// [_line4 setHidden:YES];
|
||
if (sender.selected == NO) {
|
||
[sender setTitle:@"更换" forState:UIControlStateNormal];
|
||
_headHeight4 = SectionHeadHigh + imageHigh + imageHigh/2 +3;
|
||
_headView4.frame = CGRectMake(0, 0, self.view.frame.size.width, _headHeight4 ) ;
|
||
_headView4.backgroundColor = SECTHEADER_VIEWCOLOUR;
|
||
|
||
sender.selected = YES;
|
||
|
||
[self showPhoto4];
|
||
[self.tableView reloadData];
|
||
|
||
}else if(sender.selected == YES){
|
||
[sender setTitle:@"更换" forState:UIControlStateNormal];
|
||
_headHeight4= SectionHeadHigh;
|
||
_headView4.frame = CGRectMake(0, 0, self.view.frame.size.width, _headHeight4 ) ;
|
||
_headView4.backgroundColor = SECTHEADER_VIEWCOLOUR;
|
||
|
||
sender.selected = NO;
|
||
_headView4.alpha = 1;
|
||
|
||
[_showView4 dismiss];
|
||
|
||
[self.tableView reloadData];
|
||
|
||
}
|
||
|
||
}
|
||
|
||
#pragma 展示第二个头视图
|
||
|
||
-(void)showPhoto2
|
||
{
|
||
|
||
|
||
NSMutableArray * images= [NSMutableArray array];
|
||
|
||
NSArray*deviceArr=[[DataCenter defaultDtacenter] valueForKey:@"deviceInfo"];
|
||
if (deviceArr.count==0) {
|
||
|
||
[self showTitle:@"" messsage:@"请绑定设备"];
|
||
|
||
[self.navigationController popViewControllerAnimated:YES];
|
||
|
||
}else{
|
||
|
||
|
||
DeviceModel*devicemodel=self.currentdevice;
|
||
// NSLog(@"/**/*/*devicemodel%@",devicemodel.allIconName);
|
||
|
||
NSArray *strArr = [devicemodel.allIconName componentsSeparatedByString:@","];
|
||
NSArray *nameArr = [devicemodel.allShowName componentsSeparatedByString:@","];
|
||
|
||
for (int i = 0 ; i <strArr.count ; i ++) {
|
||
|
||
NSString *picUrl = [NSString stringWithFormat:@"%@%@",devicemodel.iconLink,strArr[i]];
|
||
|
||
NSLog(@"*-*-*-*-*--%@",picUrl);
|
||
[images addObject:picUrl];
|
||
|
||
};
|
||
|
||
|
||
_showView2 = [[LYPhotoShowView alloc]initWithFrame:CGRectMake(0, SectionHeadHigh , self.view.frame.size.width, imageHigh)];
|
||
[_showView2 setImages:images nameLabels:nameArr];
|
||
|
||
|
||
__weak typeof (self) weaself =self;
|
||
_showView2.photoActionCallback = ^(NSInteger index){
|
||
|
||
_indexWithImage2 = index;
|
||
|
||
|
||
|
||
_picUrl2 = images[index];
|
||
|
||
[weaself.leftTop2 sd_setImageWithURL:[NSURL URLWithString:weaself.picUrl2] placeholderImage:[UIImage imageNamed:@"icon1"]];
|
||
|
||
weaself.leftlabel2.text= nameArr[index];
|
||
|
||
NSUserDefaults *userDict = [NSUserDefaults standardUserDefaults];
|
||
NSString *indexWithImage=[NSString stringWithFormat:@"%ld",(long)index];
|
||
|
||
[userDict setObject:indexWithImage forKey:@"indexArrVlue2"];
|
||
|
||
[userDict synchronize];
|
||
//上传设置
|
||
[weaself loadData];
|
||
|
||
};
|
||
|
||
_showView2.backgroundColor = SECTHEADER_VIEWCOLOUR;
|
||
[_headView2 addSubview: _showView2];
|
||
|
||
NSUserDefaults *userSelectLast = [NSUserDefaults standardUserDefaults];
|
||
NSInteger lastIndex = [[userSelectLast objectForKey:@"indexArrVlue2"] integerValue];
|
||
if (lastIndex) {
|
||
_showView2.line.frame=CGRectMake( lastIndex * (kplace + imageHigh) + (kplace +imageHigh) - imageHigh ,imageHigh*3/2,imageHigh,3.0f);
|
||
}
|
||
|
||
[_showView2 show];
|
||
|
||
|
||
}
|
||
}
|
||
|
||
#pragma 展示第四个头视图
|
||
|
||
-(void)showPhoto4
|
||
{
|
||
|
||
|
||
NSMutableArray * images= [NSMutableArray array];
|
||
|
||
NSArray*deviceArr=[[DataCenter defaultDtacenter] valueForKey:@"deviceInfo"];
|
||
if (deviceArr.count==0) {
|
||
|
||
[self showTitle:@"" messsage:@"请绑定设备"];
|
||
|
||
[self.navigationController popViewControllerAnimated:YES];
|
||
|
||
}else{
|
||
|
||
|
||
DeviceModel*devicemodel=self.currentdevice;
|
||
// NSLog(@"/**/*/*devicemodel%@",devicemodel.allIconName);
|
||
|
||
NSArray *strArr = [devicemodel.allIconName componentsSeparatedByString:@","];
|
||
NSArray *nameArr = [devicemodel.allShowName componentsSeparatedByString:@","];
|
||
|
||
for (int i = 0 ; i <strArr.count ; i ++) {
|
||
|
||
NSString *picUrl = [NSString stringWithFormat:@"%@%@",devicemodel.iconLink,strArr[i]];
|
||
|
||
NSLog(@"*-*-*-*-*--%@",picUrl);
|
||
[images addObject:picUrl];
|
||
|
||
};
|
||
|
||
|
||
_showView4 = [[LYPhotoShowView alloc]initWithFrame:CGRectMake(0, SectionHeadHigh , self.view.frame.size.width, imageHigh)];
|
||
[_showView4 setImages:images nameLabels:nameArr];
|
||
|
||
__weak typeof (self) weaself =self;
|
||
_showView4.photoActionCallback = ^(NSInteger index){
|
||
|
||
_indexWithImage4 = index;
|
||
_picUrl4 = images[index];
|
||
|
||
[weaself.leftTop4 sd_setImageWithURL:[NSURL URLWithString:weaself.picUrl4] placeholderImage:[UIImage imageNamed:@"icon1"]];
|
||
|
||
weaself.leftlabel4.text = nameArr[index];
|
||
|
||
|
||
// [weaself Bloack:weaself.indexWithImage :weaself.indexWithImage2 :weaself.indexWithImage3 :weaself.indexWithImage4];
|
||
|
||
NSUserDefaults *userDict = [NSUserDefaults standardUserDefaults];
|
||
NSString *indexWithImage=[NSString stringWithFormat:@"%ld",(long)index];
|
||
|
||
[userDict setObject:indexWithImage forKey:@"indexArrVlue4"];
|
||
[userDict synchronize];
|
||
//上传设置
|
||
[weaself loadData];
|
||
};
|
||
|
||
_showView4.backgroundColor = SECTHEADER_VIEWCOLOUR;
|
||
[_headView4 addSubview: _showView4];
|
||
|
||
NSUserDefaults *userSelectLast = [NSUserDefaults standardUserDefaults];
|
||
NSInteger lastIndex = [[userSelectLast objectForKey:@"indexArrVlue4"] integerValue];
|
||
if (lastIndex) {
|
||
_showView4.line.frame=CGRectMake( lastIndex * (kplace + imageHigh) + (kplace +imageHigh) - imageHigh ,imageHigh*3/2,imageHigh,3.0f);
|
||
}
|
||
|
||
[_showView4 show];
|
||
|
||
}
|
||
}
|
||
|
||
#pragma 展示第三个头视图
|
||
|
||
-(void)showPhoto3
|
||
{
|
||
|
||
NSMutableArray * images= [NSMutableArray array];
|
||
|
||
NSArray*deviceArr=[[DataCenter defaultDtacenter] valueForKey:@"deviceInfo"];
|
||
if (deviceArr.count==0) {
|
||
|
||
[self showTitle:@"" messsage:@"请绑定设备"];
|
||
|
||
[self.navigationController popViewControllerAnimated:YES];
|
||
|
||
}else{
|
||
|
||
|
||
DeviceModel*devicemodel=self.currentdevice;
|
||
// NSLog(@"/**/*/*devicemodel%@",devicemodel.allIconName);
|
||
|
||
NSArray *strArr = [devicemodel.allIconName componentsSeparatedByString:@","];
|
||
NSArray *nameArr = [devicemodel.allShowName componentsSeparatedByString:@","];
|
||
|
||
|
||
for (int i = 0 ; i <strArr.count ; i ++) {
|
||
|
||
NSString *picUrl = [NSString stringWithFormat:@"%@%@",devicemodel.iconLink,strArr[i]];
|
||
|
||
NSLog(@"*-*-*-*-*--%@",picUrl);
|
||
[images addObject:picUrl];
|
||
|
||
};
|
||
|
||
_showView3 = [[LYPhotoShowView alloc]initWithFrame:CGRectMake(0, SectionHeadHigh , self.view.frame.size.width, imageHigh)];
|
||
|
||
[_showView3 setImages:images nameLabels:nameArr];
|
||
|
||
__weak typeof (self) weaself =self;
|
||
_showView3.photoActionCallback = ^(NSInteger index){
|
||
|
||
_indexWithImage3 = index;
|
||
|
||
_picUrl3 = images[index];
|
||
|
||
[weaself.leftTop3 sd_setImageWithURL:[NSURL URLWithString:weaself.picUrl3] placeholderImage:[UIImage imageNamed:@"icon1"]];
|
||
|
||
weaself.leftlabel3.text = nameArr[index];
|
||
|
||
NSUserDefaults *userDict = [NSUserDefaults standardUserDefaults];
|
||
|
||
NSString *indexWithImage = [NSString stringWithFormat:@"%ld",(long)index];
|
||
|
||
[userDict setObject:indexWithImage forKey:@"indexArrVlue3"];
|
||
|
||
[userDict synchronize];
|
||
|
||
//上传设置
|
||
[weaself loadData];
|
||
|
||
};
|
||
_showView3.backgroundColor = SECTHEADER_VIEWCOLOUR;
|
||
[_headView3 addSubview: _showView3];
|
||
|
||
NSUserDefaults *userSelectLast = [NSUserDefaults standardUserDefaults];
|
||
NSInteger lastIndex = [[userSelectLast objectForKey:@"indexArrVlue3"] integerValue];
|
||
if (lastIndex) {
|
||
_showView3.line.frame=CGRectMake( lastIndex * (kplace + imageHigh) + (kplace +imageHigh) - imageHigh ,imageHigh*3/2,imageHigh,3.0f);
|
||
}
|
||
|
||
|
||
[_showView3 show];
|
||
|
||
|
||
}
|
||
}
|
||
|
||
#pragma mark 点击确定按钮之后执行
|
||
|
||
-(void)loadData{
|
||
|
||
NSString*customeIconString=@"";
|
||
|
||
NSUserDefaults *userDict = [NSUserDefaults standardUserDefaults];
|
||
|
||
NSString*index1=[userDict valueForKey:@"indexArrVlue1"];
|
||
NSString*index2=[userDict valueForKey:@"indexArrVlue2"];
|
||
NSString*index3=[userDict valueForKey:@"indexArrVlue3"];
|
||
NSString*index4=[userDict valueForKey:@"indexArrVlue4"];
|
||
|
||
|
||
NSArray*imageArrindex=[[NSMutableArray alloc] init];
|
||
//NSArray*nameArr=[[NSMutableArray alloc] init];
|
||
|
||
|
||
//NSArray*alliconnames=[self.currenModel.allIconName componentsSeparatedByString:@","];
|
||
//图片
|
||
if (![self.currentdevice.customIconName isEqualToString:@""]) {
|
||
|
||
imageArrindex=[self.currentdevice.customIconName componentsSeparatedByString:@","];
|
||
|
||
}else{
|
||
imageArrindex=[self.currentdevice.defaultIconName componentsSeparatedByString:@","];
|
||
|
||
}
|
||
// 图片名
|
||
NSArray*allShowNameArr=[self.currentdevice.allShowName componentsSeparatedByString:@","];
|
||
|
||
if (index1==nil) {
|
||
|
||
index1= imageArrindex[0];
|
||
|
||
}
|
||
|
||
if (index2==nil) {
|
||
|
||
index2 = imageArrindex[1];
|
||
|
||
}
|
||
|
||
if (index3==nil) {
|
||
|
||
index3 = imageArrindex[2];
|
||
|
||
}
|
||
|
||
if (index4==nil) {
|
||
|
||
index4 = imageArrindex[3];
|
||
|
||
}
|
||
|
||
|
||
// 下标
|
||
customeIconString=[NSString stringWithFormat:@"%@,%@,%@,%@",index1,index2,index3,index4];
|
||
|
||
int firstsectionNameindex = [index1 intValue];
|
||
int secdsectionNameindex =[index2 intValue];
|
||
int threedNameindex =[index3 intValue];
|
||
int fourNameindex = [index4 intValue];
|
||
|
||
//名字
|
||
NSString*customshowNameString=[NSString stringWithFormat:@"%@,%@,%@,%@",allShowNameArr[firstsectionNameindex],allShowNameArr[secdsectionNameindex],allShowNameArr[threedNameindex],allShowNameArr[fourNameindex]];
|
||
|
||
|
||
UserModel*userModel=[[DataCenter defaultDtacenter]valueForKey:@"UserLogIn"];
|
||
|
||
[IFISHHTTPTOOL saveCustomIconwith:userModel.userId customIconName:customeIconString addDeviceId:self.currentdevice.deviceId addcustomShowName:customshowNameString];
|
||
|
||
NSLog(@"%@***%@",customshowNameString,customeIconString);
|
||
|
||
self.currentdevice.customIconName=customeIconString;
|
||
self.currentdevice.customShowName=customshowNameString;
|
||
|
||
}
|
||
|
||
#pragma mark 点击返回按钮通知主界面刷新
|
||
|
||
-(void)goBackAction{
|
||
|
||
[self.navigationController popViewControllerAnimated:YES];
|
||
[[NSNotificationCenter defaultCenter] postNotificationName:@"CHANGE_IMGE" object:self.currentdevice];
|
||
}
|
||
|
||
|
||
#pragma mark 切换模式
|
||
-(void)normalFourControlSwitchClick:(UIButton*)sender{
|
||
UIButton *switchButton = (UIButton*)sender;
|
||
|
||
|
||
if (switchButton.selected ==YES) {
|
||
NSLog(@"开");
|
||
// 切换自动模式
|
||
switchButton.selected=NO;
|
||
workTypeModel*zidongModel=[[workTypeModel alloc]init];
|
||
zidongModel.crc16String=@"0000";
|
||
zidongModel.workstyle=@"01";
|
||
NSString*ziDongString=[NSString stringWithFormat:@"%@%@%@",zidongModel.description,zidongModel.workstyle,zidongModel.crc16String];
|
||
NSData*zidongData=[dataContorl stringToHexData:ziDongString];
|
||
[self.clientSocket writeData:zidongData withTimeout:-1 tag:1];
|
||
[self.clientSocket readDataWithTimeout:-1 tag:1];
|
||
self.isAuto=YES;
|
||
[_indicatorView startAnimating];
|
||
// 自动模式下锁定 灯和水泵按钮
|
||
FourControlbackMassge *backmodel=[[DataCenter defaultDtacenter]valueForKey:@"FourControlMassgeInfo"];
|
||
backmodel.yunxingmoshi=@"01";
|
||
|
||
}else{
|
||
switchButton.selected=YES;
|
||
self.isAuto=NO;
|
||
// 切换 手动模式
|
||
workTypeModel*zidongModel=[[workTypeModel alloc]init];
|
||
zidongModel.workstyle=@"00";
|
||
zidongModel.crc16String=@"0000";
|
||
NSString*ziDongString=[NSString stringWithFormat:@"%@%@%@",zidongModel.description,zidongModel.workstyle,zidongModel.crc16String];
|
||
NSData*zidongData=[dataContorl stringToHexData:ziDongString];
|
||
[self.clientSocket writeData:zidongData withTimeout:-1 tag:1];
|
||
[self.clientSocket readDataWithTimeout:-1 tag:1];
|
||
|
||
FourControlbackMassge *backmodel=[[DataCenter defaultDtacenter]valueForKey:@"FourControlMassgeInfo"];
|
||
backmodel.yunxingmoshi=@"00";
|
||
[_indicatorView startAnimating];
|
||
NSLog(@"关");
|
||
}
|
||
|
||
}
|
||
|
||
#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(normalFourmypicviewRemoveByCancle) forControlEvents:UIControlEventTouchUpInside];
|
||
[_mypicView.sureButton addTarget:self action:@selector(normalFourmypicViewRemoveByDone) 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(normalFourremindCyclePicRemove) forControlEvents:UIControlEventTouchUpInside];
|
||
|
||
[_remindPic.sureBtn addTarget:self action:@selector(normalFourremindCyclePicDone) forControlEvents:UIControlEventTouchUpInside];
|
||
|
||
[self huanShuiMainQueue];
|
||
|
||
}else if (indexPath.section!=0){
|
||
if ([self.currentdevice.isWorkModel isEqualToString:@"1"]) {
|
||
FourControlbackMassge *backmodel=[[DataCenter defaultDtacenter]valueForKey:@"FourControlMassgeInfo"];
|
||
if ([backmodel.yunxingmoshi isEqualToString:@"01"]) {//zidong mo shi
|
||
|
||
_mydatepicView=[[MydatePickerView alloc]init];
|
||
|
||
_mydatepicView.frame=CGRectMake(0,0,kScreenSize.width,kScreenSize.height);
|
||
|
||
[_mydatepicView.cancleButton addTarget:self action:@selector(normalFourcancleButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||
[_mydatepicView.sureButton addTarget:self action:@selector(normalFourdoneButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||
FourControlbackMassge *backmodel=[[DataCenter defaultDtacenter]valueForKey:@"FourControlMassgeInfo"];
|
||
if (backmodel) {
|
||
[self useMainQueue];
|
||
}
|
||
|
||
|
||
// 设置pickerView 默认选择行
|
||
|
||
[self.view.window addSubview:_mydatepicView];
|
||
}else{
|
||
[self showTitle:@"" messsage:@"请开启定时模式"];
|
||
|
||
}
|
||
|
||
}else{
|
||
|
||
_mydatepicView=[[MydatePickerView alloc]init];
|
||
_mydatepicView.frame=CGRectMake(0, 0, kScreenSize.width,self.view.bounds.size.height);
|
||
|
||
[_mydatepicView.cancleButton addTarget:self action:@selector(normalFourcancleButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||
[_mydatepicView.sureButton addTarget:self action:@selector(normalFourdoneButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
||
[self useMainQueue];
|
||
// 设置pickerView 默认选择行
|
||
[self.view.window addSubview:_mydatepicView];
|
||
}
|
||
}
|
||
}
|
||
|
||
#pragma mark 移除换水时间选择器
|
||
|
||
-(void)normalFourremindCyclePicRemove{
|
||
|
||
|
||
[_remindPic removeFromSuperview];
|
||
|
||
// if (_indexpath.section==0&&_indexpath.row==3) {
|
||
// ChangeWaterCell*cell=[self.tableView cellForRowAtIndexPath:_indexpath];
|
||
// cell.huanshuiDaylabel.text=[NSString stringWithFormat:@"%@天",_currentdevice.remindCycle];
|
||
// [self.tableView reloadData];
|
||
//
|
||
// }
|
||
|
||
|
||
}
|
||
|
||
#pragma mark 换水时间设置
|
||
|
||
-(void)normalFourremindCyclePicDone{
|
||
|
||
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:@"normalSikongpicResult"];
|
||
|
||
[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)useMainQueue{
|
||
NSArray*statArr=[_mydatepicView.dataArr objectAtIndex:0];
|
||
NSArray*endArr=[_mydatepicView.dataArr objectAtIndex:1];
|
||
// 一区
|
||
dispatch_async(_mainQueue, ^{
|
||
NSLog(@"a");
|
||
for (NSInteger i=0; i<statArr.count; i++) {
|
||
NSString*timeString=_timeArr[_indexpath.section][_indexpath.row];
|
||
NSRange range=[timeString rangeOfString:@"~"];
|
||
NSString*start=[timeString substringToIndex:range.location];
|
||
//判断数据源数组小于十的情况
|
||
_mydatepicView.startString=start;
|
||
NSString*startpicString=statArr[i];
|
||
|
||
if ([startpicString isEqualToString:start ] ) {
|
||
|
||
[_mydatepicView.picView selectRow:i inComponent:0 animated:NO];
|
||
|
||
}
|
||
}
|
||
|
||
|
||
});
|
||
// 二区
|
||
dispatch_async(_mainQueue, ^{
|
||
NSLog(@"b");
|
||
for (NSInteger k=0; k<endArr.count; k++) {
|
||
NSString*timeString=_timeArr[_indexpath.section][_indexpath.row];
|
||
NSRange range=[timeString rangeOfString:@"~"];
|
||
NSString*end=[timeString substringFromIndex:range.location+1];
|
||
_mydatepicView.endString=end;
|
||
NSString*endString=endArr[k];
|
||
if ([endString isEqualToString:end ]) {
|
||
|
||
[_mydatepicView.picView selectRow:k inComponent:1 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.section][_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.section][_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)normalFourmypicviewRemoveByCancle{
|
||
[_mypicView removeFromSuperview];
|
||
|
||
}
|
||
//温度设置
|
||
#pragma mark 温度设置
|
||
|
||
-(void)normalFourmypicViewRemoveByDone{
|
||
|
||
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];
|
||
}
|
||
FourControlbackMassge *backmodel=[[DataCenter defaultDtacenter]valueForKey:@"FourControlMassgeInfo"];
|
||
// 低温
|
||
setWaringTpModel*warModel1=[[setWaringTpModel alloc]init];
|
||
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.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];
|
||
[self.clientSocket writeData:minwenDuData withTimeout:-1 tag:1];
|
||
[self.clientSocket readDataWithTimeout:-1 tag:1];
|
||
|
||
backmodel.maxTp=warModel2.maxwaterTp;
|
||
|
||
[_indicatorView startAnimating];
|
||
[_mypicView removeFromSuperview];
|
||
|
||
|
||
}else{
|
||
|
||
[self showTitle:@"提醒" messsage:@"请正确设置温度"];
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
#pragma mark 设置时间段
|
||
-(void)normalFourdoneButtonClick{
|
||
NSLog(@"点击了确定");
|
||
_mydatepicView.resultString=nil;
|
||
if (_mydatepicView.startString==nil|_mydatepicView.endString==nil) {
|
||
[self showTitle:@"" messsage:@"请选择时间"];
|
||
}else{
|
||
|
||
_mydatepicView.resultString=[NSString stringWithFormat:@"%@~%@",_mydatepicView.startString,_mydatepicView.endString];
|
||
|
||
UILabel*timeLabel=(UILabel*)[self.view viewWithTag:TIME_TAG+_indexpath.section*10+_indexpath.row];
|
||
//时小于十时
|
||
|
||
NSString*hexDateString1=[dataContorl dateStringToHexString:_mydatepicView.startString];
|
||
NSString*hexDateString2=[dataContorl dateStringToHexString:_mydatepicView.endString];
|
||
//
|
||
SetSelectorTime*selectorTimeModel=[[SetSelectorTime alloc]init];
|
||
FourControlbackMassge *backmessage=[[DataCenter defaultDtacenter]valueForKey:@"FourControlMassgeInfo"];
|
||
NSString*timerKaiGuanState=nil;
|
||
// NSString*backMasageTimeString=nil;
|
||
selectorTimeModel.crc16str=@"0000";
|
||
if (_indexpath.section==1&&_indexpath.row==0) {
|
||
selectorTimeModel.selectorNumber=@"01";
|
||
timerKaiGuanState=[backmessage.timer1 substringWithRange:NSMakeRange(2, 2)];
|
||
///backMasageTimeString=[backmessage.timer1 substringFromIndex:4];
|
||
|
||
|
||
}else if (_indexpath.section==1&&_indexpath.row==1){
|
||
selectorTimeModel.selectorNumber=@"02";
|
||
timerKaiGuanState=[backmessage.timer2 substringWithRange:NSMakeRange(2, 2)];
|
||
}else if (_indexpath.section==2&&_indexpath.row==0){
|
||
selectorTimeModel.selectorNumber=@"03";
|
||
timerKaiGuanState=[backmessage.timer3 substringWithRange:NSMakeRange(2, 2)];
|
||
}else if (_indexpath.section==2&&_indexpath.row==1){
|
||
selectorTimeModel.selectorNumber=@"04";
|
||
timerKaiGuanState=[backmessage.timer4 substringWithRange:NSMakeRange(2, 2)];
|
||
}else if (_indexpath.section==3&&_indexpath.row==0){
|
||
selectorTimeModel.selectorNumber=@"05";
|
||
timerKaiGuanState=[backmessage.timer5 substringWithRange:NSMakeRange(2, 2)];
|
||
}else if (_indexpath.section==3&&_indexpath.row==1){
|
||
selectorTimeModel.selectorNumber=@"06";
|
||
timerKaiGuanState=[backmessage.timer6 substringWithRange:NSMakeRange(2, 2)];
|
||
}else if (_indexpath.section==4&&_indexpath.row==0){
|
||
selectorTimeModel.selectorNumber=@"07";
|
||
timerKaiGuanState=[backmessage.timer7 substringWithRange:NSMakeRange(2, 2)];
|
||
}else if (_indexpath.section==4&&_indexpath.row==1){
|
||
selectorTimeModel.selectorNumber=@"08";
|
||
timerKaiGuanState=[backmessage.timer8 substringWithRange:NSMakeRange(2, 2)];
|
||
}
|
||
|
||
//if ([timerKaiGuanState isEqualToString:@"01"]) {
|
||
|
||
timeLabel.text=_mydatepicView.resultString;//
|
||
selectorTimeModel.selectorTime=[NSString stringWithFormat:@"%@%@",hexDateString1,hexDateString2];
|
||
NSString*selectorString=[NSString stringWithFormat:@"%@%@%@%@",selectorTimeModel.description,selectorTimeModel.selectorNumber,selectorTimeModel.selectorTime,selectorTimeModel.crc16str];
|
||
|
||
|
||
NSData*selctorData=[dataContorl stringToHexData:selectorString];
|
||
[self.clientSocket writeData:selctorData withTimeout:-1 tag:1];
|
||
[self.clientSocket readDataWithTimeout:-1 tag:1];
|
||
[_indicatorView startAnimating];
|
||
NSLog(@"hexString%@",hexDateString1);
|
||
NSLog(@"result%@",_mydatepicView.resultString);
|
||
|
||
|
||
|
||
[_mydatepicView removeFromSuperview];
|
||
|
||
|
||
}
|
||
|
||
}
|
||
-(void)normalFourcancleButtonClick{
|
||
NSLog(@"点击了取消");
|
||
|
||
[_mydatepicView removeFromSuperview];
|
||
}
|
||
|
||
|
||
|
||
#pragma mark 导航条 跳转时处理
|
||
-(void)viewWillAppear:(BOOL)animated{
|
||
self.navigationController.navigationBarHidden=NO;
|
||
UISwitch *switchButton=(UISwitch*)[self.view viewWithTag:1001];
|
||
FourControlbackMassge *backmodel=[[DataCenter defaultDtacenter]valueForKey:@"FourControlMassgeInfo"];
|
||
if ([backmodel.yunxingmoshi isEqualToString:@"01"]) {
|
||
[switchButton setOn:YES];
|
||
}else{
|
||
[switchButton setOn:NO];
|
||
}
|
||
if (_currentdevice) {
|
||
[IFISHHTTPTOOL getRemindWaterInfWith:_currentdevice.deviceId huishuiInfo:^(setRemindWaterModel *remindModel) {
|
||
|
||
self.waterInfmodel=remindModel;
|
||
|
||
NSUserDefaults*defuat=[NSUserDefaults standardUserDefaults];
|
||
|
||
[defuat setInteger:self.waterInfmodel.remindcycle forKey:@"normalSikongpicResult"];
|
||
[defuat synchronize];
|
||
self.nextChangeDateLabel=self.waterInfmodel.remindDate;
|
||
|
||
[self.tableView reloadData];
|
||
}];
|
||
}
|
||
|
||
}
|
||
|
||
-(void)viewWillDisappear:(BOOL)animated{
|
||
self.navigationController.navigationBarHidden=YES;
|
||
[_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 设置定时器时间
|
||
//-(void)setDingShiQiTime{
|
||
// SetSelectorTime*selectorTime=[[SetSelectorTime alloc]init];
|
||
// selectorTime.selectorTime=@"";// picview
|
||
//}
|
||
|
||
-(void)wenduRequest{
|
||
searchDeviceModel*xinxiModel=[[searchDeviceModel alloc]init];
|
||
NSString*requestStr=xinxiModel.description;
|
||
NSData*data1=[dataContorl stringToHexData:requestStr];
|
||
[self.clientSocket writeData:data1 withTimeout:-1 tag:1];
|
||
[self.clientSocket readDataWithTimeout:-1 tag:1];
|
||
}
|
||
-(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=IndicatorBack_COLOR;
|
||
_indicatorView.layer.masksToBounds=YES;
|
||
_indicatorView.layer.cornerRadius=5;
|
||
AppDelegate*delegate=[[UIApplication sharedApplication]delegate];
|
||
[delegate.window addSubview:_indicatorView];
|
||
|
||
//[self.view addSubview:_indicatorView];
|
||
|
||
//[self.tableView bringSubviewToFront:_indicatorView];
|
||
}
|
||
|
||
@end
|