| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743 |
- //
- // ItemModel.m
- // kneet
- //
- // Created by Jason Lee on 4/1/15.
- // Copyright (c) 2015 ntels. All rights reserved.
- //
- #import "ItemModel.h"
- #import "JDObject.h"
- @implementation CmdClsValueModel
- //- (NSString *)cmdclsValueMsg {
- // ItemSubModel *subItem = [[ItemSubModel alloc] init];
- // subItem.cmdclsValue = _cmdclsValue;
- // subItem.cmdclsValueMsg = _cmdclsValueMsg;
- //
- // return subItem.cmdclsValueMsg;
- //}
- @end
- @implementation ItemSubModel
- + (JSONKeyMapper *)keyMapper {
- return [JSONKeyMapper mapperFromUnderscoreCaseToCamelCase];
- }
- - (NSString *)localStringOfDay:(NSString *)day {
- NSString *lstr = nil;
- if ([day isEqualToString:ksDayOfWeekMON]) {
- lstr = NSLocalizedString(@"월", @"월");
- } else if ([day isEqualToString:ksDayOfWeekTUE]) {
- lstr = NSLocalizedString(@"화", @"화");
- } else if ([day isEqualToString:ksDayOfWeekWED]) {
- lstr = NSLocalizedString(@"수", @"수");
- } else if ([day isEqualToString:ksDayOfWeekTHU]) {
- lstr = NSLocalizedString(@"목", @"목");
- } else if ([day isEqualToString:ksDayOfWeekFRI]) {
- lstr = NSLocalizedString(@"금", @"금");
- } else if ([day isEqualToString:ksDayOfWeekSAT]) {
- lstr = NSLocalizedString(@"토", @"토");
- } else if ([day isEqualToString:ksDayOfWeekSUN]) {
- lstr = NSLocalizedString(@"일", @"일");
- }
- return lstr;
- }
- - (NSString *)daysOfWeek {
- if (_daysOfWeek) {
- return _daysOfWeek;
- }
- NSMutableString *days = [[NSMutableString alloc] init];
- if (_cmdclsValue && ![_cmdclsValue isEmptyString]) {
- NSArray *darray = [_cmdclsValue componentsSeparatedByString:@","];
- for (NSString *day in darray) {
- NSString *prefix = [days isEmptyString] ? ksEmptyString : @", ";
- [days appendFormat:@"%@%@", prefix, [self localStringOfDay:day]];
- }
- }
- return days;
- }
- //- (NSString *)cmdclsValueMsg {
- //// if (!_cmdclsValueMsg || [_cmdclsValueMsg isEmptyString]) {
- // if (_dueDate && ![_dueDate isEmptyString]) {
- // _cmdclsValueMsg = _dueDate;
- // } else if (_daysOfWeek && ![_daysOfWeek isEmptyString]) {
- // _cmdclsValueMsg = _daysOfWeek;
- // } else if (_dueTime && ![_dueTime isEmptyString]) {
- // _cmdclsValueMsg = _dueTime;
- // } else if (_homeModes && ![_homeModes isEmptyString]) {
- // _cmdclsValueMsg = _homeModes;
- // } else if (_externHeat && ![_externHeat isEmptyString]) {
- // _cmdclsValueMsg = _externHeat;
- // }
- //// }
- // return _cmdclsValueMsg;
- //
- //// if (_dueDate && ![_dueDate isEmptyString]) {
- //// self.cmdclsValueMsg = _dueDate;
- ////
- //// } else if (_daysOfWeek && ![_daysOfWeek isEmptyString]) {
- //// self.cmdclsValueMsg = _daysOfWeek;
- ////
- //// } else if (_dueTime && ![_dueTime isEmptyString]) {
- //// self.cmdclsValueMsg = _dueTime;
- ////
- //// } else if (_homeModes && ![_homeModes isEmptyString]) {
- //// self.cmdclsValueMsg = _homeModes;
- ////
- //// } else if (_externHeat && ![_externHeat isEmptyString]) {
- //// self.cmdclsValueMsg = _externHeat;
- ////
- //// }
- //}
- #define ksCmdClassTypeFirmwareVersion @"FIRMWARE_VERSION"
- #define ksCmdClassTypeSwitchBinary @"SWITCH_BINARY"
- #define ksCmdClassTypeSwitchMultiLevel @"SWITCH_MULTILEVEL"
- #define ksCmdClassTypeSwitchColor @"SWITCH_COLOR"
- #define ksCmdClassTypeSensorBinary @"SENSOR_BINARY"
- #define ksCmdClassTypeSensorMultiLevel @"SENSOR_MULTILEVEL"
- #define ksCmdClassTypeThermostatMode @"THERMOSTAT_MODE"
- #define ksCmdClassTypeThermostatFanMode @"THERMOSTAT_FAN_MODE"
- #define ksCmdClassTypeThermostatSetPoint @"THERMOSTAT_SETPOINT"
- #define ksCmdClassTypeLock @"LOCK"
- #define ksCmdClassTypeMeterCurrent @"METER_CURRENT"
- #define ksCmdClassTypeMeterTotal @"METER_TOTAL"
- #define ksCmdClassTypeAVControlPlayback @"AV_CONTROL_PLAYBACK"
- #define ksCmdClassTypeHomeMode @"HOME_MODE"
- #define ksCmdClassTypeSpeedControl @"SPEED_CONTROL"
- #define ksCmdClassTypeValve @"VALVE"
- #define ksCmdClassTypeBattery @"BATTERY"
- #define ksCmdClassTypeDeviceStatus @"DEVICE_STATUS"
- #define ksCmdClassTypePresence @"PRESENCE"
- #define ksCmdClassTypeSystem @"SYSTEM"
- #define ksCmdClassTypeMeter @"METER"
- + (CmdClsType)cmdclsTypeForCode:(NSString *)code {
- CmdClsType type = -1;
- if ([code isEqualToString:ksCmdClassTypeFirmwareVersion]) {
- type = CmdClsTypeFirmwareVersion;
-
- } else if ([code isEqualToString:ksCmdClassTypeSwitchBinary]) {
- type = CmdClsTypeSwitchBinary;
-
- } else if ([code isEqualToString:ksCmdClassTypeSwitchMultiLevel]) {
- type = CmdClsTypeSwitchMultiLevel;
-
- } else if ([code isEqualToString:ksCmdClassTypeSwitchColor]) {
- type = CmdClsTypeSwitchColor;
-
- } else if ([code isEqualToString:ksCmdClassTypeSensorBinary]) {
- type = CmdClsTypeSensorBinary;
-
- } else if ([code isEqualToString:ksCmdClassTypeSensorMultiLevel]) {
- type = CmdClsTypeSensorMultiLevel;
-
- } else if ([code isEqualToString:ksCmdClassTypeThermostatMode]) {
- type = CmdClsTypeThermostatMode;
-
- } else if ([code isEqualToString:ksCmdClassTypeThermostatFanMode]) {
- type = CmdClsTypeThermostatFanMode;
-
- } else if ([code isEqualToString:ksCmdClassTypeThermostatSetPoint]) {
- type = CmdClsTypeThermostatSetPoint;
-
- } else if ([code isEqualToString:ksCmdClassTypeLock]) {
- type = CmdClsTypeLock;
-
- } else if ([code isEqualToString:ksCmdClassTypeMeterCurrent]) {
- type = CmdClsTypeMeterCurrent;
-
- } else if ([code isEqualToString:ksCmdClassTypeMeterTotal]) {
- type = CmdClsTypeMeterTotal;
-
- } else if ([code isEqualToString:ksCmdClassTypeAVControlPlayback]) {
- type = CmdClsTypeAVControlPlayback;
-
- } else if ([code isEqualToString:ksCmdClassTypeHomeMode]) {
- type = CmdClsTypeHomeMode;
-
- } else if ([code isEqualToString:ksCmdClassTypeSpeedControl]) {
- type = CmdClsTypeSpeedControl;
-
- } else if ([code isEqualToString:ksCmdClassTypeValve]) {
- type = CmdClsTypeValve;
-
- } else if ([code isEqualToString:ksCmdClassTypeBattery]) {
- type = CmdClsTypeBattery;
-
- } else if ([code isEqualToString:ksCmdClassTypeDeviceStatus]) {
- type = CmdClsTypeDeviceStatus;
-
- } else if ([code isEqualToString:ksCmdClassTypePresence]) {
- type = CmdClsTypePresence;
-
- } else if ([code isEqualToString:ksCmdClassTypeSystem]) {
- type = CmdClsTypeSystem;
-
- } else if ([code isEqualToString:ksCmdClassTypeMeter]) {
- type = CmdClsTypeMeter;
-
- }
- return type;
- }
- - (CmdClsType)cmdclsType {
- return [ItemSubModel cmdclsTypeForCode:_cmdclsCode];
- }
- - (NSInteger)cmdclsValueMsgLength {
- NSInteger length = 0;
- // NSArray<CmdClsValueModel> *array = nil;
- //
- // switch ([self cmdclsType]) {
- // case CmdClsTypeLock:
- // array = [self cmdclsValueListOfLock];
- // break;
- // default:
- // break;
- // }
-
- for (CmdClsValueModel *tmpCmdclsValue in self.cmdclsValueList) {
- if (tmpCmdclsValue.cmdclsValueMsg.length > length) {
- length = tmpCmdclsValue.cmdclsValueMsg.length;
- }
- }
-
- return length;
- }
- - (NSString *)cmdclsValueMsgLongest {
- NSString *hstring = nil;
- // NSArray<CmdClsValueModel> *array = nil;
- //
- // switch ([self cmdclsType]) {
- // case CmdClsTypeSwitchBinary:
- // array = [self cmdclsValueListOfSwitchBinary];
- // break;
- // case CmdClsTypeLock:
- // array = [self cmdclsValueListOfLock];
- // break;
- // default:
- // break;
- // }
-
- NSUInteger highest = 0;
- for (CmdClsValueModel *tmpCmdclsValue in self.cmdclsValueList) {
- if (tmpCmdclsValue.cmdclsValueMsg.length > highest) {
- highest = tmpCmdclsValue.cmdclsValueMsg.length;
- hstring = tmpCmdclsValue.cmdclsValueMsg;
- }
- }
-
- return hstring;
- }
- /*
- - (NSArray<CmdClsValueModel> *)cmdclsValueList {
- switch ([self cmdclsType]) {
- case CmdClsTypeThermostatMode:
- _cmdclsValueList = [self cmdclsValueListOfThermostatMode];
- break;
- case CmdClsTypeLock:
- _cmdclsValueList = [self cmdclsValueListOfLock];
- break;
- case CmdClsTypeSpeedControl:
- _cmdclsValueList = [self cmdclsValueListOfSpeedControl];
- break;
- case CmdClsTypeSwitchBinary:
- _cmdclsValueList = [self cmdclsValueListOfSwitchBinary];
- break;
- case CmdClsTypeValve:
- _cmdclsValueList = [self cmdclsValueListOfValve];
- break;
- default:
- break;
- }
- return _cmdclsValueList;
- }
- - (NSArray<CmdClsValueModel> *)cmdclsValueListOfThermostatMode {
-
- NSMutableArray<CmdClsValueModel> *array = [(NSMutableArray<CmdClsValueModel> *)[NSMutableArray alloc] init];
- NSInteger typeId = [_cmdclsTypeId integerValue];
- switch (typeId) {
- case 13001: {
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
- @"cmdcls_value_msg": NSLocalizedString(@"꺼짐", @"꺼짐")} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"COOL",
- @"cmdcls_value_msg": NSLocalizedString(@"냉방", @"냉방")} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"HEAT",
- @"cmdcls_value_msg": NSLocalizedString(@"난방", @"난방")} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"AUTO",
- @"cmdcls_value_msg": NSLocalizedString(@"자동", @"자동")} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"FAN_ONLY",
- @"cmdcls_value_msg": NSLocalizedString(@"환기", @"환기")} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"DRY_AIR",
- @"cmdcls_value_msg": NSLocalizedString(@"제습", @"제습")} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"AWAY",
- @"cmdcls_value_msg": NSLocalizedString(@"외출", @"외출")} error:nil]];
- }
- break;
- case 13002: {
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
- @"cmdcls_value_msg": NSLocalizedString(@"꺼짐", @"꺼짐")} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"COOL",
- @"cmdcls_value_msg": NSLocalizedString(@"냉방", @"냉방")} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"HEAT",
- @"cmdcls_value_msg": NSLocalizedString(@"난방", @"난방")} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"AUTO",
- @"cmdcls_value_msg": NSLocalizedString(@"자동", @"자동")} error:nil]];
- }
- break;
- case 13003: {
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
- @"cmdcls_value_msg": NSLocalizedString(@"꺼짐", @"꺼짐")} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"HEAT",
- @"cmdcls_value_msg": NSLocalizedString(@"난방", @"난방")} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"AWAY",
- @"cmdcls_value_msg": NSLocalizedString(@"외출", @"외출")} error:nil]];
- }
- break;
- case 13004: {
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
- @"cmdcls_value_msg": NSLocalizedString(@"꺼짐", @"꺼짐")} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"COOL",
- @"cmdcls_value_msg": NSLocalizedString(@"냉방", @"냉방")} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"FAN_ONLY",
- @"cmdcls_value_msg": NSLocalizedString(@"환기", @"환기")} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"DRY_AIR",
- @"cmdcls_value_msg": NSLocalizedString(@"제습", @"제습")} error:nil]];
- }
- break;
- }
- return array;
- }
- - (NSArray<CmdClsValueModel> *)cmdclsValueListOfSwitchBinary {
- NSMutableArray<CmdClsValueModel> *array = [(NSMutableArray<CmdClsValueModel> *)[NSMutableArray alloc] init];
- NSInteger typeId = [_cmdclsTypeId integerValue];
- switch (typeId) {
- case 17001:
- case 17002:
- case 17003:
- case 17004:
- case 17005:
- {
- for (CmdClsValueModel *cmdclsValue in self.cmdclsValueList) {
- if ([cmdclsValue.cmdclsValue isEqualToString:@"ON"]) {
- cmdclsValue.localizedCmdClsValueMsg = @"켬", @""
-
- }
- }
-
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"ON",
- @"cmdcls_value_msg": NSLocalizedString(@"켬", @"켬")} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
- @"cmdcls_value_msg": NSLocalizedString(@"끔", @"끔")} error:nil]];
- break;
- }
- }
- return array;
- }
- - (NSArray<CmdClsValueModel> *)cmdclsValueListOfLock {
-
- NSMutableArray<CmdClsValueModel> *array = [(NSMutableArray<CmdClsValueModel> *)[NSMutableArray alloc] init];
- NSInteger typeId = [_cmdclsTypeId integerValue];
- switch (typeId) {
- case 14001: {
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"LOCKED",
- @"cmdcls_value_msg": @"잠김"} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"UNCLOCKED",
- @"cmdcls_value_msg": @"열림"} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"JAMMED",
- @"cmdcls_value_msg": @"걸림"} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"FORCED_OPEN",
- @"cmdcls_value_msg": @"수동"} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"UNSPECIFIED",
- @"cmdcls_value_msg": @"오류"} error:nil]];
- }
- break;
- case 14002:
- case 14003:
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"LOCKED",
- @"cmdcls_value_msg": @"잠김"} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"UNCLOCKED",
- @"cmdcls_value_msg": @"열림"} error:nil]];
- break;
- }
- return array;
- }
- - (NSArray<CmdClsValueModel> *)cmdclsValueListOfSpeedControl {
-
- NSMutableArray<CmdClsValueModel> *array = [(NSMutableArray<CmdClsValueModel> *)[NSMutableArray alloc] init];
- NSInteger typeId = [_cmdclsTypeId integerValue];
- switch (typeId) {
- case 20001: {
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
- @"cmdcls_value_msg": @"꺼짐"} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"LOW",
- @"cmdcls_value_msg": @"약"} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"MEDIUM",
- @"cmdcls_value_msg": @"중"} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"HIGH",
- @"cmdcls_value_msg": @"강"} error:nil]];
- }
- break;
- }
- return array;
- }
- - (NSArray<CmdClsValueModel> *)cmdclsValueListOfValve {
-
- NSMutableArray<CmdClsValueModel> *array = [(NSMutableArray<CmdClsValueModel> *)[NSMutableArray alloc] init];
- NSInteger typeId = [_cmdclsTypeId integerValue];
- switch (typeId) {
- case 36001:
- case 36002:
- case 36003:
- {
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OPEN",
- @"cmdcls_value_msg": @"열기"} error:nil]];
- [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"CLOSE",
- @"cmdcls_value_msg": @"잠그기"} error:nil]];
- }
- break;
- }
- return array;
- }
- */
- - (NSString *)unit {
- if ([_unit isEqualToString:@"\\"]) {
- _unit = @"₩";
- }
- return _unit;
- }
- //- (NSString *)cmdclsValueMsgOfSensorBinary {
- // 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:
- // if ([_cmdclsValue isEqualToString:@"TRUE"]) {
- // msg = NSLocalizedString(@"감지됨", @"감지됨");
- // } else if ([_cmdclsValue isEqualToString:@"FALSE"]) {
- // msg = NSLocalizedString(@"정상", @"정상");
- // } else {
- // msg = @"-";
- // }
- // break;
- // case 11011:
- // if ([_cmdclsValue isEqualToString:@"TRUE"]) {
- // msg = NSLocalizedString(@"열림", @"열림");
- // } else if ([_cmdclsValue isEqualToString:@"FALSE"]) {
- // msg = NSLocalizedString(@"닫힘", @"닫힘");
- // } else {
- // msg = @"-";
- // }
- // case 11015:
- // if ([_cmdclsValue isEqualToString:@"TRUE"]) {
- // msg = NSLocalizedString(@"들어옴", @"들어옴");
- // } else if ([_cmdclsValue isEqualToString:@"FALSE"]) {
- // msg = NSLocalizedString(@"나감", @"나감");
- // } else {
- // msg = @"-";
- // }
- // break;
- // }
- // return msg;
- //}
- - (NSString *)cmdclsValueMsgOfThermostatMode {
- NSInteger typeId = [_cmdclsTypeId integerValue];
- NSString *msg = ksEmptyString;
- switch (typeId) {
- case 13001:
- case 13002:
- case 13003:
- case 13004:
- if ([_cmdclsValue isEqualToString:@"OFF"]) {
- msg = NSLocalizedString(@"꺼짐", @"꺼짐");
- } else if ([_cmdclsValue isEqualToString:@"COOL"]) {
- msg = NSLocalizedString(@"냉방", @"냉방");
- } else if ([_cmdclsValue isEqualToString:@"HEAT"]) {
- msg = NSLocalizedString(@"난방", @"난방");
- } else if ([_cmdclsValue isEqualToString:@"AUTO"]) {
- msg = NSLocalizedString(@"자동", @"자동");
- } else if ([_cmdclsValue isEqualToString:@"FAN_ONLY"]) {
- msg = NSLocalizedString(@"환기", @"환기");
- } else if ([_cmdclsValue isEqualToString:@"DRY_AIR"]) {
- msg = NSLocalizedString(@"제습", @"제습");
- } else if ([_cmdclsValue isEqualToString:@"AWAY"]) {
- msg = NSLocalizedString(@"외출", @"외출");
- } else {
- msg = @"-";
- }
- break;
- }
- return msg;
- }
- - (NSString *)cmdclsValueMsgOfLock {
- NSInteger typeId = [_cmdclsTypeId integerValue];
- NSString *msg = ksEmptyString;
- switch (typeId) {
- case 14001:
- if ([_cmdclsValue isEqualToString:@"LOCKED"]) {
- msg = NSLocalizedString(@"잠김", @"잠김");
- } else if ([_cmdclsValue isEqualToString:@"UNLOCKED"]) {
- msg = NSLocalizedString(@"열림", @"열림");
- } else if ([_cmdclsValue isEqualToString:@"JAMMED"]) {
- msg = NSLocalizedString(@"걸림", @"걸림");
- } else if ([_cmdclsValue isEqualToString:@"FORCED_OPEN"]) {
- msg = NSLocalizedString(@"수동", @"수동");
- } else if ([_cmdclsValue isEqualToString:@"UNSPECIFIED"]) {
- msg = NSLocalizedString(@"오류", @"오류");
- } else {
- msg = @"-";
- }
- break;
- case 14002:
- case 14003:
- if ([_cmdclsValue isEqualToString:@"LOCKED"]) {
- msg = @"잠김";
- } else if ([_cmdclsValue isEqualToString:@"UNLOCKED"]) {
- msg = @"열림";
- } else {
- msg = @"-";
- }
- break;
- }
- return msg;
- }
- - (NSString *)cmdclsValueMsgOfSwitchBinary {//On/Off status
- NSInteger typeId = [_cmdclsTypeId integerValue];
- NSString *msg = ksEmptyString;
- switch (typeId) {
- case 17001://Default
- case 17002://Plug
- case 17003://Bulb
- case 17004://Light
- case 17005://Wall Switch
- if ([_cmdclsValue isEqualToString:@"ON"]) {
- msg = NSLocalizedString(@"켬", @"켬");
- } else if ([_cmdclsValue isEqualToString:@"OFF"]) {
- msg = NSLocalizedString(@"끔", @"끔");
- } else {
- msg = @"-";
- }
- break;
- }
- return msg;
- }
- - (NSString *)cmdclsValueMsgOfValve {//Openn/Close status
- NSInteger typeId = [_cmdclsTypeId integerValue];
- NSString *msg = ksEmptyString;
- switch (typeId) {
- case 36001://Default
- case 36002://NTELS_1
- case 36003://NTELS_2
- if ([_cmdclsValue isEqualToString:@"OPEN"]) {
- msg = NSLocalizedString(@"열기", @"열기");
- } else if ([_cmdclsValue isEqualToString:@"CLOSE"]) {
- msg = NSLocalizedString(@"잠그기", @"잠그기");
- } else {
- msg = @"-";
- }
- break;
- }
- return msg;
- }
- - (NSString *)cmdclsValueMsg {
-
- switch ([self cmdclsType]) {
- // case CmdClsTypeSensorBinary:
- // _cmdclsValueMsg = [self cmdclsValueMsgOfSensorBinary];
- // break;
- case CmdClsTypeThermostatMode:
- _cmdclsValueMsg = [self cmdclsValueMsgOfThermostatMode];
- break;
- case CmdClsTypeLock:
- _cmdclsValueMsg = [self cmdclsValueMsgOfLock];
- break;
- case CmdClsTypeSwitchBinary:
- _cmdclsValueMsg = [self cmdclsValueMsgOfSwitchBinary];
- break;
- case CmdClsTypeSpeedControl:
- _cmdclsValueMsg = [self cmdclsValueMsgOfSpeedControl];
- break;
- case CmdClsTypeAVControlPlayback:
- _cmdclsValueMsg = [self cmdclsValueMsgOfAVPlayback];
- break;
- case CmdClsTypeValve:
- _cmdclsValueMsg = [self cmdclsValueMsgOfValve];
- break;
- case CmdClsTypeSensorMultiLevel:
- case CmdClsTypeBattery:
- case CmdClsTypeSensorBinary:
- case CmdClsTypeMeter: {
- NSString *condition = [_conditionTypeCode isEqualToString:ksConditionTypeCodeGreatOrEqual] ? @"이상" : @"이하";
- _cmdclsValueMsg = [NSString stringWithFormat:@"%@%@ %@", _cmdclsValue, _unit, condition];
- }
- }
- return _cmdclsValueMsg;
- }
- - (NSString *)cmdclsValueMsgOfSpeedControl {
- NSInteger typeId = [_cmdclsTypeId integerValue];
- NSString *msg = ksEmptyString;
- switch (typeId) {
- case 20001:
- if ([_cmdclsValue isEqualToString:@"OFF"]) {
- msg = NSLocalizedString(@"꺼짐", @"꺼짐");
- } else if ([_cmdclsValue isEqualToString:@"LOW"]) {
- msg = NSLocalizedString(@"약", @"약");
- } else if ([_cmdclsValue isEqualToString:@"MEDIUM"]) {
- msg = NSLocalizedString(@"중", @"중");
- } else if ([_cmdclsValue isEqualToString:@"HIGH"]) {
- msg = NSLocalizedString(@"강", @"강");
- } else {
- msg = @"-";
- }
- break;
- }
- return msg;
- }
- - (NSString *)cmdclsValueMsgOfAVPlayback {
- NSInteger typeId = [_cmdclsTypeId integerValue];
- NSString *msg = ksEmptyString;
- switch (typeId) {
- case 21001:
- if ([_cmdclsValue isEqualToString:@"PLAYING"]) {
- msg = NSLocalizedString(@"재생 중", @"재생 중");
- } else if ([_cmdclsValue isEqualToString:@"PAUSED"]) {
- msg = NSLocalizedString(@"정지 됨", @"정지 됨");
- } else {
- msg = @"-";
- }
- break;
- }
- return msg;
- }
- - (BOOL)isOnline {
- return _onlineState && ![_onlineState isEmptyString] && [_onlineState isEqualToString:@"ON"];
- }
- - (NSString *)conditionTypeCode {
- if (!_conditionTypeCode) {
- switch ([self cmdclsType]) {
- case CmdClsTypeSwitchMultiLevel:
- case CmdClsTypeSensorMultiLevel:
- case CmdClsTypeBattery:
- case CmdClsTypeMeter:
- _conditionTypeCode = @"05";
- break;
- default:
- _conditionTypeCode = @"01";
- break;
- }
- }
- return _conditionTypeCode;
- }
- @end
- @implementation ItemModel
- + (JSONKeyMapper *)keyMapper {
- return [[JSONKeyMapper alloc] initWithDictionary:@{@"pred_item_sequence": @"predItemSequence",
- @"item_type_code": @"itemTypeCode",
- @"item_sub_type_code": @"itemSubTypeCode",
- @"item_name": @"itemName",
- @"item_sub": @"subItems",
- @"pred_action_sequence": @"predActionSequence",
- @"pred_scene_id": @"predSceneId",
- @"pred_rule_id": @"predRuleId",
- @"cnt" : @"cnt",
- @"total_cnt" : @"totalCnt",
- @"image_file_name": @"imageFileName",
- @"source_id": @"sourceId",
- @"source_name": @"sourceName",
- @"image_file_view_name": @"imageFileViewName"}];
- }
- + (NSString *)itemSubTypeString:(NSString *)itemSubTypeCode {
- NSString *string = ksEmptyString;
- if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeDevice]) {
- string = @"Choose your things & action";
- } else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeMode]) {
- string = @"Choose home mode";
- } else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeAppPush]) {
- string = @"Choose your things & action";
- } else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeTimer]) {
- string = @"Choose your things & action";
- }
- return string;
- }
- - (NSInteger)sumPredDeviceCount {
- return _predDevices.count + [_cnt integerValue];
- }
- - (NSInteger)sumModesCount {
- return _modes.count + [_cnt integerValue];
- }
- - (NSInteger)sumPushesCount {
- return _pushes.count + [_cnt integerValue];
- }
- @end
- @implementation ItemListModel
- @end
- @implementation ItemSubListModel
- @end
|