查询定时模式

This commit is contained in:
kai60 2022-05-12 22:17:55 +08:00
parent d2ddc8b76a
commit e9992fed8b
11 changed files with 212 additions and 48 deletions

View File

@ -505,6 +505,14 @@ Copy NSString *deviceId;
self.HUD.labelText = @"绑定失败";
[self.HUD hide:YES afterDelay:2];
}
else
{
[self appendTrakContent:@"绑定返回状态码错误。设备信息为:%@"];
self.bakbutton.userInteractionEnabled=YES;
self.HUD.labelText = [NSString stringWithFormat:@"绑定失败:%@",resultDic[@"result"]];
[self.HUD hide:YES afterDelay:2];
}
} failure:^(NSError *err) {

View File

@ -13,7 +13,8 @@
#import "xuanduo3fModel.h"
NS_ASSUME_NONNULL_BEGIN
typedef void (^SocketAckBlock) (NSString*ack,NSString*funcCode,NSString* header,NSInteger length);
@interface Xuanduo2DataUtility : NSObject
+(void)readSocketDataWithBackMsgModel:(id)xuanduoModel addWithBackData:(NSData*)data type:(NSString*)type;

View File

@ -63,5 +63,14 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, strong) NSString *gapTime;
@property (nonatomic, strong) NSString *status;
@end
@interface XuanduoTimerTypeModel : NSObject
/// 灯的序号
@property (nonatomic, strong) NSString *lightNumber;
//定时模式
@property (nonatomic, strong) NSString *type;
@end
NS_ASSUME_NONNULL_END

View File

@ -18,5 +18,15 @@
@implementation XuanduoCycleModel
@end
@implementation XuanduoRecoveryModel
@end
@implementation XuanduoTimerTypeModel
@end

View File

@ -610,7 +610,7 @@
_wenduPicview.wenDuPicviewDelegate = self;
NSString *stateStr =nil;
NSString*status;
if ([self.currentDevice.type isEqualToString:DECICE_TYPE_XUANDUO2F])
if ([self.currentDevice.type isEqualToString:DECICE_TYPE_XUANDUO2F]||[self.currentDevice.type isEqualToString:DECICE_TYPE_XUANDUO4F]||[self.currentDevice.type isEqualToString:DECICE_TYPE_XUANDUO5F])
{
status=((Xuanduo2Model*)self.dataModel).status;
}

View File

@ -14,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (instancetype)shareHeaderView;
@property (weak, nonatomic) IBOutlet UIButton *controlBtn;
//一键喂鱼开关状态按钮
@property (weak, nonatomic) IBOutlet UIButton *statusBtn;
@property (weak, nonatomic) IBOutlet UIImageView *backImageView;
- (void)configWithImageName:(NSString *)name labelName:(NSString *)labelName;

View File

@ -24,6 +24,9 @@
{
self.userInteractionEnabled=YES;
[self.statusBtn setTitle:@"关闭" forState:UIControlStateNormal];
[self.statusBtn setTitle:@"打开" forState:UIControlStateNormal];
}
- (void)configWithImageName:(NSString *)name labelName:(NSString *)labelName {
self.imageView.image = [UIImage imageNamed:name];

View File

@ -39,6 +39,14 @@
<constraint firstAttribute="width" constant="30" id="wt7-Qr-eyY"/>
</constraints>
</imageView>
<button hidden="YES" opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="UKV-VP-KnJ" userLabel="statusBtn">
<rect key="frame" x="154" y="2" width="67" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="关闭">
<fontDescription key="titleFontDescription" type="system" pointSize="15"/>
</buttonConfiguration>
</button>
</subviews>
<viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@ -61,6 +69,7 @@
<outlet property="controlBtn" destination="AWf-ci-ZDG" id="00H-o4-Evv"/>
<outlet property="imageView" destination="FHB-eh-cwx" id="6dI-4d-28Q"/>
<outlet property="label" destination="15T-Hk-end" id="rtd-jg-ouc"/>
<outlet property="statusBtn" destination="UKV-VP-KnJ" id="bpN-lf-BQt"/>
</connections>
<point key="canvasLocation" x="162" y="119"/>
</view>

View File

@ -44,11 +44,15 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
@interface XuanduoTimerListViewController ()<IfishCommuniteDelegate,TimerTypeTableViewCellDelegate>
@property(nonatomic,strong) setRemindWaterModel *waterInfmodel;
@property(nonatomic,strong) Xuanduo2TimerModel *timerModel;
@property(nonatomic,strong) XuanduoTimerTypeModel *timerType;
@property(nonatomic,strong) XuanduoCycleModel *cycleModel;
@property (nonatomic,strong) NSMutableDictionary *timeDic;
@property(nonatomic,copy) NSString *nextChangeDateLabel;
@property(nonatomic,strong) MyHud *XuTohud;
//SOCKETblock
@property(nonatomic,strong) NSMutableDictionary *blockDict;
@end
@ -123,7 +127,10 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
float formatheigh = heighten/10;
_wenduString = [NSString stringWithFormat:@"%.0f~%.0f°C",formatlow,formatheigh];
}
-(void)setupData
{
self.blockDict=[[NSMutableDictionary alloc]init];
}
- (void)setupTable {
XuToControlName *name = [UserExtendataArchaver currentNewXuToControlName:self.currentdevice.macAddress];
@ -342,6 +349,21 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
if (!cell) {
cell=[[TimerTypeTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:timerTypeFlag];
}
cell.timerbtn.selected=NO;
cell.recoverybtn.selected=NO;
cell.cyclebtn.selected=NO;
if ([_timerType.type isEqualToString:@"08"]) {
cell.timerbtn.selected=YES;
}
else if ([_timerType.type isEqualToString:@"04"]) {
cell.cyclebtn.selected=YES;
}
else if ([_timerType.type isEqualToString:@"02"]||[_timerType.type isEqualToString:@"01"]||[_timerType.type isEqualToString:@"00"])
{
cell.recoverybtn.selected=YES;
}
cell.delegate=self;
return cell;
}else {
@ -605,51 +627,38 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
_selectSection = -1;
[self.tableView reloadData];
}else {
//
_selectSection = btn.tag - kBtnTag;
ReadTimerModel *readModel = [[ReadTimerModel alloc] init];
//
readModel.selectorName=_titieArr[_selectSection - 2];
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F]&&(_selectSection - 2)==2)
{
readModel.functionCode=@"19";//
}
else
{
readModel.functionCode=@"16";
}
readModel.functionCode=@"16";
readModel.sendmacId =self.currentdevice.macAddress;
readModel.resavemacId = self.currentdevice.macAddress;
readModel.crc16str=@"0000";
switch (_selectSection - 2) {
case 0: //
readModel.selectorNumber = @"04";
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
readModel.selectorNumber=@"01";
}
readModel.selectorNumber = @"f4";
break;
case 1: //
readModel.selectorNumber = @"01";
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
readModel.selectorNumber=@"02";
}
readModel.selectorNumber = @"f1";
break;
case 2: //1
readModel.selectorNumber = @"02";
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
readModel.selectorNumber=@"03";
}
readModel.selectorNumber = @"f2";
break;
case 3: //2
readModel.selectorNumber = @"03";
readModel.selectorNumber = @"f3";
break;
case 4: //
readModel.selectorNumber = @"06";
readModel.selectorNumber = @"f6";
break;
case 5: //
readModel.selectorNumber = @"05";
readModel.selectorNumber = @"f5";
break;
default:
break;
@ -1582,24 +1591,51 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
NSLog(@"return str == %@",string1);
NSString *readTimer = [string1 substringToIndex:4];
if (_selectSection-2<_titieArr.count && _selectSection-2>=0 && [readTimer isEqualToString:@"0116"]) {
if (!_timerModel) {
_timerModel = [[Xuanduo2TimerModel alloc] init];
_timerModel.groupModelArr = [NSMutableArray array];
}else {
[_timerModel.groupModelArr removeAllObjects];
NSString*lightNumber=[string1 substringWithRange:NSMakeRange(30, 2)];
//
if ([lightNumber.uppercaseString containsString:@"F"])
{
_timerType=[[XuanduoTimerTypeModel alloc]init];
_timerType.lightNumber=lightNumber;
_timerType.type=[string1 substringWithRange:NSMakeRange(32, 2)];
NSMutableArray *dataArr = [self.timeDic objectForKey:_titieArr[_selectSection-2]];
[dataArr removeAllObjects];
[dataArr addObject:plusflag];
BOOL havePlus = [dataArr containsObject:plusflag];
if (havePlus && dataArr.count > 10) {
[dataArr removeObjectAtIndex:0];
}else if (!havePlus && dataArr.count < 10){
[dataArr insertObject:plusflag atIndex:0];
}
}
[Xuanduo2DataUtility readTimerSocketDataWithBackMsgModel:_timerModel addWithBackStr:string1 type:self.currentdevice.type];
NSMutableArray *dataArr = [self.timeDic objectForKey:_titieArr[_selectSection-2]];
[dataArr removeAllObjects];
[dataArr addObject:plusflag];
[dataArr addObjectsFromArray:_timerModel.groupModelArr];
BOOL havePlus = [dataArr containsObject:plusflag];
if (havePlus && dataArr.count > 10) {
[dataArr removeObjectAtIndex:0];
}else if (!havePlus && dataArr.count < 10){
[dataArr insertObject:plusflag atIndex:0];
else if (0)
{
if (!_timerModel) {
_timerModel = [[Xuanduo2TimerModel alloc] init];
_timerModel.groupModelArr = [NSMutableArray array];
}else {
[_timerModel.groupModelArr removeAllObjects];
}
[Xuanduo2DataUtility readTimerSocketDataWithBackMsgModel:_timerModel addWithBackStr:string1 type:self.currentdevice.type];
NSMutableArray *dataArr = [self.timeDic objectForKey:_titieArr[_selectSection-2]];
[dataArr removeAllObjects];
[dataArr addObject:plusflag];
[dataArr addObjectsFromArray:_timerModel.groupModelArr];
BOOL havePlus = [dataArr containsObject:plusflag];
if (havePlus && dataArr.count > 10) {
[dataArr removeObjectAtIndex:0];
}else if (!havePlus && dataArr.count < 10){
[dataArr insertObject:plusflag atIndex:0];
}
NSLog(@"dataarr.count = %ld",dataArr.count);
}
NSLog(@"dataarr.count = %ld",dataArr.count);
}
@ -1615,6 +1651,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
}
if ([readTimer isEqualToString:@"0108"] || [readTimer isEqualToString:@"0105"]) {
[Xuanduo2DataUtility readSocketDataWithBackMsgModel:self.dataModel addWithBackData:data type:self.currentdevice.type];
[self refreshWithData:self.dataModel];

View File

@ -132,7 +132,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
}
else if(self.timerType==3)
{
type=@"自恢复模式";
type=@"定时自恢复模式";
}
_titieArr = @[type];
@ -186,7 +186,8 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
NSArray *dataArr = [self.timeDic objectForKey:_titieArr[0]];
return dataArr.count;
}
else{
else
{
return 0;
}
}
@ -347,7 +348,7 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
CGFloat height=0;
height=section==0?50:40;
height=(section==0?50:40);
return height;
}
@ -378,6 +379,21 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
return nil;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
CGFloat height=0;
if (section==0)
{
height=40;
}
return height;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView *oneHeader = [[UIView alloc] init];
oneHeader.backgroundColor = COLOR_MIAN;
return oneHeader;
}
#pragma mark tableView

View File

@ -443,10 +443,16 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
}else if(section == 2){
XuanduoSelectHeader *headerView = [XuanduoSelectHeader shareHeaderView];
headerView.controlBtn.tag = kBtnTag + section;
headerView.statusBtn.tag = kBtnTag + section;
[headerView.controlBtn setImage:[UIImage imageNamed:@"normalImage"] forState:UIControlStateNormal];
[headerView.controlBtn setImage:[UIImage imageNamed:@"selectedImage"] forState:UIControlStateNormal];
headerView.statusBtn.hidden=NO;
if (_selectSection == section) {
headerView.controlBtn.selected = YES;
}
[headerView.controlBtn addTarget:self action:@selector(foldAction:) forControlEvents:UIControlEventTouchUpInside];
[headerView.controlBtn addTarget:self action:@selector(statusChangeAction:) forControlEvents:UIControlEventTouchUpInside];
[headerView configWithImageName:_imgArr[section-2] labelName:_titieArr[section-2]];
return headerView;
}else if(section == 3){
@ -661,6 +667,69 @@ static NSString *timerTypeFlag = @"TimerTypeTableViewCell";
[_indicatorView startAnimating];
}
}
//
-(void)statusChangeAction:(UIButton*)btn
{
if (_selectSection == btn.tag - kBtnTag) {
_selectSection = -1;
[self.tableView reloadData];
}else {
_selectSection = btn.tag - kBtnTag;
ReadTimerModel *readModel = [[ReadTimerModel alloc] init];
//
readModel.selectorName=_titieArr[_selectSection - 2];
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F]&&(_selectSection - 2)==2)
{
readModel.functionCode=@"19";//
}
else
{
readModel.functionCode=@"16";
}
readModel.sendmacId =self.currentdevice.macAddress;
readModel.resavemacId = self.currentdevice.macAddress;
readModel.crc16str=@"0000";
switch (_selectSection - 2) {
case 0: //
readModel.selectorNumber = @"04";
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
readModel.selectorNumber=@"01";
}
break;
case 1: //
readModel.selectorNumber = @"01";
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
readModel.selectorNumber=@"02";
}
break;
case 2: //1
readModel.selectorNumber = @"02";
if([self.currentdevice.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{
readModel.selectorNumber=@"03";
}
break;
case 3: //2
readModel.selectorNumber = @"03";
break;
case 4: //
readModel.selectorNumber = @"06";
break;
case 5: //
readModel.selectorNumber = @"05";
break;
default:
break;
}
NSString*readString=[NSString stringWithFormat:@"%@%@%@",readModel.description,readModel.selectorNumber,readModel.crc16str];
NSData*readData=[dataContorl stringToHexData:readString];
[[Socketsingleton sharedInstance] soketWriteData:readData];
self.readMode=readModel;
[_indicatorView startAnimating];
}
}
- (void)switchAction:(UIButton *)btn {
NSInteger index = btn.tag - kSwitchBtnTag;