----------------------------------------------------------------------------- Add a Z-Wave message to the queue -----------------------------------------------------------------------------
| 388 | // Add a Z-Wave message to the queue |
| 389 | //----------------------------------------------------------------------------- |
| 390 | void 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> |
no test coverage detected