mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-19 03:49:42 +08:00
合并提交
This commit is contained in:
@ -80,22 +80,65 @@ void CVSMD12XControl::ILMES_SetPosition(int *piPositionInPulse, size_t szSize)
|
||||
|
||||
bool CVSMD12XControl::ILMES_MoveToPos(int iPositionIndex)
|
||||
{
|
||||
bool bFlagFailed = true;
|
||||
bool bRes = false;
|
||||
bRes = CVSMD12XControl::StartBackZero();
|
||||
if (!bRes)
|
||||
int iCount = 0;
|
||||
|
||||
for (int i=0;i<3;i++)
|
||||
{
|
||||
if (CVSMD12XControl::StartBackZero())
|
||||
{
|
||||
bFlagFailed = false;
|
||||
break;
|
||||
}
|
||||
while (!bRes)
|
||||
{
|
||||
iCount++;
|
||||
bRes = StopBackZero();
|
||||
if (iCount>10)
|
||||
{
|
||||
qDebug() << "StopBackZero Err.Give up...";
|
||||
bRes = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bFlagFailed)
|
||||
{
|
||||
qDebug() << "StartBackZero Err";
|
||||
return false;
|
||||
}
|
||||
|
||||
bRes = CVSMD12XControl::MoveTo(m_piPositionInPulses[iPositionIndex]);
|
||||
if (!bRes)
|
||||
bFlagFailed = true;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (MoveTo(m_piPositionInPulses[iPositionIndex]))
|
||||
{
|
||||
bFlagFailed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bFlagFailed)
|
||||
{
|
||||
qDebug() << "MoveTo Err";
|
||||
return false;
|
||||
}
|
||||
|
||||
return bRes;
|
||||
return true;
|
||||
|
||||
// bool bRes = false;
|
||||
// bRes = CVSMD12XControl::StartBackZero();
|
||||
// if (!bRes)
|
||||
// {
|
||||
// qDebug() << "StartBackZero Err";
|
||||
// return false;
|
||||
// }
|
||||
// bRes = CVSMD12XControl::MoveTo(m_piPositionInPulses[iPositionIndex]);
|
||||
// if (!bRes)
|
||||
// {
|
||||
// qDebug() << "MoveTo Err";
|
||||
// return false;
|
||||
// }
|
||||
// return bRes;
|
||||
}
|
||||
|
||||
void CVSMD12XControl::SetProtocolType(int iProtocolType /*= 0*/)
|
||||
@ -306,20 +349,20 @@ bool CVSMD12XControl::MoveTo(int iAbsPulse)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bFlagIsStopped = false;
|
||||
while (!bFlagIsStopped)
|
||||
{
|
||||
QThread::msleep(200);
|
||||
//Delay_MSec(200);
|
||||
GetStatus(m_stuMSInfo);
|
||||
ZZ_U8 ucFlag = m_stuMSInfo.uiFlags & 0x000000FF;
|
||||
ucFlag = ucFlag & 0x10;
|
||||
if (ucFlag == 0x10 && m_stuMSInfo.fVelocity == 0)
|
||||
{
|
||||
bFlagIsStopped = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
// bool bFlagIsStopped = false;
|
||||
// while (!bFlagIsStopped)
|
||||
// {
|
||||
// QThread::msleep(200);
|
||||
// //Delay_MSec(200);
|
||||
// GetStatus(m_stuMSInfo);
|
||||
// ZZ_U8 ucFlag = m_stuMSInfo.uiFlags & 0x000000FF;
|
||||
// ucFlag = ucFlag & 0x10;
|
||||
// if (ucFlag == 0x10 && m_stuMSInfo.fVelocity == 0)
|
||||
// {
|
||||
// bFlagIsStopped = true;
|
||||
// }
|
||||
// }
|
||||
return IsMotionFinished();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -382,20 +425,21 @@ bool CVSMD12XControl::StartBackZero()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bFlagIsStopped = false;
|
||||
while (!bFlagIsStopped)
|
||||
{
|
||||
QThread::msleep(200);
|
||||
//Delay_MSec(200);
|
||||
GetStatus(m_stuMSInfo);
|
||||
ZZ_U8 ucFlag = m_stuMSInfo.uiFlags & 0x000000FF;
|
||||
ucFlag = ucFlag & 0x10;
|
||||
if (ucFlag == 0x10 && m_stuMSInfo.fVelocity == 0)
|
||||
{
|
||||
bFlagIsStopped = true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return IsMotionFinished();
|
||||
// bool bFlagIsStopped = false;
|
||||
// while (!bFlagIsStopped)
|
||||
// {
|
||||
// QThread::msleep(200);
|
||||
// //Delay_MSec(200);
|
||||
// GetStatus(m_stuMSInfo);
|
||||
// ZZ_U8 ucFlag = m_stuMSInfo.uiFlags & 0x000000FF;
|
||||
// ucFlag = ucFlag & 0x10;
|
||||
// if (ucFlag == 0x10 && m_stuMSInfo.fVelocity == 0)
|
||||
// {
|
||||
// bFlagIsStopped = true;
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// return ParseReturnedString(strRecv, -1);
|
||||
|
||||
}
|
||||
@ -1374,6 +1418,50 @@ char* CVSMD12XControl::VSMD_Split(char* cStr, char cSplit)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CVSMD12XControl::IsMotionFinished()
|
||||
{
|
||||
//true means stopped
|
||||
//false means unknown status
|
||||
int iCountTotal = 0;
|
||||
int iCountStopped = 0;
|
||||
bool bFlagIsStopped = false;
|
||||
|
||||
while (!bFlagIsStopped)
|
||||
{
|
||||
iCountTotal++;
|
||||
QThread::msleep(200);
|
||||
//Delay_MSec(200);
|
||||
GetStatus(m_stuMSInfo);
|
||||
ZZ_U8 ucFlag = m_stuMSInfo.uiFlags & 0x000000FF;
|
||||
ucFlag = ucFlag & 0x10;
|
||||
if (m_stuMSInfo.fVelocity == 0)
|
||||
{
|
||||
iCountStopped++;
|
||||
}
|
||||
if (ucFlag == 0x10 && m_stuMSInfo.fVelocity == 0)
|
||||
{
|
||||
bFlagIsStopped = true;
|
||||
return true;
|
||||
}
|
||||
if (iCountStopped>=50)
|
||||
{
|
||||
qDebug() <<"Warning.Motion Err,should be stopped already.checking register and retry...";
|
||||
qDebug() <<"motion status:"<<ucFlag<<"all status:"<<QString::number(m_stuMSInfo.uiFlags,2);
|
||||
bFlagIsStopped = true;
|
||||
return false;
|
||||
}
|
||||
if (iCountTotal>1000)
|
||||
{
|
||||
qDebug() << "Err.Motor Hardware Err,should be stopped already";
|
||||
qDebug() << "motion status:" << ucFlag << "all status:" << QString::number(m_stuMSInfo.uiFlags, 2);
|
||||
bFlagIsStopped = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
void CVSMD12XControl::Delay_MSec(ZZ_U16 usMS)
|
||||
{
|
||||
QEventLoop qeLoop;
|
||||
|
@ -139,7 +139,8 @@ private:
|
||||
bool ParseReturnedParam(std::string &strRecv);
|
||||
void VSMD_BitShift(ZZ_U8* src, unValue* dst);
|
||||
char* VSMD_Split(char* cStr, char cSplit);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////sync
|
||||
bool IsMotionFinished();
|
||||
//////////////////////////////////////////////////////////////////////////qt
|
||||
void Delay_MSec(ZZ_U16 usMS);
|
||||
};
|
||||
|
Reference in New Issue
Block a user