Initial commit

This commit is contained in:
ifish
2017-08-15 16:59:01 +08:00
commit bdc83e07ef
5766 changed files with 423223 additions and 0 deletions
@@ -0,0 +1,20 @@
//
// SongNuo86Name.h
// Ifish
//
// Created by imac on 2017/6/14.
// Copyright © 2017年 lianlian. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface SongNuo86Name : NSObject
@property (nonatomic,copy) NSString *light1;
@property (nonatomic,copy) NSString *light2;
@property (nonatomic,copy) NSString *waterPump;
@property (nonatomic,copy) NSString *airPump;
@property (nonatomic,copy) NSString *guideng;
@property (nonatomic,copy) NSString *jiaRe;
@property (nonatomic,copy) NSString *macAddress;
@end
@@ -0,0 +1,41 @@
//
// SongNuo86Name.m
// Ifish
//
// Created by imac on 2017/6/14.
// Copyright © 2017年 lianlian. All rights reserved.
//
#import "SongNuo86Name.h"
@implementation SongNuo86Name
-(void)encodeWithCoder:(NSCoder*)aCoder{
[aCoder encodeObject:_light1 forKey:@"light1"];
[aCoder encodeObject:_light2 forKey:@"light2"];
[aCoder encodeObject:_waterPump forKey:@"waterPump"];
[aCoder encodeObject:_airPump forKey:@"airPump"];
[aCoder encodeObject:_guideng forKey:@"guideng"];
[aCoder encodeObject:_jiaRe forKey:@"JiaRe"];
[aCoder encodeObject:_macAddress forKey:@"macAddress"];
}
-(id)initWithCoder:(NSCoder*)aDecoder{
if (self=[super init]) {
self.light1=[aDecoder decodeObjectForKey:@"light1"];
self.light2=[aDecoder decodeObjectForKey:@"light2"];
self.waterPump = [aDecoder decodeObjectForKey:@"waterPump"];
self.airPump = [aDecoder decodeObjectForKey:@"airPump"];
self.guideng = [aDecoder decodeObjectForKey:@"guideng"];
self.jiaRe = [aDecoder decodeObjectForKey:@"JiaRe"];
self.macAddress = [aDecoder decodeObjectForKey:@"macAddress"];
}
return self;
}
@end
@@ -0,0 +1,13 @@
//
// SongNuo86NameViewController.h
// Ifish
//
// Created by imac on 2017/6/14.
// Copyright © 2017年 lianlian. All rights reserved.
//
#import "IfishDeviceControlNameBaseController.h"
@interface SongNuo86NameViewController : IfishDeviceControlNameBaseController
@end
@@ -0,0 +1,188 @@
//
// SongNuo86NameViewController.m
// Ifish
//
// Created by imac on 2017/6/14.
// Copyright © 2017年 lianlian. All rights reserved.
//
#import "SongNuo86NameViewController.h"
#import "RuSunChangeNameTextViewCell.h"
#import "SongNuo86Name.h"
#import "UserExtendataArchaver.h"
#define SONG86CELL_LIANGHT1 11000
#define SONG86CELL_LIANGHT2 11001
#define SONG86CELL_WP 11002
#define SONG86CELL_AP 11003
#define SONG86CELL_GD 11004
#define SONG86CELL_JR 11005
@interface SongNuo86NameViewController ()
@end
@implementation SongNuo86NameViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.tableView.dataSource = self;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (section==0) {
return 1;
}else{
return 6;
}
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 2;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section==0) {
return [super baseViewLoadDeviceNameCell:indexPath intable:tableView];
}
RuSunChangeNameTextViewCell*cell=[tableView dequeueReusableCellWithIdentifier:@"RuSunChangeNameTextViewCell"];
if (cell==nil) {
cell= [[[NSBundle mainBundle]loadNibNamed:@"RuSunChangeNameTextViewCell" owner:self options:nil]lastObject];
}
//控制原名
if (indexPath.row==5&&indexPath.section==1) {
cell.lineImgView.image = [UIImage imageNamed:@"redact_line_last"];
}
NSArray *titles= @[@"灯1",@"灯2",@"水泵",@"氧泵",@"柜灯",@"加热棒"];
if (indexPath.section==1) {
cell.chTitle.text = titles[indexPath.row];
}
//自定义名字
SongNuo86Name *name = [UserExtendataArchaver currentSongNuo86:self.device.macAddress];
if (indexPath.section==1&&indexPath.row==0) {
cell.chName.text = name.light1;
}else if (indexPath.section==1&&indexPath.row==1){
cell.chName.text = name.light2;
}else if (indexPath.section==1&&indexPath.row==2){
cell.chName.text = name.waterPump;
}else if (indexPath.section==1&&indexPath.row==3){
cell.chName.text = name.airPump;
}
else if (indexPath.section==1&&indexPath.row==4){
cell.chName.text = name.guideng;
}
else if (indexPath.section==1&&indexPath.row==5){
cell.chName.text = name.jiaRe;
}
cell.chName.delegate = self;
cell.tag = 11000 + indexPath.row;
return cell;
}
-(void)sureAction
{
//RunSunCHNameCustom 本地处理 保存按钮名称 不与服务器交互
SongNuo86Name *songN = [[SongNuo86Name alloc] init];
RuSunChangeNameTextViewCell*cell1 = [self.view viewWithTag:SONG86CELL_LIANGHT1];
if (cell1.chName.text.length>3) {
[self.view makeToast:@"灯1不能超过3个字"];
return;
}
if (cell1.chName.text.length==0) {
[self.view makeToast:@"灯1不能为空"];
return;
}
songN.light1 = cell1.chName.text;
RuSunChangeNameTextViewCell*cell2 = [self.view viewWithTag:SONG86CELL_LIANGHT2];
if (cell2.chName.text.length>3) {
[self.view makeToast:@"灯2不能超过3个字"];
return;
}
if (cell2.chName.text.length==0) {
[self.view makeToast:@"灯2不能为空"];
return;
}
songN.light2 = cell2.chName.text;
RuSunChangeNameTextViewCell*cell3 = [self.view viewWithTag:SONG86CELL_WP];
if (cell3.chName.text.length>3) {
[self.view makeToast:@"水泵名不能超过3个字"];
return;
}
if (cell3.chName.text.length==0) {
[self.view makeToast:@"水泵名不能为空"];
return;
}
songN.waterPump = cell3.chName.text;
RuSunChangeNameTextViewCell*cell4 = [self.view viewWithTag:SONG86CELL_AP];
if (cell4.chName.text.length>3) {
[self.view makeToast:@"氧泵名不能超过3个字"];
return;
}
if (cell4.chName.text.length==0) {
[self.view makeToast:@"氧泵名不能为空"];
return;
}
songN.airPump = cell4.chName.text;
RuSunChangeNameTextViewCell*cell5 = [self.view viewWithTag:SONG86CELL_GD];
if (cell5.chName.text.length>3) {
[self.view makeToast:@"柜灯名不能超过3个字"];
return;
}
if (cell5.chName.text.length==0) {
[self.view makeToast:@"柜灯名不能为空"];
return;
}
songN.guideng = cell5.chName.text;
RuSunChangeNameTextViewCell*cell6 = [self.view viewWithTag:SONG86CELL_JR];
if (cell6.chName.text.length>3) {
[self.view makeToast:@"加热棒名不能超过3个字"];
return;
}
if (cell6.chName.text.length==0) {
[self.view makeToast:@"加热棒名不能为空"];
return;
}
songN.jiaRe = cell6.chName.text;
songN.macAddress = self.device.macAddress;
[UserExtendataArchaver saveSongNuo86Name: songN];
[self upLoadDeviceName];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
@@ -0,0 +1,42 @@
//
// SongNuoBDProtocol.h
// Ifish
//
// Created by imac on 17/1/6.
// Copyright © 2017年 lianxiang. All rights reserved.
//
#import <Foundation/Foundation.h>
//松诺新 86 字节 硬件类型 bd
@interface SongNuoBDProtocol : NSObject
@property(nonatomic,copy) NSString *light1btn;
@property(nonatomic,copy) NSString *light2btn;
@property(nonatomic,copy) NSString *waterPumpBtn;
@property(nonatomic,copy) NSString *gasPumpBtn;
//柜灯开关
@property(nonatomic,copy) NSString *guideng;
@property(nonatomic,copy) NSString *timer1;
@property(nonatomic,copy) NSString *timer2;
@property(nonatomic,copy) NSString *timer3;
@property(nonatomic,copy) NSString *timer4;
@property(nonatomic,copy) NSString *timer5;
@property(nonatomic,copy) NSString *timer6;
@property(nonatomic,copy) NSString *timer7;
@property(nonatomic,copy) NSString *timer8;
@property(nonatomic,copy) NSString *heatStickState;
//背光亮度
@property(nonatomic,copy) NSString *backLight;
@property(nonatomic,copy) NSString *wendu;
// 加热温度
@property(nonatomic,copy) NSString *heatTemperature;
@property(nonatomic,copy) NSString *baojingSwitch;
@property(nonatomic,copy) NSString *miniTp;
@property(nonatomic,copy) NSString *maxTp;
@property(nonatomic,copy) NSString *funcCode;
@end
@@ -0,0 +1,71 @@
//
// SongNuoBDProtocol.m
// Ifish
//
// Created by imac on 17/1/6.
// Copyright © 2017年 lianxiang. All rights reserved.
//
#import "SongNuoBDProtocol.h"
//松诺新 86 字节 硬件类型 bd
@implementation SongNuoBDProtocol
-(void)encodeWithCoder:(NSCoder*)aCoder{
[aCoder encodeObject:self forKey:@"light1"];
[aCoder encodeObject:self forKey:@"light2"];
[aCoder encodeObject:self forKey:@"waterPumpBtn"];
[aCoder encodeObject:self forKey:@"gasPumpBtn"];
[aCoder encodeObject:self forKey:@"guideng"];
[aCoder encodeObject:self forKey:@"timer1"];
[aCoder encodeObject:self forKey:@"timer2"];
[aCoder encodeObject:self forKey:@"timer3"];
[aCoder encodeObject:self forKey:@"timer4"];
[aCoder encodeObject:self forKey:@"timer5"];
[aCoder encodeObject:self forKey:@"timer6"];
[aCoder encodeObject:self forKey:@"timer7"];
[aCoder encodeObject:self forKey:@"timer8"];
[aCoder encodeObject:self forKey:@"heatStickState"];
[aCoder encodeObject:self forKey:@"backLight"];
[aCoder encodeObject:self forKey:@"wendu"];
[aCoder encodeObject:self forKey:@"heatTemperature"];
[aCoder encodeObject:self forKey:@"baojingSwitch"];
[aCoder encodeObject:self forKey:@"miniTp"];
[aCoder encodeObject:self forKey:@"maxTp"];
[aCoder encodeObject:self forKey:@"funcCode"];
}
-(id)initWithCoder:(NSCoder*)aDecoder{
if (self=[super init]) {
self.light1btn =[aDecoder decodeObjectForKey:@"light1"];
self.light2btn =[aDecoder decodeObjectForKey:@"light2"];
self.waterPumpBtn=[aDecoder decodeObjectForKey:@"waterPumpBtn"];
self.gasPumpBtn=[aDecoder decodeObjectForKey:@"gasPumpBtn"];
self.guideng = [aDecoder decodeObjectForKey:@"guideng"];
self.timer1 = [aDecoder decodeObjectForKey:@"timer1"];
self.timer2 = [aDecoder decodeObjectForKey:@"timer2"];
self.timer3 = [aDecoder decodeObjectForKey:@"timer3"];
self.timer4 = [aDecoder decodeObjectForKey:@"timer4"];
self.timer5 = [aDecoder decodeObjectForKey:@"timer5"];
self.timer6 = [aDecoder decodeObjectForKey:@"timer6"];
self.timer7 = [aDecoder decodeObjectForKey:@"timer7"];
self.timer8 = [aDecoder decodeObjectForKey:@"timer8"];
self.heatStickState = [aDecoder decodeObjectForKey:@"heatStickState"];
self.backLight = [aDecoder decodeObjectForKey:@"backLight"];
self.wendu = [aDecoder decodeObjectForKey:@"wendu"];
self.heatTemperature =[aDecoder decodeObjectForKey:@"heatTemperature"];
self.baojingSwitch=[aDecoder decodeObjectForKey:@"baojingSwitch"];
self.miniTp=[aDecoder decodeObjectForKey:@"miniTp"];
self.maxTp=[aDecoder decodeObjectForKey:@"maxTp"];
self.funcCode = [aDecoder decodeObjectForKey:@"funcCode"];
}
return self;
}
@end
@@ -0,0 +1,40 @@
//
// SongNuoDBCenterViewController.h
// Ifish
//
// Created by imac on 17/1/6.
// Copyright © 2017年 lianxiang. All rights reserved.
//
#import "CenterViewController.h"
//松诺 BD 86
@interface SongNuoDBCenterViewController : CenterViewController
@property(nonatomic,strong) UIButton *button;
@property(nonatomic,strong) UILabel *buttonNameLabel;
// 灯1
@property(nonatomic,strong) UIButton *nuoLight1Btn;
// 灯2
@property(nonatomic,strong) UIButton *nuoLight2Btn;
// 水泵
@property(nonatomic,strong) UIButton *nuoWaterPumpBtn;
// 氧泵
@property(nonatomic,strong) UIButton *nuoAirPumpBtn;
//柜灯 与柜灯在设置界面不同
@property(nonatomic,strong) UIButton *nuoGuiDengBtn;
//加热棒
@property(nonatomic,strong) UIButton *nuoJiaReBtn;
@property(nonatomic,strong) UILabel *light1Name;
@property(nonatomic,strong) UILabel *light2Name;
@property(nonatomic,strong) UILabel *waterPumpName;
@property(nonatomic,strong) UILabel *airPumpName;
@property(nonatomic,strong) UILabel *guiDengName;
@property(nonatomic,strong) UILabel *jiaReName;
@end
@@ -0,0 +1,619 @@
//
// SongNuoDBCenterViewController.m
// Ifish
//
// Created by imac on 17/1/6.
// Copyright © 2017年 lianxiang. All rights reserved.
//
#import "SongNuoDBCenterViewController.h"
#import "SongNuoBDProtocol.h"
#import "SongNuoDBSetViewController.h"
#define SONGNUO_LIGHT1 600000
#define SONGNUO_LIGHT2 600001
#define SONGNUO_WATERPUMP 600002
#define SONGNUO_AIRPUMP 600003
#define SONGNUO_GUIDENG 600004
#define SONGNUO_JIARE 600005
#define kPlace ([UIScreen mainScreen].bounds.size.width - btnWid*2) /4
#define btnWid 100
#import "XuToWenDuPicview.h"
#import "JiaReWenDuModel.h"
#import "SongNuoBackMsgDataUnity.h"
#import "SongNuo86NameViewController.h"
#import "SongNuo86Name.h"
#import "UserExtendataArchaver.h"
@interface SongNuoDBCenterViewController ()
{
dispatch_queue_t _songNuoMainQueue;
}
@property(nonatomic,strong) SongNuoDBSetViewController *songNuoSetVC;
@property(nonatomic,strong) SongNuoBDProtocol * songNuoBackModel;
@property(nonatomic,strong) MyHud *SongNuoHud;
@property(nonatomic,strong) XuToWenDuPicview *wenduPicview;
@property(nonatomic,strong) SongNuo86NameViewController *changeNameVC;
@end
@implementation SongNuoDBCenterViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
_songNuoBackModel=[[SongNuoBDProtocol alloc] init];
[Socketsingleton sharedInstance].communiteDelegate=self;
// Do any additional setup after loading the view.
_songNuoMainQueue = dispatch_get_main_queue();
[self initSongNuoBDUI];
[self creatFishAnimation];
[self.setbackBtn addTarget:self action:@selector(songNuoBDSetBtnAction) forControlEvents:UIControlEventTouchUpInside];
UITapGestureRecognizer*tapgestureRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(songNuoBDSetBtnAction:)];
[self.setImag addGestureRecognizer:tapgestureRecognizer];
}
#pragma mark- 设置
-(void)songNuoBDSetBtnAction{
SongNuoBackMassage *backmodel=[[DataCenter defaultDtacenter]valueForKey:@"SongNuoDBProto"];
if (self.binddeviceArr.count ==0) {
//老方案已去
[self.view makeToast:@"暂未绑定设备"];
}else{
if (backmodel) {
[self pushSetTimeVC];
}else{
[self.indicatorView stopAnimating];
[self showLableAction:@"设备已离线"];
//[self.XuTohud hidmyHud];
}
}
NSLog(@"点击绚多的设置按钮");
}
-(void)songNuoBDSetBtnAction:(UIGestureRecognizer *)sender{
SongNuoBackMassage *backmodel=[[DataCenter defaultDtacenter]valueForKey:@"SongNuoDBProto"];
if (self.binddeviceArr.count ==0) {
[self.view makeToast:@"暂未绑定设备"];
}else{
if (backmodel) {
[self pushSetTimeVC];
}else{
[self.indicatorView stopAnimating];
[self showLableAction:@"设备已离线"];
}
}
NSLog(@"松诺的设置按钮");
}
-(void)pushSetTimeVC{
_songNuoSetVC=[[SongNuoDBSetViewController alloc] init];
_songNuoSetVC.currentdevice=self.currentDevice;
[self.navigationController pushViewController:_songNuoSetVC animated:YES];
}
-(void)creatFishAnimation{
NSLog(@"SongNuoBDUI");
}
-(void)initSongNuoBDUI
{
NSArray *nameArr=@[@"PFLight1_off",@"PFLight1_off",@"ChongLang_off",@"O2_off",@"",@"PFkilLlight_off",@"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 -10 , btnControlWith, btnControlWith +11);
[self.button setImage:[UIImage imageNamed:nameArr[i]] forState:UIControlStateNormal];
//self.button.backgroundColor = [UIColor redColor];
self.button.tag=600000+i;
[self.button addTarget:self action:@selector(songNuoBDBtnClick:) forControlEvents:UIControlEventTouchUpInside];
UILabel* textLbl = [[UILabel alloc] initWithFrame:CGRectMake(btnControlPlace +i*(btnControlPlace + btnControlWith),kScreenSize.height - 3*btnControlPlace - 2 *btnControlWith -20 + btnControlWith , btnControlWith, btnControlPlace - 5)];
//textLbl.backgroundColor = [UIColor blackColor];
textLbl.textColor = [UIColor colorWithRed:250/255.0f green:255/255.0f blue:255/254.0f alpha:1];
textLbl.textAlignment = NSTextAlignmentCenter;
NSArray *arr = @[@"灯1",@"灯2",@"水泵"];
textLbl.text = arr[i];
textLbl.font = [UIFont boldSystemFontOfSize:14];
[self.tableView addSubview:textLbl];
[self.tableView addSubview:self.button];
if (i==0) {
self.nuoLight1Btn = self.button;
self.light1Name = textLbl;
}else if (i==1){
self.nuoLight2Btn = self.button;
self.light2Name = textLbl;
}else if (i==2){
self.nuoWaterPumpBtn = self.button;
self.waterPumpName = textLbl;
}
}
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, btnControlWith, btnControlWith +11);
[self.button setImage:[UIImage imageNamed:nameArr[i+3]]forState:UIControlStateNormal];
self.button.tag= 600003+i;
[self.button addTarget:self action:@selector(songNuoBDBtnClick:) forControlEvents:UIControlEventTouchUpInside];
UILabel* textLbl = [[UILabel alloc] initWithFrame:CGRectMake(btnControlPlace1 +i*(btnControlPlace1 + 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 = @[@"氧泵",@"柜灯",@"加热棒"];
textLbl.font = [UIFont boldSystemFontOfSize:14];
textLbl.text = arr[i];
[self.tableView addSubview:textLbl];
[self.tableView addSubview:self.button];
if (i==0) {
self.nuoAirPumpBtn = self.button;
self.airPumpName = textLbl;
}else if (i==1){
self.nuoGuiDengBtn = self.button;
self.guiDengName = textLbl;
}else if (i==1){
self.nuoJiaReBtn = self.button;
self.jiaReName = textLbl;
}
}
//重置 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);
self.temperature.frame = CGRectMake(30, 70, (kScreenSize.width - 2 * kPlace - 100)*2/3, (kScreenSize.width - 2 * kPlace - 200)*2/3);
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];
}else{
self.temperature.frame = CGRectMake(10, 80, kScreenSize.width - 2 * kPlace - 100, kScreenSize.width - 2 * kPlace - 200);
self.temperature.font = [UIFont fontWithName:@"Avenir Next Condensed" size:70];
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, kScreenSize.width - 2 * kPlace - 210);
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 initCHNames];
}
-(void)songNuoBDBtnClick:(UIButton*)btn{
SongNuoBDProtocol*backmodel=[[DataCenter defaultDtacenter]valueForKey:@"SongNuoDBProto"];
if (backmodel) {
}else{
[self deviceNotOnlineState];
[self showLableAction:@"设备已离线"];
return;
}
XuToLightModel * lightModel=[[XuToLightModel alloc] init];
lightModel.sendmacId = self.currentDevice.macAddress;
lightModel.resavemacId = self.currentDevice.macAddress;
NSString*switchString1=lightModel.description;
if (btn.selected) {//开
lightModel.switchBtn=@"00";
btn.selected=NO;
}else {// 关
lightModel.switchBtn=@"01";
btn.selected=YES;
}
lightModel.crc16Str=@"0000";// CRC16验证码
switch (btn.tag) {
case SONGNUO_LIGHT1:
{
btn.userInteractionEnabled=YES;
[btn setImage:[UIImage imageNamed:@"PFLight1_on.png"] forState:UIControlStateSelected];
lightModel.lightNumber =@"01";
NSString*switchString2=[NSString stringWithFormat:@"%@%@%@%@",switchString1,lightModel.lightNumber,lightModel.switchBtn,lightModel.crc16Str];
NSData*manulData=[dataContorl stringToHexData:switchString2];
[ [Socketsingleton sharedInstance] soketWriteData:manulData];
if ([Socketsingleton sharedInstance].clientSocket.isConnected) {
//soket 未断开时显示
[self creatSongNuoIndicator];
[self.SongNuoHud myhudstart];
}
if ([lightModel.switchBtn isEqualToString:@"00"]) {
btn.selected=YES;
}else{
btn.selected=NO;
}
}
break;
case SONGNUO_LIGHT2:
{
btn.userInteractionEnabled=YES;
[btn setImage:[UIImage imageNamed:@"PFLight1_on.png"] forState:UIControlStateSelected];
lightModel.lightNumber =@"02";// 01 --灯1
NSString*switchString2=[NSString stringWithFormat:@"%@%@%@%@",switchString1,lightModel.lightNumber,lightModel.switchBtn,lightModel.crc16Str];
NSData*manulData=[dataContorl stringToHexData:switchString2];
[ [Socketsingleton sharedInstance] soketWriteData:manulData];
if ([Socketsingleton sharedInstance].clientSocket.isConnected) {
//soket 未断开时显示
[self creatSongNuoIndicator];
[self.SongNuoHud myhudstart];
}
if ([lightModel.switchBtn isEqualToString:@"00"]) {
btn.selected=YES;
}else{
btn.selected=NO;
}
}
break;
case SONGNUO_WATERPUMP:
{
btn.userInteractionEnabled=YES;
[btn setImage:[UIImage imageNamed:@"ChongLang_on.png"] forState:UIControlStateSelected];
lightModel.lightNumber=@"03";//
NSString*switchString2=[NSString stringWithFormat:@"%@%@%@%@",switchString1,lightModel.lightNumber,lightModel.switchBtn,lightModel.crc16Str];
NSData*manulData=[dataContorl stringToHexData:switchString2];
[ [Socketsingleton sharedInstance] soketWriteData:manulData];
if ([Socketsingleton sharedInstance].clientSocket.isConnected) {
//soket 未断开时显示
[self creatSongNuoIndicator];
[self.SongNuoHud myhudstart];
}
if ([lightModel.switchBtn isEqualToString:@"00"]) {
btn.selected=YES;
}else{
btn.selected=NO;
}
}
break;
case SONGNUO_AIRPUMP:
{
btn.userInteractionEnabled=YES;
[btn setImage:[UIImage imageNamed:@"O2_on.png"] forState:UIControlStateNormal];
lightModel.lightNumber=@"04";//
NSString*switchString2=[NSString stringWithFormat:@"%@%@%@%@",switchString1,lightModel.lightNumber,lightModel.switchBtn,lightModel.crc16Str];
NSData*manulData=[dataContorl stringToHexData:switchString2];
[ [Socketsingleton sharedInstance] soketWriteData:manulData];
if ([Socketsingleton sharedInstance].clientSocket.isConnected) {
//soket 未断开时显示
[self creatSongNuoIndicator];
[self.SongNuoHud myhudstart];
}
if ([lightModel.switchBtn isEqualToString:@"00"]) {
btn.selected=YES;
}else{
btn.selected=NO;
}
}
break;
case SONGNUO_GUIDENG:
{
btn.userInteractionEnabled=YES;
[btn setImage:[UIImage imageNamed:@"PFkilLlight_on.png"] forState:UIControlStateSelected];
lightModel.lightNumber=@"05";//
NSString*switchString2=[NSString stringWithFormat:@"%@%@%@%@",switchString1,lightModel.lightNumber,lightModel.switchBtn,lightModel.crc16Str];
NSData*manulData=[dataContorl stringToHexData:switchString2];
[ [Socketsingleton sharedInstance] soketWriteData:manulData];
if ([Socketsingleton sharedInstance].clientSocket.isConnected) {
//soket 未断开时显示
[self creatSongNuoIndicator];
[self.SongNuoHud myhudstart];
}
if ([lightModel.switchBtn isEqualToString:@"00"]) {
btn.selected=YES;
}else{
btn.selected=NO;
}
}
break;
case SONGNUO_JIARE:
{
if (backmodel) {
_wenduPicview=[[XuToWenDuPicview 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];
[self songNuoJiaReMianQue];
}else{
[self showLableAction:@"设备已离线"];
}
}
break;
default:
break;
}
}
#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)creatSongNuoIndicator{
self.SongNuoHud=[[MyHud alloc]init];
self.SongNuoHud.frame=CGRectMake(0, kScreenSize.height*2/3 - 50 , kScreenSize.width,kScreenSize.height/3);
[self.SongNuoHud myhudtimeOut];
[self.view addSubview:self.SongNuoHud];
}
-(void)songNuoJiaReMianQue{
SongNuoBackMassage *backmodel=[[DataCenter defaultDtacenter]valueForKey:@"SongNuoDBProto"];
UInt64 mac=[dataContorl hexToTen:backmodel.heatTemperature];
NSLog(@"%llu",mac);
//float TPlabel=mac/10+(mac%10)*0.1;
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(_songNuoMainQueue, ^{
for (NSInteger i=0; i<wenDuArr.count; i++) {
NSString*picString=wenDuArr[i];
if ([picString isEqualToString:stringFloat ] ) {
[_wenduPicview.pic selectRow:i inComponent:0 animated:NO];
}
}
});
}
#pragma mark - 收到服务端的回执之后,调用的代理方法
-(void)socketDidGetBackmsgData:(NSData *)data onsoket:(AsyncSocket *)sock{
NSString*string1=[dataContorl dataToHexString:data];
//设备在线显示与设备离线相对应 收到返回数据改变显示状态
[self.indicatorView stopAnimating];
//[_HUD hide:YES];
[self.SongNuoHud hidmyHud];
self.notOnLineLabel.hidden = YES;
self.dulabel.hidden=NO;
self.temperature.hidden=NO;
if (_songNuoSetVC.indicatorView) {
[_songNuoSetVC.indicatorView stopAnimating];
}
NSLog(@"收到服务器的回执2--->%@",data);
self.dataLength=string1.length;
//存储
[SongNuoBackMsgDataUnity readSoketBDProtocolMassgModel:_songNuoBackModel addWithBackData:data];
// 温度
[SongNuoBackMsgDataUnity setBD86Templabel:self.temperature addbubleImge:self.bubble WithBackData:data addWithProtocol:_songNuoBackModel addWithTableview:self.tableView];
//灯的状态
[SongNuoBackMsgDataUnity resetSongNuoBD86ButtonState:self.nuoLight1Btn addlight2:self.nuoLight2Btn addWaterPump:self.nuoWaterPumpBtn addAir:self.nuoAirPumpBtn guiDeng:self.nuoGuiDengBtn addJiaRe:self.nuoJiaReBtn withProtocol:_songNuoBackModel];
// 刷新设置界面
_songNuoSetVC.timeArr = [SongNuoBackMsgDataUnity refreshSongNuoBD86TimerAddTempWithBackMassageModel:_songNuoBackModel];
[_songNuoSetVC.tableView reloadData];
}
-(void)ifishDeviceLogInSuccees{
self.isconnect=YES;
NSLog(@"app登录成功");
}
-(void)ifishDeviceLogInFail{
[self endRefreshing];
[self.indicatorView stopAnimating];
dispatch_async(dispatch_get_main_queue(), ^{
[self deviceNotOnlineState];//设备离线
});
}
#pragma mark -父类方法
-(void)shezhiMingCheng
{
_changeNameVC = [[SongNuo86NameViewController 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{
SongNuo86Name* songNuo = [UserExtendataArchaver currentSongNuo86:self.currentDevice.macAddress];
self.light1Name.text = songNuo.light1;
self.light2Name.text = songNuo.light2;
self.waterPumpName.text = songNuo.waterPump;
self.airPumpName.text = songNuo.airPump;
self.guiDengName.text = songNuo.guideng;
self.jiaReName.text = songNuo.jiaRe;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
@@ -0,0 +1,29 @@
//
// SongNuoDBSetViewController.h
// Ifish
//
// Created by imac on 17/1/6.
// Copyright © 2017年 lianxiang. All rights reserved.
//
#import "FatherController.h"
@interface SongNuoDBSetViewController : FatherController
{
BOOL _isHidden;
BOOL mySwitchIsOn;
}
@property(nonatomic,strong)NSArray*timeArr;
@property(nonatomic,strong)NSArray*titleArr;
@property(nonatomic)BOOL isAuto;// 自动模式
@property(nonatomic)UIActivityIndicatorView*indicatorView;
-(void)addAlertView;
@property(nonatomic)int percent;
@property(nonatomic,strong) DeviceModel* currentdevice;
@end