@@ -59,13 +59,6 @@ class DelegateBase
59
59
DelegateBase (){};
60
60
virtual ~DelegateBase () = default ;
61
61
62
- // TODO: Remove these
63
- virtual DataModel::Nullable<chip::Percent> HandleOpenValve (DataModel::Nullable<chip::Percent> level)
64
- {
65
- return DataModel::NullNullable;
66
- }
67
- virtual void HandleRemainingDurationTick (uint32_t duration) {}
68
-
69
62
// This delegate function will be called only for valve implementations that support the LVL feature.
70
63
// Delegates for valves that do not support the LVL feature return CHIP_ERROR_NOT_IMPLEMENTED.
71
64
// When this function is called, the delegate should set the valve to the target level, or begin the async process of opening
@@ -89,7 +82,7 @@ class DelegateBase
89
82
// When this function is called, the delegate should open the valve, or begin the async process of opening the valve.
90
83
// If the valve is able to be opened (success)
91
84
// - If the valve is fully open, currentState should be set to kOpen
92
- // - If the valve is not fully opened, the delegate should set the currentLevel to the current valve level and the caller
85
+ // - If the valve is not fully opened, the delegate should set the currentState to kTransitioning and the caller
93
86
// will continue to query the valve level until the target level is reached or the valve is closed.
94
87
// - A valve fault may be returned even if the Open command is successful, if the fault did not prevent the valve from safely
95
88
// opening
@@ -103,7 +96,41 @@ class DelegateBase
103
96
virtual Percent GetCurrentValveLevel () = 0;
104
97
// This delegate function will be called only for valve implementations that do not support the LVL feature.
105
98
virtual ValveStateEnum GetCurrentValveState () = 0;
106
- virtual CHIP_ERROR HandleCloseValve () = 0;
99
+
100
+ // This delegate function will be called when the valve needs to be closed either due to an explicit command or
101
+ // from the expiration of the open duration. This function will be called for valves that support the LVL feature.
102
+ // Delegates for valves that do not support the LVL feature should return CHIP_ERROR_NOT_IMPLEMENTED.
103
+ // When this function is called, the delegate should close the valve, or begin the async process of closing.
104
+ // If the valve is able to be closed (success)
105
+ // - the delegate should set currentLevel
106
+ // - If the valve is fully closed, currentLevel should be set to 0
107
+ // - If the valve is not fully closed, the delegate should set the currentLevel to the current valve level and the caller
108
+ // will continue to query the valve level until the valve reaches 0 or a command overrides.
109
+ // - A valve fault may be returned even if the Open command is successful, if the fault did not prevent the valve from safely
110
+ // closing
111
+ // - return CHIP_NO_ERROR
112
+ // If the valve cannot be closed (failure)
113
+ // - The delegate should set the valveFault parameter to indicate the reason for the failure (if applicable)
114
+ // - The delegate should return a CHIP_ERROR_INTERNAL
115
+ virtual CHIP_ERROR HandleCloseValve (Percent & currentLevel, BitMask<ValveFaultBitmap> & valveFault) = 0;
116
+
117
+ // This delegate function will be called when the valve needs to be closed either due to an explicit command or
118
+ // from the expiration of the open duration.
119
+ // This delegate function will be called only for valve implementations that DO NOT support the LVL feature.
120
+ // Delegates for valves that support the LVL feature should return CHIP_ERROR_NOT_IMPLEMENTED.
121
+ // When this function is called, the delegate should close the valve, or begin the async process of closing.
122
+ // If the valve is able to be closed (success)
123
+ // - If the valve is fully closed, currentState should be set to kClosed
124
+ // - If the valve is not fully opened, the delegate should set the currentLevel to the current valve level and the caller
125
+ // will continue to query the valve level until the target level is reached or the valve is closed.
126
+ // - A valve fault may be returned even if the Open command is successful, if the fault did not prevent the valve from safely
127
+ // opening
128
+ // - return CHIP_NO_ERROR
129
+ // If the valve cannot be safely opened (failure)
130
+ // - The delegate should set the valveFault parameter to indicate the reason for the failure (if applicable)
131
+ // - The delegate should return a CHIP_ERROR_INTERNAL
132
+ virtual CHIP_ERROR HandleCloseValve (ValveStateEnum & currentState, BitMask<ValveFaultBitmap> & valveFault) = 0;
133
+
107
134
virtual DelegateType GetDelegateType () { return DelegateType::kBase ; };
108
135
};
109
136
@@ -112,26 +139,38 @@ class LevelControlDelegate : public DelegateBase
112
139
virtual CHIP_ERROR HandleOpenValve (const Percent targetLevel, Percent & currentLevel,
113
140
BitMask<ValveFaultBitmap> & valveFault) = 0;
114
141
115
- virtual Percent GetCurrentValveLevel () = 0;
142
+ virtual Percent GetCurrentValveLevel () = 0;
143
+ virtual CHIP_ERROR HandleCloseValve (Percent & currentLevel, BitMask<ValveFaultBitmap> & valveFault) = 0;
116
144
117
145
// Final overrides - the driver should not implement these classes
118
146
CHIP_ERROR HandleOpenValve (ValveStateEnum & currentState, BitMask<ValveFaultBitmap> & valveFault) final
119
147
{
120
148
return CHIP_ERROR_NOT_IMPLEMENTED;
121
149
}
150
+ CHIP_ERROR HandleCloseValve (ValveStateEnum & currentState, BitMask<ValveFaultBitmap> & valveFault) final
151
+ {
152
+ return CHIP_ERROR_NOT_IMPLEMENTED;
153
+ }
154
+
122
155
ValveStateEnum GetCurrentValveState () final { return ValveStateEnum::kUnknownEnumValue ; }
123
156
DelegateType GetDelegateType () final { return DelegateType::kLevel ; };
124
157
};
125
158
126
159
class NonLevelControlDelegate : public DelegateBase
127
160
{
128
- virtual CHIP_ERROR HandleOpenValve (ValveStateEnum & currentState, BitMask<ValveFaultBitmap> & valveFault) = 0;
129
- virtual ValveStateEnum GetCurrentValveState () = 0;
161
+ virtual CHIP_ERROR HandleOpenValve (ValveStateEnum & currentState, BitMask<ValveFaultBitmap> & valveFault) = 0;
162
+ virtual ValveStateEnum GetCurrentValveState () = 0;
163
+ virtual CHIP_ERROR HandleCloseValve (ValveStateEnum & currentState, BitMask<ValveFaultBitmap> & valveFault) = 0;
130
164
131
165
CHIP_ERROR HandleOpenValve (const Percent targetLevel, Percent & currentLevel, BitMask<ValveFaultBitmap> & valveFault) final
132
166
{
133
167
return CHIP_ERROR_NOT_IMPLEMENTED;
134
168
}
169
+ CHIP_ERROR HandleCloseValve (Percent & currentLevel, BitMask<ValveFaultBitmap> & valveFault) final
170
+ {
171
+ return CHIP_ERROR_NOT_IMPLEMENTED;
172
+ }
173
+
135
174
Percent GetCurrentValveLevel () final { return 0 ; }
136
175
DelegateType GetDelegateType () final { return DelegateType::kNonLevel ; };
137
176
};
0 commit comments