First, I briefly describe my code. My code collect data in 30Hz. If I use Ontimer, the code is no problem but when I use Multimedia timer, my code have an error:
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\wincore.cpp
Line: 946
This is my code (Not fully):
LONG CPredOTSDlg::nGetSystemTransformData( UINT wParam, LONG lParam )
{
char pszTemp[256];
CString szCBHandle, szPortNo;
int nRow = -1;
Rotation dtEulerRot;
if (!m_bIsTracking)
return 0;
#if 0
if ( m_nTrackingMode == 0 )
{
if ( !pCommandHandling->nGetTXTransforms( m_bUse0x0800Option ? true : false ) )
return 0;
}
else if ( m_nTrackingMode == 1 )
{
if ( !pCommandHandling->nGetBXTransforms( m_bUse0x0800Option ? true : false ) )
return 0;
}
#else
if ( !pCommandHandling->nGetTXTransforms( false ) )
return 0;
#endif
if ( pCommandHandling->m_dtSystemInformation.bPortOccupied )
{
if ( pCommandHandling->nStopTracking() &&
nActivatePorts() &&
pCommandHandling->nStartTracking() )
{
return 1;
}
m_bStopTracking = true;
m_bIsTracking = FALSE;
return 0;
}
for ( int i = 0; i < NO_HANDLES; i ++ )
{
if ( pCommandHandling->m_dtHandleInformation[i].HandleInfo.bInitialized > 0 &&
pCommandHandling->m_dtHandleInformation[i].szToolType[1] != _T('8') )
{
if ( pCommandHandling->m_dtHandleInformation[i].Xfrms.ulFlags == TRANSFORM_VALID ||
pCommandHandling->m_dtHandleInformation[i].Xfrms.ulFlags == TRANSFORM_MISSING )
{
UpdateData(false);
}
if( i == pCommandHandling->m_nRefHandle )
sprintf( pszTemp, _T("R%02X"), i );
else
sprintf( pszTemp, _T("%02X"), i );
#if 0
for ( int j = nRow+1; j < m_ctlTrackingList.GetItemCount(); j++ )
{
szPortNo = m_ctlTrackingList.GetItemText( j, 1 );
if ( pCommandHandling->m_dtHandleInformation[i].szPhysicalPort == szPortNo )
{
nRow = j;
break;
}
}
#endif
if ( pCommandHandling->m_dtHandleInformation[i].Xfrms.ulFlags == TRANSFORM_VALID )
{
sprintf( pszTemp, _T("%.2f"),
pCommandHandling->m_dtHandleInformation[i].Xfrms.translation.x );
sprintf( pszTemp, _T("%.2f"),
pCommandHandling->m_dtHandleInformation[i].Xfrms.translation.y );
sprintf( pszTemp, _T("%.2f"),
pCommandHandling->m_dtHandleInformation[i].Xfrms.translation.z );
if( !m_bUseEulerAngles )
{
sprintf( pszTemp, _T("%.4f"),
pCommandHandling->m_dtHandleInformation[i].Xfrms.rotation.q0 );
sprintf( pszTemp, _T("%.4f"),
pCommandHandling->m_dtHandleInformation[i].Xfrms.rotation.qx );
sprintf( pszTemp, _T("%.4f"),
pCommandHandling->m_dtHandleInformation[i].Xfrms.rotation.qy );
sprintf( pszTemp, _T("%.4f"),
pCommandHandling->m_dtHandleInformation[i].Xfrms.rotation.qz );
}
else
{
CvtQuatToEulerRotation( &pCommandHandling->m_dtHandleInformation[i].Xfrms.rotation,
&dtEulerRot );
sprintf( pszTemp, _T("%.4f"), dtEulerRot.fYaw );
sprintf( pszTemp, _T("%.4f"), dtEulerRot.fPitch );
sprintf( pszTemp, _T("%.4f"), dtEulerRot.fRoll );
sprintf( pszTemp, _T("") );
}
sprintf( pszTemp, _T("%.4f"),
pCommandHandling->m_dtHandleInformation[i].Xfrms.fError );
#if 0
if ( pCommandHandling->m_dtHandleInformation[i].HandleInfo.bPartiallyOutOfVolume )
else if ( pCommandHandling->m_dtHandleInformation[i].HandleInfo.bOutOfVolume )
else
#endif
if(i == 1)
{
m_GantryX.px = pCommandHandling->m_dtHandleInformation[i].Xfrms.translation.x;
m_GantryX.py = pCommandHandling->m_dtHandleInformation[i].Xfrms.translation.y;
m_GantryX.pz = pCommandHandling->m_dtHandleInformation[i].Xfrms.translation.z;
m_GantryX.rx = dtEulerRot.fYaw;
m_GantryX.ry = dtEulerRot.fPitch;
m_GantryX.rz = dtEulerRot.fRoll;
CvtQuatToRotationMatrix(&pCommandHandling->m_dtHandleInformation[i].Xfrms.rotation,m_motgRM);
}
else if(i == 2)
{
m_MeasuredX.px = pCommandHandling->m_dtHandleInformation[i].Xfrms.translation.x;
m_MeasuredX.py = pCommandHandling->m_dtHandleInformation[i].Xfrms.translation.y;
m_MeasuredX.pz = pCommandHandling->m_dtHandleInformation[i].Xfrms.translation.z;
m_MeasuredX.rx = dtEulerRot.fYaw;
m_MeasuredX.ry = dtEulerRot.fPitch;
m_MeasuredX.rz = dtEulerRot.fRoll;
CvtQuatToRotationMatrix(&pCommandHandling->m_dtHandleInformation[i].Xfrms.rotation,m_motxRM);
}
}
#if 0
else
{
if ( pCommandHandling->m_dtHandleInformation[i].Xfrms.ulFlags == TRANSFORM_MISSING )
m_ctlTrackingList.SetItemText( nRow, 2, _T("MISSING") );
else
{
m_ctlTrackingList.SetItemText( nRow, 2, _T("DISABLED") );
if (m_ctlPortHandleCB.GetCurSel() >= 0)
{
m_ctlPortHandleCB.GetLBText( m_ctlPortHandleCB.GetCurSel(), szCBHandle );
if ( !(strncmp( (LPSTR) (LPCSTR)szCBHandle, pszTemp, 2 )) &&
pCommandHandling->m_dtHandleInformation[i].HandleInfo.bEnabled )
{
m_szManufID = _T("");
m_bPortEnabled = FALSE;
m_bPortInitialized = FALSE;
m_szSerialNo = _T("");
m_szToolRev = _T("");
m_szToolType = _T("");
m_szPartNumber = _T("");
UpdateData(false);
}
}
}
m_ctlTrackingList.SetItemText( nRow, 3, _T("---") );
m_ctlTrackingList.SetItemText( nRow, 4, _T("---") );
m_ctlTrackingList.SetItemText( nRow, 5, _T("---") );
m_ctlTrackingList.SetItemText( nRow, 6, _T("---") );
m_ctlTrackingList.SetItemText( nRow, 7, _T("---") );
if( !m_bUseEulerAngles )
m_ctlTrackingList.SetItemText( nRow, 8, _T("---") );
else
m_ctlTrackingList.SetItemText( nRow, 8, _T("") );
m_ctlTrackingList.SetItemText( nRow, 9, _T("---") );
if ( pCommandHandling->m_dtHandleInformation[i].HandleInfo.bPartiallyOutOfVolume )
m_ctlTrackingList.SetItemText( nRow, 10, _T("POOV") );
else if ( pCommandHandling->m_dtHandleInformation[i].HandleInfo.bOutOfVolume )
m_ctlTrackingList.SetItemText( nRow, 10, _T("OOV") );
else
m_ctlTrackingList.SetItemText( nRow, 10, _T("---") );
}
#endif
}
}
return 1;
}
And when debugging it creates a breakpoint at line
if( i == pCommandHandling->m_nRefHandle )
sprintf( pszTemp, _T("R%02X"), i );
else
sprintf( pszTemp, _T("%02X"), i );
Here, is my callback function
void CALLBACK TimeProc(UINT wTimerID, UINT msg, DWORD dwUser, DWORD dw1, DWORD dw2)
{
CCriticalSection cs;
CPredOTSDlg* obj = (CPredOTSDlg*) dwUser;
cs.Lock();
obj->nGetSystemTransformData(0,0);
cs.Unlock();
}
How can I solve this problem?