CommandClassControlView.m 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. //
  2. // CommandClassControlView.m
  3. // kneet
  4. //
  5. // Created by Jason Lee on 3/16/15.
  6. // Copyright (c) 2015 ntels. All rights reserved.
  7. //
  8. #import "JDObject.h"
  9. #import "RequestHandler.h"
  10. #import "JDJSONModel.h"
  11. #import "DeviceModel.h"
  12. #import "CustomLabel.h"
  13. #import "CommonUtil.h"
  14. #import "CustomButton.h"
  15. #import "CommandClassControlView.h"
  16. #import "ThingsDetailViewController.h"
  17. #import "ThingsViewController.h"
  18. #import "MainViewController.h"
  19. #define MAX_CONTROL_REQUEST_TIME 10
  20. @implementation CommandClassControlView
  21. + (CommandClassControlView *)viewForCommandClass:(CmdClsType)cmdClsType {
  22. CommandClassControlView *controlView = nil;
  23. for (UIView *view in [CommonUtil nibViews:@"CommandClassControlView"]) {
  24. if (view.tag == cmdClsType) {
  25. controlView = (CommandClassControlView *)view;
  26. controlView.width = kfControlDefaultWidth;
  27. controlView.height = kfControlDefaultHeight;
  28. break;
  29. }
  30. }
  31. return controlView;
  32. }
  33. - (void)setDevice:(DeviceModel *)device {
  34. _device = device;
  35. }
  36. - (void)setNode:(NodeModel *)node {
  37. _node = node;
  38. }
  39. - (void)setLayoutUI {
  40. }
  41. - (void)updateLayout {
  42. }
  43. //todo : 로딩화면 띄우기
  44. //예외처리 하기
  45. - (NSDictionary *)parameterForNodeCommand {
  46. NSDictionary *parameter = nil;
  47. if (_device) {
  48. NSLog(@"Device : %@", _device);
  49. parameter = @{
  50. @"device_id": _device.deviceId,
  51. @"node_id": _device.nodeId};
  52. } else if (_node) {
  53. NSLog(@"Node : %@", _node);
  54. parameter = @{@"device_id": _node.deviceId,
  55. @"node_id": _node.nodeId};
  56. }
  57. return parameter;
  58. }
  59. - (NSDictionary *)requestValueForNodeCommand:(NSString *)requestValue {
  60. NSDictionary *result = nil;
  61. if (_device) {
  62. result = @{_device.cmdclsId:requestValue};
  63. } else if (_node) {
  64. result = @{_node.cmdclsId:requestValue};
  65. }
  66. return result;
  67. }
  68. - (CGSize)sizeForIntrinsic {
  69. return CGSizeMake(kfControlMaxWidth, kfControlDefaultHeight);
  70. }
  71. - (CGSize)sizeForIntrinsicForItemCount:(NSInteger)count {
  72. return CGSizeMake(kfControlMaxWidth, kfControlDefaultHeight);
  73. }
  74. - (void)requestNodeCommand:(NSDictionary *)parameters requestValue:(NSString *)requestValue completionHandler:(NodeCommandCompletionBlock)completion failureHandler:(NodeCommandFailureBlock)failure {
  75. if (_device.isRequesting) {
  76. return;
  77. }
  78. _device.isRequesting = YES;
  79. [[[RACObserve(_device, contentValue) skip:1] take:1] subscribeNext:^(id x) {
  80. [self updateLayout];
  81. }];
  82. NSString *deviceId = parameters[@"device_id"];
  83. NSString *nodeId = parameters[@"node_id"];
  84. NSDictionary *param = @{@"request_value": requestValue};
  85. NSString *path = [NSString stringWithFormat:API_POST_NODE_COMMAND, deviceId, nodeId];
  86. [[RequestHandler handler] sendAsyncRequestAPIPath:path method:ksHTTPRequestPOST parameters:param modelClass:[DeviceModel class] showLoadingView:NO completion:^(id responseObject) {
  87. if (!responseObject) {//응답결과가 잘못되었거나 없을 경우,
  88. return;
  89. }
  90. DeviceModel *result = (DeviceModel *)responseObject;
  91. if (result && result.commandId && ![result.commandId isEmptyString]) {
  92. _device.requestTime = result.requestTime;
  93. ThingsViewController *vc = [JDFacade facade].mainViewController.tvc;
  94. if (vc && [vc isKindOfClass:[ThingsViewController class]]) {
  95. [vc requestPollingCommandStatusOfDeviceInBackground:_device];
  96. }
  97. }
  98. if (completion) {
  99. completion(responseObject);
  100. }
  101. } failure:^(id errorObject) {
  102. JDErrorModel *error = (JDErrorModel *)errorObject;
  103. [[JDFacade facade] alert:error.errorMessage];
  104. if (failure) {
  105. failure(error);
  106. }
  107. }];
  108. }
  109. - (void)requestNodeCommand:(NSDictionary *)parameters requestValue:(NSDictionary *)requestValue {
  110. if (_device.isRequesting) {
  111. return;
  112. }
  113. NSLog(@"Device : %@", _device);
  114. _device.isRequesting = YES;
  115. SocketRequestModel *request = [[SocketRequestModel alloc] initWithMsgType:MSG_TYPE_NODE_COMMAND];
  116. NSDictionary *param = @{@"device_id": parameters[@"device_id"],
  117. @"node_id":parameters[@"node_id"],
  118. @"command_type":CMD_TYPE_CONTROL,
  119. @"request_value":requestValue,
  120. @"cust_id": [[JDFacade facade].loginUser custId],
  121. @"ctrt_grp_id": [[JDFacade facade].loginUser ctrtGrpId]};
  122. [request setRequestMsg:param];
  123. [[SocketServiceHandler sharedManager] sendDataWithDelegate:request delegate:self];
  124. [self performSelector:@selector(chkRequstDeviceControlResult) withObject:nil afterDelay:MAX_CONTROL_REQUEST_TIME];
  125. }
  126. - (void)requestNodeCommand:(NSString *)requestValue {
  127. if (_device.isRequesting) {
  128. return;
  129. }
  130. NSLog(@"Device : %@", _device);
  131. _device.isRequesting = YES;
  132. [[[RACObserve(_device, contentValue) skip:1] take:1] subscribeNext:^(id x) {
  133. [self updateLayout];
  134. }];
  135. SocketRequestModel *request = [[SocketRequestModel alloc] initWithMsgType:MSG_TYPE_NODE_COMMAND];
  136. NSDictionary *param = @{@"device_id": _device.deviceId,
  137. @"node_id":_device.nodeId,
  138. @"command_type":CMD_TYPE_CONTROL,
  139. @"request_value":@{_device.cmdclsId:requestValue},
  140. @"cust_id": [[JDFacade facade].loginUser custId],
  141. @"ctrt_grp_id": [[JDFacade facade].loginUser ctrtGrpId]};
  142. [request setRequestMsg:param];
  143. [[SocketServiceHandler sharedManager] sendDataWithDelegate:request delegate:self];
  144. [self performSelector:@selector(chkRequstDeviceControlResult) withObject:nil afterDelay:MAX_CONTROL_REQUEST_TIME];
  145. }
  146. + (NSString *)cmdclsValueForType:(NSString *)dataTypeCode value:(CGFloat)value {
  147. NSString *result = nil;
  148. if ([dataTypeCode isEqualToString:ksDataTypeCodeInteger]) {
  149. result = [NSString stringWithFormat:@"%zd", (NSInteger)value];
  150. } else if ([dataTypeCode isEqualToString:ksDataTypeCodeFloat]) {
  151. result = [NSString stringWithFormat:@"%.1f", value];
  152. } else {
  153. result = [NSString stringWithFormat:@"%zd", (NSInteger)value];
  154. }
  155. return result;
  156. }
  157. - (void)updateThingsViewContoller {
  158. if ([[JDFacade facade].currentViewController isKindOfClass:[ThingsDetailViewController class]]) {
  159. ThingsViewController *vc = [[JDFacade facade] viewControllerOnNaviationController:[ThingsViewController class]];
  160. if (vc) {
  161. [vc prepareViewDidLoad];
  162. }
  163. }
  164. }
  165. -(void) chkRequstDeviceControlResult {
  166. if (_device.isRequesting) {
  167. _device.isRequesting = NO;
  168. ThingsViewController *vc = [JDFacade facade].mainViewController.tvc;
  169. if (vc && [vc isKindOfClass:[ThingsViewController class]]) {
  170. [vc requestDeviceControl];
  171. }
  172. }
  173. }
  174. - (void) socketDidReceiveMessage:(id)message result:(SocketModel *)result
  175. {
  176. NSLog(@"Message : %@", message);
  177. NSLog(@"Message : %@", result);
  178. if (result.isSuccess) {
  179. ThingsViewController *vc = [JDFacade facade].mainViewController.tvc;
  180. if (vc && [vc isKindOfClass:[ThingsViewController class]]) {
  181. [vc requestDeviceControl];
  182. }
  183. } else {
  184. _device.isRequesting = NO;
  185. }
  186. }
  187. @end
  188. @implementation CommandClassSwitchView
  189. - (void)willMoveToSuperview:(UIView *)newSuperview {
  190. if (!newSuperview)
  191. return;
  192. [self initControl];
  193. }
  194. - (void)initControl {
  195. _requestValueForOff = @"OFF";
  196. _requestValueForOn = @"ON";
  197. [self setLayoutUI];
  198. }
  199. - (void)setLayoutUI {
  200. _device = _device ? _device : _node;
  201. _isON = [_device.contentValue isEqualToString:_requestValueForOn];
  202. _device.cmdclsValue = _isON ? _requestValueForOff : _requestValueForOn;
  203. _lblContentValueMsg.text = _device.contentValueMsg;
  204. _btnSwitch.hidden = self.isReOrderMode;
  205. [self setSwitchBinary];
  206. }
  207. - (IBAction)btnSwitchTouched:(id)sender {
  208. NSString *requestValue = _isON ? _requestValueForOff : _requestValueForOn;
  209. _device.cmdclsValue = requestValue;
  210. // [self requestNodeCommand:self.parameterForNodeCommand requestValue:requestValue completionHandler:^(id result) {
  211. //
  212. //// _device.contentValue = requestValue;
  213. //// _isON = !_isON;
  214. //// _device.contentValue = _isON ? _requestValueForOn : _requestValueForOff;
  215. //// [self toggleSwitch];
  216. //
  217. // } failureHandler:nil];
  218. // [self requestNodeCommand:requestValue];
  219. [self requestNodeCommand:self.parameterForNodeCommand requestValue:[self requestValueForNodeCommand:requestValue]];
  220. }
  221. - (void)setSwitchBinary {
  222. _lblContentValueMsg.text = _device.contentValueMsg;
  223. // [_btnSwitch setTitle:_device.cmdclsValueMsg forState:UIControlStateNormal];
  224. if (_isON) {//OFF
  225. [_btnSwitch setImage:[UIImage imageNamed:@"img_things_list_btn_onoff_on"] forState:UIControlStateNormal];
  226. [self.lblContentValueMsg setColor:kUITextColor02 text:self.lblContentValueMsg.text];
  227. } else {//ON
  228. [_btnSwitch setImage:[UIImage imageNamed:@"img_things_list_btn_onoff_off"] forState:UIControlStateNormal];
  229. }
  230. }
  231. - (void)toggleSwitch {
  232. [self setSwitchBinary];
  233. [self updateThingsViewContoller];
  234. }
  235. - (void)updateLayout {
  236. _isON = !_isON;
  237. [self setSwitchBinary];
  238. }
  239. @end
  240. @implementation CommandClassSwitchMultiLevelView
  241. - (void)willMoveToSuperview:(UIView *)newSuperview {
  242. if (!newSuperview)
  243. return;
  244. [self initControl];
  245. }
  246. - (void)initControl {
  247. [self setLayoutUI];
  248. }
  249. - (void)setLayoutUI {
  250. _device = _device ? _device : _node;
  251. _device.cmdclsValue = _device.cmdclsValue ? _device.cmdclsValue : [CommandClassControlView cmdclsValueForType:_device.dataTypeCode value:[_device.controlMaxValue floatValue]/ 2];
  252. _currentValue = !_isConditionMode ? [_device.contentValue floatValue] : [_device.cmdclsValue floatValue];
  253. _minValue = [_device.controlMinValue floatValue];
  254. _maxValue = [_device.controlMaxValue floatValue];
  255. _step = [_device.controlStep floatValue];
  256. NSString *sMax = [CommandClassControlView cmdclsValueForType:_device.dataTypeCode value:_maxValue];
  257. CGFloat width = [CommonUtil getSizeFromString:sMax font:_btnLabel.titleLabel.font width:FLT_MAX].width + kfSwitchLabelPadding;
  258. CGFloat eWidth = width + kfCommandClassSwitchLeftPadding + kfCommandClassSwitchRightPadding;
  259. eWidth = eWidth < kfControlDefaultWidth ? kfControlDefaultWidth : eWidth;
  260. _constraintBtnLabelWidth.constant = eWidth;
  261. CGRect sr = self.frame;
  262. sr.size.width = eWidth;
  263. self.frame = sr;
  264. [_btnLabel setTitle:[NSString stringWithFormat:@"%@%@", [CommandClassControlView cmdclsValueForType:_device.dataTypeCode value:_currentValue], _device.unit ? _device.unit : ksEmptyString] forState:UIControlStateNormal];
  265. }
  266. - (void)setEnable:(BOOL)enable {
  267. _enable = enable;
  268. _btnMinus.userInteractionEnabled = _enable;
  269. _btnPlus.userInteractionEnabled = _enable;
  270. if (_enable) {
  271. [_btnLabel setTitleColor:kUITextColor02 forState:UIControlStateNormal];
  272. [_btnMinus setImage:[UIImage imageNamed:@"tp_01_img_control_unit_minus"] forState:UIControlStateNormal];
  273. [_btnPlus setImage:[UIImage imageNamed:@"tp_01_img_control_unit_plus"] forState:UIControlStateNormal];
  274. } else {
  275. [_btnLabel setTitleColor:kUITextColor03 forState:UIControlStateNormal];
  276. [_btnMinus setImage:[UIImage imageNamed:@"tp_01_img_control_unit_minus_disable"] forState:UIControlStateNormal];
  277. [_btnPlus setImage:[UIImage imageNamed:@"tp_01_img_control_unit_plus_disable"] forState:UIControlStateNormal];
  278. }
  279. }
  280. - (IBAction)btnPlusTouchDown:(id)sender {
  281. if (!_pressTimer) {
  282. _pressTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(addValue) userInfo:nil repeats:YES];
  283. }
  284. }
  285. - (void)btnMinusTouchDown:(id)sender {
  286. if (!_pressTimer) {
  287. _pressTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(subtractValue) userInfo:nil repeats:YES];
  288. }
  289. }
  290. - (IBAction)btnPlusTouchUp:(id)sender {
  291. [_pressTimer invalidate];
  292. _pressTimer = nil;
  293. [self addValue];
  294. [self requestCommand];
  295. }
  296. - (IBAction)btnMinusTouchUp:(id)sender {
  297. [_pressTimer invalidate];
  298. _pressTimer = nil;
  299. [self subtractValue];
  300. [self requestCommand];
  301. }
  302. - (void)addValue {
  303. _currentValue = _currentValue + _step > _maxValue ? _minValue : _currentValue + _step;
  304. [_btnLabel setTitle:[NSString stringWithFormat:@"%@%@", [CommandClassControlView cmdclsValueForType:_device.dataTypeCode value:_currentValue], _device.unit ? _device.unit : ksEmptyString] forState:UIControlStateNormal];
  305. if (_device) {
  306. _device.cmdclsValue = [CommandClassControlView cmdclsValueForType:_device.dataTypeCode value:_currentValue];
  307. [self updateThingsViewContoller];
  308. }
  309. }
  310. - (void)subtractValue {
  311. _currentValue = _currentValue - _step < _minValue ? _maxValue : _currentValue - _step;
  312. [_btnLabel setTitle:[NSString stringWithFormat:@"%@%@", [CommandClassControlView cmdclsValueForType:_device.dataTypeCode value:_currentValue], _device.unit ? _device.unit : ksEmptyString] forState:UIControlStateNormal];
  313. if (_device) {
  314. _device.cmdclsValue = [CommandClassControlView cmdclsValueForType:_device.dataTypeCode value:_currentValue];
  315. [self updateThingsViewContoller];
  316. }
  317. }
  318. - (void)requestCommand {
  319. if (_isConditionMode) //룰, 씬일 경우, 제어를 하지 않음
  320. return;
  321. NSString *requestValue = _device.cmdclsValue;
  322. // [self requestNodeCommand:self.parameterForNodeCommand requestValue:requestValue completionHandler:^(id result) {
  323. // _device.contentValue = [CommandClassControlView cmdclsValueForType:_device.dataTypeCode value:_currentValue];
  324. // } failureHandler:nil];
  325. // [self requestNodeCommand:requestValue];
  326. [self requestNodeCommand:self.parameterForNodeCommand requestValue:[self requestValueForNodeCommand:requestValue]];
  327. }
  328. @end
  329. @implementation CommandClassValveView
  330. - (void)willMoveToSuperview:(UIView *)newSuperview {
  331. if (!newSuperview)
  332. return;
  333. [self initControl];
  334. }
  335. - (void)initControl {
  336. _requestValueForOpen = @"OPEN";
  337. _requestValueForClose = @"CLOSE";
  338. [self setLayoutUI];
  339. }
  340. - (void)setLayoutUI {
  341. _device = _device ? _device : _node;
  342. _lblContentValueMsg.text = _device.contentValueMsg;
  343. _isOpened = [_device.contentValue isEqualToString:_requestValueForOpen];
  344. _device.cmdclsValue = _isOpened ? _requestValueForClose : _requestValueForOpen;
  345. if ([_device.contentValue isEqualToString:_requestValueForOpen]) {
  346. [self.lblContentValueMsg setColor:kUITextColor02 text:self.lblContentValueMsg.text];
  347. }
  348. _btnOpen.hidden = self.isReOrderMode;
  349. [self setSwitchBinary];
  350. }
  351. - (void)setSwitchBinary {
  352. if (_isOpened) {//Unlocked
  353. // [_btnOpen setImage:[UIImage imageNamed:@"img_things_list_btn_lockunlock_unlock"] forState:UIControlStateNormal];
  354. [_btnOpen setImage:[UIImage imageNamed:@"img_things_list_btn_onoff_on"] forState:UIControlStateNormal];
  355. } else {//Locked
  356. // [_btnOpen setImage:[UIImage imageNamed:@"img_things_list_btn_lockunlock_lock"] forState:UIControlStateNormal];
  357. [_btnOpen setImage:[UIImage imageNamed:@"img_things_list_btn_onoff_off"] forState:UIControlStateNormal];
  358. }
  359. }
  360. - (IBAction)btnOpenTouched:(id)sender {
  361. NSString *requestValue = _isOpened ? @"CLOSE" : @"OPEN";
  362. if ([_device.cmdclsTypeId isEqualToString:@"36002"]) {
  363. requestValue = @"CLOSE";
  364. if (!_isOpened) {
  365. [[JDFacade facade] toast:@"이미 잠긴 상태입니다"];
  366. return;
  367. }
  368. }
  369. _device.cmdclsValue = requestValue;
  370. // [self requestNodeCommand:self.parameterForNodeCommand requestValue:requestValue completionHandler:^(id result) {
  371. //
  372. //// if ([_device.cmdclsTypeId isEqualToString:@"14001"]) {//Lock.Default일 경우에만 컨트롤을 토글시킴.
  373. //// _isLocked = !_isLocked;
  374. //// _device.contentValue = _isLocked ? @"LOCKED" : @"UNLOCKED";
  375. //// } else if ([_device.cmdclsTypeId isEqualToString:@"14002"]) {
  376. //// _isLocked = YES;
  377. //// _device.contentValue = @"LOCKED";
  378. //// } else if ([_device.cmdclsTypeId isEqualToString:@"14003"]) {
  379. //// _isLocked = NO;
  380. //// _device.contentValue = @"UNLOCKED";
  381. //// }
  382. //
  383. // [self toggleOpenButton];
  384. //
  385. // } failureHandler:nil];
  386. // [self requestNodeCommand:requestValue];
  387. [self requestNodeCommand:self.parameterForNodeCommand requestValue:[self requestValueForNodeCommand:requestValue]];
  388. }
  389. - (void)toggleOpenButton {
  390. [self setSwitchBinary];
  391. // [_btnSwitch faceOffImage];
  392. [self updateThingsViewContoller];
  393. }
  394. @end
  395. #pragma mark - Sensors View
  396. @implementation CommandClassSensorBinaryView
  397. - (void)willMoveToSuperview:(UIView *)newSuperview {
  398. if (!newSuperview)
  399. return;
  400. [self initControl];
  401. }
  402. - (void)initControl {
  403. [self setLayoutUI];
  404. }
  405. - (void)setLayoutUI {
  406. _device = _device ? _device : _node;
  407. NSString *contentValue = _device.contentValueMsg;
  408. NSString *unit = _device.unit && ![_device.unit isEmptyString] ? _device.unit : ksEmptyString;
  409. unit = [contentValue isEqualToString:@"-"] ? ksEmptyString : unit;
  410. self.lblControl.text = [NSString stringWithFormat:@"%@ %@", contentValue, unit];
  411. if ([_device.contentValue isEqualToString:@"TRUE"]) {
  412. [self.lblControl setColor:kUITextColor02 text:self.lblControl.text];
  413. }
  414. }
  415. @end
  416. @implementation CommandClassSensorMultiLevelView
  417. - (void)setLayoutUI {
  418. _device = _device ? _device : _node;
  419. NSString *contentValue = (!_device.contentValue || [_device.contentValue isEmptyString] ||[_device.contentValue isEqualToString:@"none"]) ? @"-" : _device.contentValue;
  420. NSString *unit = _device.unit && ![_device.unit isEmptyString] ? _device.unit : ksEmptyString;
  421. unit = [contentValue isEqualToString:@"-"] ? ksEmptyString : unit;
  422. self.lblControl.text = [NSString stringWithFormat:@"%@%@", contentValue, unit];
  423. // if (self.constraintControlLabelWidth) {
  424. // self.constraintControlLabelWidth.constant = [CommonUtil getSizeFromString:self.lblControl.text font:self.lblControl.font width:kfControlMaxWidth].width;
  425. //
  426. // CGRect sr = self.frame;
  427. // sr.size.width = self.constraintControlLabelWidth.constant;
  428. // self.frame = sr;
  429. // }
  430. }
  431. @end
  432. @implementation CommandClassMeterCurrentView
  433. - (void)willMoveToSuperview:(UIView *)newSuperview {
  434. if (!newSuperview)
  435. return;
  436. [self initControl];
  437. }
  438. - (void)initControl {
  439. _lblMeter.textColor = kUITextColor02;
  440. [self setLayoutUI];
  441. }
  442. - (void)setLayoutUI {
  443. _device = _device ? _device : _node;
  444. NSString *contentValue = (!_device.contentValue || [_device.contentValue isEmptyString] ||[_device.contentValue isEqualToString:@"none"]) ? @"-" : _device.contentValue;
  445. NSString *unit = _device.unit && ![_device.unit isEmptyString] ? _device.unit : ksEmptyString;
  446. unit = [contentValue isEqualToString:@"-"] ? ksEmptyString : unit;
  447. if (_node) {//디바이스 상세일 경우,
  448. self.lblMeter.text = [NSString stringWithFormat:@"%@ %@", contentValue, unit];
  449. self.lblMeter.font = [UIFont systemFontOfSize:kUIFontSize07];
  450. } else if (_device) {
  451. self.lblMeter.text = [NSString stringWithFormat:@"%@ : %@ %@", _device.nodeName, contentValue, unit];
  452. [self.lblMeter setColor:kUITextColor02 text:contentValue];
  453. }
  454. // self.constraintControlLabelWidth.constant = [CommonUtil getSizeFromString:self.lblMeter.text font:self.lblMeter.font width:kfControlMaxWidth].width;
  455. //
  456. // CGRect sr = self.frame;
  457. // sr.size.width = self.constraintControlLabelWidth.constant;
  458. // self.frame = sr;
  459. }
  460. @end
  461. @implementation CommandClassMeterTotalView
  462. @end