mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-20 03:49:43 +08:00
12345
This commit is contained in:
4
main.cpp
4
main.cpp
@ -9,7 +9,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
QCoreApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
//////////////////////////////////////////////////////////////////////////logger
|
//////////////////////////////////////////////////////////////////////////logger
|
||||||
QT_LOG::ZZ_InitLogger(QCoreApplication::applicationDirPath() + "/Log/");
|
//QT_LOG::ZZ_InitLogger(QCoreApplication::applicationDirPath() + "/Log/");
|
||||||
QString qstrTest="This is a test message 2";
|
QString qstrTest="This is a test message 2";
|
||||||
qDebug() << qstrTest;
|
qDebug() << qstrTest;
|
||||||
//////////////////////////////////////////////////////////////////////////test
|
//////////////////////////////////////////////////////////////////////////test
|
||||||
@ -17,6 +17,8 @@ int main(int argc, char *argv[])
|
|||||||
QByteArray qbTest;
|
QByteArray qbTest;
|
||||||
m_ctrlATP.ATPInitialize(7);
|
m_ctrlATP.ATPInitialize(7);
|
||||||
m_ctrlATP.GetDeviceAttribute();
|
m_ctrlATP.GetDeviceAttribute();
|
||||||
|
m_ctrlATP.SetExposureTime(m_ctrlATP.m_adaDeviceAttr.iMinIntegrationTime);
|
||||||
|
|
||||||
m_ctrlATP.RecvData(qbTest);
|
m_ctrlATP.RecvData(qbTest);
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
return a.exec();
|
return a.exec();
|
||||||
|
@ -57,12 +57,23 @@ int ZZ_ATPControl_Serial_Qt::ATPClose()
|
|||||||
}
|
}
|
||||||
int ZZ_ATPControl_Serial_Qt::GetDeviceInfo()
|
int ZZ_ATPControl_Serial_Qt::GetDeviceInfo()
|
||||||
{
|
{
|
||||||
|
|
||||||
QByteArray qbSend, qbRecv;
|
QByteArray qbSend, qbRecv;
|
||||||
|
|
||||||
|
qbSend.clear();
|
||||||
|
qbRecv.clear();
|
||||||
qbSend.append(GET_PN_NUMBER);
|
qbSend.append(GET_PN_NUMBER);
|
||||||
SendCommand(qbSend);
|
SendCommand(qbSend);
|
||||||
RecvData(qbRecv);
|
RecvData(qbRecv);
|
||||||
ParseData(qbRecv);
|
ParseData(qbRecv);
|
||||||
|
m_adiDeviceInfo.strPN = qbRecv.data();
|
||||||
|
|
||||||
|
qbSend.clear();
|
||||||
|
qbRecv.clear();
|
||||||
|
qbSend.append(GET_SN_NUMBER);
|
||||||
|
SendCommand(qbSend);
|
||||||
|
RecvData(qbRecv);
|
||||||
|
ParseData(qbRecv);
|
||||||
|
m_adiDeviceInfo.strSN = qbRecv.data();
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -71,17 +82,43 @@ int ZZ_ATPControl_Serial_Qt::GetDeviceInfo()
|
|||||||
int ZZ_ATPControl_Serial_Qt::GetDeviceAttribute()
|
int ZZ_ATPControl_Serial_Qt::GetDeviceAttribute()
|
||||||
{
|
{
|
||||||
QByteArray qbSend, qbRecv;
|
QByteArray qbSend, qbRecv;
|
||||||
qbSend.append(GET_WAVELENGTH_CALIBRATION_COEF);
|
|
||||||
qbSend.resize(2);
|
qbSend.clear();
|
||||||
qbSend[0] = 0x00;
|
qbRecv.clear();
|
||||||
qbSend[1] = 0x01;
|
qbSend.append(GET_MIN_INTEGRATION_TIME);
|
||||||
SendCommand(qbSend);
|
SendCommand(qbSend);
|
||||||
RecvData(qbRecv);
|
RecvData(qbRecv);
|
||||||
//ParseData(qbRecv);
|
ParseData(qbRecv);
|
||||||
|
m_adaDeviceAttr.iMinIntegrationTime = (ZZ_U8)qbRecv[1] + (ZZ_U8)qbRecv[0] * 256;
|
||||||
|
|
||||||
float a[4];
|
qbSend.clear();
|
||||||
memcpy(a, (ZZ_U8*)(qbRecv[5]+16), 4 * 4);
|
qbRecv.clear();
|
||||||
|
qbSend.append(GET_MAX_INTEGRATION_TIME);
|
||||||
|
SendCommand(qbSend);
|
||||||
|
RecvData(qbRecv);
|
||||||
|
ParseData(qbRecv);
|
||||||
|
m_adaDeviceAttr.iMaxIntegrationTime = (ZZ_U8)qbRecv[1] + (ZZ_U8)qbRecv[0] * 256;
|
||||||
|
|
||||||
|
|
||||||
|
SetExposureTime(m_adaDeviceAttr.iMinIntegrationTime);
|
||||||
|
SingleShot(m_adaDeviceAttr.iPixels);
|
||||||
|
|
||||||
|
|
||||||
|
qbSend.clear();
|
||||||
|
qbRecv.clear();
|
||||||
|
qbSend.append(GET_WAVELENGTH_CALIBRATION_COEF);
|
||||||
|
qbSend.resize(3);
|
||||||
|
qbSend[1] = 0x00;
|
||||||
|
qbSend[2] = 0x01;
|
||||||
|
SendCommand(qbSend);
|
||||||
|
RecvData(qbRecv);
|
||||||
|
ParseData(qbRecv);
|
||||||
|
|
||||||
|
float fWaveLengthCoef[4];
|
||||||
|
memcpy(fWaveLengthCoef, qbRecv.data()+16, 4 * sizeof(float));
|
||||||
|
// for ()
|
||||||
|
// {
|
||||||
|
// }
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +226,93 @@ int ZZ_ATPControl_Serial_Qt::ParseData(QByteArray &qbData)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ZZ_ATPControl_Serial_Qt::PerformAutoExposure(float fMinScaleFactor, float fMaxScaleFactor, float &fPredictedExposureTime)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ZZ_ATPControl_Serial_Qt::SetExtShutter(int iShutterA, int iShutterB)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ZZ_ATPControl_Serial_Qt::SetExposureTime(int iExposureTimeInMS)
|
||||||
|
{
|
||||||
|
QByteArray qbExposureTime,qbRecv;
|
||||||
|
qbExposureTime.append(SET_INTEGRATION_TIME);
|
||||||
|
qbExposureTime.resize(3);
|
||||||
|
qbExposureTime[1] = iExposureTimeInMS >> 8;
|
||||||
|
qbExposureTime[2] = iExposureTimeInMS & 0xFF;
|
||||||
|
|
||||||
|
SendCommand(qbExposureTime);
|
||||||
|
RecvData(qbRecv);
|
||||||
|
ParseData(qbRecv);
|
||||||
|
|
||||||
|
if ((ZZ_U8)qbRecv[0] != 0)
|
||||||
|
{
|
||||||
|
qDebug() << "Err:SetExposureTime Failed.Exit Code:1" ;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ZZ_ATPControl_Serial_Qt::SingleShot(ATPDataFrame &dfData)
|
||||||
|
{
|
||||||
|
QByteArray qbSend, qbRecv;
|
||||||
|
qbSend.clear();
|
||||||
|
qbRecv.clear();
|
||||||
|
qbSend.append(SYNC_GET_DATA);
|
||||||
|
qbSend.resize(3);
|
||||||
|
qbSend[1] = 0x00;
|
||||||
|
qbSend[2] = 0x01;
|
||||||
|
SendCommand(qbSend);
|
||||||
|
RecvData(qbRecv);
|
||||||
|
ParseData(qbRecv);
|
||||||
|
|
||||||
|
if ((ZZ_U8)qbRecv[0] != 0)
|
||||||
|
{
|
||||||
|
qDebug() << "Err:SingleShot Failed.Exit Code:1";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int iDataSizeInPixel = (qbRecv.size() - 1) / 2;
|
||||||
|
memcpy(dfData.usData, qbRecv.data() + 1, iDataSizeInPixel * 2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//int isize = qbRecv.size();
|
||||||
|
//m_adaDeviceAttr.iPixels = isize / 2;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ZZ_ATPControl_Serial_Qt::SingleShot(int &iPixels)
|
||||||
|
{
|
||||||
|
QByteArray qbSend, qbRecv;
|
||||||
|
qbSend.clear();
|
||||||
|
qbRecv.clear();
|
||||||
|
qbSend.append(SYNC_GET_DATA);
|
||||||
|
qbSend.resize(3);
|
||||||
|
qbSend[1] = 0x00;
|
||||||
|
qbSend[2] = 0x01;
|
||||||
|
SendCommand(qbSend);
|
||||||
|
RecvData(qbRecv);
|
||||||
|
ParseData(qbRecv);
|
||||||
|
|
||||||
|
if ((ZZ_U8)qbRecv[0] != 0)
|
||||||
|
{
|
||||||
|
qDebug() << "Err:SingleShot Failed.Exit Code:1";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iPixels = (qbRecv.size() - 1) / 2;
|
||||||
|
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
//void ZZ_ATPControl_Serial_Qt::ReadMessage()
|
//void ZZ_ATPControl_Serial_Qt::ReadMessage()
|
||||||
//{
|
//{
|
||||||
|
@ -13,12 +13,16 @@ public:
|
|||||||
ZZ_ATPControl_Serial_Qt();
|
ZZ_ATPControl_Serial_Qt();
|
||||||
virtual ~ZZ_ATPControl_Serial_Qt();
|
virtual ~ZZ_ATPControl_Serial_Qt();
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////shutter control stub code s
|
||||||
|
int SetExtShutter(int iShutterA,int iShutterB); //0:close 1:open
|
||||||
|
//////////////////////////////////////////////////////////////////////////shutter control stub code e
|
||||||
public:
|
public:
|
||||||
int SetBaudRate(int iBaud);
|
int SetBaudRate(int iBaud);
|
||||||
|
|
||||||
int ATPInitialize( ZZ_U8 ucPortNumber);
|
int ATPInitialize( ZZ_U8 ucPortNumber);
|
||||||
int ATPClose();
|
int ATPClose();
|
||||||
|
|
||||||
|
int SingleShot(int &iPixels);
|
||||||
int SingleShot(ATPDataFrame &dfData);
|
int SingleShot(ATPDataFrame &dfData);
|
||||||
int SingleShotDark(ATPDataFrame &dfData);
|
int SingleShotDark(ATPDataFrame &dfData);
|
||||||
int SingleShotDeducted(ATPDataFrame &dfData);
|
int SingleShotDeducted(ATPDataFrame &dfData);
|
||||||
|
@ -48,7 +48,7 @@ namespace ZZ_MISCDEF
|
|||||||
typedef struct tagATPDataFrame
|
typedef struct tagATPDataFrame
|
||||||
{
|
{
|
||||||
unsigned short usExposureTime;
|
unsigned short usExposureTime;
|
||||||
int iData[4096];
|
ZZ_U16 usData[4096];
|
||||||
float fTemperature;
|
float fTemperature;
|
||||||
double dTimes = 0;
|
double dTimes = 0;
|
||||||
}ATPDataFrame;
|
}ATPDataFrame;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
|
#include <QtCore/QTime>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QtSerialPort/QSerialPort>
|
#include <QtSerialPort/QSerialPort>
|
||||||
|
Reference in New Issue
Block a user