diff --git a/.vs/-1359169916_indexfilecopy.bin b/.vs/-1359169916_indexfilecopy.bin index 2247d7e..04b1faf 100644 Binary files a/.vs/-1359169916_indexfilecopy.bin and b/.vs/-1359169916_indexfilecopy.bin differ diff --git a/.vs/IRIS_FODIS/v17/.suo b/.vs/IRIS_FODIS/v17/.suo index 4283d31..30bd06d 100644 Binary files a/.vs/IRIS_FODIS/v17/.suo and b/.vs/IRIS_FODIS/v17/.suo differ diff --git a/.vs/IRIS_FODIS/v17/Browse.VC.db b/.vs/IRIS_FODIS/v17/Browse.VC.db index ae083af..1667d71 100644 Binary files a/.vs/IRIS_FODIS/v17/Browse.VC.db and b/.vs/IRIS_FODIS/v17/Browse.VC.db differ diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json index 5c05727..6a7cf6d 100644 --- a/.vs/VSWorkspaceState.json +++ b/.vs/VSWorkspaceState.json @@ -1,16 +1,26 @@ { + "OutputFoldersPerTargetSystem": { + "本地计算机": [ + "out\\build\\Linux-GCC-Debug", + "out\\install\\Linux-GCC-Debug", + "out\\build\\x64-Debug", + "out\\install\\x64-Debug", + "out\\build\\Linux-GCC-Debug-Nanopi-Air", + "out\\install\\Linux-GCC-Debug-Nanopi-Air" + ] + }, "ExpandedNodes": [ "", "\\Source", "\\Source\\Calibration", - "\\Source\\Capture", + "\\Source\\FS", + "\\Source\\GPS", "\\Source\\Logger", "\\Source\\OSIF", - "\\Source\\OSIF\\DLib", "\\Source\\OSIF\\include", "\\Source\\Settings", "\\Source\\ZZ_SDK" ], - "SelectedNode": "\\main.cpp", + "SelectedNode": "\\CMakeLists.txt", "PreviewInSolutionExplorer": false } \ No newline at end of file diff --git a/.vs/cmake.db b/.vs/cmake.db index 8eb0cfa..212c388 100644 Binary files a/.vs/cmake.db and b/.vs/cmake.db differ diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index b8afb2b..8007c12 100644 Binary files a/.vs/slnx.sqlite and b/.vs/slnx.sqlite differ diff --git a/CMakeSettings.json b/CMakeSettings.json index 56d077b..8376127 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -10,7 +10,7 @@ "ctestCommandArgs": "", "inheritEnvironments": [ "linux_arm" ], "intelliSenseMode": "linux-gcc-arm", - "remoteMachineName": "1290204378;172.16.0.83 (username=root, port=22, authentication=Password)", + "remoteMachineName": "-237651717;172.16.0.93 (username=root, port=22, authentication=Password)", "remoteCMakeListsRoot": "/home/pi/FODIS/src/", "remoteBuildRoot": "/home/pi/FODIS/build_d/${name}", "remoteInstallRoot": "/home/pi/FODIS/out/install/${name}", diff --git a/Source/Capture/AbsFSController.cpp b/Source/Capture/AbsFSController.cpp index 15c4ce3..57d07e3 100644 --- a/Source/Capture/AbsFSController.cpp +++ b/Source/Capture/AbsFSController.cpp @@ -80,6 +80,17 @@ int CAbsFSController::Initialize() return 3; } break; + + case DeviceModel::IS11: + m_pFSCtrl = new IS11_Ctrl_Qt; + //m_pFSCtrl->Initialize(false, m_struFSParam.strInterface, NULL); + if (m_pFSCtrl->Initialize(false, m_struFSParam.strInterface, m_struFSParam.strSN) != 0) + { + qDebug() << "IS11 Not Opened"; + return 3; + } + break; + default: break; } diff --git a/Source/Capture/AbsFSController.h b/Source/Capture/AbsFSController.h index 2938e6b..6cb64f5 100644 --- a/Source/Capture/AbsFSController.h +++ b/Source/Capture/AbsFSController.h @@ -4,6 +4,8 @@ #include "OControl_USB.h" #include #include +#include "IS11_Ctrl_Qt.h" + using namespace ZZ_MISCDEF::ZZ_RUNPARAMS; using namespace ZZ_MISCDEF::MISC_DETECTOR; using namespace ZZ_MISCDEF::IRIS; diff --git a/Source/FS/IS11_Ctrl_Qt.cpp b/Source/FS/IS11_Ctrl_Qt.cpp new file mode 100644 index 0000000..090ea16 --- /dev/null +++ b/Source/FS/IS11_Ctrl_Qt.cpp @@ -0,0 +1,575 @@ +#include "IS11_Ctrl_Qt.h" + +IS11_Ctrl_Qt::IS11_Ctrl_Qt(QObject* parent /*= nullptr*/) +{ + m_pSerialPort = new QSerialPort; + m_iBaudRate = 921600; +} + +IS11_Ctrl_Qt::~IS11_Ctrl_Qt() +{ + delete m_pSerialPort; +} + +int IS11_Ctrl_Qt::Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName) +{ + QString qstrPortName = QString::fromStdString(ucPortNumber); + m_pSerialPort->setPortName(qstrPortName); + m_pSerialPort->setReadBufferSize(512); + + bool bRes = m_pSerialPort->setBaudRate(m_iBaudRate); + if (!bRes) + { + //qDebug() << "Err:setBaudRate Failed.Exit Code:1"; + //std::cout << "Err.setBaudRate Failed" << std::endl; + printf("Err:setBaudRate Failed.Exit Code:1"); + return 1; + } + + bRes = m_pSerialPort->open(QIODevice::ReadWrite); + if (!bRes) + { + //qDebug() << "Err:open Failed.Exit Code:2"; + //std::cout << "Err.open Failed" << std::endl; + printf("Err:open Failed.Exit Code:2"); + return 2; + } + + + // 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) + { + printf("Err:FS serial number not match.Exit Code:3"); + //qDebug() << "Err:FS serial number not match.Exit Code:3"; + //return 3; + } + else + { + return 0; + } + return 0; +} + +void IS11_Ctrl_Qt::Close() +{ + +} + +int IS11_Ctrl_Qt::SingleShot(DataFrame& dfData) +{ + SendData_CMD03((char*)GET_ALL_DN, sizeof(GET_ALL_DN)); + RecvData_CMD03(dfData); + return 0; +} + +int IS11_Ctrl_Qt::SetExposureTime(int iExposureTimeInMS) +{ + QByteArray qbaRecv; + qbaRecv.clear(); + + unsigned char pucExposureTime[2]; + pucExposureTime[0] = iExposureTimeInMS / 256; + pucExposureTime[1] = iExposureTimeInMS % 256; + SendData_CMD06((char *)SET_INTEGRAL_TIME, sizeof(SET_INTEGRAL_TIME), (char*)pucExposureTime, 2); + //SendData_CMD03((char *)GET_INTEGRAL_TIME, sizeof(GET_INTEGRAL_TIME)); + int iRes = RecvData_CMD06(qbaRecv); + return iRes; +} + +int IS11_Ctrl_Qt::GetExposureTime(int & iExposureTimeInMS) +{ + QByteArray qbaRecv; + qbaRecv.clear(); + SendData_CMD03((char *)GET_INTEGRAL_TIME, sizeof(GET_INTEGRAL_TIME)); + int iRes = RecvData_CMD03(qbaRecv); + + iExposureTimeInMS = qbaRecv[0]*256+ qbaRecv[1]; + return iRes; +} + +int IS11_Ctrl_Qt::GetDeviceInfo(DeviceInfo & Info) +{ + Info.strPN = "IS11"; + Info.strSN = "NULL"; + return 0; +} + +int IS11_Ctrl_Qt::GetDeviceAttribute(DeviceAttribute & Attr) +{ + QByteArray qbaRecv; + qbaRecv.clear(); + float fCoef[4]; + unsigned short usTempCoef[8]; + + Attr.iPixels = 2048; + Attr.iMinIntegrationTimeInMS = 1; + Attr.iMaxIntegrationTimeInMS = 60000; + + SendData_CMD03((char *)GET_WAVELENTH_COEFF, sizeof(GET_WAVELENTH_COEFF)); + RecvData_CMD03(qbaRecv); + + //memcpy(fTempCoef,qbaRecv,16); + memcpy(usTempCoef, qbaRecv, 16); + + for (int i=0;i<8;i++) + { + usTempCoef[i] = qToBigEndian(usTempCoef[i]); + } + + //float *pfTemp = (float*)usTempCoef; + memcpy(fCoef, usTempCoef,16); + + //Conv_LTB((char*)fTempCoef,16); + + for (int i = 1; i <= 2048; i++) + { + Attr.fWaveLengthInNM[i - 1] = fCoef[0] * i*i*i + fCoef[1] * i*i + fCoef[2] * i + fCoef[3]; + //setem.WavelenthStr = setem.WavelenthStr + String(setem.wavelenthlist[i - 1]).c_str() + ","; + } + return 0; +} + +int IS11_Ctrl_Qt::SetDeviceTemperature(float fTemperature) +{ + return 0; +} + +int IS11_Ctrl_Qt::GetDeviceTemperature(float & fTemperature) +{ + fTemperature = -1000; + return 0; +} + +int IS11_Ctrl_Qt::PerformAutoExposure(float fMinScaleFactor, float fMaxScaleFactor, float & fPredictedExposureTime) +{ + return 0; +} + +// unsigned short IS11_Ctrl_Qt::crc16(const uint8_t *pbdata, size_t sz) +// { +// uint16_t i, j, tmp, CRC16; +// +// CRC16 = 0xFFFF; // CRC¼Ä´æÆ÷³õʼֵ +// for (i = 0; i < sz; i++) +// { +// CRC16 ^= pbdata[i]; +// for (j = 0; j < 8; j++) +// { +// tmp = (uint16_t)(CRC16 & 0x0001); +// CRC16 >>= 1; +// if (tmp == 1) +// { +// CRC16 ^= 0xa001; // Òì»ò¶àÏîʽ +// } +// } +// } +// return CRC16; +// } + +unsigned short IS11_Ctrl_Qt::CalCRC16(const uint8_t *pbData, size_t szLength) +{ + uint16_t usCRC16 = CRC16_INIT; + for (size_t i = 0; i < szLength; i++) + { + usCRC16 ^= pbData[i]; + for (size_t j = 0; j < 8; j++) + { + if ((usCRC16 & 0x0001) != 0) + { + usCRC16 = (usCRC16 >> 1) ^ CRC16_POLYNOMIAL; + } + else + { + usCRC16 = usCRC16 >> 1; + } + } + } + return usCRC16; +} + +void IS11_Ctrl_Qt::Conv_LTB(char * pcData, int iLength) +{ + char *TempData = new char[iLength]; + memcpy(TempData, pcData, iLength); + + for (int i = 0; i < iLength / 2; i++) + { + pcData[2 * i] = TempData[2 * i + 1]; + pcData[2 * i + 1] = TempData[2 * i]; + /* code */ + } + delete[] TempData; +} + +int IS11_Ctrl_Qt::SendData_CMD03(char * pcCMD, size_t szCMDLength) +{ + QString qstrSend,qstrCRC16; + QByteArray qbaSend; + qbaSend.clear(); + + //char *pctest=new char[szCMDLength+2]; + //memcpy(pctest, pcCMD, szCMDLength); + //ushort ustest = crc16((unsigned char*)pcCMD,szCMDLength); + //qstrCRC16= QString::fromLatin1((const char*)usCRC16, (int)sizeof(uint16_t)); + //memcpy(pctest+ szCMDLength,&usCRC16, 2); + //int iReturn = m_pSerialPort->write(pctest,szCMDLength+2); + //delete[] pctest; + uint16_t usCRC16 = CalCRC16((unsigned char*)pcCMD, szCMDLength); + qstrSend = QString::fromLatin1((const char*)pcCMD, (int)szCMDLength); + const char * pucSend = (char *)&usCRC16; + + qbaSend.append(qstrSend); + qbaSend.append(pucSend, (int)sizeof(uint16_t)); + + int iReturn = m_pSerialPort->write(qbaSend); + + return iReturn; +} + +int IS11_Ctrl_Qt::RecvData_CMD03(QByteArray &qbaRecv) +{ + int iRetryCount = 0; + QByteArray qbaOriRecv,qbaTemp; + qbaOriRecv.clear(); + qbaTemp.clear(); + + ///read all once + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + while (qbaOriRecv.size() < 2 || ParseHdr(qbaOriRecv, 3) == 1) + { + m_pSerialPort->waitForReadyRead(1000); + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + iRetryCount++; + if (iRetryCount>100) + { + qDebug() << "Recv Hdr Err.out of retry time.RecvData_CMD03"; + return 1; + } + } + + iRetryCount = 0; + while (qbaOriRecv.size()< qbaOriRecv[2]+5) + { + m_pSerialPort->waitForReadyRead(100); + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + iRetryCount++; + if (iRetryCount > 20) + { + qDebug() << "Recv Data Err.out of retry time"; + return 2; + } + } + + if (qbaOriRecv.size()!= qbaOriRecv[2] + 5) + { + /// can be handled but dont want to + qDebug() << "Wrong Recv data size.RecvData_CMD03_QBA"; + return 3; + } + + unsigned short usCRCC=CalCRC16((unsigned char *)qbaOriRecv.data(), qbaOriRecv.size()-2); + char *pc = (char *)&usCRCC; + if ((pc[0]== qbaOriRecv[qbaOriRecv.size()-1]&& pc[1]== qbaOriRecv[qbaOriRecv.size()-2])|| + (pc[0] == qbaOriRecv[qbaOriRecv.size()-2] && pc[1] == qbaOriRecv[qbaOriRecv.size()-1])) + { + qbaRecv = qbaOriRecv.mid(3, qbaOriRecv.length() - 5); + } + else + { + ///error crc + qDebug() << "Recv data crc16 Err."<waitForReadyRead(100); + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + }*/ + + return 0; +} + +int IS11_Ctrl_Qt::RecvData_CMD03(DataFrame& dfData) +{ + int iRecvDataLength = 0; + int iRetryCount = 0; + QByteArray qbaOriRecv, qbaTemp; + qbaOriRecv.clear(); + qbaTemp.clear(); + + ///read all once + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + while (qbaOriRecv.size() < 4 || ParseHdr(qbaOriRecv, 3) == 1) + { + m_pSerialPort->waitForReadyRead(100); + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + iRetryCount++; + if (iRetryCount > 20) + { + qDebug() << "Recv Hdr Err.out of retry time"; + return 1; + } + } + + int length = qbaOriRecv[2] * 256 + qbaOriRecv[3]; + iRetryCount = 0; + while (qbaOriRecv.size() < length + 4) + { + m_pSerialPort->waitForReadyRead(100); + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + iRetryCount++; + if (iRetryCount > 20) + { + qDebug() << "Recv Data Err.out of retry time"; + return 2; + } + } + + if (qbaOriRecv.size() != length + 4) + { + /// can be handled but dont want to + qDebug() << "Wrong Recv data size.RecvData_CMD03_DF"; + return 3; + } + + QByteArray qbaData; + qbaData = qbaOriRecv.right(length - 4); + + int iDataSizeInPixel = qbaData.size() / 2; + unsigned short *pusData = new unsigned short[iDataSizeInPixel]; + + memcpy(pusData, qbaData, iDataSizeInPixel * 2); + for (size_t i = 0; i < iDataSizeInPixel; i++) + { + dfData.lData[i] = qToBigEndian(pusData[i]); + //qDebug() << dfData.lData[i]; + + } + ///it seems the manufacture not enable crc16 check for this function +// unsigned short usCRCC = CalCRC16((unsigned char *)qbaOriRecv.data(), qbaOriRecv.size() - 2); +// char *pc = (char *)&usCRCC; +// if ((pc[0] == qbaOriRecv[qbaOriRecv.size() - 1] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 2]) || +// (pc[0] == qbaOriRecv[qbaOriRecv.size() - 2] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 1])) +// { +// //qbaRecv = qbaOriRecv.mid(3, qbaOriRecv.length() - 5); +// //dataframe process here +// +// } +// else +// { +// ///error crc +// qDebug() << "Recv data crc16 Err." << pc[1] << pc[0]; +// return 4; +// } + + return 0; +} + + +//int IS11_Ctrl_Qt::RecvData_CMD03(float& fWavelength) +//{ +// int iRetryCount = 0; +// QByteArray qbaOriRecv, qbaTemp,qbaRecv; +// qbaOriRecv.clear(); +// qbaTemp.clear(); +// qbaRecv.clear(); +// +// ///read all once +// Read_IS11(qbaTemp); +// qbaOriRecv.append(qbaTemp); +// while (qbaOriRecv.size() < 2 || ParseHdr(qbaOriRecv, 3) == 1) +// { +// m_pSerialPort->waitForReadyRead(100); +// Read_IS11(qbaTemp); +// qbaOriRecv.append(qbaTemp); +// iRetryCount++; +// if (iRetryCount > 20) +// { +// qDebug() << "Recv Hdr Err.out of retry time"; +// return 1; +// } +// } +// +// iRetryCount = 0; +// while (qbaOriRecv.size() < qbaOriRecv[2] + 5) +// { +// m_pSerialPort->waitForReadyRead(100); +// Read_IS11(qbaTemp); +// qbaOriRecv.append(qbaTemp); +// iRetryCount++; +// if (iRetryCount > 20) +// { +// qDebug() << "Recv Data Err.out of retry time"; +// return 2; +// } +// } +// +// if (qbaOriRecv.size() != qbaOriRecv[2] + 5) +// { +// /// can be handled but dont want to +// qDebug() << "Wrong Recv data size."; +// return 3; +// } +// +// unsigned short usCRCC = CalCRC16((unsigned char *)qbaOriRecv.data(), qbaOriRecv.size() - 2); +// char *pc = (char *)&usCRCC; +// if ((pc[0] == qbaOriRecv[qbaOriRecv.size() - 1] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 2]) || +// (pc[0] == qbaOriRecv[qbaOriRecv.size() - 2] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 1])) +// { +// qbaRecv = qbaOriRecv.mid(3, qbaOriRecv.length() - 5); +// } +// else +// { +// ///error crc +// qDebug() << "Recv data crc16 Err." << pc[1] << pc[0]; +// return 4; +// } +// +// fWavelength = qbaRecv.toFloat(); +// return 0; +//} + +int IS11_Ctrl_Qt::SendData_CMD06(char *pcCMD, size_t szCMDLength, char *pcValue, size_t szValueLenth) +{ +// QString qstrSend, qstrSend1, qstrCRC16;///QByteArray append³öÏÖ¶àÓà×Ö½Ú +// QByteArray qbaSend; +// qbaSend.clear(); +// +// qstrSend = QString::fromLatin1(pcCMD, (int)szCMDLength); +// qbaSend.append(qstrSend); +// +// qstrSend1.clear(); +// qstrSend1 = QString::fromLatin1(pcValue,(int)szValueLenth); +// qbaSend.append(qstrSend1); + + QByteArray qbaSend; + qbaSend.append(pcCMD, szCMDLength); + qbaSend.append(pcValue, szValueLenth); + + unsigned short usCRC16 = CalCRC16((unsigned char*)qbaSend.data(), qbaSend.size()); + const char * pucSend = (char *)&usCRC16; + qbaSend.append(pucSend, (int)sizeof(unsigned short)); + + int iReturn = m_pSerialPort->write(qbaSend); + + return 0; + +} + +int IS11_Ctrl_Qt::RecvData_CMD06(QByteArray &qbaRecv) +{ + int iRetryCount = 0; + QByteArray qbaOriRecv, qbaTemp; + qbaOriRecv.clear(); + qbaTemp.clear(); + + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + while (qbaOriRecv.size() < 2 || ParseHdr(qbaOriRecv, 6) == 1) + { + m_pSerialPort->waitForReadyRead(1000); + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + iRetryCount++; + if (iRetryCount > 100) + { + qDebug() << "Recv Hdr Err.out of retry time.RecvData_CMD06"; + return 1; + } + } + + iRetryCount = 0; + while (qbaOriRecv.size() < 8) + { + m_pSerialPort->waitForReadyRead(100); + Read_IS11(qbaTemp); + qbaOriRecv.append(qbaTemp); + iRetryCount++; + if (iRetryCount > 20) + { + qDebug() << "Recv Data Err.out of retry time"; + return 2; + } + } + + if (qbaOriRecv.size() != 8) + { + /// can be handled but dont want to + qDebug() << "Wrong Recv data size.RecvData_CMD06"; + return 3; + } + + unsigned short usCRCC = CalCRC16((unsigned char *)qbaOriRecv.data(), qbaOriRecv.size() - 2); + char *pc = (char *)&usCRCC; + if ((pc[0] == qbaOriRecv[qbaOriRecv.size() - 1] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 2]) || + (pc[0] == qbaOriRecv[qbaOriRecv.size() - 2] && pc[1] == qbaOriRecv[qbaOriRecv.size() - 1])) + { + qbaRecv = qbaOriRecv.mid(2, 4); + } + else + { + ///error crc + qDebug() << "Recv data crc16 Err." << pc[1] << pc[0]; + return 4; + } + + return 0; +} + +int IS11_Ctrl_Qt::ParseHdr(QByteArray &qbaData, char cHdrType) +{ + QByteArray qbaTemp(qbaData); + while ((qbaTemp[0] != (char)0x01) &&(qbaTemp[1] != cHdrType)) + { + qbaTemp.remove(0, 1); + if (qbaTemp.size()<=2) + { + return 1; + } + } + + if (qbaTemp!= qbaData) + { + ///warning some communication error may happened. + qbaData = qbaTemp; + return 1000; + } + + return 0; +} + +int IS11_Ctrl_Qt::Write_IS11(char * pcCMD, size_t szCMDLength) +{ + QString qstrSend; + QByteArray qbaSend; + qbaSend.clear(); + + qstrSend = QString::fromLatin1((const char*)pcCMD, (int)szCMDLength); + return (int)m_pSerialPort->write(qbaSend); +} + +int IS11_Ctrl_Qt::Read_IS11(QByteArray &qbaRecv) +{ + //m_pSerialPort->waitForReadyRead(100); + qbaRecv = m_pSerialPort->readAll(); + return qbaRecv.size(); +} diff --git a/Source/FS/IS11_Ctrl_Qt.h b/Source/FS/IS11_Ctrl_Qt.h new file mode 100644 index 0000000..d417c73 --- /dev/null +++ b/Source/FS/IS11_Ctrl_Qt.h @@ -0,0 +1,126 @@ +#pragma once +#include "IrisFiberSpectrometerBase.h" +#include + +#define CRC16_INIT 0xFFFF +#define CRC16_POLYNOMIAL 0xa001 + +const uint8_t GET_ADDRESS[] = {0x01,0x03,0x00,0x01,0x00,0x01}; +const uint8_t GET_BANDRATE[] = {0x01,0x03,0x00,0x02,0x00,0x01}; +const uint8_t GET_INTEGRAL_TIME[] = {0x01,0x03,0x00,0x06,0x00,0x01}; +const uint8_t GET_AVERAGE_NUMBER[] = {0x01,0x03,0x00,0x07,0x00,0x01}; +const uint8_t GET_WAVELENTH_AT_BAND[] = {0x01,0x03,0x00,0x10,0x00,0x02}; +const uint8_t GET_VALUE_AT_BAND[] = {0x01,0x03,0x00,0x30,0x00,0x02}; +const uint8_t GET_SETTING_OF_LAMP[] = {0x01,0x03,0x00,0x04,0x00,0x01}; +const uint8_t GET_WAVELENTH_COEFF[] = {0x01,0x03,0x00,0x20,0x00,0x08}; +const uint8_t GET_ALL_DN[] = {0x01,0x03,0x01,0x00,0x10,0x00}; +const uint8_t GET_SERIAL_NUMBER[] = {0x01,0x03,0x00,0x40,0x00,0x00}; +const uint8_t GET_PRODUCT_NAME[] = {0x01,0x03,0x00,0x50,0x00,0x00}; + +const uint8_t SET_ADDRESS[] = {0x01,0x06,0x00,0x01}; +const uint8_t SET_BandRATE[] = {0x01,0x06,0x00,0x02}; +const uint8_t SET_INTEGRAL_TIME[] = {0x01,0x06,0x00,0x06}; +const uint8_t SET_AVERAGE_NUMBER[] = {0x01,0x06,0x00,0x07}; +const uint8_t SET_WORK_MODE[] = {0x01,0x06,0x00,0x01}; + +const uint8_t SET_WAVELENTH_COEFF[] = {0x01,0x10,0x00,0x20,0x00,0x08,0x16}; + +class IS11_Ctrl_Qt :public CIrisFSBase +{ + Q_OBJECT +public: + IS11_Ctrl_Qt(QObject* parent = nullptr); + virtual ~IS11_Ctrl_Qt(); +public: + //do not call + //int ReInit(); + //ÉèÖò¨ÌØÂÊ + //int SetBaudRate(int iBaud); + //³õʼ»¯É豸 + int Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName); + + //¹Ø±ÕÉ豸 + void Close(); + + //µ¥´Î²âÊԲɼ¯ ÓÃÒÔÈ·ÈÏÉ豸ÏñËØÊý + //int SingleShot(int& iPixels); + + //µ¥´ÎÊý¾Ý²É¼¯ + int SingleShot(DataFrame& dfData); + + //µ¥´Î°µ±³¾°²É¼¯ + //int SingleShotDark(ATPDataFrame &dfData); + + //int SingleShotDeducted(ATPDataFrame &dfData); + //ÉèÖÃÆØ¹âʱ¼ä + int SetExposureTime(int iExposureTimeInMS); + + //»ñÈ¡ÆØ¹âʱ¼äÉèÖà + int GetExposureTime(int& iExposureTimeInMS); + + //int GetWaveLength(float *pfWaveLength); + + //»ñÈ¡É豸ÐÅÏ¢ + int GetDeviceInfo(DeviceInfo& Info); + + //»ñÈ¡Éè±¸ÌØÕ÷Êý¾Ý + int GetDeviceAttribute(DeviceAttribute& Attr); + + //int GetDeviceListInfo(); //use type name to enum + + //ÉèÖÃÎÂ¶È + int SetDeviceTemperature(float fTemperature); + + //»ñÈ¡ÎÂ¶È + int GetDeviceTemperature(float& fTemperature); + + //×Ô¶¯ÆØ¹â + int PerformAutoExposure(float fMinScaleFactor, float fMaxScaleFactor, float& fPredictedExposureTime); + +#ifdef _DEBUG +public: +#else // +private: +#endif + //port + int m_iBaudRate; + QSerialPort* m_pSerialPort; + + //ATP + DeviceInfo m_diDeviceInfo; + DeviceAttribute m_daDeviceAttr; + + //Attr + int m_iExposureTime; + +#ifdef _DEBUG +public: +#else // +private: +#endif + //unsigned short crc16(const uint8_t *pbdata, size_t sz); + unsigned short CalCRC16(const uint8_t *pbData, size_t szLength); + void Conv_LTB(char * pcData, int iLength); + + int Write_IS11(char * pcCMD, size_t szCMDLength); + int Read_IS11(QByteArray &qbaRecv); + + + + int SendData_CMD03(char * pcCMD, size_t szCMDLength); + int RecvData_CMD03(QByteArray &qbaRecv); + int RecvData_CMD03(DataFrame& dfData); + //int RecvData_CMD03(float& fWavelength); + //int RecvData_CMD03(DeviceAttribute& Attr); + + int SendData_CMD06(char *pcCMD, size_t szCMDLength, char *pcValue, size_t szValueLenth); + int RecvData_CMD06(QByteArray &qbaRecv); + + int SendData_CMD10(char * pcCMD, size_t szCMDLength); + int RecvData_CMD10(QByteArray &qbaRecv); + + int ParseHdr(QByteArray &qbaData,char cHdrType); + + +}; + diff --git a/Source/FS/ZZ_Types.h b/Source/FS/ZZ_Types.h index 21816d1..8a00289 100644 --- a/Source/FS/ZZ_Types.h +++ b/Source/FS/ZZ_Types.h @@ -60,7 +60,8 @@ namespace ZZ_MISCDEF QEP, ISIF, IS1, - IS2 + IS2, + IS11 }; @@ -76,6 +77,7 @@ namespace ZZ_MISCDEF case DeviceModel::ISIF: return "ISIF"; break; case DeviceModel::IS1: return "IS1"; break; case DeviceModel::IS2: return "IS2"; break; + case DeviceModel::IS11: return "IS11"; break; default: return "error"; break; } } @@ -111,6 +113,10 @@ namespace ZZ_MISCDEF { return DeviceModel::IS2; } + else if (strDeviceModelName == "IS11") + { + return DeviceModel::IS11; + } else { return -1; diff --git a/main.cpp b/main.cpp index b76395e..0d09e42 100644 --- a/main.cpp +++ b/main.cpp @@ -24,16 +24,16 @@ int main(int argc, char* argv[]) system("gpio mode 5 out"); qDebug() << "system(gpio mode 4 out)"; - qDebug() << "system(gpio mode 5 out)"; + qDebug() << "system(gpio mode 5 out)";//ָʾµÆ¿ØÖÆ bool bRes = false; - OneFSContext m_struFSParam; + OneFSContext m_struFSParam;//²ÎÊýÀà GPSInfo m_struGPSInfo; //FodisRP m_struMiscRunParams; - ZZ_SysConfigger m_syscfSettings; + ZZ_SysConfigger m_syscfSettings;//¿ØÖÆÀà BD357Controller m_ctrlGPS; - CMainGrabber m_mgMainGrabber; + CMainGrabber m_mgMainGrabber;//Ö÷²É¼¯ DataFileProcessor m_dfpDataSaver; @@ -123,19 +123,19 @@ int main(int argc, char* argv[]) //m_test.Initialize_Part(); //m_test.LoadTable(); - m_ctrlGPS.SetContext(m_mgMainGrabber); + m_ctrlGPS.SetContext(m_mgMainGrabber);//³õʼ»¯gps m_ctrlGPS.SetupMessagePipeline(); m_ctrlGPS.Initialize(m_struGPSInfo); QThread* m_pqDataGrabberThreadHolder = new QThread(); m_mgMainGrabber.moveToThread(m_pqDataGrabberThreadHolder); - m_mgMainGrabber.SetRunParams(m_struFSParam); + m_mgMainGrabber.SetRunParams(m_struFSParam);//³õʼ»¯Ö÷²É¼¯Ïß³Ì m_mgMainGrabber.SetContext(m_ctrlGPS, m_dfpDataSaver); m_pqDataGrabberThreadHolder->start(); - m_mgMainGrabber.Initialize(); + m_mgMainGrabber.Initialize();//¿ªÊ¼¹¤×÷ //m_ctrlGPS.SyncDateOnce(); cout << "Hello CMake." << endl;