ifish/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/FourControl/FourControlSetViewController.m

1446 lines
55 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// FourControlSetViewController.m
// Ifish
//
// Created by imac on 16/5/24.
// Copyright © 2016年 imac. All rights reserved.
//
#import "FourControlSetViewController.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 "BackmassegeModel.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 "CreatErWeiMaController.h"
@interface FourControlSetViewController ()
{
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) NSInteger tian;
@end
@implementation FourControlSetViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
_waterInfmodel=[[setRemindWaterModel alloc]init];
[super viewDidLoad];
_mainQueue = dispatch_get_main_queue();
self.navigationController.navigationBar.backItem.title=@"";
[self addTitleViewWithTitle:@"设置"];
[self initData];
[self creatIndicatorView];
self.tableView.backgroundColor=COLOR_MIAN;
// if ([self.currentdevice.isMaster isEqualToString:@"1"]) {
// 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"];
}
-(void)fourItemClick{
CreatErWeiMaController*vc=[[CreatErWeiMaController alloc]init]
;
vc.erdevicemodel=self.currentdevice;
[self.navigationController pushViewController:vc animated:YES];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
-(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];
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",@""]];
}
}
#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;
}
if (indexPath.section!=0 && !(indexPath.section==4&&indexPath.row==2)) {
[cell SetEightTimerSwitchAtIndex:indexPath WithBacmodel:backmodel];
}
[cell.mySwitchButton addTarget:self action:@selector(normalFourbtnCliCk:) 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];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
return cell;
}
}
}
-(void)normalFourbtnCliCk:(UIButton*)btn{
TimerSateModel*stateModel=[[TimerSateModel alloc]init];
stateModel.resavemacId = self.currentdevice.macAddress;
stateModel.sendmacId = self.currentdevice.macAddress;
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)];
stateModel.timerNumber=@"01";
// stateModel.timerState=[backmodel.timer1 substringWithRange:NSMakeRange(2, 2)];
}else if (btn.tag==3011){
backState=[backmodel.timer2 substringWithRange:NSMakeRange(2, 2)];
stateModel.timerNumber=@"02";
// stateModel.timerState=[backmodel.timer2 substringWithRange:NSMakeRange(2, 2)];
}else if (btn.tag==3020){
backState=[backmodel.timer3 substringWithRange:NSMakeRange(2, 2)];
stateModel.timerNumber=@"03";
// stateModel.timerState=[backmodel.timer3 substringWithRange:NSMakeRange(2, 2)];
}else if (btn.tag==3021){
backState=[backmodel.timer4 substringWithRange:NSMakeRange(2, 2)];
stateModel.timerNumber=@"04";
// stateModel.timerState=[backmodel.timer4 substringWithRange:NSMakeRange(2, 2)];
}else if (btn.tag==3030){
backState=[backmodel.timer5 substringWithRange:NSMakeRange(2, 2)];
stateModel.timerNumber=@"05";
//stateModel.timerState=[backmodel.timer5 substringWithRange:NSMakeRange(2, 2)];
}else if (btn.tag==3031){
backState=[backmodel.timer6 substringWithRange:NSMakeRange(2, 2)];
stateModel.timerNumber=@"06";
}else if (btn.tag==3040){
backState=[backmodel.timer7 substringWithRange:NSMakeRange(2, 2)];
stateModel.timerNumber=@"07";
}else if (btn.tag==3041){
backState=[backmodel.timer8 substringWithRange:NSMakeRange(2, 2)];
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];
[[Socketsingleton sharedInstance] soketWriteData:selctorData];
[_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];
[[Socketsingleton sharedInstance] soketWriteData:selctorData];
[_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];
warModel1.sendmacId = self.currentdevice.macAddress;
warModel1.resavemacId = self.currentdevice.macAddress;
//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];
[[Socketsingleton sharedInstance] soketWriteData:minwenDuData];
[_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.sendmacId = self.currentdevice.macAddress;
guidengModel.resavemacId =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];
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];
[[Socketsingleton sharedInstance] soketWriteData:guidengData];
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.sendmacId = self.currentdevice.macAddress;
brightModel.resavemacId = 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)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];
}
}
}
//-(void)returnBool:(ReturnBoolBlock)block{
// self.returnboolBlock=block;
//
//}
#pragma mark tableView 头视图和脚视图
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if (section == 1) {
return 50;
}else if (section ==0){
return 5;
}else {
return 0;
}
}
-(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{
//view.alpha=0;
}
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
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;
}
}
#pragma mark 切换模式
-(void)normalFourControlSwitchClick:(UIButton*)sender{
UIButton *switchButton = (UIButton*)sender;
if (switchButton.selected ==YES) {
NSLog(@"");
// 切换自动模式
switchButton.selected=NO;
workTypeModel*zidongModel=[[workTypeModel alloc]init];
zidongModel.sendmacId = self.currentdevice.macAddress;
zidongModel.resavemacId = self.currentdevice.macAddress;
zidongModel.crc16String=@"0000";
zidongModel.workstyle=@"01";
NSString*ziDongString=[NSString stringWithFormat:@"%@%@%@",zidongModel.description,zidongModel.workstyle,zidongModel.crc16String];
NSData*zidongData=[dataContorl stringToHexData:ziDongString];
[[Socketsingleton sharedInstance] soketWriteData:zidongData];
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];
[[Socketsingleton sharedInstance] soketWriteData:zidongData];
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.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.sendmacId = self.currentdevice.macAddress;
warModel2.resavemacId = 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)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];
selectorTimeModel.resavemacId =self.currentdevice.macAddress;
selectorTimeModel.sendmacId = self.currentdevice.macAddress;
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];
[[Socketsingleton sharedInstance] soketWriteData:selctorData];
[_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{
[_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];
});
}
-(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