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

Method Test

cpp/src/command_classes/Powerlevel.cpp:381–442  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Test node to node communications -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

379// Test node to node communications
380//-----------------------------------------------------------------------------
381bool Powerlevel::Test
382(
383 uint8 const _instance
384)
385{
386 uint8 testNodeId;
387 PowerLevelEnum powerLevel = PowerLevel_Normal;
388 uint16 numFrames;
389
390 if( ValueByte* value = static_cast<ValueByte*>( GetValue( _instance, PowerlevelIndex_TestNode ) ) )
391 {
392 testNodeId = value->GetValue();
393 value->Release();
394 }
395 else
396 {
397 return false;
398 }
399
400 if( ValueList* value = static_cast<ValueList*>( GetValue( _instance, PowerlevelIndex_TestPowerlevel ) ) )
401 {
402 ValueList::Item const *item = value->GetItem();
403 if (item != NULL)
404 powerLevel = (PowerLevelEnum)item->m_value;
405 value->Release();
406 }
407 else
408 {
409 return false;
410 }
411
412 if( ValueShort* value = static_cast<ValueShort*>( GetValue( _instance, PowerlevelIndex_TestFrames ) ) )
413 {
414 numFrames = value->GetValue();
415 value->Release();
416 }
417 else
418 {
419 return false;
420 }
421 if (powerLevel > 9) /* size of c_powerLevelNames minus Unknown */
422 {
423 Log::Write (LogLevel_Warning, GetNodeId(), "powerLevel Value was greater than range. Dropping");
424 return false;
425 }
426
427
428 Log::Write( LogLevel_Info, GetNodeId(), "Running a Power Level Test: Target Node = %d, Power Level = %s, Number of Frames = %d", testNodeId, c_powerLevelNames[powerLevel], numFrames );
429 Msg* msg = new Msg( "PowerlevelCmd_TestNodeSet", GetNodeId(), REQUEST, FUNC_ID_ZW_SEND_DATA, true, true, FUNC_ID_APPLICATION_COMMAND_HANDLER, GetCommandClassId() );
430 msg->SetInstance( this, _instance );
431 msg->Append( GetNodeId() );
432 msg->Append( 6 );
433 msg->Append( GetCommandClassId() );
434 msg->Append( PowerlevelCmd_TestNodeSet );
435 msg->Append( testNodeId );
436 msg->Append( (uint8)powerLevel );
437 msg->Append( (uint8)(numFrames >> 8) );
438 msg->Append( (uint8)(numFrames & 0x00ff) );

Callers

nothing calls this directly

Calls 9

WriteFunction · 0.85
GetCommandClassIdFunction · 0.85
GetItemMethod · 0.80
SendMsgMethod · 0.80
GetNodeIdFunction · 0.70
GetValueMethod · 0.45
ReleaseMethod · 0.45
SetInstanceMethod · 0.45
AppendMethod · 0.45

Tested by

no test coverage detected