MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / SetValue

Method SetValue

cpp/src/command_classes/Powerlevel.cpp:215–320  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Set a value on the Z-Wave device -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

213// Set a value on the Z-Wave device
214//-----------------------------------------------------------------------------
215bool Powerlevel::SetValue
216(
217 Value const& _value
218)
219{
220 bool res = false;
221 uint8 instance = _value.GetID().GetInstance();
222
223 switch( _value.GetID().GetIndex() )
224 {
225 case PowerlevelIndex_Powerlevel:
226 {
227 if( ValueList* value = static_cast<ValueList*>( GetValue( instance, PowerlevelIndex_Powerlevel ) ) )
228 {
229 ValueList::Item const *item = (static_cast<ValueList const*>( &_value))->GetItem();
230 if (item != NULL)
231 value->OnValueRefreshed( item->m_value );
232 value->Release();
233 }
234 res = true;
235 break;
236 }
237 case PowerlevelIndex_Timeout:
238 {
239 if( ValueByte* value = static_cast<ValueByte*>( GetValue( instance, PowerlevelIndex_Timeout ) ) )
240 {
241 value->OnValueRefreshed( (static_cast<ValueByte const*>( &_value))->GetValue() );
242 value->Release();
243 }
244 res = true;
245 break;
246 }
247 case PowerlevelIndex_Set:
248 {
249 // Set
250 if( ValueButton* button = static_cast<ValueButton*>( GetValue( instance, PowerlevelIndex_Set ) ) )
251 {
252 if( button->IsPressed() )
253 {
254 res = Set( instance );
255 }
256 button->Release();
257 }
258 break;
259 }
260 case PowerlevelIndex_TestNode:
261 {
262 if( ValueByte* value = static_cast<ValueByte*>( GetValue( instance, PowerlevelIndex_TestNode ) ) )
263 {
264 value->OnValueRefreshed( (static_cast<ValueByte const*>( &_value))->GetValue() );
265 value->Release();
266 }
267 res = true;
268 break;
269 }
270 case PowerlevelIndex_TestPowerlevel:
271 {
272 if( ValueList* value = static_cast<ValueList*>( GetValue( instance, PowerlevelIndex_TestPowerlevel ) ) )

Callers

nothing calls this directly

Calls 8

SetFunction · 0.85
GetInstanceMethod · 0.80
GetItemMethod · 0.80
IsPressedMethod · 0.80
TestClass · 0.50
OnValueRefreshedMethod · 0.45
ReleaseMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected