ItemModel.m 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. //
  2. // ItemModel.m
  3. // kneet
  4. //
  5. // Created by Jason Lee on 4/1/15.
  6. // Copyright (c) 2015 ntels. All rights reserved.
  7. //
  8. #import "ItemModel.h"
  9. #import "JDObject.h"
  10. @implementation CmdClsValueModel
  11. //- (NSString *)cmdclsValueMsg {
  12. // ItemSubModel *subItem = [[ItemSubModel alloc] init];
  13. // subItem.cmdclsValue = _cmdclsValue;
  14. // subItem.cmdclsValueMsg = _cmdclsValueMsg;
  15. //
  16. // return subItem.cmdclsValueMsg;
  17. //}
  18. @end
  19. @implementation ItemSubModel
  20. + (JSONKeyMapper *)keyMapper {
  21. return [JSONKeyMapper mapperFromUnderscoreCaseToCamelCase];
  22. }
  23. - (NSString *)localStringOfDay:(NSString *)day {
  24. NSString *lstr = nil;
  25. if ([day isEqualToString:ksDayOfWeekMON]) {
  26. lstr = NSLocalizedString(@"월", @"월");
  27. } else if ([day isEqualToString:ksDayOfWeekTUE]) {
  28. lstr = NSLocalizedString(@"화", @"화");
  29. } else if ([day isEqualToString:ksDayOfWeekWED]) {
  30. lstr = NSLocalizedString(@"수", @"수");
  31. } else if ([day isEqualToString:ksDayOfWeekTHU]) {
  32. lstr = NSLocalizedString(@"목", @"목");
  33. } else if ([day isEqualToString:ksDayOfWeekFRI]) {
  34. lstr = NSLocalizedString(@"금", @"금");
  35. } else if ([day isEqualToString:ksDayOfWeekSAT]) {
  36. lstr = NSLocalizedString(@"토", @"토");
  37. } else if ([day isEqualToString:ksDayOfWeekSUN]) {
  38. lstr = NSLocalizedString(@"일", @"일");
  39. }
  40. return lstr;
  41. }
  42. - (NSString *)daysOfWeek {
  43. NSMutableString *days = [[NSMutableString alloc] init];
  44. if (_cmdclsValue && ![_cmdclsValue isEmptyString]) {
  45. NSArray *darray = [_cmdclsValue componentsSeparatedByString:@","];
  46. for (NSString *day in darray) {
  47. NSString *prefix = [days isEmptyString] ? ksEmptyString : @", ";
  48. [days appendFormat:@"%@%@", prefix, [self localStringOfDay:day]];
  49. }
  50. }
  51. return days;
  52. }
  53. //- (NSString *)cmdclsValueMsg {
  54. //// if (!_cmdclsValueMsg || [_cmdclsValueMsg isEmptyString]) {
  55. // if (_dueDate && ![_dueDate isEmptyString]) {
  56. // _cmdclsValueMsg = _dueDate;
  57. // } else if (_daysOfWeek && ![_daysOfWeek isEmptyString]) {
  58. // _cmdclsValueMsg = _daysOfWeek;
  59. // } else if (_dueTime && ![_dueTime isEmptyString]) {
  60. // _cmdclsValueMsg = _dueTime;
  61. // } else if (_homeModes && ![_homeModes isEmptyString]) {
  62. // _cmdclsValueMsg = _homeModes;
  63. // } else if (_externHeat && ![_externHeat isEmptyString]) {
  64. // _cmdclsValueMsg = _externHeat;
  65. // }
  66. //// }
  67. // return _cmdclsValueMsg;
  68. //
  69. //// if (_dueDate && ![_dueDate isEmptyString]) {
  70. //// self.cmdclsValueMsg = _dueDate;
  71. ////
  72. //// } else if (_daysOfWeek && ![_daysOfWeek isEmptyString]) {
  73. //// self.cmdclsValueMsg = _daysOfWeek;
  74. ////
  75. //// } else if (_dueTime && ![_dueTime isEmptyString]) {
  76. //// self.cmdclsValueMsg = _dueTime;
  77. ////
  78. //// } else if (_homeModes && ![_homeModes isEmptyString]) {
  79. //// self.cmdclsValueMsg = _homeModes;
  80. ////
  81. //// } else if (_externHeat && ![_externHeat isEmptyString]) {
  82. //// self.cmdclsValueMsg = _externHeat;
  83. ////
  84. //// }
  85. //}
  86. #define ksCmdClassTypeFirmwareVersion @"FIRMWARE_VERSION"
  87. #define ksCmdClassTypeSwitchBinary @"SWITCH_BINARY"
  88. #define ksCmdClassTypeSwitchMultiLevel @"SWITCH_MULTILEVEL"
  89. #define ksCmdClassTypeSwitchColor @"SWITCH_COLOR"
  90. #define ksCmdClassTypeSensorBinary @"SENSOR_BINARY"
  91. #define ksCmdClassTypeSensorMultiLevel @"SENSOR_MULTILEVEL"
  92. #define ksCmdClassTypeThermostatMode @"THERMOSTAT_MODE"
  93. #define ksCmdClassTypeThermostatFanMode @"THERMOSTAT_FAN_MODE"
  94. #define ksCmdClassTypeThermostatSetPoint @"THERMOSTAT_SETPOINT"
  95. #define ksCmdClassTypeLock @"LOCK"
  96. #define ksCmdClassTypeMeterCurrent @"METER_CURRENT"
  97. #define ksCmdClassTypeMeterTotal @"METER_TOTAL"
  98. #define ksCmdClassTypeAVControlPlayback @"AV_CONTROL_PLAYBACK"
  99. #define ksCmdClassTypeHomeMode @"HOME_MODE"
  100. #define ksCmdClassTypeSpeedControl @"SPEED_CONTROL"
  101. #define ksCmdClassTypeValve @"VALVE"
  102. #define ksCmdClassTypeBattery @"BATTERY"
  103. #define ksCmdClassTypeDeviceStatus @"DEVICE_STATUS"
  104. #define ksCmdClassTypePresence @"PRESENCE"
  105. #define ksCmdClassTypeSystem @"SYSTEM"
  106. + (CmdClsType)cmdclsTypeForCode:(NSString *)code {
  107. CmdClsType type = -1;
  108. if ([code isEqualToString:ksCmdClassTypeFirmwareVersion]) {
  109. type = CmdClsTypeFirmwareVersion;
  110. } else if ([code isEqualToString:ksCmdClassTypeSwitchBinary]) {
  111. type = CmdClsTypeSwitchBinary;
  112. } else if ([code isEqualToString:ksCmdClassTypeSwitchMultiLevel]) {
  113. type = CmdClsTypeSwitchMultiLevel;
  114. } else if ([code isEqualToString:ksCmdClassTypeSwitchColor]) {
  115. type = CmdClsTypeSwitchColor;
  116. } else if ([code isEqualToString:ksCmdClassTypeSensorBinary]) {
  117. type = CmdClsTypeSensorBinary;
  118. } else if ([code isEqualToString:ksCmdClassTypeSensorMultiLevel]) {
  119. type = CmdClsTypeSensorMultiLevel;
  120. } else if ([code isEqualToString:ksCmdClassTypeThermostatMode]) {
  121. type = CmdClsTypeThermostatMode;
  122. } else if ([code isEqualToString:ksCmdClassTypeThermostatFanMode]) {
  123. type = CmdClsTypeThermostatFanMode;
  124. } else if ([code isEqualToString:ksCmdClassTypeThermostatSetPoint]) {
  125. type = CmdClsTypeThermostatSetPoint;
  126. } else if ([code isEqualToString:ksCmdClassTypeLock]) {
  127. type = CmdClsTypeLock;
  128. } else if ([code isEqualToString:ksCmdClassTypeMeterCurrent]) {
  129. type = CmdClsTypeMeterCurrent;
  130. } else if ([code isEqualToString:ksCmdClassTypeMeterTotal]) {
  131. type = CmdClsTypeMeterTotal;
  132. } else if ([code isEqualToString:ksCmdClassTypeAVControlPlayback]) {
  133. type = CmdClsTypeAVControlPlayback;
  134. } else if ([code isEqualToString:ksCmdClassTypeHomeMode]) {
  135. type = CmdClsTypeHomeMode;
  136. } else if ([code isEqualToString:ksCmdClassTypeSpeedControl]) {
  137. type = CmdClsTypeSpeedControl;
  138. }
  139. return type;
  140. }
  141. - (CmdClsType)cmdclsType {
  142. return [ItemSubModel cmdclsTypeForCode:_cmdclsCode];
  143. }
  144. - (NSInteger)cmdclsValueMsgLength {
  145. NSInteger length = 0;
  146. // NSArray<CmdClsValueModel> *array = nil;
  147. //
  148. // switch ([self cmdclsType]) {
  149. // case CmdClsTypeLock:
  150. // array = [self cmdclsValueListOfLock];
  151. // break;
  152. // default:
  153. // break;
  154. // }
  155. for (CmdClsValueModel *tmpCmdclsValue in self.cmdclsValueList) {
  156. if (tmpCmdclsValue.cmdclsValueMsg.length > length) {
  157. length = tmpCmdclsValue.cmdclsValueMsg.length;
  158. }
  159. }
  160. return length;
  161. }
  162. - (NSString *)cmdclsValueMsgLongest {
  163. NSString *hstring = nil;
  164. // NSArray<CmdClsValueModel> *array = nil;
  165. //
  166. // switch ([self cmdclsType]) {
  167. // case CmdClsTypeSwitchBinary:
  168. // array = [self cmdclsValueListOfSwitchBinary];
  169. // break;
  170. // case CmdClsTypeLock:
  171. // array = [self cmdclsValueListOfLock];
  172. // break;
  173. // default:
  174. // break;
  175. // }
  176. NSUInteger highest = 0;
  177. for (CmdClsValueModel *tmpCmdclsValue in self.cmdclsValueList) {
  178. if (tmpCmdclsValue.cmdclsValueMsg.length > highest) {
  179. highest = tmpCmdclsValue.cmdclsValueMsg.length;
  180. hstring = tmpCmdclsValue.cmdclsValueMsg;
  181. }
  182. }
  183. return hstring;
  184. }
  185. /*
  186. - (NSArray<CmdClsValueModel> *)cmdclsValueList {
  187. switch ([self cmdclsType]) {
  188. case CmdClsTypeThermostatMode:
  189. _cmdclsValueList = [self cmdclsValueListOfThermostatMode];
  190. break;
  191. case CmdClsTypeLock:
  192. _cmdclsValueList = [self cmdclsValueListOfLock];
  193. break;
  194. case CmdClsTypeSpeedControl:
  195. _cmdclsValueList = [self cmdclsValueListOfSpeedControl];
  196. break;
  197. case CmdClsTypeSwitchBinary:
  198. _cmdclsValueList = [self cmdclsValueListOfSwitchBinary];
  199. break;
  200. case CmdClsTypeValve:
  201. _cmdclsValueList = [self cmdclsValueListOfValve];
  202. break;
  203. default:
  204. break;
  205. }
  206. return _cmdclsValueList;
  207. }
  208. - (NSArray<CmdClsValueModel> *)cmdclsValueListOfThermostatMode {
  209. NSMutableArray<CmdClsValueModel> *array = [(NSMutableArray<CmdClsValueModel> *)[NSMutableArray alloc] init];
  210. NSInteger typeId = [_cmdclsTypeId integerValue];
  211. switch (typeId) {
  212. case 13001: {
  213. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
  214. @"cmdcls_value_msg": NSLocalizedString(@"꺼짐", @"꺼짐")} error:nil]];
  215. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"COOL",
  216. @"cmdcls_value_msg": NSLocalizedString(@"냉방", @"냉방")} error:nil]];
  217. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"HEAT",
  218. @"cmdcls_value_msg": NSLocalizedString(@"난방", @"난방")} error:nil]];
  219. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"AUTO",
  220. @"cmdcls_value_msg": NSLocalizedString(@"자동", @"자동")} error:nil]];
  221. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"FAN_ONLY",
  222. @"cmdcls_value_msg": NSLocalizedString(@"환기", @"환기")} error:nil]];
  223. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"DRY_AIR",
  224. @"cmdcls_value_msg": NSLocalizedString(@"제습", @"제습")} error:nil]];
  225. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"AWAY",
  226. @"cmdcls_value_msg": NSLocalizedString(@"외출", @"외출")} error:nil]];
  227. }
  228. break;
  229. case 13002: {
  230. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
  231. @"cmdcls_value_msg": NSLocalizedString(@"꺼짐", @"꺼짐")} error:nil]];
  232. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"COOL",
  233. @"cmdcls_value_msg": NSLocalizedString(@"냉방", @"냉방")} error:nil]];
  234. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"HEAT",
  235. @"cmdcls_value_msg": NSLocalizedString(@"난방", @"난방")} error:nil]];
  236. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"AUTO",
  237. @"cmdcls_value_msg": NSLocalizedString(@"자동", @"자동")} error:nil]];
  238. }
  239. break;
  240. case 13003: {
  241. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
  242. @"cmdcls_value_msg": NSLocalizedString(@"꺼짐", @"꺼짐")} error:nil]];
  243. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"HEAT",
  244. @"cmdcls_value_msg": NSLocalizedString(@"난방", @"난방")} error:nil]];
  245. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"AWAY",
  246. @"cmdcls_value_msg": NSLocalizedString(@"외출", @"외출")} error:nil]];
  247. }
  248. break;
  249. case 13004: {
  250. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
  251. @"cmdcls_value_msg": NSLocalizedString(@"꺼짐", @"꺼짐")} error:nil]];
  252. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"COOL",
  253. @"cmdcls_value_msg": NSLocalizedString(@"냉방", @"냉방")} error:nil]];
  254. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"FAN_ONLY",
  255. @"cmdcls_value_msg": NSLocalizedString(@"환기", @"환기")} error:nil]];
  256. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"DRY_AIR",
  257. @"cmdcls_value_msg": NSLocalizedString(@"제습", @"제습")} error:nil]];
  258. }
  259. break;
  260. }
  261. return array;
  262. }
  263. - (NSArray<CmdClsValueModel> *)cmdclsValueListOfSwitchBinary {
  264. NSMutableArray<CmdClsValueModel> *array = [(NSMutableArray<CmdClsValueModel> *)[NSMutableArray alloc] init];
  265. NSInteger typeId = [_cmdclsTypeId integerValue];
  266. switch (typeId) {
  267. case 17001:
  268. case 17002:
  269. case 17003:
  270. case 17004:
  271. case 17005:
  272. {
  273. for (CmdClsValueModel *cmdclsValue in self.cmdclsValueList) {
  274. if ([cmdclsValue.cmdclsValue isEqualToString:@"ON"]) {
  275. cmdclsValue.localizedCmdClsValueMsg = @"켬", @""
  276. }
  277. }
  278. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"ON",
  279. @"cmdcls_value_msg": NSLocalizedString(@"켬", @"켬")} error:nil]];
  280. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
  281. @"cmdcls_value_msg": NSLocalizedString(@"끔", @"끔")} error:nil]];
  282. break;
  283. }
  284. }
  285. return array;
  286. }
  287. - (NSArray<CmdClsValueModel> *)cmdclsValueListOfLock {
  288. NSMutableArray<CmdClsValueModel> *array = [(NSMutableArray<CmdClsValueModel> *)[NSMutableArray alloc] init];
  289. NSInteger typeId = [_cmdclsTypeId integerValue];
  290. switch (typeId) {
  291. case 14001: {
  292. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"LOCKED",
  293. @"cmdcls_value_msg": @"잠김"} error:nil]];
  294. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"UNCLOCKED",
  295. @"cmdcls_value_msg": @"열림"} error:nil]];
  296. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"JAMMED",
  297. @"cmdcls_value_msg": @"걸림"} error:nil]];
  298. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"FORCED_OPEN",
  299. @"cmdcls_value_msg": @"수동"} error:nil]];
  300. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"UNSPECIFIED",
  301. @"cmdcls_value_msg": @"오류"} error:nil]];
  302. }
  303. break;
  304. case 14002:
  305. case 14003:
  306. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"LOCKED",
  307. @"cmdcls_value_msg": @"잠김"} error:nil]];
  308. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"UNCLOCKED",
  309. @"cmdcls_value_msg": @"열림"} error:nil]];
  310. break;
  311. }
  312. return array;
  313. }
  314. - (NSArray<CmdClsValueModel> *)cmdclsValueListOfSpeedControl {
  315. NSMutableArray<CmdClsValueModel> *array = [(NSMutableArray<CmdClsValueModel> *)[NSMutableArray alloc] init];
  316. NSInteger typeId = [_cmdclsTypeId integerValue];
  317. switch (typeId) {
  318. case 20001: {
  319. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
  320. @"cmdcls_value_msg": @"꺼짐"} error:nil]];
  321. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"LOW",
  322. @"cmdcls_value_msg": @"약"} error:nil]];
  323. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"MEDIUM",
  324. @"cmdcls_value_msg": @"중"} error:nil]];
  325. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"HIGH",
  326. @"cmdcls_value_msg": @"강"} error:nil]];
  327. }
  328. break;
  329. }
  330. return array;
  331. }
  332. - (NSArray<CmdClsValueModel> *)cmdclsValueListOfValve {
  333. NSMutableArray<CmdClsValueModel> *array = [(NSMutableArray<CmdClsValueModel> *)[NSMutableArray alloc] init];
  334. NSInteger typeId = [_cmdclsTypeId integerValue];
  335. switch (typeId) {
  336. case 36001:
  337. case 36002:
  338. case 36003:
  339. {
  340. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OPEN",
  341. @"cmdcls_value_msg": @"열기"} error:nil]];
  342. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"CLOSE",
  343. @"cmdcls_value_msg": @"잠그기"} error:nil]];
  344. }
  345. break;
  346. }
  347. return array;
  348. }
  349. */
  350. - (NSString *)unit {
  351. if ([_unit isEqualToString:@"\\"]) {
  352. _unit = @"₩";
  353. }
  354. return _unit;
  355. }
  356. //- (NSString *)cmdclsValueMsgOfSensorBinary {
  357. // NSInteger typeId = [_cmdclsTypeId integerValue];
  358. // NSString *msg = ksEmptyString;
  359. // switch (typeId) {
  360. // case 11001:
  361. // case 11002:
  362. // case 11003:
  363. // case 11004:
  364. // case 11005:
  365. // case 11006:
  366. // case 11007:
  367. // case 11008:
  368. // case 11009:
  369. // case 11010:
  370. // case 11012:
  371. // case 11013:
  372. // case 11014:
  373. // case 11016:
  374. // if ([_cmdclsValue isEqualToString:@"TRUE"]) {
  375. // msg = NSLocalizedString(@"감지됨", @"감지됨");
  376. // } else if ([_cmdclsValue isEqualToString:@"FALSE"]) {
  377. // msg = NSLocalizedString(@"정상", @"정상");
  378. // } else {
  379. // msg = @"-";
  380. // }
  381. // break;
  382. // case 11011:
  383. // if ([_cmdclsValue isEqualToString:@"TRUE"]) {
  384. // msg = NSLocalizedString(@"열림", @"열림");
  385. // } else if ([_cmdclsValue isEqualToString:@"FALSE"]) {
  386. // msg = NSLocalizedString(@"닫힘", @"닫힘");
  387. // } else {
  388. // msg = @"-";
  389. // }
  390. // case 11015:
  391. // if ([_cmdclsValue isEqualToString:@"TRUE"]) {
  392. // msg = NSLocalizedString(@"들어옴", @"들어옴");
  393. // } else if ([_cmdclsValue isEqualToString:@"FALSE"]) {
  394. // msg = NSLocalizedString(@"나감", @"나감");
  395. // } else {
  396. // msg = @"-";
  397. // }
  398. // break;
  399. // }
  400. // return msg;
  401. //}
  402. - (NSString *)cmdclsValueMsgOfThermostatMode {
  403. NSInteger typeId = [_cmdclsTypeId integerValue];
  404. NSString *msg = ksEmptyString;
  405. switch (typeId) {
  406. case 13001:
  407. case 13002:
  408. case 13003:
  409. case 13004:
  410. if ([_cmdclsValue isEqualToString:@"OFF"]) {
  411. msg = NSLocalizedString(@"꺼짐", @"꺼짐");
  412. } else if ([_cmdclsValue isEqualToString:@"COOL"]) {
  413. msg = NSLocalizedString(@"냉방", @"냉방");
  414. } else if ([_cmdclsValue isEqualToString:@"HEAT"]) {
  415. msg = NSLocalizedString(@"난방", @"난방");
  416. } else if ([_cmdclsValue isEqualToString:@"AUTO"]) {
  417. msg = NSLocalizedString(@"자동", @"자동");
  418. } else if ([_cmdclsValue isEqualToString:@"FAN_ONLY"]) {
  419. msg = NSLocalizedString(@"환기", @"환기");
  420. } else if ([_cmdclsValue isEqualToString:@"DRY_AIR"]) {
  421. msg = NSLocalizedString(@"제습", @"제습");
  422. } else if ([_cmdclsValue isEqualToString:@"AWAY"]) {
  423. msg = NSLocalizedString(@"외출", @"외출");
  424. } else {
  425. msg = @"-";
  426. }
  427. break;
  428. }
  429. return msg;
  430. }
  431. - (NSString *)cmdclsValueMsgOfLock {
  432. NSInteger typeId = [_cmdclsTypeId integerValue];
  433. NSString *msg = ksEmptyString;
  434. switch (typeId) {
  435. case 14001:
  436. if ([_cmdclsValue isEqualToString:@"LOCKED"]) {
  437. msg = NSLocalizedString(@"잠김", @"잠김");
  438. } else if ([_cmdclsValue isEqualToString:@"UNLOCKED"]) {
  439. msg = NSLocalizedString(@"열림", @"열림");
  440. } else if ([_cmdclsValue isEqualToString:@"JAMMED"]) {
  441. msg = NSLocalizedString(@"걸림", @"걸림");
  442. } else if ([_cmdclsValue isEqualToString:@"FORCED_OPEN"]) {
  443. msg = NSLocalizedString(@"수동", @"수동");
  444. } else if ([_cmdclsValue isEqualToString:@"UNSPECIFIED"]) {
  445. msg = NSLocalizedString(@"오류", @"오류");
  446. } else {
  447. msg = @"-";
  448. }
  449. break;
  450. case 14002:
  451. case 14003:
  452. if ([_cmdclsValue isEqualToString:@"LOCKED"]) {
  453. msg = @"잠김";
  454. } else if ([_cmdclsValue isEqualToString:@"UNLOCKED"]) {
  455. msg = @"열림";
  456. } else {
  457. msg = @"-";
  458. }
  459. break;
  460. }
  461. return msg;
  462. }
  463. - (NSString *)cmdclsValueMsgOfSwitchBinary {//On/Off status
  464. NSInteger typeId = [_cmdclsTypeId integerValue];
  465. NSString *msg = ksEmptyString;
  466. switch (typeId) {
  467. case 17001://Default
  468. case 17002://Plug
  469. case 17003://Bulb
  470. case 17004://Light
  471. case 17005://Wall Switch
  472. if ([_cmdclsValue isEqualToString:@"ON"]) {
  473. msg = NSLocalizedString(@"켬", @"켬");
  474. } else if ([_cmdclsValue isEqualToString:@"OFF"]) {
  475. msg = NSLocalizedString(@"끔", @"끔");
  476. } else {
  477. msg = @"-";
  478. }
  479. break;
  480. }
  481. return msg;
  482. }
  483. - (NSString *)cmdclsValueMsg {
  484. switch ([self cmdclsType]) {
  485. // case CmdClsTypeSensorBinary:
  486. // _cmdclsValueMsg = [self cmdclsValueMsgOfSensorBinary];
  487. // break;
  488. case CmdClsTypeThermostatMode:
  489. _cmdclsValueMsg = [self cmdclsValueMsgOfThermostatMode];
  490. break;
  491. case CmdClsTypeLock:
  492. _cmdclsValueMsg = [self cmdclsValueMsgOfLock];
  493. break;
  494. case CmdClsTypeSwitchBinary:
  495. _cmdclsValueMsg = [self cmdclsValueMsgOfSwitchBinary];
  496. break;
  497. case CmdClsTypeSpeedControl:
  498. _cmdclsValueMsg = [self cmdclsValueMsgOfSpeedControl];
  499. break;
  500. case CmdClsTypeAVControlPlayback:
  501. _cmdclsValueMsg = [self cmdclsValueMsgOfAVPlayback];
  502. break;
  503. case CmdClsTypeValve:
  504. _cmdclsValueMsg = [self cmdclsValueMsgOfValve];
  505. }
  506. return _cmdclsValueMsg;
  507. }
  508. - (NSString *)cmdclsValueMsgOfSpeedControl {
  509. NSInteger typeId = [_cmdclsTypeId integerValue];
  510. NSString *msg = ksEmptyString;
  511. switch (typeId) {
  512. case 20001:
  513. if ([_cmdclsValue isEqualToString:@"OFF"]) {
  514. msg = NSLocalizedString(@"꺼짐", @"꺼짐");
  515. } else if ([_cmdclsValue isEqualToString:@"LOW"]) {
  516. msg = NSLocalizedString(@"약", @"약");
  517. } else if ([_cmdclsValue isEqualToString:@"MEDIUM"]) {
  518. msg = NSLocalizedString(@"중", @"중");
  519. } else if ([_cmdclsValue isEqualToString:@"HIGH"]) {
  520. msg = NSLocalizedString(@"강", @"강");
  521. } else {
  522. msg = @"-";
  523. }
  524. break;
  525. }
  526. return msg;
  527. }
  528. - (NSString *)cmdclsValueMsgOfAVPlayback {
  529. NSInteger typeId = [_cmdclsTypeId integerValue];
  530. NSString *msg = ksEmptyString;
  531. switch (typeId) {
  532. case 21001:
  533. if ([_cmdclsValue isEqualToString:@"PLAYING"]) {
  534. msg = NSLocalizedString(@"재생 중", @"재생 중");
  535. } else if ([_cmdclsValue isEqualToString:@"PAUSED"]) {
  536. msg = NSLocalizedString(@"정지 됨", @"정지 됨");
  537. } else {
  538. msg = @"-";
  539. }
  540. break;
  541. }
  542. return msg;
  543. }
  544. - (NSString *)cmdclsValueMsgOfValve {
  545. NSInteger typeId= [_cmdclsTypeId integerValue];
  546. NSString *msg = ksEmptyString;
  547. switch (typeId) {
  548. case 36001:
  549. case 36002:
  550. case 36003:
  551. if ([_cmdclsValue isEqualToString:@"OPEN"]) {
  552. msg = NSLocalizedString(@"열기", @"열기");
  553. } else if ([_cmdclsValue isEqualToString:@"CLOSE"]) {
  554. msg = NSLocalizedString(@"잠그기", @"잠그기");
  555. } else {
  556. msg = @"-";
  557. }
  558. break;
  559. }
  560. return msg;
  561. }
  562. @end
  563. @implementation ItemModel
  564. + (JSONKeyMapper *)keyMapper {
  565. return [[JSONKeyMapper alloc] initWithDictionary:@{@"pred_item_sequence": @"predItemSequence",
  566. @"item_type_code": @"itemTypeCode",
  567. @"item_sub_type_code": @"itemSubTypeCode",
  568. @"item_name": @"itemName",
  569. @"item_sub": @"subItems",
  570. @"pred_action_sequence": @"predActionSequence",
  571. @"pred_scene_id": @"predSceneId",
  572. @"pred_rule_id": @"predRuleId",
  573. @"cnt" : @"cnt",
  574. @"total_cnt" : @"totalCnt",
  575. @"image_file_name": @"imageFileName",
  576. @"source_id": @"sourceId",
  577. @"source_name": @"sourceName",
  578. @"image_file_view_name": @"imageFileViewName"}];
  579. }
  580. + (NSString *)itemSubTypeString:(NSString *)itemSubTypeCode {
  581. NSString *string = ksEmptyString;
  582. if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeDevice]) {
  583. string = @"Choose your things & action";
  584. } else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeMode]) {
  585. string = @"Choose home mode";
  586. } else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeAppPush]) {
  587. string = @"Choose your things & action";
  588. } else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeTimer]) {
  589. string = @"Choose your things & action";
  590. }
  591. return string;
  592. }
  593. - (NSInteger)sumPredDeviceCount {
  594. return _predDevices.count + [_cnt integerValue];
  595. }
  596. - (NSInteger)sumModesCount {
  597. return _modes.count + [_cnt integerValue];
  598. }
  599. - (NSInteger)sumPushesCount {
  600. return _pushes.count + [_cnt integerValue];
  601. }
  602. @end
  603. @implementation ItemListModel
  604. @end
  605. @implementation ItemSubListModel
  606. @end