CommandClassControlView.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 32.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, _isMandatoryNode;
  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. @property (assign, nonatomic) BOOL isMandatoryNode;
  32. + (CommandClassControlView *)viewForCommandClass:(CmdClsType)cmdClsType;
  33. - (void)requestNodeCommand:(NSDictionary *)parameters requestValue:(NSString *)requestValue completionHandler:(NodeCommandCompletionBlock)completion failureHandler:(NodeCommandFailureBlock)failure;
  34. - (NSDictionary *)parameterForNodeCommand;
  35. - (CGSize)sizeForIntrinsic;
  36. - (CGSize)sizeForIntrinsicForItemCount:(NSInteger)count;
  37. - (void)setLayoutUI;
  38. - (void)updateLayout;
  39. - (void)updateThingsViewContoller;
  40. + (NSString *)cmdclsValueForType:(NSString *)dataTypeCode value:(CGFloat)value;
  41. @end
  42. @class CustomSwitch;
  43. @class CustomButton;
  44. @interface CommandClassSwitchView : CommandClassControlView {
  45. @protected
  46. BOOL _isON;
  47. __weak CustomLabel *_lblContentValueMsg;
  48. NSString *_requestValueForOn, *_requestValueForOff;
  49. __weak NSLayoutConstraint *_constraintBtnSwitchWidth;
  50. }
  51. @property (assign, nonatomic) BOOL isON;
  52. @property (weak, nonatomic) IBOutlet CustomButton *btnSwitch;
  53. @property (weak, nonatomic) IBOutlet CustomLabel *lblContentValueMsg;
  54. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *constraintBtnSwitchWidth;
  55. - (IBAction)btnSwitchTouched:(id)sender;
  56. @end
  57. @interface CommandClassSwitchMultiLevelView : CommandClassControlView {
  58. NSTimer *_pressTimer;
  59. @protected
  60. CGFloat _minValue, _maxValue, _currentValue, _step;
  61. }
  62. @property (weak, nonatomic) IBOutlet CustomButton *btnLabel;
  63. @property (weak, nonatomic) IBOutlet CustomButton *btnPlus;
  64. @property (weak, nonatomic) IBOutlet CustomButton *btnMinus;
  65. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *constraintBtnLabelWidth;
  66. - (IBAction)btnPlusTouchDown:(id)sender;
  67. - (IBAction)btnPlusTouchUp:(id)sender;
  68. - (IBAction)btnMinusTouchDown:(id)sender;
  69. - (IBAction)btnMinusTouchUp:(id)sender;
  70. @end
  71. @interface CommandClassValveView : CommandClassControlView {
  72. @protected
  73. BOOL _isOpened;
  74. __weak CustomLabel *_lblContentValueMsg;
  75. NSString *_requestValueForOpen, *_requestValueForClose;
  76. __weak NSLayoutConstraint *_constraintBtnWidth;
  77. }
  78. @property (assign, nonatomic) BOOL isOpened;
  79. @property (weak, nonatomic) IBOutlet CustomButton *btnOpen;
  80. @property (weak, nonatomic) IBOutlet CustomLabel *lblContentValueMsg;
  81. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *constraintBtnWidth;
  82. - (IBAction)btnOpenTouched:(id)sender;
  83. @end
  84. #pragma mark - Sensors
  85. @class CustomLabel;
  86. @interface CommandClassSensorBinaryView : CommandClassControlView {
  87. @protected
  88. __weak CustomLabel *_lblControl;
  89. }
  90. @property (weak, nonatomic) IBOutlet CustomLabel *lblControl;
  91. @end
  92. @interface CommandClassSensorMultiLevelView : CommandClassSensorBinaryView
  93. @end
  94. @interface CommandClassMeterCurrentView : CommandClassControlView
  95. @property (weak, nonatomic) IBOutlet CustomLabel *lblMeter;
  96. @end
  97. @interface CommandClassMeterTotalView : CommandClassMeterCurrentView
  98. @end