----------------------------------------------------------------------------- Set whether the device is likely to be awake -----------------------------------------------------------------------------
| 340 | // Set whether the device is likely to be awake |
| 341 | //----------------------------------------------------------------------------- |
| 342 | void WakeUp::SetAwake |
| 343 | ( |
| 344 | bool _state |
| 345 | ) |
| 346 | { |
| 347 | if( m_awake != _state ) |
| 348 | { |
| 349 | /* we do the call on RefreshValuesOnWakeup here, so any duplicates in the wakeup Queue are handled appropriately |
| 350 | * |
| 351 | */ |
| 352 | if ( m_awake == false ) { |
| 353 | Node* node = GetNodeUnsafe(); |
| 354 | if (node) |
| 355 | node->RefreshValuesOnWakeup(); |
| 356 | } |
| 357 | |
| 358 | m_awake = _state; |
| 359 | Log::Write( LogLevel_Info, GetNodeId(), " Node %d has been marked as %s", GetNodeId(), m_awake ? "awake" : "asleep" ); |
| 360 | Notification* notification = new Notification( Notification::Type_Notification ); |
| 361 | notification->SetHomeAndNodeIds( GetHomeId(), GetNodeId() ); |
| 362 | notification->SetNotification( m_awake ? Notification::Code_Awake : Notification::Code_Sleep ); |
| 363 | GetDriver()->QueueNotification( notification ); |
| 364 | |
| 365 | } |
| 366 | |
| 367 | if( m_awake ) |
| 368 | { |
| 369 | // If the device is marked for polling, request the current state |
| 370 | Node* node = GetNodeUnsafe(); |
| 371 | if( m_pollRequired ) |
| 372 | { |
| 373 | if( node != NULL ) |
| 374 | { |
| 375 | node->SetQueryStage( Node::QueryStage_Dynamic ); |
| 376 | } |
| 377 | m_pollRequired = false; |
| 378 | } |
| 379 | // Send all pending messages |
| 380 | SendPending(); |
| 381 | |
| 382 | |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | //----------------------------------------------------------------------------- |
| 387 | // <WakeUp::QueueMsg> |
no test coverage detected