Преглед изворни кода

- 멀티 홈허브 선택창 작업

KaRam Kim пре 8 година
родитељ
комит
707dbcc630

+ 4 - 3
OneCable/Classes/Model/DeviceModel.h

@@ -39,18 +39,19 @@
 @property (copy, nonatomic) NSString *deviceType;
 @property (copy, nonatomic) NSString *collectTime;
 
-@property (copy, nonatomic) NSString *deviceOnline;
+@property (copy, nonatomic) NSString *deviceOnline; //홈허브 네트워크(MQTT) 연결상태
 @property (copy, nonatomic) NSString *deviceOnlineLastDatetime;
 @property (copy, nonatomic) NSString *deviceConnLastDatetime;
-@property (copy, nonatomic) NSString *deviceConn;
+@property (copy, nonatomic) NSString *deviceConn;  // 홈허브 동글 연결 상태
 
 @property (copy, nonatomic) NSString *deviceclassTypeId;
 
 @property (copy, nonatomic) NSString *totalCtrtCnt; //게이트웨이 별 전체 장치 개수
 @property (copy, nonatomic) NSString *remainCtrtCnt;//추가가가능한 장치 개수
 
-@property (assign, nonatomic, readonly) BOOL isDeviceOnlined;
+@property (assign, nonatomic, readonly) BOOL isDeviceOnlined; //홈허브 네트워크(MQTT) 연결상태
 @property (assign, nonatomic, readonly) BOOL isDeviceConn;
+@property (assign, nonatomic, readonly) BOOL isUpdateNeed; // 홈허브 동글 연결 상태
 
 //detail
 @property (copy, nonatomic) NSString *seq;

+ 10 - 0
OneCable/Classes/Model/DeviceModel.m

@@ -685,6 +685,16 @@
     return _deviceConn && ![_deviceConn isEmptyString] && [_deviceConn isEqualToString:@"connect"];
 }
 
+-(BOOL)isUpdateNeed {
+    BOOL result = NO;
+    
+    if (![_lastFirmwareVersion isEquestToIgnoreCase:_firmwareVersion] || ![_lastSoftwareVersion isEquestToIgnoreCase:_softwareVersion]) {
+        result = YES;
+    }
+    
+    return result;
+}
+
 
 @end
 

+ 9 - 0
OneCable/Classes/Model/SocketMsgModel.h

@@ -23,9 +23,18 @@
 #define  MSG_TYPE_NODE_DELETE_RES       @"node.delete.result"
 #define  MSG_TYPE_NODE_REGIST_RES       @"node.register.result"
 
+#define  MSG_TYPE_NODE_PROFILE_UPDATE       @"node.profile.update"
+#define  MSG_TYPE_NODE_PROFILE_UPDATE_RES   @"node.profile.update.result"
+
 #define  MSG_TYPE_DEVICE_CONTENT       @"device.content"
 #define  MSG_TYPE_NODE_CONTENT         @"node.content"
 
+#define  MSG_TYPE_FIRMWARE_UPGRADE          @"firmware.upgrade"
+#define  MSG_TYPE_FIRMWARE_UPGRADE_RESULT   @"firmware.upgrade.result"
+#define  MSG_TYPE_SOFTWARE_UPGRADE          @"software.upgrade"
+#define  MSG_TYPE_SOFTWARE_UPGRADE_RESULT   @"software.upgrade.result"
+#define  MSG_TYPE_NODES_RELOAD              @"nodes.reload"
+
 
 
 #define  CMD_TYPE_PAIRING_START         @"pairing_start"

+ 2 - 0
OneCable/Classes/Util/CommonUtil.h

@@ -160,6 +160,8 @@ typedef enum {
 + (NSString *)stringFromDate2:(NSDate *)date;
 + (NSString *)birthStringFromDate:(NSDate *)date;
 
++ (NSString *)connectDataFromStr:(NSString *)dateString;
+
 + (NSString *)stringFromString:(NSString *)dateString;
 + (NSString *)stringFromDateComponents:(NSDateComponents *)components;
 + (NSString *)stringFromDateComponents2:(NSDateComponents *)components;

+ 11 - 0
OneCable/Classes/Util/CommonUtil.m

@@ -576,6 +576,17 @@
     return [CommonUtil stringFromDateComponents:components];
 }
 
++ (NSString *)connectDataFromStr:(NSString *)dateString
+{
+    NSDate *date = [CommonUtil dateFromDateString:dateString];
+    
+    NSDateFormatter *df = [CommonUtil dateFormatter];
+    df.dateFormat = @"YYYY.MM.dd HH:mm:ss";
+    
+    return [NSString stringWithFormat:@"%@", [df stringFromDate:date]];
+
+}
+
 
 + (NSDateComponents *)dateComponentsFromString:(NSString *)dateString {
 

+ 1 - 0
OneCable/Classes/ViewControllers/HomeHubScreens/HomeHubViewController.h

@@ -14,6 +14,7 @@
 
 @interface HomeHubViewController : JDViewController <BLEServiceHandlerDelegate>
 
+@property (weak, nonatomic) DeviceModel *selectHub;
 #pragma mark - Properties
 @property (weak, nonatomic) IBOutlet CustomTableView *tableView;
 @property (weak, nonatomic) IBOutlet CustomButton *btnEditTitle; // Head Title 명 수정 버튼

+ 13 - 7
OneCable/Classes/ViewControllers/HomeHubScreens/HomeHubViewController.m

@@ -37,12 +37,14 @@
 @interface HomeHubViewController () {
     
     BOOL bleState;
-
+    DeviceModel *hubInfo;
 }
 @end
 
 #pragma mark - Class Definition
 
+
+
 @implementation HomeHubViewController 
 
 
@@ -68,6 +70,12 @@
     bleState = NO;
     BLEServiceHandler *bleService = [BLEServiceHandler sharedManager];
     bleService.delegate = self;
+    
+    if (_selectHub == nil) {
+        hubInfo = [[JDFacade facade].loginUser getHomeHub];
+    } else {
+        hubInfo = _selectHub;
+    }
 }
 
 
@@ -112,23 +120,21 @@
         
         [self masterBtn:tcell.btnSet];
         
-        if (!([[Reachability reachabilityForInternetConnection]currentReachabilityStatus] == NotReachable)) {
-
+        if ([hubInfo isDeviceOnlined]) {
             tcell.lblNetworkStatus.text = @"온라인";
             tcell.lblBrokenTime.text = @"";
             tcell.lblNetworkStatus.textColor = kUITextColor04;
             tcell.imgvStatus.hidden = YES;
-            
         } else {
             tcell.lblNetworkStatus.text = @"오프라인";
-            tcell.lblBrokenTime.text = @"2017.04.04 15:33:30";
+            tcell.lblBrokenTime.text = [CommonUtil stringFromString:hubInfo.deviceOnlineLastDatetime];
             tcell.lblNetworkStatus.textColor = kUITextColor07;
             tcell.lblBrokenTime.textColor = kUITextColor07;
             tcell.imgvStatus.hidden = NO;
-//            tcell.imgvStatus.image = [UIImage imageNamed:@"common_bullet_alert_on"];
         }
+            
         
-        if([JDFacade facade].loginUser.isHomehubOnline){
+        if([hubInfo isDeviceConn]){
             
             tcell.lblDeviceStatus.text = @"온라인";
             tcell.lblDeviceStatus.textColor = kUITextColor04;

+ 83 - 4
OneCable/Classes/ViewControllers/HomeHubScreens/MultiHomeHubViewController.m

@@ -13,6 +13,8 @@
 #import "CustomButton.h"
 #import "Reachability.h"
 
+#import "HomeHubViewController.h"
+
 /**
  
  네트워크, 동글 On / Off 이미지
@@ -24,6 +26,9 @@
     Off : img_homehub_list_update_off
  **/
 @interface MultiHomeHubViewController ()
+{
+    UIImage *_imgOnline, *_imgOffLine, *_imgUptOn, *_imgUptOff;
+}
 
 @end
 
@@ -40,6 +45,7 @@
     [super viewDidLoad];
     
     [self initUI];
+    [self prepareViewDidLoad];
 }
 
 - (void)initUI {
@@ -47,12 +53,22 @@
     [self initTableViewAsDefaultStyle:_tableView];
 }
 
+- (void)prepareViewDidLoad {
+    
+    _imgOnline = [UIImage imageNamed:@"img_homehub_list_connect"];
+    _imgOffLine = [UIImage imageNamed:@"img_homehub_list_connect"];
+    _imgUptOn = [UIImage imageNamed:@"img_homehub_list_update_on"];
+    _imgUptOff = [UIImage imageNamed:@"img_homehub_list_update_off"];
+}
+
+
+#pragma mark - TableView Delegate
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
     return 1;
 }
 
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
-    return 1;
+    return [[JDFacade facade].loginUser.deviceList count];
 }
 
 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
@@ -63,15 +79,78 @@
 }
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     
-    UITableViewCell *cell = nil;
+    DeviceModel *info = [[JDFacade facade].loginUser.deviceList objectAtIndex:indexPath.row];
+    
+    MultiHomeHubTableViewCell *cell = (MultiHomeHubTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"MultiHubCellIdentifier"];
+    
+    cell.lblTitle.text = [NSString stringWithFormat:@"%@", info.deviceName];
+    cell.btnHubDetail.tag = indexPath.row;
     
-    MultiHomeHubTableViewCell *tcell = (MultiHomeHubTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"MultiHubCellIdentifier"];
+    // 네트워크 연결상태 확인
+    if ([info isDeviceConn]) {
+        cell.imgNetwork.image = _imgOnline;
+    } else {
+        cell.imgNetwork.image = _imgOffLine;
+    }
+
+    // Z-Wave 동작상태 확인
+    if ([info isDeviceOnlined]) {
+        cell.imgDongle.image = _imgOnline;
+    } else {
+        cell.imgDongle.image = _imgOnline;
+    }
     
-    cell = tcell;
+    if ([info isUpdateNeed]) {
+        cell.imgUpdate.image = _imgUptOn;
+    } else {
+        cell.imgUpdate.image = _imgUptOff;
+    }
+        
     
     return cell;
 }
 
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+    [tableView deselectRowAtIndexPath:indexPath animated:NO];
+    
+     [self showHomeHubDetail:indexPath];
+}
+
+
+- (IBAction)btnHubDetail:(id)sender {
+    UIButton *senderButton = (UIButton *)sender;
+    
+    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:senderButton.tag inSection:0];
+    
+    [self showHomeHubDetail:indexPath];
+}
+
+
+-(void)showHomeHubDetail:(NSIndexPath *)indexPath
+{
+    DeviceModel *info = [[JDFacade facade].loginUser.deviceList objectAtIndex:indexPath.row];
+    HomeHubViewController *vc = (HomeHubViewController *)[CommonUtil instantiateViewControllerWithIdentifier:@"HomeHubViewController" storyboardName:@"Main"];
+    vc.selectHub = info;
+
+//    vc.providesPresentationContextTransitionStyle = YES;
+//    vc.definesPresentationContext = YES;
+//    
+//    [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
+//    
+    UIViewController *pvc = self.presentingViewController;
+    [self dismissViewControllerAnimated:NO completion:^{//TODO : UI Confirm with Mr.Mo
+        [pvc presentViewController:vc animated:YES completion:nil];
+    }];
+   
+//    UIViewController *pvc = self.presentingViewController;
+//    [self dismissViewControllerAnimated:NO completion:^{
+//        [pvc presentViewController:vc animated:YES completion:nil];
+//    }];
+//
+//    [self presentViewController:vc animated:YES completion:nil];
+}
+
+
 - (IBAction)btnCloseTouched:(id)sender {
     [self dismissViewControllerAnimated:YES completion:nil];
 }

+ 1 - 1
OneCable/Classes/ViewControllers/MainScreens/ManagementViewController.m

@@ -91,7 +91,7 @@
 // 홈허브 이동
 - (IBAction)btnHomeHubTouched:(id)sender {
 
-    UIViewController *vc = vc = [CommonUtil instantiateViewControllerWithIdentifier:@"HomeHubViewController" storyboardName:@"Main"];
+    UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"HomeHubViewController" storyboardName:@"Main"];
     
     //멀티 홈허브일때
     if ([[JDFacade facade].loginUser isMultiHomeHub]) {