DeviceModel.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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. case 11015:
  65. case 11017:
  66. if ([self.contentValue isEqualToString:@"TRUE"]) {
  67. msg = NSLocalizedString(@"들어옴", @"들어옴");
  68. } else if ([self.contentValue isEqualToString:@"FALSE"]) {
  69. msg = NSLocalizedString(@"나감", @"나감");
  70. } else {
  71. msg = @"-";
  72. }
  73. break;
  74. }
  75. return msg;
  76. }
  77. - (NSString *)contentValueMsgOfThermostatMode {
  78. NSInteger typeId = [_cmdclsTypeId integerValue];
  79. NSString *msg = ksEmptyString;
  80. switch (typeId) {
  81. case 13001:
  82. case 13002:
  83. case 13003:
  84. case 13004:
  85. if ([self.contentValue isEqualToString:@"OFF"]) {
  86. msg = NSLocalizedString(@"꺼짐", @"꺼짐");
  87. } else if ([self.contentValue isEqualToString:@"COOL"]) {
  88. msg = NSLocalizedString(@"냉방", @"냉방");
  89. } else if ([self.contentValue isEqualToString:@"HEAT"]) {
  90. msg = NSLocalizedString(@"난방", @"난방");
  91. } else if ([self.contentValue isEqualToString:@"AUTO"]) {
  92. msg = NSLocalizedString(@"자동", @"자동");
  93. } else if ([self.contentValue isEqualToString:@"FAN_ONLY"]) {
  94. msg = NSLocalizedString(@"환기", @"환기");
  95. } else if ([self.contentValue isEqualToString:@"DRY_AIR"]) {
  96. msg = NSLocalizedString(@"제습", @"제습");
  97. } else if ([self.contentValue isEqualToString:@"AWAY"]) {
  98. msg = NSLocalizedString(@"외출", @"외출");
  99. } else {
  100. msg = @"-";
  101. }
  102. break;
  103. }
  104. return msg;
  105. }
  106. - (NSString *)contentValueMsgOfLock {
  107. NSInteger typeId = [_cmdclsTypeId integerValue];
  108. NSString *msg = ksEmptyString;
  109. switch (typeId) {
  110. case 14001:
  111. if ([self.contentValue isEqualToString:@"LOCKED"]) {
  112. msg = NSLocalizedString(@"잠김", @"잠김");
  113. } else if ([self.contentValue isEqualToString:@"UNLOCKED"]) {
  114. msg = NSLocalizedString(@"열림", @"열림");
  115. } else if ([self.contentValue isEqualToString:@"JAMMED"]) {
  116. msg = NSLocalizedString(@"걸림", @"걸림");
  117. } else if ([self.contentValue isEqualToString:@"FORCED_OPEN"]) {
  118. msg = NSLocalizedString(@"수동", @"수동");
  119. } else if ([self.contentValue isEqualToString:@"UNSPECIFIED"]) {
  120. msg = NSLocalizedString(@"오류", @"오류");
  121. } else {
  122. msg = @"-";
  123. }
  124. break;
  125. case 14002:
  126. case 14003:
  127. if ([self.contentValue isEqualToString:@"LOCKED"]) {
  128. msg = @"잠김";
  129. } else if ([self.contentValue isEqualToString:@"UNLOCKED"]) {
  130. msg = @"열림";
  131. } else {
  132. msg = @"-";
  133. }
  134. break;
  135. }
  136. return msg;
  137. }
  138. - (NSString *)contentValueMsgOfSwitchBinary {
  139. NSInteger typeId = [_cmdclsTypeId integerValue];
  140. NSString *msg = ksEmptyString;
  141. switch (typeId) {
  142. case 17001:
  143. case 17002:
  144. if ([self.contentValue isEqualToString:@"ON"]) {
  145. msg = NSLocalizedString(@"켜짐", @"켜짐");
  146. } else if ([self.contentValue isEqualToString:@"OFF"]) {
  147. msg = NSLocalizedString(@"꺼짐", @"꺼짐");
  148. } else {
  149. msg = @"-";
  150. }
  151. break;
  152. }
  153. return msg;
  154. }
  155. - (NSString *)contentValueMsgOfValve {
  156. NSInteger typeId = [_cmdclsTypeId integerValue];
  157. NSString *msg = ksEmptyString;
  158. switch (typeId) {
  159. case 36001:
  160. case 36002:
  161. case 36003:
  162. if ([self.contentValue isEqualToString:@"OPEN"]) {
  163. msg = NSLocalizedString(@"열림", @"열림");
  164. } else if ([self.contentValue isEqualToString:@"CLOSE"]) {
  165. msg = NSLocalizedString(@"잠김", @"잠김");
  166. } else {
  167. msg = @"-";
  168. }
  169. break;
  170. }
  171. return msg;
  172. }
  173. - (NSString *)contentValueMsg {
  174. switch ([self cmdclsType]) {
  175. case CmdClsTypeSensorBinary:
  176. _contentValueMsg = [self contentValueMsgOfSensorBinary];
  177. break;
  178. case CmdClsTypeThermostatMode:
  179. _contentValueMsg = [self contentValueMsgOfThermostatMode];
  180. break;
  181. case CmdClsTypeLock:
  182. _contentValueMsg = [self contentValueMsgOfLock];
  183. break;
  184. case CmdClsTypeSwitchBinary:
  185. _contentValueMsg = [self contentValueMsgOfSwitchBinary];
  186. break;
  187. case CmdClsTypeSpeedControl:
  188. _contentValueMsg = [self contentValueMsgOfSpeedControl];
  189. break;
  190. case CmdClsTypeAVControlPlayback:
  191. _contentValueMsg = [self contentValueMsgOfAVPlayback];
  192. break;
  193. case CmdClsTypeValve:
  194. _contentValueMsg = [self contentValueMsgOfValve];
  195. default:
  196. break;
  197. }
  198. return _contentValueMsg;
  199. }
  200. - (NSString *)contentValueMsgOfSpeedControl {
  201. NSInteger typeId = [_cmdclsTypeId integerValue];
  202. NSString *msg = ksEmptyString;
  203. switch (typeId) {
  204. case 20001:
  205. if ([self.contentValue isEqualToString:@"OFF"]) {
  206. msg = NSLocalizedString(@"꺼짐", @"꺼짐");
  207. } else if ([self.contentValue isEqualToString:@"LOW"]) {
  208. msg = NSLocalizedString(@"약", @"약");
  209. } else if ([self.contentValue isEqualToString:@"MEDIUM"]) {
  210. msg = NSLocalizedString(@"중", @"중");
  211. } else if ([self.contentValue isEqualToString:@"HIGH"]) {
  212. msg = NSLocalizedString(@"강", @"강");
  213. } else {
  214. msg = @"-";
  215. }
  216. break;
  217. }
  218. return msg;
  219. }
  220. - (NSString *)contentValueMsgOfAVPlayback {
  221. NSInteger typeId = [_cmdclsTypeId integerValue];
  222. NSString *msg = ksEmptyString;
  223. switch (typeId) {
  224. case 21001:
  225. if ([self.contentValue isEqualToString:@"PLAYING"]) {
  226. msg = NSLocalizedString(@"재생 중", @"재생 중");
  227. } else if ([self.contentValue isEqualToString:@"PAUSED"]) {
  228. msg = NSLocalizedString(@"정지 됨", @"정지 됨");
  229. } else {
  230. msg = @"-";
  231. }
  232. break;
  233. }
  234. return msg;
  235. }
  236. - (instancetype)initWithSubItem:(ItemSubModel *)subItem {//mobile devices.
  237. if (self = [super init]) {
  238. self.deviceId = subItem.sourceId;
  239. self.deviceName = subItem.sourceName;
  240. self.nodeId = subItem.sourceSubId;
  241. self.nodeName = subItem.sourceSubName;
  242. self.conditionTypeCode = subItem.conditionTypeCode;
  243. self.dataTypeCode = subItem.dataTypeCode;
  244. self.cmdclsValue = subItem.cmdclsValue;
  245. self.nickname = subItem.nickname;
  246. self.deleteYn = subItem.deleteYn;
  247. // objc_setAssociatedObject(self, @"CHECK_STATUS", @YES, OBJC_ASSOCIATION_COPY_NONATOMIC); //for checkbox
  248. [[JDFacade facade] setRadioButtonStatus:@YES object:self]; //for radio box
  249. }
  250. return self;
  251. }
  252. + (NSString *)contentValueMsgByCmdClsCode:(NSString *)cmdclsCode cmdclsTypeId:(NSString *)cmdclsTypeId contentValue:(NSString *)contentValue {
  253. DeviceModel *tmpDevice = [[DeviceModel alloc] init];
  254. tmpDevice.cmdclsCode = cmdclsCode;
  255. tmpDevice.cmdclsTypeId = cmdclsTypeId;
  256. tmpDevice.contentValue = contentValue;
  257. return tmpDevice.contentValueMsg;
  258. }
  259. @end
  260. @implementation DeviceListModel
  261. @end
  262. @implementation NodeModel
  263. //- (CmdClsType)cmdclsType {
  264. // return [DeviceModel cmdclsTypeForCode:_cmdclsCode];
  265. //}
  266. @end
  267. @implementation DeviceDetailModel
  268. @end
  269. @implementation PredefinedDeviceModel
  270. //+ (JSONKeyMapper *)keyMapper {
  271. //
  272. // NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
  273. //
  274. // //self
  275. // [dictionary setValue:@"cmdclsTypeSystemName" forKey:@"cmdcls_type_system_name"];
  276. // [dictionary setValue:@"cmdclsTypeId" forKey:@"cmdcls_type_id"];
  277. // [dictionary setValue:@"cmdclsCode" forKey:@"cmdcls_code"];
  278. // [dictionary setValue:@"deviceProfileId" forKey:@"device_profile_id"];
  279. // [dictionary setValue:@"createDatetime" forKey:@"create_datetime"];
  280. // [dictionary setValue:@"cmdclsTypeName" forKey:@"cmdcls_type_name"];
  281. // [dictionary setValue:@"deviceName" forKey:@"device_name"];
  282. // [dictionary setValue:@"profileName" forKey:@"profile_name"];
  283. // [dictionary setValue:@"imageFileName" forKey:@"image_file_name"];
  284. // [dictionary setValue:@"contentValue" forKey:@"content_value"];
  285. // [dictionary setValue:@"nodeName" forKey:@"node_name"];
  286. // [dictionary setValue:@"cmdclsCount" forKey:@"cmdcls_count"];
  287. // [dictionary setValue:@"nodeId" forKey:@"node_id"];
  288. // [dictionary setValue:@"deviceId" forKey:@"device_id"];
  289. // [dictionary setValue:@"cmdclsValue" forKey:@"cmdcls_value"];
  290. // [dictionary setValue:@"conditionTypeCode" forKey:@"condition_type_code"];
  291. // [dictionary setValue:@"dataTypeCode" forKey:@"data_type_code"];
  292. //
  293. // return [[JSONKeyMapper alloc] initWithDictionary:dictionary];
  294. //}
  295. - (instancetype)initWithSubItem:(ItemSubModel *)subItem {
  296. if (self = [super init]) {
  297. self.deviceId = subItem.sourceId;
  298. self.deviceName = subItem.sourceName;
  299. self.nodeId = subItem.sourceSubId;
  300. self.nodeName = subItem.sourceSubName;
  301. self.conditionTypeCode = subItem.conditionTypeCode;
  302. self.dataTypeCode = subItem.dataTypeCode;
  303. self.cmdclsValue = subItem.cmdclsValue;
  304. self.predCmdclsValue = subItem.predCmdclsValue;
  305. self.deleteYn = subItem.deleteYn;
  306. [[JDFacade facade] setCheckBoxStatus:@YES object:self]; //for check box
  307. [[JDFacade facade] setRadioButtonStatus:@YES object:self]; //for radio box
  308. }
  309. return self;
  310. }
  311. @end
  312. @implementation PredefinedDeviceListModel
  313. @end
  314. @implementation DeviceIconModel
  315. @end
  316. @implementation DeviceIconListModel
  317. @end