DeviceModel.m 26 KB

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