//
//  ItemModel.h
//  kneet
//
//  Created by Jason Lee on 4/1/15.
//  Copyright (c) 2015 ntels. All rights reserved.
//
#import "JDJSONModel.h"

#define ksItemSubTypeCodeDevice     @"01"
#define ksItemSubTypeCodeMode       @"02"
#define ksItemSubTypeCodeAppPush    @"03"
#define ksItemSubTypeCodeTimer      @"05"
#define ksItemSubTypeCodeGeoFencing @"06"

#define ksItemTypeCodeTrigger       @"01"
#define ksItemTypeCodeAction        @"02"
#define ksItemTypeCodeCondition     @"03"

#define ksConditionSubTypeCodeDueDate       @"21"
#define ksConditionSubTypeCodeDaysOfWeek    @"22"
#define ksConditionSubTypeCodeDueTime       @"23"
#define ksConditionSubTypeCodeHomeMode      @"02"
#define ksConditionSubTypeCodeExternHeat    @"31"

@protocol ItemModel;
@protocol ItemSubModel;
@protocol ModeModel;
@protocol DeviceModel;

@interface ItemSubModel : JDJSONModel {//subCondition
@protected
    NSString *_cmdclsValueMsg;
}

//@property (copy, nonatomic) NSString *itemSubTypeCode;
@property (copy, nonatomic) NSString *subSequence;
@property (copy, nonatomic) NSString *sourceId;
@property (copy, nonatomic) NSString *sourceSubId;
@property (copy, nonatomic) NSString *conditionTypeCode;
@property (copy, nonatomic) NSString *cmdclsValue;
@property (copy, nonatomic) NSString *cmdclsValueMsg;
@property (copy, nonatomic) NSString *dataTypeCode;
@property (copy, nonatomic) NSString *sourceName;
@property (copy, nonatomic) NSString *sourceSubName;
@property (copy, nonatomic) NSString *actionTypeCode;
@property (copy, nonatomic) NSString *deleteYn;

@property (copy, nonatomic) NSString *hour;
@property (copy, nonatomic) NSString *minute;
@property (copy, nonatomic) NSString *nickname;
@property (copy, nonatomic) NSString *predCmdclsValue;

@property (strong, nonatomic) NSMutableArray<ItemModel> *conditions;

//flash
@property (copy, nonatomic) NSString<Ignore> *dueDate;
@property (copy, nonatomic) NSString<Ignore> *daysOfWeek;
@property (copy, nonatomic) NSString<Ignore> *dueTime;
@property (copy, nonatomic) NSString<Ignore> *homeModes;
@property (copy, nonatomic) NSString<Ignore> *externHeat;


@end

@protocol PredefinedDeviceModel;
@interface ItemModel : JDJSONModel  //condition

@property (copy, nonatomic) NSString *predItemSequence;
@property (copy, nonatomic) NSString *itemTypeCode;
@property (copy, nonatomic) NSString *itemSubTypeCode;
@property (copy, nonatomic) NSString *itemName;

@property (copy, nonatomic) NSString *predRuleId;

@property (copy, nonatomic) NSString *predSceneId;
@property (copy, nonatomic) NSString *predActionSequence;
@property (copy, nonatomic) NSString *cnt;
@property (copy, nonatomic) NSString *totalCnt;
@property (copy, nonatomic) NSString *imageFileName;



@property (strong, nonatomic) NSMutableArray<ItemSubModel> *subItems;

//for register
@property (strong, nonatomic) NSMutableArray<PredefinedDeviceModel> *predDevices;
@property (strong, nonatomic) NSMutableArray<ModeModel> *modes;
@property (strong, nonatomic) NSMutableArray<ItemSubModel> *pushes;
@property (strong, nonatomic) NSMutableArray<ItemSubModel> *timers;
@property (strong, nonatomic) NSMutableArray<DeviceModel> *mobileDevices;

//fuction
@property (assign, nonatomic, readonly) NSInteger sumPredDeviceCount;
@property (assign, nonatomic, readonly) NSInteger sumModesCount;
@property (assign, nonatomic, readonly) NSInteger sumPushesCount;

+ (NSString *)itemSubTypeString:(NSString *)itemSubTypeCode;

@end

@interface ItemListModel : JDJSONModel
@property (copy, nonatomic) NSMutableArray<ItemModel> *list;
@end
