CommandClassControlView.h 4.3 KB

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