mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-18 19:39:43 +08:00
修改了电机运动判断函数,添加了尝试机制。其他小bug/同步等修改。测试版本号:beta 1.0
This commit is contained in:
@ -86,6 +86,7 @@ bool DataFileProcessor::WriteEnvironmentInfo()
|
||||
qfData.write("EnvironmentalContext,");
|
||||
qfData.write("DEV_SN,");
|
||||
qfData.write(m_struEC.qstrDEV_SN.toLatin1());
|
||||
qfData.write(",");
|
||||
qfData.write("CaseHumidity,");
|
||||
qfData.write(m_struEC.qstrCaseHumidity.toLatin1());
|
||||
qfData.write(",");
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -107,6 +107,8 @@ int CAbstractFSController::PerformAutoExposure()
|
||||
float fPredictedExposureTime;
|
||||
int iDeviceDepth = (int)m_fsInfo.lDepth;
|
||||
|
||||
qDebug() << "MAX---Min" << m_fsInfo.fMaxFactor << "---" << m_fsInfo.fMinFactor;
|
||||
|
||||
bool bFlagIsOverTrying = false;
|
||||
bool bFlagIsLowerMinExposureTime = false;
|
||||
bool bFlagIsOverMaxExposureTime = false;
|
||||
@ -163,6 +165,8 @@ int CAbstractFSController::PerformAutoExposure()
|
||||
}
|
||||
double dTemp = dSum / iCount;
|
||||
|
||||
qDebug() << "Avg " << dTemp;
|
||||
|
||||
if (dTemp >= iDeviceDepth * 0.99)
|
||||
{
|
||||
bIsValueOverflow = true;
|
||||
@ -178,6 +182,7 @@ int CAbstractFSController::PerformAutoExposure()
|
||||
|
||||
else if (iDeviceDepth * m_fsInfo.fMaxFactor >= dTemp && dTemp >= iDeviceDepth * m_fsInfo.fMinFactor)
|
||||
{
|
||||
qDebug() << "trace bFlagIsAutoExposureOK =1" << iExposureTime;
|
||||
bFlagIsAutoExposureOK = 1;
|
||||
}
|
||||
else if (dTemp > iDeviceDepth * m_fsInfo.fMaxFactor)
|
||||
@ -305,7 +310,7 @@ int CAbstractFSController::StartAcquisitionSignal()
|
||||
|
||||
|
||||
|
||||
//PerformAutoExposure();
|
||||
PerformAutoExposure();
|
||||
TakeSignalFrame();
|
||||
|
||||
qDebug() << "Stop acq Signal" << " Thread ID:" << m_iThreadID;
|
||||
|
@ -27,7 +27,7 @@ void Scheduler::Preheating()
|
||||
#ifdef _DEBUG
|
||||
QThread::msleep(5000);
|
||||
#else
|
||||
QThread::msleep(1000*60*5);
|
||||
QThread::msleep(10000);//NEED TO CHANGE BEFOR HAND TO CUSTOM
|
||||
#endif
|
||||
qDebug() << "Preheating Finished";
|
||||
}
|
||||
|
0
source/Upload/DataFileTransfer.cpp
Normal file
0
source/Upload/DataFileTransfer.cpp
Normal file
3
source/Upload/DataFileTransfer.h
Normal file
3
source/Upload/DataFileTransfer.h
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#include "ZZ_Types.h"
|
Reference in New Issue
Block a user