| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882 |
- // Generated by json_to_model
- #import "JDObject.h"
- #import "DeviceModel.h"
- #import "CustomRadioGroup.h"
- #import "CustomCheckBox.h"
- @implementation DeviceModel
- //+ (JSONKeyMapper *)keyMapper {
- //
- // NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
- //
- // //self
- // [dictionary setValue:@"cmdclsTypeSystemName" forKey:@"cmdcls_type_system_name"];
- // [dictionary setValue:@"cmdclsTypeId" forKey:@"cmdcls_type_id"];
- // [dictionary setValue:@"cmdclsCode" forKey:@"cmdcls_code"];
- // [dictionary setValue:@"deviceProfileId" forKey:@"device_profile_id"];
- // [dictionary setValue:@"createDatetime" forKey:@"create_datetime"];
- // [dictionary setValue:@"cmdclsTypeName" forKey:@"cmdcls_type_name"];
- // [dictionary setValue:@"deviceName" forKey:@"device_name"];
- // [dictionary setValue:@"profileName" forKey:@"profile_name"];
- // [dictionary setValue:@"imageFileName" forKey:@"image_file_name"];
- // [dictionary setValue:@"contentValue" forKey:@"content_value"];
- // [dictionary setValue:@"nodeName" forKey:@"node_name"];
- // [dictionary setValue:@"cmdclsCount" forKey:@"cmdcls_count"];
- // [dictionary setValue:@"nodeId" forKey:@"node_id"];
- // [dictionary setValue:@"deviceId" forKey:@"device_id"];
- //
- // return [[JSONKeyMapper alloc] initWithDictionary:dictionary];
- //}
- - (NSString *)deviceName {
- NSString *result = @"";
-
- if (![_prdName isEmptyString]) {
- result = _prdName;
- }
-
- if (![_prdUserName isEmptyString]) {
- result = _prdUserName;
- }
-
- return result;
- }
- - (NSString *)contentValueMsgOfSensorBinary {
- NSInteger typeId = [_cmdclsTypeId integerValue];
- NSString *msg = ksEmptyString;
- switch (typeId) {
- case 11001:
- case 11002:
- case 11003:
- case 11004:
- case 11005:
- case 11006:
- case 11007:
- case 11008:
- case 11009:
- case 11010:
- case 11012:
- case 11013:
- case 11014:
- case 11016:
- case 11018:
- if ([self.contentValue isEqualToString:@"TRUE"]) {
- msg = NSLocalizedString(@"감지됨", @"감지됨");
- } else if ([self.contentValue isEqualToString:@"FALSE"]) {
- msg = NSLocalizedString(@"정상", @"정상");
- } else {
- msg = @"-";
- }
- break;
- case 11011:
- if ([self.contentValue isEqualToString:@"TRUE"]) {
- msg = NSLocalizedString(@"열림", @"열림");
- } else if ([self.contentValue isEqualToString:@"FALSE"]) {
- msg = NSLocalizedString(@"닫힘", @"닫힘");
- } else {
- msg = @"-";
- }
- break;
- case 11015:
- case 11017:
- if ([self.contentValue isEqualToString:@"TRUE"]) {
- msg = NSLocalizedString(@"들어옴", @"들어옴");
- } else if ([self.contentValue isEqualToString:@"FALSE"]) {
- msg = NSLocalizedString(@"나감", @"나감");
- } else {
- msg = @"-";
- }
- break;
- }
- return msg;
- }
- - (NSString *)contentValueMsgOfThermostatMode {
- NSInteger typeId = [_cmdclsTypeId integerValue];
- NSString *msg = ksEmptyString;
- switch (typeId) {
- case 13001:
- case 13002:
- case 13003:
- case 13004:
- if ([self.contentValue isEqualToString:@"OFF"]) {
- msg = NSLocalizedString(@"꺼짐", @"꺼짐");
- } else if ([self.contentValue isEqualToString:@"COOL"]) {
- msg = NSLocalizedString(@"냉방", @"냉방");
- } else if ([self.contentValue isEqualToString:@"HEAT"]) {
- msg = NSLocalizedString(@"난방", @"난방");
- } else if ([self.contentValue isEqualToString:@"AUTO"]) {
- msg = NSLocalizedString(@"자동", @"자동");
- } else if ([self.contentValue isEqualToString:@"FAN_ONLY"]) {
- msg = NSLocalizedString(@"환기", @"환기");
- } else if ([self.contentValue isEqualToString:@"DRY_AIR"]) {
- msg = NSLocalizedString(@"제습", @"제습");
- } else if ([self.contentValue isEqualToString:@"AWAY"]) {
- msg = NSLocalizedString(@"외출", @"외출");
- } else {
- msg = @"-";
- }
- break;
- }
- return msg;
- }
- - (NSString *)contentValueMsgOfLock {
- NSInteger typeId = [_cmdclsTypeId integerValue];
- NSString *msg = ksEmptyString;
- switch (typeId) {
- case 14001:
- if ([self.contentValue isEqualToString:@"LOCKED"]) {
- msg = NSLocalizedString(@"잠김", @"잠김");
- } else if ([self.contentValue isEqualToString:@"UNLOCKED"]) {
- msg = NSLocalizedString(@"열림", @"열림");
- } else if ([self.contentValue isEqualToString:@"JAMMED"]) {
- msg = NSLocalizedString(@"걸림", @"걸림");
- } else if ([self.contentValue isEqualToString:@"FORCED_OPEN"]) {
- msg = NSLocalizedString(@"수동", @"수동");
- } else if ([self.contentValue isEqualToString:@"UNSPECIFIED"]) {
- msg = NSLocalizedString(@"오류", @"오류");
- } else {
- msg = @"-";
- }
- break;
- case 14002:
- case 14003:
- if ([self.contentValue isEqualToString:@"LOCKED"]) {
- msg = @"잠김";
- } else if ([self.contentValue isEqualToString:@"UNLOCKED"]) {
- msg = @"열림";
- } else {
- msg = @"-";
- }
- break;
- }
- return msg;
- }
- - (NSString *)contentValueMsgOfSwitchBinary {
- NSInteger typeId = [_cmdclsTypeId integerValue];
- NSString *msg = ksEmptyString;
- switch (typeId) {
- case 17001:
- case 17002:
- if ([self.contentValue isEqualToString:@"ON"]) {
- msg = NSLocalizedString(@"켜짐", @"켜짐");
- } else if ([self.contentValue isEqualToString:@"OFF"]) {
- msg = NSLocalizedString(@"꺼짐", @"꺼짐");
- } else {
- msg = @"-";
- }
- break;
- }
- return msg;
- }
- - (NSString *)contentValueMsgOfValve {
- NSInteger typeId = [_cmdclsTypeId integerValue];
- NSString *msg = ksEmptyString;
- switch (typeId) {
- case 36001:
- case 36002:
- case 36003:
- default:
- if ([self.contentValue isEqualToString:@"OPEN"]) {
- msg = NSLocalizedString(@"열림", @"열림");
- } else if ([self.contentValue isEqualToString:@"CLOSE"]) {
- msg = NSLocalizedString(@"잠김", @"잠김");
- } else {
- msg = @"-";
- }
- break;
- }
- return msg;
- }
- - (NSString *)contentValueMsg {
-
- switch ([self cmdclsType]) {
- case CmdClsTypeSensorBinary:
- _contentValueMsg = [self contentValueMsgOfSensorBinary];
- break;
- case CmdClsTypeThermostatMode:
- _contentValueMsg = [self contentValueMsgOfThermostatMode];
- break;
- case CmdClsTypeLock:
- _contentValueMsg = [self contentValueMsgOfLock];
- break;
- case CmdClsTypeSwitchBinary:
- _contentValueMsg = [self contentValueMsgOfSwitchBinary];
- break;
- case CmdClsTypeSpeedControl:
- _contentValueMsg = [self contentValueMsgOfSpeedControl];
- break;
- case CmdClsTypeAVControlPlayback:
- _contentValueMsg = [self contentValueMsgOfAVPlayback];
- break;
- case CmdClsTypeValve:
- _contentValueMsg = [self contentValueMsgOfValve];
- break;
- default:
- _contentValueMsg = !_contentValue || [_contentValue isEmptyString] || [_contentValue isEqualToString:@"none"] ? @"-" : [NSString stringWithFormat:@"%@%@", _contentValue, _unit];
- break;
- }
- return _contentValueMsg;
- }
- - (NSString *)contentValueMsgOfSpeedControl {
- NSInteger typeId = [_cmdclsTypeId integerValue];
- NSString *msg = ksEmptyString;
- switch (typeId) {
- case 20001:
- if ([self.contentValue isEqualToString:@"OFF"]) {
- msg = NSLocalizedString(@"꺼짐", @"꺼짐");
- } else if ([self.contentValue isEqualToString:@"LOW"]) {
- msg = NSLocalizedString(@"약", @"약");
- } else if ([self.contentValue isEqualToString:@"MEDIUM"]) {
- msg = NSLocalizedString(@"중", @"중");
- } else if ([self.contentValue isEqualToString:@"HIGH"]) {
- msg = NSLocalizedString(@"강", @"강");
- } else {
- msg = @"-";
- }
- break;
- }
- return msg;
- }
- - (NSString *)contentValueMsgOfAVPlayback {
- NSInteger typeId = [_cmdclsTypeId integerValue];
- NSString *msg = ksEmptyString;
- switch (typeId) {
- case 21001:
- if ([self.contentValue isEqualToString:@"PLAYING"]) {
- msg = NSLocalizedString(@"재생 중", @"재생 중");
- } else if ([self.contentValue isEqualToString:@"PAUSED"]) {
- msg = NSLocalizedString(@"정지 됨", @"정지 됨");
- } else {
- msg = @"-";
- }
- break;
- }
- return msg;
- }
- - (UIImage *)imageForHeatInSeason {
- NSString *month = [NSString stringWithFormat:@"%zd", [CommonUtil dateComponents:[NSDate systemDate]].month];
-
- NSArray *summer = @[@"6", @"7", @"8", @"9"];
- NSArray *winter = @[@"12", @"1", @"2"];
-
- BOOL isSummer = [summer indexOfObjectIdenticalTo:month];
- BOOL isWinter = [winter indexOfObjectIdenticalTo:month];
-
- NSInteger min = 20;
- min = isSummer ? 26 : min;
- min = isWinter ? 18 : min;
-
- NSInteger max = 22;
- max = isSummer ? 28 : max;
- max = isWinter ? 20 : max;
-
- UIImage *image = nil;
- NSInteger heat = [_contentValue integerValue];
- if (heat < min) {
- image = [UIImage imageNamed:@"img_things_detail_03_01_sensor_temperature_cool"];
- } else if (heat > max) {
- image = [UIImage imageNamed:@"img_things_detail_03_03_sensor_temperature_hot"];
- } else {
- image = [UIImage imageNamed:@"img_things_detail_03_02_sensor_temperature_nice"];
- }
- return image;
- }
- - (NSString *)conditionForHeatInSeason {
- NSString *month = [NSString stringWithFormat:@"%zd", [CommonUtil dateComponents:[NSDate systemDate]].month];
-
- NSArray *summer = @[@"6", @"7", @"8", @"9"];
- NSArray *winter = @[@"12", @"1", @"2"];
-
- BOOL isSummer = [summer indexOfObjectIdenticalTo:month];
- BOOL isWinter = [winter indexOfObjectIdenticalTo:month];
-
- NSInteger min = 20;
- min = isSummer ? 26 : min;
- min = isWinter ? 18 : min;
-
- NSInteger max = 22;
- max = isSummer ? 28 : max;
- max = isWinter ? 20 : max;
-
- NSString *condition = nil;
- NSInteger heat = [_contentValue integerValue];
- if (heat < min) {
- condition = @"추워요";
- } else if (heat > max) {
- condition = @"더워요";
- } else {
- condition = @"쾌적해요";
- }
-
- return condition;
- }
- - (UIImage *)imageForHumidityInSeason {
- NSString *month = [NSString stringWithFormat:@"%zd", [CommonUtil dateComponents:[NSDate systemDate]].month];
-
- NSArray *summer = @[@"6", @"7", @"8", @"9"];
- NSArray *winter = @[@"12", @"1", @"2"];
-
- BOOL isSummer = [summer indexOfObjectIdenticalTo:month];
- BOOL isWinter = [winter indexOfObjectIdenticalTo:month];
-
- NSInteger min = 50;
- min = isSummer ? 30 : min;
- min = isWinter ? 60 : min;
-
- NSInteger max = 60;
- max = isSummer ? 40 : max;
- max = isWinter ? 70 : max;
-
- UIImage *image = nil;
- NSInteger heat = [_contentValue integerValue];
- if (heat < min) {
- image = [UIImage imageNamed:@"img_things_detail_04_01_sensor_humidity_dry"];
- } else if (heat > max) {
- image = [UIImage imageNamed:@"img_things_detail_04_02_sensor_humidity_nice"];
- } else {
- image = [UIImage imageNamed:@"img_things_detail_04_03_sensor_humidity_moist"];
- }
- return image;
- }
- - (NSString *)conditionForHumidityInSeason {
- NSString *month = [NSString stringWithFormat:@"%zd", [CommonUtil dateComponents:[NSDate systemDate]].month];
-
- NSArray *summer = @[@"6", @"7", @"8", @"9"];
- NSArray *winter = @[@"12", @"1", @"2"];
-
- BOOL isSummer = [summer indexOfObjectIdenticalTo:month];
- BOOL isWinter = [winter indexOfObjectIdenticalTo:month];
-
- NSInteger min = 50;
- min = isSummer ? 30 : min;
- min = isWinter ? 60 : min;
-
- NSInteger max = 60;
- max = isSummer ? 40 : max;
- max = isWinter ? 70 : max;
-
- NSString *condition = nil;
- NSInteger heat = [_contentValue integerValue];
- if (heat < min) {
- condition = @"건조해요";
- } else if (heat > max) {
- condition = @"습해요";
- } else {
- condition = @"쾌적해요";
- }
- return condition;
- }
- - (UIImage *)imageForLuminance {
- UIImage *image = nil;
- NSInteger lux = [_contentValue integerValue];
- if (lux < 10) {
- image = [UIImage imageNamed:@"img_things_detail_07_01_bright_state_dark"];
- } else if (lux < 50) {
- image = [UIImage imageNamed:@"img_things_detail_07_02_bright_state_soft"];
- } else if (lux < 80){
- image = [UIImage imageNamed:@"img_things_detail_07_03_bright_state_nice"];
- } else if (lux <= 100) {
- image = [UIImage imageNamed:@"img_things_detail_07_04_bright_state_bright"];
- }
- return image;
- }
- - (NSString *)conditionForLuminance {
-
- NSString *condition = nil;
- NSInteger lux = [_contentValue integerValue];
- if (lux < 10) {
- condition = @"어두워요";
- } else if (lux < 50) {
- condition = @"은은해요";
- } else if (lux < 80){
- condition = @"쾌적해요";
- } else if (lux <= 100) {
- condition = @"밝아요";
- }
- return condition;
- }
- - (UIImage *)imageForMandataryForState:(UIControlState)state {
- NSInteger typeId = [_cmdclsTypeId integerValue];
- UIImage *image = nil;
-
-
- switch (typeId) {
- // case 11006://Heat
- // if (state == UIControlStateNormal || state == UIControlStateSelected) {//default
- // image = [self imageForHeatInSeason];
- // } else if (state == UIControlStateDisabled) {//offline
- // image = [UIImage imageNamed:@"img_things_detail_03_00_sensor_temperature_offline"];
- // }
- // break;
- case 11011://door
- if (state == UIControlStateNormal) {//default
- image = [UIImage imageNamed:@"img_things_detail_01_02_sensor_door_close"];
- } else if (state == UIControlStateSelected) {//selected
- image = [UIImage imageNamed:@"img_things_detail_01_02_sensor_door_open"];
- } else if (state == UIControlStateDisabled) {//offline
- image = [UIImage imageNamed:@"img_things_detail_01_02_sensor_door_close"];
- }
- break;
- case 11013://모션센서
- if (state == UIControlStateNormal) {//default
- image = [UIImage imageNamed:@"img_things_detail_08_01_motion_state_none"];
- } else if (state == UIControlStateSelected) {//selected
- image = [UIImage imageNamed:@"img_things_detail_08_02_motion_state_detect"];
- } else if (state == UIControlStateDisabled) {//offline
- image = [UIImage imageNamed:@"motionimg_things_detail_08_00_motion_state_offline"];
- }
- break;
- case 11017://shock
- if (state == UIControlStateNormal) {//default
- image = [UIImage imageNamed:@"img_things_detail_02_01_sensor_shock_normal"];
- } else if (state == UIControlStateSelected) {//selected
- image = [UIImage imageNamed:@"img_things_detail_02_02_sensor_shock_sensing"];
- } else if (state == UIControlStateDisabled) {//offline
- image = [UIImage imageNamed:@"img_things_detail_02_00_sensor_shock_offline"];
- }
- case 12002://온도
- if (state == UIControlStateNormal || state == UIControlStateSelected) {//default
- image = [self imageForHeatInSeason];
- } else if (state == UIControlStateDisabled) {//offline
- image = [UIImage imageNamed:@"img_things_detail_03_00_sensor_temperature_offline"];
- }
- break;
- case 12004://밝기
- if (state == UIControlStateNormal || state == UIControlStateSelected) {//default
- image = [self imageForLuminance];
- } else if (state == UIControlStateDisabled) {//offline
- image = [UIImage imageNamed:@"img_things_detail_07_00_bright_state_offline"];
- }
- break;
- case 12006://습도
- if (state == UIControlStateNormal || state == UIControlStateSelected) {//default
- image = [self imageForHumidityInSeason];
- } else if (state == UIControlStateDisabled) {//offline
- image = [UIImage imageNamed:@"img_things_detail_04_00_sensor_humidity_offline"];
- }
- break;
- }
- return image;
- }
- - (NSString *)conditionForMandatary {
- NSInteger typeId = [_cmdclsTypeId integerValue];
- NSString *condition = nil;
-
- switch (typeId) {
- case 12002://온도
- condition = [self conditionForHeatInSeason];
- break;
- case 12004://밝기
- condition = [self conditionForLuminance];
- break;
- case 12006://습도
- condition = [self conditionForHumidityInSeason];
- break;
- }
- return condition;
- }
- - (UIImage *)backgroundImageForMandatary:(NSString *)value {
- NSInteger typeId = [_cmdclsTypeId integerValue];
- UIImage *bgImage = nil;
-
- if (!value || [value isEmptyString] || [value isEqualToString:@"none"]) {
- bgImage = [UIImage imageNamed:@"img_thing_icon_bg_default"];
- return bgImage;
- }
-
- switch (typeId) {
- case 11006:
- case 11011:
- case 11013:
- case 11017://sensor-binary
- if ([value isEqualToString:@"TRUE"]) {
- bgImage = [UIImage imageNamed:@"img_thing_icon_bg_active"];
- } else if ([value isEqualToString:@"FALSE"]) {
- bgImage = [UIImage imageNamed:@"img_thing_icon_bg_default"];
- }
- break;
- case 12002:
- case 12006:
- case 12004://sensor-multilevel
- bgImage = [UIImage imageNamed:@"img_thing_icon_bg_active"];
- break;
- case 36002://valve
- if ([value isEqualToString:@"OPEN"]) {
- bgImage = [UIImage imageNamed:@"img_thing_icon_bg_active"];
- } else if ([value isEqualToString:@"CLOSE"]) {
- bgImage = [UIImage imageNamed:@"img_thing_icon_bg_default"];
- }
- break;
- case 17002://switch
- if ([value isEqualToString:@"ON"]) {
- bgImage = [UIImage imageNamed:@"img_thing_icon_bg_active"];
- } else if ([value isEqualToString:@"OFF"]) {
- bgImage = [UIImage imageNamed:@"img_thing_icon_bg_default"];
- }
- break;
- }
- return bgImage;
- }
- - (UIImage *)imgaeForAddDel
- {
- NSInteger typeId = [_cmdclsTypeId integerValue];
- UIImage *image = [UIImage imageNamed:@"img_thing_icon_bg_default"];
-
- switch (typeId) {
- case 11011://door
- image = [UIImage imageNamed:@"img_things_product_addimg_02_mutisensor_door"];
- break;
- case 11013://멀티센서
- image = [UIImage imageNamed:@"img_things_product_addimg_02_mutisensor_door"];
- break;
- case 11017://shock
- image = [UIImage imageNamed:@"img_things_detail_02_01_sensor_shock_normal"];
- case 12002://온도
- image = [UIImage imageNamed:@"img_things_detail_03_00_sensor_temperature_offline"];
- break;
- case 12004://밝기
- image = [UIImage imageNamed:@"img_things_detail_07_00_bright_state_offline"];
- break;
- case 12006://습도
- image = [UIImage imageNamed:@"img_things_detail_04_00_sensor_humidity_offline"];
- break;
- case 17002://Smart Plug
- image = [UIImage imageNamed:@"img_things_product_addimg_03_smartplug"];
- break;
- case 36002://valve
- image = [UIImage imageNamed:@"img_things_product_addimg_01_smartgasvalve"];
- break;
- }
-
- return image;
- }
- - (NSString *)manufacturerName
- {
- NSInteger typeId = [_cmdclsTypeId integerValue];
- NSString *result = @"";
-
- switch (typeId) {
- case 11011://door
- result = @"도어센서";
- break;
- case 11013://멀티센서
- result = @"멀티센서";
- break;
- case 11017://shock
- result = @"VisionSecurity";
- case 12002://온도
- result = @"VisionSecurity";
- break;
- case 12004://밝기
- result = @"VisionSecurity";
- break;
- case 12006://습도
- result = @"VisionSecurity";
- break;
- case 17002://Smart Plug
- result = @"VisionSecurity";
- break;
- case 36002://valve
- result = @"타임밸브";
- break;
- }
-
- return result;
- }
- - (NSString *)getAddDelDescription
- {
- NSInteger typeId = [_cmdclsTypeId integerValue];
- NSString *result = @"";
-
- switch (typeId) {
- case 11011://door
- result = @"센서 아래 버튼을 1회 누른 후 LED가 깜빡임을 멈추면 1회 더 누르세요.";
- break;
- case 11013://멀티센서
- result = @"멀티센서";
- break;
- case 11017://shock
- result = @"VisionSecurity";
- case 12002://온도
- result = @"VisionSecurity";
- break;
- case 12004://밝기
- result = @"VisionSecurity";
- break;
- case 12006://습도
- result = @"VisionSecurity";
- break;
- case 17002://Smart Plug
- result = @"위에 버튼에 빨간 불이 깜빡일 때까지 5초 이상 누르세요.";
- break;
- case 36002://valve
- result = @"벨브를 열림 상태에 두고 \"위로\" 버튼을\n비프음이 날 때까지 5초 이상 누르세요.";
- break;
- }
-
- return result;
- }
- - (instancetype)initWithSubItem:(ItemSubModel *)subItem {//mobile devices.
- if (self = [super init]) {
- self.deviceId = subItem.sourceId;
- self.deviceName = subItem.sourceName;
- self.nodeId = subItem.sourceSubId;
- self.nodeName = subItem.sourceSubName;
- self.conditionTypeCode = subItem.conditionTypeCode;
- self.dataTypeCode = subItem.dataTypeCode;
- self.cmdclsValue = subItem.cmdclsValue;
- self.nickname = subItem.nickname;
- self.deleteYn = subItem.deleteYn;
-
- // objc_setAssociatedObject(self, @"CHECK_STATUS", @YES, OBJC_ASSOCIATION_COPY_NONATOMIC); //for checkbox
- [[JDFacade facade] setRadioButtonStatus:@YES object:self]; //for radio box
- }
- return self;
- }
- - (instancetype)initWithDeviceModel:(DeviceModel *)deviceModel deviceName:(NSString*)deviceName {//mobile devices.
- if (self = [super init]) {
- self.categoryName = deviceModel.categoryName;
- self.deviceMfId = deviceModel.deviceMfId;
- self.deviceConnLastDatetime = deviceModel.deviceConnLastDatetime;
- self.deviceOnline = deviceModel.deviceOnline;
- self.deviceModelId = deviceModel.deviceModelId;
- self.deviceConn = deviceModel.deviceConn;
- self.enable = deviceModel.enable;
- self.deviceName = deviceName;
- self.seq = deviceModel.seq;
- self.lastFirmwareVersion = deviceModel.lastFirmwareVersion;
- self.deviceSn = deviceModel.deviceSn;
- self.prdUserName = deviceName;
- self.deviceId = deviceModel.deviceId;
- self.prdName = deviceModel.prdName;
- self.remainCtrtCnt = deviceModel.remainCtrtCnt;
- self.firmwareVersion = deviceModel.firmwareVersion;
- self.conditionTypeCode = deviceModel.conditionTypeCode;
- self.softwareVersion = deviceModel.softwareVersion;
- self.totalCtrtCnt = deviceModel.totalCtrtCnt;
- self.deviceOnlineLastDatetime = deviceModel.deviceOnlineLastDatetime;
-
- // objc_setAssociatedObject(self, @"CHECK_STATUS", @YES, OBJC_ASSOCIATION_COPY_NONATOMIC); //for checkbox
- [[JDFacade facade] setRadioButtonStatus:@YES object:self]; //for radio box
- }
- return self;
- }
- + (NSString *)contentValueMsgByCmdClsCode:(NSString *)cmdclsCode cmdclsTypeId:(NSString *)cmdclsTypeId contentValue:(NSString *)contentValue {
- DeviceModel *tmpDevice = [[DeviceModel alloc] init];
- tmpDevice.cmdclsCode = cmdclsCode;
- tmpDevice.cmdclsTypeId = cmdclsTypeId;
- tmpDevice.contentValue = contentValue;
-
- return tmpDevice.contentValueMsg;
- }
- - (BOOL)isDeviceOnlined {
- return _deviceOnline && ![_deviceOnline isEmptyString] && [_deviceOnline isEqualToString:@"ON"];
- }
- - (BOOL)isDeviceConn {
- return _deviceConn && ![_deviceConn isEmptyString] && [_deviceConn isEqualToString:@"connect"];
- }
- -(BOOL)isUpdateNeed {
- BOOL result = NO;
-
- if (![[_lastSoftwareVersion uppercaseString] isEqualToString:[_softwareVersion uppercaseString]] ||
- ![[_lastFirmwareVersion uppercaseString] isEqualToString:[_firmwareVersion uppercaseString]]) {
- result = YES;
- }
-
- return result;
- }
- - (BOOL)isUpdateSoftware {
-
- //[_lastSoftwareVersion.trim isEquestToIgnoreCase:_softwareVersion.trim]
- if (![[_lastSoftwareVersion uppercaseString] isEqualToString:[_softwareVersion uppercaseString]]) {
-
- return YES;
- }
-
- return NO;
- }
- - (BOOL)isUpdateFirmware {
-
- if (![[_lastFirmwareVersion uppercaseString] isEqualToString:[_firmwareVersion uppercaseString]]) {
-
- return YES;
- }
-
- return NO;
- }
- @end
- @implementation DeviceListModel
- @end
- @implementation NodeListModel
- -(BOOL)isCanReOrder
- {
- BOOL result = NO;
-
- if (_nodes.count > 1) {
- result = YES;
- }
-
- return result;
- }
- -(BOOL)isCanAddNode
- {
- BOOL result = NO;
-
- if ([_ctrtCnt integerValue] > _nodes.count) {
- result = YES;
- }
-
- return result;
- }
- -(BOOL)isCanDelNode
- {
- BOOL result = NO;
-
- if (_nodes.count > 0) {
- result = YES;
- }
-
- return result;
- }
- @end
- @implementation NodeModel
- //- (CmdClsType)cmdclsType {
- // return [DeviceModel cmdclsTypeForCode:_cmdclsCode];
- //}
- - (BOOL)isDeviceOnline {
- return _refDevice.isOnline;
- }
- @end
- @implementation DeviceDetailModel
- -(BOOL)isProfileUpdate
- {
- BOOL result = NO;
-
- if ([_profileUpdateYn isEquestToIgnoreCase:@"Y"]) {
- result = YES;
- }
-
- return result;
- }
- @end
- @implementation PredefinedDeviceModel
- //+ (JSONKeyMapper *)keyMapper {
- //
- // NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
- //
- // //self
- // [dictionary setValue:@"cmdclsTypeSystemName" forKey:@"cmdcls_type_system_name"];
- // [dictionary setValue:@"cmdclsTypeId" forKey:@"cmdcls_type_id"];
- // [dictionary setValue:@"cmdclsCode" forKey:@"cmdcls_code"];
- // [dictionary setValue:@"deviceProfileId" forKey:@"device_profile_id"];
- // [dictionary setValue:@"createDatetime" forKey:@"create_datetime"];
- // [dictionary setValue:@"cmdclsTypeName" forKey:@"cmdcls_type_name"];
- // [dictionary setValue:@"deviceName" forKey:@"device_name"];
- // [dictionary setValue:@"profileName" forKey:@"profile_name"];
- // [dictionary setValue:@"imageFileName" forKey:@"image_file_name"];
- // [dictionary setValue:@"contentValue" forKey:@"content_value"];
- // [dictionary setValue:@"nodeName" forKey:@"node_name"];
- // [dictionary setValue:@"cmdclsCount" forKey:@"cmdcls_count"];
- // [dictionary setValue:@"nodeId" forKey:@"node_id"];
- // [dictionary setValue:@"deviceId" forKey:@"device_id"];
- // [dictionary setValue:@"cmdclsValue" forKey:@"cmdcls_value"];
- // [dictionary setValue:@"conditionTypeCode" forKey:@"condition_type_code"];
- // [dictionary setValue:@"dataTypeCode" forKey:@"data_type_code"];
- //
- // return [[JSONKeyMapper alloc] initWithDictionary:dictionary];
- //}
- - (instancetype)initWithSubItem:(ItemSubModel *)subItem {
- if (self = [super init]) {
- self.deviceId = subItem.sourceId;
- self.deviceName = subItem.sourceName;
- self.nodeId = subItem.sourceSubId;
- self.nodeName = subItem.sourceSubName;
- self.conditionTypeCode = subItem.conditionTypeCode;
- self.dataTypeCode = subItem.dataTypeCode;
- self.cmdclsValue = subItem.cmdclsValue;
- self.predCmdclsValue = subItem.predCmdclsValue;
- self.deleteYn = subItem.deleteYn;
-
- [[JDFacade facade] setCheckBoxStatus:@YES object:self]; //for check box
- [[JDFacade facade] setRadioButtonStatus:@YES object:self]; //for radio box
- }
- return self;
- }
- @end
- @implementation PredefinedDeviceListModel
- @end
- @implementation DeviceIconModel
- @end
- @implementation DeviceIconListModel
- @end
|