ItemModel.m 28 KB

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