1164 lines
45 KiB
Objective-C
1164 lines
45 KiB
Objective-C
//
|
|
// RuiMeiSetViewController.m
|
|
// Ifish
|
|
//
|
|
// Created by Minghao Xue on 2018/4/22.
|
|
// Copyright © 2018年 lianlian. All rights reserved.
|
|
//
|
|
|
|
#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 "MydatePickerView.h"
|
|
#define SET_CELL_TAG 2000
|
|
#define MYSWITCH_TAG 30000
|
|
#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 "RuiMeiProtocolModel.h"
|
|
#import "RuiMeiBackMsgUtils.h"
|
|
#import "RuSunGuiDeng.h"
|
|
#import "RuiMeiSetViewController.h"
|
|
#import "CustomModeSetCell.h"
|
|
#import "RuSunLightOrder.h"
|
|
|
|
@interface RuiMeiSetViewController ()
|
|
{
|
|
|
|
MydatePickerView*_mydatepicView;
|
|
MyPickerView* _mypicView;
|
|
remindCyclePic*_remindPic;
|
|
dispatch_queue_t _mainQueue;
|
|
}
|
|
|
|
@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 RuiMeiSetViewController
|
|
|
|
- (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;
|
|
self.tableView.separatorStyle=UITableViewCellSeparatorStyleNone;
|
|
}
|
|
|
|
-(void)creatIndicatorView{
|
|
|
|
_indicatorView=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
|
|
|
|
|
|
_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=(AppDelegate*)[[UIApplication sharedApplication]delegate];
|
|
[delegate.window addSubview:_indicatorView];
|
|
|
|
}
|
|
|
|
|
|
-(void)initData{
|
|
|
|
self.titleArr=@[@[@"预警设置",@"换水提醒",@"自定义模式开关"],@[@"时段一",@"时段二"],@[@"时段一",@"时段二"],@[@"时段一",@"时段二"],@[@"时段一",@"时段二"]];
|
|
|
|
|
|
RuiMeiProtocolModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:DataCenterRuiMeiModelKey];
|
|
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];
|
|
//共八定时器 一个灯两个定时器
|
|
//CH1 timer1 timer2
|
|
// 十六进制
|
|
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];
|
|
|
|
//CH2 timer3 timer4
|
|
// 十六进制
|
|
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];
|
|
|
|
//CH3 timer5 timer6
|
|
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];
|
|
//CH4 timer7 timer8
|
|
|
|
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];
|
|
|
|
self.timeArr=@[@[wenduString,@"设置时段"],@[setTim1,setTim2],@[setTim3,setTim4],@[setTim5,setTim6],@[setTim7,setTim8,@""]];
|
|
|
|
}else{
|
|
|
|
[self.view makeToast:@"设备已离线"];
|
|
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 3;
|
|
|
|
}else if (section == 4){
|
|
|
|
return 3;
|
|
|
|
}else{
|
|
return 2;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
RuiMeiProtocolModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:DataCenterRuiMeiModelKey];
|
|
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(ruSunTempSwitchAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
if (backmodel) {
|
|
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;
|
|
}
|
|
|
|
}else{
|
|
|
|
}
|
|
|
|
return cell;
|
|
|
|
}else if (indexPath.section==0&&indexPath.row==1){
|
|
// 换水提醒
|
|
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(ruSunChangeWaterSwitch:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
if ([self.waterInfmodel.waterremind isEqualToString:@"1"]) {
|
|
[cell.ChangeWaterSwitch setBackgroundImage:[UIImage imageNamed:@"greenbtn_big"] forState:UIControlStateNormal];
|
|
cell.ChangeWaterSwitch.selected = NO;
|
|
|
|
|
|
|
|
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"set_cellBack"]];
|
|
}else{
|
|
[cell.ChangeWaterSwitch setBackgroundImage:[UIImage imageNamed:@"graybtn_big"] forState:UIControlStateNormal];
|
|
cell.ChangeWaterSwitch.selected = YES;
|
|
|
|
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==2){
|
|
static NSString*customModeSetCellId=@"customModeSetCell";
|
|
CustomModeSetCell*cell=[tableView dequeueReusableCellWithIdentifier:customModeSetCellId];
|
|
if (cell==nil) {
|
|
cell=[[[NSBundle mainBundle]loadNibNamed:@"CustomModeSetCell" owner:self options:nil]lastObject];
|
|
}
|
|
cell.switchControl.selected = self.customModeOn;
|
|
[cell.switchControl addTarget:self action:@selector(customModeSwitchBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
|
|
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];
|
|
}
|
|
|
|
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;
|
|
|
|
|
|
if (indexPath.section!=0 && !(indexPath.section==4&&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)) {
|
|
|
|
|
|
if (indexPath.section==1&&indexPath.row==0) {//开关一
|
|
NSString*state=[backmodel.timer1 substringWithRange:NSMakeRange(2, 2)];
|
|
|
|
if ([state isEqualToString:@"00"]) {
|
|
|
|
[cell.mySwitchButton setImage:[UIImage imageNamed:@"Switch-Off"] forState:UIControlStateNormal];
|
|
|
|
|
|
}else{
|
|
|
|
[cell.mySwitchButton setImage:[UIImage imageNamed:@"Switch-On"] forState:UIControlStateNormal];
|
|
}
|
|
}
|
|
|
|
if (indexPath.section==1&&indexPath.row==1) {//开关2
|
|
NSString*state=[backmodel.timer2 substringWithRange:NSMakeRange(2, 2)];
|
|
if ([state isEqualToString:@"00"]) {
|
|
|
|
[cell.mySwitchButton setImage:[UIImage imageNamed:@"Switch-Off"] forState:UIControlStateNormal];
|
|
|
|
}else{
|
|
|
|
[cell.mySwitchButton setImage:[UIImage imageNamed:@"Switch-On"] forState:UIControlStateNormal];
|
|
}
|
|
}
|
|
if (indexPath.section==2&&indexPath.row==0) {//开关3
|
|
NSString*state=[backmodel.timer3 substringWithRange:NSMakeRange(2, 2)];
|
|
if ([state isEqualToString:@"00"]) {
|
|
|
|
[cell.mySwitchButton setImage:[UIImage imageNamed:@"Switch-Off"] forState:UIControlStateNormal];
|
|
|
|
}else{
|
|
|
|
[cell.mySwitchButton setImage:[UIImage imageNamed:@"Switch-On"] forState:UIControlStateNormal];
|
|
}
|
|
}
|
|
|
|
if (indexPath.section==2&&indexPath.row==1) {//开关4
|
|
NSString*state=[backmodel.timer4 substringWithRange:NSMakeRange(2, 2)];
|
|
|
|
if ([state isEqualToString:@"00"]) {
|
|
|
|
[cell.mySwitchButton setImage:[UIImage imageNamed:@"Switch-Off"] forState:UIControlStateNormal];
|
|
|
|
}else{
|
|
|
|
[cell.mySwitchButton setImage:[UIImage imageNamed:@"Switch-On"] forState:UIControlStateNormal];
|
|
}
|
|
}
|
|
|
|
if (indexPath.section==3&&indexPath.row==0) {//开关5
|
|
NSString*state=[backmodel.timer5 substringWithRange:NSMakeRange(2, 2)];
|
|
NSLog(@"state5****%@",state);
|
|
if ([state isEqualToString:@"00"]) {
|
|
|
|
[cell.mySwitchButton setImage:[UIImage imageNamed:@"Switch-Off"] forState:UIControlStateNormal];
|
|
|
|
}else{
|
|
|
|
|
|
[cell.mySwitchButton setImage:[UIImage imageNamed:@"Switch-On"] forState:UIControlStateNormal];
|
|
}
|
|
}
|
|
|
|
if (indexPath.section==3&&indexPath.row==1) {//开关6
|
|
NSString*state=[backmodel.timer6 substringWithRange:NSMakeRange(2, 2)];
|
|
NSLog(@"state6****%@",state);
|
|
if ([state isEqualToString:@"00"]) {
|
|
|
|
[cell.mySwitchButton setImage:[UIImage imageNamed:@"Switch-Off"] forState:UIControlStateNormal];
|
|
|
|
|
|
}else{
|
|
|
|
[cell.mySwitchButton setImage:[UIImage imageNamed:@"Switch-On"] forState:UIControlStateNormal];
|
|
|
|
}
|
|
}
|
|
|
|
if (indexPath.section==4&&indexPath.row==0) {//开关7
|
|
NSString*state=[backmodel.timer7 substringWithRange:NSMakeRange(2, 2)];
|
|
NSLog(@"state7****%@",state);
|
|
if ([state isEqualToString:@"00"]) {
|
|
|
|
[cell.mySwitchButton setImage:[UIImage imageNamed:@"Switch-Off"] forState:UIControlStateNormal];
|
|
|
|
}else{
|
|
|
|
[cell.mySwitchButton setImage:[UIImage imageNamed:@"Switch-On"] forState:UIControlStateNormal];
|
|
}
|
|
}
|
|
|
|
if (indexPath.section==4&&indexPath.row==1) {//开关8
|
|
|
|
NSString*state=[backmodel.timer8 substringWithRange:NSMakeRange(2, 2)];
|
|
NSLog(@"state8****%@",state);
|
|
if ([state isEqualToString:@"00"]) {
|
|
|
|
[cell.mySwitchButton setImage:[UIImage imageNamed:@"Switch-Off"] forState:UIControlStateNormal];
|
|
|
|
}else{
|
|
|
|
[cell.mySwitchButton setImage:[UIImage imageNamed:@"Switch-On"] forState:UIControlStateNormal];
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
[cell setRuSunControl84biteAtIndex:indexPath currenmac:self.currentdevice.macAddress];
|
|
//cell 选中效果
|
|
[cell.mySwitchButton addTarget:self action:@selector(btnCliCk:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
return cell;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
-(void)btnCliCk:(UIButton*)btn{
|
|
|
|
if (!self.customModeOn) {
|
|
return;
|
|
}
|
|
|
|
TimerSateModel*stateModel=[[TimerSateModel alloc]init];
|
|
stateModel.sendmacId = self.currentdevice.macAddress;
|
|
stateModel.resavemacId =self.currentdevice.macAddress;
|
|
|
|
|
|
stateModel.crc16String=@"0000";
|
|
RuiMeiProtocolModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:DataCenterRuiMeiModelKey];
|
|
|
|
NSString*backState=nil;
|
|
|
|
if (btn.tag==30010) {
|
|
backState=[backmodel.timer1 substringWithRange:NSMakeRange(2, 2)];
|
|
|
|
stateModel.timerNumber=@"01";
|
|
|
|
}else if (btn.tag==30011){
|
|
backState=[backmodel.timer2 substringWithRange:NSMakeRange(2, 2)];
|
|
|
|
stateModel.timerNumber=@"02";
|
|
// stateModel.timerState=[backmodel.timer2 substringWithRange:NSMakeRange(2, 2)];
|
|
|
|
}else if (btn.tag==30020){
|
|
|
|
backState=[backmodel.timer3 substringWithRange:NSMakeRange(2, 2)];
|
|
|
|
stateModel.timerNumber=@"03";
|
|
// stateModel.timerState=[backmodel.timer3 substringWithRange:NSMakeRange(2, 2)];
|
|
}else if (btn.tag==30021){
|
|
backState=[backmodel.timer4 substringWithRange:NSMakeRange(2, 2)];
|
|
|
|
stateModel.timerNumber=@"04";
|
|
// stateModel.timerState=[backmodel.timer4 substringWithRange:NSMakeRange(2, 2)];
|
|
|
|
}else if (btn.tag==30030){
|
|
backState=[backmodel.timer5 substringWithRange:NSMakeRange(2, 2)];
|
|
|
|
stateModel.timerNumber=@"05";
|
|
//stateModel.timerState=[backmodel.timer5 substringWithRange:NSMakeRange(2, 2)];
|
|
|
|
|
|
}else if (btn.tag==30031){
|
|
backState=[backmodel.timer6 substringWithRange:NSMakeRange(2, 2)];
|
|
|
|
stateModel.timerNumber=@"06";
|
|
|
|
}else if (btn.tag==30040){
|
|
|
|
backState=[backmodel.timer7 substringWithRange:NSMakeRange(2, 2)];
|
|
|
|
stateModel.timerNumber=@"07";
|
|
}else if (btn.tag==30041){
|
|
|
|
backState=[backmodel.timer8 substringWithRange:NSMakeRange(2, 2)];
|
|
|
|
stateModel.timerNumber=@"08";
|
|
}
|
|
|
|
if ([backState isEqualToString:@"01"]) {
|
|
//发关闭指令
|
|
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)ruSunTempSwitchAction:(UIButton*)temperatureSwitch{
|
|
|
|
RuiMeiProtocolModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:DataCenterRuiMeiModelKey];
|
|
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:(RuiMeiProtocolModel *)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)ruSunChangeWaterSwitch:(UIButton*)sender{
|
|
|
|
UIButton*huanShuiSwitch=(UIButton*)sender;
|
|
|
|
//BOOL isButtonOn=[huanShuiSwitch isOn];
|
|
|
|
NSUserDefaults*defuat=[NSUserDefaults standardUserDefaults];
|
|
NSString*picResult=[defuat valueForKey:@"RuiMei2aPicResult"];
|
|
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 - 自定义模式开关设置
|
|
-(void)customModeSwitchBtnClicked:(UIButton*)sender{
|
|
//此款设备无运行模式
|
|
RuSunLightOrder*lightOrder=[[RuSunLightOrder alloc]init];
|
|
lightOrder.sendmacId = self.currentdevice.macAddress;
|
|
lightOrder.resavemacId = self.currentdevice.macAddress;
|
|
NSString*switchString1=lightOrder.description;
|
|
|
|
NSString *lightSate;
|
|
if (sender.selected == YES) {
|
|
sender.selected = NO;
|
|
lightSate=@"00";
|
|
}else{
|
|
sender.selected =YES;
|
|
lightSate=@"01";// 关
|
|
}
|
|
lightOrder.switchBtn = lightSate;
|
|
lightOrder.crc16Str=@"0000";
|
|
lightOrder.lightNumber=@"05";
|
|
NSString*switchString2=[NSString stringWithFormat:@"%@%@%@%@",switchString1,lightOrder.lightNumber,lightOrder.switchBtn,lightOrder.crc16Str];
|
|
NSData*manulData=[dataContorl stringToHexData:switchString2];
|
|
[ [Socketsingleton sharedInstance] soketWriteData:manulData];
|
|
[_indicatorView startAnimating];
|
|
}
|
|
|
|
#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==2) {
|
|
return 50;
|
|
|
|
}else if (indexPath.section==0&&indexPath.row==1){
|
|
|
|
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;
|
|
}
|
|
|
|
}
|
|
|
|
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
|
if (section==1) {
|
|
UIImageView*secondSectionHeader=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"firstSetCell"]];
|
|
UILabel *label=[[UILabel alloc] init];
|
|
label.text=@"定时模式";
|
|
label.font = [UIFont systemFontOfSize:15];
|
|
label.frame=CGRectMake(18, 5, 100, 40);
|
|
[secondSectionHeader addSubview:label];
|
|
|
|
return secondSectionHeader;
|
|
|
|
|
|
}else if (section == 0){
|
|
UIView*oneHeader=[[UIView alloc] init];
|
|
oneHeader.backgroundColor=COLOR_MIAN;
|
|
return oneHeader;
|
|
|
|
}else{
|
|
return nil;
|
|
}
|
|
|
|
}
|
|
#pragma mark tableView 点击事件
|
|
|
|
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
_indexpath=indexPath;
|
|
if (indexPath.row==0&&indexPath.section==0) {
|
|
|
|
_mypicView=[[MyPickerView alloc]init];
|
|
|
|
_mypicView.frame=CGRectMake(0, 0, kScreenSize.width, kScreenSize.height);
|
|
[self.view.window addSubview:_mypicView];
|
|
[_mypicView.cancleButton addTarget:self action:@selector(mypicviewRemoveByCancle) forControlEvents:UIControlEventTouchUpInside];
|
|
[_mypicView.sureButton addTarget:self action:@selector(mypicViewRemoveByDone) forControlEvents:UIControlEventTouchUpInside];
|
|
[self temperatureMainQueue];
|
|
|
|
}else if (indexPath.section==0&&indexPath.row==1){
|
|
//换水提醒日期选择
|
|
_remindPic=[[remindCyclePic alloc]init];
|
|
|
|
_remindPic.frame=CGRectMake(0, 0, kScreenSize.width, kScreenSize.height);
|
|
[self.view.window addSubview:_remindPic];
|
|
[_remindPic.cancleBtn addTarget:self action:@selector(xuToremindCyclePicRemove) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
[_remindPic.sureBtn addTarget:self action:@selector(xuToremindCyclePicDone) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
[self huanShuiMainQueue];
|
|
|
|
}else if (indexPath.section!=0){
|
|
|
|
if (!self.customModeOn) {
|
|
return;
|
|
}
|
|
|
|
_mydatepicView=[[MydatePickerView alloc]init];
|
|
|
|
_mydatepicView.frame=CGRectMake(0,0,kScreenSize.width,kScreenSize.height);
|
|
|
|
[_mydatepicView.cancleButton addTarget:self action:@selector(cancleButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
|
[_mydatepicView.sureButton addTarget:self action:@selector(doneButtonClick) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
RuiMeiProtocolModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:DataCenterRuiMeiModelKey];
|
|
if (backmodel) {
|
|
//在线
|
|
[self useMainQueue];
|
|
}
|
|
|
|
|
|
|
|
// 设置pickerView 默认选择行
|
|
|
|
[self.view.window addSubview:_mydatepicView];
|
|
|
|
|
|
}
|
|
}
|
|
|
|
#pragma mark 移除换水时间选择器
|
|
|
|
-(void)xuToremindCyclePicRemove{
|
|
|
|
[_remindPic removeFromSuperview];
|
|
|
|
}
|
|
|
|
#pragma mark 换水时间设置
|
|
|
|
-(void)xuToremindCyclePicDone{
|
|
|
|
if (_indexpath.section==0&&_indexpath.row==1) {
|
|
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:@"RuiMei2aPicResult"];
|
|
|
|
[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)mypicviewRemoveByCancle{
|
|
[_mypicView removeFromSuperview];
|
|
|
|
}
|
|
|
|
//温度设置
|
|
#pragma mark 温度设置
|
|
|
|
-(void)mypicViewRemoveByDone{
|
|
|
|
if (_mypicView.picViewResultString==nil) {
|
|
[_mypicView removeFromSuperview];
|
|
|
|
}else{
|
|
if (_indexpath.section==0&&_indexpath.row==0) {
|
|
|
|
TemperatureSetCell*cell=[self.tableView cellForRowAtIndexPath:_indexpath];
|
|
cell.temperaturelabel.text=[NSString stringWithFormat:@"%@°C",_mypicView.picViewResultString];
|
|
}
|
|
|
|
RuiMeiProtocolModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:DataCenterRuiMeiModelKey];
|
|
// 低温
|
|
setWaringTpModel*warModel1=[[setWaringTpModel alloc]init];
|
|
warModel1.resavemacId =self.currentdevice.macAddress;
|
|
warModel1.sendmacId =self.currentdevice.macAddress;
|
|
warModel1.crc16Ing=@"0000";
|
|
warModel1.kaiguan=@"02";//设置
|
|
NSString*maxminTpString=warModel1.description;
|
|
|
|
NSRange range=[_mypicView.picViewResultString rangeOfString:@"~"];
|
|
NSString*lowString=[_mypicView.picViewResultString substringToIndex:range.location];
|
|
|
|
int intlowString = [lowString intValue];
|
|
int newIntlowString=intlowString*10;
|
|
warModel1.miniwaterTp=[dataContorl tpIntStringToFourHex:newIntlowString]; // 转四位16进制
|
|
//写入数据
|
|
backmodel.miniTp=warModel1.miniwaterTp;
|
|
|
|
// 高温
|
|
setWaringTpModel*warModel2=[[setWaringTpModel alloc]init];
|
|
warModel2.resavemacId =self.currentdevice.macAddress;
|
|
warModel2.sendmacId = self.currentdevice.macAddress;
|
|
|
|
warModel2.crc16Ing=@"0000";
|
|
warModel2.kaiguan=@"02";//设置
|
|
NSString*heighString=[_mypicView.picViewResultString substringFromIndex:range.location+1];
|
|
int intString = [heighString intValue];
|
|
int newIntString=intString*10;
|
|
|
|
warModel2.maxwaterTp=[dataContorl tpIntStringToFourHex:newIntString];
|
|
|
|
if ([lowString intValue]<[heighString intValue]) {
|
|
|
|
|
|
NSString*minString=[NSString stringWithFormat:@"%@%@%@%@%@",maxminTpString,warModel1.kaiguan,warModel1.miniwaterTp,warModel2.maxwaterTp,warModel1.crc16Ing];
|
|
NSData*minwenDuData=[dataContorl stringToHexData:minString];
|
|
[[Socketsingleton sharedInstance] soketWriteData:minwenDuData];
|
|
backmodel.miniTp=warModel1.miniwaterTp;
|
|
backmodel.maxTp=warModel2.maxwaterTp;
|
|
[_indicatorView startAnimating];
|
|
[_mypicView removeFromSuperview];
|
|
|
|
|
|
}else{
|
|
|
|
[self showTitle:@"提醒" messsage:@"请正确设置温度"];
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
#pragma mark 设置时间段
|
|
-(void)doneButtonClick{
|
|
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.sendmacId =self.currentdevice.macAddress;
|
|
selectorTimeModel.resavemacId = self.currentdevice.macAddress;
|
|
|
|
RuiMeiProtocolModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:DataCenterRuiMeiModelKey];
|
|
|
|
NSString*timerKaiGuanState=nil;
|
|
// NSString*backMasageTimeString=nil;
|
|
selectorTimeModel.crc16str=@"0000";
|
|
if (_indexpath.section==1&&_indexpath.row==0) {
|
|
selectorTimeModel.selectorNumber=@"01";
|
|
timerKaiGuanState=[backmodel.timer1 substringWithRange:NSMakeRange(2, 2)];
|
|
///backMasageTimeString=[backmessage.timer1 substringFromIndex:4];
|
|
|
|
}else if (_indexpath.section==1&&_indexpath.row==1){
|
|
selectorTimeModel.selectorNumber=@"02";
|
|
timerKaiGuanState=[backmodel.timer2 substringWithRange:NSMakeRange(2, 2)];
|
|
}else if (_indexpath.section==2&&_indexpath.row==0){
|
|
selectorTimeModel.selectorNumber=@"03";
|
|
timerKaiGuanState=[backmodel.timer3 substringWithRange:NSMakeRange(2, 2)];
|
|
}else if (_indexpath.section==2&&_indexpath.row==1){
|
|
selectorTimeModel.selectorNumber=@"04";
|
|
timerKaiGuanState=[backmodel.timer4 substringWithRange:NSMakeRange(2, 2)];
|
|
}else if (_indexpath.section==3&&_indexpath.row==0){
|
|
selectorTimeModel.selectorNumber=@"05";
|
|
timerKaiGuanState=[backmodel.timer5 substringWithRange:NSMakeRange(2, 2)];
|
|
}else if (_indexpath.section==3&&_indexpath.row==1){
|
|
selectorTimeModel.selectorNumber=@"06";
|
|
timerKaiGuanState=[backmodel.timer6 substringWithRange:NSMakeRange(2, 2)];
|
|
}else if (_indexpath.section==4&&_indexpath.row==0){
|
|
selectorTimeModel.selectorNumber=@"07";
|
|
timerKaiGuanState=[backmodel.timer7 substringWithRange:NSMakeRange(2, 2)];
|
|
}else if (_indexpath.section==4&&_indexpath.row==1){
|
|
selectorTimeModel.selectorNumber=@"08";
|
|
timerKaiGuanState=[backmodel.timer8 substringWithRange:NSMakeRange(2, 2)];
|
|
}
|
|
|
|
|
|
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)cancleButtonClick{
|
|
NSLog(@"点击了取消");
|
|
|
|
[_mydatepicView removeFromSuperview];
|
|
}
|
|
|
|
|
|
#pragma mark 导航条 跳转时处理
|
|
-(void)viewWillAppear:(BOOL)animated{
|
|
[super viewWillAppear:animated];
|
|
self.navigationController.navigationBarHidden=NO;
|
|
|
|
if (_currentdevice) {
|
|
[IFISHHTTPTOOL getRemindWaterInfWith:_currentdevice.deviceId huishuiInfo:^(setRemindWaterModel *remindModel) {
|
|
|
|
self.waterInfmodel=remindModel;
|
|
|
|
NSUserDefaults*defuat=[NSUserDefaults standardUserDefaults];
|
|
|
|
[defuat setInteger:self.waterInfmodel.remindcycle forKey:@"RuiMei2aPicResult"];
|
|
[defuat synchronize];
|
|
self.nextChangeDateLabel=self.waterInfmodel.remindDate;
|
|
|
|
[self.tableView reloadData];
|
|
}];
|
|
}
|
|
|
|
}
|
|
|
|
-(void)viewWillDisappear:(BOOL)animated{
|
|
[super viewWillDisappear:animated];
|
|
[_indicatorView stopAnimating];
|
|
|
|
}
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
[super didReceiveMemoryWarning];
|
|
// Dispose of any resources that can be recreated.
|
|
}
|
|
|
|
@end
|