DeviceModel.m 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882
  1. // Generated by json_to_model
  2. #import "JDObject.h"
  3. #import "DeviceModel.h"
  4. #import "CustomRadioGroup.h"
  5. #import "CustomCheckBox.h"
  6. @implementation DeviceModel
  7. //+ (JSONKeyMapper *)keyMapper {
  8. //
  9. // NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
  10. //
  11. // //self
  12. // [dictionary setValue:@"cmdclsTypeSystemName" forKey:@"cmdcls_type_system_name"];
  13. // [dictionary setValue:@"cmdclsTypeId" forKey:@"cmdcls_type_id"];
  14. // [dictionary setValue:@"cmdclsCode" forKey:@"cmdcls_code"];
  15. // [dictionary setValue:@"deviceProfileId" forKey:@"device_profile_id"];
  16. // [dictionary setValue:@"createDatetime" forKey:@"create_datetime"];
  17. // [dictionary setValue:@"cmdclsTypeName" forKey:@"cmdcls_type_name"];
  18. // [dictionary setValue:@"deviceName" forKey:@"device_name"];
  19. // [dictionary setValue:@"profileName" forKey:@"profile_name"];
  20. // [dictionary setValue:@"imageFileName" forKey:@"image_file_name"];
  21. // [dictionary setValue:@"contentValue" forKey:@"content_value"];
  22. // [dictionary setValue:@"nodeName" forKey:@"node_name"];
  23. // [dictionary setValue:@"cmdclsCount" forKey:@"cmdcls_count"];
  24. // [dictionary setValue:@"nodeId" forKey:@"node_id"];
  25. // [dictionary setValue:@"deviceId" forKey:@"device_id"];
  26. //
  27. // return [[JSONKeyMapper alloc] initWithDictionary:dictionary];
  28. //}
  29. - (NSString *)deviceName {
  30. NSString *result = @"";
  31. if (![_prdName isEmptyString]) {
  32. result = _prdName;
  33. }
  34. if (![_prdUserName isEmptyString]) {
  35. result = _prdUserName;
  36. }
  37. return result;
  38. }
  39. - (NSString *)contentValueMsgOfSensorBinary {
  40. NSInteger typeId = [_cmdclsTypeId integerValue];
  41. NSString *msg = ksEmptyString;
  42. switch (typeId) {
  43. case 11001:
  44. case 11002:
  45. case 11003:
  46. case 11004:
  47. case 11005:
  48. case 11006:
  49. case 11007:
  50. case 11008:
  51. case 11009:
  52. case 11010:
  53. case 11012:
  54. case 11013:
  55. case 11014:
  56. case 11016:
  57. case 11018:
  58. if ([self.contentValue isEqualToString:@"TRUE"]) {
  59. msg = NSLocalizedString(@"감지됨", @"감지됨");
  60. } else if ([self.contentValue isEqualToString:@"FALSE"]) {
  61. msg = NSLocalizedString(@"정상", @"정상");
  62. } else {
  63. msg = @"-";
  64. }
  65. break;
  66. case 11011:
  67. if ([self.contentValue isEqualToString:@"TRUE"]) {
  68. msg = NSLocalizedString(@"열림", @"열림");
  69. } else if ([self.contentValue isEqualToString:@"FALSE"]) {
  70. msg = NSLocalizedString(@"닫힘", @"닫힘");
  71. } else {
  72. msg = @"-";
  73. }
  74. break;
  75. case 11015:
  76. case 11017:
  77. if ([self.contentValue isEqualToString:@"TRUE"]) {
  78. msg = NSLocalizedString(@"들어옴", @"들어옴");
  79. } else if ([self.contentValue isEqualToString:@"FALSE"]) {
  80. msg = NSLocalizedString(@"나감", @"나감");
  81. } else {
  82. msg = @"-";
  83. }
  84. break;
  85. }
  86. return msg;
  87. }
  88. - (NSString *)contentValueMsgOfThermostatMode {
  89. NSInteger typeId = [_cmdclsTypeId integerValue];
  90. NSString *msg = ksEmptyString;
  91. switch (typeId) {
  92. case 13001:
  93. case 13002:
  94. case 13003:
  95. case 13004:
  96. if ([self.contentValue isEqualToString:@"OFF"]) {
  97. msg = NSLocalizedString(@"꺼짐", @"꺼짐");
  98. } else if ([self.contentValue isEqualToString:@"COOL"]) {
  99. msg = NSLocalizedString(@"냉방", @"냉방");
  100. } else if ([self.contentValue isEqualToString:@"HEAT"]) {
  101. msg = NSLocalizedString(@"난방", @"난방");
  102. } else if ([self.contentValue isEqualToString:@"AUTO"]) {
  103. msg = NSLocalizedString(@"자동", @"자동");
  104. } else if ([self.contentValue isEqualToString:@"FAN_ONLY"]) {
  105. msg = NSLocalizedString(@"환기", @"환기");
  106. } else if ([self.contentValue isEqualToString:@"DRY_AIR"]) {
  107. msg = NSLocalizedString(@"제습", @"제습");
  108. } else if ([self.contentValue isEqualToString:@"AWAY"]) {
  109. msg = NSLocalizedString(@"외출", @"외출");
  110. } else {
  111. msg = @"-";
  112. }
  113. break;
  114. }
  115. return msg;
  116. }
  117. - (NSString *)contentValueMsgOfLock {
  118. NSInteger typeId = [_cmdclsTypeId integerValue];
  119. NSString *msg = ksEmptyString;
  120. switch (typeId) {
  121. case 14001:
  122. if ([self.contentValue isEqualToString:@"LOCKED"]) {
  123. msg = NSLocalizedString(@"잠김", @"잠김");
  124. } else if ([self.contentValue isEqualToString:@"UNLOCKED"]) {
  125. msg = NSLocalizedString(@"열림", @"열림");
  126. } else if ([self.contentValue isEqualToString:@"JAMMED"]) {
  127. msg = NSLocalizedString(@"걸림", @"걸림");
  128. } else if ([self.contentValue isEqualToString:@"FORCED_OPEN"]) {
  129. msg = NSLocalizedString(@"수동", @"수동");
  130. } else if ([self.contentValue isEqualToString:@"UNSPECIFIED"]) {
  131. msg = NSLocalizedString(@"오류", @"오류");
  132. } else {
  133. msg = @"-";
  134. }
  135. break;
  136. case 14002:
  137. case 14003:
  138. if ([self.contentValue isEqualToString:@"LOCKED"]) {
  139. msg = @"잠김";
  140. } else if ([self.contentValue isEqualToString:@"UNLOCKED"]) {
  141. msg = @"열림";
  142. } else {
  143. msg = @"-";
  144. }
  145. break;
  146. }
  147. return msg;
  148. }
  149. - (NSString *)contentValueMsgOfSwitchBinary {
  150. NSInteger typeId = [_cmdclsTypeId integerValue];
  151. NSString *msg = ksEmptyString;
  152. switch (typeId) {
  153. case 17001:
  154. case 17002:
  155. if ([self.contentValue isEqualToString:@"ON"]) {
  156. msg = NSLocalizedString(@"켜짐", @"켜짐");
  157. } else if ([self.contentValue isEqualToString:@"OFF"]) {
  158. msg = NSLocalizedString(@"꺼짐", @"꺼짐");
  159. } else {
  160. msg = @"-";
  161. }
  162. break;
  163. }
  164. return msg;
  165. }
  166. - (NSString *)contentValueMsgOfValve {
  167. NSInteger typeId = [_cmdclsTypeId integerValue];
  168. NSString *msg = ksEmptyString;
  169. switch (typeId) {
  170. case 36001:
  171. case 36002:
  172. case 36003:
  173. default:
  174. if ([self.contentValue isEqualToString:@"OPEN"]) {
  175. msg = NSLocalizedString(@"열림", @"열림");
  176. } else if ([self.contentValue isEqualToString:@"CLOSE"]) {
  177. msg = NSLocalizedString(@"잠김", @"잠김");
  178. } else {
  179. msg = @"-";
  180. }
  181. break;
  182. }
  183. return msg;
  184. }
  185. - (NSString *)contentValueMsg {
  186. switch ([self cmdclsType]) {
  187. case CmdClsTypeSensorBinary:
  188. _contentValueMsg = [self contentValueMsgOfSensorBinary];
  189. break;
  190. case CmdClsTypeThermostatMode:
  191. _contentValueMsg = [self contentValueMsgOfThermostatMode];
  192. break;
  193. case CmdClsTypeLock:
  194. _contentValueMsg = [self contentValueMsgOfLock];
  195. break;
  196. case CmdClsTypeSwitchBinary:
  197. _contentValueMsg = [self contentValueMsgOfSwitchBinary];
  198. break;
  199. case CmdClsTypeSpeedControl:
  200. _contentValueMsg = [self contentValueMsgOfSpeedControl];
  201. break;
  202. case CmdClsTypeAVControlPlayback:
  203. _contentValueMsg = [self contentValueMsgOfAVPlayback];
  204. break;
  205. case CmdClsTypeValve:
  206. _contentValueMsg = [self contentValueMsgOfValve];
  207. break;
  208. default:
  209. _contentValueMsg = !_contentValue || [_contentValue isEmptyString] || [_contentValue isEqualToString:@"none"] ? @"-" : [NSString stringWithFormat:@"%@%@", _contentValue, _unit];
  210. break;
  211. }
  212. return _contentValueMsg;
  213. }
  214. - (NSString *)contentValueMsgOfSpeedControl {
  215. NSInteger typeId = [_cmdclsTypeId integerValue];
  216. NSString *msg = ksEmptyString;
  217. switch (typeId) {
  218. case 20001:
  219. if ([self.contentValue isEqualToString:@"OFF"]) {
  220. msg = NSLocalizedString(@"꺼짐", @"꺼짐");
  221. } else if ([self.contentValue isEqualToString:@"LOW"]) {
  222. msg = NSLocalizedString(@"약", @"약");
  223. } else if ([self.contentValue isEqualToString:@"MEDIUM"]) {
  224. msg = NSLocalizedString(@"중", @"중");
  225. } else if ([self.contentValue isEqualToString:@"HIGH"]) {
  226. msg = NSLocalizedString(@"강", @"강");
  227. } else {
  228. msg = @"-";
  229. }
  230. break;
  231. }
  232. return msg;
  233. }
  234. - (NSString *)contentValueMsgOfAVPlayback {
  235. NSInteger typeId = [_cmdclsTypeId integerValue];
  236. NSString *msg = ksEmptyString;
  237. switch (typeId) {
  238. case 21001:
  239. if ([self.contentValue isEqualToString:@"PLAYING"]) {
  240. msg = NSLocalizedString(@"재생 중", @"재생 중");
  241. } else if ([self.contentValue isEqualToString:@"PAUSED"]) {
  242. msg = NSLocalizedString(@"정지 됨", @"정지 됨");
  243. } else {
  244. msg = @"-";
  245. }
  246. break;
  247. }
  248. return msg;
  249. }
  250. - (UIImage *)imageForHeatInSeason {
  251. NSString *month = [NSString stringWithFormat:@"%zd", [CommonUtil dateComponents:[NSDate systemDate]].month];
  252. NSArray *summer = @[@"6", @"7", @"8", @"9"];
  253. NSArray *winter = @[@"12", @"1", @"2"];
  254. BOOL isSummer = [summer indexOfObjectIdenticalTo:month];
  255. BOOL isWinter = [winter indexOfObjectIdenticalTo:month];
  256. NSInteger min = 20;
  257. min = isSummer ? 26 : min;
  258. min = isWinter ? 18 : min;
  259. NSInteger max = 22;
  260. max = isSummer ? 28 : max;
  261. max = isWinter ? 20 : max;
  262. UIImage *image = nil;
  263. NSInteger heat = [_contentValue integerValue];
  264. if (heat < min) {
  265. image = [UIImage imageNamed:@"img_things_detail_03_01_sensor_temperature_cool"];
  266. } else if (heat > max) {
  267. image = [UIImage imageNamed:@"img_things_detail_03_03_sensor_temperature_hot"];
  268. } else {
  269. image = [UIImage imageNamed:@"img_things_detail_03_02_sensor_temperature_nice"];
  270. }
  271. return image;
  272. }
  273. - (NSString *)conditionForHeatInSeason {
  274. NSString *month = [NSString stringWithFormat:@"%zd", [CommonUtil dateComponents:[NSDate systemDate]].month];
  275. NSArray *summer = @[@"6", @"7", @"8", @"9"];
  276. NSArray *winter = @[@"12", @"1", @"2"];
  277. BOOL isSummer = [summer indexOfObjectIdenticalTo:month];
  278. BOOL isWinter = [winter indexOfObjectIdenticalTo:month];
  279. NSInteger min = 20;
  280. min = isSummer ? 26 : min;
  281. min = isWinter ? 18 : min;
  282. NSInteger max = 22;
  283. max = isSummer ? 28 : max;
  284. max = isWinter ? 20 : max;
  285. NSString *condition = nil;
  286. NSInteger heat = [_contentValue integerValue];
  287. if (heat < min) {
  288. condition = @"추워요";
  289. } else if (heat > max) {
  290. condition = @"더워요";
  291. } else {
  292. condition = @"쾌적해요";
  293. }
  294. return condition;
  295. }
  296. - (UIImage *)imageForHumidityInSeason {
  297. NSString *month = [NSString stringWithFormat:@"%zd", [CommonUtil dateComponents:[NSDate systemDate]].month];
  298. NSArray *summer = @[@"6", @"7", @"8", @"9"];
  299. NSArray *winter = @[@"12", @"1", @"2"];
  300. BOOL isSummer = [summer indexOfObjectIdenticalTo:month];
  301. BOOL isWinter = [winter indexOfObjectIdenticalTo:month];
  302. NSInteger min = 50;
  303. min = isSummer ? 30 : min;
  304. min = isWinter ? 60 : min;
  305. NSInteger max = 60;
  306. max = isSummer ? 40 : max;
  307. max = isWinter ? 70 : max;
  308. UIImage *image = nil;
  309. NSInteger heat = [_contentValue integerValue];
  310. if (heat < min) {
  311. image = [UIImage imageNamed:@"img_things_detail_04_01_sensor_humidity_dry"];
  312. } else if (heat > max) {
  313. image = [UIImage imageNamed:@"img_things_detail_04_02_sensor_humidity_nice"];
  314. } else {
  315. image = [UIImage imageNamed:@"img_things_detail_04_03_sensor_humidity_moist"];
  316. }
  317. return image;
  318. }
  319. - (NSString *)conditionForHumidityInSeason {
  320. NSString *month = [NSString stringWithFormat:@"%zd", [CommonUtil dateComponents:[NSDate systemDate]].month];
  321. NSArray *summer = @[@"6", @"7", @"8", @"9"];
  322. NSArray *winter = @[@"12", @"1", @"2"];
  323. BOOL isSummer = [summer indexOfObjectIdenticalTo:month];
  324. BOOL isWinter = [winter indexOfObjectIdenticalTo:month];
  325. NSInteger min = 50;
  326. min = isSummer ? 30 : min;
  327. min = isWinter ? 60 : min;
  328. NSInteger max = 60;
  329. max = isSummer ? 40 : max;
  330. max = isWinter ? 70 : max;
  331. NSString *condition = nil;
  332. NSInteger heat = [_contentValue integerValue];
  333. if (heat < min) {
  334. condition = @"건조해요";
  335. } else if (heat > max) {
  336. condition = @"습해요";
  337. } else {
  338. condition = @"쾌적해요";
  339. }
  340. return condition;
  341. }
  342. - (UIImage *)imageForLuminance {
  343. UIImage *image = nil;
  344. NSInteger lux = [_contentValue integerValue];
  345. if (lux < 10) {
  346. image = [UIImage imageNamed:@"img_things_detail_07_01_bright_state_dark"];
  347. } else if (lux < 50) {
  348. image = [UIImage imageNamed:@"img_things_detail_07_02_bright_state_soft"];
  349. } else if (lux < 80){
  350. image = [UIImage imageNamed:@"img_things_detail_07_03_bright_state_nice"];
  351. } else if (lux <= 100) {
  352. image = [UIImage imageNamed:@"img_things_detail_07_04_bright_state_bright"];
  353. }
  354. return image;
  355. }
  356. - (NSString *)conditionForLuminance {
  357. NSString *condition = nil;
  358. NSInteger lux = [_contentValue integerValue];
  359. if (lux < 10) {
  360. condition = @"어두워요";
  361. } else if (lux < 50) {
  362. condition = @"은은해요";
  363. } else if (lux < 80){
  364. condition = @"쾌적해요";
  365. } else if (lux <= 100) {
  366. condition = @"밝아요";
  367. }
  368. return condition;
  369. }
  370. - (UIImage *)imageForMandataryForState:(UIControlState)state {
  371. NSInteger typeId = [_cmdclsTypeId integerValue];
  372. UIImage *image = nil;
  373. switch (typeId) {
  374. // case 11006://Heat
  375. // if (state == UIControlStateNormal || state == UIControlStateSelected) {//default
  376. // image = [self imageForHeatInSeason];
  377. // } else if (state == UIControlStateDisabled) {//offline
  378. // image = [UIImage imageNamed:@"img_things_detail_03_00_sensor_temperature_offline"];
  379. // }
  380. // break;
  381. case 11011://door
  382. if (state == UIControlStateNormal) {//default
  383. image = [UIImage imageNamed:@"img_things_detail_01_02_sensor_door_close"];
  384. } else if (state == UIControlStateSelected) {//selected
  385. image = [UIImage imageNamed:@"img_things_detail_01_02_sensor_door_open"];
  386. } else if (state == UIControlStateDisabled) {//offline
  387. image = [UIImage imageNamed:@"img_things_detail_01_02_sensor_door_close"];
  388. }
  389. break;
  390. case 11013://모션센서
  391. if (state == UIControlStateNormal) {//default
  392. image = [UIImage imageNamed:@"img_things_detail_08_01_motion_state_none"];
  393. } else if (state == UIControlStateSelected) {//selected
  394. image = [UIImage imageNamed:@"img_things_detail_08_02_motion_state_detect"];
  395. } else if (state == UIControlStateDisabled) {//offline
  396. image = [UIImage imageNamed:@"motionimg_things_detail_08_00_motion_state_offline"];
  397. }
  398. break;
  399. case 11017://shock
  400. if (state == UIControlStateNormal) {//default
  401. image = [UIImage imageNamed:@"img_things_detail_02_01_sensor_shock_normal"];
  402. } else if (state == UIControlStateSelected) {//selected
  403. image = [UIImage imageNamed:@"img_things_detail_02_02_sensor_shock_sensing"];
  404. } else if (state == UIControlStateDisabled) {//offline
  405. image = [UIImage imageNamed:@"img_things_detail_02_00_sensor_shock_offline"];
  406. }
  407. case 12002://온도
  408. if (state == UIControlStateNormal || state == UIControlStateSelected) {//default
  409. image = [self imageForHeatInSeason];
  410. } else if (state == UIControlStateDisabled) {//offline
  411. image = [UIImage imageNamed:@"img_things_detail_03_00_sensor_temperature_offline"];
  412. }
  413. break;
  414. case 12004://밝기
  415. if (state == UIControlStateNormal || state == UIControlStateSelected) {//default
  416. image = [self imageForLuminance];
  417. } else if (state == UIControlStateDisabled) {//offline
  418. image = [UIImage imageNamed:@"img_things_detail_07_00_bright_state_offline"];
  419. }
  420. break;
  421. case 12006://습도
  422. if (state == UIControlStateNormal || state == UIControlStateSelected) {//default
  423. image = [self imageForHumidityInSeason];
  424. } else if (state == UIControlStateDisabled) {//offline
  425. image = [UIImage imageNamed:@"img_things_detail_04_00_sensor_humidity_offline"];
  426. }
  427. break;
  428. }
  429. return image;
  430. }
  431. - (NSString *)conditionForMandatary {
  432. NSInteger typeId = [_cmdclsTypeId integerValue];
  433. NSString *condition = nil;
  434. switch (typeId) {
  435. case 12002://온도
  436. condition = [self conditionForHeatInSeason];
  437. break;
  438. case 12004://밝기
  439. condition = [self conditionForLuminance];
  440. break;
  441. case 12006://습도
  442. condition = [self conditionForHumidityInSeason];
  443. break;
  444. }
  445. return condition;
  446. }
  447. - (UIImage *)backgroundImageForMandatary:(NSString *)value {
  448. NSInteger typeId = [_cmdclsTypeId integerValue];
  449. UIImage *bgImage = nil;
  450. if (!value || [value isEmptyString] || [value isEqualToString:@"none"]) {
  451. bgImage = [UIImage imageNamed:@"img_thing_icon_bg_default"];
  452. return bgImage;
  453. }
  454. switch (typeId) {
  455. case 11006:
  456. case 11011:
  457. case 11013:
  458. case 11017://sensor-binary
  459. if ([value isEqualToString:@"TRUE"]) {
  460. bgImage = [UIImage imageNamed:@"img_thing_icon_bg_active"];
  461. } else if ([value isEqualToString:@"FALSE"]) {
  462. bgImage = [UIImage imageNamed:@"img_thing_icon_bg_default"];
  463. }
  464. break;
  465. case 12002:
  466. case 12006:
  467. case 12004://sensor-multilevel
  468. bgImage = [UIImage imageNamed:@"img_thing_icon_bg_active"];
  469. break;
  470. case 36002://valve
  471. if ([value isEqualToString:@"OPEN"]) {
  472. bgImage = [UIImage imageNamed:@"img_thing_icon_bg_active"];
  473. } else if ([value isEqualToString:@"CLOSE"]) {
  474. bgImage = [UIImage imageNamed:@"img_thing_icon_bg_default"];
  475. }
  476. break;
  477. case 17002://switch
  478. if ([value isEqualToString:@"ON"]) {
  479. bgImage = [UIImage imageNamed:@"img_thing_icon_bg_active"];
  480. } else if ([value isEqualToString:@"OFF"]) {
  481. bgImage = [UIImage imageNamed:@"img_thing_icon_bg_default"];
  482. }
  483. break;
  484. }
  485. return bgImage;
  486. }
  487. - (UIImage *)imgaeForAddDel
  488. {
  489. NSInteger typeId = [_cmdclsTypeId integerValue];
  490. UIImage *image = [UIImage imageNamed:@"img_thing_icon_bg_default"];
  491. switch (typeId) {
  492. case 11011://door
  493. image = [UIImage imageNamed:@"img_things_product_addimg_02_mutisensor_door"];
  494. break;
  495. case 11013://멀티센서
  496. image = [UIImage imageNamed:@"img_things_product_addimg_02_mutisensor_door"];
  497. break;
  498. case 11017://shock
  499. image = [UIImage imageNamed:@"img_things_detail_02_01_sensor_shock_normal"];
  500. case 12002://온도
  501. image = [UIImage imageNamed:@"img_things_detail_03_00_sensor_temperature_offline"];
  502. break;
  503. case 12004://밝기
  504. image = [UIImage imageNamed:@"img_things_detail_07_00_bright_state_offline"];
  505. break;
  506. case 12006://습도
  507. image = [UIImage imageNamed:@"img_things_detail_04_00_sensor_humidity_offline"];
  508. break;
  509. case 17002://Smart Plug
  510. image = [UIImage imageNamed:@"img_things_product_addimg_03_smartplug"];
  511. break;
  512. case 36002://valve
  513. image = [UIImage imageNamed:@"img_things_product_addimg_01_smartgasvalve"];
  514. break;
  515. }
  516. return image;
  517. }
  518. - (NSString *)manufacturerName
  519. {
  520. NSInteger typeId = [_cmdclsTypeId integerValue];
  521. NSString *result = @"";
  522. switch (typeId) {
  523. case 11011://door
  524. result = @"도어센서";
  525. break;
  526. case 11013://멀티센서
  527. result = @"멀티센서";
  528. break;
  529. case 11017://shock
  530. result = @"VisionSecurity";
  531. case 12002://온도
  532. result = @"VisionSecurity";
  533. break;
  534. case 12004://밝기
  535. result = @"VisionSecurity";
  536. break;
  537. case 12006://습도
  538. result = @"VisionSecurity";
  539. break;
  540. case 17002://Smart Plug
  541. result = @"VisionSecurity";
  542. break;
  543. case 36002://valve
  544. result = @"타임밸브";
  545. break;
  546. }
  547. return result;
  548. }
  549. - (NSString *)getAddDelDescription
  550. {
  551. NSInteger typeId = [_cmdclsTypeId integerValue];
  552. NSString *result = @"";
  553. switch (typeId) {
  554. case 11011://door
  555. result = @"센서 아래 버튼을 1회 누른 후 LED가 깜빡임을 멈추면 1회 더 누르세요.";
  556. break;
  557. case 11013://멀티센서
  558. result = @"멀티센서";
  559. break;
  560. case 11017://shock
  561. result = @"VisionSecurity";
  562. case 12002://온도
  563. result = @"VisionSecurity";
  564. break;
  565. case 12004://밝기
  566. result = @"VisionSecurity";
  567. break;
  568. case 12006://습도
  569. result = @"VisionSecurity";
  570. break;
  571. case 17002://Smart Plug
  572. result = @"위에 버튼에 빨간 불이 깜빡일 때까지 5초 이상 누르세요.";
  573. break;
  574. case 36002://valve
  575. result = @"벨브를 열림 상태에 두고 \"위로\" 버튼을\n비프음이 날 때까지 5초 이상 누르세요.";
  576. break;
  577. }
  578. return result;
  579. }
  580. - (instancetype)initWithSubItem:(ItemSubModel *)subItem {//mobile devices.
  581. if (self = [super init]) {
  582. self.deviceId = subItem.sourceId;
  583. self.deviceName = subItem.sourceName;
  584. self.nodeId = subItem.sourceSubId;
  585. self.nodeName = subItem.sourceSubName;
  586. self.conditionTypeCode = subItem.conditionTypeCode;
  587. self.dataTypeCode = subItem.dataTypeCode;
  588. self.cmdclsValue = subItem.cmdclsValue;
  589. self.nickname = subItem.nickname;
  590. self.deleteYn = subItem.deleteYn;
  591. // objc_setAssociatedObject(self, @"CHECK_STATUS", @YES, OBJC_ASSOCIATION_COPY_NONATOMIC); //for checkbox
  592. [[JDFacade facade] setRadioButtonStatus:@YES object:self]; //for radio box
  593. }
  594. return self;
  595. }
  596. - (instancetype)initWithDeviceModel:(DeviceModel *)deviceModel deviceName:(NSString*)deviceName {//mobile devices.
  597. if (self = [super init]) {
  598. self.categoryName = deviceModel.categoryName;
  599. self.deviceMfId = deviceModel.deviceMfId;
  600. self.deviceConnLastDatetime = deviceModel.deviceConnLastDatetime;
  601. self.deviceOnline = deviceModel.deviceOnline;
  602. self.deviceModelId = deviceModel.deviceModelId;
  603. self.deviceConn = deviceModel.deviceConn;
  604. self.enable = deviceModel.enable;
  605. self.deviceName = deviceName;
  606. self.seq = deviceModel.seq;
  607. self.lastFirmwareVersion = deviceModel.lastFirmwareVersion;
  608. self.deviceSn = deviceModel.deviceSn;
  609. self.prdUserName = deviceName;
  610. self.deviceId = deviceModel.deviceId;
  611. self.prdName = deviceModel.prdName;
  612. self.remainCtrtCnt = deviceModel.remainCtrtCnt;
  613. self.firmwareVersion = deviceModel.firmwareVersion;
  614. self.conditionTypeCode = deviceModel.conditionTypeCode;
  615. self.softwareVersion = deviceModel.softwareVersion;
  616. self.totalCtrtCnt = deviceModel.totalCtrtCnt;
  617. self.deviceOnlineLastDatetime = deviceModel.deviceOnlineLastDatetime;
  618. // objc_setAssociatedObject(self, @"CHECK_STATUS", @YES, OBJC_ASSOCIATION_COPY_NONATOMIC); //for checkbox
  619. [[JDFacade facade] setRadioButtonStatus:@YES object:self]; //for radio box
  620. }
  621. return self;
  622. }
  623. + (NSString *)contentValueMsgByCmdClsCode:(NSString *)cmdclsCode cmdclsTypeId:(NSString *)cmdclsTypeId contentValue:(NSString *)contentValue {
  624. DeviceModel *tmpDevice = [[DeviceModel alloc] init];
  625. tmpDevice.cmdclsCode = cmdclsCode;
  626. tmpDevice.cmdclsTypeId = cmdclsTypeId;
  627. tmpDevice.contentValue = contentValue;
  628. return tmpDevice.contentValueMsg;
  629. }
  630. - (BOOL)isDeviceOnlined {
  631. return _deviceOnline && ![_deviceOnline isEmptyString] && [_deviceOnline isEqualToString:@"ON"];
  632. }
  633. - (BOOL)isDeviceConn {
  634. return _deviceConn && ![_deviceConn isEmptyString] && [_deviceConn isEqualToString:@"connect"];
  635. }
  636. -(BOOL)isUpdateNeed {
  637. BOOL result = NO;
  638. if (![[_lastSoftwareVersion uppercaseString] isEqualToString:[_softwareVersion uppercaseString]] ||
  639. ![[_lastFirmwareVersion uppercaseString] isEqualToString:[_firmwareVersion uppercaseString]]) {
  640. result = YES;
  641. }
  642. return result;
  643. }
  644. - (BOOL)isUpdateSoftware {
  645. //[_lastSoftwareVersion.trim isEquestToIgnoreCase:_softwareVersion.trim]
  646. if (![[_lastSoftwareVersion uppercaseString] isEqualToString:[_softwareVersion uppercaseString]]) {
  647. return YES;
  648. }
  649. return NO;
  650. }
  651. - (BOOL)isUpdateFirmware {
  652. if (![[_lastFirmwareVersion uppercaseString] isEqualToString:[_firmwareVersion uppercaseString]]) {
  653. return YES;
  654. }
  655. return NO;
  656. }
  657. @end
  658. @implementation DeviceListModel
  659. @end
  660. @implementation NodeListModel
  661. -(BOOL)isCanReOrder
  662. {
  663. BOOL result = NO;
  664. if (_nodes.count > 1) {
  665. result = YES;
  666. }
  667. return result;
  668. }
  669. -(BOOL)isCanAddNode
  670. {
  671. BOOL result = NO;
  672. if ([_ctrtCnt integerValue] > _nodes.count) {
  673. result = YES;
  674. }
  675. return result;
  676. }
  677. -(BOOL)isCanDelNode
  678. {
  679. BOOL result = NO;
  680. if (_nodes.count > 0) {
  681. result = YES;
  682. }
  683. return result;
  684. }
  685. @end
  686. @implementation NodeModel
  687. //- (CmdClsType)cmdclsType {
  688. // return [DeviceModel cmdclsTypeForCode:_cmdclsCode];
  689. //}
  690. - (BOOL)isDeviceOnline {
  691. return _refDevice.isOnline;
  692. }
  693. @end
  694. @implementation DeviceDetailModel
  695. -(BOOL)isProfileUpdate
  696. {
  697. BOOL result = NO;
  698. if ([_profileUpdateYn isEquestToIgnoreCase:@"Y"]) {
  699. result = YES;
  700. }
  701. return result;
  702. }
  703. @end
  704. @implementation PredefinedDeviceModel
  705. //+ (JSONKeyMapper *)keyMapper {
  706. //
  707. // NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
  708. //
  709. // //self
  710. // [dictionary setValue:@"cmdclsTypeSystemName" forKey:@"cmdcls_type_system_name"];
  711. // [dictionary setValue:@"cmdclsTypeId" forKey:@"cmdcls_type_id"];
  712. // [dictionary setValue:@"cmdclsCode" forKey:@"cmdcls_code"];
  713. // [dictionary setValue:@"deviceProfileId" forKey:@"device_profile_id"];
  714. // [dictionary setValue:@"createDatetime" forKey:@"create_datetime"];
  715. // [dictionary setValue:@"cmdclsTypeName" forKey:@"cmdcls_type_name"];
  716. // [dictionary setValue:@"deviceName" forKey:@"device_name"];
  717. // [dictionary setValue:@"profileName" forKey:@"profile_name"];
  718. // [dictionary setValue:@"imageFileName" forKey:@"image_file_name"];
  719. // [dictionary setValue:@"contentValue" forKey:@"content_value"];
  720. // [dictionary setValue:@"nodeName" forKey:@"node_name"];
  721. // [dictionary setValue:@"cmdclsCount" forKey:@"cmdcls_count"];
  722. // [dictionary setValue:@"nodeId" forKey:@"node_id"];
  723. // [dictionary setValue:@"deviceId" forKey:@"device_id"];
  724. // [dictionary setValue:@"cmdclsValue" forKey:@"cmdcls_value"];
  725. // [dictionary setValue:@"conditionTypeCode" forKey:@"condition_type_code"];
  726. // [dictionary setValue:@"dataTypeCode" forKey:@"data_type_code"];
  727. //
  728. // return [[JSONKeyMapper alloc] initWithDictionary:dictionary];
  729. //}
  730. - (instancetype)initWithSubItem:(ItemSubModel *)subItem {
  731. if (self = [super init]) {
  732. self.deviceId = subItem.sourceId;
  733. self.deviceName = subItem.sourceName;
  734. self.nodeId = subItem.sourceSubId;
  735. self.nodeName = subItem.sourceSubName;
  736. self.conditionTypeCode = subItem.conditionTypeCode;
  737. self.dataTypeCode = subItem.dataTypeCode;
  738. self.cmdclsValue = subItem.cmdclsValue;
  739. self.predCmdclsValue = subItem.predCmdclsValue;
  740. self.deleteYn = subItem.deleteYn;
  741. [[JDFacade facade] setCheckBoxStatus:@YES object:self]; //for check box
  742. [[JDFacade facade] setRadioButtonStatus:@YES object:self]; //for radio box
  743. }
  744. return self;
  745. }
  746. @end
  747. @implementation PredefinedDeviceListModel
  748. @end
  749. @implementation DeviceIconModel
  750. @end
  751. @implementation DeviceIconListModel
  752. @end