ItemModel.m 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  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. } else if ([code isEqualToString:ksCmdClassTypeValve]) {
  139. type = CmdClsTypeValve;
  140. } else if ([code isEqualToString:ksCmdClassTypeBattery]) {
  141. type = CmdClsTypeBattery;
  142. } else if ([code isEqualToString:ksCmdClassTypeDeviceStatus]) {
  143. type = CmdClsTypeDeviceStatus;
  144. } else if ([code isEqualToString:ksCmdClassTypePresence]) {
  145. type = CmdClsTypePresence;
  146. } else if ([code isEqualToString:ksCmdClassTypeSystem]) {
  147. type = CmdClsTypeSystem;
  148. }
  149. return type;
  150. }
  151. - (CmdClsType)cmdclsType {
  152. return [ItemSubModel cmdclsTypeForCode:_cmdclsCode];
  153. }
  154. - (NSInteger)cmdclsValueMsgLength {
  155. NSInteger length = 0;
  156. // NSArray<CmdClsValueModel> *array = nil;
  157. //
  158. // switch ([self cmdclsType]) {
  159. // case CmdClsTypeLock:
  160. // array = [self cmdclsValueListOfLock];
  161. // break;
  162. // default:
  163. // break;
  164. // }
  165. for (CmdClsValueModel *tmpCmdclsValue in self.cmdclsValueList) {
  166. if (tmpCmdclsValue.cmdclsValueMsg.length > length) {
  167. length = tmpCmdclsValue.cmdclsValueMsg.length;
  168. }
  169. }
  170. return length;
  171. }
  172. - (NSString *)cmdclsValueMsgLongest {
  173. NSString *hstring = nil;
  174. // NSArray<CmdClsValueModel> *array = nil;
  175. //
  176. // switch ([self cmdclsType]) {
  177. // case CmdClsTypeSwitchBinary:
  178. // array = [self cmdclsValueListOfSwitchBinary];
  179. // break;
  180. // case CmdClsTypeLock:
  181. // array = [self cmdclsValueListOfLock];
  182. // break;
  183. // default:
  184. // break;
  185. // }
  186. NSUInteger highest = 0;
  187. for (CmdClsValueModel *tmpCmdclsValue in self.cmdclsValueList) {
  188. if (tmpCmdclsValue.cmdclsValueMsg.length > highest) {
  189. highest = tmpCmdclsValue.cmdclsValueMsg.length;
  190. hstring = tmpCmdclsValue.cmdclsValueMsg;
  191. }
  192. }
  193. return hstring;
  194. }
  195. /*
  196. - (NSArray<CmdClsValueModel> *)cmdclsValueList {
  197. switch ([self cmdclsType]) {
  198. case CmdClsTypeThermostatMode:
  199. _cmdclsValueList = [self cmdclsValueListOfThermostatMode];
  200. break;
  201. case CmdClsTypeLock:
  202. _cmdclsValueList = [self cmdclsValueListOfLock];
  203. break;
  204. case CmdClsTypeSpeedControl:
  205. _cmdclsValueList = [self cmdclsValueListOfSpeedControl];
  206. break;
  207. case CmdClsTypeSwitchBinary:
  208. _cmdclsValueList = [self cmdclsValueListOfSwitchBinary];
  209. break;
  210. case CmdClsTypeValve:
  211. _cmdclsValueList = [self cmdclsValueListOfValve];
  212. break;
  213. default:
  214. break;
  215. }
  216. return _cmdclsValueList;
  217. }
  218. - (NSArray<CmdClsValueModel> *)cmdclsValueListOfThermostatMode {
  219. NSMutableArray<CmdClsValueModel> *array = [(NSMutableArray<CmdClsValueModel> *)[NSMutableArray alloc] init];
  220. NSInteger typeId = [_cmdclsTypeId integerValue];
  221. switch (typeId) {
  222. case 13001: {
  223. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
  224. @"cmdcls_value_msg": NSLocalizedString(@"꺼짐", @"꺼짐")} error:nil]];
  225. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"COOL",
  226. @"cmdcls_value_msg": NSLocalizedString(@"냉방", @"냉방")} error:nil]];
  227. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"HEAT",
  228. @"cmdcls_value_msg": NSLocalizedString(@"난방", @"난방")} error:nil]];
  229. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"AUTO",
  230. @"cmdcls_value_msg": NSLocalizedString(@"자동", @"자동")} error:nil]];
  231. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"FAN_ONLY",
  232. @"cmdcls_value_msg": NSLocalizedString(@"환기", @"환기")} error:nil]];
  233. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"DRY_AIR",
  234. @"cmdcls_value_msg": NSLocalizedString(@"제습", @"제습")} error:nil]];
  235. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"AWAY",
  236. @"cmdcls_value_msg": NSLocalizedString(@"외출", @"외출")} error:nil]];
  237. }
  238. break;
  239. case 13002: {
  240. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
  241. @"cmdcls_value_msg": NSLocalizedString(@"꺼짐", @"꺼짐")} error:nil]];
  242. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"COOL",
  243. @"cmdcls_value_msg": NSLocalizedString(@"냉방", @"냉방")} error:nil]];
  244. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"HEAT",
  245. @"cmdcls_value_msg": NSLocalizedString(@"난방", @"난방")} error:nil]];
  246. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"AUTO",
  247. @"cmdcls_value_msg": NSLocalizedString(@"자동", @"자동")} error:nil]];
  248. }
  249. break;
  250. case 13003: {
  251. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
  252. @"cmdcls_value_msg": NSLocalizedString(@"꺼짐", @"꺼짐")} error:nil]];
  253. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"HEAT",
  254. @"cmdcls_value_msg": NSLocalizedString(@"난방", @"난방")} error:nil]];
  255. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"AWAY",
  256. @"cmdcls_value_msg": NSLocalizedString(@"외출", @"외출")} error:nil]];
  257. }
  258. break;
  259. case 13004: {
  260. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
  261. @"cmdcls_value_msg": NSLocalizedString(@"꺼짐", @"꺼짐")} error:nil]];
  262. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"COOL",
  263. @"cmdcls_value_msg": NSLocalizedString(@"냉방", @"냉방")} error:nil]];
  264. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"FAN_ONLY",
  265. @"cmdcls_value_msg": NSLocalizedString(@"환기", @"환기")} error:nil]];
  266. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"DRY_AIR",
  267. @"cmdcls_value_msg": NSLocalizedString(@"제습", @"제습")} error:nil]];
  268. }
  269. break;
  270. }
  271. return array;
  272. }
  273. - (NSArray<CmdClsValueModel> *)cmdclsValueListOfSwitchBinary {
  274. NSMutableArray<CmdClsValueModel> *array = [(NSMutableArray<CmdClsValueModel> *)[NSMutableArray alloc] init];
  275. NSInteger typeId = [_cmdclsTypeId integerValue];
  276. switch (typeId) {
  277. case 17001:
  278. case 17002:
  279. case 17003:
  280. case 17004:
  281. case 17005:
  282. {
  283. for (CmdClsValueModel *cmdclsValue in self.cmdclsValueList) {
  284. if ([cmdclsValue.cmdclsValue isEqualToString:@"ON"]) {
  285. cmdclsValue.localizedCmdClsValueMsg = @"켬", @""
  286. }
  287. }
  288. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"ON",
  289. @"cmdcls_value_msg": NSLocalizedString(@"켬", @"켬")} error:nil]];
  290. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
  291. @"cmdcls_value_msg": NSLocalizedString(@"끔", @"끔")} error:nil]];
  292. break;
  293. }
  294. }
  295. return array;
  296. }
  297. - (NSArray<CmdClsValueModel> *)cmdclsValueListOfLock {
  298. NSMutableArray<CmdClsValueModel> *array = [(NSMutableArray<CmdClsValueModel> *)[NSMutableArray alloc] init];
  299. NSInteger typeId = [_cmdclsTypeId integerValue];
  300. switch (typeId) {
  301. case 14001: {
  302. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"LOCKED",
  303. @"cmdcls_value_msg": @"잠김"} error:nil]];
  304. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"UNCLOCKED",
  305. @"cmdcls_value_msg": @"열림"} error:nil]];
  306. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"JAMMED",
  307. @"cmdcls_value_msg": @"걸림"} error:nil]];
  308. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"FORCED_OPEN",
  309. @"cmdcls_value_msg": @"수동"} error:nil]];
  310. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"UNSPECIFIED",
  311. @"cmdcls_value_msg": @"오류"} error:nil]];
  312. }
  313. break;
  314. case 14002:
  315. case 14003:
  316. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"LOCKED",
  317. @"cmdcls_value_msg": @"잠김"} error:nil]];
  318. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"UNCLOCKED",
  319. @"cmdcls_value_msg": @"열림"} error:nil]];
  320. break;
  321. }
  322. return array;
  323. }
  324. - (NSArray<CmdClsValueModel> *)cmdclsValueListOfSpeedControl {
  325. NSMutableArray<CmdClsValueModel> *array = [(NSMutableArray<CmdClsValueModel> *)[NSMutableArray alloc] init];
  326. NSInteger typeId = [_cmdclsTypeId integerValue];
  327. switch (typeId) {
  328. case 20001: {
  329. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OFF",
  330. @"cmdcls_value_msg": @"꺼짐"} error:nil]];
  331. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"LOW",
  332. @"cmdcls_value_msg": @"약"} error:nil]];
  333. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"MEDIUM",
  334. @"cmdcls_value_msg": @"중"} error:nil]];
  335. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"HIGH",
  336. @"cmdcls_value_msg": @"강"} error:nil]];
  337. }
  338. break;
  339. }
  340. return array;
  341. }
  342. - (NSArray<CmdClsValueModel> *)cmdclsValueListOfValve {
  343. NSMutableArray<CmdClsValueModel> *array = [(NSMutableArray<CmdClsValueModel> *)[NSMutableArray alloc] init];
  344. NSInteger typeId = [_cmdclsTypeId integerValue];
  345. switch (typeId) {
  346. case 36001:
  347. case 36002:
  348. case 36003:
  349. {
  350. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"OPEN",
  351. @"cmdcls_value_msg": @"열기"} error:nil]];
  352. [array addObject:[[CmdClsValueModel alloc] initWithDictionary:@{@"cmdcls_value":@"CLOSE",
  353. @"cmdcls_value_msg": @"잠그기"} error:nil]];
  354. }
  355. break;
  356. }
  357. return array;
  358. }
  359. */
  360. - (NSString *)unit {
  361. if ([_unit isEqualToString:@"\\"]) {
  362. _unit = @"₩";
  363. }
  364. return _unit;
  365. }
  366. //- (NSString *)cmdclsValueMsgOfSensorBinary {
  367. // NSInteger typeId = [_cmdclsTypeId integerValue];
  368. // NSString *msg = ksEmptyString;
  369. // switch (typeId) {
  370. // case 11001:
  371. // case 11002:
  372. // case 11003:
  373. // case 11004:
  374. // case 11005:
  375. // case 11006:
  376. // case 11007:
  377. // case 11008:
  378. // case 11009:
  379. // case 11010:
  380. // case 11012:
  381. // case 11013:
  382. // case 11014:
  383. // case 11016:
  384. // if ([_cmdclsValue isEqualToString:@"TRUE"]) {
  385. // msg = NSLocalizedString(@"감지됨", @"감지됨");
  386. // } else if ([_cmdclsValue isEqualToString:@"FALSE"]) {
  387. // msg = NSLocalizedString(@"정상", @"정상");
  388. // } else {
  389. // msg = @"-";
  390. // }
  391. // break;
  392. // case 11011:
  393. // if ([_cmdclsValue isEqualToString:@"TRUE"]) {
  394. // msg = NSLocalizedString(@"열림", @"열림");
  395. // } else if ([_cmdclsValue isEqualToString:@"FALSE"]) {
  396. // msg = NSLocalizedString(@"닫힘", @"닫힘");
  397. // } else {
  398. // msg = @"-";
  399. // }
  400. // case 11015:
  401. // if ([_cmdclsValue isEqualToString:@"TRUE"]) {
  402. // msg = NSLocalizedString(@"들어옴", @"들어옴");
  403. // } else if ([_cmdclsValue isEqualToString:@"FALSE"]) {
  404. // msg = NSLocalizedString(@"나감", @"나감");
  405. // } else {
  406. // msg = @"-";
  407. // }
  408. // break;
  409. // }
  410. // return msg;
  411. //}
  412. - (NSString *)cmdclsValueMsgOfThermostatMode {
  413. NSInteger typeId = [_cmdclsTypeId integerValue];
  414. NSString *msg = ksEmptyString;
  415. switch (typeId) {
  416. case 13001:
  417. case 13002:
  418. case 13003:
  419. case 13004:
  420. if ([_cmdclsValue isEqualToString:@"OFF"]) {
  421. msg = NSLocalizedString(@"꺼짐", @"꺼짐");
  422. } else if ([_cmdclsValue isEqualToString:@"COOL"]) {
  423. msg = NSLocalizedString(@"냉방", @"냉방");
  424. } else if ([_cmdclsValue isEqualToString:@"HEAT"]) {
  425. msg = NSLocalizedString(@"난방", @"난방");
  426. } else if ([_cmdclsValue isEqualToString:@"AUTO"]) {
  427. msg = NSLocalizedString(@"자동", @"자동");
  428. } else if ([_cmdclsValue isEqualToString:@"FAN_ONLY"]) {
  429. msg = NSLocalizedString(@"환기", @"환기");
  430. } else if ([_cmdclsValue isEqualToString:@"DRY_AIR"]) {
  431. msg = NSLocalizedString(@"제습", @"제습");
  432. } else if ([_cmdclsValue isEqualToString:@"AWAY"]) {
  433. msg = NSLocalizedString(@"외출", @"외출");
  434. } else {
  435. msg = @"-";
  436. }
  437. break;
  438. }
  439. return msg;
  440. }
  441. - (NSString *)cmdclsValueMsgOfLock {
  442. NSInteger typeId = [_cmdclsTypeId integerValue];
  443. NSString *msg = ksEmptyString;
  444. switch (typeId) {
  445. case 14001:
  446. if ([_cmdclsValue isEqualToString:@"LOCKED"]) {
  447. msg = NSLocalizedString(@"잠김", @"잠김");
  448. } else if ([_cmdclsValue isEqualToString:@"UNLOCKED"]) {
  449. msg = NSLocalizedString(@"열림", @"열림");
  450. } else if ([_cmdclsValue isEqualToString:@"JAMMED"]) {
  451. msg = NSLocalizedString(@"걸림", @"걸림");
  452. } else if ([_cmdclsValue isEqualToString:@"FORCED_OPEN"]) {
  453. msg = NSLocalizedString(@"수동", @"수동");
  454. } else if ([_cmdclsValue isEqualToString:@"UNSPECIFIED"]) {
  455. msg = NSLocalizedString(@"오류", @"오류");
  456. } else {
  457. msg = @"-";
  458. }
  459. break;
  460. case 14002:
  461. case 14003:
  462. if ([_cmdclsValue isEqualToString:@"LOCKED"]) {
  463. msg = @"잠김";
  464. } else if ([_cmdclsValue isEqualToString:@"UNLOCKED"]) {
  465. msg = @"열림";
  466. } else {
  467. msg = @"-";
  468. }
  469. break;
  470. }
  471. return msg;
  472. }
  473. - (NSString *)cmdclsValueMsgOfSwitchBinary {//On/Off status
  474. NSInteger typeId = [_cmdclsTypeId integerValue];
  475. NSString *msg = ksEmptyString;
  476. switch (typeId) {
  477. case 17001://Default
  478. case 17002://Plug
  479. case 17003://Bulb
  480. case 17004://Light
  481. case 17005://Wall Switch
  482. if ([_cmdclsValue isEqualToString:@"ON"]) {
  483. msg = NSLocalizedString(@"켬", @"켬");
  484. } else if ([_cmdclsValue isEqualToString:@"OFF"]) {
  485. msg = NSLocalizedString(@"끔", @"끔");
  486. } else {
  487. msg = @"-";
  488. }
  489. break;
  490. }
  491. return msg;
  492. }
  493. - (NSString *)cmdclsValueMsgOfValve {//Openn/Close status
  494. NSInteger typeId = [_cmdclsTypeId integerValue];
  495. NSString *msg = ksEmptyString;
  496. switch (typeId) {
  497. case 36001://Default
  498. case 36002://NTELS_1
  499. case 36003://NTELS_2
  500. if ([_cmdclsValue isEqualToString:@"OPEN"]) {
  501. msg = NSLocalizedString(@"열기", @"열기");
  502. } else if ([_cmdclsValue isEqualToString:@"CLOSE"]) {
  503. msg = NSLocalizedString(@"잠그기", @"잠그기");
  504. } else {
  505. msg = @"-";
  506. }
  507. break;
  508. }
  509. return msg;
  510. }
  511. - (NSString *)cmdclsValueMsg {
  512. switch ([self cmdclsType]) {
  513. // case CmdClsTypeSensorBinary:
  514. // _cmdclsValueMsg = [self cmdclsValueMsgOfSensorBinary];
  515. // break;
  516. case CmdClsTypeThermostatMode:
  517. _cmdclsValueMsg = [self cmdclsValueMsgOfThermostatMode];
  518. break;
  519. case CmdClsTypeLock:
  520. _cmdclsValueMsg = [self cmdclsValueMsgOfLock];
  521. break;
  522. case CmdClsTypeSwitchBinary:
  523. _cmdclsValueMsg = [self cmdclsValueMsgOfSwitchBinary];
  524. break;
  525. case CmdClsTypeSpeedControl:
  526. _cmdclsValueMsg = [self cmdclsValueMsgOfSpeedControl];
  527. break;
  528. case CmdClsTypeAVControlPlayback:
  529. _cmdclsValueMsg = [self cmdclsValueMsgOfAVPlayback];
  530. break;
  531. case CmdClsTypeValve:
  532. _cmdclsValueMsg = [self cmdclsValueMsgOfValve];
  533. }
  534. return _cmdclsValueMsg;
  535. }
  536. - (NSString *)cmdclsValueMsgOfSpeedControl {
  537. NSInteger typeId = [_cmdclsTypeId integerValue];
  538. NSString *msg = ksEmptyString;
  539. switch (typeId) {
  540. case 20001:
  541. if ([_cmdclsValue isEqualToString:@"OFF"]) {
  542. msg = NSLocalizedString(@"꺼짐", @"꺼짐");
  543. } else if ([_cmdclsValue isEqualToString:@"LOW"]) {
  544. msg = NSLocalizedString(@"약", @"약");
  545. } else if ([_cmdclsValue isEqualToString:@"MEDIUM"]) {
  546. msg = NSLocalizedString(@"중", @"중");
  547. } else if ([_cmdclsValue isEqualToString:@"HIGH"]) {
  548. msg = NSLocalizedString(@"강", @"강");
  549. } else {
  550. msg = @"-";
  551. }
  552. break;
  553. }
  554. return msg;
  555. }
  556. - (NSString *)cmdclsValueMsgOfAVPlayback {
  557. NSInteger typeId = [_cmdclsTypeId integerValue];
  558. NSString *msg = ksEmptyString;
  559. switch (typeId) {
  560. case 21001:
  561. if ([_cmdclsValue isEqualToString:@"PLAYING"]) {
  562. msg = NSLocalizedString(@"재생 중", @"재생 중");
  563. } else if ([_cmdclsValue isEqualToString:@"PAUSED"]) {
  564. msg = NSLocalizedString(@"정지 됨", @"정지 됨");
  565. } else {
  566. msg = @"-";
  567. }
  568. break;
  569. }
  570. return msg;
  571. }
  572. - (BOOL)isOnline {
  573. return _onlineState && ![_onlineState isEmptyString] && [_onlineState isEqualToString:@"ON"];
  574. }
  575. @end
  576. @implementation ItemModel
  577. + (JSONKeyMapper *)keyMapper {
  578. return [[JSONKeyMapper alloc] initWithDictionary:@{@"pred_item_sequence": @"predItemSequence",
  579. @"item_type_code": @"itemTypeCode",
  580. @"item_sub_type_code": @"itemSubTypeCode",
  581. @"item_name": @"itemName",
  582. @"item_sub": @"subItems",
  583. @"pred_action_sequence": @"predActionSequence",
  584. @"pred_scene_id": @"predSceneId",
  585. @"pred_rule_id": @"predRuleId",
  586. @"cnt" : @"cnt",
  587. @"total_cnt" : @"totalCnt",
  588. @"image_file_name": @"imageFileName",
  589. @"source_id": @"sourceId",
  590. @"source_name": @"sourceName",
  591. @"image_file_view_name": @"imageFileViewName"}];
  592. }
  593. + (NSString *)itemSubTypeString:(NSString *)itemSubTypeCode {
  594. NSString *string = ksEmptyString;
  595. if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeDevice]) {
  596. string = @"Choose your things & action";
  597. } else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeMode]) {
  598. string = @"Choose home mode";
  599. } else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeAppPush]) {
  600. string = @"Choose your things & action";
  601. } else if ([itemSubTypeCode isEqualToString:ksItemSubTypeCodeTimer]) {
  602. string = @"Choose your things & action";
  603. }
  604. return string;
  605. }
  606. - (NSInteger)sumPredDeviceCount {
  607. return _predDevices.count + [_cnt integerValue];
  608. }
  609. - (NSInteger)sumModesCount {
  610. return _modes.count + [_cnt integerValue];
  611. }
  612. - (NSInteger)sumPushesCount {
  613. return _pushes.count + [_cnt integerValue];
  614. }
  615. @end
  616. @implementation ItemListModel
  617. @end
  618. @implementation ItemSubListModel
  619. @end