DeviceModel.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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. if ([self.contentValue isEqualToString:@"ON"]) {
  144. msg = NSLocalizedString(@"켜짐", @"켜짐");
  145. } else if ([self.contentValue isEqualToString:@"OFF"]) {
  146. msg = NSLocalizedString(@"꺼짐", @"꺼짐");
  147. } else {
  148. msg = @"-";
  149. }
  150. break;
  151. }
  152. return msg;
  153. }
  154. - (NSString *)contentValueMsg {
  155. switch ([self cmdclsType]) {
  156. case CmdClsTypeSensorBinary:
  157. _contentValueMsg = [self contentValueMsgOfSensorBinary];
  158. break;
  159. case CmdClsTypeThermostatMode:
  160. _contentValueMsg = [self contentValueMsgOfThermostatMode];
  161. break;
  162. case CmdClsTypeLock:
  163. _contentValueMsg = [self contentValueMsgOfLock];
  164. break;
  165. case CmdClsTypeSwitchBinary:
  166. _contentValueMsg = [self contentValueMsgOfSwitchBinary];
  167. break;
  168. case CmdClsTypeSpeedControl:
  169. _contentValueMsg = [self contentValueMsgOfSpeedControl];
  170. break;
  171. case CmdClsTypeAVControlPlayback:
  172. _contentValueMsg = [self contentValueMsgOfAVPlayback];
  173. break;
  174. default:
  175. break;
  176. }
  177. return _contentValueMsg;
  178. }
  179. - (NSString *)contentValueMsgOfSpeedControl {
  180. NSInteger typeId = [_cmdclsTypeId integerValue];
  181. NSString *msg = ksEmptyString;
  182. switch (typeId) {
  183. case 20001:
  184. if ([self.contentValue isEqualToString:@"OFF"]) {
  185. msg = NSLocalizedString(@"꺼짐", @"꺼짐");
  186. } else if ([self.contentValue isEqualToString:@"LOW"]) {
  187. msg = NSLocalizedString(@"약", @"약");
  188. } else if ([self.contentValue isEqualToString:@"MEDIUM"]) {
  189. msg = NSLocalizedString(@"중", @"중");
  190. } else if ([self.contentValue isEqualToString:@"HIGH"]) {
  191. msg = NSLocalizedString(@"강", @"강");
  192. } else {
  193. msg = @"-";
  194. }
  195. break;
  196. }
  197. return msg;
  198. }
  199. - (NSString *)contentValueMsgOfAVPlayback {
  200. NSInteger typeId = [_cmdclsTypeId integerValue];
  201. NSString *msg = ksEmptyString;
  202. switch (typeId) {
  203. case 21001:
  204. if ([self.contentValue isEqualToString:@"PLAYING"]) {
  205. msg = NSLocalizedString(@"재생 중", @"재생 중");
  206. } else if ([self.contentValue isEqualToString:@"PAUSED"]) {
  207. msg = NSLocalizedString(@"정지 됨", @"정지 됨");
  208. } else {
  209. msg = @"-";
  210. }
  211. break;
  212. }
  213. return msg;
  214. }
  215. - (instancetype)initWithSubItem:(ItemSubModel *)subItem {//mobile devices.
  216. if (self = [super init]) {
  217. self.deviceId = subItem.sourceId;
  218. self.deviceName = subItem.sourceName;
  219. self.nodeId = subItem.sourceSubId;
  220. self.nodeName = subItem.sourceSubName;
  221. self.conditionTypeCode = subItem.conditionTypeCode;
  222. self.dataTypeCode = subItem.dataTypeCode;
  223. self.cmdclsValue = subItem.cmdclsValue;
  224. self.nickname = subItem.nickname;
  225. self.deleteYn = subItem.deleteYn;
  226. // objc_setAssociatedObject(self, @"CHECK_STATUS", @YES, OBJC_ASSOCIATION_COPY_NONATOMIC); //for checkbox
  227. [[JDFacade facade] setRadioButtonStatus:@YES object:self]; //for radio box
  228. }
  229. return self;
  230. }
  231. @end
  232. @implementation DeviceListModel
  233. @end
  234. @implementation NodeModel
  235. //- (CmdClsType)cmdclsType {
  236. // return [DeviceModel cmdclsTypeForCode:_cmdclsCode];
  237. //}
  238. @end
  239. @implementation DeviceDetailModel
  240. @end
  241. @implementation PredefinedDeviceModel
  242. //+ (JSONKeyMapper *)keyMapper {
  243. //
  244. // NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
  245. //
  246. // //self
  247. // [dictionary setValue:@"cmdclsTypeSystemName" forKey:@"cmdcls_type_system_name"];
  248. // [dictionary setValue:@"cmdclsTypeId" forKey:@"cmdcls_type_id"];
  249. // [dictionary setValue:@"cmdclsCode" forKey:@"cmdcls_code"];
  250. // [dictionary setValue:@"deviceProfileId" forKey:@"device_profile_id"];
  251. // [dictionary setValue:@"createDatetime" forKey:@"create_datetime"];
  252. // [dictionary setValue:@"cmdclsTypeName" forKey:@"cmdcls_type_name"];
  253. // [dictionary setValue:@"deviceName" forKey:@"device_name"];
  254. // [dictionary setValue:@"profileName" forKey:@"profile_name"];
  255. // [dictionary setValue:@"imageFileName" forKey:@"image_file_name"];
  256. // [dictionary setValue:@"contentValue" forKey:@"content_value"];
  257. // [dictionary setValue:@"nodeName" forKey:@"node_name"];
  258. // [dictionary setValue:@"cmdclsCount" forKey:@"cmdcls_count"];
  259. // [dictionary setValue:@"nodeId" forKey:@"node_id"];
  260. // [dictionary setValue:@"deviceId" forKey:@"device_id"];
  261. // [dictionary setValue:@"cmdclsValue" forKey:@"cmdcls_value"];
  262. // [dictionary setValue:@"conditionTypeCode" forKey:@"condition_type_code"];
  263. // [dictionary setValue:@"dataTypeCode" forKey:@"data_type_code"];
  264. //
  265. // return [[JSONKeyMapper alloc] initWithDictionary:dictionary];
  266. //}
  267. - (instancetype)initWithSubItem:(ItemSubModel *)subItem {
  268. if (self = [super init]) {
  269. self.deviceId = subItem.sourceId;
  270. self.deviceName = subItem.sourceName;
  271. self.nodeId = subItem.sourceSubId;
  272. self.nodeName = subItem.sourceSubName;
  273. self.conditionTypeCode = subItem.conditionTypeCode;
  274. self.dataTypeCode = subItem.dataTypeCode;
  275. self.cmdclsValue = subItem.cmdclsValue;
  276. self.predCmdclsValue = subItem.predCmdclsValue;
  277. self.deleteYn = subItem.deleteYn;
  278. [[JDFacade facade] setCheckBoxStatus:@YES object:self]; //for check box
  279. [[JDFacade facade] setRadioButtonStatus:@YES object:self]; //for radio box
  280. }
  281. return self;
  282. }
  283. @end
  284. @implementation PredefinedDeviceListModel
  285. @end
  286. @implementation DeviceIconModel
  287. @end
  288. @implementation DeviceIconListModel
  289. @end