Browse Source

2017.07.11 장치리스트 홉허브 disconnect

eunmi.kim 8 years ago
parent
commit
d35b992c85

+ 1 - 0
OneCable/Classes/Model/LoginModel.h

@@ -209,6 +209,7 @@
 -(DeviceModel *)getHomeHub:(NSString*)homeHubId;
 -(DeviceModel *)getHomeHub;
 - (BOOL)onlineHomeHubFromSelectedHub:(DeviceModel*)selectedHub ;
+- (BOOL)connectedHomeHubFromSelectedHub:(DeviceModel*)selectedHub ;
 - (BOOL)isMultiHomeHub;
 
 @end

+ 31 - 0
OneCable/Classes/Model/LoginModel.m

@@ -246,6 +246,37 @@
 }
 
 
+- (BOOL)connectedHomeHubFromSelectedHub:(DeviceModel*)selectedHub {
+    
+    BOOL result = false;
+    
+    //멀티인경우
+    if (_deviceList.count > 1) {
+
+        for (DeviceModel *device in _deviceList) {
+            
+            if (selectedHub != nil) {
+                
+                if (EQUALS(selectedHub.deviceId, device.deviceId))
+                    return device.isDeviceConn;
+            }
+            else {
+                
+                if (device.isDeviceConn)
+                    return true;
+            }
+        }
+    }
+    //단일인 경우
+    else {
+        
+        return [self getHomeHub].isDeviceConn;
+    }
+    
+    return result;
+}
+
+
 - (void)setMemberId:(NSString *)memberId {
     _memberId = memberId;
 

+ 6 - 3
OneCable/Classes/ViewControllers/RuelsScreens/DaylightPopupView.m

@@ -221,8 +221,10 @@
 
     ItemSubModel *subItem = nil;
     if (_daylightTrigger.subItems && _daylightTrigger.subItems.count) {
+        
         subItem = _daylightTrigger.subItems[0];
-    } else {
+    }
+    else {
         subItem = [[ItemSubModel alloc] init];
         
         _daylightTrigger.daylights = (NSMutableArray<ItemSubModel> *)[[NSMutableArray alloc] init];
@@ -234,9 +236,10 @@
     subItem.sourceId = _weatherLocation.commonCode;
     subItem.sourceName = _weatherLocation.commonCodeName;
     subItem.sourceSubId = _btnSunRise.selected ? @"sunriseUtcTime" : @"sunsetUtcTime";
-
+    subItem.daysOfWeek = [TimePickerPopupView daysOfWeek:_chkDays];
+    
     //set Days condition
-    [TimePickerPopupView setDaysCondition:_refConditions chkDays:_chkDays];
+    //[TimePickerPopupView setDaysCondition:_refConditions chkDays:_chkDays];
     
     [super btnConfirmTouched:sender];
 }

+ 4 - 2
OneCable/Classes/ViewControllers/RuelsScreens/ExternHeatPopupView.m

@@ -268,7 +268,8 @@
     
     if (_externHeatTrigger.subItems && _externHeatTrigger.subItems.count) {
         subItem = _externHeatTrigger.subItems[0];
-    } else {
+    }
+    else {
         subItem = [[ItemSubModel alloc] init];
         
         _externHeatTrigger.heats = (NSMutableArray<ItemSubModel> *)[[NSMutableArray alloc] init];
@@ -284,9 +285,10 @@
     subItem.sourceName = _weatherLocation.commonCodeName;
     subItem.conditionTypeCode = _btnOver.selected ? ksConditionTypeCodeGreatOrEqual : ksConditionTypeCodeLessOrEqual;
     subItem.cmdclsValue = _temperature;
+    subItem.daysOfWeek = [TimePickerPopupView daysOfWeek:_chkDays];
     
     //set Days condition
-    [TimePickerPopupView setDaysCondition:_refConditions chkDays:_chkDays];
+    //[TimePickerPopupView setDaysCondition:_refConditions chkDays:_chkDays];
     
     [super btnConfirmTouched:sender];
 }

+ 61 - 23
OneCable/Classes/ViewControllers/RuelsScreens/RulesAddViewController.m

@@ -350,23 +350,26 @@
 
 - (void)requestRegisterRule {
     
-    NSLog(@"_conditions : %@", _conditions);
-    
-    
+    NSLog(@"requestRegisterRule");
     NSArray *triggers       = [self items:_triggers];
-    NSArray *actions        = [self items:_actions];
     
-    BOOL hasConditionForRegister = [_conditions matchedArrayInSubArrays:@"subItems" predicateFormat:@"conditionTypeCode == %@", @"09"].count || _chkConditions.checked;
-    NSArray *conditions     = hasConditionForRegister ? [self conditions:_conditions] : nil;
+    NSLog(@"triggers");
+    NSArray *actions        = [self items:_actions];
+    NSLog(@"actions");
+//    BOOL hasConditionForRegister = [_conditions matchedArrayInSubArrays:@"subItems" predicateFormat:@"conditionTypeCode == %@", @"09"].count || _chkConditions.checked;
+//    NSArray *conditions     = hasConditionForRegister ? [self conditions:_conditions] : nil;
+  
+    NSArray *conditions     = [self conditions:_conditions];
+    NSLog(@"conditions");
     
     //validate
     if (!triggers || !triggers.count) {
-        [[JDFacade facade] alert:NSLocalizedString(@"실행할 때를 선택하세요", @"실행할 때를 선택하세요")];
+        [[JDFacade facade] alert:NSLocalizedString(@"규칙을 실행할 조건을 설정하세요.", @"규칙을 실행할 조건을 설정하세요.")];
         return;
     }
     
     if (!actions || !actions.count) {
-        [[JDFacade facade] alert:NSLocalizedString(@"실행할 장치를 선택하세요", @"실행할 장치를 선택하세요")];
+        [[JDFacade facade] alert:NSLocalizedString(@"실행 조건에 맞춰 동작할 장치나 알림 메시지 중 최소 하나 이상을 설정하세요.", @"실행 조건에 맞춰 동작할 장치나 알림 메시지 중 최소 하나 이상을 설정하세요.")];
         return;
     }
     
@@ -487,14 +490,22 @@
     
     for (ItemModel *item in items) {
         
+        NSLog(@"item : %@", item);
+        
         NSDictionary *dic = nil;
         NSMutableArray *subItems = [[NSMutableArray alloc] init];
         
         NSArray *pdevices   = [self subItemsForType:item.subItems itemSubType:ksItemSubTypeCodeDevice];
+        NSLog(@"pdevices : %@", pdevices);
         NSArray *pushes     = [self subItemsForType:item.pushes itemSubType:ksItemSubTypeCodeAppPush];
+        NSLog(@"pushes : %@", pushes);
         NSArray *timers     = [self subItemsForType:item.timers itemSubType:ksItemSubTypeCodeTimer];
+        NSLog(@"timers : %@", timers);
         NSArray *daylights  = [self subItemsForType:item.daylights itemSubType:ksItemSubTypeCodeDaylight];
+        NSLog(@"daylights : %@", daylights);
         NSArray *heats      = [self subItemsForType:item.heats itemSubType:ksItemSubTypeCodeHeat];
+        NSLog(@"heats : %@", heats);
+        
         
         if (pdevices && pdevices.count) {//device
             [subItems addObjectsFromArray:pdevices];
@@ -521,6 +532,8 @@
                     @"item_sub_type_code": item.itemSubTypeCode,
                     @"item_sub": subItems};
             [rItems addObject:dic];
+            
+            NSLog(@"dic : %@ %@", dic, item.itemName);
         }
     }
     
@@ -530,6 +543,7 @@
 //서브아이템 배열을 리턴함.
 - (NSArray *)subItemsForType:(NSArray *)subItems itemSubType:(NSString *)itemSubTypeCode {
     
+    NSLog(@"itemSubTypeCode : %@", itemSubTypeCode);
     NSMutableArray *rSubItems = [[NSMutableArray alloc] init];
     
     if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeDevice]) {//디바이스일 경우,
@@ -545,35 +559,44 @@
             [rSubItems addObject:rSubItem];
         }
         
-    } else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeAppPush]) {//푸시일 경우,
+    }
+    else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeAppPush]) {//푸시일 경우,
         //at once.
-        
+        NSLog(@"subItems : %@", subItems);
         for (ItemSubModel *subItem in subItems) {
+            
+            NSLog(@"subItem : %@", subItem);
             NSDictionary *rSubItem = @{@"condition_type_code": subItem.conditionTypeCode,
                                        @"cmdcls_value": subItem.cmdclsValue};
             
             [rSubItems addObject:rSubItem];
         }
         
-    } else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeTimer]) {//타이머일 경우,
+    }
+    else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeTimer]) {//타이머일 경우,
         for (ItemSubModel *subItem in subItems) {
             NSDictionary *rSubItem = @{@"hour": subItem.hour,
-                                       @"minute": subItem.minute};
+                                       @"minute": subItem.minute,
+                                       @"dayofweek": subItem.daysOfWeek};
             
             [rSubItems addObject:rSubItem];
         }
-    } else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeDaylight]) {//해뜰때/질때 일 경우,
+    }
+    else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeDaylight]) {//해뜰때/질때 일 경우,
         for (ItemSubModel *subItem in subItems) {
             NSDictionary *rSubItem = @{@"source_id": subItem.sourceId,
-                                       @"source_sub_id": subItem.sourceSubId};
+                                       @"source_sub_id": subItem.sourceSubId,
+                                       @"dayofweek": subItem.daysOfWeek};
             
             [rSubItems addObject:rSubItem];
         }
-    } else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeHeat]) {//해뜰때/질때 일 경우,
+    }
+    else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeHeat]) {//온도
         for (ItemSubModel *subItem in subItems) {
             NSDictionary *rSubItem = @{@"source_id": subItem.sourceId,
                                        @"condition_type_code": subItem.conditionTypeCode,
-                                       @"cmdcls_value": subItem.cmdclsValue};
+                                       @"cmdcls_value": subItem.cmdclsValue,
+                                       @"dayofweek": subItem.daysOfWeek};
             
             [rSubItems addObject:rSubItem];
         }
@@ -593,7 +616,10 @@
         
         if ([condition.itemSubTypeCode isEqualToString:ksConditionSubTypeCodeHomeMode]) {
             for (ItemSubModel *mode in condition.subItems) {
+                
+                NSLog(@"mode : %@", mode);
                 NSDictionary *rSubItem = @{@"source_id": mode.sourceId,
+                                           @"condition_type_code": mode.conditionTypeCode,
                                            @"cmdcls_value": mode.cmdclsValue,
                                            @"condition_type_code": mode.conditionTypeCode};
                 
@@ -603,7 +629,11 @@
         else if ([condition.itemSubTypeCode isEqualToString:ksConditionSubTypeCodeDueDate]) {
             
             for (ItemSubModel *subItem in condition.subItems) {
-                NSDictionary *rSubItem = @{@"cmdcls_value": subItem.cmdclsValue,
+                NSLog(@"subItem : %@", subItem);
+                NSDictionary *rSubItem = @{@"source_id": subItem.sourceId,
+                                           @"source_sub_id": subItem.sourceSubId,
+                                           @"condition_type_code": subItem.conditionTypeCode,
+                                           @"cmdcls_value": subItem.cmdclsValue,
                                            @"condition_type_code": subItem.conditionTypeCode};
                 
                 [rSubItems addObject:rSubItem];
@@ -612,6 +642,7 @@
         else if ([condition.itemSubTypeCode isEqualToString:ksItemSubTypeCodeDevice]) {
             
             for (ItemSubModel *pdevice in condition.subItems) {
+                NSLog(@"pdevice : %@", pdevice);
                 NSDictionary *rSubItem = @{@"source_id": pdevice.sourceId,
                                            @"source_sub_id": pdevice.sourceSubId,
                                            @"cmdcls_value": pdevice.cmdclsValue,
@@ -624,6 +655,7 @@
         else if ([condition.itemSubTypeCode isEqualToString:ksConditionSubTypeCodeDaysOfWeek]) {
             
             for (ItemSubModel *subItem in condition.subItems) {
+                NSLog(@"subItem : %@", subItem);
                 NSDictionary *rSubItem = @{@"cmdcls_value": subItem.cmdclsValue,
                                            @"condition_type_code": subItem.conditionTypeCode};
                 
@@ -636,6 +668,8 @@
                     @"item_sub_type_code": condition.itemSubTypeCode,
                     @"item_sub": rSubItems};
             [rConditions addObject:dic];
+            
+            NSLog(@"dic : %@ %@", dic, condition.itemName);
         }
     }
     
@@ -1218,8 +1252,8 @@
             }
         }
         
-        NSLog(@"section == 4");
-        NSLog(@"_conditionDevices : %@", _conditionDevices);
+//        NSLog(@"section == 4");
+//        NSLog(@"_conditionDevices : %@", _conditionDevices);
         
         _rcv.conditions = _conditions;
         _rcv.refDevices = _conditionDevices;
@@ -1382,8 +1416,6 @@
         
         if (buttonIndex == 0) {//OK
             
-            NSLog(@"여기인가??");
-            
             subItem.cmdclsCode = matchedSubItem.cmdclsCode;
             subItem.cmdclsTypeId = matchedSubItem.cmdclsTypeId;
             subItem.cmdclsValueList = matchedSubItem.cmdclsValueList;
@@ -1613,10 +1645,14 @@
     }
     
     ItemModel *pushItem = [_actions objectKey:@"itemSubTypeCode" eqaulToString:ksItemSubTypeCodeAppPush];
+    
     if (pushItem) {
+        
         if (_txvMessage && [_txvMessage.text isEmptyString]) {//푸시메시지 여부 확인
             [_actions removeObject:pushItem];
-        } else if (_txvMessage) {
+        }
+        else if (_txvMessage) {
+            
             ItemSubModel *subItem = pushItem.pushes[0];
             subItem.cmdclsValue = _txvMessage.text;
             
@@ -1628,9 +1664,11 @@
     }
     
     if (!_refRuleDetail) {//생성
+        
         [self requestRegisterRule];
         
-    } else {//수정
+    }
+    else {//수정
 
         BOOL hasDeleteNode = NO;
         ItemModel *triggerDevice = [_triggers objectKey:@"itemSubTypeCode" eqaulToString:ksItemSubTypeCodeDevice];

+ 7 - 2
OneCable/Classes/ViewControllers/RuelsScreens/TimePickerPopupView.m

@@ -237,13 +237,18 @@
     ItemSubModel *subItem = nil;
     
     if (_timeTrigger.subItems && _timeTrigger.subItems.count) {
+        
         subItem = _timeTrigger.subItems[0];
-    } else {
+        
+    }
+    else {
+        
         subItem = [[ItemSubModel alloc] init];
 
         
         subItem.hour = _txtHour.text;
         subItem.minute = _txtMinute.text;
+        subItem.daysOfWeek = [TimePickerPopupView daysOfWeek:_chkDays];
         
         _timeTrigger.timers = (NSMutableArray<ItemSubModel> *)[[NSMutableArray alloc] init];
         [_timeTrigger.timers addObject:subItem];
@@ -257,7 +262,7 @@
 //    subItem.minute = ds.minute < 10 ? [NSString stringWithFormat:@"0%zd", ds.minute] : [NSString stringWithFormat:@"%zd", ds.minute];
     
     //set Days condition
-    [TimePickerPopupView setDaysCondition:_refConditions chkDays:_chkDays];
+//    [TimePickerPopupView setDaysCondition:_refConditions chkDays:_chkDays];
     
     [super btnConfirmTouched:sender];
 }

+ 1 - 0
OneCable/Classes/ViewControllers/RuelsScreens/TriggerSelectPopupView.m

@@ -62,6 +62,7 @@
 
 #pragma mark - UI Events
 - (IBAction)btnTimerTouched:(id)sender {
+    
     ItemModel *trigger = _refTriggers && _refTriggers.count ? _refTriggers[0] : nil;
     
     BOOL isNewTrigger = !trigger.timers || !trigger.timers.count;

+ 142 - 110
OneCable/Classes/ViewControllers/ThingsScreens/ThingsViewController.m

@@ -165,6 +165,18 @@
     [self prepareViewDidLoadRefreshPopup:NO];
 }
 
+
+- (void)viewWillDisappear:(BOOL)animated {
+    
+    if (_deviceCommandsBackgroundTimer) {
+        [_deviceCommandsBackgroundTimer invalidate];
+        _deviceCommandsBackgroundTimer = nil;
+    }
+    
+    [self releaseDevicesTimer];
+}
+
+
 - (void)initProperties {
     _deviceFlag = IS_IPHONE_6P ? 2 : 2;
 }
@@ -211,7 +223,12 @@
         
         for (DeviceModel *deviceModel in [JDFacade facade].loginUser.deviceList) {
             
-            if (!deviceModel.isDeviceOnlined) {
+            NSLog(@"isDeviceOnlined : %d, isDeviceConn : %d, is : %d",
+                  deviceModel.isDeviceOnlined,
+                  deviceModel.isDeviceConn,
+                  !deviceModel.isDeviceOnlined || !deviceModel.isDeviceConn);
+            
+            if (!deviceModel.isDeviceOnlined || !deviceModel.isDeviceConn) {
                 offlineCount++;
                 
                 if (offlineName.length == 0) {
@@ -220,6 +237,7 @@
             }
         }
         
+
         if (offlineCount == 1) {
 
             _lblOffline.text = [NSString stringWithFormat:@"%@ 오프라인", offlineName];
@@ -231,25 +249,30 @@
         }
         
         
+        NSLog(@"offlineCount : %ld", offlineCount);
         
         showOffline = offlineCount > 0;
-        
-        
+
     }
     else {
         
-        if (!deviceModel.isDeviceOnlined) {
+        if (!deviceModel.isDeviceOnlined || !deviceModel.isDeviceConn) {
             
             NSString *name = deviceModel.prdUserName != nil ? deviceModel.prdUserName : deviceModel.prdName;
             _lblOffline.text = [NSString stringWithFormat:@"%@ 오프라인", name];
         }
         
-        showOffline = !deviceModel.isDeviceOnlined;
+        showOffline = !deviceModel.isDeviceOnlined || !deviceModel.isDeviceConn;
+        
+        
+        NSLog(@"showOffline : %d %d %d", deviceModel.isDeviceOnlined,deviceModel.isDeviceConn, showOffline);
+        
     }
     
     _viewHeight.constant = showOffline ? 54 : 0;
 }
 
+
 - (void)initRefreshController {
     //set refresh controls
     __weak typeof(self) weakSelf = self;
@@ -284,6 +307,8 @@
     ////    }
 }
 
+
+//버튼 말풍선 셋팅
 - (void)setMoreBtnArray {
     
     _moreBtnArray = [NSMutableArray array];
@@ -296,7 +321,7 @@
     
     //멀티이고 하나 선택한 경우
     if (_selectHub != nil)
-        isOnlineHomeHub = _selectHub.isDeviceOnlined;
+        isOnlineHomeHub = _selectHub.isDeviceOnlined && _selectHub.isDeviceConn;
     
     if([[JDFacade facade].loginUser.gradeCode isEqualToString:KNEET_MEMBER_MASTER]) {
         for (int i = 0; i < 4; i++) {
@@ -365,6 +390,7 @@
 
 }
 
+
 - (void)fetchDevicesFromServer {
 
     [self performSelector:@selector(requestHomeHubList) withObject:nil afterDelay:0.0f];
@@ -412,8 +438,6 @@
 
 }
 
-
-
 - (void)precessMasterTransfer {
     
     [[JDFacade facade] confirmTitle:@"알림"
@@ -685,7 +709,7 @@
                                                    
                                                    DataSelectModel *data = [[DataSelectModel alloc] init];
                                                    data.title = info.deviceName;
-                                                   if (![info isDeviceOnlined]) {
+                                                   if (!info.isDeviceOnlined || !info.isDeviceConn) {
                                                        data.strColorCode = kUITextColorCode06;
                                                    }
                                                    
@@ -860,10 +884,9 @@
         _selectHub = (DeviceModel *)seleced.value;
         [JDFacade facade].loginUser.selectedHomeHubID = _selectHub.deviceId;
         
-        NSLog(@"Selected Hub : %@", _selectHub);
-        
         [self updateTitle];
         [self requestDeviceList:@YES];
+       
     }];
 }
 
@@ -991,12 +1014,12 @@
 }
 
 #pragma mark - UICollectionView Delegate
-
 - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
     NSInteger auth = [JDFacade facade].loginUser.level == 90
     && !_isDeleteMode
     && [_nodeListData isCanAddNode]
-    && [[JDFacade facade].loginUser onlineHomeHubFromSelectedHub:_selectHub]; //마스터 권한일 경우,
+    && [[JDFacade facade].loginUser onlineHomeHubFromSelectedHub:_selectHub]
+    && [[JDFacade facade].loginUser connectedHomeHubFromSelectedHub:_selectHub];
     
 //    NSLog(@"authCount : %ld", auth);
 //    NSLog(@"[JDFacade facade].loginUser.level : %ld", [JDFacade facade].loginUser.level);
@@ -1109,7 +1132,7 @@
             
         }
         
-        if (!device.isOnline) {
+        if (!device.isOnline || !device.isDeviceConn) {
 
             cell.lblDeviceStatus.text = @"OFFLINE";
             cell.lblDeviceStatus.textColor = kUITextColor01;
@@ -1444,6 +1467,93 @@
 }
 
 
+-(void)moreBtnAction:(id)sender
+{
+    NSInteger tag = [(UIButton *)sender tag];
+    NSLog(@"MoreBtn Action : %li", (long)tag);
+    switch (tag) {
+        case ReOrder:
+        {
+            [self toggleReOrderMode:YES];
+        }
+            break;
+        case Add:
+        {
+            [self addNewDevice];
+        }
+            break;
+        case Del:
+        {
+            [self toggleEditMode:YES];
+        }
+            break;
+        case Refresh:
+        {
+            [self refreshDeviceList];
+        }
+            break;
+            
+        default:
+            break;
+    }
+}
+
+
+-(void)btnDeviceTouched:(id)sender
+{
+    NSIndexPath *indexPath = (NSIndexPath *) ((CustomButton *)sender).value;
+    //
+    //    DeviceModel *device =_deviceList[indexPath.row];
+    //    NSLog(@"Device : %@", device);
+    [self moveToDetail:indexPath];
+}
+
+
+-(void)btnDeviceDelete:(id)sender
+{
+    NSIndexPath *indexPath = (NSIndexPath *) ((CustomButton *)sender).value;
+    
+    DeviceModel *device =_deviceList[indexPath.row];
+    
+    if (![device isOnline]) {
+        ThingsForcedDelViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsForcedDelViewController" storyboardName:@"Things"];
+        
+        vc.delDevice = device;
+        //        vc.providesPresentationContextTransitionStyle = YES;
+        //        vc.definesPresentationContext = YES;
+        //
+        //        [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
+        //
+        //        [self presentViewController:vc animated:NO completion:nil];
+        [self showTransparencyModalView:vc removeSelf:NO];
+        
+    } else {
+        ThingsGeneralDelViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsGeneralDelViewController" storyboardName:@"Things"];
+        
+        vc.delDevice = device;
+        //        vc.providesPresentationContextTransitionStyle = YES;
+        //        vc.definesPresentationContext = YES;
+        //
+        //        [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
+        //
+        //        [self presentViewController:vc animated:NO completion:nil];
+        [self showTransparencyModalView:vc removeSelf:NO];
+    }
+    
+    //    [self requestDeviceList:@NO];
+}
+
+
+-(void)finishDeviveDelete
+{
+    NSLog(@"tvc finishDeviveDelete");
+    
+    [self toggleEditMode:NO];
+    [self requestDeviceList:@YES];
+}
+
+
+
 #pragma mark - SocketService
 - (void) socketDidReceiveMessage:(id)message result:(SocketModel *)result
 {
@@ -1510,7 +1620,7 @@
     
     //    CommandModel *response = [[CommandModel alloc] initWithDictionary:notification.object error:nil];
     
-    //NSLog(@"Result : %@", result);
+    NSLog(@"Result : %@", result);
     
     if ([result.messageType isEquestToIgnoreCase:MSG_TYPE_NODE_CONTENT]) {
         ContentModel *response = [[ContentModel alloc] initWithDictionary:notification.object error:nil];
@@ -1535,120 +1645,42 @@
     else if ([result.messageType isEquestToIgnoreCase:MSG_TYPE_NODE_COMMAND_RES]) {
         
     }
-    else if ([result.messageType isEquestToIgnoreCase:MSG_TYPE_NODE_REGIST_RES] || [result.messageType isEquestToIgnoreCase:MSG_TYPE_NODE_DELETE_RES]) {
+    else if ([result.messageType isEquestToIgnoreCase:MSG_TYPE_NODE_REGIST_RES] ||
+             [result.messageType isEquestToIgnoreCase:MSG_TYPE_NODE_DELETE_RES]) {
         
         [self requestDeviceList:@NO];
         
     }
-    else if([result.messageType isEquestToIgnoreCase:MSG_TYPE_DEVICE_CONTENT]) {
+    else if([result.messageType isEquestToIgnoreCase:MSG_TYPE_DEVICE_CONTENT] ||
+            [result.messageType isEquestToIgnoreCase:MSG_TYPE_DEVICE_CONN]) {
 
         if (_selectHub != nil) {
             
             [JDFacade facade].loginUser.selectedHomeHubID = _selectHub.deviceId;
         }
 
-
-        [self performSelector:@selector(viewOfflineSetDeviceModel:) withObject:nil afterDelay:1.0f];
-        [self performSelector:@selector(setMoreBtnArray) withObject:nil afterDelay:1.0f];
-
-    }
-}
-
-#pragma mark - MoreButtonDelegate
--(void)moreBtnAction:(id)sender
-{
-    NSInteger tag = [(UIButton *)sender tag];
-    NSLog(@"MoreBtn Action : %li", (long)tag);
-    switch (tag) {
-        case ReOrder:
-        {
-            [self toggleReOrderMode:YES];
-        }
-            break;
-        case Add:
-        {
-            [self addNewDevice];
-        }
-            break;
-        case Del:
-        {
-            [self toggleEditMode:YES];
-        }
-            break;
-        case Refresh:
-        {
-            [self refreshDeviceList];
-        }
-            break;
-            
-        default:
-            break;
+        //소켓 통신을 핸들러와 동시에 받는데 핸들러에서 유저 정보에 디바이스 정보 업데이트 해줌. 그 후에 화면 갱신
+        [self performSelector:@selector(hubStatusChangeRefresh) withObject:nil afterDelay:1.0f];
+       
     }
 }
 
 
-#pragma mark - MemoryWarning
-
-- (void)viewWillDisappear:(BOOL)animated {
+//허브 상태 변경 전체 리프레시
+- (void)hubStatusChangeRefresh {
     
-    if (_deviceCommandsBackgroundTimer) {
-        [_deviceCommandsBackgroundTimer invalidate];
-        _deviceCommandsBackgroundTimer = nil;
-    }
-    
-    [self releaseDevicesTimer];
-}
-
-
--(void)btnDeviceTouched:(id)sender
-{
-    NSIndexPath *indexPath = (NSIndexPath *) ((CustomButton *)sender).value;
-    //
-    //    DeviceModel *device =_deviceList[indexPath.row];
-    //    NSLog(@"Device : %@", device);
-    [self moveToDetail:indexPath];
-}
-
--(void)btnDeviceDelete:(id)sender
-{
-    NSIndexPath *indexPath = (NSIndexPath *) ((CustomButton *)sender).value;
+//    NSLog(@"\n\ndeviceList : %@", _deviceList);
+//    NSLog(@"\n\ndeviceList : %@", [JDFacade facade].loginUser.deviceList);
+   
+    [self viewOfflineSetDeviceModel:nil]; //상단 오프라인 허브 정보 확성화 체크(온라인, 연결상태)
     
-    DeviceModel *device =_deviceList[indexPath.row];
+    [self setMoreBtnArray]; //상단 오른쪽 버튼 팝업 재조회(추가가능여부)
     
-    if (![device isOnline]) {
-        ThingsForcedDelViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsForcedDelViewController" storyboardName:@"Things"];
-        
-        vc.delDevice = device;
-        //        vc.providesPresentationContextTransitionStyle = YES;
-        //        vc.definesPresentationContext = YES;
-        //
-        //        [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
-        //
-        //        [self presentViewController:vc animated:NO completion:nil];
-        [self showTransparencyModalView:vc removeSelf:NO];
-        
-    } else {
-        ThingsGeneralDelViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"ThingsGeneralDelViewController" storyboardName:@"Things"];
-        
-        vc.delDevice = device;
-        //        vc.providesPresentationContextTransitionStyle = YES;
-        //        vc.definesPresentationContext = YES;
-        //        
-        //        [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
-        //        
-        //        [self presentViewController:vc animated:NO completion:nil];
-        [self showTransparencyModalView:vc removeSelf:NO];
-    }
+    [self requestHomeHubList]; //타이틀 허브 리스트 재조회(온라인, 연결상태)
     
-    //    [self requestDeviceList:@NO];
+    [_collectionView reloadData]; //장치추카 셀(온라인, 연결상태)
 }
 
--(void)finishDeviveDelete
-{
-    NSLog(@"tvc finishDeviveDelete");
-    
-    [self toggleEditMode:NO];
-    [self requestDeviceList:@YES];
-}
+
 
 @end