1983 lines
76 KiB
Objective-C
1983 lines
76 KiB
Objective-C
//
|
||
// MonitorBootmView.m
|
||
// Ifish
|
||
//
|
||
// Created by imac on 16/6/28.
|
||
// Copyright © 2016年 lianxiang. All rights reserved.
|
||
//
|
||
|
||
#import "MonitorBootmView.h"
|
||
|
||
#import "DeviceModel.h"
|
||
#import "ifishdeviceListCell.h"
|
||
#import "FishControlFirstCell.h"
|
||
#import "FishControlSecondCell.h"
|
||
#import "FishControlThreedViewCell.h"
|
||
#import "FishControlFourthCell.h"
|
||
#import "DeviceCameraModel.h"
|
||
#import "manulswitchMSModel.h"
|
||
#import "IfishDeviceInfo.h"
|
||
#import "RunSunCHNameCustom.h"
|
||
#import "RunSunCHControl.h"
|
||
#import "RunSunControlName.h"
|
||
#import "UserExtendataArchaver.h"
|
||
#import "SongNuo86Name.h"
|
||
#import "SongNuo128Name.h"
|
||
#import "TwoControlName.h"
|
||
#import "ThreeControlName.h"
|
||
#import "FourControlName.h"
|
||
#import "XuToControlName.h"
|
||
#import "RuiMeiCHNameCustom.h"
|
||
#import "RuiMeiCHControl.h"
|
||
|
||
@implementation MonitorBootmView
|
||
|
||
-(id)initWithFrame:(CGRect)frame
|
||
{
|
||
self=[super initWithFrame:frame];
|
||
|
||
if (self) {
|
||
|
||
//[self initTableDatasource];
|
||
frameHeight = frame.size.height; //fram 高度
|
||
viewFrame = frame;
|
||
_isBindIfishDevice = [self testIsbindDeviceOrNot];
|
||
|
||
if ( _isBindIfishDevice) {
|
||
//已建立关系
|
||
|
||
[self setCollectionFrame:frame];
|
||
|
||
[self initSoket];
|
||
|
||
|
||
}else{
|
||
//未建立关系
|
||
|
||
[self setTabViewWithFrame:frame];
|
||
}
|
||
|
||
self.backgroundColor = [UIColor whiteColor];
|
||
|
||
}
|
||
|
||
return self;
|
||
|
||
}
|
||
|
||
-(BOOL)testIsbindDeviceOrNot{
|
||
|
||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||
|
||
NSString *cameraId=[userdefult valueForKey:@"OnShowCameraId"];
|
||
|
||
NSArray *devicCameraArr = [[DataCenter defaultDtacenter]
|
||
valueForKey:@"devicamerArr"];
|
||
|
||
NSMutableArray *camerwIdArr = [[NSMutableArray alloc] init];
|
||
|
||
for (DeviceCameraModel *camera in devicCameraArr) {
|
||
|
||
[camerwIdArr addObject:camera.cameraId];
|
||
|
||
}
|
||
|
||
BOOL exst=[camerwIdArr containsObject:cameraId];
|
||
|
||
if (exst) {
|
||
return YES;
|
||
}
|
||
return NO;
|
||
}
|
||
|
||
|
||
-(void)initTableDatasource{
|
||
|
||
NSArray*devicearray=[[DataCenter defaultDtacenter]
|
||
valueForKey:@"deviceInfo"];
|
||
|
||
NSMutableArray * devicCameraArr = [[DataCenter defaultDtacenter]
|
||
valueForKey:@"devicamerArr"];
|
||
NSMutableArray*arr=[[NSMutableArray alloc] init];
|
||
NSMutableArray *devceIdArr=[[NSMutableArray alloc] init];
|
||
for (DeviceModel *model in devicearray) {
|
||
//判断是否授权 未授权不显示 而且是主控制 在列表中显示
|
||
|
||
if ([model.isBlacklist isEqual:[NSNull null]]) {
|
||
model.isBlacklist = @"1";
|
||
}
|
||
if (!model.isMaster) {
|
||
model.isMaster = @"0";
|
||
}
|
||
|
||
for (DeviceCameraModel *camera in devicCameraArr) {
|
||
[devceIdArr addObject:camera.deviceId];
|
||
}
|
||
BOOL isHaveRalate=[devceIdArr containsObject:model.deviceId];
|
||
|
||
if ([model.isBlacklist isEqualToString:@"0"]&&[model.isMaster isEqualToString:@"1"]&& !isHaveRalate) {
|
||
|
||
//为关联摄像头 展示
|
||
[arr addObject:model];
|
||
|
||
}
|
||
}
|
||
|
||
self.ifishDeviceArr=arr;
|
||
|
||
}
|
||
-(void)setCollectionFrame:(CGRect)frame{
|
||
|
||
NSLog(@"控制界面");
|
||
self.device = [self getDeviceModel];
|
||
|
||
[self setDataArr];
|
||
self.flowLayout = [[UICollectionViewFlowLayout alloc] init];
|
||
self.flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
|
||
|
||
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0,0,self.frame.size.width, self.frame.size.height) collectionViewLayout:self.flowLayout];
|
||
self.collectionView.backgroundColor =[UIColor whiteColor];
|
||
|
||
self.collectionView.delegate = self;
|
||
self.collectionView.dataSource = self;
|
||
self.collectionView.showsVerticalScrollIndicator = NO;
|
||
|
||
[self addSubview:self.collectionView];
|
||
|
||
[self.collectionView registerClass:[FishControlFirstCell class] forCellWithReuseIdentifier:@"FishControlFirstCell"];
|
||
[self.collectionView registerClass:[FishControlSecondCell class] forCellWithReuseIdentifier:@"FishControlSecondCell"];
|
||
[self.collectionView registerClass:[FishControlThreedViewCell class] forCellWithReuseIdentifier:@"FishControlThreedViewCell"];
|
||
[self.collectionView registerClass:[FishControlFourthCell class] forCellWithReuseIdentifier:@"FishControlFourthCell"];
|
||
|
||
}
|
||
|
||
#pragma mark 获取设备model collection 数据源
|
||
|
||
/**
|
||
* 只有建立关系后才会展示控制view
|
||
*/
|
||
|
||
-(DeviceModel *)getDeviceModel{
|
||
|
||
DeviceModel *devmodel=nil;
|
||
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
|
||
NSString *cameraId=[userdefult valueForKey:@"OnShowCameraId"];
|
||
NSString *deviceId =nil;
|
||
|
||
NSArray *devicCameraArr = [[DataCenter defaultDtacenter] valueForKey:@"devicamerArr"];
|
||
|
||
|
||
//根据camerID 找到设备id
|
||
for (DeviceCameraModel *model in devicCameraArr) {
|
||
|
||
if ([model.cameraId isEqual:cameraId]) {
|
||
|
||
deviceId= model.deviceId;
|
||
|
||
}
|
||
|
||
}
|
||
//根据设备id获取对应model
|
||
|
||
NSArray*devicearray=[[DataCenter defaultDtacenter] valueForKey:@"deviceInfo"];
|
||
|
||
for (DeviceModel *dmodel in devicearray) {
|
||
|
||
if ([dmodel.deviceId isEqual:deviceId]) {
|
||
|
||
devmodel = dmodel;
|
||
}
|
||
|
||
}
|
||
return devmodel;
|
||
|
||
}
|
||
|
||
//-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
|
||
//
|
||
// NSLog(@"开始滑动");
|
||
//}
|
||
|
||
-(void)setTabViewWithFrame:(CGRect)frame{
|
||
[self initTableDatasource];
|
||
if ([self.ifishDeviceArr count]!=0) {
|
||
// 存在水族箱设备
|
||
|
||
self.tableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStylePlain];
|
||
|
||
self.tableView.delegate = self;
|
||
self.tableView.dataSource = self;
|
||
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||
|
||
self.tableView.scrollEnabled = YES;
|
||
//self.tableView.backgroundColor = [UIColor greenColor];
|
||
self.tableView.backgroundColor = RGB(242, 242, 242);
|
||
|
||
[self.tableView registerClass:[ifishdeviceListCell class] forCellReuseIdentifier:@"ifishdeviceListCell"];
|
||
[self addSubview:self.tableView];
|
||
|
||
// UIButton *sureBtn=[UIButton buttonWithType:UIButtonTypeCustom];
|
||
// sureBtn.frame =CGRectMake(10,frameHeight - frameHeight/7, kScreenSize.width -10*2, frameHeight/7);
|
||
// [sureBtn setTitle:@"确定" forState:UIControlStateNormal];
|
||
// sureBtn.layer.masksToBounds = YES;
|
||
// sureBtn.layer.cornerRadius =5;
|
||
// sureBtn.backgroundColor = COLOR_LABEL_TITLE;
|
||
// [sureBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
|
||
// [self.tableView addSubview:sureBtn];
|
||
|
||
|
||
}else{
|
||
|
||
UIButton *notbindBtn=[UIButton buttonWithType:UIButtonTypeCustom];
|
||
|
||
|
||
NSString *title=@"您暂无可用的水族箱,前往绑定。";
|
||
|
||
[notbindBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
|
||
NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:title];
|
||
NSMutableParagraphStyle * paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
||
[paragraphStyle setLineSpacing:8];
|
||
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [title length])];
|
||
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0 green:170.0/255.0 blue:218.0/255.0 alpha:1] range:NSMakeRange(9,5)];
|
||
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(0,10)];
|
||
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange([title length]-1,1)];
|
||
[notbindBtn setAttributedTitle:attributedString forState:UIControlStateNormal];
|
||
[notbindBtn sizeToFit];
|
||
notbindBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
|
||
|
||
CGFloat btnTitleW =[self widthForString:notbindBtn.titleLabel.text fontSize:20 andHeight:10];
|
||
CGFloat btnTitleH = [self heightForString:notbindBtn.titleLabel.text fontSize:20 andWidth:btnTitleW];
|
||
|
||
notbindBtn.frame =CGRectMake(self.frame.size.width/2 -btnTitleW/2,self.frame.size.height/2 -btnTitleH/2, btnTitleW, btnTitleH);
|
||
|
||
[notbindBtn addTarget:self action:@selector(noCanUserDeviceClick) forControlEvents:UIControlEventTouchUpInside];
|
||
[self addSubview:notbindBtn];
|
||
|
||
[self.tableView removeFromSuperview];
|
||
|
||
}
|
||
|
||
}
|
||
//无可用水族箱前往绑定按钮
|
||
-(void)noCanUserDeviceClick{
|
||
|
||
[self.MonitorBottomDelegate noCanuserDevicePush];
|
||
|
||
}
|
||
|
||
#pragma mark -表格
|
||
//多少段
|
||
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
||
|
||
return 1;
|
||
}
|
||
|
||
|
||
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||
|
||
return 5;
|
||
}
|
||
|
||
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||
//最多绑定 5个水族箱设备 所以这里取最多情况
|
||
|
||
|
||
return frameHeight/7;
|
||
|
||
|
||
}
|
||
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
|
||
|
||
return frameHeight/7;
|
||
|
||
}
|
||
|
||
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
||
return frameHeight/7;
|
||
}
|
||
//头视图
|
||
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
||
UIView *headerView = [[UIView alloc] init];
|
||
//[headerView setBackgroundColor:XBGAlpha];
|
||
[headerView setBackgroundColor:RGB(242, 242, 242)];
|
||
UILabel *readLabel=[[UILabel alloc] init ];
|
||
readLabel.text = @"请选择一个水族箱,和摄像头建立关系";
|
||
|
||
NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:readLabel.text ];
|
||
|
||
CGFloat labelW=[self widthForString:readLabel.text fontSize:20 andHeight:10];
|
||
CGFloat labelH=[self heightForString:readLabel.text fontSize:20 andWidth:labelW];
|
||
//frameHeight/7 -labelH/2
|
||
readLabel.frame = CGRectMake(30,5,labelW,labelH);
|
||
[readLabel setAttributedText:attributedString];
|
||
readLabel.textColor = [UIColor blackColor];
|
||
|
||
[headerView addSubview:readLabel];
|
||
[tableView setTableHeaderView:headerView];
|
||
return headerView;
|
||
}
|
||
//脚视图
|
||
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
|
||
|
||
UIView *footerView = [[UIView alloc] init];
|
||
//[headerView setBackgroundColor:XBGAlpha];
|
||
|
||
[footerView setBackgroundColor:RGB(242, 242, 242)];
|
||
|
||
UIButton *sureBtn=[UIButton buttonWithType:UIButtonTypeCustom];
|
||
sureBtn.frame =CGRectMake(10, 0, kScreenSize.width -10*2, frameHeight/7);
|
||
[sureBtn setTitle:@"确定" forState:UIControlStateNormal];
|
||
sureBtn.layer.masksToBounds = YES;
|
||
sureBtn.layer.cornerRadius =5;
|
||
sureBtn.backgroundColor = COLOR_LABEL_TITLE;
|
||
[sureBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
|
||
[footerView addSubview:sureBtn];
|
||
[tableView setTableFooterView:footerView];
|
||
return footerView;
|
||
|
||
}
|
||
|
||
#pragma mark- 确定绑定点击事件
|
||
|
||
-(void)btnClick:(UIButton *)btn{
|
||
|
||
NSArray*devicearray=[[DataCenter defaultDtacenter]
|
||
valueForKey:@"deviceInfo"];
|
||
|
||
|
||
NSMutableArray*arr=[[NSMutableArray alloc]init];
|
||
NSMutableArray *devceIdArr=[[NSMutableArray alloc] init];
|
||
NSMutableArray * devicCameraArr = [[DataCenter defaultDtacenter]
|
||
valueForKey:@"devicamerArr"];
|
||
for (DeviceModel *model in devicearray) {
|
||
//判断是否授权 未授权不显示 而且是主控制 在列表中显示 还要判断设备是否已经关联摄像头 已经关联不展示
|
||
|
||
if ([model.isBlacklist isEqual:[NSNull null]]) {
|
||
model.isBlacklist = @"1";
|
||
}
|
||
if (!model.isMaster) {
|
||
model.isMaster = @"0";
|
||
}
|
||
|
||
|
||
|
||
for (DeviceCameraModel *camera in devicCameraArr) {
|
||
[devceIdArr addObject:camera.deviceId];
|
||
}
|
||
BOOL isHaveRalate=[devceIdArr containsObject:model.deviceId];
|
||
|
||
if ([model.isBlacklist isEqualToString:@"0"]&&[model.isMaster isEqualToString:@"1"]&&!isHaveRalate) {
|
||
|
||
//为关联摄像头 展示
|
||
[arr addObject:model];
|
||
|
||
|
||
}
|
||
|
||
}
|
||
|
||
NSInteger index=tapIndex.row;
|
||
|
||
if (!index) {
|
||
|
||
index = 0;
|
||
|
||
}
|
||
|
||
self.device = arr[index];
|
||
|
||
[self bidDeviceAddCamerawithdeviceId:self.device.deviceId];
|
||
|
||
}
|
||
|
||
-(void)bidDeviceAddCamerawithdeviceId:(NSString *)deviceId{
|
||
|
||
NSString *usId =[dataContorl dataControlGetUserIdInfo];
|
||
NSNumber *userId =(NSNumber *)usId ;
|
||
[AFNOHeaderHttpTool deviceBindCameraWith:self.cameraId userId:userId deviceId:deviceId success:^(id response) {
|
||
|
||
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||
|
||
NSString *result= reDic[@"result"] ;
|
||
|
||
if ([result isEqualToString:IFISHERROCODE]) {
|
||
// 设置代理展示解绑按钮
|
||
|
||
[self.MonitorBottomDelegate cameraBindDeviceSuccess];
|
||
[self makeToast:@"设置成功"];
|
||
|
||
//存储摄像头设备关系数组
|
||
NSArray *devicCameraArr = [[DataCenter defaultDtacenter] valueForKey:@"devicamerArr"];
|
||
DeviceCameraModel *devicecamera=[[DeviceCameraModel alloc] init];
|
||
devicecamera.cameraId = self.cameraId;
|
||
devicecamera.deviceId = deviceId;
|
||
|
||
NSMutableArray *camerwIdArr = [[NSMutableArray alloc] initWithArray:devicCameraArr];
|
||
|
||
if (!camerwIdArr) {
|
||
|
||
camerwIdArr =[[NSMutableArray alloc] init];
|
||
|
||
}
|
||
[camerwIdArr addObject:devicecamera];
|
||
|
||
[[DataCenter defaultDtacenter]setValue:camerwIdArr forKey:@"devicamerArr"];
|
||
|
||
[self removeTable];
|
||
|
||
|
||
}else if([result isEqualToString:IFFISHFAIL]){
|
||
|
||
[self makeToast:@"设置失败"];
|
||
|
||
}else if([result isEqualToString:IFISHDEVICE_REMOVE]){
|
||
|
||
[self makeToast:@"设备不存在,错误码207"];
|
||
|
||
NSArray*deviceArry=[[DataCenter defaultDtacenter]valueForKey:@"deviceInfo"];
|
||
NSMutableArray *newArr = [NSMutableArray arrayWithArray:deviceArry];
|
||
|
||
for (DeviceModel *model in deviceArry) {
|
||
|
||
if ([model.deviceId isEqual:deviceId]) {
|
||
|
||
[newArr removeObject:model];
|
||
|
||
}
|
||
|
||
}
|
||
|
||
[[DataCenter defaultDtacenter] setValue: newArr forKey:@"deviceInfo"];
|
||
|
||
[self setTabViewWithFrame:viewFrame];
|
||
|
||
}else if([result isEqualToString:IFISHCAMERA_REMOVE]){
|
||
|
||
NSArray*cameraArry=[[DataCenter defaultDtacenter]valueForKey:@"cameraArr"];
|
||
|
||
NSMutableArray *newArr = [NSMutableArray arrayWithArray:cameraArry];
|
||
|
||
|
||
for (IfishCameraModel *model in cameraArry) {
|
||
|
||
if ([model.cameraId isEqual:self.cameraId]) {
|
||
|
||
[newArr removeObject:model];
|
||
|
||
}
|
||
|
||
}
|
||
|
||
[[DataCenter defaultDtacenter] setValue: newArr forKey:@"cameraArr"];
|
||
|
||
[self makeToast:@"摄像头不存在,错误码210"];
|
||
|
||
[self performSelector:@selector(cameraJieBang) withObject:self afterDelay:1.6];
|
||
|
||
|
||
|
||
}
|
||
|
||
} failure:^(NSError *err) {
|
||
|
||
[self makeToast:@"网络异常"];
|
||
|
||
}];
|
||
|
||
}
|
||
|
||
-(void)removeTable{
|
||
|
||
// __weak typeof(self) wekself =self;
|
||
[UIView animateWithDuration:2.0 animations:^{
|
||
|
||
[self.tableView removeFromSuperview];
|
||
|
||
} completion:^(BOOL finished) {
|
||
|
||
[self setCollectionFrame: viewFrame];
|
||
[self initSoket];
|
||
|
||
}];
|
||
}
|
||
|
||
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
|
||
{
|
||
//cell.backgroundColor = COLOR_MIAN;
|
||
|
||
}
|
||
|
||
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||
|
||
|
||
if(indexPath.row<self.ifishDeviceArr.count) {
|
||
ifishdeviceListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ifishdeviceListCell"];
|
||
if(cell==nil){
|
||
|
||
cell = [[ifishdeviceListCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ifishdeviceListCell"];
|
||
|
||
}
|
||
|
||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||
|
||
[cell setcellImgAtindex:indexPath withSelectIndex:tapIndex];
|
||
|
||
DeviceModel *model=self.ifishDeviceArr[indexPath.row];
|
||
NSString *str= model.showName;
|
||
[cell setTitleAtIndex:indexPath withdeviceName:str];
|
||
cell.backgroundColor = RGB(242, 242, 242);
|
||
|
||
return cell;
|
||
}else{
|
||
|
||
static NSString *cellID=@"kongCell";
|
||
UITableViewCell *kongCell=[tableView dequeueReusableCellWithIdentifier:cellID];
|
||
|
||
if (kongCell==nil) {
|
||
|
||
kongCell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
|
||
}
|
||
kongCell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||
//关闭用户交互
|
||
kongCell.userInteractionEnabled = NO;
|
||
kongCell.backgroundColor = [UIColor clearColor];
|
||
|
||
return kongCell;
|
||
}
|
||
|
||
}
|
||
|
||
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
||
|
||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||
|
||
tapIndex =indexPath;
|
||
//刷新界面
|
||
[self.tableView reloadData];
|
||
|
||
}
|
||
|
||
|
||
#pragma mark -collection
|
||
#pragma 设置item size
|
||
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
|
||
{
|
||
|
||
return CGSizeMake((self.frame.size.width-2)/3, (self.frame.size.width-2)/3);
|
||
|
||
}
|
||
|
||
//距离上下左右的间距
|
||
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
|
||
{
|
||
|
||
return UIEdgeInsetsMake(0, 0, 0, 0);
|
||
|
||
}
|
||
|
||
|
||
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
|
||
{
|
||
//设置最小的列间距
|
||
|
||
return 1.0f;
|
||
|
||
}
|
||
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
|
||
{
|
||
//设置最小的行间距
|
||
return 1.0f;
|
||
}
|
||
|
||
#pragma mark UICollectionViewDataSource
|
||
|
||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||
|
||
if ([self.device.type isEqualToString:DECICE_TYPE_THREETMP]) {
|
||
//带加热棒 睿芯
|
||
return 3 + self.device.controlAmount.integerValue +1;
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_RUSUN2A]){
|
||
|
||
return 3 + 6;
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_JUNENGCC]){
|
||
return 3 + self.device.controlAmount.integerValue +1;;
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_SONGNEWBD]){
|
||
|
||
return 3 + self.device.controlAmount.integerValue +1;
|
||
|
||
} else if ([self.device.type isEqualToString:DECICE_TYPE_RUIMEI]) {
|
||
return 3 + 5;
|
||
} else {
|
||
|
||
if (self.device.controlAmount.integerValue ==5) {
|
||
|
||
return 3 + self.device.controlAmount.integerValue +1;
|
||
}else if (self.device.controlAmount.integerValue ==4 && self.device.timerAmount.integerValue == 6){
|
||
//可丽爱
|
||
return 3 + self.device.controlAmount.integerValue +1;
|
||
|
||
}else{
|
||
return 3 + self.device.controlAmount.integerValue;
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
#pragma mark 点击item方法
|
||
|
||
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
|
||
// NSLog(@"点%ld",(long)indexPath.row);
|
||
//新加字段 硬件类型 type
|
||
if ([self.device.type isEqual:[NSNull null]]||!self.device.type) {
|
||
[self makeToast:@"未知设备类型"];
|
||
return;
|
||
}
|
||
|
||
//第一行事件
|
||
if (indexPath.row <3) {
|
||
|
||
if (self.MonitorBottomDelegate ) {
|
||
|
||
//硬件型号: 1c 三控(温控),硬件型号:cc 四川聚能 松诺新bd
|
||
if ([self.device.type isEqualToString:DECICE_TYPE_THREETMP]) {
|
||
if (!_ruSunBack) {
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
|
||
[self.MonitorBottomDelegate didselectCollectionIex:indexPath
|
||
withData:self.device
|
||
addMassglength:self.dataLength];
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_RUSUN2A]){
|
||
|
||
if (!_ruSun84Back) {
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
|
||
[self.MonitorBottomDelegate didselectCollectionIex:indexPath
|
||
withData:self.device
|
||
addMassglength:self.dataLength];
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_RUIMEI]){
|
||
|
||
if (!_ruiMeiBack) {
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
|
||
[self.MonitorBottomDelegate didselectCollectionIex:indexPath
|
||
withData:self.device
|
||
addMassglength:self.dataLength];
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_JUNENGCC]){
|
||
|
||
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_SONGNEWBD]){
|
||
//松诺新86 字节
|
||
if (!_songNuoBDBack) {
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
|
||
[self.MonitorBottomDelegate didselectCollectionIex:indexPath
|
||
withData:self.device
|
||
addMassglength:self.dataLength];
|
||
|
||
}else{
|
||
|
||
int controlAmount=[self.device.controlAmount intValue];
|
||
switch (controlAmount) {
|
||
case IFISH_DEVICE_CONTROLAMOUNT0:
|
||
{
|
||
|
||
if (!_zeroBckModel) {
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
|
||
[self.MonitorBottomDelegate didselectCollectionIex:indexPath
|
||
withData:self.device
|
||
addMassglength:self.dataLength];
|
||
|
||
|
||
}
|
||
break;
|
||
case IFISH_DEVICE_CONTROLAMOUNT2:
|
||
{
|
||
//2空
|
||
|
||
if (!_backModel1 && !_twoControlBack) {
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
|
||
[self.MonitorBottomDelegate didselectCollectionIex:indexPath
|
||
withData:self.device
|
||
addMassglength:self.dataLength];
|
||
|
||
}
|
||
break;
|
||
case IFISH_DEVICE_CONTROLAMOUNT3:
|
||
{
|
||
//3空
|
||
if (!_backModel1) {
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
|
||
[self.MonitorBottomDelegate didselectCollectionIex:indexPath
|
||
withData:self.device
|
||
addMassglength:self.dataLength];
|
||
|
||
|
||
}
|
||
break;
|
||
case IFISH_DEVICE_CONTROLAMOUNT4:
|
||
{
|
||
|
||
//4空
|
||
int timerAmount=[self.device.timerAmount intValue];
|
||
|
||
if (timerAmount ==8) {
|
||
|
||
if (!_fourControlbackmodel) {
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
|
||
[self.MonitorBottomDelegate didselectCollectionIex:indexPath
|
||
withData:self.device
|
||
addMassglength:self.dataLength];
|
||
}else if (timerAmount ==6){
|
||
//可丽爱
|
||
if (!_keLiAiBackmodel) {
|
||
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
|
||
[self.MonitorBottomDelegate didselectCollectionIex:indexPath
|
||
withData:self.device
|
||
addMassglength:self.dataLength];
|
||
|
||
}
|
||
}
|
||
break;
|
||
|
||
|
||
case IFISH_DEVICE_CONTROLAMOUNT5:
|
||
{
|
||
//5空
|
||
|
||
if (!_xutoback) {
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
|
||
[self.MonitorBottomDelegate didselectCollectionIex:indexPath
|
||
withData:self.device
|
||
addMassglength:self.dataLength];
|
||
|
||
|
||
}
|
||
break;
|
||
|
||
|
||
case IFISH_DEVICE_CONTROLAMOUNT6:
|
||
{
|
||
//6空
|
||
|
||
|
||
}
|
||
break;
|
||
case IFISH_DEVICE_CONTROLAMOUNT8:
|
||
{
|
||
//8空
|
||
if (!_songNuoBackMassage) {
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
|
||
[self.MonitorBottomDelegate didselectCollectionIex:indexPath
|
||
withData:self.device
|
||
addMassglength:self.dataLength];
|
||
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
|
||
}
|
||
|
||
}
|
||
|
||
return;
|
||
}
|
||
|
||
//第二行起事件
|
||
//硬件型号: 1c 三控(温控),硬件型号:cc 四川聚能 松诺新bd
|
||
if ([self.device.type isEqualToString:DECICE_TYPE_THREETMP]) {
|
||
|
||
if (!_ruSunBack) {
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
if (indexPath.row == 6) {
|
||
|
||
//点击加热棒
|
||
[self.MonitorBottomDelegate selectRuSunIndex:indexPath withbackModle:_ruSunBack];
|
||
|
||
}else{
|
||
[BootomViewSoketBackMasgConreol RusunCommandSelectorWithBackMode148:_ruSunBack atindexPath:indexPath];
|
||
[self makeToastActivity];
|
||
}
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_RUSUN2A]){
|
||
if (!_ruSun84Back) {
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
if (indexPath.row == 8) {
|
||
|
||
//点击加热棒
|
||
[self.MonitorBottomDelegate selectRuSun84Index:indexPath withbackModle:_ruSun84Back];
|
||
|
||
}else{
|
||
|
||
[BootomViewSoketBackMasgConreol RusunCommandSelectorWithBackMode168:_ruSun84Back atindexPath:indexPath];
|
||
[self makeToastActivity];
|
||
}
|
||
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_RUIMEI]){
|
||
if (!_ruiMeiBack) {
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
if (indexPath.row == 7) {
|
||
|
||
//点击加热棒
|
||
[self.MonitorBottomDelegate selectRuiMeiIndex:indexPath withbackModle:_ruiMeiBack];
|
||
|
||
}else{
|
||
|
||
[BootomViewSoketBackMasgConreol RuiMeiCommandSelectorWithBackMode168:_ruiMeiBack atindexPath:indexPath];
|
||
[self makeToastActivity];
|
||
}
|
||
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_JUNENGCC]){
|
||
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_SONGNEWBD]){
|
||
if (!_songNuoBDBack) {
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
|
||
if (indexPath.row == 6) {
|
||
//点击加热棒
|
||
[self.MonitorBottomDelegate selectSongNuoBDIndex:indexPath withBackModel:_songNuoBDBack];
|
||
|
||
}else{
|
||
[BootomViewSoketBackMasgConreol SongnuoBDCommandSelectorWithBackMode86:_songNuoBDBack atindexPath:indexPath];
|
||
}
|
||
[self makeToastActivity];
|
||
|
||
}else{
|
||
|
||
int controlAmount=[self.device.controlAmount intValue];
|
||
|
||
switch (controlAmount) {
|
||
case IFISH_DEVICE_CONTROLAMOUNT0:
|
||
{
|
||
//可不做处理
|
||
|
||
}
|
||
break;
|
||
case IFISH_DEVICE_CONTROLAMOUNT2:
|
||
{
|
||
//2空
|
||
|
||
if (!self.dataLength) {
|
||
//没返回数据
|
||
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
|
||
}
|
||
|
||
if (IFISH_BACKMASGTYAP99 ==self.dataLength ) {
|
||
|
||
[BootomViewSoketBackMasgConreol TwoControlCommandSelectorWithBackModel99:_backModel1 atindexPath:indexPath];
|
||
|
||
|
||
}else if (IFISH_BACKMASGTYAP57==self.dataLength){
|
||
|
||
[BootomViewSoketBackMasgConreol TwoControlCommandSelectorWithBackModel57:_twoControlBack atindexPath:indexPath];
|
||
}
|
||
|
||
[self makeToastActivity];
|
||
|
||
}
|
||
break;
|
||
case IFISH_DEVICE_CONTROLAMOUNT3:
|
||
{
|
||
//3空
|
||
|
||
if (!_backModel1) {
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
[BootomViewSoketBackMasgConreol threeControlCommandSelectorWithBackModel:_backModel1 atindexPath:indexPath];
|
||
[self makeToastActivity];
|
||
|
||
|
||
|
||
}
|
||
break;
|
||
case IFISH_DEVICE_CONTROLAMOUNT4:
|
||
{
|
||
//4空
|
||
|
||
int timerAmount=[self.device.timerAmount intValue];
|
||
|
||
if (timerAmount == 8) {
|
||
if (!_fourControlbackmodel) {
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
|
||
[BootomViewSoketBackMasgConreol FourControlCommandSelectorWithBackModel85:_fourControlbackmodel atindexPath:indexPath];
|
||
[self makeToastActivity];
|
||
|
||
}else if (timerAmount == 6){
|
||
//可丽爱
|
||
|
||
if (!_keLiAiBackmodel) {
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
|
||
if (indexPath.row ==7) {
|
||
//点击加热棒
|
||
[self.MonitorBottomDelegate selctKeLiAiIndex:indexPath withBackModel:_keLiAiBackmodel];
|
||
|
||
|
||
}else{
|
||
|
||
[BootomViewSoketBackMasgConreol KeLiAiCommandSelectorWithBackModel72:_keLiAiBackmodel atindexPath:indexPath];
|
||
|
||
|
||
[self makeToastActivity];
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
break;
|
||
|
||
|
||
case IFISH_DEVICE_CONTROLAMOUNT5:
|
||
{
|
||
//5空
|
||
|
||
if (!_xutoback) {
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
|
||
|
||
if (IFISH_BACKMASGTYAP73 == self.dataLength ){
|
||
if (indexPath.row == 7 || indexPath.row ==8 ) {
|
||
|
||
[self.MonitorBottomDelegate selectXuToAtIndex:indexPath withbackModel:_xutoback];
|
||
|
||
}else{
|
||
[self makeToastActivity];
|
||
[BootomViewSoketBackMasgConreol XuToControlCommandSelectorWithBackModel73:_xutoback atindexPath:indexPath];
|
||
}
|
||
|
||
|
||
}
|
||
|
||
}
|
||
break;
|
||
|
||
|
||
case IFISH_DEVICE_CONTROLAMOUNT6:
|
||
{
|
||
//6空
|
||
|
||
[self makeToastActivity];
|
||
}
|
||
break;
|
||
case IFISH_DEVICE_CONTROLAMOUNT8:
|
||
{
|
||
//8空
|
||
|
||
|
||
if (!_songNuoBackMassage) {
|
||
[self makeToast:@"暂未连接"];
|
||
return;
|
||
}
|
||
|
||
|
||
if (IFISH_BACKMASGTYAP128 == self.dataLength ){
|
||
if ( indexPath.row ==10 ) {
|
||
|
||
[self.MonitorBottomDelegate slectSongNuoInde:indexPath withBackModel:_songNuoBackMassage];
|
||
|
||
|
||
}else{
|
||
|
||
|
||
[self makeToastActivity];
|
||
|
||
[BootomViewSoketBackMasgConreol SongNuoControlCommandSelectorWithBackModel128:_songNuoBackMassage atindexPath:indexPath];
|
||
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
#pragma mark 加载脚步视图
|
||
//- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
|
||
|
||
// if (indexPath.section == 0) {
|
||
//
|
||
// if (kind == UICollectionElementKindSectionFooter) {
|
||
//
|
||
//
|
||
// return nil;
|
||
//
|
||
// }else{
|
||
// return nil;
|
||
//
|
||
// }
|
||
//
|
||
//
|
||
// }else{
|
||
//
|
||
//
|
||
// return nil;
|
||
// }
|
||
|
||
|
||
//}
|
||
//-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
|
||
//{
|
||
//
|
||
//
|
||
//
|
||
// return CGSizeMake(,);
|
||
//
|
||
//}
|
||
|
||
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
|
||
{
|
||
return 1;
|
||
}
|
||
#pragma mark 设置item内容
|
||
|
||
-(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||
|
||
if (indexPath.row ==0) {
|
||
FishControlFirstCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"FishControlFirstCell" forIndexPath:indexPath];
|
||
|
||
cell.backgroundColor = [UIColor whiteColor];
|
||
|
||
[cell intiFactoryImgWith: self.device];
|
||
|
||
return cell;
|
||
|
||
}else if (indexPath.row == 1){
|
||
//温度
|
||
|
||
FishControlSecondCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"FishControlSecondCell" forIndexPath:indexPath];
|
||
|
||
cell.backgroundColor = [UIColor whiteColor];
|
||
[cell setTemWith:self.temperature];
|
||
|
||
return cell;
|
||
|
||
}else if (indexPath.row == 2){
|
||
|
||
FishControlThreedViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"FishControlThreedViewCell" forIndexPath:indexPath];
|
||
|
||
cell.backgroundColor = [UIColor whiteColor];
|
||
return cell;
|
||
}else {
|
||
|
||
|
||
FishControlFourthCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"FishControlFourthCell" forIndexPath:indexPath];
|
||
|
||
cell.backgroundColor = [UIColor whiteColor];
|
||
cell.btnName.text = self.btnNameArr [indexPath.row - 3];
|
||
|
||
cell.tag = 10000*indexPath.row - 3;
|
||
|
||
if ([self.device.type isEqualToString:DECICE_TYPE_THREETMP]) {
|
||
|
||
if (!_ruSunBack) {
|
||
cell.controBtnImg.image = self.btnImgArr[indexPath.row - 3];
|
||
[self makeToast:@"连接设备中..."];
|
||
}
|
||
|
||
[cell setRusuanTmpControlBtnImg:self.btnImgArr addArr:self.btnOnImgArr atIndex:indexPath addBackModel:_ruSunBack];
|
||
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_RUSUN2A]){
|
||
|
||
if (!_ruSun84Back) {
|
||
cell.controBtnImg.image = self.btnImgArr[indexPath.row - 3];
|
||
[self makeToast:@"连接设备中..."];
|
||
}
|
||
|
||
[cell setRusuan84ControlBtnImg:self.btnImgArr addArr:self.btnOnImgArr atIndex:indexPath addBackModel:_ruSun84Back];
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_RUIMEI]){
|
||
|
||
if (!_ruiMeiBack) {
|
||
cell.controBtnImg.image = self.btnImgArr[indexPath.row - 3];
|
||
[self makeToast:@"连接设备中..."];
|
||
}
|
||
|
||
[cell setRuiMeiControlBtnImg:self.btnImgArr addArr:self.btnOnImgArr atIndex:indexPath addBackModel:_ruiMeiBack];
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_JUNENGCC]){
|
||
|
||
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_SONGNEWBD]){
|
||
|
||
if (!_songNuoBDBack) {
|
||
cell.controBtnImg.image = self.btnImgArr[indexPath.row - 3];
|
||
[self makeToast:@"连接设备中..."];
|
||
}
|
||
|
||
[cell setSongNuoBDControBtnImg:self.btnImgArr addArr:self.btnOnImgArr atIndex:indexPath addBackModel:_songNuoBDBack];
|
||
|
||
|
||
}else{
|
||
int controlAmount=[self.device.controlAmount intValue];
|
||
|
||
switch (controlAmount) {
|
||
case IFISH_DEVICE_CONTROLAMOUNT0:
|
||
{
|
||
//可不做处理
|
||
|
||
}
|
||
break;
|
||
case IFISH_DEVICE_CONTROLAMOUNT2:
|
||
{
|
||
//2空
|
||
|
||
if (!self.dataLength) {
|
||
//没返回数据
|
||
cell.controBtnImg.image = self.btnImgArr [indexPath.row - 3];
|
||
[self makeToast:@"连接设备中..."];
|
||
|
||
return cell;
|
||
}
|
||
|
||
if (IFISH_BACKMASGTYAP99 == self.dataLength ) {
|
||
|
||
[cell setTwoCOntrolImg:self.btnImgArr addArr:self.btnOnImgArr atIndex:indexPath addBackModel:_backModel1];
|
||
|
||
}else if (IFISH_BACKMASGTYAP57 ==self.dataLength ){
|
||
[cell setTwoControlBtnImgWith:self.btnImgArr addArr:self.btnOnImgArr atIndex:indexPath addBackModel:_twoControlBack];
|
||
|
||
}
|
||
|
||
|
||
}
|
||
break;
|
||
case IFISH_DEVICE_CONTROLAMOUNT3:
|
||
{
|
||
//3空
|
||
|
||
if (!_backModel1) {
|
||
cell.controBtnImg.image = self.btnImgArr [indexPath.row - 3];
|
||
[self makeToast:@"连接设备中..."];
|
||
}
|
||
[cell setBtnImgWith:self.btnImgArr addArr:self.btnOnImgArr atIndex:indexPath addBackModel:_backModel1];
|
||
|
||
|
||
}
|
||
break;
|
||
case IFISH_DEVICE_CONTROLAMOUNT4:
|
||
{
|
||
//4空
|
||
int timerAmount=[self.device.timerAmount intValue];
|
||
if (timerAmount == 8) {
|
||
if (!_fourControlbackmodel) {
|
||
cell.controBtnImg.image = self.btnImgArr [indexPath.row - 3];
|
||
[self makeToast:@"连接设备中..."];
|
||
}
|
||
|
||
[cell setFourControlBtnImgWith:self.btnImgArr addArr:self.btnOnImgArr atIndex:indexPath addBackModel:_fourControlbackmodel];
|
||
|
||
}else if (timerAmount == 6){
|
||
//可丽爱
|
||
if (!_keLiAiBackmodel) {
|
||
|
||
cell.controBtnImg.image = self.btnImgArr[indexPath.row - 3];
|
||
[self makeToast:@"连接设备中..."];
|
||
|
||
}
|
||
|
||
[cell setKeLiAiBtnImgWith:self.btnImgArr addArr:self.btnOnImgArr atIndex:indexPath addBackModel:_keLiAiBackmodel];
|
||
|
||
|
||
}
|
||
|
||
|
||
}
|
||
break;
|
||
|
||
|
||
case IFISH_DEVICE_CONTROLAMOUNT5:
|
||
{
|
||
//5空
|
||
if (!_xutoback) {
|
||
cell.controBtnImg.image = self.btnImgArr [indexPath.row - 3];
|
||
[self makeToast:@"连接设备中..."];
|
||
}
|
||
|
||
[cell setXuanduoControlBtnImg:self.btnImgArr addArr:self.btnOnImgArr atIndex:indexPath addBackModel:_xutoback];
|
||
|
||
|
||
}
|
||
break;
|
||
|
||
|
||
case IFISH_DEVICE_CONTROLAMOUNT6:
|
||
{
|
||
//6空
|
||
|
||
|
||
}
|
||
break;
|
||
case IFISH_DEVICE_CONTROLAMOUNT8:
|
||
{
|
||
//8空
|
||
|
||
if (!_songNuoBackMassage) {
|
||
cell.controBtnImg.image = self.btnImgArr [indexPath.row - 3];
|
||
[self makeToast:@"连接设备中..."];
|
||
}
|
||
|
||
[cell setSongNuoControlBtnImg:self.btnImgArr addArr:self.btnOnImgArr atIndex:indexPath addBackModel:_songNuoBackMassage];
|
||
|
||
|
||
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
}
|
||
return cell;
|
||
|
||
}
|
||
|
||
}
|
||
/**
|
||
根据设备类型设置不同数组
|
||
相同控制数设备有可能有多个 消息返回类型
|
||
* 如三控 有 99 字节和 71 字节
|
||
按钮状态 可按控制数解析 温度用字节和控制数解析
|
||
*/
|
||
-(void)setDataArr{
|
||
//设置不同的图片 及名称
|
||
if ([self.device.type isEqual:[NSNull null]]||!self.device.type) {
|
||
|
||
[self makeToast:@"未知类型"];
|
||
self.btnNameArr = @[];
|
||
self.btnImgArr = @[];
|
||
self.btnOnImgArr = @[];
|
||
return;
|
||
}
|
||
|
||
|
||
//硬件型号: 1c 三控(温控),硬件型号:cc 四川聚能 松诺新bd
|
||
if ([self.device.type isEqualToString:DECICE_TYPE_THREETMP]) {
|
||
|
||
RunSunControlName *name = [UserExtendataArchaver currentRuSunTemp:self.device.macAddress];
|
||
self.btnNameArr = @[name.light1,name.light2,name.pump,name.JiaRe];
|
||
|
||
self.btnImgArr = @[LXImageWithImageName(@"bootview_light_off"),
|
||
LXImageWithImageName(@"bootview_light_off"),
|
||
LXImageWithImageName(@"bootview_pump_off"),
|
||
LXImageWithImageName(@"bootview_heat_off")];
|
||
|
||
self.btnOnImgArr = @[LXImageWithImageName(@"bootview_light_on"),
|
||
LXImageWithImageName(@"bootview_light_on"),
|
||
LXImageWithImageName(@"bootview_pump_on"),
|
||
LXImageWithImageName(@"bootview_heat_on")];
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_RUSUN2A]){
|
||
|
||
RunSunCHControl *ruSunch = [RunSunCHNameCustom currentdevice:self.device.macAddress];
|
||
self.btnNameArr = @[ruSunch.ch1name,ruSunch.ch2name,ruSunch.ch3name,ruSunch.ch4name,ruSunch.guideng,ruSunch.jiaRe];
|
||
|
||
self.btnImgArr = @[LXImageWithImageName(@"bootview_light_off"),
|
||
LXImageWithImageName(@"bootview_light_off"),
|
||
LXImageWithImageName(@"bootview_light_off"),
|
||
LXImageWithImageName(@"bootview_light_off"),
|
||
LXImageWithImageName(@"bootview_light_off"),
|
||
LXImageWithImageName(@"bootview_heat_off")];
|
||
|
||
self.btnOnImgArr = @[LXImageWithImageName(@"bootview_light_on"),
|
||
LXImageWithImageName(@"bootview_light_on"),
|
||
LXImageWithImageName(@"bootview_light_on"),
|
||
LXImageWithImageName(@"bootview_light_on"),
|
||
LXImageWithImageName(@"bootview_light_on"),
|
||
LXImageWithImageName(@"bootview_heat_on")];
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_JUNENGCC]){
|
||
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_SONGNEWBD]){
|
||
//self.btnNameArr = @[@"灯1",@"灯2",@"水泵",@"氧泵",@"加热棒"];
|
||
SongNuo86Name* songNuo = [UserExtendataArchaver currentSongNuo86:self.device.macAddress];
|
||
self.btnNameArr = @[songNuo.light1,songNuo.light2,songNuo.waterPump,songNuo.airPump,songNuo.guideng,songNuo.jiaRe];
|
||
|
||
self.btnImgArr = @[LXImageWithImageName(@"bootview_light_off"),
|
||
LXImageWithImageName(@"bootview_light_off"),
|
||
LXImageWithImageName(@"bootview_pump_off"),
|
||
LXImageWithImageName(@"bootview_022_off"),
|
||
LXImageWithImageName(@"bootview_heat_off")];
|
||
|
||
self.btnOnImgArr = @[LXImageWithImageName(@"bootview_light_on"),
|
||
LXImageWithImageName(@"bootview_light_on"),
|
||
LXImageWithImageName(@"bootview_pump_on"),
|
||
LXImageWithImageName(@"bootview_022_on"),
|
||
LXImageWithImageName(@"bootview_heat_on")];
|
||
|
||
} else if ([self.device.type isEqualToString:DECICE_TYPE_RUIMEI]){
|
||
//self.btnNameArr = @[@"灯1",@"灯2",@"水泵",@"氧泵",@"加热棒"];
|
||
RuiMeiCHControl* ruimei = [RuiMeiCHNameCustom currentdevice:self.device.macAddress];
|
||
self.btnNameArr = @[ruimei.ch1name,ruimei.ch2name,ruimei.ch3name,ruimei.ch4name,ruimei.jiaRe];
|
||
|
||
self.btnImgArr = @[LXImageWithImageName(@"bootview_light_off"),
|
||
LXImageWithImageName(@"bootview_light_off"),
|
||
LXImageWithImageName(@"bootview_shajun_off"),
|
||
LXImageWithImageName(@"bootview_co2_off"),
|
||
LXImageWithImageName(@"bootview_heat_off")];
|
||
|
||
self.btnOnImgArr = @[LXImageWithImageName(@"bootview_light_on"),
|
||
LXImageWithImageName(@"bootview_light_on"),
|
||
LXImageWithImageName(@"bootview_shajun_on"),
|
||
LXImageWithImageName(@"bootview_co2_on"),
|
||
LXImageWithImageName(@"bootview_heat_on")];
|
||
|
||
} else{
|
||
|
||
int controlAmount=[self.device.controlAmount intValue];
|
||
|
||
switch (controlAmount) {
|
||
case IFISH_DEVICE_CONTROLAMOUNT0:
|
||
{
|
||
//可不做处理
|
||
|
||
}
|
||
break;
|
||
case IFISH_DEVICE_CONTROLAMOUNT2:
|
||
{
|
||
//2空
|
||
//self.btnNameArr = @[@"灯",@"水泵"];
|
||
TwoControlName *name = [UserExtendataArchaver currentTwoControlName:self.device.macAddress];
|
||
self.btnNameArr = @[name.lightName,name.pumpName];
|
||
self.btnImgArr = @[LXImageWithImageName(@"bootview_light_off"),LXImageWithImageName(@"bootview_pump_off")];
|
||
self.btnOnImgArr = @[LXImageWithImageName(@"bootview_light_on"),LXImageWithImageName(@"bootview_pump_on")];
|
||
}
|
||
break;
|
||
case IFISH_DEVICE_CONTROLAMOUNT3:
|
||
{
|
||
//3空
|
||
//self.btnNameArr = @[@"灯1",@"灯2",@"水泵"];
|
||
ThreeControlName *name =[UserExtendataArchaver currentThreeControlName:self.device.macAddress];
|
||
self.btnNameArr =@[name.light1Name,name.light2Name,name.pumpName];
|
||
self.btnImgArr = @[LXImageWithImageName(@"bootview_light_off"),LXImageWithImageName(@"bootview_light_off"),LXImageWithImageName(@"bootview_pump_off")];
|
||
|
||
self.btnOnImgArr = @[LXImageWithImageName(@"bootview_light_on"),LXImageWithImageName(@"bootview_light_on"),LXImageWithImageName(@"bootview_pump_on")];
|
||
|
||
}
|
||
break;
|
||
|
||
case IFISH_DEVICE_CONTROLAMOUNT4:
|
||
{
|
||
//4空 8定时器
|
||
int timerAmount=[self.device.timerAmount intValue];
|
||
|
||
if (timerAmount == 8) {
|
||
FourControlName *name = [UserExtendataArchaver currentFourControlName:self.device.macAddress];
|
||
self.btnNameArr =@[name.light1,name.light2,name.uvName,name.pumpName];
|
||
//self.btnNameArr = @[@"灯1",@"灯2",@"UV杀菌",@"冲浪/氧泵"];
|
||
self.btnImgArr = @[LXImageWithImageName(@"bootview_light_off"),LXImageWithImageName(@"bootview_light_off"),LXImageWithImageName(@"bootview_shajun_off"),LXImageWithImageName(@"bootview_pump_off")];
|
||
self.btnOnImgArr = @[LXImageWithImageName(@"bootview_light_on"),LXImageWithImageName(@"bootview_light_on"),LXImageWithImageName(@"bootview_shajun_on"),LXImageWithImageName(@"bootview_pump_on")];
|
||
|
||
}else if (timerAmount == 6){
|
||
//可丽爱 4控制 6定时器 带加热
|
||
//可丽爱暂时不自定义按钮名字
|
||
self.btnNameArr = @[@"灯1",@"灯2",@"紫外线",@"水泵",@"加热棒"];
|
||
self.btnImgArr = @[LXImageWithImageName(@"bootview_light_off"),
|
||
LXImageWithImageName(@"bootview_light_off"),
|
||
LXImageWithImageName(@"bootview_shajun_off"),
|
||
LXImageWithImageName(@"bootview_pump_off"),
|
||
LXImageWithImageName(@"bootview_heat_off")];
|
||
|
||
|
||
self.btnOnImgArr = @[LXImageWithImageName(@"bootview_light_on"),
|
||
LXImageWithImageName(@"bootview_light_on"),
|
||
LXImageWithImageName(@"bootview_shajun_on"),
|
||
LXImageWithImageName(@"bootview_pump_on"),
|
||
LXImageWithImageName(@"bootview_heat_on")];
|
||
|
||
}
|
||
|
||
}
|
||
break;
|
||
|
||
case IFISH_DEVICE_CONTROLAMOUNT5:
|
||
{
|
||
////炫多 5控
|
||
|
||
//self.btnNameArr = @[@"气泵",@"灯1",@"灯2",@"护理灯",@"水泵",@"加热棒"];
|
||
XuToControlName *name = [UserExtendataArchaver currentXuToControlName:self.device.macAddress];
|
||
self.btnNameArr = @[name.airPump,name.light1,name.light2,name.huLiDeng,name.waterPump,name.jiaRe];
|
||
|
||
self.btnImgArr = @[LXImageWithImageName(@"bootview_ceclePum_off"),LXImageWithImageName(@"bootview_light_off"),LXImageWithImageName(@"bootview_light_off"),LXImageWithImageName(@"bootview_shajun_off"),LXImageWithImageName(@"bootview_pump_off"),LXImageWithImageName(@"bootview_heat_off")];
|
||
|
||
self.btnOnImgArr = @[LXImageWithImageName(@"bootview_ceclePum_on"),LXImageWithImageName(@"bootview_light_on"),LXImageWithImageName(@"bootview_light_on"),LXImageWithImageName(@"bootview_shajun_on"),LXImageWithImageName(@"bootview_pump_on"),LXImageWithImageName(@"bootview_heat_on")];
|
||
|
||
}
|
||
break;
|
||
|
||
|
||
case IFISH_DEVICE_CONTROLAMOUNT6:
|
||
{
|
||
//6空
|
||
|
||
self.btnNameArr = @[];
|
||
self.btnImgArr = @[];
|
||
}
|
||
break;
|
||
case IFISH_DEVICE_CONTROLAMOUNT8:
|
||
{
|
||
//8空
|
||
//self.btnNameArr = @[@"灯1",@"灯2",@"水泵",@"氧泵",@"UV杀菌",@"造浪",@"备用",@"加热棒"];
|
||
SongNuo128Name *name = [UserExtendataArchaver currentSongNuo128:self.device.macAddress];
|
||
|
||
self.btnNameArr = @[name.light1,name.light2,name.waterPump,name.airPump,name.uVPump,name.wave,name.beiYong,name.jiaRe];
|
||
|
||
self.btnImgArr = @[
|
||
LXImageWithImageName(@"bootview_light_off"),
|
||
LXImageWithImageName(@"bootview_light_off"),
|
||
LXImageWithImageName(@"bootview_pump_off"),
|
||
LXImageWithImageName(@"bootview_022_off"),
|
||
LXImageWithImageName(@"bootview_shajun_off"),
|
||
LXImageWithImageName(@"bootview_ceclePum_off"),
|
||
LXImageWithImageName(@"bootview_beiyong_off"),
|
||
LXImageWithImageName(@"bootview_heat_off")
|
||
|
||
];
|
||
|
||
self.btnOnImgArr = @[
|
||
LXImageWithImageName(@"bootview_light_on"),
|
||
LXImageWithImageName(@"bootview_light_on"),
|
||
LXImageWithImageName(@"bootview_pump_on"),
|
||
LXImageWithImageName(@"bootview_022_on"),
|
||
LXImageWithImageName(@"bootview_shajun_on"),
|
||
LXImageWithImageName(@"bootview_ceclePum_on"),
|
||
LXImageWithImageName(@"bootview_beiyong_on"),
|
||
LXImageWithImageName(@"bootview_heat_on")
|
||
|
||
];
|
||
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
|
||
|
||
}
|
||
|
||
}
|
||
//在与水族箱建立关系后连接soket
|
||
-(void)initSoket{
|
||
|
||
[[Socketsingleton sharedInstance] socketConnectHost];
|
||
[Socketsingleton sharedInstance].communiteDelegate =self;
|
||
[Socketsingleton sharedInstance].macAddress = self.device.macAddress;
|
||
|
||
}
|
||
|
||
#pragma mark IfishCommuniteDelegate
|
||
|
||
#pragma mark当已经和服务端断开连接后调用该代理方法
|
||
//断线重连功能需要在这里进行
|
||
|
||
-(void)ifishSocketDidDisconnect:(AsyncSocket *)sock{
|
||
|
||
|
||
}
|
||
|
||
#pragma mark soket错误断开
|
||
|
||
-(void)ifishSocket:(AsyncSocket *)sock willDisconnectWithError:(NSError *)err{
|
||
NSLog(@"soket错误断开");
|
||
}
|
||
|
||
-(BOOL)ifishSocketWillConnect:(AsyncSocket *)sock{
|
||
|
||
return YES;
|
||
|
||
}
|
||
|
||
#pragma mark 当已经与服务端建立连接后调用的代理方法
|
||
|
||
-(void)ifishSocket:(AsyncSocket *)sock ifishSocketdidConnectToHost:(NSString *)host port:(UInt16)port{
|
||
|
||
NSLog(@"已经与服务器建立连接%d", sock.isConnected);
|
||
}
|
||
|
||
#pragma mark 发送完成处理
|
||
-(void)ifishSocket:(AsyncSocket *)sock didWriteDataWithTag:(long)tag{
|
||
|
||
|
||
}
|
||
|
||
#pragma mark 收到服务端的回执之后,调用的代理方法
|
||
|
||
-(void)socketDidGetBackmsgData:(NSData *)data onsoket:(AsyncSocket *)sock
|
||
|
||
{
|
||
|
||
|
||
//[self makeToast:@"连接成功"];
|
||
//根据传入设备model判断 设备类型
|
||
|
||
|
||
[self judgeBackamsgTaypeWith:self.device addData:data];
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
-(void)ifishDeviceLogInSuccees{
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
-(void)ifishSocket:(AsyncSocket *)sock didAcceptNewSocket:(AsyncSocket *)newSocket{
|
||
|
||
|
||
}
|
||
|
||
-(void)ifishDeviceLogInFail{
|
||
|
||
|
||
}
|
||
|
||
-(void)judgeBackamsgTaypeWith:(DeviceModel *)devicemoel addData:(NSData *)data{
|
||
|
||
[self hideToastActivity];
|
||
NSString*string1=[dataContorl dataToHexString:data];
|
||
self.dataLength = string1.length;
|
||
if ([devicemoel.controlAmount isEqual:[NSNull null]]) {
|
||
|
||
// 服务器返回此字段 为NSUll 时默认到0控
|
||
devicemoel.controlAmount = 0;
|
||
|
||
}
|
||
if ([self.device.type isEqual:[NSNull null]]) {
|
||
|
||
// 服务器返回此字段 为NSUll
|
||
return;
|
||
|
||
}
|
||
|
||
//硬件型号: 1c 三控(温控),硬件型号:cc 四川聚能 松诺新bd
|
||
//设置页 指令状态展示可通过通知方式刷新, 这里控制器作为属性更新返回数据
|
||
//英文版已改 分类处理
|
||
if ([self.device.type isEqualToString:DECICE_TYPE_THREETMP]) {
|
||
if (!_ruSunBack) {
|
||
_ruSunBack = [[RuSunProtocol alloc] init];
|
||
|
||
}
|
||
[RuSunBackMessageUtils readSoketDataWithBaackMassgModel:_ruSunBack addWithBackData:data];
|
||
|
||
self.temperature = [BootomViewSoketBackMasgConreol getTempNewWayWithSoketData:data adddeviceType:DECICE_TYPE_THREETMP];
|
||
|
||
[self.collectionView reloadData];
|
||
|
||
NSArray *timerArr=[RuSunBackMessageUtils refreshRuSunTimerAddTemperatureWithBackMassageModel:_ruSunBack];
|
||
|
||
[self.MonitorBottomDelegate setTimeVCReloadDatawithTimerArr:timerArr
|
||
withData:self.device
|
||
addMassglength:string1.length];
|
||
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_RUSUN2A]){
|
||
//睿芯 2a
|
||
if (!_ruSun84Back) {
|
||
_ruSun84Back = [[RunSun84Protocol alloc] init];
|
||
|
||
}
|
||
[RuSun84BackMsgUtils readSoketDataWithBaackMassgModel:_ruSun84Back addWithBackData:data];
|
||
|
||
self.temperature = [BootomViewSoketBackMasgConreol getTempNewWayWithSoketData:data adddeviceType:DECICE_TYPE_RUSUN2A];
|
||
|
||
[self.collectionView reloadData];
|
||
|
||
NSArray *timerArr=[RuSun84BackMsgUtils refreshRuSunTimerAddTemperatureWithBackMassageModel:_ruSun84Back];
|
||
[self.MonitorBottomDelegate setTimeVCReloadDatawithTimerArr:timerArr
|
||
withData:self.device
|
||
addMassglength:string1.length];
|
||
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_RUIMEI]){
|
||
//瑞美
|
||
if (!_ruiMeiBack) {
|
||
_ruiMeiBack = [[RuiMeiProtocolModel alloc] init];
|
||
|
||
}
|
||
|
||
[RuiMeiBackMsgUtils readSoketDataWithBaackMassgModel:_ruiMeiBack addWithBackData:data];
|
||
|
||
self.temperature = [BootomViewSoketBackMasgConreol getTempNewWayWithSoketData:data adddeviceType:DECICE_TYPE_RUIMEI];
|
||
|
||
[self.collectionView reloadData];
|
||
|
||
NSArray *timerArr=[RuiMeiBackMsgUtils refreshRuSunTimerAddTemperatureWithBackMassageModel:_ruiMeiBack];
|
||
|
||
[self.MonitorBottomDelegate setTimeVCReloadDatawithTimerArr:timerArr
|
||
withData:self.device
|
||
addMassglength:string1.length];
|
||
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_JUNENGCC]){
|
||
//巨能
|
||
|
||
}else if ([self.device.type isEqualToString:DECICE_TYPE_SONGNEWBD]){
|
||
//松诺 BD
|
||
if (!_songNuoBDBack) {
|
||
_songNuoBDBack = [[SongNuoBDProtocol alloc] init];
|
||
}
|
||
[SongNuoBackMsgDataUnity readSoketBDProtocolMassgModel:_songNuoBDBack addWithBackData:data];
|
||
self.temperature = [BootomViewSoketBackMasgConreol getTempNewWayWithSoketData:data adddeviceType:DECICE_TYPE_SONGNEWBD];
|
||
NSArray *timerArr=[SongNuoBackMsgDataUnity refreshSongNuoBD86TimerAddTempWithBackMassageModel:_songNuoBDBack];
|
||
[self.MonitorBottomDelegate setTimeVCReloadDatawithTimerArr:timerArr
|
||
withData:self.device
|
||
addMassglength:string1.length];
|
||
|
||
|
||
}else{
|
||
|
||
int controlAmount=[devicemoel.controlAmount intValue];
|
||
|
||
switch (controlAmount) {
|
||
|
||
case IFISH_DEVICE_CONTROLAMOUNT0:
|
||
{
|
||
if (!_zeroBckModel) {
|
||
_zeroBckModel=[[ZeroControlBackmsgModel alloc] init];
|
||
}
|
||
|
||
[DeviceCommunicateDataUnity readSoketbackMassageZeroControlData:data WithModel:_zeroBckModel];
|
||
self.temperature = [BootomViewSoketBackMasgConreol getTempWithSoketData:data];
|
||
[self.collectionView reloadData];
|
||
NSArray *timerArr=[DeviceCommunicateDataUnity refreshNoneControlSetViewWithBackMassageModel:_zeroBckModel];
|
||
|
||
[self.MonitorBottomDelegate setTimeVCReloadDatawithTimerArr:timerArr
|
||
withData:self.device
|
||
addMassglength:string1.length];
|
||
|
||
|
||
}
|
||
|
||
break;
|
||
case IFISH_DEVICE_CONTROLAMOUNT2:
|
||
{
|
||
|
||
if (string1.length == IFISH_BACKMASGTYAP57) {
|
||
if (!_twoControlBack) {
|
||
|
||
_twoControlBack=[[TwoControlBackmsgmodel alloc] init];
|
||
}
|
||
|
||
[DeviceCommunicateDataUnity readSoketbackMassageOfTwoControlData:data WithModel:_twoControlBack];
|
||
|
||
self.temperature = [BootomViewSoketBackMasgConreol getTempWithSoketData:data];
|
||
[self.collectionView reloadData];
|
||
|
||
|
||
int timerAmount=[self.device.timerAmount intValue];
|
||
if (timerAmount ==0) {
|
||
//两控零定时器
|
||
NSArray *timerArr=[DeviceCommunicateDataUnity
|
||
refreshTwoControlTimerWithBackMassageModel:_twoControlBack];
|
||
[self.MonitorBottomDelegate setTimeVCReloadDatawithTimerArr:timerArr
|
||
withData:self.device
|
||
addMassglength:string1.length];
|
||
|
||
|
||
}else if (timerAmount ==4){
|
||
//两控四定时器
|
||
|
||
NSArray *timerArr = [DeviceCommunicateDataUnity refreshTwoControlTimerAddTemperatureWithBackMassageModel:_twoControlBack];
|
||
[self.MonitorBottomDelegate setTimeVCReloadDatawithTimerArr:timerArr
|
||
withData:self.device
|
||
addMassglength:string1.length];
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
}else if (string1.length == IFISH_BACKMASGTYAP99){
|
||
|
||
if (!_backModel1) {
|
||
_backModel1=[[BackmassegeModel alloc] init];
|
||
}
|
||
|
||
[DeviceCommunicateDataUnity refreshTwoControlSetViewWithBackMassageModel:_backModel1];
|
||
self.temperature = [BootomViewSoketBackMasgConreol getTempWithSoketData:data];
|
||
[self.collectionView reloadData];
|
||
|
||
|
||
NSArray *timerArr = [DeviceCommunicateDataUnity refreshTwoControlSetViewWithBackMassageModel:_backModel1];
|
||
[self.MonitorBottomDelegate setTimeVCReloadDatawithTimerArr:timerArr
|
||
withData:self.device
|
||
addMassglength:string1.length];
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
}
|
||
break;
|
||
case IFISH_DEVICE_CONTROLAMOUNT3:
|
||
{
|
||
if (!_backModel1) {
|
||
_backModel1=[[BackmassegeModel alloc] init];
|
||
}
|
||
|
||
//设置温度
|
||
|
||
if (string1.length == IFISH_BACKMASGTYAP71) {
|
||
[DeviceCommunicateDataUnity readSoketThreeControlBackMassageData:data
|
||
WithModel:_backModel1];
|
||
|
||
self.temperature = [BootomViewSoketBackMasgConreol getTempWithSoketData:data];
|
||
|
||
//实时更新按钮状态
|
||
[self.collectionView reloadData];
|
||
|
||
//刷新 设置界面状态
|
||
|
||
NSArray *timerArr=[DeviceCommunicateDataUnity refreshThreeControlTimerAddTemperatureWithBackMassageModel:_backModel1];
|
||
|
||
[self.MonitorBottomDelegate setTimeVCReloadDatawithTimerArr:timerArr
|
||
withData:self.device
|
||
addMassglength:string1.length];
|
||
|
||
|
||
}else if (string1.length == IFISH_BACKMASGTYAP99){
|
||
//解析存储方式不同注意 主要在温度字段
|
||
[DeviceCommunicateDataUnity readSoketbackMassageOfThreeControlData:data
|
||
WithModel:_backModel1];
|
||
|
||
self.temperature = [BootomViewSoketBackMasgConreol getTempWithSoketData:data];
|
||
|
||
[self.collectionView reloadData];
|
||
|
||
NSArray *timerArr=[DeviceCommunicateDataUnity refreshThreeControlTimerAddTemperatureWithBackMassageModel:_backModel1];
|
||
|
||
[self.MonitorBottomDelegate setTimeVCReloadDatawithTimerArr:timerArr
|
||
withData:self.device
|
||
addMassglength:string1.length];
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|
||
break;
|
||
case IFISH_DEVICE_CONTROLAMOUNT4:
|
||
{
|
||
int timerAmount=[devicemoel.timerAmount intValue];
|
||
|
||
if (timerAmount ==8) {
|
||
|
||
if(!_fourControlbackmodel){
|
||
|
||
_fourControlbackmodel = [[FourControlbackMassge alloc] init];
|
||
|
||
}
|
||
|
||
if (string1.length ==IFISH_BACKMASGTYAP85) {
|
||
|
||
[FourControlDataUnity readSoketbackMassageOfFourControlData:data WithModel:_fourControlbackmodel];
|
||
self.temperature = [BootomViewSoketBackMasgConreol getTempWithSoketData:data];
|
||
|
||
[self.collectionView reloadData];
|
||
|
||
NSArray *timerArr=[FourControlDataUnity refreshFourControlTimerWithBackMassageModel:_fourControlbackmodel];
|
||
|
||
[self.MonitorBottomDelegate setTimeVCReloadDatawithTimerArr:timerArr
|
||
withData:self.device
|
||
addMassglength:string1.length];
|
||
}
|
||
|
||
}else if (timerAmount ==6){
|
||
//可丽爱
|
||
if (!_keLiAiBackmodel) {
|
||
|
||
_keLiAiBackmodel = [[KeLiAiBackMassage alloc] init];
|
||
|
||
}
|
||
|
||
if (string1.length ==IFISH_BACKMASGTYAP72) {
|
||
|
||
[KeLiAiBackmassageDataUnity readSoketDataWithBaackMassgModel:_keLiAiBackmodel addWithBackData:data];
|
||
self.temperature = [BootomViewSoketBackMasgConreol getTempWithSoketData:data];
|
||
|
||
[self.collectionView reloadData];
|
||
|
||
NSArray *timerArr=[KeLiAiBackmassageDataUnity refreshKeLiAiTimerAddTemperatureWithBackMassageModel:_keLiAiBackmodel];
|
||
|
||
[self.MonitorBottomDelegate setTimeVCReloadDatawithTimerArr:timerArr
|
||
withData:self.device
|
||
addMassglength:string1.length];
|
||
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
break;
|
||
case IFISH_DEVICE_CONTROLAMOUNT5:
|
||
{
|
||
//炫多 5控
|
||
if (!_xutoback) {
|
||
|
||
_xutoback = [[XutoBackMsgModel alloc] init];
|
||
}
|
||
|
||
if (string1.length == IFISH_BACKMASGTYAP73) {
|
||
|
||
[XuToSoketBackMsgDataUnity readSoketDataWithBaackMassgModel:_xutoback addWithBackData:data];
|
||
self.temperature = [BootomViewSoketBackMasgConreol getTempWithSoketData:data];
|
||
[self.collectionView reloadData];
|
||
NSArray *timerArr=[XuToSoketBackMsgDataUnity refreshXuToTimerAddTemperatureWithBackMassageModel:_xutoback];
|
||
[self.MonitorBottomDelegate setTimeVCReloadDatawithTimerArr:timerArr
|
||
withData:self.device
|
||
addMassglength:string1.length];
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|
||
break;
|
||
|
||
case IFISH_DEVICE_CONTROLAMOUNT6:
|
||
|
||
{
|
||
|
||
}
|
||
break;
|
||
|
||
case IFISH_DEVICE_CONTROLAMOUNT8:
|
||
|
||
{
|
||
//松诺八控
|
||
|
||
if (!_songNuoBackMassage) {
|
||
|
||
_songNuoBackMassage = [[SongNuoBackMassage alloc] init];
|
||
}
|
||
|
||
if (string1.length == IFISH_BACKMASGTYAP128) {
|
||
|
||
[SongNuoBackMsgDataUnity readSoketDataWithBaackMassgModel:_songNuoBackMassage addWithBackData:data];
|
||
self.temperature = [BootomViewSoketBackMasgConreol getTempWithSoketData:data];
|
||
[self.collectionView reloadData];
|
||
NSArray *timerArr=[SongNuoBackMsgDataUnity refreshSongNuoTimerAddTemperatureWithBackMassageModel:_songNuoBackMassage];
|
||
[self.MonitorBottomDelegate setTimeVCReloadDatawithTimerArr:timerArr
|
||
withData:self.device
|
||
addMassglength:string1.length];
|
||
|
||
}
|
||
|
||
|
||
|
||
}
|
||
break;
|
||
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
#pragma -mark -functions
|
||
|
||
//获取字符串的宽度
|
||
-(float) widthForString:(NSString *)value fontSize:(float)fontSize andHeight:(float)height
|
||
{
|
||
CGSize sizeToFit = [value sizeWithFont:[UIFont systemFontOfSize:fontSize] constrainedToSize:CGSizeMake(CGFLOAT_MAX, height) lineBreakMode:NSLineBreakByWordWrapping];//此处的换行类型(lineBreakMode)可根据自己的实际情况进行设置
|
||
return sizeToFit.width;
|
||
}
|
||
//获得字符串的高度
|
||
-(float) heightForString:(NSString *)value fontSize:(float)fontSize andWidth:(float)width
|
||
{
|
||
CGSize sizeToFit = [value sizeWithFont:[UIFont systemFontOfSize:fontSize] constrainedToSize:CGSizeMake(width, CGFLOAT_MAX) lineBreakMode:NSLineBreakByCharWrapping];//此处的换行类型(lineBreakMode)可根据自己的实际情况进行设置
|
||
return sizeToFit.height;
|
||
}
|
||
|
||
-(void)cameraJieBang{
|
||
|
||
[self.MonitorBottomDelegate cameraIsNotExit];
|
||
}
|
||
|
||
@end
|