| 308 | } |
| 309 | |
| 310 | XnStatus GeneratorWatcher::Watch() |
| 311 | { |
| 312 | XnStatus nRetVal = XN_STATUS_OK; |
| 313 | |
| 314 | nRetVal = NodeWatcher::Watch(); |
| 315 | XN_IS_STATUS_OK(nRetVal); |
| 316 | |
| 317 | XnUInt64 nCurrentTimeStamp = m_generator.GetTimestamp(); |
| 318 | XnUInt32 nCurrentFrameID = m_generator.GetFrameID(); |
| 319 | |
| 320 | // check if timestamp has changed since last time. |
| 321 | // Note that the first frame might have a timestamp of zero, so also make sure frame ID changes |
| 322 | if ((nCurrentTimeStamp > m_nLastDataTimeStamp) || |
| 323 | (nCurrentFrameID > m_nLastDataFrameID)) |
| 324 | { |
| 325 | m_nLastDataTimeStamp = nCurrentTimeStamp; |
| 326 | m_nLastDataFrameID = nCurrentFrameID; |
| 327 | |
| 328 | const void* pData = GetCurrentData(); |
| 329 | if (pData != NULL) |
| 330 | { |
| 331 | nRetVal = m_notifications.OnNodeNewData(m_pCookie, |
| 332 | m_generator.GetName(), |
| 333 | nCurrentTimeStamp, |
| 334 | m_generator.GetFrameID(), |
| 335 | pData, |
| 336 | m_generator.GetDataSize()); |
| 337 | XN_IS_STATUS_OK(nRetVal); |
| 338 | } |
| 339 | } |
| 340 | return XN_STATUS_OK; |
| 341 | } |
| 342 | |
| 343 | XnUInt64 GeneratorWatcher::GetTimestamp() |
| 344 | { |
no test coverage detected