From ed9a854e8bb68c624d13b939afd29a0e0b925e61 Mon Sep 17 00:00:00 2001 From: tangchao Date: Thu, 17 Feb 2022 17:39:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=94=AF=E6=8C=81=E4=BD=BF?= =?UTF-8?q?=E7=94=A8asd=E6=B5=8B=E5=AE=9A=E7=9A=84=E7=A7=AF=E5=88=86?= =?UTF-8?q?=E7=90=83=E6=A0=87=E5=87=86=E8=83=BD=E9=87=8F=E6=9B=B2=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- othersoft/calibration_console/CMakeLists.txt | 8 +- .../Header_Files/ATPControl_Serial_QT.h | 6 +- .../Source_Files/ATPControl_Serial_QT.cpp | 597 ++++++++---------- .../Source_Files/calibration.cpp | 18 +- .../calibration_console/Source_Files/main.cpp | 15 +- .../Source_Files/oceanOpticsFiberImager.cpp | 2 +- 6 files changed, 298 insertions(+), 348 deletions(-) diff --git a/othersoft/calibration_console/CMakeLists.txt b/othersoft/calibration_console/CMakeLists.txt index 740febd..7f426f7 100644 --- a/othersoft/calibration_console/CMakeLists.txt +++ b/othersoft/calibration_console/CMakeLists.txt @@ -29,10 +29,10 @@ set(TARGET ximeaImageRecorder) set(CMAKE_INCLUDE_CURRENT_DIR ON) find_package(Qt5 REQUIRED ${QT}) -#include_directories(/home/iris-xport/projects/ocean/seabreeze-3.0.11/SeaBreeze/include/) -#LINK_DIRECTORIES(/home/iris-xport/projects/ocean/seabreeze-3.0.11/SeaBreeze/lib/) -include_directories(/home/pi/SeaBrease/include/) -LINK_DIRECTORIES(/home/pi/SeaBrease/lib/) +include_directories(/home/iris-xport/projects/ocean/seabreeze-3.0.11/SeaBreeze/include/) +LINK_DIRECTORIES(/home/iris-xport/projects/ocean/seabreeze-3.0.11/SeaBreeze/lib/) +#include_directories(/home/pi/SeaBrease/include/) +#LINK_DIRECTORIES(/home/pi/SeaBrease/lib/) include_directories(.)#包含头文件 include_directories(/usr/include/eigen3)#包含头文件,安装eigen:sudo apt-get install libeigen3-dev diff --git a/othersoft/calibration_console/Header_Files/ATPControl_Serial_QT.h b/othersoft/calibration_console/Header_Files/ATPControl_Serial_QT.h index c18c5eb..937ffde 100644 --- a/othersoft/calibration_console/Header_Files/ATPControl_Serial_QT.h +++ b/othersoft/calibration_console/Header_Files/ATPControl_Serial_QT.h @@ -7,6 +7,7 @@ #include "ZZ_Math.h" #include #include +#include #include "IrisFiberSpectrometerBase.h" using namespace ZZ_MISCDEF; @@ -86,8 +87,9 @@ private: //////////////////////////////////////////////////////////////////////////shutter control stub code e int GetExposureTime_Init(); int SendCommand(QByteArray qbCommand); - int RecvData(QByteArray& qbData); - int ParseData(QByteArray& qbData); + int RecvData(QByteArray &qbData); + int RecvData_ShortLag(QByteArray &qbData); + int ParseData(QByteArray &qbData); public slots: int Init_Self(); signals: diff --git a/othersoft/calibration_console/Source_Files/ATPControl_Serial_QT.cpp b/othersoft/calibration_console/Source_Files/ATPControl_Serial_QT.cpp index 82f1948..d6acb15 100644 --- a/othersoft/calibration_console/Source_Files/ATPControl_Serial_QT.cpp +++ b/othersoft/calibration_console/Source_Files/ATPControl_Serial_QT.cpp @@ -1,7 +1,6 @@ //#include "pch.h" #include "Header_Files/ATPControl_Serial_QT.h" //#include "ZZ_Math_HDRONLY.h" -#include ZZ_ATPControl_Serial_Qt::ZZ_ATPControl_Serial_Qt(QObject* parent /*= nullptr*/) { @@ -64,26 +63,27 @@ int ZZ_ATPControl_Serial_Qt::Initialize(bool bIsUSBMode, std::string ucPortNumbe return 2; } - // int testi; - // GetDeviceAttribute(m_daDeviceAttr); - // GetExposureTime(testi); - // SetExposureTime(10000); - // DataFrame test; - // SingleShot(test); +// int testi; +// GetDeviceAttribute(m_daDeviceAttr); +// GetExposureTime(testi); +// SetExposureTime(10000); +// DataFrame test; +// SingleShot(test); GetDeviceInfo(m_diDeviceInfo); GetExposureTime_Init(); -// -// std::string::size_type szPostion = m_diDeviceInfo.strSN.find(strDeviceName); -// if (szPostion == std::string::npos) -// { -// qDebug() << "Err:FS serial number not match.Exit Code:3"; -// return 3; -// } -// else -// { -// return 0; -// } + + + std::string::size_type szPostion = m_diDeviceInfo.strSN.find(strDeviceName); + if (szPostion == std::string::npos) + { + qDebug() << "Err:FS serial number not match.Exit Code:3"; + return 3; + } + else + { + return 0; + } return 0; } @@ -91,7 +91,7 @@ void ZZ_ATPControl_Serial_Qt::Close() { m_pSerialPort->close(); } -int ZZ_ATPControl_Serial_Qt::GetDeviceInfo(DeviceInfo& Info) +int ZZ_ATPControl_Serial_Qt::GetDeviceInfo(DeviceInfo &Info) { QByteArray qbSend, qbRecv; @@ -146,7 +146,7 @@ int ZZ_ATPControl_Serial_Qt::GetDeviceInfo(DeviceInfo& Info) return 0; } -int ZZ_ATPControl_Serial_Qt::GetDeviceAttribute(DeviceAttribute& Attr) +int ZZ_ATPControl_Serial_Qt::GetDeviceAttribute(DeviceAttribute &Attr) { QByteArray qbSend, qbRecv; @@ -197,6 +197,9 @@ int ZZ_ATPControl_Serial_Qt::GetDeviceAttribute(DeviceAttribute& Attr) m_daDeviceAttr.iMaxIntegrationTimeInMS = (ZZ_U8)qbRecv[1] + (ZZ_U8)qbRecv[0] * 256; + int iTempExpTime = 0; + GetExposureTime(iTempExpTime); + iRes = SetExposureTime(m_daDeviceAttr.iMinIntegrationTimeInMS); if (iRes != 0) { @@ -210,6 +213,8 @@ int ZZ_ATPControl_Serial_Qt::GetDeviceAttribute(DeviceAttribute& Attr) return 3; } + SetExposureTime(iTempExpTime); + qbSend.clear(); qbRecv.clear(); @@ -239,7 +244,7 @@ int ZZ_ATPControl_Serial_Qt::GetDeviceAttribute(DeviceAttribute& Attr) memcpy(fWaveLengthCoef, qbRecv.data() + 16, 4 * sizeof(float)); for (int i = 0; i < m_daDeviceAttr.iPixels; i++) { - m_daDeviceAttr.fWaveLengthInNM[i] = fWaveLengthCoef[0] * i * i * i + fWaveLengthCoef[1] * i * i + fWaveLengthCoef[2] * i + fWaveLengthCoef[3]; + m_daDeviceAttr.fWaveLengthInNM[i] = fWaveLengthCoef[0] * i*i*i + fWaveLengthCoef[1] * i*i + fWaveLengthCoef[2] * i + fWaveLengthCoef[3]; } Attr = m_daDeviceAttr; @@ -313,7 +318,7 @@ int ZZ_ATPControl_Serial_Qt::SendCommand(QByteArray qbCommand) return 0; } -int ZZ_ATPControl_Serial_Qt::RecvData(QByteArray& qbData) +int ZZ_ATPControl_Serial_Qt::RecvData(QByteArray &qbData) { qbData.clear(); qbData = m_pSerialPort->readAll(); @@ -321,11 +326,11 @@ int ZZ_ATPControl_Serial_Qt::RecvData(QByteArray& qbData) int iCounter = 0; while (qbData.size() < 4) { - m_pSerialPort->waitForReadyRead(1000); + m_pSerialPort->waitForReadyRead(600); QByteArray qbTemp = m_pSerialPort->readAll(); qbData.append(qbTemp); - if (iCounter > 150) + if (iCounter > 25) { qDebug() << "Err:RecvData Failed,Not Enough Data.Exit Code:1" << qbData.size(); return 1; @@ -377,7 +382,71 @@ int ZZ_ATPControl_Serial_Qt::RecvData(QByteArray& qbData) return 0; } -int ZZ_ATPControl_Serial_Qt::ParseData(QByteArray& qbData) +int ZZ_ATPControl_Serial_Qt::RecvData_ShortLag(QByteArray &qbData) +{ + qbData.clear(); + qbData = m_pSerialPort->readAll(); + + int iCounter = 0; + while (qbData.size() < 4) + { + m_pSerialPort->waitForReadyRead(100); + QByteArray qbTemp = m_pSerialPort->readAll(); + qbData.append(qbTemp); + + if (iCounter > 6) + { + qDebug() << "Err:RecvData Failed,Not Enough Data.Exit Code:1" << qbData.size(); + return 1; + } + iCounter++; + } + + if ((ZZ_U8)qbData[0] != (ZZ_U8)0xaa || (ZZ_U8)qbData[1] != (ZZ_U8)0x55) + { + qDebug() << "Err:RecvData Failed,Wrong Header.Exit Code:2" << qbData.size(); + return 2; + } + + iCounter = 0; + int iLength = qbData[2] * 256 + qbData[3] + 2; + while (qbData.size() < iLength) + { + m_pSerialPort->waitForReadyRead(100); + qbData.append(m_pSerialPort->readAll()); + + if (iCounter > 6) + { + qDebug() << "Err:RecvData Failed,Incomplete Data.Exit Code:3" << qbData.size(); + return 3; + } + iCounter++; + } + + if (qbData.size() > iLength) + { + qbData.remove(iLength - 1, qbData.size() - iLength); + } + int iCheckSumLength = iLength - 3; + ZZ_U16 usCheckSum = 0; + for (int i = 0; i < iCheckSumLength; i++) + { + usCheckSum += qbData[i + 2]; + } + usCheckSum = usCheckSum % 256; + ZZ_U8 ucTemp = qbData[qbData.size() - 1]; + if ((ZZ_U8)usCheckSum != ucTemp) + { + qDebug() << "Err:RecvData Failed,Incorrect Check Sum.Exit Code:4" << "Total Recv:" << qbData.size() << "Check Sum:" << usCheckSum << "Not Equal To" << ucTemp; + //qbData.clear(); + //return 4; + return 0; + } + + return 0; +} + +int ZZ_ATPControl_Serial_Qt::ParseData(QByteArray &qbData) { if (qbData.size() < 6) { @@ -395,301 +464,166 @@ int ZZ_ATPControl_Serial_Qt::Init_Self() return 0; } -int ZZ_ATPControl_Serial_Qt::PerformAutoExposure(float fMinScaleFactor, float fMaxScaleFactor, float& fPredictedExposureTime) +int ZZ_ATPControl_Serial_Qt::PerformAutoExposure(float fMinScaleFactor, float fMaxScaleFactor, float &fPredictedExposureTime) { -// using namespace ZZ_MATH; -// int iDeviceDepth = 65535; -// -// bool bFlagIsOverTrying = false; -// bool bFlagIsLowerMinExposureTime = false; -// bool bFlagIsOverMaxExposureTime = false; -// bool bFlagIsAutoExposureOK = false; -// bool bFlagIsAutoExposureFailed = false; -// -// bool bIsValueOverflow = false; -// bool bIsLastValueOverflow = false; -// -// float fExposureTime = 0; -// float fTempExposureTime = 0; -// double fLastExposureTime = 0.1; -// int iRepeatCount = 0; -// -// int iRes = SetExposureTime(2000);//need change to load from files -// if (iRes != 0) -// { -// qDebug() << "Err:PerformAutoExposure Failed.Exit Code:1"; -// return 1; -// } -// -// while (!bFlagIsAutoExposureOK && !bFlagIsAutoExposureFailed) -// { -// DataFrame dfTemp; -// -// if (iRepeatCount++ > 30) -// { -// bFlagIsAutoExposureFailed = true; -// bFlagIsOverTrying = true; -// break; -// } -// -// fExposureTime = (float)m_daDeviceAttr.iMinIntegrationTimeInMS; -// fTempExposureTime = fExposureTime; -// -// iRes = SingleShot(dfTemp); -// if (iRes != 0) -// { -// qDebug() << "Err:PerformAutoExposure Failed.Exit Code:2"; -// return 2; -// } -// -// HeapSort(dfTemp.lData, m_daDeviceAttr.iPixels); -// -// double dSum = 0; -// int iCount = m_daDeviceAttr.iPixels / 100; -// for (int i = 0; i < iCount; i++) -// { -// dSum += dfTemp.lData[i]; -// } -// double dTemp = dSum / iCount; -// -// if (dTemp >= iDeviceDepth * 0.99) -// { -// bIsValueOverflow = true; -// if (!bIsLastValueOverflow) -// { -// fExposureTime = (float)(fLastExposureTime + fExposureTime) / 2; -// } -// else -// { -// fExposureTime = fExposureTime / 2; -// } -// } -// -// else if (iDeviceDepth * fMaxScaleFactor >= dTemp && dTemp >= iDeviceDepth * fMinScaleFactor) -// { -// bFlagIsAutoExposureOK = 1; -// } -// else if (dTemp > iDeviceDepth * fMaxScaleFactor) -// { -// bIsValueOverflow = true; -// if (!bIsLastValueOverflow) -// { -// fExposureTime = (float)(fLastExposureTime + fExposureTime) / 2; -// } -// else -// { -// fExposureTime = fExposureTime * 3 / 4; -// } -// } -// else if (dTemp < iDeviceDepth * fMinScaleFactor) -// { -// bIsValueOverflow = false; -// if (bIsLastValueOverflow) -// { -// fExposureTime = (float)(fLastExposureTime + fExposureTime) / 2; -// } -// else -// { -// double dFactor; -// dFactor = dTemp / (iDeviceDepth * fMaxScaleFactor); -// fExposureTime = (float)(fExposureTime / dFactor); -// } -// if (/*fExposureTime > 100 || */fExposureTime < 10) -// { -// bFlagIsAutoExposureOK = false; -// bFlagIsAutoExposureFailed = true; -// bFlagIsLowerMinExposureTime = true; -// } -// } -// bIsLastValueOverflow = bIsValueOverflow; -// fLastExposureTime = fTempExposureTime; -// -// if (fExposureTime > 13000) -// { -// bFlagIsAutoExposureOK = false; -// bFlagIsAutoExposureFailed = true; -// fPredictedExposureTime = 13000; -// iRes = SetExposureTime(13000); -// if (iRes != 0) -// { -// qDebug() << "Err:PerformAutoExposure Failed.Exit Code:3"; -// return 3; -// } -// bFlagIsOverMaxExposureTime = true; -// break; -// } -// -// iRes = SetExposureTime((int)fExposureTime); -// if (iRes != 0) -// { -// qDebug() << "Err:PerformAutoExposure Failed.Exit Code:4"; -// return 3; -// } -// } -// fPredictedExposureTime = fExposureTime; -// return 0; - int m_iThreadID=0; // qDebug() << "--------------------------Starting PerformAutoExposure" << " Thread ID:" << m_iThreadID; - using namespace ZZ_MATH; + using namespace ZZ_MATH; // float fPredictedExposureTime; - int iDeviceDepth = 65535; + int iDeviceDepth = 65535; // qDebug() << "MAX---Min" << fMaxScaleFactor << "---" << fMinScaleFactor << " Thread ID:" << m_iThreadID; - bool bFlagIsOverTrying = false; - bool bFlagIsLowerMinExposureTime = false; - bool bFlagIsOverMaxExposureTime = false; - bool bFlagIsAutoExposureOK = false; - bool bFlagIsAutoExposureFailed = false; + bool bFlagIsOverTrying = false; + bool bFlagIsLowerMinExposureTime = false; + bool bFlagIsOverMaxExposureTime = false; + bool bFlagIsAutoExposureOK = false; + bool bFlagIsAutoExposureFailed = false; - bool bIsValueOverflow = false; - bool bIsLastValueOverflow = false; + bool bIsValueOverflow = false; + bool bIsLastValueOverflow = false; - int iExposureTime = 0; - float fTempExposureTime = 0; - double fLastExposureTime = 0.1; - int iRepeatCount = 0; + int iExposureTime = 0; + float fTempExposureTime = 0; + double fLastExposureTime = 0.1; + int iRepeatCount = 0; - //int iRes = m_pFSCtrl->SetExposureTime(1000);//need change to load from files - int iRes = 0; - if (iRes != 0) - { + //int iRes = m_pFSCtrl->SetExposureTime(1000);//need change to load from files + int iRes = 0; + if (iRes != 0) + { // qDebug() << "Err:PerformAutoExposure Failed.Exit Code:1" << " Thread ID:" << m_iThreadID; - return 1; - } + return 1; + } - while (!bFlagIsAutoExposureOK && !bFlagIsAutoExposureFailed) - { - DataFrame dfTemp; + while (!bFlagIsAutoExposureOK && !bFlagIsAutoExposureFailed) + { + DataFrame dfTemp; - if (iRepeatCount++ > 30) - { - bFlagIsAutoExposureFailed = true; - bFlagIsOverTrying = true; - break; - } - //m_pFSCtrl->SetExposureTime(5000); - GetExposureTime(iExposureTime); + if (iRepeatCount++ > 30) + { + bFlagIsAutoExposureFailed = true; + bFlagIsOverTrying = true; + break; + } + //m_pFSCtrl->SetExposureTime(5000); + GetExposureTime(iExposureTime); // qDebug() << "Current ExpTime:" << iExposureTime << " Thread ID:" << m_iThreadID; - //m_pFSCtrl->SetExposureTime(2500); - //fExposureTime = (float)m_daDeviceAttr.iMinIntegrationTimeInMS; - fTempExposureTime = iExposureTime; + //m_pFSCtrl->SetExposureTime(2500); + //fExposureTime = (float)m_daDeviceAttr.iMinIntegrationTimeInMS; + fTempExposureTime = iExposureTime; - iRes = SingleShot(dfTemp); - //iRes = m_pFSCtrl->SingleShot(dfTemp); - if (iRes != 0) - { + iRes = SingleShot(dfTemp); + //iRes = m_pFSCtrl->SingleShot(dfTemp); + if (iRes != 0) + { // qDebug() << "Err:PerformAutoExposure Failed.Exit Code:2" << " Thread ID:" << m_iThreadID; - return 2; - } + return 2; + } - HeapSort(dfTemp.lData, m_daDeviceAttr.iPixels); + HeapSort(dfTemp.lData, m_daDeviceAttr.iPixels); - double dSum = 0; - int iCount = m_daDeviceAttr.iPixels / 200; - for (int i = 0; i < iCount; i++) - { - dSum += dfTemp.lData[i]; - } - double dTemp = dSum / iCount; + double dSum = 0; + int iCount = m_daDeviceAttr.iPixels / 200; + for (int i = 0; i < iCount; i++) + { + dSum += dfTemp.lData[i]; + } + double dTemp = dSum / iCount; // qDebug() << "Avg " << dTemp << " Thread ID:" << m_iThreadID; - if (dTemp >= iDeviceDepth * 0.99) - { - bIsValueOverflow = true; - if (!bIsLastValueOverflow) - { - iExposureTime = (float)(fLastExposureTime + iExposureTime) / 2; - } - else - { - iExposureTime = iExposureTime / 2; - } - } + if (dTemp >= iDeviceDepth * 0.99) + { + bIsValueOverflow = true; + if (!bIsLastValueOverflow) + { + iExposureTime = (float)(fLastExposureTime + iExposureTime) / 2; + } + else + { + iExposureTime = iExposureTime / 2; + } + } - else if (iDeviceDepth * fMaxScaleFactor >= dTemp && dTemp >= iDeviceDepth * fMinScaleFactor) - { + else if (iDeviceDepth * fMaxScaleFactor >= dTemp && dTemp >= iDeviceDepth * fMinScaleFactor) + { // qDebug() << "trace bFlagIsAutoExposureOK =1 " << iExposureTime << " Thread ID:" << m_iThreadID; - bFlagIsAutoExposureOK = 1; - } - else if (dTemp > iDeviceDepth * fMaxScaleFactor) - { - bIsValueOverflow = true; - if (!bIsLastValueOverflow) - { - iExposureTime = (float)(fLastExposureTime + iExposureTime) / 2; - } - else - { - iExposureTime = iExposureTime * 3 / 4; - } - } - else if (dTemp < iDeviceDepth * fMinScaleFactor) - { - bIsValueOverflow = false; - if (bIsLastValueOverflow) - { - iExposureTime = (float)(fLastExposureTime + iExposureTime) / 2; - } - else - { - double dFactor; - dFactor = dTemp / (iDeviceDepth * fMaxScaleFactor); - iExposureTime = (float)(iExposureTime / dFactor); - } - if (/*fExposureTime > 100 || */iExposureTime < 10) - { - bFlagIsAutoExposureOK = false; - bFlagIsAutoExposureFailed = true; - bFlagIsLowerMinExposureTime = true; - } - } - bIsLastValueOverflow = bIsValueOverflow; - fLastExposureTime = fTempExposureTime; + bFlagIsAutoExposureOK = 1; + } + else if (dTemp > iDeviceDepth * fMaxScaleFactor) + { + bIsValueOverflow = true; + if (!bIsLastValueOverflow) + { + iExposureTime = (float)(fLastExposureTime + iExposureTime) / 2; + } + else + { + iExposureTime = iExposureTime * 3 / 4; + } + } + else if (dTemp < iDeviceDepth * fMinScaleFactor) + { + bIsValueOverflow = false; + if (bIsLastValueOverflow) + { + iExposureTime = (float)(fLastExposureTime + iExposureTime) / 2; + } + else + { + double dFactor; + dFactor = dTemp / (iDeviceDepth * fMaxScaleFactor); + iExposureTime = (float)(iExposureTime / dFactor); + } + if (/*fExposureTime > 100 || */iExposureTime < 10) + { + bFlagIsAutoExposureOK = false; + bFlagIsAutoExposureFailed = true; + bFlagIsLowerMinExposureTime = true; + } + } + bIsLastValueOverflow = bIsValueOverflow; + fLastExposureTime = fTempExposureTime; - if (iExposureTime > 120000) - { - bFlagIsAutoExposureOK = false; - bFlagIsAutoExposureFailed = true; - float fPredictedExposureTime = 120000; - iRes = SetExposureTime(120000); - if (iRes != 0) - { + if (iExposureTime > 120000) + { + bFlagIsAutoExposureOK = false; + bFlagIsAutoExposureFailed = true; + float fPredictedExposureTime = 120000; + iRes = SetExposureTime(120000); + if (iRes != 0) + { // qDebug() << "Err:PerformAutoExposure Failed.Exit Code:3" << " Thread ID:" << m_iThreadID; - return 3; - } - else - { - //qDebug() << "Warning:PerformAutoExposure exceed max integration time.Will be limited to 30sec"; + return 3; + } + else + { + //qDebug() << "Warning:PerformAutoExposure exceed max integration time.Will be limited to 30sec"; // qDebug() << "Warning:PerformAutoExposure exceed max integration time.Will be limited to " << m_daDeviceAttr.iMaxIntegrationTimeInMS << "MS" << " Thread ID:" << m_iThreadID; - } - bFlagIsOverMaxExposureTime = true; - break; - } + } + bFlagIsOverMaxExposureTime = true; + break; + } - iRes = SetExposureTime((int)iExposureTime); - if (iRes != 0) - { + iRes = SetExposureTime((int)iExposureTime); + if (iRes != 0) + { // qDebug() << "Err:PerformAutoExposure Failed.Exit Code:4" << " Thread ID:" << m_iThreadID; - return 3; - } - else - { - qDebug() << "Success:PerformAutoExposure. Value" << iExposureTime << " Thread ID:" << m_iThreadID; - } - } - fPredictedExposureTime = iExposureTime; + return 3; + } + else + { + qDebug() << "Success:PerformAutoExposure. Value" << iExposureTime << " Thread ID:" << m_iThreadID; + } + } + fPredictedExposureTime = iExposureTime; // qDebug() << "--------------------------Stop PerformAutoExposure" << " Thread ID:" << m_iThreadID; - //emit SignalAcqFinished(m_iThreadID, 1); - - return 0; - - + //emit SignalAcqFinished(m_iThreadID, 1); + return 0; } @@ -739,40 +673,40 @@ int ZZ_ATPControl_Serial_Qt::SetExposureTime(int iExposureTimeInMS) return 0; } -int ZZ_ATPControl_Serial_Qt::GetExposureTime(int& iExposureTimeInMS) +int ZZ_ATPControl_Serial_Qt::GetExposureTime(int &iExposureTimeInMS) { - // QByteArray qbSend, qbRecv; - // qbSend.clear(); - // qbRecv.clear(); - // qbSend.append(GET_INTEGRATION_TIME); - // qbSend.resize(3); - // qbSend[1] = 0x00; - // qbSend[2] = 0x01; - // int iRes = SendCommand(qbSend); - // if (iRes != 0) - // { - // qDebug() << "Err:GetExposureTime Failed.Exit Code:1"; - // return 1; - // } - // iRes = RecvData(qbRecv); - // if (iRes != 0) - // { - // qDebug() << "Err:GetExposureTime Failed.Exit Code:2"; - // return 2; - // } - // iRes = ParseData(qbRecv); - // if (iRes != 0) - // { - // qDebug() << "Err:GetExposureTime Failed.Exit Code:3"; - // return 3; - // } - // - // iExposureTimeInMS = (ZZ_U8)qbRecv[1] + (ZZ_U8)qbRecv[0] * 256; +// QByteArray qbSend, qbRecv; +// qbSend.clear(); +// qbRecv.clear(); +// qbSend.append(GET_INTEGRATION_TIME); +// qbSend.resize(3); +// qbSend[1] = 0x00; +// qbSend[2] = 0x01; +// int iRes = SendCommand(qbSend); +// if (iRes != 0) +// { +// qDebug() << "Err:GetExposureTime Failed.Exit Code:1"; +// return 1; +// } +// iRes = RecvData(qbRecv); +// if (iRes != 0) +// { +// qDebug() << "Err:GetExposureTime Failed.Exit Code:2"; +// return 2; +// } +// iRes = ParseData(qbRecv); +// if (iRes != 0) +// { +// qDebug() << "Err:GetExposureTime Failed.Exit Code:3"; +// return 3; +// } +// +// iExposureTimeInMS = (ZZ_U8)qbRecv[1] + (ZZ_U8)qbRecv[0] * 256; iExposureTimeInMS = m_iExposureTime; return 0; } -int ZZ_ATPControl_Serial_Qt::SingleShot(DataFrame& dfData) +int ZZ_ATPControl_Serial_Qt::SingleShot(DataFrame &dfData) { QByteArray qbSend, qbRecv; @@ -780,10 +714,11 @@ int ZZ_ATPControl_Serial_Qt::SingleShot(DataFrame& dfData) qbRecv.clear(); qbSend.append(SYNC_GET_DATA); qbSend.resize(3); - // qbSend[1] = 0x00; - // qbSend[2] = 0x01; - qbSend[1] = m_iExposureTime >> 8;; - qbSend[2] = m_iExposureTime & 0xFF; +// qbSend[1] = 0x00; +// qbSend[2] = 0x01; + int iTemp=m_iExposureTime; + qbSend[1] = iTemp >> 8;; + qbSend[2] = iTemp & 0xFF; int iRes = SendCommand(qbSend); if (iRes != 0) { @@ -821,16 +756,22 @@ int ZZ_ATPControl_Serial_Qt::SingleShot(DataFrame& dfData) } - // for (int i = 0; i < iDataSizeInPixel; i++) - // { - // dfData.lData[i] = usData[i]; - // } +// for (int i = 0; i < iDataSizeInPixel; i++) +// { +// dfData.lData[i] = usData[i]; +// } } + float fTemp; + GetDeviceTemperature(fTemp); + + dfData.usExposureTimeInMS = m_iExposureTime; + dfData.fTemperature = fTemp; + return 0; } -int ZZ_ATPControl_Serial_Qt::SingleShot(int& iPixels) +int ZZ_ATPControl_Serial_Qt::SingleShot(int &iPixels) { QByteArray qbSend, qbRecv; qbSend.clear(); @@ -878,7 +819,7 @@ int ZZ_ATPControl_Serial_Qt::SingleShot(int& iPixels) // return 0; // } -int ZZ_ATPControl_Serial_Qt::GetDeviceTemperature(float& fTemperature) +int ZZ_ATPControl_Serial_Qt::GetDeviceTemperature(float &fTemperature) { fTemperature = 0; @@ -895,7 +836,7 @@ int ZZ_ATPControl_Serial_Qt::GetDeviceTemperature(float& fTemperature) qDebug() << "Err:GetDeviceTemperature Failed.Exit Code:1"; return 1; } - iRes = RecvData(qbRecv); + iRes = RecvData_ShortLag(qbRecv); if (iRes != 0) { qDebug() << "Err:GetDeviceTemperature Failed.Exit Code:2"; diff --git a/othersoft/calibration_console/Source_Files/calibration.cpp b/othersoft/calibration_console/Source_Files/calibration.cpp index 3832faa..b6704dc 100644 --- a/othersoft/calibration_console/Source_Files/calibration.cpp +++ b/othersoft/calibration_console/Source_Files/calibration.cpp @@ -186,7 +186,7 @@ void CalibrationAlgorithm::readAndResample_StandardLightFile(QString filePath, i // outfile2 << m_dStandardLightDataBase << std::endl; // } // -// outfile2 << deviceAttribute.fWaveLengthInNM[i] << "," << dTemp << std::endl; +// outfile2 << deviceAttribute.fWaveLengthInNM[i] << "," << m_dStandardLightDataResampled[i] << std::endl; // } // outfile2.close(); } @@ -228,14 +228,14 @@ void CalibrationAlgorithm::produceCalfile(QString calFilePath, DeviceAttribute d fclose(calFileHandle); -// //д뵽CSVļ -// QString calFile_csv = calFilePath.split(".")[0] + ".csv"; -// std::ofstream outfile(calFile_csv.toStdString().c_str()); -// for (int i = 0; i < deviceAttribute.iPixels; i++) -// { -// outfile << deviceAttribute.fWaveLengthInNM[i] << "," << m_gain[i] << std::endl; -// } -// outfile.close(); + //д뵽CSVļ + QString calFile_csv = calFilePath.split(".")[0] + ".csv"; + std::ofstream outfile(calFile_csv.toStdString().c_str()); + for (int i = 0; i < deviceAttribute.iPixels; i++) + { + outfile << deviceAttribute.fWaveLengthInNM[i] << "," << m_gain[i] << std::endl; + } + outfile.close(); delete[] m_gain; } diff --git a/othersoft/calibration_console/Source_Files/main.cpp b/othersoft/calibration_console/Source_Files/main.cpp index fee67c6..bc0b805 100644 --- a/othersoft/calibration_console/Source_Files/main.cpp +++ b/othersoft/calibration_console/Source_Files/main.cpp @@ -64,7 +64,10 @@ int main(int argc, char *argv[]) case CommandLineOk: break; case CommandLineError: - fputs(qPrintable(errorMessage), stderr); + errorMessage = "
" + errorMessage + "s!"; + logout(errorMessage); + +// fputs(qPrintable(errorMessage), stderr); fputs("\n\n", stderr); fputs(qPrintable(parser.helpText()), stderr); return 1; @@ -78,12 +81,14 @@ int main(int argc, char *argv[]) } + + //Ƕ FiberSpectrometerOperationBase * m_FiberSpectrometer; switch (query.deviceType) { case OPTOSKY: - m_FiberSpectrometer = new ATPFiberImager(false,"ttyUSB0","ocean_optics"); + m_FiberSpectrometer = new ATPFiberImager(false,query.serialPort.toStdString(),"ocean_optics"); break; case OceanOptics: m_FiberSpectrometer = new OceanOpticsFiberImager(); @@ -342,13 +347,15 @@ CommandLineParseResult parseCommandLine2(QCommandLineParser &parser, TcQuery *qu QString selector = parser.value(standardLightFileSelector); // QString standardLightFilePath_tmp = QDir::cleanPath(QDir::rootPath() + QDir::separator() + "standardLightFile" + QDir::separator() + selector); - QString tmp = "/home/data/Setting/standardLightFile"; + QString tmp = "/home/data/Setting/StandardLightFile"; QString standardLightFilePath_tmp = tmp + QDir::separator() + selector; + string xx=standardLightFilePath_tmp.toStdString(); + //ж϶ļǷ if (!isFileExist(standardLightFilePath_tmp)) { - *errorMessage = "No standard light file set."; + *errorMessage = "Standard light file '" + selector + "' does not exist!"; return CommandLineError; } diff --git a/othersoft/calibration_console/Source_Files/oceanOpticsFiberImager.cpp b/othersoft/calibration_console/Source_Files/oceanOpticsFiberImager.cpp index 673feb3..578b519 100644 --- a/othersoft/calibration_console/Source_Files/oceanOpticsFiberImager.cpp +++ b/othersoft/calibration_console/Source_Files/oceanOpticsFiberImager.cpp @@ -155,7 +155,7 @@ void OceanOpticsFiberImager::recordTarget(int recordTimes, QString path) // QString fileName = path + "/" + currentTime + "_" + QString::fromStdString(deviceInfo.strSN) + "_integratingSphereSpectral.csv"; // std::ofstream outfile(fileName.toStdString().c_str()); // -// for (int i = 0; i < attribute.iPixels; i++) +// for (int i = 0; i < attribute.iPixels; i++)// // { // if (i==0) // {