diff --git a/CmakeLists.txt b/CmakeLists.txt index 3516327..6ac4387 100644 --- a/CmakeLists.txt +++ b/CmakeLists.txt @@ -21,6 +21,7 @@ include_directories("source/Thread") include_directories("source/LinearShutter") include_directories("source/OSIF/include") include_directories("source/Misc_Detector") +include_directories("source/Upload") link_directories("source/OSIF/DLib") diff --git a/main.cpp b/main.cpp index 98fd4b5..3962026 100644 --- a/main.cpp +++ b/main.cpp @@ -36,7 +36,7 @@ int main(int argc, char *argv[]) MEContext m_struMEC; HumitureDeviceInfo m_struHumitureDI; //////////////////////////////////////////////////////////////////////////logger - //QT_LOG::ZZ_InitLogger(QCoreApplication::applicationDirPath() + "/Log/"); + QT_LOG::ZZ_InitLogger("/home/data/Log/"); //m_test123; diff --git a/source/FS/DataFileProcessor.cpp b/source/FS/DataFileProcessor.cpp index 3cbcb08..8ea81bd 100644 --- a/source/FS/DataFileProcessor.cpp +++ b/source/FS/DataFileProcessor.cpp @@ -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(","); diff --git a/source/LinearShutter/VSMD12XControl.cpp b/source/LinearShutter/VSMD12XControl.cpp index 82f627e..98c5396 100644 --- a/source/LinearShutter/VSMD12XControl.cpp +++ b/source/LinearShutter/VSMD12XControl.cpp @@ -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:"<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; diff --git a/source/LinearShutter/VSMD12XControl.h b/source/LinearShutter/VSMD12XControl.h index 28daf56..8605200 100644 --- a/source/LinearShutter/VSMD12XControl.h +++ b/source/LinearShutter/VSMD12XControl.h @@ -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); }; diff --git a/source/Thread/AbstractFSController.cpp b/source/Thread/AbstractFSController.cpp index c76f235..0544837 100644 --- a/source/Thread/AbstractFSController.cpp +++ b/source/Thread/AbstractFSController.cpp @@ -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; diff --git a/source/Thread/Scheduler.cpp b/source/Thread/Scheduler.cpp index 6ea31fc..31029ff 100644 --- a/source/Thread/Scheduler.cpp +++ b/source/Thread/Scheduler.cpp @@ -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"; } diff --git a/source/Upload/DataFileTransfer.cpp b/source/Upload/DataFileTransfer.cpp new file mode 100644 index 0000000..e69de29 diff --git a/source/Upload/DataFileTransfer.h b/source/Upload/DataFileTransfer.h new file mode 100644 index 0000000..b3afd26 --- /dev/null +++ b/source/Upload/DataFileTransfer.h @@ -0,0 +1,3 @@ +#pragma once +#include "pch.h" +#include "ZZ_Types.h" \ No newline at end of file