CommandClassControlDetailView.m 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //
  2. // CommandClassControlDetailView.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 "CustomRadioGroup.h"
  16. #import "UIImageView+WebCache.h"
  17. #import "CommandClassControlDetailView.h"
  18. #import "CommandClassControlView.h"
  19. #import "CustomImageView.h"
  20. #define GRAPH_ANI_DUR 0.5f
  21. #define DEGREES(radians)((radians) * 180 / M_PI)
  22. #define RADIANS(degree)((degree) * M_PI / 180)
  23. #define kfControlDetailDefaultWidth 320.0f;
  24. #define kfControlDetailDefaultHeight 340.0f;
  25. typedef void(^NodeCommandCompletionBlock)(id result);
  26. typedef void(^NodeCommandFailureBlock)(id error);
  27. @implementation CommandClassControlDetailView
  28. + (CommandClassControlView *)viewForCommandClass:(CmdClsType)cmdClsType
  29. {
  30. CommandClassControlView *controlView = nil;
  31. for (UIView *view in [CommonUtil nibViews:@"CommandClassControlDetailView"]) {
  32. if (view.tag == cmdClsType) {
  33. controlView = (CommandClassControlView *)view;
  34. controlView.width = IPHONE_WIDTH;
  35. controlView.height = kfControlDetailDefaultHeight;
  36. break;
  37. }
  38. }
  39. if (!controlView) {//상위 부모에서 가져옴.
  40. controlView = [CommandClassControlView viewForCommandClass:cmdClsType];
  41. }
  42. return controlView;
  43. }
  44. @end
  45. @implementation CommandClassSwitchDetailView
  46. - (void)setLayoutUI {
  47. [super setLayoutUI];
  48. [self updateLayout];
  49. }
  50. - (IBAction)btnOnTouched:(id)sender {
  51. [self requestNodeCommand:self.parameterForNodeCommand requestValue:_requestValueForOn completionHandler:nil failureHandler:nil];
  52. }
  53. - (IBAction)btnOffTouched:(id)sender {
  54. [self requestNodeCommand:self.parameterForNodeCommand requestValue:_requestValueForOff completionHandler:nil failureHandler:nil];
  55. }
  56. - (void)updateLayout {
  57. [super updateLayout];
  58. _btnOn.selected = _isON;
  59. _btnOff.selected = !_btnOn.selected;
  60. }
  61. @end
  62. @implementation CommandClassValveDetailView
  63. @end
  64. #pragma mark - Sensors View
  65. @implementation CommandClassSensorBinaryDetailView
  66. @end
  67. @implementation CommandClassSensorMultiLevelDetailView
  68. @end