CommandClassControlView.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. //
  2. // CommandClassControlView.h
  3. // kneet
  4. //
  5. // Created by Jason Lee on 3/16/15.
  6. // Copyright (c) 2015 ntels. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #define kfSwitchLabelPadding 20.0f
  10. #define kfCommandClassSwitchLeftPadding 30.0f
  11. #define kfCommandClassSwitchRightPadding 40.0f
  12. #define kfCommandClassLockRightPadding 20.0f
  13. #define kfControlDefaultWidth 120.0f
  14. #define kfControlMaxWidth IPHONE_WIDTH - 120.0f
  15. #define kfControlDefaultHeight 35.0f
  16. #import "DeviceModel.h"
  17. @class RACDisposable;
  18. typedef void(^NodeCommandCompletionBlock)(id result);
  19. typedef void(^NodeCommandFailureBlock)(id error);
  20. @interface CommandClassControlView : UIView {
  21. @protected
  22. BOOL _enable, _isConditionMode, _isConditionTypeMode;
  23. DeviceModel *_device;
  24. NodeModel *_node;
  25. }
  26. @property (strong, nonatomic) DeviceModel *device;
  27. @property (strong, nonatomic) NodeModel *node;
  28. @property (assign, nonatomic) BOOL enable;
  29. @property (assign, nonatomic) BOOL isConditionMode;
  30. @property (assign, nonatomic) BOOL isConditionTypeMode;
  31. + (CommandClassControlView *)viewForCommandClass:(CmdClsType)cmdClsType;
  32. - (void)requestNodeCommand:(NSDictionary *)parameters requestValue:(NSString *)requestValue completionHandler:(NodeCommandCompletionBlock)completion failureHandler:(NodeCommandFailureBlock)failure;
  33. - (NSDictionary *)parameterForNodeCommand;
  34. - (CGSize)sizeForIntrinsic;
  35. - (CGSize)sizeForIntrinsicForItemCount:(NSInteger)count;
  36. - (void)setLayoutUI;
  37. - (void)updateLayout;
  38. - (void)updateThingsViewContoller;
  39. + (NSString *)cmdclsValueForType:(NSString *)dataTypeCode value:(CGFloat)value;
  40. @end
  41. @class CustomSwitch;
  42. @class CustomButton;
  43. @interface CommandClassSwitchView : CommandClassControlView {
  44. @protected
  45. BOOL _isON;
  46. __weak CustomLabel *_lblContentValueMsg;
  47. NSString *_requestValueForOn, *_requestValueForOff;
  48. }
  49. @property (assign, nonatomic) BOOL isON;
  50. @property (weak, nonatomic) IBOutlet CustomButton *btnSwitch;
  51. @property (weak, nonatomic) IBOutlet CustomLabel *lblContentValueMsg;
  52. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *constraintBtnSwitchWidth;
  53. - (IBAction)btnSwitchTouched:(id)sender;
  54. @end
  55. @interface CommandClassSwitchMultiLevelView : CommandClassControlView {
  56. NSTimer *_pressTimer;
  57. @protected
  58. CGFloat _minValue, _maxValue, _currentValue, _step;
  59. }
  60. @property (weak, nonatomic) IBOutlet CustomButton *btnLabel;
  61. @property (weak, nonatomic) IBOutlet CustomButton *btnPlus;
  62. @property (weak, nonatomic) IBOutlet CustomButton *btnMinus;
  63. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *constraintBtnLabelWidth;
  64. - (IBAction)btnPlusTouchDown:(id)sender;
  65. - (IBAction)btnPlusTouchUp:(id)sender;
  66. - (IBAction)btnMinusTouchDown:(id)sender;
  67. - (IBAction)btnMinusTouchUp:(id)sender;
  68. @end
  69. @interface CommandClassValveView : CommandClassControlView {
  70. @protected
  71. BOOL _isOpen;
  72. __weak CustomLabel *_lblContentValueMsg;
  73. NSString *_requestValueForOpen, *_requestValueForClose;
  74. }
  75. @property (assign, nonatomic) BOOL isOpened;
  76. @property (weak, nonatomic) IBOutlet CustomButton *btnOpen;
  77. @property (weak, nonatomic) IBOutlet CustomLabel *lblContentValueMsg;
  78. - (IBAction)btnOpenTouched:(id)sender;
  79. @end
  80. #pragma mark - Sensors
  81. @class CustomLabel;
  82. @interface CommandClassSensorBinaryView : CommandClassControlView
  83. @property (weak, nonatomic) IBOutlet CustomLabel *lblControl;
  84. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *constraintControlLabelWidth;
  85. @end
  86. @interface CommandClassSensorMultiLevelView : CommandClassSensorBinaryView
  87. @end
  88. @interface CommandClassMeterCurrentView : CommandClassControlView
  89. @property (weak, nonatomic) IBOutlet CustomLabel *lblMeter;
  90. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *constraintControlLabelWidth;
  91. @end
  92. @interface CommandClassMeterTotalView : CommandClassMeterCurrentView
  93. @end