----------------------------------------------------------------------------- Check polling status of a value -----------------------------------------------------------------------------
| 4356 | // Check polling status of a value |
| 4357 | //----------------------------------------------------------------------------- |
| 4358 | bool Driver::isPolled |
| 4359 | ( |
| 4360 | ValueID const &_valueId |
| 4361 | ) |
| 4362 | { |
| 4363 | bool bPolled; |
| 4364 | |
| 4365 | // make sure the polling thread doesn't lock the node while we're in this function |
| 4366 | m_pollMutex->Lock(); |
| 4367 | |
| 4368 | Value* value = GetValue( _valueId ); |
| 4369 | if( value && value->GetPollIntensity() != 0 ) |
| 4370 | { |
| 4371 | bPolled = true; |
| 4372 | } |
| 4373 | else |
| 4374 | { |
| 4375 | bPolled = false; |
| 4376 | } |
| 4377 | |
| 4378 | if (value) value->Release(); |
| 4379 | |
| 4380 | /* |
| 4381 | * This code is retained for the moment as a belt-and-suspenders test to confirm that |
| 4382 | * the pollIntensity member of each value and the pollList contents do not get out |
| 4383 | * of sync. |
| 4384 | */ |
| 4385 | // confirm that this node exists |
| 4386 | uint8 nodeId = _valueId.GetNodeId(); |
| 4387 | LockGuard LG(m_nodeMutex); |
| 4388 | Node* node = GetNode( nodeId ); |
| 4389 | if( node != NULL) |
| 4390 | { |
| 4391 | |
| 4392 | // See if the value is already in the poll list. |
| 4393 | for( list<PollEntry>::iterator it = m_pollList.begin(); it != m_pollList.end(); ++it ) |
| 4394 | { |
| 4395 | if( (*it).m_id == _valueId ) |
| 4396 | { |
| 4397 | // Found it |
| 4398 | if( bPolled ) |
| 4399 | { |
| 4400 | m_pollMutex->Unlock(); |
| 4401 | return true; |
| 4402 | } |
| 4403 | else |
| 4404 | { |
| 4405 | Log::Write( LogLevel_Error, nodeId, "IsPolled setting for valueId 0x%016x is not consistent with the poll list", _valueId.GetId() ); |
| 4406 | } |
| 4407 | } |
| 4408 | } |
| 4409 | |
| 4410 | // Not in the list |
| 4411 | |
| 4412 | if( !bPolled ) |
| 4413 | { |
| 4414 | m_pollMutex->Unlock(); |
| 4415 | return false; |