DeviceModel.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  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. if ([self.contentValue isEqualToString:@"OPEN"]) {
  164. msg = NSLocalizedString(@"열림", @"열림");
  165. } else if ([self.contentValue isEqualToString:@"CLOSE"]) {
  166. msg = NSLocalizedString(@"잠김", @"잠김");
  167. } else {
  168. msg = @"-";
  169. }
  170. break;
  171. }
  172. return msg;
  173. }
  174. - (NSString *)contentValueMsg {
  175. switch ([self cmdclsType]) {
  176. case CmdClsTypeSensorBinary:
  177. _contentValueMsg = [self contentValueMsgOfSensorBinary];
  178. break;
  179. case CmdClsTypeThermostatMode:
  180. _contentValueMsg = [self contentValueMsgOfThermostatMode];
  181. break;
  182. case CmdClsTypeLock:
  183. _contentValueMsg = [self contentValueMsgOfLock];
  184. break;
  185. case CmdClsTypeSwitchBinary:
  186. _contentValueMsg = [self contentValueMsgOfSwitchBinary];
  187. break;
  188. case CmdClsTypeSpeedControl:
  189. _contentValueMsg = [self contentValueMsgOfSpeedControl];
  190. break;
  191. case CmdClsTypeAVControlPlayback:
  192. _contentValueMsg = [self contentValueMsgOfAVPlayback];
  193. break;
  194. case CmdClsTypeValve:
  195. _contentValueMsg = [self contentValueMsgOfValve];
  196. break;
  197. default:
  198. _contentValueMsg = !_contentValue || [_contentValue isEmptyString] || [_contentValue isEqualToString:@"none"] ? @"-" : [NSString stringWithFormat:@"%@%@", _contentValue, _unit];
  199. break;
  200. }
  201. return _contentValueMsg;
  202. }
  203. - (NSString *)contentValueMsgOfSpeedControl {
  204. NSInteger typeId = [_cmdclsTypeId integerValue];
  205. NSString *msg = ksEmptyString;
  206. switch (typeId) {
  207. case 20001:
  208. if ([self.contentValue isEqualToString:@"OFF"]) {
  209. msg = NSLocalizedString(@"꺼짐", @"꺼짐");
  210. } else if ([self.contentValue isEqualToString:@"LOW"]) {
  211. msg = NSLocalizedString(@"약", @"약");
  212. } else if ([self.contentValue isEqualToString:@"MEDIUM"]) {
  213. msg = NSLocalizedString(@"중", @"중");
  214. } else if ([self.contentValue isEqualToString:@"HIGH"]) {
  215. msg = NSLocalizedString(@"강", @"강");
  216. } else {
  217. msg = @"-";
  218. }
  219. break;
  220. }
  221. return msg;
  222. }
  223. - (NSString *)contentValueMsgOfAVPlayback {
  224. NSInteger typeId = [_cmdclsTypeId integerValue];
  225. NSString *msg = ksEmptyString;
  226. switch (typeId) {
  227. case 21001:
  228. if ([self.contentValue isEqualToString:@"PLAYING"]) {
  229. msg = NSLocalizedString(@"재생 중", @"재생 중");
  230. } else if ([self.contentValue isEqualToString:@"PAUSED"]) {
  231. msg = NSLocalizedString(@"정지 됨", @"정지 됨");
  232. } else {
  233. msg = @"-";
  234. }
  235. break;
  236. }
  237. return msg;
  238. }
  239. - (UIImage *)imageForHeatInSeason {
  240. NSString *month = [NSString stringWithFormat:@"%zd", [CommonUtil dateComponents:[NSDate systemDate]].month];
  241. NSArray *summer = @[@"6", @"7", @"8", @"9"];
  242. NSArray *winter = @[@"12", @"1", @"2"];
  243. BOOL isSummer = [summer indexOfObjectIdenticalTo:month];
  244. BOOL isWinter = [winter indexOfObjectIdenticalTo:month];
  245. NSInteger min = 20;
  246. min = isSummer ? 26 : min;
  247. min = isWinter ? 18 : min;
  248. NSInteger max = 22;
  249. max = isSummer ? 28 : max;
  250. max = isWinter ? 20 : max;
  251. UIImage *image = nil;
  252. NSInteger heat = [_contentValue integerValue];
  253. if (heat < min) {
  254. image = [UIImage imageNamed:@"img_things_detail_03_01_sensor_temperature_cool"];
  255. } else if (heat > max) {
  256. image = [UIImage imageNamed:@"img_things_detail_03_03_sensor_temperature_hot"];
  257. } else {
  258. image = [UIImage imageNamed:@"img_things_detail_03_02_sensor_temperature_nice"];
  259. }
  260. return image;
  261. }
  262. - (NSString *)conditionForHeatInSeason {
  263. NSString *month = [NSString stringWithFormat:@"%zd", [CommonUtil dateComponents:[NSDate systemDate]].month];
  264. NSArray *summer = @[@"6", @"7", @"8", @"9"];
  265. NSArray *winter = @[@"12", @"1", @"2"];
  266. BOOL isSummer = [summer indexOfObjectIdenticalTo:month];
  267. BOOL isWinter = [winter indexOfObjectIdenticalTo:month];
  268. NSInteger min = 20;
  269. min = isSummer ? 26 : min;
  270. min = isWinter ? 18 : min;
  271. NSInteger max = 22;
  272. max = isSummer ? 28 : max;
  273. max = isWinter ? 20 : max;
  274. NSString *condition = nil;
  275. NSInteger heat = [_contentValue integerValue];
  276. if (heat < min) {
  277. condition = @"추워요";
  278. } else if (heat > max) {
  279. condition = @"더워요";
  280. } else {
  281. condition = @"쾌적해요";
  282. }
  283. return condition;
  284. }
  285. - (UIImage *)imageForHumidityInSeason {
  286. NSString *month = [NSString stringWithFormat:@"%zd", [CommonUtil dateComponents:[NSDate systemDate]].month];
  287. NSArray *summer = @[@"6", @"7", @"8", @"9"];
  288. NSArray *winter = @[@"12", @"1", @"2"];
  289. BOOL isSummer = [summer indexOfObjectIdenticalTo:month];
  290. BOOL isWinter = [winter indexOfObjectIdenticalTo:month];
  291. NSInteger min = 50;
  292. min = isSummer ? 30 : min;
  293. min = isWinter ? 60 : min;
  294. NSInteger max = 60;
  295. max = isSummer ? 40 : max;
  296. max = isWinter ? 70 : max;
  297. UIImage *image = nil;
  298. NSInteger heat = [_contentValue integerValue];
  299. if (heat < min) {
  300. image = [UIImage imageNamed:@"img_things_detail_04_01_sensor_humidity_dry"];
  301. } else if (heat > max) {
  302. image = [UIImage imageNamed:@"img_things_detail_04_02_sensor_humidity_nice"];
  303. } else {
  304. image = [UIImage imageNamed:@"img_things_detail_04_03_sensor_humidity_moist"];
  305. }
  306. return image;
  307. }
  308. - (NSString *)conditionForHumidityInSeason {
  309. NSString *month = [NSString stringWithFormat:@"%zd", [CommonUtil dateComponents:[NSDate systemDate]].month];
  310. NSArray *summer = @[@"6", @"7", @"8", @"9"];
  311. NSArray *winter = @[@"12", @"1", @"2"];
  312. BOOL isSummer = [summer indexOfObjectIdenticalTo:month];
  313. BOOL isWinter = [winter indexOfObjectIdenticalTo:month];
  314. NSInteger min = 50;
  315. min = isSummer ? 30 : min;
  316. min = isWinter ? 60 : min;
  317. NSInteger max = 60;
  318. max = isSummer ? 40 : max;
  319. max = isWinter ? 70 : max;
  320. NSString *condition = nil;
  321. NSInteger heat = [_contentValue integerValue];
  322. if (heat < min) {
  323. condition = @"건조해요";
  324. } else if (heat > max) {
  325. condition = @"습해요";
  326. } else {
  327. condition = @"쾌적해요";
  328. }
  329. return condition;
  330. }
  331. - (UIImage *)imageForLuminance {
  332. UIImage *image = nil;
  333. NSInteger lux = [_contentValue integerValue];
  334. if (lux < 10) {
  335. image = [UIImage imageNamed:@"img_things_detail_07_01_bright_state_dark"];
  336. } else if (lux < 50) {
  337. image = [UIImage imageNamed:@"img_things_detail_07_02_bright_state_soft"];
  338. } else if (lux < 80){
  339. image = [UIImage imageNamed:@"img_things_detail_07_03_bright_state_nice"];
  340. } else if (lux <= 100) {
  341. image = [UIImage imageNamed:@"img_things_detail_07_04_bright_state_bright"];
  342. }
  343. return image;
  344. }
  345. - (NSString *)conditionForLuminance {
  346. NSString *condition = nil;
  347. NSInteger lux = [_contentValue integerValue];
  348. if (lux < 10) {
  349. condition = @"어두워요";
  350. } else if (lux < 50) {
  351. condition = @"은은해요";
  352. } else if (lux < 80){
  353. condition = @"쾌적해요";
  354. } else if (lux <= 100) {
  355. condition = @"밝아요";
  356. }
  357. return condition;
  358. }
  359. - (UIImage *)imageForMandataryForState:(UIControlState)state {
  360. NSInteger typeId = [_cmdclsTypeId integerValue];
  361. UIImage *image = nil;
  362. switch (typeId) {
  363. // case 11006://Heat
  364. // if (state == UIControlStateNormal || state == UIControlStateSelected) {//default
  365. // image = [self imageForHeatInSeason];
  366. // } else if (state == UIControlStateDisabled) {//offline
  367. // image = [UIImage imageNamed:@"img_things_detail_03_00_sensor_temperature_offline"];
  368. // }
  369. // break;
  370. case 11011://door
  371. if (state == UIControlStateNormal) {//default
  372. image = [UIImage imageNamed:@"img_things_detail_01_01_sensor_door_close"];
  373. } else if (state == UIControlStateSelected) {//selected
  374. image = [UIImage imageNamed:@"img_things_detail_01_02_sensor_door_open"];
  375. } else if (state == UIControlStateDisabled) {//offline
  376. image = [UIImage imageNamed:@"img_things_detail_01_00_sensor_door_offline"];
  377. }
  378. break;
  379. case 11013://모션센서
  380. if (state == UIControlStateNormal) {//default
  381. image = [UIImage imageNamed:@"img_things_detail_08_01_motion_state_none"];
  382. } else if (state == UIControlStateSelected) {//selected
  383. image = [UIImage imageNamed:@"img_things_detail_08_02_motion_state_detect"];
  384. } else if (state == UIControlStateDisabled) {//offline
  385. image = [UIImage imageNamed:@"motionimg_things_detail_08_00_motion_state_offline"];
  386. }
  387. break;
  388. case 11017://shock
  389. if (state == UIControlStateNormal) {//default
  390. image = [UIImage imageNamed:@"img_things_detail_02_01_sensor_shock_normal"];
  391. } else if (state == UIControlStateSelected) {//selected
  392. image = [UIImage imageNamed:@"img_things_detail_02_02_sensor_shock_sensing"];
  393. } else if (state == UIControlStateDisabled) {//offline
  394. image = [UIImage imageNamed:@"img_things_detail_02_00_sensor_shock_offline"];
  395. }
  396. case 12002://온도
  397. if (state == UIControlStateNormal || state == UIControlStateSelected) {//default
  398. image = [self imageForHeatInSeason];
  399. } else if (state == UIControlStateDisabled) {//offline
  400. image = [UIImage imageNamed:@"img_things_detail_03_00_sensor_temperature_offline"];
  401. }
  402. break;
  403. case 12004://밝기
  404. if (state == UIControlStateNormal || state == UIControlStateSelected) {//default
  405. image = [self imageForLuminance];
  406. } else if (state == UIControlStateDisabled) {//offline
  407. image = [UIImage imageNamed:@"img_things_detail_07_00_bright_state_offline"];
  408. }
  409. break;
  410. case 12006://습도
  411. if (state == UIControlStateNormal || state == UIControlStateSelected) {//default
  412. image = [self imageForHumidityInSeason];
  413. } else if (state == UIControlStateDisabled) {//offline
  414. image = [UIImage imageNamed:@"img_things_detail_04_00_sensor_humidity_offline"];
  415. }
  416. break;
  417. }
  418. return image;
  419. }
  420. - (NSString *)conditionForMandatary {
  421. NSInteger typeId = [_cmdclsTypeId integerValue];
  422. NSString *condition = nil;
  423. switch (typeId) {
  424. case 12002://온도
  425. condition = [self conditionForHeatInSeason];
  426. break;
  427. case 12004://밝기
  428. condition = [self conditionForLuminance];
  429. break;
  430. case 12006://습도
  431. condition = [self conditionForHumidityInSeason];
  432. break;
  433. }
  434. return condition;
  435. }
  436. - (UIImage *)backgroundImageForMandatary:(NSString *)value {
  437. NSInteger typeId = [_cmdclsTypeId integerValue];
  438. UIImage *bgImage = nil;
  439. if (!value || [value isEmptyString] || [value isEqualToString:@"none"]) {
  440. bgImage = [UIImage imageNamed:@"img_thing_icon_bg_default"];
  441. return bgImage;
  442. }
  443. switch (typeId) {
  444. case 11006:
  445. case 11011:
  446. case 11013:
  447. case 11017://sensor-binary
  448. if ([value isEqualToString:@"TRUE"]) {
  449. bgImage = [UIImage imageNamed:@"img_thing_icon_bg_active"];
  450. } else if ([value isEqualToString:@"FALSE"]) {
  451. bgImage = [UIImage imageNamed:@"img_thing_icon_bg_default"];
  452. }
  453. break;
  454. case 12002:
  455. case 12006:
  456. case 12004://sensor-multilevel
  457. bgImage = [UIImage imageNamed:@"img_thing_icon_bg_active"];
  458. break;
  459. case 36002://valve
  460. if ([value isEqualToString:@"OPEN"]) {
  461. bgImage = [UIImage imageNamed:@"img_thing_icon_bg_active"];
  462. } else if ([value isEqualToString:@"CLOSE"]) {
  463. bgImage = [UIImage imageNamed:@"img_thing_icon_bg_default"];
  464. }
  465. break;
  466. case 17002://switch
  467. if ([value isEqualToString:@"ON"]) {
  468. bgImage = [UIImage imageNamed:@"img_thing_icon_bg_active"];
  469. } else if ([value isEqualToString:@"OFF"]) {
  470. bgImage = [UIImage imageNamed:@"img_thing_icon_bg_default"];
  471. }
  472. break;
  473. }
  474. return bgImage;
  475. }
  476. - (instancetype)initWithSubItem:(ItemSubModel *)subItem {//mobile devices.
  477. if (self = [super init]) {
  478. self.deviceId = subItem.sourceId;
  479. self.deviceName = subItem.sourceName;
  480. self.nodeId = subItem.sourceSubId;
  481. self.nodeName = subItem.sourceSubName;
  482. self.conditionTypeCode = subItem.conditionTypeCode;
  483. self.dataTypeCode = subItem.dataTypeCode;
  484. self.cmdclsValue = subItem.cmdclsValue;
  485. self.nickname = subItem.nickname;
  486. self.deleteYn = subItem.deleteYn;
  487. // objc_setAssociatedObject(self, @"CHECK_STATUS", @YES, OBJC_ASSOCIATION_COPY_NONATOMIC); //for checkbox
  488. [[JDFacade facade] setRadioButtonStatus:@YES object:self]; //for radio box
  489. }
  490. return self;
  491. }
  492. + (NSString *)contentValueMsgByCmdClsCode:(NSString *)cmdclsCode cmdclsTypeId:(NSString *)cmdclsTypeId contentValue:(NSString *)contentValue {
  493. DeviceModel *tmpDevice = [[DeviceModel alloc] init];
  494. tmpDevice.cmdclsCode = cmdclsCode;
  495. tmpDevice.cmdclsTypeId = cmdclsTypeId;
  496. tmpDevice.contentValue = contentValue;
  497. return tmpDevice.contentValueMsg;
  498. }
  499. - (BOOL)isDeviceOnline {
  500. return _deviceOnline && ![_deviceOnline isEmptyString] && [_deviceOnline isEqualToString:@"ON"];
  501. }
  502. - (BOOL)isDeviceConn {
  503. return _deviceConn && ![_deviceConn isEmptyString] && [_deviceConn isEqualToString:@"ON"];
  504. }
  505. @end
  506. @implementation DeviceListModel
  507. @end
  508. @implementation NodeModel
  509. //- (CmdClsType)cmdclsType {
  510. // return [DeviceModel cmdclsTypeForCode:_cmdclsCode];
  511. //}
  512. - (BOOL)isDeviceOnline {
  513. return _refDevice.isOnline;
  514. }
  515. @end
  516. @implementation DeviceDetailModel
  517. @end
  518. @implementation PredefinedDeviceModel
  519. //+ (JSONKeyMapper *)keyMapper {
  520. //
  521. // NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
  522. //
  523. // //self
  524. // [dictionary setValue:@"cmdclsTypeSystemName" forKey:@"cmdcls_type_system_name"];
  525. // [dictionary setValue:@"cmdclsTypeId" forKey:@"cmdcls_type_id"];
  526. // [dictionary setValue:@"cmdclsCode" forKey:@"cmdcls_code"];
  527. // [dictionary setValue:@"deviceProfileId" forKey:@"device_profile_id"];
  528. // [dictionary setValue:@"createDatetime" forKey:@"create_datetime"];
  529. // [dictionary setValue:@"cmdclsTypeName" forKey:@"cmdcls_type_name"];
  530. // [dictionary setValue:@"deviceName" forKey:@"device_name"];
  531. // [dictionary setValue:@"profileName" forKey:@"profile_name"];
  532. // [dictionary setValue:@"imageFileName" forKey:@"image_file_name"];
  533. // [dictionary setValue:@"contentValue" forKey:@"content_value"];
  534. // [dictionary setValue:@"nodeName" forKey:@"node_name"];
  535. // [dictionary setValue:@"cmdclsCount" forKey:@"cmdcls_count"];
  536. // [dictionary setValue:@"nodeId" forKey:@"node_id"];
  537. // [dictionary setValue:@"deviceId" forKey:@"device_id"];
  538. // [dictionary setValue:@"cmdclsValue" forKey:@"cmdcls_value"];
  539. // [dictionary setValue:@"conditionTypeCode" forKey:@"condition_type_code"];
  540. // [dictionary setValue:@"dataTypeCode" forKey:@"data_type_code"];
  541. //
  542. // return [[JSONKeyMapper alloc] initWithDictionary:dictionary];
  543. //}
  544. - (instancetype)initWithSubItem:(ItemSubModel *)subItem {
  545. if (self = [super init]) {
  546. self.deviceId = subItem.sourceId;
  547. self.deviceName = subItem.sourceName;
  548. self.nodeId = subItem.sourceSubId;
  549. self.nodeName = subItem.sourceSubName;
  550. self.conditionTypeCode = subItem.conditionTypeCode;
  551. self.dataTypeCode = subItem.dataTypeCode;
  552. self.cmdclsValue = subItem.cmdclsValue;
  553. self.predCmdclsValue = subItem.predCmdclsValue;
  554. self.deleteYn = subItem.deleteYn;
  555. [[JDFacade facade] setCheckBoxStatus:@YES object:self]; //for check box
  556. [[JDFacade facade] setRadioButtonStatus:@YES object:self]; //for radio box
  557. }
  558. return self;
  559. }
  560. @end
  561. @implementation PredefinedDeviceListModel
  562. @end
  563. @implementation DeviceIconModel
  564. @end
  565. @implementation DeviceIconListModel
  566. @end