1.修改了部分ATP系列光谱仪的控制函数以匹配数据类型的改变。

2.添加了网络上传模块,矫正算法部分可能需要调整。
This commit is contained in:
2022-01-13 17:03:16 +08:00
parent a3d2319f56
commit 8ce6cb4755
33 changed files with 329 additions and 45 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,9 @@
[DEVICE INFO]
TotalSpectrometer=1
[FS1]
Model=OSIFAlpha
Port=-1
UID=FLMS15815
Model=ISIF
Port=COM7
UID=21351029
AEMax=0.85
AEMin=0.75
Depth=65535
@ -16,6 +16,13 @@ AEMin=0.75
Depth=230000
[FS3]
Model=Null
[FS4]
Model=OSIFAlpha
Port=-1
UID=FLMS15815
AEMax=0.85
AEMin=0.75
Depth=65535
[LINEAR SHUTTER]
Port=COM8
Type=1

View File

@ -18,6 +18,7 @@ int main(int argc, char *argv[])
QCoreApplication a(argc, argv);
system("gpio mode 1 output");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ų<EFBFBD>ʼ<EFBFBD><CABC>
qDebug() << "gpio mode 1 output......" << endl;
//////////////////////////////////////////////////////////////////////////
@ -85,10 +86,11 @@ int main(int argc, char *argv[])
m_sTimer.moveToThread(m_pqTimerThreadHolder);
m_mduUploader.moveToThread(m_pqUploaderThreadHolder);
//m_mdgGrabber.SetContext(m_struRuntimeParams, m_dfpSaver, m_sTimer);
m_mdgGrabber.SetContext(m_struRuntimeParams, m_dfpSaver, m_sTimer, m_mduUploader);
m_mdgGrabber.Init_Normal();
m_mduUploader.Initialize();
m_mduUploader.SetErr(m_eiErrInfo);
m_mduUploader.UploadInfo();
@ -100,6 +102,9 @@ int main(int argc, char *argv[])
m_mdgGrabber.Init_Self();
m_sTimer.SelfStart();
//////////////////////////////////////////////////////////////////////////test
// DataFileProcessor testdp;
// ZZ_SysConfigger test;
@ -170,6 +175,7 @@ int main(int argc, char *argv[])
// m_ctrlATP.SetExposureTime(m_ctrlATP.m_adaDeviceAttr.iMinIntegrationTime);
// m_ctrlATP.RecvData(qbTest);
//////////////////////////////////////////////////////////////////////////
return a.exec();
}

View File

@ -54,7 +54,7 @@ int CAbstractFSController::InitializeFSControl()
break;
case DeviceModel::ISIF:
m_pFSCtrl = new ZZ_ATPControl_Serial_Qt;
m_pFSCtrl->Initialize(false, m_fsInfo.strInterface, NULL);
//m_pFSCtrl->Initialize(false, m_fsInfo.strInterface, NULL);
if (m_pFSCtrl->Initialize(false, m_fsInfo.strInterface, m_fsInfo.strSN) != 0)
{
qDebug() << "ISIF Not Opened";
@ -63,7 +63,7 @@ int CAbstractFSController::InitializeFSControl()
break;
case DeviceModel::IS1:
m_pFSCtrl = new ZZ_ATPControl_Serial_Qt;
m_pFSCtrl->Initialize(false, m_fsInfo.strInterface, NULL);
//m_pFSCtrl->Initialize(false, m_fsInfo.strInterface, NULL);
if (m_pFSCtrl->Initialize(false, m_fsInfo.strInterface, m_fsInfo.strSN) != 0)
{
qDebug() << "IS1 Not Opened";
@ -72,7 +72,7 @@ int CAbstractFSController::InitializeFSControl()
break;
case DeviceModel::IS2:
m_pFSCtrl = new ZZ_ATPControl_Serial_Qt;
m_pFSCtrl->Initialize(false, m_fsInfo.strInterface, NULL);
//m_pFSCtrl->Initialize(false, m_fsInfo.strInterface, NULL);
if (m_pFSCtrl->Initialize(false, m_fsInfo.strInterface, m_fsInfo.strSN) != 0)
{
qDebug() << "IS2 Not Opened";

View File

@ -69,6 +69,7 @@ int CMainDataGrabber::SetContext(RunTimeGrabberParams struGrabberRTParams, DataF
int CMainDataGrabber::SetContext(RunTimeGrabberParams struGrabberRTParams, DataFileProcessor &dfpSaver, Scheduler &sScheduler, CMainDataUploader &mduUploader)
{
SetGrabberParams(struGrabberRTParams);
SetGrabberFileProcessor(dfpSaver);
SetTimer(sScheduler);
@ -117,6 +118,11 @@ int CMainDataGrabber::SetUploader(CMainDataUploader &mduUploader/*, RunTimeGrabb
int CMainDataGrabber::InitLS()
{
//InitializeWorkers();
//SetupMsgPipelines_RunTime();
//StartWorkers();
PortInfo piTemp;
piTemp.qstrFullPortName = QString::fromStdString(m_struLinearShutterContext.strInterface);
m_ctrlLS.ILMES_InitializeComm(piTemp, m_struLinearShutterContext.ucProtocolType, m_struLinearShutterContext.ucCmdID);
@ -175,7 +181,7 @@ int CMainDataGrabber::InitializeWorkers()
DeviceAttribute daAttrTemp;
m_pWorkThread->GetDeviceAttr(daAttrTemp);
m_struDeviceContext.usPixels[i] = (ZZ_U16)daAttrTemp.iPixels;
for (ZZ_U16 j=0;j< daAttrTemp.iPixels;j++)
for (ZZ_U16 j = 0; j < daAttrTemp.iPixels; j++)
{
m_struDeviceContext.fWavelength[i][j] = daAttrTemp.fWaveLengthInNM[j];
}
@ -195,7 +201,20 @@ int CMainDataGrabber::StartWorkers()
QThread *pWorkThreadHolder = new QThread();
m_pControlThread[i]->moveToThread(pWorkThreadHolder);
pWorkThreadHolder->start();
// m_pControlThread[i]->InitializeFSControl();
// DeviceAttribute daAttrTemp;
// m_pControlThread[i]->GetDeviceAttr(daAttrTemp);
// m_struDeviceContext.usPixels[i] = (ZZ_U16)daAttrTemp.iPixels;
// for (ZZ_U16 j = 0; j < daAttrTemp.iPixels; j++)
// {
// m_struDeviceContext.fWavelength[i][j] = daAttrTemp.fWaveLengthInNM[j];
// }
}
// m_struRTGP.fscParams = m_struDeviceContext;
// m_pdfpSaver->SetDeviceInfo(m_struDeviceContext);
// m_pmduUploader->SetRTGP(m_struRTGP);
return 0;
}
@ -203,7 +222,8 @@ int CMainDataGrabber::StartWorkers()
int CMainDataGrabber::SetupMsgPipelines()
{
//connect(this, &CMainDataGrabber::SignalStartGrabOnce, this, &CMainDataGrabber::StartGrab);
//connect(m_GrabTimer, &QTimer::timeout, this, &CMainDataGrabber::OnTimeCounter);
//FS
for (ZZ_U8 i = 0; i < m_struDeviceContext.ucDeviceNumber; i++)
{
connect(this, &CMainDataGrabber::SignalStartGrabOnce_Signal, m_pControlThread[i], &CAbstractFSController::StartAcquisitionSignal);
@ -213,22 +233,32 @@ int CMainDataGrabber::SetupMsgPipelines()
}
connect(this, &CMainDataGrabber::SignalGrabOnceFinished, this, &CMainDataGrabber::GrabOnceFinished);
//connect(m_GrabTimer, &QTimer::timeout, this, &CMainDataGrabber::OnTimeCounter);
connect(m_psScheduler, &Scheduler::SignalGrabOnce, this, &CMainDataGrabber::OnTimeCounter);
connect(this, &CMainDataGrabber::SignalStartGrab, this, &CMainDataGrabber::StartGrabTimer);
connect(this, &CMainDataGrabber::SignalGrabOnceFinished_Signal, this, &CMainDataGrabber::GrabOnceFinished_Signal);
connect(this, &CMainDataGrabber::SignalGrabOnceFinished_Dark, this, &CMainDataGrabber::GrabOnceFinished_Dark);
//net work
connect(this, &CMainDataGrabber::SignalPushOneDataFrame, m_pmduUploader,&CMainDataUploader::SlotPushOneDataFrame);
qDebug()<<connect(this,&CMainDataGrabber::SignalLSInit,this,&CMainDataGrabber::InitLS);
//shutter
connect(this,&CMainDataGrabber::SignalLSInit,this,&CMainDataGrabber::InitLS);
return 0;
}
int CMainDataGrabber::SetupMsgPipelines_RunTime()
{
for (ZZ_U8 i = 0; i < m_struDeviceContext.ucDeviceNumber; i++)
{
connect(this, &CMainDataGrabber::SignalStartGrabOnce_Signal, m_pControlThread[i], &CAbstractFSController::StartAcquisitionSignal);
connect(this, &CMainDataGrabber::SignalStartGrabOnce_Dark, m_pControlThread[i], &CAbstractFSController::StartAcquisitionDark);
connect(m_pControlThread[i], &CAbstractFSController::SignalAcqFinished_Signal, this, &CMainDataGrabber::HandleThreadEvent_Signal);
connect(m_pControlThread[i], &CAbstractFSController::SignalAcqFinished_Dark, this, &CMainDataGrabber::HandleThreadEvent_Dark);
}
return 0;
}
int CMainDataGrabber::StartGrab()
{
emit SignalStartGrab();
@ -439,7 +469,7 @@ int CMainDataGrabber::GrabOnceFinished()
//emit SignalPushOneDataFrame(vecData);
m_pmduUploader->SetData(vecData);
emit SignalPushOneDataFrame();
// emit SignalPushOneDataFrame();
m_pdfpSaver->SetData(vecData);
m_pdfpSaver->WriteDataFile();
m_iFlagIsCapturing = 0;

View File

@ -59,6 +59,7 @@ private:
int InitializeWorkers();
int StartWorkers();
int SetupMsgPipelines();
int SetupMsgPipelines_RunTime();
int StartGrab();

View File

@ -2,11 +2,11 @@
#include "ATPControl_Serial_QT.h"
#include "ZZ_Math_HDRONLY.h"
ZZ_ATPControl_Serial_Qt::ZZ_ATPControl_Serial_Qt()
ZZ_ATPControl_Serial_Qt::ZZ_ATPControl_Serial_Qt(QObject* parent /*= nullptr*/)
{
m_pSerialPort = new QSerialPort;
//connect(m_pSerialPort, &QSerialPort::readyRead, this, &ZZ_ATPControl_Serial_Qt::ReadMessage);
m_iBaudRate = 115200;
//emit SignalInit_Self();
}
ZZ_ATPControl_Serial_Qt::~ZZ_ATPControl_Serial_Qt()
@ -18,6 +18,19 @@ ZZ_ATPControl_Serial_Qt::~ZZ_ATPControl_Serial_Qt()
}
// int ZZ_ATPControl_Serial_Qt::ReInit()
// {
// m_pSerialPort->close();
// delete m_pSerialPort;
//
// m_pSerialPort = new QSerialPort;
//
// m_pSerialPort->setPortName("COM7");
// m_pSerialPort->setReadBufferSize(512);
// bool bRes = m_pSerialPort->setBaudRate(m_iBaudRate);
// bRes = m_pSerialPort->open(QIODevice::ReadWrite);
// }
// int ZZ_ATPControl_Serial_Qt::SetBaudRate(int iBaud)
// {
// m_iBaudRate = iBaud;
@ -27,6 +40,9 @@ ZZ_ATPControl_Serial_Qt::~ZZ_ATPControl_Serial_Qt()
int ZZ_ATPControl_Serial_Qt::Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName)
{
//connect(this, &ZZ_ATPControl_Serial_Qt::SignalInit_Self, this, &ZZ_ATPControl_Serial_Qt::Init_Self);
//emit SignalInit_Self();
QString qstrPortName = QString::fromStdString(ucPortNumber);
m_pSerialPort->setPortName(qstrPortName);
@ -47,6 +63,18 @@ int ZZ_ATPControl_Serial_Qt::Initialize(bool bIsUSBMode, std::string ucPortNumbe
return 2;
}
GetDeviceInfo(m_diDeviceInfo);
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;
}
@ -319,6 +347,12 @@ int ZZ_ATPControl_Serial_Qt::ParseData(QByteArray &qbData)
return 0;
}
int ZZ_ATPControl_Serial_Qt::Init_Self()
{
m_pSerialPort = new QSerialPort;
return 0;
}
int ZZ_ATPControl_Serial_Qt::PerformAutoExposure(float fMinScaleFactor, float fMaxScaleFactor, float &fPredictedExposureTime)
{
using namespace ZZ_MATH;
@ -500,6 +534,7 @@ int ZZ_ATPControl_Serial_Qt::GetExposureTime(int &iExposureTimeInMS)
int ZZ_ATPControl_Serial_Qt::SingleShot(DataFrame &dfData)
{
QByteArray qbSend, qbRecv;
qbSend.clear();
qbRecv.clear();
@ -511,6 +546,8 @@ int ZZ_ATPControl_Serial_Qt::SingleShot(DataFrame &dfData)
RecvData(qbRecv);
ParseData(qbRecv);
ZZ_U16 usData[4096] = {0};
if ((ZZ_U8)qbRecv[0] != 0)
{
qDebug() << "Err:SingleShot Failed.Exit Code:1";
@ -518,9 +555,13 @@ int ZZ_ATPControl_Serial_Qt::SingleShot(DataFrame &dfData)
}
else
{
//int aaa = qbRecv.size();
int iDataSizeInPixel = (qbRecv.size() - 1) / 2;
memcpy(dfData.lData, qbRecv.data() + 1, iDataSizeInPixel * 2);
memcpy(usData, qbRecv.data() + 1, iDataSizeInPixel * 2);
for (int i=0;i< iDataSizeInPixel;i++)
{
dfData.lData[i] = usData[i];
}
}
return 0;

View File

@ -12,16 +12,19 @@ using namespace ZZ_MISCDEF::IRIS::FS;
class ZZ_ATPControl_Serial_Qt:public CIrisFSBase
{
//Q_OBJECT
Q_OBJECT
public:
ZZ_ATPControl_Serial_Qt();
ZZ_ATPControl_Serial_Qt(QObject* parent = nullptr);
virtual ~ZZ_ATPControl_Serial_Qt();
public:
//do not call
//int ReInit();
//<2F><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>
//int SetBaudRate(int iBaud);
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>
int Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName);
//<2F>ر<EFBFBD><D8B1>
void Close();
@ -79,6 +82,10 @@ private:
int SendCommand(QByteArray qbCommand);
int RecvData(QByteArray &qbData);
int ParseData(QByteArray &qbData);
public slots:
int Init_Self();
signals:
void SignalInit_Self();
//private slots :
//void ReadMessage();
};

View File

@ -37,10 +37,10 @@ void DataFileProcessor::SetData(std::vector<std::vector<DataFrame>> vecData)
bool DataFileProcessor::WriteDataFile()
{
//GenerateFilePath();
//WriteEnvironmentInfo();
//WriteDeviceInfo();
//WriteData();
GenerateFilePath();
WriteEnvironmentInfo();
WriteDeviceInfo();
WriteData();
return 1;
}
@ -184,6 +184,7 @@ void DataFileProcessor::WriteDeviceInfo()
qfData.write("Depth,");
qstrTemp = QString::number(m_struDeviceContext.lDepth[i]);
qfData.write(qstrTemp.toLatin1());
qfData.write(",");
qfData.write("TEC Temperature,");
qstrTemp = QString::number(m_vecData[i][0].fTemperature);

View File

@ -1,10 +1,11 @@
#include <string>
#include "ZZ_Types.h"
#include "pch.h"
#pragma once
using namespace ZZ_MISCDEF;
using namespace ZZ_MISCDEF::IRIS::FS;
class CIrisFSBase
class CIrisFSBase:public QObject
{
public:
//CIrisFSBase();

View File

@ -45,8 +45,10 @@
QString qstrTemp= m_qsDeviceConfig->value(QString("FS%1/Model").arg(i+1), "Null").toString();
m_struFSContext.ucDeviceModel[i]= enumDeviceModel.keysToValue(qstrTemp.toLatin1().data());
int iInterface= m_qsDeviceConfig->value(QString("FS%1/Port").arg(i + 1), -2).toInt();
m_struFSContext.strInterface[i] = iInterface;
//int iInterface= m_qsDeviceConfig->value(QString("FS%1/Port").arg(i + 1), -2).toString();
//m_struFSContext.strInterface[i] = iInterface;
qstrTemp = m_qsDeviceConfig->value(QString("FS%1/Port").arg(i + 1), -2).toString();
m_struFSContext.strInterface[i] = qstrTemp.toStdString();
qstrTemp = m_qsDeviceConfig->value(QString("FS%1/UID").arg(i + 1), "Null").toString();
m_struFSContext.strSN[i] = qstrTemp.toStdString();

View File

@ -34,7 +34,8 @@ int ZZ_HttpTransfer::SendData()
QNetworkRequest qnRequest;
qnRequest.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/json"));
qnRequest.setUrl(QUrl("http://172.16.0.234/fileup/Data_uper.php"));
QString qstrURL = m_qstrUploadURL + "/Data_uper.php";
qnRequest.setUrl(QUrl(qstrURL));
QByteArray qbSend;
QString qstrSend;
@ -57,15 +58,15 @@ int ZZ_HttpTransfer::SendData()
qbSend.append((char*)m_vecCalcedData[i][j].fData, sizeof(float)*m_vecCalcedData[i][j].iPixels);
m_pNetworkManagerThread->post(qnRequest, qbSend);
iFlagIsReplied = 0;
m_iFlagIsReplied = 0;
int iCount = 0;
while (!iFlagIsReplied)
while (!m_iFlagIsReplied)
{
iCount++;
Delay_MSec(500);
if (iCount > 20)
{
iFlagIsReplied = 1;
m_iFlagIsReplied = 1;
qDebug() << "Reply Timeout:Upload Data ";
}
}
@ -89,12 +90,14 @@ int ZZ_HttpTransfer::SendInfo()
QNetworkRequest qnRequest;
qnRequest.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/json"));
qnRequest.setUrl(QUrl("http://172.16.0.234/fileup/Dev_info_uper.php"));
QString qstrURL = m_qstrUploadURL + "/Dev_info_uper.php";
qnRequest.setUrl(QUrl(qstrURL));
//qnRequest.setUrl(QUrl("http://172.16.0.234/fileup/Dev_info_uper.php"));
QByteArray qbSend;
QString qstrSend;
QString qstrWaveLength;
iFlagIsReplied = false;
m_iFlagIsReplied = false;
for (int i = 0; i < m_struGrabberRTParams.fscParams.ucDeviceNumber; i++)
{
qstrSend = "Location:" + QString("%1").arg(m_struEC.qstrLocation) + "####";
@ -126,15 +129,15 @@ int ZZ_HttpTransfer::SendInfo()
qbSend = qstrSend.toLatin1();
m_pNetworkManager->post(qnRequest, qbSend);
iFlagIsReplied = 0;
m_iFlagIsReplied = 0;
int iCount = 0;
while (!iFlagIsReplied)
while (!m_iFlagIsReplied)
{
iCount++;
Delay_MSec(500);
if (iCount>2)
{
iFlagIsReplied = 1;
m_iFlagIsReplied = 1;
qDebug() << "Reply Timeout:Upload Info ";
}
}
@ -155,7 +158,9 @@ int ZZ_HttpTransfer::SendErr()
QNetworkRequest qnRequest;
qnRequest.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/json"));
qnRequest.setUrl(QUrl("http://172.16.0.234/fileup/Warning.php"));
QString qstrURL = m_qstrUploadURL + "/Warning.php";
qnRequest.setUrl(QUrl(qstrURL));
//qnRequest.setUrl(QUrl("http://172.16.0.234/fileup/Warning.php"));
QByteArray qbSend;
QString qstrSend;
@ -194,15 +199,15 @@ int ZZ_HttpTransfer::SendErr()
qbSend = qstrSend.toLatin1();
m_pNetworkManager->post(qnRequest, qbSend);
iFlagIsReplied = 0;
m_iFlagIsReplied = 0;
int iCount = 0;
while (!iFlagIsReplied)
while (!m_iFlagIsReplied)
{
iCount++;
Delay_MSec(500);
if (iCount > 2)
{
iFlagIsReplied = 1;
m_iFlagIsReplied = 1;
qDebug() << "Reply Timeout:Upload Info ";
}
}
@ -218,6 +223,8 @@ void ZZ_HttpTransfer::SetContext(EContext struEC, MEContext struMEC)
{
m_struEC = struEC;
m_struMEC = struMEC;
m_qstrUploadURL = m_struMEC.qstrHTTPServer;
}
void ZZ_HttpTransfer::SetDeviceInfo(RunTimeGrabberParams struGrabberRTParams)
@ -245,7 +252,7 @@ int ZZ_HttpTransfer::SlotReplyFinished(QNetworkReply* qnReply)
QByteArray qbData = qnReply->readAll();
if (qnReply->error()== QNetworkReply::NoError)
{
iFlagIsReplied = 1;
m_iFlagIsReplied = 1;
}
qnReply->abort();
qnReply->close();
@ -262,7 +269,7 @@ int ZZ_HttpTransfer::SlotReplyFinishedThread(QNetworkReply* qnReply)
QByteArray qbData = qnReply->readAll();
if (qnReply->error() == QNetworkReply::NoError)
{
iFlagIsReplied = 1;
m_iFlagIsReplied = 1;
}
qnReply->abort();
qnReply->close();

View File

@ -42,7 +42,8 @@ private:
RunTimeGrabberParams m_struGrabberRTParams;
vector<vector<CalDataFrame>> m_vecCalcedData;
int iFlagIsReplied;
QString m_qstrUploadURL;
int m_iFlagIsReplied;
public slots:
int SlotReplyFinished(QNetworkReply* qnReply);
int SlotReplyFinishedThread(QNetworkReply* qnReply);

View File

@ -70,7 +70,7 @@ void CMainDataUploader::Calibration()
m_vecCalcedData[j][i].qstrGrabDate = m_qstrGrabDate;
for (int k=0;k< m_struGrabberRTParams.fscParams.usPixels[j];k++)
{
m_vecCalcedData[j][i].fData[k] = (float)(m_vecData[j][i].lData[k]* m_vecCalData[j][i].dCal_Gain[k]);
m_vecCalcedData[j][i].fData[k] = (float)(m_vecData[j][i].lData[k]* m_vecCalData[j][i].dCal_Gain[k]* m_vecCalData[j][i].uiExposureTimeInMS/m_vecData[j][i].usExposureTimeInMS);
}
}
}