DeviceModel.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  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. - (instancetype)initWithSubItem:(ItemSubModel *)subItem {//mobile devices.
  478. if (self = [super init]) {
  479. self.deviceId = subItem.sourceId;
  480. self.deviceName = subItem.sourceName;
  481. self.nodeId = subItem.sourceSubId;
  482. self.nodeName = subItem.sourceSubName;
  483. self.conditionTypeCode = subItem.conditionTypeCode;
  484. self.dataTypeCode = subItem.dataTypeCode;
  485. self.cmdclsValue = subItem.cmdclsValue;
  486. self.nickname = subItem.nickname;
  487. self.deleteYn = subItem.deleteYn;
  488. // objc_setAssociatedObject(self, @"CHECK_STATUS", @YES, OBJC_ASSOCIATION_COPY_NONATOMIC); //for checkbox
  489. [[JDFacade facade] setRadioButtonStatus:@YES object:self]; //for radio box
  490. }
  491. return self;
  492. }
  493. + (NSString *)contentValueMsgByCmdClsCode:(NSString *)cmdclsCode cmdclsTypeId:(NSString *)cmdclsTypeId contentValue:(NSString *)contentValue {
  494. DeviceModel *tmpDevice = [[DeviceModel alloc] init];
  495. tmpDevice.cmdclsCode = cmdclsCode;
  496. tmpDevice.cmdclsTypeId = cmdclsTypeId;
  497. tmpDevice.contentValue = contentValue;
  498. return tmpDevice.contentValueMsg;
  499. }
  500. - (BOOL)isDeviceOnlined {
  501. return _deviceOnline && ![_deviceOnline isEmptyString] && [_deviceOnline isEqualToString:@"ON"];
  502. }
  503. - (BOOL)isDeviceConn {
  504. return _deviceConn && ![_deviceConn isEmptyString] && [_deviceConn isEqualToString:@"connect"];
  505. }
  506. @end
  507. @implementation DeviceListModel
  508. @end
  509. @implementation NodeListModel
  510. -(BOOL)isCanReOrder
  511. {
  512. BOOL result = NO;
  513. NSLog(@"Node Count : %i", _nodes.count);
  514. if (_nodes.count > 1) {
  515. result = YES;
  516. }
  517. return result;
  518. }
  519. -(BOOL)isCanAddNode
  520. {
  521. BOOL result = NO;
  522. if ([_ctrtCnt integerValue] > _nodes.count) {
  523. result = YES;
  524. }
  525. return result;
  526. }
  527. -(BOOL)isCanDelNode
  528. {
  529. BOOL result = NO;
  530. if (_nodes.count > 0) {
  531. result = YES;
  532. }
  533. return result;
  534. }
  535. @end
  536. @implementation NodeModel
  537. //- (CmdClsType)cmdclsType {
  538. // return [DeviceModel cmdclsTypeForCode:_cmdclsCode];
  539. //}
  540. - (BOOL)isDeviceOnline {
  541. return _refDevice.isOnline;
  542. }
  543. @end
  544. @implementation DeviceDetailModel
  545. @end
  546. @implementation PredefinedDeviceModel
  547. //+ (JSONKeyMapper *)keyMapper {
  548. //
  549. // NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
  550. //
  551. // //self
  552. // [dictionary setValue:@"cmdclsTypeSystemName" forKey:@"cmdcls_type_system_name"];
  553. // [dictionary setValue:@"cmdclsTypeId" forKey:@"cmdcls_type_id"];
  554. // [dictionary setValue:@"cmdclsCode" forKey:@"cmdcls_code"];
  555. // [dictionary setValue:@"deviceProfileId" forKey:@"device_profile_id"];
  556. // [dictionary setValue:@"createDatetime" forKey:@"create_datetime"];
  557. // [dictionary setValue:@"cmdclsTypeName" forKey:@"cmdcls_type_name"];
  558. // [dictionary setValue:@"deviceName" forKey:@"device_name"];
  559. // [dictionary setValue:@"profileName" forKey:@"profile_name"];
  560. // [dictionary setValue:@"imageFileName" forKey:@"image_file_name"];
  561. // [dictionary setValue:@"contentValue" forKey:@"content_value"];
  562. // [dictionary setValue:@"nodeName" forKey:@"node_name"];
  563. // [dictionary setValue:@"cmdclsCount" forKey:@"cmdcls_count"];
  564. // [dictionary setValue:@"nodeId" forKey:@"node_id"];
  565. // [dictionary setValue:@"deviceId" forKey:@"device_id"];
  566. // [dictionary setValue:@"cmdclsValue" forKey:@"cmdcls_value"];
  567. // [dictionary setValue:@"conditionTypeCode" forKey:@"condition_type_code"];
  568. // [dictionary setValue:@"dataTypeCode" forKey:@"data_type_code"];
  569. //
  570. // return [[JSONKeyMapper alloc] initWithDictionary:dictionary];
  571. //}
  572. - (instancetype)initWithSubItem:(ItemSubModel *)subItem {
  573. if (self = [super init]) {
  574. self.deviceId = subItem.sourceId;
  575. self.deviceName = subItem.sourceName;
  576. self.nodeId = subItem.sourceSubId;
  577. self.nodeName = subItem.sourceSubName;
  578. self.conditionTypeCode = subItem.conditionTypeCode;
  579. self.dataTypeCode = subItem.dataTypeCode;
  580. self.cmdclsValue = subItem.cmdclsValue;
  581. self.predCmdclsValue = subItem.predCmdclsValue;
  582. self.deleteYn = subItem.deleteYn;
  583. [[JDFacade facade] setCheckBoxStatus:@YES object:self]; //for check box
  584. [[JDFacade facade] setRadioButtonStatus:@YES object:self]; //for radio box
  585. }
  586. return self;
  587. }
  588. @end
  589. @implementation PredefinedDeviceListModel
  590. @end
  591. @implementation DeviceIconModel
  592. @end
  593. @implementation DeviceIconListModel
  594. @end