ifish/Ifish/controllers/FishTinkController/maincontroller/CenterontrolControllers/XuTo/XuanduoElectricityController.m

1340 lines
52 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.

//
// Xuanduo2SettingController.m
// Ifish
//
// Created by Alex on 2019/4/28.
// Copyright © 2019 lianlian. All rights reserved.
//
#import "XuanduoElectricityController.h"
#import "UINavigationBar+Background.h"
#import "TemperatureSetCell.h"
#import "ChangeWaterCell.h"
#import "Xuanduo2Model.h"
#import "TemperatureSetModel.h"
#import "setWaringTpModel.h"
#import "remindCyclePic.h"
#import "MyPickerView.h"
#import "PlusTableViewCell.h"
#import "SetTimerCell.h"
#import "XuanduoSectionHeaderView.h"
#import "XuanduoSelectHeader.h"
#import "MydatePickerView.h"
#import "SetTimerModel.h"
#import "ReadTimerModel.h"
#import "Xuanduo2DataUtility.h"
#import "Xuanduo2TimerModel.h"
#import "IfishDeviceInfo.h"
#import "NSString+Add.h"
#import "XuToControlName.h"
#import "UserExtendataArchaver.h"
#import "TimerTypeTableViewCell.h"
#import "ElectricityCell.h"
#import "ElectricityView.h"
#define kBtnTag 500
#define kSwitchBtnTag 600
static NSString *ElectricityCellid = @"ElectricityCell";
static NSString *changeWaterCellid = @"ChangeWaterCell";
static NSString *addCellid = @"PlusTableViewCell";
static NSString *plusflag = @"plusCell";
static NSString *setTimerflag = @"SetTimerCell";
static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
@interface XuanduoElectricityController ()<IfishCommuniteDelegate,TimerTypeTableViewCellDelegate>
@property(nonatomic,strong) setRemindWaterModel *waterInfmodel;
@property(nonatomic,strong) Xuanduo2TimerModel *timerModel;
@property(nonatomic,strong) XuanduoCycleModel *cycleModel;
@property (nonatomic,strong) NSMutableDictionary *timeDic;
@property(nonatomic,copy) NSString *nextChangeDateLabel;
@property(nonatomic,strong) MyHud *XuTohud;
@property(nonatomic,strong)UITableView*tableView;
@property(nonatomic,strong)ElectricityView*headerView;
@property(nonatomic,strong)NSDictionary*dataDict;
@property(nonatomic,strong)NSArray*sortedArray;
@end
@implementation XuanduoElectricityController
{
NSString *_wenduString;
NSIndexPath *_indexPath;
MyPickerView *_mypicView;
NSArray *_titieArr;
NSArray *_imgArr;
remindCyclePic*_remindPic;
BOOL _huanShuiSwitchIsOn;
NSInteger _selectSection;
MydatePickerView*_mydatepicView;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[Socketsingleton sharedInstance].communiteDelegate = self;
//关闭打开的section
_selectSection = -1;
[self.tableView reloadData];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self setup];
[self connect];
}
- (void)viewWillDisappear:(BOOL)animated{
[_indicatorView stopAnimating];
}
- (void)setup {
[self.navigationController.navigationBar resetBackgroundImage];
NSString*title=@"电量统计";
[self addTitleViewWithTitle:title];
[self refreshWithData:self.dataModel];
[self setupTable];
[self requestData];
[self creatIndicatorView];
[Socketsingleton sharedInstance].communiteDelegate = self;
}
-(void)requestData
{
[AFHttpTool requestWihtMethod:RequestMethodTypePost url:kdevicePowers params:@{} success:^(id response) {
NSDictionary*resultDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
// resultDic=@{@"result":@"100",@"data":@{@"history":@{@"2022":@{@"1":@"100",@"4":@"344",@"2":@"23"},@"2021":@{@"3":@"100",@"4":@"344",@"2":@"23"}}}};
NSString*result=resultDic[@"result"];
if ([resultDic[@"result"] isEqualToString:@"100"])
{
NSDictionary*data=resultDic[@"data"];
NSDictionary*his=data[@"history"];
self.dataDict=his;
self.sortedArray= [his.allKeys sortedArrayUsingComparator:^NSComparisonResult(NSString* number1, NSString* number2){
if ([number1 integerValue] > [number2 integerValue]){
return NSOrderedAscending;
}else if([number1 integerValue] < [number2 integerValue]){
return NSOrderedDescending;
}
else{
return NSOrderedSame;
}
}];
[self.tableView reloadData];
}
else
{
[self.view makeToast:result];
}
} failure:^(NSError *err) {
}];
}
- (void)refreshWithData:(Xuanduo3fModel*)model {
NSString*low = model.miniTemp;
NSString*heigh = model.maxTemp;
UInt64 lowten = [dataContorl hexToTen:low];
UInt64 heighten = [dataContorl hexToTen:heigh];
float formatlow = lowten/10;
float formatheigh = heighten/10;
_wenduString = [NSString stringWithFormat:@"%.0f~%.0f°C",formatlow,formatheigh];
}
- (void)setupTable {
self.tableView=[[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewCellStyleDefault];
self.tableView.delegate=self;
self.tableView.dataSource=self;
self.tableView.backgroundColor=COLOR_MIAN;
ElectricityView*header=[ElectricityView viewFromXib];
self.tableView.tableHeaderView=header;
self.headerView=header;
self.view.backgroundColor=COLOR_MIAN;
if (@available(iOS 15.0, *)) {
self.tableView.sectionHeaderTopPadding=0;
} else {
// Fallback on earlier versions
}
self.tableView.separatorStyle=UITableViewCellSeparatorStyleSingleLine;
self.tableView.separatorInset=UIEdgeInsetsMake(0, 15, 0, 15);
[self.tableView registerNib:[UINib nibWithNibName:ElectricityCellid bundle:nil] forCellReuseIdentifier:ElectricityCellid];
[self.view addSubview:self.tableView];
}
-(NSString*)getMonthByNumberString:(NSString*)number
{
NSDictionary*months=@{@"1":@"",@"2":@"",@"3":@"",@"4":@"",@"5":@"",@"6":@"",@"7":@"",@"8":@"",@"9":@"",@"10":@"",@"11":@"十一",@"12":@"十二"};
return months[number]?:@"";
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return self.sortedArray.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSString*key=self.sortedArray[section];
NSDictionary*dic=self.dataDict[key];
return dic.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ElectricityCell *cell = [tableView dequeueReusableCellWithIdentifier:ElectricityCellid];
cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
NSString*key=self.sortedArray[indexPath.section];
NSDictionary*dic=self.dataDict[key];
NSArray*array=[dic.allKeys sortedArrayUsingComparator:^NSComparisonResult(NSString* number1, NSString* number2){
if ([number1 integerValue] > [number2 integerValue]){
return NSOrderedDescending;
}else if([number1 integerValue] < [number2 integerValue]){
return NSOrderedAscending;
}
else{
return NSOrderedSame;
}
}];
NSString*month=array[indexPath.row];
NSString*power=dic[month];
cell.monthLabel.text=[NSString stringWithFormat:@"%@月",[self getMonthByNumberString:month]];
cell.powerLabel.text=power;
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 44;;
}
#pragma mark tableView 头视图和脚视图
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 44;
}
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
NSString*year=self.sortedArray[section];
UIView *oneHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 44)];
oneHeader.backgroundColor = [UIColor whiteColor];
UILabel*label=[[UILabel alloc]initWithFrame:CGRectMake(10, 0, 60, 44)];
label.text=[NSString stringWithFormat:@"%@年",year];
label.textColor=[UIColor lightGrayColor];
[oneHeader addSubview:label];
return oneHeader;
}
#pragma mark tableView 点击事件
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
-(void)temperatureMainQueue{
NSArray*lowArr=[_mypicView.picArr objectAtIndex:0];
NSArray*heighArr=[_mypicView.picArr objectAtIndex:2];
for (NSInteger i=0; i<lowArr.count; i++) {
NSString*tempretureString1=[_wenduString substringWithRange:NSMakeRange(0, _wenduString.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;
}
}
for (NSInteger j=0; j<heighArr.count; j++) {
NSString*tempretureString1= [_wenduString substringWithRange:NSMakeRange(0, _wenduString.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;
}
}
}
#pragma mark - cell的折叠
- (void)foldAction:(UIButton *)btn {
if (_selectSection == btn.tag - kBtnTag) {
_selectSection = -1;
[self.tableView reloadData];
}else {
_selectSection = btn.tag - kBtnTag;
ReadTimerModel *readModel = [[ReadTimerModel alloc] init];
//杀菌不定时
readModel.selectorName=_titieArr[_selectSection - 2];
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F]&&(_selectSection - 2)==2)
{
readModel.functionCode=@"19";//读取
}
else
{
readModel.functionCode=@"16";
}
readModel.sendmacId =self.currentdevice.macAddress;
readModel.resavemacId = self.currentdevice.macAddress;
readModel.crc16str=@"0000";
switch (_selectSection - 2) {
case 0: //循环泵 或 照明
readModel.selectorNumber = @"04";
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
readModel.selectorNumber=@"01";
}
break;
case 1: //增氧
readModel.selectorNumber = @"01";
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
readModel.selectorNumber=@"02";
}
break;
case 2: //灯光1
readModel.selectorNumber = @"02";
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
readModel.selectorNumber=@"03";
}
break;
case 3: //灯光2
readModel.selectorNumber = @"03";
break;
case 4: //造浪泵
readModel.selectorNumber = @"06";
break;
case 5: // 杀菌灯
readModel.selectorNumber = @"05";
break;
default:
break;
}
NSString*readString=[NSString stringWithFormat:@"%@%@%@",readModel.description,readModel.selectorNumber,readModel.crc16str];
NSData*readData=[dataContorl stringToHexData:readString];
[[Socketsingleton sharedInstance] soketWriteData:readData];
self.readMode=readModel;
[_indicatorView startAnimating];
}
}
- (void)switchAction:(UIButton *)btn {
NSInteger index = btn.tag - kSwitchBtnTag;
NSArray *dataArr = [self.timeDic objectForKey:_titieArr[_selectSection-2]];
BOOL havePlus = [dataArr containsObject:plusflag];
SetTimerModel *timerModel = [[SetTimerModel alloc] init];
timerModel.sendmacId =self.currentdevice.macAddress;
timerModel.resavemacId = self.currentdevice.macAddress;
timerModel.crc16str=@"0000";
XuanduoTimerGroup *group = [dataArr objectAtIndex:(havePlus?index+1:index)];
if ([group isKindOfClass: [XuanduoTimerGroup class] ]) {
NSString*hexDateString1=[dataContorl dateStringToHexString:group.startTime];
NSString*hexDateString2=[dataContorl dateStringToHexString:group.endTime];
timerModel.selectorTime=[NSString stringWithFormat:@"%@%@",hexDateString1,hexDateString2];
timerModel.groupNumber = [dataContorl groupNumberTohex:group.groupNumber.integerValue];
if ([group.status isEqualToString:@"01"]) {
timerModel.isOn = @"00";
}else {
timerModel.isOn = @"01";
}
ReadTimerModel *readModel = [[ReadTimerModel alloc] init];
readModel.sendmacId =self.currentdevice.macAddress;
readModel.resavemacId = self.currentdevice.macAddress;
readModel.crc16str=@"0000";
switch (_selectSection - 2) {
case 0: //循环泵
{
timerModel.selectorNumber = @"04";
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
timerModel.selectorNumber=@"01";
}
}
break;
case 1: //增氧
{
timerModel.selectorNumber = @"01";
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
timerModel.selectorNumber=@"02";
}
}
break;
case 2: //灯光1
{
timerModel.selectorNumber = @"02";
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
timerModel.selectorNumber=@"03";
}
}
break;
case 3: //灯光2
{
timerModel.selectorNumber = @"03";
}
break;
case 4: //造浪泵
{
timerModel.selectorNumber = @"06";
}
break;
case 5: //杀菌灯
{
timerModel.selectorNumber = @"05";
}
break;
default:
break;
}
NSString*selectorString=[NSString stringWithFormat:@"%@%@%@%@%@%@",timerModel.description,timerModel.selectorNumber,timerModel.groupNumber,timerModel.isOn,timerModel.selectorTime,timerModel.crc16str];
NSData*selctorData=[dataContorl stringToHexData:selectorString];
[[Socketsingleton sharedInstance] soketWriteData:selctorData];
// [_indicatorView startAnimating];
readModel.selectorNumber = timerModel.selectorNumber;
NSString*readString=[NSString stringWithFormat:@"%@%@%@",readModel.description,readModel.selectorNumber,readModel.crc16str];
NSLog(@"read str = %@",readString);
NSData*readData=[dataContorl stringToHexData:readString];
[[Socketsingleton sharedInstance] soketWriteData:readData];
;
}
else if ([group isKindOfClass: [XuanduoCycleModel class] ])
{
baseModel*tempModel=[[baseModel alloc]init];
tempModel.sendmacId =self.currentdevice.macAddress;
tempModel.resavemacId =self.currentdevice.macAddress;
tempModel.functionCode=@"18";
tempModel.massagelegth=@"17";
if ([_cycleModel.status isEqualToString:@"01"]) {
_cycleModel.status = @"00";
}else {
_cycleModel.status = @"01";
}
NSString*minString=[NSString stringWithFormat:@"%@%@%@%@%@%@",tempModel.description,_cycleModel.lightNumber,_cycleModel.lastTime,_cycleModel.gapTime,_cycleModel.status,@"0000"];
NSData*tempData=[dataContorl stringToHexData:minString];
[[Socketsingleton sharedInstance] soketWriteData:tempData];
baseModel*readModel=[[baseModel alloc]init];
readModel.sendmacId =self.currentdevice.macAddress;
readModel.resavemacId =self.currentdevice.macAddress;
readModel.functionCode=@"19";
readModel.massagelegth=@"12";
NSString*readString=[NSString stringWithFormat:@"%@%@%@%@%@%@",readModel.description,_cycleModel.lightNumber,@"0000"];
NSData*readData=[dataContorl stringToHexData:readString];
[[Socketsingleton sharedInstance] soketWriteData:readData];
}
}
- (void)addTimer:(UIButton *)btn {
_mydatepicView=[[MydatePickerView alloc]init];
_mydatepicView.frame=CGRectMake(0,0,kScreenSize.width,kScreenSize.height);
[_mydatepicView.sureButton addTarget:self action:@selector(doneButtonClick) forControlEvents:UIControlEventTouchUpInside];
[_mydatepicView.cancleButton addTarget:self action:@selector(deleteButtonClick) forControlEvents:UIControlEventTouchUpInside];
if (!btn) {
_mydatepicView.haveDelected = YES;
[self resetPickerView];
}
// 设置pickerView 默认选择行
[self.view.window addSubview:_mydatepicView];
}
- (void)resetPickerView {
NSMutableArray *dataArr = [self.timeDic objectForKey:_titieArr[_selectSection-2]];
BOOL havePlus = [dataArr containsObject:plusflag];
XuanduoTimerGroup *model = nil;
if (havePlus) {
model = dataArr[_indexPath.row + 1];
}else {
model = dataArr[_indexPath.row];
}
NSArray *startArr = [model.startTime componentsSeparatedByString:@":"];
NSArray *endArr = [model.endTime componentsSeparatedByString:@":"];
NSLog(@"stat %@ end %@",startArr,endArr);
if (startArr.count == 2 && endArr.count == 2) {
NSInteger row1 = [[_mydatepicView.dataArr objectAtIndex:0] indexOfObject:startArr[0]];
if (row1==NSNotFound)
{
row1=0;
}
[_mydatepicView.picView selectRow:row1 inComponent:0 animated:NO];
NSInteger row2 = [[_mydatepicView.dataArr objectAtIndex:1] indexOfObject:startArr[1]];
if (row2==NSNotFound)
{
row2=0;
}
[_mydatepicView.picView selectRow:row2 inComponent:1 animated:NO];
NSInteger row3 = [[_mydatepicView.dataArr objectAtIndex:2] indexOfObject:endArr[0]];
if (row3==NSNotFound)
{
row3=0;
}
[_mydatepicView.picView selectRow:row3 inComponent:2 animated:NO];
NSInteger row4 = [[_mydatepicView.dataArr objectAtIndex:3] indexOfObject:endArr[1]];
if (row4==NSNotFound)
{
row4=0;
}
[_mydatepicView.picView selectRow:row4 inComponent:3 animated:NO];
_mydatepicView.startString = startArr[0];
_mydatepicView.endString = startArr[1];
_mydatepicView.startString1 = endArr[0];
_mydatepicView.endString1 = endArr[1];
}
}
#pragma mark -- 设置时间段 --
-(void)doneButtonClick{
NSLog(@"点击了加号");
// 需要判断之前的时间段是否重叠
NSString *startTime = [NSString stringWithFormat:@"%@:%@",_mydatepicView.startString,_mydatepicView.endString];
NSString *endTime = [NSString stringWithFormat:@"%@:%@",_mydatepicView.startString1,_mydatepicView.endString1];
_mydatepicView.resultString=nil;
if([startTime isEqualToString:endTime]){
[self showTitle:@"" messsage:@"开始时间不能等于结束时间"];
return;
}else if (![self isValidTimer:startTime withEndTime:endTime] && !_mydatepicView.haveDelected){
[self showTitle:@"" messsage:@"添加的时间段与之前的重叠"];
return;
}else{
_mydatepicView.resultString=[NSString stringWithFormat:@"%@~%@",startTime,endTime];
NSString*hexDateString1=[dataContorl dateStringToHexString:startTime];
NSString*hexDateString2=[dataContorl dateStringToHexString:endTime];
SetTimerModel *timerModel = [[SetTimerModel alloc] init];
timerModel.sendmacId =self.currentdevice.macAddress;
timerModel.resavemacId = self.currentdevice.macAddress;
timerModel.crc16str=@"0000";
timerModel.isOn = @"01";
timerModel.selectorTime=[NSString stringWithFormat:@"%@%@",hexDateString1,hexDateString2];
[_mydatepicView removeFromSuperview];
ReadTimerModel *readModel = [[ReadTimerModel alloc] init];
readModel.sendmacId =self.currentdevice.macAddress;
readModel.resavemacId = self.currentdevice.macAddress;
readModel.crc16str=@"0000";
NSInteger index = _selectSection - 2;
if (index < _titieArr.count) {
NSMutableArray *dataArr = [self.timeDic objectForKey:_titieArr[index]];
NSInteger groupNumber = 1;
for (int i = 0 ; i < dataArr.count; i++) {
if ([dataArr[i] isKindOfClass:[XuanduoTimerGroup class]] &&
((XuanduoTimerGroup *)dataArr[i]).groupNumber.integerValue == groupNumber) {
groupNumber++;
}
}
NSLog(@"indexgroup = %d",groupNumber);
timerModel.groupNumber = [dataContorl groupNumberTohex:groupNumber];
XuanduoTimerGroup *group;
BOOL havePlus = NO;
if (_mydatepicView.haveDelected) {
havePlus = [dataArr containsObject:plusflag];
group = [dataArr objectAtIndex:havePlus?(_indexPath.row+1):_indexPath.row];
timerModel.groupNumber = [dataContorl groupNumberTohex:group.groupNumber.integerValue];;
NSLog(@"realgroup = %ld",group.groupNumber.integerValue);
timerModel.isOn = group.status;
[dataArr removeObject:group];
if (![self isValidTimer:startTime withEndTime:endTime]) {
[self showTitle:@"" messsage:@"添加的时间段与之前的重叠"];
[dataArr insertObject:group atIndex:havePlus?(_indexPath.row+1):_indexPath.row];
return;
}else {
[dataArr insertObject:group atIndex:havePlus?(_indexPath.row+1):_indexPath.row];
}
}
switch (index) {
case 0: //循环泵
{
timerModel.selectorNumber = @"04";
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
timerModel.selectorNumber=@"01";
}
}
break;
case 1: //增氧
{
timerModel.selectorNumber = @"01";
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
timerModel.selectorNumber=@"02";
}
}
break;
case 2: //灯光1
{
timerModel.selectorNumber = @"02";
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
timerModel.selectorNumber=@"03";
}
}
break;
case 3: //灯光2
{
timerModel.selectorNumber = @"03";
}
break;
case 4: //造浪泵
{
timerModel.selectorNumber = @"06";
}
break;
case 5: //杀菌灯
{
timerModel.selectorNumber = @"05";
}
break;
default:
break;
}
NSString*selectorString=[NSString stringWithFormat:@"%@%@%@%@%@%@",timerModel.description,timerModel.selectorNumber,timerModel.groupNumber,timerModel.isOn,timerModel.selectorTime,timerModel.crc16str];
NSData*selctorData=[dataContorl stringToHexData:selectorString];
[[Socketsingleton sharedInstance] soketWriteData:selctorData];
[_indicatorView startAnimating];
NSLog(@"hexString%@",selectorString);
NSLog(@"result%@",_mydatepicView.resultString);
readModel.selectorNumber = timerModel.selectorNumber;
NSString*readString=[NSString stringWithFormat:@"%@%@%@",readModel.description,readModel.selectorNumber,readModel.crc16str];
NSData*readData=[dataContorl stringToHexData:readString];
[[Socketsingleton sharedInstance] soketWriteData:readData];
[_indicatorView startAnimating];
}
}
}
/// 删除时间段
- (void)deleteButtonClick{
NSString*hexDateString1=[dataContorl dateStringToHexString:@"00:00"];
NSString*hexDateString2=[dataContorl dateStringToHexString:@"00:00"];
SetTimerModel *timerModel = [[SetTimerModel alloc] init];
timerModel.sendmacId =self.currentdevice.macAddress;
timerModel.resavemacId = self.currentdevice.macAddress;
timerModel.crc16str=@"0000";
timerModel.isOn = @"00";
timerModel.selectorTime=[NSString stringWithFormat:@"%@%@",hexDateString1,hexDateString2];
[_mydatepicView removeFromSuperview];
ReadTimerModel *readModel = [[ReadTimerModel alloc] init];
readModel.sendmacId =self.currentdevice.macAddress;
readModel.resavemacId = self.currentdevice.macAddress;
readModel.crc16str=@"0000";
NSInteger index = _selectSection - 2;
NSLog(@"index = %d",index);
if (index < _titieArr.count) {
NSArray *dataArr = [self.timeDic objectForKey:_titieArr[_selectSection-2]];
BOOL havePlus = [dataArr containsObject:plusflag];
XuanduoTimerGroup *group = [dataArr objectAtIndex:(havePlus?_indexPath.row+1:_indexPath.row)];
timerModel.groupNumber = [dataContorl groupNumberTohex:group.groupNumber.integerValue];
switch (index) {
case 0: //循环泵
{
timerModel.selectorNumber = @"04";
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
timerModel.selectorNumber=@"01";
}
}
break;
case 1: //增氧
{
timerModel.selectorNumber = @"01";
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
timerModel.selectorNumber=@"02";
}
}
break;
case 2: //灯光1
{
timerModel.selectorNumber = @"02";
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
timerModel.selectorNumber=@"03";
}
}
break;
case 3: //灯光2
{
timerModel.selectorNumber = @"03";
}
break;
case 4: //造浪泵
{
timerModel.selectorNumber = @"06";
}
break;
case 5: //杀菌灯
{
timerModel.selectorNumber = @"05";
}
break;
default:
break;
}
NSString*selectorString=[NSString stringWithFormat:@"%@%@%@%@%@%@",timerModel.description,timerModel.selectorNumber,timerModel.groupNumber,timerModel.isOn,timerModel.selectorTime,timerModel.crc16str];
NSData*selctorData=[dataContorl stringToHexData:selectorString];
[[Socketsingleton sharedInstance] soketWriteData:selctorData];
[_indicatorView startAnimating];
NSLog(@"delete hexString = %@",selectorString);
NSLog(@"result%@",_mydatepicView.resultString);
readModel.selectorNumber = timerModel.selectorNumber;
NSString*readString=[NSString stringWithFormat:@"%@%@%@",readModel.description,readModel.selectorNumber,readModel.crc16str];
NSData*readData=[dataContorl stringToHexData:readString];
[[Socketsingleton sharedInstance] soketWriteData:readData];
[_indicatorView startAnimating];
}
}
/// 时间重叠则添加无效
- (BOOL)isValidTimer:(NSString *)startTime withEndTime:(NSString *)endTime{
__block BOOL isValid = YES;
NSString *addEndtime = endTime;
if ([startTime compare:endTime] == NSOrderedDescending) { //开始时间小于结束时间 跨天
NSInteger endHour = [addEndtime substringToIndex:2].integerValue;
NSString *endHourStr = [NSString stringWithFormat:@"%ld",endHour + 24];
addEndtime = [NSString stringWithFormat:@"%@:%@",endHourStr,[addEndtime substringFromIndex:3]];
}
NSArray *dataArr = [self.timeDic objectForKey:_titieArr[_selectSection-2]];
[dataArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:[XuanduoTimerGroup class]]) {
XuanduoTimerGroup *group = obj;
NSString *compareEndTime = group.endTime;
if (group.isCrossDay) {
NSInteger hour = [compareEndTime substringToIndex:2].integerValue;
NSString *hourStr = [NSString stringWithFormat:@"%ld",hour + 24];
compareEndTime = [NSString stringWithFormat:@"%@:%@",hourStr,[compareEndTime substringFromIndex:3]];
NSLog(@"跨天 compareendstr = %@",compareEndTime);
if ([group.startTime compare:startTime] == NSOrderedSame && [compareEndTime compare:addEndtime] == NSOrderedSame) {
isValid = NO;
* stop = YES;
NSLog(@"跨天1 compareendstr = %@",compareEndTime);
}else if (([startTime compare:group.startTime] == NSOrderedAscending || [startTime compare:group.startTime] == NSOrderedSame)&& ([addEndtime compare:group.startTime] == NSOrderedDescending || [addEndtime compare:group.startTime] == NSOrderedSame)) {
isValid = NO;
* stop = YES;
NSLog(@"跨天2 compareendstr = %@",compareEndTime);
}else if (([startTime compare:group.startTime] == NSOrderedDescending || [startTime compare:group.startTime] == NSOrderedSame)&& ([addEndtime compare:compareEndTime] == NSOrderedAscending|| [addEndtime compare:compareEndTime] == NSOrderedSame)){
isValid = NO;
* stop = YES;
NSLog(@"跨天3 compareendstr = %@",compareEndTime);
}else if ([startTime compare:group.endTime] == NSOrderedSame){
isValid = NO;
* stop = YES;
NSLog(@"跨天4 compareendstr = %@",compareEndTime);
}else if (([startTime compare:group.startTime] == NSOrderedDescending || [startTime compare:group.startTime] == NSOrderedSame) && [startTime compare:compareEndTime] == NSOrderedAscending ){
isValid = NO;
* stop = YES;
}
}else {
NSLog(@"group.start=%@ group.end=%@ start=%@ end=%@",group.startTime,group.endTime,startTime,endTime);
if ([group.startTime compare:startTime] == NSOrderedSame && [compareEndTime compare:addEndtime] == NSOrderedSame) {
isValid = NO;
* stop = YES;
NSLog(@"不跨天1 compareendstr = %@",compareEndTime);
}else if (([startTime compare:group.startTime] == NSOrderedAscending || [startTime compare:group.startTime] == NSOrderedSame)&& ([addEndtime compare:group.startTime] == NSOrderedDescending || [addEndtime compare:group.startTime] == NSOrderedSame)) {
isValid = NO;
* stop = YES;
NSLog(@"不跨天2 compareendstr = %@",compareEndTime);
}else if(([startTime compare:group.startTime] == NSOrderedDescending || [startTime compare:group.startTime] == NSOrderedSame)&& ([addEndtime compare:compareEndTime] == NSOrderedAscending|| [addEndtime compare:compareEndTime] == NSOrderedSame)){
isValid = NO;
* stop = YES;
NSLog(@"不跨天3 compareendstr = %@",compareEndTime);
}else if ([startTime compare:group.endTime] == NSOrderedSame){
isValid = NO;
* stop = YES;
NSLog(@"不跨天4 compareendstr = %@",compareEndTime);
}else if (([startTime compare:group.startTime] == NSOrderedDescending || [startTime compare:group.startTime] == NSOrderedSame) && [startTime compare:compareEndTime] == NSOrderedAscending ){
isValid = NO;
* stop = YES;
}
}
}
}];
return isValid;
}
#pragma mark 温度设置
-(void)mypicViewRemoveByDone{
if (_mypicView.picViewResultString==nil) {
[_mypicView removeFromSuperview];
}else{
if (_indexPath.section==0) {
TemperatureSetCell*cell=[self.tableView cellForRowAtIndexPath:_indexPath];
cell.temperaturelabel.text=[NSString stringWithFormat:@"%@°C",_mypicView.picViewResultString];
}
BackmassegeModel*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"DeviceBackInfo"];
// 低温
setWaringTpModel*warModel1=[[setWaringTpModel alloc]init];
warModel1.sendmacId =self.currentdevice.macAddress;
warModel1.resavemacId =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];
NSLog(@"minstring = %@",minString);
NSData*minwenDuData=[dataContorl stringToHexData:minString];
[[Socketsingleton sharedInstance] soketWriteData:minwenDuData];
backmodel.maxTp=warModel2.maxwaterTp;
[_indicatorView startAnimating];
[_mypicView removeFromSuperview];
}else{
[self showTitle:@"提醒" messsage:@"请正确设置温度"];
}
}
}
#pragma mark 默认换水时间
-(void)huanShuiMainQueue{
if (_indexPath.section-2==_titieArr.count)
{
Xuanduo3fModel*model3=self.dataModel;
int mac=[dataContorl hexToTen:model3.heatingTemperature];
//float TPlabel=mac/10+(mac%10)*0.1;
NSInteger temp = mac/10.0;
if (temp<1)
{
temp=1;
}
[_remindPic.pic selectRow:temp-1 inComponent:0 animated:NO];
return;
}
else if ([_remindPic.type isEqualToString:@"cycle"])
{
int mac=[dataContorl hexToTen:_cycleModel.lastTime];
//float TPlabel=mac/10+(mac%10)*0.1;
NSInteger temp = mac;
if (temp<1)
{
temp=1;
}
[_remindPic.pic selectRow:temp-1 inComponent:0 animated:NO];
return;
}
else if (_remindPic.picViewResultString !=nil || (_remindPic.picViewResultString ==nil && self.waterInfmodel.remindcycle !=0 )) {
NSArray*shijianArr=[_remindPic.picArr objectAtIndex:0];
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];
}
}
}
}
#pragma mark 换水时间设置
-(void)xuToremindCyclePicDone{
if (_indexPath.section==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];
NSString*title=@"请设置换水天数";
if ([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
title=@"请设置杀菌天数";
}
[_remindPic makeToast:title];
return;
}
cell.huanshuiDaylabel.text=[NSString stringWithFormat:@"%@天",str];
//设置换水日期
[IFISHHTTPTOOL setRemindWaterInfWith:[NSString stringWithFormat:@"%@_%@",self.currentdevice.deviceId,self.currentdevice.type]
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:@"xuto2picResult"];
[defuat synchronize];
[_remindPic removeFromSuperview];
}
else if (_indexPath.section-2==_titieArr.count)
{
TemperatureSetCell*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];
NSString*title=@"请设置换水天数";
if ([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
title=@"请设置杀菌天数";
}
[_remindPic makeToast:title];
return;
}
cell.temperaturelabel.text=[NSString stringWithFormat:@"%.1f℃",str.floatValue];
//设置换水日期
;
[_remindPic removeFromSuperview];
baseModel*tempModel=[[baseModel alloc]init];
tempModel.sendmacId =self.currentdevice.macAddress;
tempModel.resavemacId =self.currentdevice.macAddress;
tempModel.functionCode=@"0e";
tempModel.massagelegth=@"13";
int intString = [str intValue];
int newIntString=intString*10;
NSString*temp =[dataContorl tpIntStringToFourHex:newIntString];
NSString*minString=[NSString stringWithFormat:@"%@%@%@",tempModel.description,temp,@"0000"];
NSLog(@"minstring = %@",minString);
NSData*tempData=[dataContorl stringToHexData:minString];
[[Socketsingleton sharedInstance] soketWriteData:tempData];
}
else if ([_remindPic.type isEqualToString:@"cycle"])
{
SetTimerCell*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.timerLabel.text=[NSString stringWithFormat:@"%d分钟",str.intValue];
//设置换水日期
;
[_remindPic removeFromSuperview];
baseModel*tempModel=[[baseModel alloc]init];
tempModel.sendmacId =self.currentdevice.macAddress;
tempModel.resavemacId =self.currentdevice.macAddress;
tempModel.functionCode=@"18";
tempModel.massagelegth=@"17";
int intString = [str intValue];
NSString*hex=[dataContorl ToHex:intString];
NSString*temp =[dataContorl leftAddZero:4 andStr:hex];
_cycleModel.lastTime=temp;
NSString*minString=[NSString stringWithFormat:@"%@%@%@%@%@%@",tempModel.description,_cycleModel.lightNumber,_cycleModel.lastTime,_cycleModel.gapTime,_cycleModel.status,@"0000"];
NSLog(@"minstring = %@",minString);
NSData*tempData=[dataContorl stringToHexData:minString];
[[Socketsingleton sharedInstance] soketWriteData:tempData];
baseModel*readModel=[[baseModel alloc]init];
readModel.sendmacId =self.currentdevice.macAddress;
readModel.resavemacId =self.currentdevice.macAddress;
readModel.functionCode=@"19";
readModel.massagelegth=@"12";
NSString*readString=[NSString stringWithFormat:@"%@%@%@%@%@%@",readModel.description,_cycleModel.lightNumber,@"0000"];
NSData*readData=[dataContorl stringToHexData:readString];
[[Socketsingleton sharedInstance] soketWriteData:readData];
}
}
#pragma mark 开启关闭报警
-(void)xuTotempSwitchAction:(UIButton*)temperatureSwitch{
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:self.dataModel];
}
-(void)setTmperatureStateWithModel:(setWaringTpModel*)waringModel addBackModel:(Xuanduo2Model *)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.miniTemp=waringModel.miniwaterTp;
backModel.maxTemp=waringModel.maxwaterTp;
}
#pragma mark 换水提醒Action
-(void)xuTochangeWaterSwitch:(UIButton*)sender{
UIButton*huanShuiSwitch=(UIButton*)sender;
//BOOL isButtonOn=[huanShuiSwitch isOn];
NSUserDefaults*defuat=[NSUserDefaults standardUserDefaults];
NSString*picResult=[defuat valueForKey:@"xuto2picResult"];
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:[NSString stringWithFormat:@"%@_%@",self.currentdevice.deviceId,self.currentdevice.type]
waterRemind:@"1" remindCycle:picResult
huishuiShiJian:^(setRemindWaterModel *remindModel) {
self.nextChangeDateLabel=remindModel.remindDate;
}];
//更新选择状态 设置界面 在不断 刷新
self.waterInfmodel.waterremind=@"1";
[self.tableView reloadData];
}else{
//关
huanShuiSwitch.selected =YES;
[IFISHHTTPTOOL setRemindWaterInfWith:[NSString stringWithFormat:@"%@_%@",self.currentdevice.deviceId,self.currentdevice.type]
waterRemind:@"0" remindCycle:picResult
huishuiShiJian:^(setRemindWaterModel *remindModel) {
self.nextChangeDateLabel=remindModel.remindDate;
self.waterInfmodel=remindModel;
}];
self.waterInfmodel.waterremind=@"0";
[self.tableView reloadData];
}
}
}
-(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= [[UIApplication sharedApplication] delegate];
[delegate.window addSubview:_indicatorView];
}
- (setRemindWaterModel *)waterInfmodel {
if (!_waterInfmodel) {
_waterInfmodel = [setRemindWaterModel new];
}
return _waterInfmodel;
}
- (NSMutableDictionary *)timeDic {
if (!_timeDic) {
_timeDic = [[NSMutableDictionary alloc] init];
}
return _timeDic;
}
#pragma mark - socket --
- (void)connect {
if ([self.currentdevice.isBlacklist isEqualToString:@"0"]) {
[self InitSocket];//允许请求数据
}
}
#pragma mark 连接socket
-(void)InitSocket{
NSLog(@"******%d",[Socketsingleton sharedInstance].clientSocket.isConnected);
if (![Socketsingleton sharedInstance].clientSocket.isConnected) {
//[[Socketsingleton sharedInstance];
}
// 切换设备 先断开然后重连
[[Socketsingleton sharedInstance] socketConnectHost];
[Socketsingleton sharedInstance].macAddress = self.currentdevice.macAddress;
}
#pragma mark 通信监听communiteDelegate
//当已经和服务端断开连接后调用该代理方法
//断线重连功能需要在这里进行
-(void)ifishSocketDidDisconnect:(AsyncSocket *)sock{
}
-(void)ifishSocket:(AsyncSocket *)sock willDisconnectWithError:(NSError *)err{
// NSLog(@"soket错误断开");
// NSLog(@"存留数据%@",[sock unreadData]);
}
-(BOOL)ifishSocketWillConnect:(AsyncSocket *)sock{
// NSLog(@"将要链接");
return YES;
}
#pragma mark 当已经与服务端建立连接后调用的代理方法
-(void)ifishSocket:(AsyncSocket *)sock ifishSocketdidConnectToHost:(NSString *)host port:(UInt16)port{
//已建立连接 登陆指令同意在soket单例中
}
//发送完成处理
-(void)ifishSocket:(AsyncSocket *)sock didWriteDataWithTag:(long)tag{
}
#pragma mark 登陆成功后收到服务端的回执之后,调用的代理方法
//父类里面不执行此方法 接收服务器返回信息 在子类中做处理
//communiteDelegate
-(void)socketDidGetBackmsgData:(NSData *)data onsoket:(AsyncSocket *)sock{
//[_HUD hide:YES];
NSString*string1=[dataContorl dataToHexString:data];
NSLog(@"return str == %@",string1);
NSString *readTimer = [string1 substringToIndex:4];
if ( [readTimer isEqualToString:@"0116"])
{
NSString*lightNumber=[string1 substringWithRange:NSMakeRange(30, 2)];
if ([lightNumber isEqualToString:@"08"])//定时
{
XuanduoElectricityModel*model=[[XuanduoElectricityModel alloc]init];
model.dayPower=[string1 substringWithRange:NSMakeRange(34, 4)];
model.monthPower=[string1 substringWithRange:NSMakeRange(38, 4)];
model.PowerRating=[string1 substringWithRange:NSMakeRange(42, 4)];
self.headerView.dayPowerLabel.text=[NSString stringWithFormat:@"%ld",[dataContorl hexToTen:model.dayPower]];
self.headerView.monthPower.text=[NSString stringWithFormat:@"%ld",[dataContorl hexToTen:model.monthPower]];
self.headerView.rating.text=[NSString stringWithFormat:@"%ld",[dataContorl hexToTen:model.PowerRating]];
}
}
if ([readTimer isEqualToString:@"0108"] || [readTimer isEqualToString:@"0105"]) {
[Xuanduo2DataUtility readSocketDataWithBackMsgModel:self.dataModel addWithBackData:data type:self.currentdevice.type];
[self refreshWithData:self.dataModel];
}
[self.XuTohud hidmyHud];
[self.indicatorView stopAnimating];
[self.tableView reloadData];
}
-(void)ifishDeviceLogInFail{
}
-(void)ifishDeviceLogInSuccees
{
baseModel*readModel=[[baseModel alloc]init];
readModel.sendmacId =self.currentdevice.macAddress;
readModel.resavemacId =self.currentdevice.macAddress;
readModel.functionCode=@"16";
readModel.massagelegth=@"12";
NSString*readString=[NSString stringWithFormat:@"%@%@%@",readModel.description,@"08",@"0000"];
NSData*readData=[dataContorl stringToHexData:readString];
[[Socketsingleton sharedInstance] soketWriteData:readData];
[_indicatorView startAnimating];
}
-(void)ifishSocket:(AsyncSocket *)sock didAcceptNewSocket:(AsyncSocket *)newSocket{
}
@end