611 lines
22 KiB
Objective-C
611 lines
22 KiB
Objective-C
//
|
|
// RunSun84biteCenterViewController.m
|
|
// Ifish
|
|
//
|
|
// Created by imac on 2017/6/2.
|
|
// Copyright © 2017年 lianlian. All rights reserved.
|
|
//
|
|
|
|
#import "RunSun84biteCenterViewController.h"
|
|
#import "RunSun84Protocol.h"
|
|
#define kPlace ([UIScreen mainScreen].bounds.size.width - btnWid*2) /4
|
|
#define RUNSUN_CH1 6000
|
|
#define RUNSUN_CH2 6001
|
|
#define RUNSUN_CH3 6002
|
|
#define RUNSUN_CH4 6003
|
|
#define RUNSUN_GUIDENG 6004
|
|
#define RUNSUN_JARE 6005
|
|
|
|
#define btnWid 100
|
|
#import "XuToWenDuPicview.h"
|
|
#import "RuSunLightOrder.h"
|
|
#import "RuSunGuiDeng.h"
|
|
#import "RunSun84CHSetViewController.h"
|
|
#import "RuSun84BackMsgUtils.h"
|
|
#import "RunSunCHNameCustom.h"
|
|
#import "RunSunChangeNameViewController.h"
|
|
#import "RunSunCHControl.h"
|
|
#import "RuSunInpdViewController.h"
|
|
#import "HaveHotCoolWenDuPicview.h"
|
|
@interface RunSun84biteCenterViewController ()<HaveHotCoolWenDuPicviewDelegate>
|
|
{
|
|
dispatch_queue_t _ruSunMainQueue;
|
|
}
|
|
@property(nonatomic,strong) RunSun84Protocol *backmodel;
|
|
@property(nonatomic,strong) HaveHotCoolWenDuPicview *wenduPicview;
|
|
@property(nonatomic,strong) RunSun84CHSetViewController *rusunHaveHeatSetVC;
|
|
//@property(nonatomic,strong) RunSunChangeNameViewController *changenameVC;
|
|
@property(nonatomic,strong) RuSunInpdViewController *changenameVC;
|
|
|
|
@end
|
|
|
|
@implementation RunSun84biteCenterViewController
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
[super viewDidLoad];
|
|
|
|
_backmodel=[[RunSun84Protocol alloc] init];
|
|
[Socketsingleton sharedInstance].communiteDelegate=self;
|
|
_ruSunMainQueue = dispatch_get_main_queue();
|
|
// Do any additional setup after loading the view.
|
|
UITapGestureRecognizer*tapgestureRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(RuSunCenterViewSetTap)];
|
|
[self.setImag addGestureRecognizer:tapgestureRecognizer];
|
|
[self.setbackBtn addTarget:self action:@selector(RuSunCenterViewSetAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
[self.SetTimeButton addTarget:self action:@selector(RuSunCenterViewSetAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
[self initControlNormalBtn];
|
|
}
|
|
|
|
-(void)RuSunCenterViewSetTap
|
|
{
|
|
|
|
RunSun84Protocol*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"RuSunBackMessage84bite"];
|
|
|
|
if (backmodel) {
|
|
[self pushSetTimeVC];
|
|
}else{
|
|
[self deviceNotOnlineState];
|
|
|
|
[self showLableAction:@"设备已离线"];
|
|
|
|
[self.indicatorView stopAnimating];
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#pragma mark -转跳设置界面
|
|
|
|
-(void)RuSunCenterViewSetAction:(UIButton*)btn
|
|
{
|
|
RunSun84Protocol*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"RuSunBackMessage84bite"];
|
|
if (backmodel) {
|
|
[self pushSetTimeVC];
|
|
}else{
|
|
[self deviceNotOnlineState];
|
|
|
|
[self showLableAction:@"设备已离线"];
|
|
|
|
[self.indicatorView stopAnimating];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-(void)pushSetTimeVC{
|
|
|
|
_rusunHaveHeatSetVC=[[RunSun84CHSetViewController alloc]init];
|
|
|
|
_rusunHaveHeatSetVC.currentdevice=self.currentDevice;
|
|
[self.navigationController pushViewController:_rusunHaveHeatSetVC animated:YES];
|
|
|
|
}
|
|
|
|
|
|
-(void)initControlNormalBtn
|
|
{
|
|
|
|
NSArray*nameArr=@[@"PFLight1_off.png",@"PFLight1_off.png",@"PFLight1_off.png",@"PFLight1_off.png",@"PFLight1_off.png",@"JiaReBang_off"];
|
|
CGFloat btnControlWith = 70;
|
|
CGFloat btnControlPlace = (kScreenSize.width - 3*btnControlWith )/4;
|
|
|
|
for (int i = 0; i < 3; i ++) {
|
|
|
|
self.button = [[UIButton alloc] init] ;
|
|
self.button.frame = CGRectMake(btnControlPlace +i*(btnControlPlace + btnControlWith),kScreenSize.height - 3*btnControlPlace - 2 *btnControlWith -(is_iPhone_X?0:20) , btnControlWith, btnControlWith +11);
|
|
|
|
[self.button setImage:[UIImage imageNamed:nameArr[i]] forState:UIControlStateNormal];
|
|
//self.button.backgroundColor = [UIColor redColor];
|
|
self.button.tag=6000+i;
|
|
[self.button addTarget:self action:@selector(controlBtnCilck:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
|
self.chName = [[UILabel alloc] initWithFrame:CGRectMake(btnControlPlace +i*(btnControlPlace + btnControlWith),kScreenSize.height - 3*btnControlPlace - 2 *btnControlWith -20 + btnControlWith -5 , btnControlWith, btnControlPlace - 5)];
|
|
//textLbl.backgroundColor = [UIColor blackColor];
|
|
self.chName.textColor = [UIColor colorWithRed:250/255.0f green:255/255.0f blue:255/254.0f alpha:1];
|
|
self.chName.textAlignment = NSTextAlignmentCenter;
|
|
NSArray *arr = @[@"S1",@"S2",@"S3"];
|
|
self.chName.text = arr[i];
|
|
|
|
self.chName.font = [UIFont boldSystemFontOfSize:14];
|
|
|
|
[self.tableView addSubview:self.chName];
|
|
[self.tableView addSubview:self.button];
|
|
|
|
if (i==0) {
|
|
|
|
self.ch1Button = self.button;
|
|
self.ch1Name = self.chName;
|
|
}else if (i==1){
|
|
|
|
self.ch2Button = self.button;
|
|
self.ch2Name = self.chName;
|
|
|
|
}else if (i==2){
|
|
self.ch3Name = self.chName;
|
|
self.ch3Button = self.button;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//CGFloat btnControlPlace1 = (kScreenSize.width - 2*btnControlWith )/3;
|
|
|
|
for (int i = 0; i < 3; i ++) {
|
|
self.button = [[UIButton alloc] init] ;
|
|
self.button.frame = CGRectMake(btnControlPlace +i*(btnControlPlace + btnControlWith), kScreenSize.height - 2*btnControlPlace - btnControlWith -25 -5 , btnControlWith, btnControlWith + 11);
|
|
|
|
|
|
[self.button setImage:[UIImage imageNamed:nameArr[i+3]]forState:UIControlStateNormal];
|
|
|
|
self.button.tag= 6003+i;
|
|
[self.button addTarget:self action:@selector(controlBtnCilck:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
UILabel* textLbl = [[UILabel alloc] initWithFrame:CGRectMake(btnControlPlace +i*(btnControlPlace + btnControlWith), kScreenSize.height - 2*btnControlPlace - btnControlWith -35 + btnControlWith, btnControlWith, btnControlPlace - 5)];
|
|
//textLbl.backgroundColor = [UIColor blackColor];
|
|
textLbl.textAlignment = NSTextAlignmentCenter;
|
|
textLbl.textColor = [UIColor colorWithRed:250/255.0f green:255/255.0f blue:255/254.0f alpha:1];
|
|
NSArray *arr = @[@"S4",@"USB灯",@"S5"];
|
|
textLbl.font = [UIFont boldSystemFontOfSize:14];
|
|
textLbl.text = arr[i];
|
|
self.chName = textLbl;
|
|
[self.tableView addSubview:textLbl];
|
|
[self.tableView addSubview:self.button];
|
|
|
|
if (i==0) {
|
|
|
|
self.ch4Button = self.button;
|
|
self.ch4Name = self.chName;
|
|
}else if (i==1){
|
|
|
|
self.guidengButton = self.button;
|
|
self.guiDengName = self.chName;
|
|
}else if (i==2){
|
|
|
|
self.heatBtn = self.button;
|
|
self.jiaReName = self.chName;
|
|
|
|
}
|
|
}
|
|
|
|
//重置 self.bubble 的 frame
|
|
CGFloat animViewHeight= kScreenSize.width/4;
|
|
if (kScreenSize.height==480) {
|
|
|
|
self.bubble.frame = CGRectMake((kScreenSize.width -(kScreenSize.width - 2 * kPlace)*2/3)/2, kPlace + 60 , (kScreenSize.width - 2 * kPlace)*2/3, (kScreenSize.width - 2 * kPlace)*2/3);
|
|
|
|
//(kScreenSize.width - 2 * kPlace - 200)*2/3
|
|
self.temperature.frame = CGRectMake(30, 70, (kScreenSize.width - 2 * kPlace - 100)*2/3, 50);
|
|
self.temperature.font = [UIFont fontWithName:@"Avenir Next Condensed" size:46];
|
|
|
|
self.dulabel.frame = CGRectMake( (kScreenSize.width - 2 * kPlace - 100)*2/3,74,50, kScreenSize.width - 2 * kPlace - 210);
|
|
|
|
|
|
self.dulabel.font = [UIFont fontWithName:@"Avenir Next Condensed" size:20];
|
|
|
|
self.animView.frame= CGRectMake(0, kPlace + 80 + (kScreenSize.width - 2 * kPlace) -animViewHeight/2 - 15-80, kScreenSize.width, animViewHeight);
|
|
|
|
self.notOnLineLabel.frame = CGRectMake(40, 60, kScreenSize.width - 2 * kPlace - 100, kScreenSize.width - 2 * kPlace - 200);
|
|
self.notOnLineLabel .font = [UIFont fontWithName:@"Avenir Next Condensed" size:15];
|
|
|
|
self.hotcolLabe = [[UILabel alloc] init];
|
|
self.hotcolLabe.frame = CGRectMake(0, CGRectGetMaxY(self.temperature.frame) + 10, self.bubble.frame.size.width, 15);
|
|
//self.hotcolLabe.textColor = JWUIColorFromRGB(fc6638);
|
|
self.hotcolLabe.textAlignment = NSTextAlignmentCenter;
|
|
self.hotcolLabe.font =[UIFont systemFontOfSize:13];
|
|
self.hotcolLabe.text = @"制冷加热";
|
|
[self.bubble addSubview:self.hotcolLabe];
|
|
|
|
self.hotcolTempLabe = [[UILabel alloc] init];
|
|
self.hotcolTempLabe.frame = CGRectMake(0, CGRectGetMaxY(self.hotcolLabe.frame) + 5, self.bubble.frame.size.width, 15);
|
|
self.hotcolTempLabe.font =[UIFont systemFontOfSize:14];
|
|
self.hotcolTempLabe.textAlignment = NSTextAlignmentCenter;
|
|
self.hotcolTempLabe.textColor = JWUIColorFromRGB(0x666666);
|
|
self.hotcolTempLabe.text = @"温度";
|
|
[self.bubble addSubview:self.hotcolTempLabe];
|
|
|
|
|
|
}else{
|
|
//kScreenSize.width - 2 * kPlace - 200
|
|
self.temperature.frame = CGRectMake(10, 80, kScreenSize.width - 2 * kPlace - 100,70);
|
|
self.temperature.font = [UIFont fontWithName:@"Avenir Next Condensed" size:60];
|
|
|
|
self.bubble.frame = CGRectMake((kScreenSize.width -(kScreenSize.width - 3 * kPlace ))/2, kPlace + 80 , kScreenSize.width - 3 * kPlace, kScreenSize.width - 3 * kPlace);
|
|
|
|
self.dulabel.frame = CGRectMake((kScreenSize.width - 2 * kPlace)/3*2 -30 , 90 ,50, 60);
|
|
self.dulabel.font = [UIFont fontWithName:@"Avenir Next Condensed" size:40];
|
|
self.animView.frame= CGRectMake(0, kPlace + 40 + (kScreenSize.width - 2 * kPlace) -animViewHeight/2 - 15, kScreenSize.width, animViewHeight);
|
|
|
|
CGFloat bubH=kScreenSize.width - 3 * kPlace;
|
|
self.notOnLineLabel.frame = CGRectMake(0,bubH/2-15, bubH, 30);
|
|
self.notOnLineLabel .font = [UIFont fontWithName:@"Avenir Next Condensed" size:20];
|
|
|
|
self.hotcolLabe = [[UILabel alloc] init];
|
|
self.hotcolLabe.frame = CGRectMake(0, CGRectGetMaxY(self.temperature.frame) + 10, self.bubble.frame.size.width, 15);
|
|
//self.hotcolLabe.textColor = JWUIColorFromRGB(fc6638);
|
|
self.hotcolLabe.textAlignment = NSTextAlignmentCenter;
|
|
self.hotcolLabe.font =[UIFont systemFontOfSize:13];
|
|
[self.bubble addSubview:self.hotcolLabe];
|
|
|
|
self.hotcolTempLabe = [[UILabel alloc] init];
|
|
self.hotcolTempLabe.frame = CGRectMake(0, CGRectGetMaxY(self.hotcolLabe.frame) + 5, self.bubble.frame.size.width, 15);
|
|
self.hotcolTempLabe.font =[UIFont systemFontOfSize:14];
|
|
self.hotcolTempLabe.textAlignment = NSTextAlignmentCenter;
|
|
self.hotcolTempLabe.textColor = JWUIColorFromRGB(0x666666);
|
|
self.hotcolTempLabe.text = @"温度";
|
|
[self.bubble addSubview:self.hotcolTempLabe];
|
|
}
|
|
|
|
[self initCHNames];
|
|
}
|
|
|
|
|
|
#pragma mark - 控制按钮事件
|
|
|
|
-(void)controlBtnCilck:(UIButton *)btn{
|
|
|
|
RunSun84Protocol*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"RuSunBackMessage84bite"];
|
|
if (backmodel) {
|
|
|
|
|
|
}else{
|
|
[self.indicatorView stopAnimating];
|
|
[self deviceNotOnlineState];
|
|
[self showLableAction:@"设备已离线"];
|
|
return;
|
|
}
|
|
|
|
NSString *lightSate;
|
|
if (btn.selected) {
|
|
lightSate=@"00";
|
|
btn.selected=NO;
|
|
|
|
}else {
|
|
lightSate=@"01";
|
|
btn.selected=YES;
|
|
}
|
|
|
|
switch (btn.tag) {
|
|
|
|
case RUNSUN_CH1:
|
|
{
|
|
btn.userInteractionEnabled=YES;
|
|
[btn setImage:[UIImage imageNamed:@"PFLight1_on.png"] forState:UIControlStateSelected];
|
|
[self sendOffOnLinghtCommend:@"01" liaghtState:lightSate];
|
|
|
|
}
|
|
break;
|
|
|
|
case RUNSUN_CH2:
|
|
{
|
|
btn.userInteractionEnabled=YES;
|
|
[btn setImage:[UIImage imageNamed:@"PFLight1_on.png"] forState:UIControlStateSelected];
|
|
[self sendOffOnLinghtCommend:@"02" liaghtState:lightSate];
|
|
}
|
|
break;
|
|
case RUNSUN_CH3:
|
|
{
|
|
btn.userInteractionEnabled=YES;
|
|
[btn setImage:[UIImage imageNamed:@"PFLight1_on.png"] forState:UIControlStateSelected];
|
|
[self sendOffOnLinghtCommend:@"03" liaghtState:lightSate];
|
|
}
|
|
break;
|
|
case RUNSUN_CH4:
|
|
{
|
|
btn.userInteractionEnabled=YES;
|
|
[btn setImage:[UIImage imageNamed:@"PFLight1_on.png"] forState:UIControlStateSelected];
|
|
[self sendOffOnLinghtCommend:@"04" liaghtState:lightSate];
|
|
}
|
|
break;
|
|
|
|
case RUNSUN_GUIDENG:
|
|
{
|
|
//此款设备 柜灯在主控制界面
|
|
btn.userInteractionEnabled=YES;
|
|
[btn setImage:[UIImage imageNamed:@"PFLight1_on.png"] forState:UIControlStateSelected];
|
|
[self sendGuiDengCommend:lightSate];
|
|
|
|
}
|
|
break;
|
|
case RUNSUN_JARE:
|
|
{
|
|
if (backmodel) {
|
|
_wenduPicview=[[HaveHotCoolWenDuPicview alloc] init];
|
|
_wenduPicview.frame=CGRectMake(0, 0, kScreenSize.width, kScreenSize.height);
|
|
[_wenduPicview.sureBtn addTarget:self action:@selector(sureBtnClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
[self.view.window addSubview:_wenduPicview];
|
|
_wenduPicview.wenDuPicviewDelegate = self;
|
|
NSString *stateStr =nil;
|
|
if ([backmodel.hotCool isKindOfClass:[NSNull class]]||!backmodel.hotCool) {
|
|
backmodel.hotCool = @"0000";
|
|
}
|
|
stateStr = [backmodel.hotCool substringWithRange:NSMakeRange(2, 2)];
|
|
[_wenduPicview initCateBtnSate:stateStr];
|
|
|
|
[self ruSunJiaReMianQue];
|
|
|
|
}else{
|
|
|
|
[self showLableAction:@"设备已离线"];
|
|
}
|
|
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
#pragma mark - 发送开关灯指令
|
|
-(void)sendOffOnLinghtCommend:(NSString *)linghtNumber liaghtState:(NSString *)state
|
|
{
|
|
//此款设备无运行模式
|
|
RuSunLightOrder*lightOrder=[[RuSunLightOrder alloc]init];
|
|
lightOrder.sendmacId = self.currentDevice.macAddress;
|
|
lightOrder.resavemacId = self.currentDevice.macAddress;
|
|
NSString*switchString1=lightOrder.description;
|
|
lightOrder.switchBtn = state;
|
|
lightOrder.crc16Str=@"0000";
|
|
lightOrder.lightNumber=linghtNumber;
|
|
NSString*switchString2=[NSString stringWithFormat:@"%@%@%@%@",switchString1,lightOrder.lightNumber,lightOrder.switchBtn,lightOrder.crc16Str];
|
|
NSData*manulData=[dataContorl stringToHexData:switchString2];
|
|
[ [Socketsingleton sharedInstance] soketWriteData:manulData];
|
|
if ([Socketsingleton sharedInstance].clientSocket.isConnected) {
|
|
//soket 未断开时显示
|
|
[self initHUD];
|
|
[self.myhud myhudstart];
|
|
}
|
|
|
|
}
|
|
|
|
#pragma mark -发送柜灯指令
|
|
-(void)sendGuiDengCommend:(NSString *)lightSate
|
|
{
|
|
|
|
|
|
RuSunGuiDeng*guidengModel=[[RuSunGuiDeng alloc]init];
|
|
guidengModel.resavemacId = self.currentDevice.macAddress;
|
|
guidengModel.sendmacId = self.currentDevice.macAddress;
|
|
guidengModel.crc16Str=@"0000";
|
|
guidengModel.onOff=lightSate;
|
|
|
|
NSString* guidengOrder=[NSString stringWithFormat:@"%@%@%@",guidengModel.description,guidengModel.onOff,guidengModel.crc16Str];
|
|
NSData*guidengData=[dataContorl stringToHexData:guidengOrder];
|
|
[[Socketsingleton sharedInstance] soketWriteData:guidengData];
|
|
|
|
if ([Socketsingleton sharedInstance].clientSocket.isConnected) {
|
|
//soket 未断开时显示
|
|
[self initHUD];
|
|
[self.myhud myhudstart];
|
|
}
|
|
}
|
|
|
|
#pragma mark -加热制冷温度选择
|
|
|
|
-(void)sureBtnClick:(UIButton *)btn{
|
|
|
|
NSLog(@"%@******** _wenduPicview.picViewResultString",_wenduPicview.picViewResultString);
|
|
if (_wenduPicview.picViewResultString ==nil) {
|
|
|
|
[_wenduPicview removeFromSuperview];
|
|
|
|
}else{
|
|
|
|
JiaReWenDuModel *model=[[JiaReWenDuModel alloc] init];
|
|
model.resavemacId = self.currentDevice.macAddress;
|
|
model.sendmacId = self.currentDevice.macAddress;
|
|
int intlowString = [_wenduPicview.picViewResultString intValue];
|
|
int newIntlowString=intlowString*10;
|
|
|
|
NSLog(@"%d******** newIntlowString",newIntlowString);
|
|
// 转四位16进制
|
|
model.JiaReWenDu=[dataContorl tpIntStringToFourHex:newIntlowString];
|
|
model.crc16Code =@"0000";
|
|
|
|
NSString * hexstring=[NSString stringWithFormat:@"%@%@%@",model.description,model.JiaReWenDu,model.crc16Code];
|
|
NSData*data=[dataContorl stringToHexData:hexstring];
|
|
|
|
[ [Socketsingleton sharedInstance] soketWriteData:data];
|
|
}
|
|
|
|
[_wenduPicview removeFromSuperview];
|
|
|
|
}
|
|
|
|
-(void)ruSunJiaReMianQue
|
|
{
|
|
RunSun84Protocol*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"RuSunBackMessage84bite"];
|
|
UInt64 mac=[dataContorl hexToTen:backmodel.heatTemperature];
|
|
NSLog(@"%llu",mac);
|
|
float TPlabel=mac/10;
|
|
int temp= (int)(TPlabel+0.5);
|
|
NSString *stringFloat = [NSString stringWithFormat:@"%d",temp];
|
|
NSLog(@"%@",stringFloat);
|
|
NSArray*wenDuArr=[_wenduPicview.picArr objectAtIndex:0];
|
|
|
|
dispatch_async(_ruSunMainQueue, ^{
|
|
for (NSInteger i=0; i<wenDuArr.count; i++) {
|
|
|
|
NSString*picString=wenDuArr[i];
|
|
|
|
if ([picString isEqualToString:stringFloat ] ) {
|
|
|
|
[_wenduPicview.pic selectRow:i inComponent:0 animated:NO];
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
[super didReceiveMemoryWarning];
|
|
// Dispose of any resources that can be recreated.
|
|
}
|
|
|
|
#pragma mark - 登陆成功后收到服务端的回执之后,调用的代理方法
|
|
-(void)socketDidGetBackmsgData:(NSData *)data onsoket:(AsyncSocket *)sock{
|
|
|
|
|
|
[self.indicatorView stopAnimating];
|
|
self.temperature.hidden=NO;
|
|
//设备在线显示与设备离线相对应
|
|
self.dulabel.hidden=NO;
|
|
//设备在线显示与设备离线相对应 收到返回数据改变显示状态
|
|
self.notOnLineLabel.hidden = YES;
|
|
self.temperaturebackImg.hidden=NO;
|
|
self.hotcolTempLabe.hidden = NO;
|
|
self.hotcolLabe.hidden = NO;
|
|
|
|
[self.myhud hidmyHud];
|
|
if (_rusunHaveHeatSetVC.indicatorView) {
|
|
[_rusunHaveHeatSetVC.indicatorView stopAnimating];
|
|
}
|
|
//存储
|
|
[RuSun84BackMsgUtils readSoketDataWithBaackMassgModel:_backmodel addWithBackData:data];
|
|
|
|
// 温度 等状态
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
[RuSun84BackMsgUtils setTemperaturelabel:self.temperature addbubleImge:self.bubble WithBackData:data addWithBackMassageModel:_backmodel addWithTableview:self.tableView];
|
|
|
|
[RuSun84BackMsgUtils resetRuSunCHState:_ch1Button ch2:_ch2Button ch3:_ch3Button ch4:_ch4Button guideng:_guidengButton andJiaRe:_heatBtn withBackModel:_backmodel ];
|
|
|
|
|
|
if (!_backmodel.hotCool) {
|
|
_backmodel.hotCool = @"00";
|
|
}
|
|
NSString*stateString=[_backmodel.hotCool substringWithRange:NSMakeRange(2, IFISH_LIGHTBTN_BYTE)];
|
|
if ([stateString isEqualToString:@"00"]) {
|
|
//00加热
|
|
self.hotcolLabe.text = [NSString stringWithFormat:@"-加热-"];
|
|
self.hotcolLabe.textColor = JWUIColorFromRGB(0xfc6638);
|
|
|
|
|
|
}else{
|
|
//01制冷
|
|
self.hotcolLabe.text = [NSString stringWithFormat:@"-制冷-"];
|
|
self.hotcolLabe.textColor = JWUIColorFromRGB(0x38b9fc);
|
|
|
|
}
|
|
|
|
if (!_backmodel.heatStickState) {
|
|
_backmodel.heatStickState = @"00";
|
|
}
|
|
UInt64 mac=[dataContorl hexToTen:_backmodel.heatTemperature];
|
|
float TPlabel=mac/10;
|
|
int temp= (int)(TPlabel+0.5);
|
|
NSString *stringFloat = [NSString stringWithFormat:@"%d°C",temp];
|
|
NSLog(@"制冷加热温度%@",stringFloat);
|
|
|
|
self.hotcolTempLabe.text = stringFloat;
|
|
|
|
|
|
});
|
|
|
|
|
|
// 刷新设置界面
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
if (_rusunHaveHeatSetVC) {
|
|
_rusunHaveHeatSetVC.timeArr= [RuSun84BackMsgUtils refreshRuSunTimerAddTemperatureWithBackMassageModel:_backmodel];
|
|
[_rusunHaveHeatSetVC.tableView reloadData];
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
-(void)ifishDeviceLogInSuccees{
|
|
self.isconnect=YES;
|
|
NSLog(@"设备登录成功");
|
|
|
|
}
|
|
-(void)ifishDeviceLogInFail{
|
|
|
|
[self endRefreshing];
|
|
[self.indicatorView stopAnimating];
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
[self deviceNotOnlineState];//设备离线
|
|
self.hotcolTempLabe.hidden = YES;
|
|
self.hotcolLabe.hidden = YES;
|
|
});
|
|
}
|
|
|
|
#pragma mark -父类方法
|
|
-(void)shezhiMingCheng
|
|
{
|
|
|
|
//_changenameVC = [[RunSunChangeNameViewController alloc] init];
|
|
|
|
_changenameVC = [[RuSunInpdViewController alloc] init];
|
|
_changenameVC.name = self.name.text;
|
|
_changenameVC.device = self.currentDevice;
|
|
__weak typeof (self)wself = self;
|
|
|
|
_changenameVC.NameWithBlock = ^(NSString *nameStr){
|
|
wself.name.text = nameStr;
|
|
[wself initCHNames];
|
|
};
|
|
[ wself.navigationController pushViewController: _changenameVC animated:YES];
|
|
|
|
}
|
|
|
|
-(void)initCHNames{
|
|
|
|
RunSunCHControl * ruSunCH = [RunSunCHNameCustom currentdevice:self.currentDevice.macAddress];
|
|
self.ch1Name.text = ruSunCH.ch1name;
|
|
self.ch2Name.text = ruSunCH.ch2name;
|
|
self.ch3Name.text = ruSunCH.ch3name;
|
|
self.ch4Name.text = ruSunCH.ch4name;
|
|
self.guiDengName.text = ruSunCH.guideng;
|
|
self.jiaReName.text = ruSunCH.jiaRe;
|
|
|
|
}
|
|
#pragma mark - 制冷制热指令
|
|
-(void)didSelectCoolOrHeat:(NSString *)hotCool{
|
|
//由s5 控制 原理同灯
|
|
RuSunLightOrder*lightOrder=[[RuSunLightOrder alloc]init];
|
|
lightOrder.sendmacId = self.currentDevice.macAddress;
|
|
lightOrder.resavemacId = self.currentDevice.macAddress;
|
|
NSString*switchString1=lightOrder.description;
|
|
lightOrder.switchBtn = hotCool;
|
|
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];
|
|
if ([Socketsingleton sharedInstance].clientSocket.isConnected) {
|
|
//soket 未断开时显示
|
|
[self initHUD];
|
|
[self.myhud myhudstart];
|
|
}
|
|
}
|
|
|
|
|
|
@end
|