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

Method SetValue

cpp/src/command_classes/SwitchMultilevel.cpp:318–449  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Set the level on a device -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

316// Set the level on a device
317//-----------------------------------------------------------------------------
318bool SwitchMultilevel::SetValue
319(
320 Value const& _value
321)
322{
323 bool res = false;
324 uint8 instance = _value.GetID().GetInstance();
325
326 switch( _value.GetID().GetIndex() )
327 {
328 case SwitchMultilevelIndex_Level:
329 {
330 // Level
331 if( ValueByte* value = static_cast<ValueByte*>( GetValue( instance, SwitchMultilevelIndex_Level ) ) )
332 {
333 res = SetLevel( instance, (static_cast<ValueByte const*>(&_value))->GetValue() );
334 value->Release();
335 }
336 break;
337 }
338 case SwitchMultilevelIndex_Bright:
339 {
340 // Bright
341 if( ValueButton* button = static_cast<ValueButton*>( GetValue( instance, SwitchMultilevelIndex_Bright ) ) )
342 {
343 if( button->IsPressed() )
344 {
345 res = StartLevelChange( instance, SwitchMultilevelDirection_Up );
346 }
347 else
348 {
349 res = StopLevelChange( instance );
350 }
351 button->Release();
352 }
353 break;
354 }
355 case SwitchMultilevelIndex_Dim:
356 {
357 // Dim
358 if( ValueButton* button = static_cast<ValueButton*>( GetValue( instance, SwitchMultilevelIndex_Dim ) ) )
359 {
360 if( button->IsPressed() )
361 {
362 res = StartLevelChange( instance, SwitchMultilevelDirection_Down );
363 }
364 else
365 {
366 res = StopLevelChange( instance );
367 }
368 button->Release();
369 }
370 break;
371 }
372 case SwitchMultilevelIndex_IgnoreStartLevel:
373 {
374 if( ValueBool* value = static_cast<ValueBool*>( GetValue( instance, SwitchMultilevelIndex_IgnoreStartLevel ) ) )
375 {

Callers

nothing calls this directly

Calls 5

GetInstanceMethod · 0.80
IsPressedMethod · 0.80
GetValueMethod · 0.45
ReleaseMethod · 0.45
OnValueRefreshedMethod · 0.45

Tested by

no test coverage detected