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

Method QueueMsg

cpp/src/command_classes/WakeUp.cpp:390–430  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Add a Z-Wave message to the queue -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

388// Add a Z-Wave message to the queue
389//-----------------------------------------------------------------------------
390void WakeUp::QueueMsg
391(
392 Driver::MsgQueueItem const& _item
393)
394{
395 m_mutex->Lock();
396
397 // See if there is already a copy of this message in the queue. If so,
398 // we delete it. This is to prevent duplicates building up if the
399 // device does not wake up very often. Deleting the original and
400 // adding the copy to the end avoids problems with the order of
401 // commands such as on and off.
402 list<Driver::MsgQueueItem>::iterator it = m_pendingQueue.begin();
403 while( it != m_pendingQueue.end() )
404 {
405 Driver::MsgQueueItem const& item = *it;
406 if( item == _item )
407 {
408 // Duplicate found
409 if( Driver::MsgQueueCmd_SendMsg == item.m_command )
410 {
411 delete item.m_msg;
412 }
413 else if( Driver::MsgQueueCmd_Controller == item.m_command )
414 {
415 delete item.m_cci;
416 }
417 m_pendingQueue.erase( it++ );
418 }
419 else
420 {
421 ++it;
422 }
423 }
424 /* make sure the SendAttempts is reset to 0 */
425 if (_item.m_command == Driver::MsgQueueCmd_SendMsg)
426 _item.m_msg->SetSendAttempts(0);
427
428 m_pendingQueue.push_back( _item );
429 m_mutex->Unlock();
430}
431
432//-----------------------------------------------------------------------------
433// <WakeUp::SendPending>

Callers 4

SendMsgMethod · 0.80
refreshNodeConfigMethod · 0.80

Calls 4

LockMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected