mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-12-14 19:03:32 +08:00
合并
This commit is contained in:
@ -18,11 +18,11 @@ include_directories("source/FS")
|
|||||||
include_directories("source/Logger")
|
include_directories("source/Logger")
|
||||||
include_directories("source/ZZ_SDK")
|
include_directories("source/ZZ_SDK")
|
||||||
include_directories("source/Settings")
|
include_directories("source/Settings")
|
||||||
include_directories("source/Thread")
|
include_directories("source/CaptureThread")
|
||||||
include_directories("source/LinearShutter")
|
include_directories("source/LinearShutter")
|
||||||
include_directories("source/OSIF/include")
|
include_directories("source/OSIF/include")
|
||||||
include_directories("source/Misc_Detector")
|
include_directories("source/Misc_Detector")
|
||||||
include_directories("source/Upload")
|
include_directories("source/Uploader")
|
||||||
|
|
||||||
link_directories("source/OSIF/DLib")
|
link_directories("source/OSIF/DLib")
|
||||||
link_directories("/home/pi/SeaBrease/lib")
|
link_directories("/home/pi/SeaBrease/lib")
|
||||||
|
|||||||
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
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
@ -1,9 +1,5 @@
|
|||||||
[DEVICE INFO]
|
[DEVICE INFO]
|
||||||
TotalSpectrometer=1
|
TotalSpectrometer=2
|
||||||
[FS2]
|
|
||||||
Model=ISIF
|
|
||||||
Port=/dev/ttyS1
|
|
||||||
UID=QEP02975
|
|
||||||
[FS1]
|
[FS1]
|
||||||
Model=OSIFAlpha
|
Model=OSIFAlpha
|
||||||
Port=-1
|
Port=-1
|
||||||
@ -17,11 +13,12 @@ Model=Null
|
|||||||
Port=/dev/ttyUSB1
|
Port=/dev/ttyUSB1
|
||||||
Type=1
|
Type=1
|
||||||
DCID=1
|
DCID=1
|
||||||
TotalPosition=5
|
TotalPosition=6
|
||||||
Position0=10000
|
Position0=2000
|
||||||
Position1=91947
|
Position1=110000
|
||||||
Position2=219299
|
Position2=220000
|
||||||
Position3=347535
|
Position3=330000
|
||||||
Position4=474904
|
Position4=440000
|
||||||
|
Position5=550000
|
||||||
[HUMITURE]
|
[HUMITURE]
|
||||||
Port=/dev/ttyUSB3
|
Port=/dev/ttyUSB3
|
||||||
30
main.cpp
30
main.cpp
@ -6,6 +6,7 @@
|
|||||||
#include "DataFileProcessor.h"
|
#include "DataFileProcessor.h"
|
||||||
#include "Scheduler.h"
|
#include "Scheduler.h"
|
||||||
#include "GY39Controller.h"
|
#include "GY39Controller.h"
|
||||||
|
#include "MainDataUploader.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@ -26,23 +27,32 @@ int main(int argc, char *argv[])
|
|||||||
ZZ_SysConfigger m_scConfiggerLoader;
|
ZZ_SysConfigger m_scConfiggerLoader;
|
||||||
Scheduler m_sTimer;
|
Scheduler m_sTimer;
|
||||||
CMainDataGrabber m_mdgGrabber;
|
CMainDataGrabber m_mdgGrabber;
|
||||||
|
CMainDataUploader m_mduUploader;
|
||||||
|
ErrInfo m_eiErrInfo;
|
||||||
|
|
||||||
|
m_eiErrInfo.fChassisTempErr = 0;
|
||||||
|
m_eiErrInfo.fTecTempErr = 0;
|
||||||
|
m_eiErrInfo.iDataTransferErr = 0;
|
||||||
|
m_eiErrInfo.iShutterErr = 0;
|
||||||
|
|
||||||
////
|
////
|
||||||
bool bRes;
|
bool bRes;
|
||||||
float m_fChassisTemp, m_fChassisHum;
|
float m_fChassisTemp = 0, m_fChassisHum = 0;
|
||||||
|
|
||||||
RunTimeGrabberParams m_struRuntimeParams;
|
RunTimeGrabberParams m_struRuntimeParams;
|
||||||
EContext m_struEC;
|
EContext m_struEC;
|
||||||
MEContext m_struMEC;
|
MEContext m_struMEC;
|
||||||
HumitureDeviceInfo m_struHumitureDI;
|
HumitureDeviceInfo m_struHumitureDI;
|
||||||
//////////////////////////////////////////////////////////////////////////logger
|
//////////////////////////////////////////////////////////////////////////logger
|
||||||
QT_LOG::ZZ_InitLogger("/home/data/Log/");
|
///create main system logger
|
||||||
|
//QT_LOG::ZZ_InitLogger("/home/data/Log/");
|
||||||
|
|
||||||
|
|
||||||
//m_test123;
|
//m_test123;
|
||||||
//m_test123.Initialize("COM11");
|
//m_test123.Initialize("COM11");
|
||||||
//m_test123.GetHumiture(fTemp, fHum);
|
//m_test123.GetHumiture(fTemp, fHum);
|
||||||
//////////////////////////////////////////////////////////////////////////config
|
//////////////////////////////////////////////////////////////////////////config
|
||||||
|
///turn on power supply
|
||||||
system("gpio write 1 1");//<2F>豸<EFBFBD>ϵ<EFBFBD>
|
system("gpio write 1 1");//<2F>豸<EFBFBD>ϵ<EFBFBD>
|
||||||
qDebug() << "gpio write 1 1......" << endl;
|
qDebug() << "gpio write 1 1......" << endl;
|
||||||
|
|
||||||
@ -58,25 +68,35 @@ int main(int argc, char *argv[])
|
|||||||
m_dfpSaver.SetEnvironmentContex(m_struEC);
|
m_dfpSaver.SetEnvironmentContex(m_struEC);
|
||||||
m_dfpSaver.SetManmadeEnviromentalContext(m_struMEC);
|
m_dfpSaver.SetManmadeEnviromentalContext(m_struMEC);
|
||||||
|
|
||||||
m_ctrlHumitureDetector.Initialize(m_struHumitureDI.qstrInterfaceName.toStdString());
|
m_mduUploader.SetContext(m_struEC, m_struMEC);
|
||||||
|
//m_ctrlHumitureDetector.Initialize(m_struHumitureDI.qstrInterfaceName.toStdString());
|
||||||
//////////////////////////////////////////////////////////////////////////prepare
|
//////////////////////////////////////////////////////////////////////////prepare
|
||||||
m_sTimer.Preheating();
|
m_sTimer.Preheating();
|
||||||
m_ctrlHumitureDetector.GetHumiture_retry(m_fChassisTemp, m_fChassisHum);
|
//m_ctrlHumitureDetector.GetHumiture_retry(m_fChassisTemp, m_fChassisHum);
|
||||||
|
|
||||||
m_struEC.qstrCaseTemperature= QString("%1").arg(m_fChassisTemp);
|
m_struEC.qstrCaseTemperature= QString("%1").arg(m_fChassisTemp);
|
||||||
m_struEC.qstrCaseHumidity = QString("%1").arg(m_fChassisHum);
|
m_struEC.qstrCaseHumidity = QString("%1").arg(m_fChassisHum);
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
QThread* m_pqDataGrabberThreadHolder = new QThread();
|
QThread* m_pqDataGrabberThreadHolder = new QThread();
|
||||||
QThread* m_pqTimerThreadHolder = new QThread();
|
QThread* m_pqTimerThreadHolder = new QThread();
|
||||||
|
QThread* m_pqUploaderThreadHolder = new QThread();
|
||||||
|
|
||||||
m_mdgGrabber.moveToThread(m_pqDataGrabberThreadHolder);
|
m_mdgGrabber.moveToThread(m_pqDataGrabberThreadHolder);
|
||||||
m_sTimer.moveToThread(m_pqTimerThreadHolder);
|
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_mdgGrabber.SetContext(m_struRuntimeParams, m_dfpSaver, m_sTimer, m_mduUploader);
|
||||||
m_mdgGrabber.Init_Normal();
|
m_mdgGrabber.Init_Normal();
|
||||||
|
|
||||||
|
m_mduUploader.Initialize();
|
||||||
|
m_mduUploader.SetErr(m_eiErrInfo);
|
||||||
|
m_mduUploader.UploadInfo();
|
||||||
|
m_mduUploader.UploadErr();
|
||||||
|
|
||||||
m_pqDataGrabberThreadHolder->start();
|
m_pqDataGrabberThreadHolder->start();
|
||||||
m_pqTimerThreadHolder->start();
|
m_pqTimerThreadHolder->start();
|
||||||
|
m_pqUploaderThreadHolder->start();
|
||||||
|
|
||||||
m_mdgGrabber.Init_Self();
|
m_mdgGrabber.Init_Self();
|
||||||
m_sTimer.SelfStart();
|
m_sTimer.SelfStart();
|
||||||
|
|||||||
@ -90,6 +90,12 @@ int CAbstractFSController::InitializeFSControl()
|
|||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iRes = m_pFSCtrl->SetDeviceTemperature(0);
|
||||||
|
if (iRes != 0)
|
||||||
|
{
|
||||||
|
qDebug() << "SetDeviceTemperature Failed" << iRes;
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -310,7 +316,7 @@ int CAbstractFSController::StartAcquisitionSignal()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
PerformAutoExposure();
|
//PerformAutoExposure();
|
||||||
TakeSignalFrame();
|
TakeSignalFrame();
|
||||||
|
|
||||||
qDebug() << "Stop acq Signal" << " Thread ID:" << m_iThreadID;
|
qDebug() << "Stop acq Signal" << " Thread ID:" << m_iThreadID;
|
||||||
@ -10,6 +10,9 @@ CMainDataGrabber::CMainDataGrabber(QObject* parent /*= nullptr*/)
|
|||||||
m_iFlagIsCapturing = false;
|
m_iFlagIsCapturing = false;
|
||||||
m_iFlagIsCapturing_Signal = false;
|
m_iFlagIsCapturing_Signal = false;
|
||||||
m_iFlagIsCapturing_Dark = false;
|
m_iFlagIsCapturing_Dark = false;
|
||||||
|
|
||||||
|
//qRegisterMetaType<DataFrame>("DataFrame");
|
||||||
|
//qRegisterMetaType<vector<vector<DataFrame>>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
CMainDataGrabber::~CMainDataGrabber()
|
CMainDataGrabber::~CMainDataGrabber()
|
||||||
@ -64,6 +67,15 @@ int CMainDataGrabber::SetContext(RunTimeGrabberParams struGrabberRTParams, DataF
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CMainDataGrabber::SetContext(RunTimeGrabberParams struGrabberRTParams, DataFileProcessor &dfpSaver, Scheduler &sScheduler, CMainDataUploader &mduUploader)
|
||||||
|
{
|
||||||
|
SetGrabberParams(struGrabberRTParams);
|
||||||
|
SetGrabberFileProcessor(dfpSaver);
|
||||||
|
SetTimer(sScheduler);
|
||||||
|
SetUploader(mduUploader/*, struGrabberRTParams*/);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void CMainDataGrabber::Init_Normal()
|
void CMainDataGrabber::Init_Normal()
|
||||||
{
|
{
|
||||||
InitThreadStatus();
|
InitThreadStatus();
|
||||||
@ -80,6 +92,8 @@ int CMainDataGrabber::SetGrabberParams(RunTimeGrabberParams struGrabberRTParams)
|
|||||||
m_struLinearShutterContext = struGrabberRTParams.lscParam;
|
m_struLinearShutterContext = struGrabberRTParams.lscParam;
|
||||||
|
|
||||||
m_iTotalThreads = m_struDeviceContext.ucDeviceNumber;
|
m_iTotalThreads = m_struDeviceContext.ucDeviceNumber;
|
||||||
|
|
||||||
|
m_struRTGP = struGrabberRTParams;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,6 +109,12 @@ int CMainDataGrabber::SetTimer(Scheduler &sScheduler)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CMainDataGrabber::SetUploader(CMainDataUploader &mduUploader/*, RunTimeGrabberParams struGrabberRTParams*/)
|
||||||
|
{
|
||||||
|
m_pmduUploader = &mduUploader;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int CMainDataGrabber::InitLS()
|
int CMainDataGrabber::InitLS()
|
||||||
{
|
{
|
||||||
PortInfo piTemp;
|
PortInfo piTemp;
|
||||||
@ -159,10 +179,11 @@ int CMainDataGrabber::InitializeWorkers()
|
|||||||
{
|
{
|
||||||
m_struDeviceContext.fWavelength[i][j] = daAttrTemp.fWaveLengthInNM[j];
|
m_struDeviceContext.fWavelength[i][j] = daAttrTemp.fWaveLengthInNM[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pControlThread.push_back(m_pWorkThread);
|
m_pControlThread.push_back(m_pWorkThread);
|
||||||
}
|
}
|
||||||
|
m_struRTGP.fscParams = m_struDeviceContext;
|
||||||
m_pdfpSaver->SetDeviceInfo(m_struDeviceContext);
|
m_pdfpSaver->SetDeviceInfo(m_struDeviceContext);
|
||||||
|
m_pmduUploader->SetRTGP(m_struRTGP);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,6 +222,8 @@ int CMainDataGrabber::SetupMsgPipelines()
|
|||||||
connect(this, &CMainDataGrabber::SignalGrabOnceFinished_Signal, this, &CMainDataGrabber::GrabOnceFinished_Signal);
|
connect(this, &CMainDataGrabber::SignalGrabOnceFinished_Signal, this, &CMainDataGrabber::GrabOnceFinished_Signal);
|
||||||
connect(this, &CMainDataGrabber::SignalGrabOnceFinished_Dark, this, &CMainDataGrabber::GrabOnceFinished_Dark);
|
connect(this, &CMainDataGrabber::SignalGrabOnceFinished_Dark, this, &CMainDataGrabber::GrabOnceFinished_Dark);
|
||||||
|
|
||||||
|
connect(this, &CMainDataGrabber::SignalPushOneDataFrame, m_pmduUploader,&CMainDataUploader::SlotPushOneDataFrame);
|
||||||
|
|
||||||
qDebug()<<connect(this,&CMainDataGrabber::SignalLSInit,this,&CMainDataGrabber::InitLS);
|
qDebug()<<connect(this,&CMainDataGrabber::SignalLSInit,this,&CMainDataGrabber::InitLS);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -214,7 +237,7 @@ int CMainDataGrabber::StartGrab()
|
|||||||
|
|
||||||
void CMainDataGrabber::Init_Self()
|
void CMainDataGrabber::Init_Self()
|
||||||
{
|
{
|
||||||
emit SignalLSInit();
|
//emit SignalLSInit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,7 +399,7 @@ int CMainDataGrabber::GrabOnceFinished()
|
|||||||
{
|
{
|
||||||
////move to
|
////move to
|
||||||
qDebug()<<"Start ILMES_MoveToPos:"<<i+1;
|
qDebug()<<"Start ILMES_MoveToPos:"<<i+1;
|
||||||
m_ctrlLS.ILMES_MoveToPos(i+1);
|
//m_ctrlLS.ILMES_MoveToPos(i+1);
|
||||||
qDebug() << "Stop ILMES_MoveToPos:" << i + 1;
|
qDebug() << "Stop ILMES_MoveToPos:" << i + 1;
|
||||||
m_struAcqPosSetting.iPosition[i + 1];
|
m_struAcqPosSetting.iPosition[i + 1];
|
||||||
m_iFlagIsCapturing_Signal = 1;
|
m_iFlagIsCapturing_Signal = 1;
|
||||||
@ -389,7 +412,7 @@ int CMainDataGrabber::GrabOnceFinished()
|
|||||||
|
|
||||||
////move to
|
////move to
|
||||||
qDebug() << "Start ILMES_MoveToPos:" << 0;
|
qDebug() << "Start ILMES_MoveToPos:" << 0;
|
||||||
m_ctrlLS.ILMES_MoveToPos(0);
|
//m_ctrlLS.ILMES_MoveToPos(0);
|
||||||
qDebug() << "Stop ILMES_MoveToPos:" << 0;
|
qDebug() << "Stop ILMES_MoveToPos:" << 0;
|
||||||
m_struAcqPosSetting.iPosition[0];
|
m_struAcqPosSetting.iPosition[0];
|
||||||
m_iFlagIsCapturing_Dark = 1;
|
m_iFlagIsCapturing_Dark = 1;
|
||||||
@ -413,6 +436,10 @@ int CMainDataGrabber::GrabOnceFinished()
|
|||||||
}
|
}
|
||||||
vecData.push_back(vecSignal);
|
vecData.push_back(vecSignal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//emit SignalPushOneDataFrame(vecData);
|
||||||
|
m_pmduUploader->SetData(vecData);
|
||||||
|
emit SignalPushOneDataFrame();
|
||||||
m_pdfpSaver->SetData(vecData);
|
m_pdfpSaver->SetData(vecData);
|
||||||
m_pdfpSaver->WriteDataFile();
|
m_pdfpSaver->WriteDataFile();
|
||||||
m_iFlagIsCapturing = 0;
|
m_iFlagIsCapturing = 0;
|
||||||
@ -5,10 +5,13 @@
|
|||||||
#include "DataFileProcessor.h"
|
#include "DataFileProcessor.h"
|
||||||
#include "Scheduler.h"
|
#include "Scheduler.h"
|
||||||
#include "VSMD12XControl.h"
|
#include "VSMD12XControl.h"
|
||||||
|
#include "MainDataUploader.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||||
|
|
||||||
|
//Q_DECLARE_METATYPE(vector<vector<DataFrame>>)
|
||||||
|
|
||||||
class CMainDataGrabber :public QObject
|
class CMainDataGrabber :public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -29,16 +32,17 @@ private:
|
|||||||
int m_iFlagIsCapturing_Signal;
|
int m_iFlagIsCapturing_Signal;
|
||||||
int m_iFlagIsCapturing_Dark;
|
int m_iFlagIsCapturing_Dark;
|
||||||
|
|
||||||
DataFileProcessor* m_pdfpSaver;
|
DataFileProcessor * m_pdfpSaver;
|
||||||
Scheduler * m_psScheduler;
|
Scheduler * m_psScheduler;
|
||||||
|
CMainDataUploader * m_pmduUploader;
|
||||||
|
|
||||||
CVSMD12XControl m_ctrlLS;
|
CVSMD12XControl m_ctrlLS;
|
||||||
|
|
||||||
FSContext m_struDeviceContext;
|
FSContext m_struDeviceContext;
|
||||||
LSContext m_struLinearShutterContext;
|
LSContext m_struLinearShutterContext;
|
||||||
AcqPosSettings m_struAcqPosSetting;
|
AcqPosSettings m_struAcqPosSetting;
|
||||||
AcqTimeSettings m_struAcqTime;
|
AcqTimeSettings m_struAcqTime;
|
||||||
|
RunTimeGrabberParams m_struRTGP;
|
||||||
|
|
||||||
//QTimer *m_GrabTimer;
|
//QTimer *m_GrabTimer;
|
||||||
private:
|
private:
|
||||||
@ -49,6 +53,7 @@ private:
|
|||||||
int SetGrabberParams(RunTimeGrabberParams struGrabberRTParams);
|
int SetGrabberParams(RunTimeGrabberParams struGrabberRTParams);
|
||||||
int SetGrabberFileProcessor(DataFileProcessor &dfpSaver);
|
int SetGrabberFileProcessor(DataFileProcessor &dfpSaver);
|
||||||
int SetTimer(Scheduler &sScheduler);
|
int SetTimer(Scheduler &sScheduler);
|
||||||
|
int SetUploader(CMainDataUploader &mduUploader/*, RunTimeGrabberParams struGrabberRTParams*/);
|
||||||
|
|
||||||
int InitThreadStatus();
|
int InitThreadStatus();
|
||||||
int InitializeWorkers();
|
int InitializeWorkers();
|
||||||
@ -59,6 +64,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
int SetContext(RunTimeGrabberParams struGrabberRTParams, DataFileProcessor &dfpSaver, Scheduler &sScheduler);
|
int SetContext(RunTimeGrabberParams struGrabberRTParams, DataFileProcessor &dfpSaver, Scheduler &sScheduler);
|
||||||
|
int SetContext(RunTimeGrabberParams struGrabberRTParams, DataFileProcessor &dfpSaver, Scheduler &sScheduler,CMainDataUploader &mduUploader);
|
||||||
void Init_Normal();
|
void Init_Normal();
|
||||||
void Init_Self();
|
void Init_Self();
|
||||||
|
|
||||||
@ -88,4 +94,6 @@ signals:
|
|||||||
void SignalStartGrab();
|
void SignalStartGrab();
|
||||||
|
|
||||||
void SignalLSInit();
|
void SignalLSInit();
|
||||||
|
void SignalPushOneDataFrame();
|
||||||
|
//void SignalPushOneDataFrame(std::vector<std::vector<DataFrame>> vecData);
|
||||||
};
|
};
|
||||||
@ -1,6 +1,6 @@
|
|||||||
#include "DataFileProcessor.h"
|
#include "DataFileProcessor.h"
|
||||||
|
|
||||||
DataFileProcessor::DataFileProcessor()
|
DataFileProcessor::DataFileProcessor(QObject* parent /*= nullptr*/)
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
m_qstrFilePath = "E:/WorkSpace/TowerOptoSifAndSpectral/Data";
|
m_qstrFilePath = "E:/WorkSpace/TowerOptoSifAndSpectral/Data";
|
||||||
@ -37,10 +37,10 @@ void DataFileProcessor::SetData(std::vector<std::vector<DataFrame>> vecData)
|
|||||||
|
|
||||||
bool DataFileProcessor::WriteDataFile()
|
bool DataFileProcessor::WriteDataFile()
|
||||||
{
|
{
|
||||||
GenerateFilePath();
|
//GenerateFilePath();
|
||||||
WriteEnvironmentInfo();
|
//WriteEnvironmentInfo();
|
||||||
WriteDeviceInfo();
|
//WriteDeviceInfo();
|
||||||
WriteData();
|
//WriteData();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,6 +153,10 @@ void DataFileProcessor::WriteDeviceInfo()
|
|||||||
qfData.write("TotalSpectrometer,");
|
qfData.write("TotalSpectrometer,");
|
||||||
qstrTemp = QString::number(m_struDeviceContext.ucDeviceNumber);
|
qstrTemp = QString::number(m_struDeviceContext.ucDeviceNumber);
|
||||||
qfData.write(qstrTemp.toLatin1());
|
qfData.write(qstrTemp.toLatin1());
|
||||||
|
qfData.write(",");
|
||||||
|
qfData.write("TotalScanPoints,");
|
||||||
|
qstrTemp = QString::number(m_vecData[0].size());
|
||||||
|
qfData.write(qstrTemp.toLatin1());
|
||||||
qfData.write("\n");
|
qfData.write("\n");
|
||||||
|
|
||||||
for (int i=0;i< m_struDeviceContext.ucDeviceNumber;i++)
|
for (int i=0;i< m_struDeviceContext.ucDeviceNumber;i++)
|
||||||
@ -181,6 +185,10 @@ void DataFileProcessor::WriteDeviceInfo()
|
|||||||
qstrTemp = QString::number(m_struDeviceContext.lDepth[i]);
|
qstrTemp = QString::number(m_struDeviceContext.lDepth[i]);
|
||||||
qfData.write(qstrTemp.toLatin1());
|
qfData.write(qstrTemp.toLatin1());
|
||||||
|
|
||||||
|
qfData.write("TEC Temperature,");
|
||||||
|
qstrTemp = QString::number(m_vecData[i][0].fTemperature);
|
||||||
|
qfData.write(qstrTemp.toLatin1());
|
||||||
|
|
||||||
qfData.write("\n");
|
qfData.write("\n");
|
||||||
|
|
||||||
qfData.write("Wavelength,");
|
qfData.write("Wavelength,");
|
||||||
@ -222,7 +230,15 @@ bool DataFileProcessor::WriteData()
|
|||||||
qstrTemp = QString("_P%1").arg(j + 1);
|
qstrTemp = QString("_P%1").arg(j + 1);
|
||||||
qfData.write(qstrTemp.toLatin1());
|
qfData.write(qstrTemp.toLatin1());
|
||||||
qfData.write(",");
|
qfData.write(",");
|
||||||
qfData.write("valid");
|
if ((m_vecData[i][j].fTemperature < 5) && (m_vecData[i][j].fTemperature> -5))
|
||||||
|
{
|
||||||
|
qfData.write("valid");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qfData.write("invalid");
|
||||||
|
}
|
||||||
|
|
||||||
qfData.write(",");
|
qfData.write(",");
|
||||||
qstrTemp = QString::number(m_vecData[i][j].usExposureTimeInMS);
|
qstrTemp = QString::number(m_vecData[i][j].usExposureTimeInMS);
|
||||||
qfData.write(qstrTemp.toLatin1());
|
qfData.write(qstrTemp.toLatin1());
|
||||||
|
|||||||
@ -4,10 +4,11 @@
|
|||||||
using namespace ZZ_MISCDEF::ZZ_DATAFILE;
|
using namespace ZZ_MISCDEF::ZZ_DATAFILE;
|
||||||
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||||
using namespace ZZ_MISCDEF::IRIS::FS;
|
using namespace ZZ_MISCDEF::IRIS::FS;
|
||||||
class DataFileProcessor
|
class DataFileProcessor :public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DataFileProcessor();
|
DataFileProcessor(QObject* parent = nullptr);
|
||||||
virtual ~DataFileProcessor();
|
virtual ~DataFileProcessor();
|
||||||
public:
|
public:
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -394,6 +394,8 @@ int OceanOptics_lib::SetDeviceTemperature(float fTemperature)
|
|||||||
//<2F><>ȡ<EFBFBD>¶<EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD>
|
//<2F><>ȡ<EFBFBD>¶<EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD>
|
||||||
int OceanOptics_lib::GetDeviceTemperature(float &fTemperature)
|
int OceanOptics_lib::GetDeviceTemperature(float &fTemperature)
|
||||||
{
|
{
|
||||||
|
fTemperature = 0;
|
||||||
|
|
||||||
if (m_iSpectralmeterHandle == -100)
|
if (m_iSpectralmeterHandle == -100)
|
||||||
{
|
{
|
||||||
printf("\nNo!!!!!!!!!!!!\n");
|
printf("\nNo!!!!!!!!!!!!\n");
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
//<2F><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ļ<EFBFBD>
|
//<2F><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ļ<EFBFBD>
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -23,9 +23,9 @@ namespace ZZ_MISCDEF
|
|||||||
{
|
{
|
||||||
typedef struct tagDataFrame
|
typedef struct tagDataFrame
|
||||||
{
|
{
|
||||||
ZZ_U16 usExposureTimeInMS;
|
ZZ_U32 usExposureTimeInMS;
|
||||||
ZZ_S32 lData[4096];
|
ZZ_S32 lData[4096];
|
||||||
float fTemperature = -1000;
|
float fTemperature = 0;
|
||||||
double dTimes = 0;
|
double dTimes = 0;
|
||||||
}DataFrame;
|
}DataFrame;
|
||||||
|
|
||||||
@ -179,6 +179,14 @@ namespace ZZ_MISCDEF
|
|||||||
//<2F><><EFBFBD>в<EFBFBD><D0B2><EFBFBD>
|
//<2F><><EFBFBD>в<EFBFBD><D0B2><EFBFBD>
|
||||||
namespace ZZ_RUNPARAMS
|
namespace ZZ_RUNPARAMS
|
||||||
{
|
{
|
||||||
|
typedef struct tagErrorInfo
|
||||||
|
{
|
||||||
|
int iDataTransferErr = -1000;
|
||||||
|
float fTecTempErr = -1000;
|
||||||
|
int iShutterErr = -1000;
|
||||||
|
float fChassisTempErr = -1000;
|
||||||
|
}ErrInfo;
|
||||||
|
|
||||||
typedef struct tagFiberSpecContext
|
typedef struct tagFiberSpecContext
|
||||||
{
|
{
|
||||||
ZZ_U8 ucDeviceNumber;
|
ZZ_U8 ucDeviceNumber;
|
||||||
@ -309,6 +317,25 @@ namespace ZZ_MISCDEF
|
|||||||
|
|
||||||
|
|
||||||
}ATPDataHeader;
|
}ATPDataHeader;
|
||||||
|
|
||||||
|
typedef struct tagCalibrationFrame
|
||||||
|
{
|
||||||
|
ZZ_U32 uiExposureTimeInMS;
|
||||||
|
float fTemperature;
|
||||||
|
int iPixels;
|
||||||
|
float fWaveLength[4096] = { 0 };
|
||||||
|
double dCal_Gain[4096] = { 0 };
|
||||||
|
double dCal_Offset[4096] = { 0 };
|
||||||
|
}CalFrame;
|
||||||
|
|
||||||
|
typedef struct tagCalDataFrame
|
||||||
|
{
|
||||||
|
ZZ_U32 usExposureTimeInMS;
|
||||||
|
float fTemperature = 0;
|
||||||
|
int iPixels;
|
||||||
|
float fData[4096];
|
||||||
|
QString qstrGrabDate;
|
||||||
|
}CalDataFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
//misc detector
|
//misc detector
|
||||||
|
|||||||
@ -19,6 +19,7 @@ GY39Controller::~GY39Controller()
|
|||||||
int GY39Controller::SendCommand(QByteArray qbCommand)
|
int GY39Controller::SendCommand(QByteArray qbCommand)
|
||||||
{
|
{
|
||||||
qint64 qi64Write = m_pSerialPort->write(qbCommand);
|
qint64 qi64Write = m_pSerialPort->write(qbCommand);
|
||||||
|
m_pSerialPort->waitForBytesWritten(5000);
|
||||||
if (qi64Write != qbCommand.size())
|
if (qi64Write != qbCommand.size())
|
||||||
{
|
{
|
||||||
qDebug() << "Err:write Failed.Exit Code:1" << qi64Write;
|
qDebug() << "Err:write Failed.Exit Code:1" << qi64Write;
|
||||||
@ -36,7 +37,7 @@ int GY39Controller::RecvHumitureData(QByteArray &qbData)
|
|||||||
int iCounter = 0;
|
int iCounter = 0;
|
||||||
while (qbData.size() < 15)
|
while (qbData.size() < 15)
|
||||||
{
|
{
|
||||||
m_pSerialPort->waitForReadyRead(50);
|
m_pSerialPort->waitForReadyRead(5000);
|
||||||
QByteArray qbTemp = m_pSerialPort->readAll();
|
QByteArray qbTemp = m_pSerialPort->readAll();
|
||||||
qbData.append(qbTemp);
|
qbData.append(qbTemp);
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "pch.h"
|
|
||||||
#include "ZZ_Types.h"
|
|
||||||
289
source/Uploader/DataFileTransfer.cpp
Normal file
289
source/Uploader/DataFileTransfer.cpp
Normal file
@ -0,0 +1,289 @@
|
|||||||
|
#include "DataFileTransfer.h"
|
||||||
|
ZZ_HttpTransfer::ZZ_HttpTransfer(QObject* parent /*= nullptr*/)
|
||||||
|
{
|
||||||
|
m_pNetworkManager = nullptr;
|
||||||
|
m_pNetworkManagerThread = nullptr;
|
||||||
|
//connect(this, &ZZ_HttpTransfer::SignalInit_Self, this, &ZZ_HttpTransfer::SlotInit_Self);
|
||||||
|
}
|
||||||
|
|
||||||
|
ZZ_HttpTransfer::~ZZ_HttpTransfer()
|
||||||
|
{
|
||||||
|
if (m_pNetworkManager!= nullptr)
|
||||||
|
{
|
||||||
|
delete m_pNetworkManager;
|
||||||
|
}
|
||||||
|
if (m_pNetworkManagerThread != nullptr)
|
||||||
|
{
|
||||||
|
delete m_pNetworkManagerThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// void ZZ_HttpTransfer::Init_Self()
|
||||||
|
// {
|
||||||
|
// emit SignalInit_Self();
|
||||||
|
// }
|
||||||
|
|
||||||
|
int ZZ_HttpTransfer::SendData()
|
||||||
|
{
|
||||||
|
if (m_pNetworkManagerThread == nullptr)
|
||||||
|
{
|
||||||
|
m_pNetworkManagerThread = new QNetworkAccessManager();
|
||||||
|
connect(m_pNetworkManagerThread, SIGNAL(finished(QNetworkReply*)), this, SLOT(SlotReplyFinishedThread(QNetworkReply*)));
|
||||||
|
}
|
||||||
|
|
||||||
|
QNetworkRequest qnRequest;
|
||||||
|
qnRequest.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/json"));
|
||||||
|
qnRequest.setUrl(QUrl("http://172.16.0.234/fileup/Data_uper.php"));
|
||||||
|
|
||||||
|
QByteArray qbSend;
|
||||||
|
QString qstrSend;
|
||||||
|
for (int i = 0; i < m_struGrabberRTParams.fscParams.ucDeviceNumber; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < m_struGrabberRTParams.apsParams.iTotalPosition - 1; j++)
|
||||||
|
{
|
||||||
|
|
||||||
|
qstrSend.clear();
|
||||||
|
qstrSend = m_vecCalcedData[i][j].qstrGrabDate + "##";
|
||||||
|
qstrSend += /*"FS_SN:" +*/ QString::fromLocal8Bit(m_struGrabberRTParams.fscParams.strSN[i].c_str()) + "##";
|
||||||
|
qstrSend += /*"Position:" +*/ QString("%1").arg(j + 1) + "##";
|
||||||
|
qstrSend += /*"ExpTime:" +*/ QString("%1").arg(m_vecCalcedData[i][j].usExposureTimeInMS) + "##";
|
||||||
|
qstrSend += /*"Bands:" +*/ QString("%1").arg(m_vecCalcedData[i][j].iPixels) + "##";
|
||||||
|
qstrSend += /*"temp:" +*/ QString("%1").arg(m_vecCalcedData[i][j].fTemperature) + "##";
|
||||||
|
|
||||||
|
//send
|
||||||
|
qbSend.clear();
|
||||||
|
qbSend.append(qstrSend.toLatin1());
|
||||||
|
qbSend.append((char*)m_vecCalcedData[i][j].fData, sizeof(float)*m_vecCalcedData[i][j].iPixels);
|
||||||
|
|
||||||
|
m_pNetworkManagerThread->post(qnRequest, qbSend);
|
||||||
|
iFlagIsReplied = 0;
|
||||||
|
int iCount = 0;
|
||||||
|
while (!iFlagIsReplied)
|
||||||
|
{
|
||||||
|
iCount++;
|
||||||
|
Delay_MSec(500);
|
||||||
|
if (iCount > 20)
|
||||||
|
{
|
||||||
|
iFlagIsReplied = 1;
|
||||||
|
qDebug() << "Reply Timeout:Upload Data ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ZZ_HttpTransfer::SendInfo()
|
||||||
|
{
|
||||||
|
if (m_pNetworkManager == nullptr)
|
||||||
|
{
|
||||||
|
m_pNetworkManager = new QNetworkAccessManager();
|
||||||
|
connect(m_pNetworkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(SlotReplyFinished(QNetworkReply*)));
|
||||||
|
}
|
||||||
|
|
||||||
|
QNetworkRequest qnRequest;
|
||||||
|
qnRequest.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/json"));
|
||||||
|
qnRequest.setUrl(QUrl("http://172.16.0.234/fileup/Dev_info_uper.php"));
|
||||||
|
|
||||||
|
QByteArray qbSend;
|
||||||
|
QString qstrSend;
|
||||||
|
QString qstrWaveLength;
|
||||||
|
iFlagIsReplied = false;
|
||||||
|
for (int i = 0; i < m_struGrabberRTParams.fscParams.ucDeviceNumber; i++)
|
||||||
|
{
|
||||||
|
qstrSend = "Location:" + QString("%1").arg(m_struEC.qstrLocation) + "####";
|
||||||
|
qstrSend += "DEV_SN:" + QString("%1").arg(m_struEC.qstrDEV_SN) + "####";
|
||||||
|
qstrSend += "FS_SN:" + QString::fromLocal8Bit(m_struGrabberRTParams.fscParams.strSN[i].c_str()) + "####";
|
||||||
|
qstrSend += "GPS_Longtitude:" + QString("%1").arg(m_struEC.qstrGPS_Longtitude) + "####";
|
||||||
|
qstrSend += "GPS_Latitude:" + QString("%1").arg(m_struEC.qstrGPS_Latitude) + "####";
|
||||||
|
qstrSend += "GPS_Altitude:" + QString("%1").arg(m_struEC.qstrGPS_Altitude) + "####";
|
||||||
|
qstrSend += "GPS_North:" + QString("%1").arg(m_struEC.qstrGPS_North) + "####";
|
||||||
|
qstrSend += "InstallationTime:" + QString("%1").arg(m_struMEC.qstrInstallationTime) + "####";
|
||||||
|
qstrSend += "NameOfMaintenanceStaff:" + QString("%1").arg(m_struMEC.qstrNameOfMaintenanceStaff) + "####";
|
||||||
|
qstrSend += "PhoneNumberOfMaintenanceStaff:" + QString("%1").arg(m_struMEC.qstrPhoneNumberOfMaintenanceStaff) + "####";
|
||||||
|
qstrSend += "Bands:" + QString("%1").arg(m_struGrabberRTParams.fscParams.usPixels[i]) + "####";
|
||||||
|
qstrSend += "Positions:" + QString("%1").arg(m_struGrabberRTParams.apsParams.iTotalPosition-1) + "####";
|
||||||
|
qstrSend += "WaveLength:";
|
||||||
|
for (int j=0;j< m_struGrabberRTParams.fscParams.usPixels[i];j++)
|
||||||
|
{
|
||||||
|
qstrWaveLength = QString("%1").arg(m_struGrabberRTParams.fscParams.fWavelength[i][j]);
|
||||||
|
qstrSend += qstrWaveLength;
|
||||||
|
if (j == m_struGrabberRTParams.fscParams.usPixels[i]-1)
|
||||||
|
{
|
||||||
|
//qstrSend += "####";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qstrSend += ",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qbSend = qstrSend.toLatin1();
|
||||||
|
m_pNetworkManager->post(qnRequest, qbSend);
|
||||||
|
iFlagIsReplied = 0;
|
||||||
|
int iCount = 0;
|
||||||
|
while (!iFlagIsReplied)
|
||||||
|
{
|
||||||
|
iCount++;
|
||||||
|
Delay_MSec(500);
|
||||||
|
if (iCount>2)
|
||||||
|
{
|
||||||
|
iFlagIsReplied = 1;
|
||||||
|
qDebug() << "Reply Timeout:Upload Info ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//qDebug() << qstrSend;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ZZ_HttpTransfer::SendErr()
|
||||||
|
{
|
||||||
|
if (m_pNetworkManager == nullptr)
|
||||||
|
{
|
||||||
|
m_pNetworkManager = new QNetworkAccessManager();
|
||||||
|
connect(m_pNetworkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(SlotReplyFinished(QNetworkReply*)));
|
||||||
|
}
|
||||||
|
|
||||||
|
QNetworkRequest qnRequest;
|
||||||
|
qnRequest.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("application/json"));
|
||||||
|
qnRequest.setUrl(QUrl("http://172.16.0.234/fileup/Warning.php"));
|
||||||
|
|
||||||
|
QByteArray qbSend;
|
||||||
|
QString qstrSend;
|
||||||
|
qbSend.clear();
|
||||||
|
qstrSend.clear();
|
||||||
|
|
||||||
|
if (m_struErrInfo.fChassisTempErr==-1000)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qstrSend += "Case_Temp:" + QString("%1").arg(m_struErrInfo.iDataTransferErr);
|
||||||
|
}
|
||||||
|
if (m_struErrInfo.fTecTempErr == -1000)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qstrSend += "##TEC_Temp:" + QString("%1").arg(m_struErrInfo.fTecTempErr);
|
||||||
|
}
|
||||||
|
if (m_struErrInfo.iDataTransferErr == -1000)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qstrSend += "##No_Data:" + QString("%1").arg(m_struErrInfo.iDataTransferErr);
|
||||||
|
}
|
||||||
|
if (m_struErrInfo.iShutterErr == -1000)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qstrSend += "##Shutter_Pos:" + QString("%1").arg(m_struErrInfo.iDataTransferErr);
|
||||||
|
}
|
||||||
|
|
||||||
|
qbSend = qstrSend.toLatin1();
|
||||||
|
m_pNetworkManager->post(qnRequest, qbSend);
|
||||||
|
iFlagIsReplied = 0;
|
||||||
|
int iCount = 0;
|
||||||
|
while (!iFlagIsReplied)
|
||||||
|
{
|
||||||
|
iCount++;
|
||||||
|
Delay_MSec(500);
|
||||||
|
if (iCount > 2)
|
||||||
|
{
|
||||||
|
iFlagIsReplied = 1;
|
||||||
|
qDebug() << "Reply Timeout:Upload Info ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZZ_HttpTransfer::SetErrInfo(ErrInfo struErrInfo)
|
||||||
|
{
|
||||||
|
m_struErrInfo = struErrInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZZ_HttpTransfer::SetContext(EContext struEC, MEContext struMEC)
|
||||||
|
{
|
||||||
|
m_struEC = struEC;
|
||||||
|
m_struMEC = struMEC;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZZ_HttpTransfer::SetDeviceInfo(RunTimeGrabberParams struGrabberRTParams)
|
||||||
|
{
|
||||||
|
m_struGrabberRTParams = struGrabberRTParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZZ_HttpTransfer::SetCalData(vector<vector<CalDataFrame>> vecCalcedData)
|
||||||
|
{
|
||||||
|
m_vecCalcedData.clear();
|
||||||
|
m_vecCalcedData = vecCalcedData;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZZ_HttpTransfer::Delay_MSec(ZZ_U16 usMS)
|
||||||
|
{
|
||||||
|
QEventLoop qeLoop;
|
||||||
|
QTimer::singleShot(usMS, &qeLoop, SLOT(quit()));
|
||||||
|
qeLoop.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ZZ_HttpTransfer::SlotReplyFinished(QNetworkReply* qnReply)
|
||||||
|
{
|
||||||
|
|
||||||
|
QString qstrURL = qnReply->url().toString();
|
||||||
|
QByteArray qbData = qnReply->readAll();
|
||||||
|
if (qnReply->error()== QNetworkReply::NoError)
|
||||||
|
{
|
||||||
|
iFlagIsReplied = 1;
|
||||||
|
}
|
||||||
|
qnReply->abort();
|
||||||
|
qnReply->close();
|
||||||
|
qnReply->deleteLater();
|
||||||
|
qnReply = NULL;
|
||||||
|
//delete qnReply;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ZZ_HttpTransfer::SlotReplyFinishedThread(QNetworkReply* qnReply)
|
||||||
|
{
|
||||||
|
|
||||||
|
QString qstrURL = qnReply->url().toString();
|
||||||
|
QByteArray qbData = qnReply->readAll();
|
||||||
|
if (qnReply->error() == QNetworkReply::NoError)
|
||||||
|
{
|
||||||
|
iFlagIsReplied = 1;
|
||||||
|
}
|
||||||
|
qnReply->abort();
|
||||||
|
qnReply->close();
|
||||||
|
qnReply->deleteLater();
|
||||||
|
qnReply = NULL;
|
||||||
|
//delete qnReply;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// int ZZ_HttpTransfer::SlotInit_Self()
|
||||||
|
// {
|
||||||
|
// if (m_pNetworkManager == nullptr)
|
||||||
|
// {
|
||||||
|
// m_pNetworkManager = new QNetworkAccessManager();
|
||||||
|
// connect(m_pNetworkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(SlotReplyFinished(QNetworkReply*)));
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// delete m_pNetworkManager;
|
||||||
|
// m_pNetworkManager = new QNetworkAccessManager();
|
||||||
|
// connect(m_pNetworkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(SlotReplyFinished(QNetworkReply*)));
|
||||||
|
// }
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
52
source/Uploader/DataFileTransfer.h
Normal file
52
source/Uploader/DataFileTransfer.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "pch.h"
|
||||||
|
#include "ZZ_Types.h"
|
||||||
|
//http://172.16.0.234/fileup/Data_uper.php
|
||||||
|
//http://172.16.0.234/fileup/Dev_info_uper.php
|
||||||
|
//http://172.16.0.234/fileup/Warning.php
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace ZZ_MISCDEF::ZZ_DATAFILE;
|
||||||
|
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||||
|
using namespace ZZ_MISCDEF::IRIS::FS;
|
||||||
|
using namespace ZZ_MISCDEF;
|
||||||
|
|
||||||
|
class ZZ_HttpTransfer :public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ZZ_HttpTransfer(QObject* parent = nullptr);
|
||||||
|
~ZZ_HttpTransfer();
|
||||||
|
public:
|
||||||
|
public:
|
||||||
|
//void Init_Self();
|
||||||
|
|
||||||
|
int SendData();
|
||||||
|
int SendInfo();
|
||||||
|
int SendErr();
|
||||||
|
|
||||||
|
void SetErrInfo(ErrInfo struErrInfo);
|
||||||
|
void SetContext(EContext struEC, MEContext struMEC);
|
||||||
|
void SetDeviceInfo(RunTimeGrabberParams struGrabberRTParams);
|
||||||
|
void SetCalData(vector<vector<CalDataFrame>> vecCalcedData);
|
||||||
|
private:
|
||||||
|
void Delay_MSec(ZZ_U16 usMS);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QNetworkAccessManager *m_pNetworkManager;
|
||||||
|
QNetworkAccessManager *m_pNetworkManagerThread;
|
||||||
|
|
||||||
|
ErrInfo m_struErrInfo;
|
||||||
|
EContext m_struEC;
|
||||||
|
MEContext m_struMEC;
|
||||||
|
RunTimeGrabberParams m_struGrabberRTParams;
|
||||||
|
vector<vector<CalDataFrame>> m_vecCalcedData;
|
||||||
|
|
||||||
|
int iFlagIsReplied;
|
||||||
|
public slots:
|
||||||
|
int SlotReplyFinished(QNetworkReply* qnReply);
|
||||||
|
int SlotReplyFinishedThread(QNetworkReply* qnReply);
|
||||||
|
//int SlotInit_Self();
|
||||||
|
signals:
|
||||||
|
//void SignalInit_Self();
|
||||||
|
};
|
||||||
134
source/Uploader/MainDataUploader.cpp
Normal file
134
source/Uploader/MainDataUploader.cpp
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
#include "MainDataUploader.h"
|
||||||
|
|
||||||
|
CMainDataUploader::CMainDataUploader(QObject* parent /*= nullptr*/)
|
||||||
|
{
|
||||||
|
m_pRadConverter = new RadConverter;
|
||||||
|
m_pTransfer = new ZZ_HttpTransfer;
|
||||||
|
//connect(this, &CMainDataUploader::SignalInit_Self, m_pTransfer, &ZZ_HttpTransfer::SlotInit_Self);
|
||||||
|
}
|
||||||
|
|
||||||
|
CMainDataUploader::~CMainDataUploader()
|
||||||
|
{
|
||||||
|
if (m_pRadConverter)
|
||||||
|
{
|
||||||
|
delete m_pRadConverter;
|
||||||
|
}
|
||||||
|
if (m_pTransfer)
|
||||||
|
{
|
||||||
|
delete m_pTransfer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMainDataUploader::SetErr(ErrInfo struErrInfo)
|
||||||
|
{
|
||||||
|
m_pTransfer->SetErrInfo(struErrInfo);
|
||||||
|
//m_struErrInfo = struErrInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMainDataUploader::SetData(vector<vector<DataFrame>> vecData)
|
||||||
|
{
|
||||||
|
QDateTime qdtTime = QDateTime::currentDateTime();
|
||||||
|
QString qstrAddYMD = qdtTime.toString("yyyy_MM_dd");
|
||||||
|
QString qstrAddHMS = qdtTime.toString("_hh_mm_ss");
|
||||||
|
|
||||||
|
m_qstrGrabDate.clear();
|
||||||
|
m_qstrGrabDate = qstrAddYMD + qstrAddHMS;
|
||||||
|
|
||||||
|
m_vecData = vecData;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMainDataUploader::SetRTGP(RunTimeGrabberParams struGrabberRTParams)
|
||||||
|
{
|
||||||
|
m_struGrabberRTParams = struGrabberRTParams;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMainDataUploader::SetContext(EContext struEC, MEContext struMEC)
|
||||||
|
{
|
||||||
|
m_struEC = struEC;
|
||||||
|
m_struMEC = struMEC;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMainDataUploader::Calibration()
|
||||||
|
{
|
||||||
|
int iScanPoints = m_struGrabberRTParams.apsParams.iTotalPosition - 1;
|
||||||
|
int iDevices = m_struGrabberRTParams.fscParams.ucDeviceNumber;
|
||||||
|
|
||||||
|
m_vecCalcedData.clear();
|
||||||
|
m_vecCalcedData.resize(iDevices);
|
||||||
|
for (int i=0;i< iDevices;i++)
|
||||||
|
{
|
||||||
|
m_vecCalcedData[i].resize(iScanPoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j < iDevices; j++)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < iScanPoints; i++)
|
||||||
|
{
|
||||||
|
m_vecCalcedData[j][i].usExposureTimeInMS = m_vecData[j][i].usExposureTimeInMS;
|
||||||
|
m_vecCalcedData[j][i].iPixels = m_vecCalData[j][i].iPixels;
|
||||||
|
m_vecCalcedData[j][i].fTemperature = m_vecData[j][i].fTemperature;
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int CMainDataUploader::UploadInfo()
|
||||||
|
{
|
||||||
|
m_pTransfer->SendInfo();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CMainDataUploader::UploadErr()
|
||||||
|
{
|
||||||
|
m_pTransfer->SendErr();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CMainDataUploader::UploadData()
|
||||||
|
{
|
||||||
|
m_pTransfer->SetCalData(m_vecCalcedData);
|
||||||
|
m_pTransfer->SendData();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CMainDataUploader::Initialize()
|
||||||
|
{
|
||||||
|
m_pRadConverter->LoadCalibrationFrames(m_struGrabberRTParams,m_vecCalData);
|
||||||
|
m_pTransfer->SetContext(m_struEC, m_struMEC);
|
||||||
|
m_pTransfer->SetDeviceInfo(m_struGrabberRTParams);
|
||||||
|
//m_pTransfer->Init_Self();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// int CMainDataUploader::Init_Self()
|
||||||
|
// {
|
||||||
|
// emit SignalInit_Self();
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// int CMainDataUploader::SlotPushOneDataFrame(vector<vector<DataFrame>> vecData)
|
||||||
|
// {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
|
||||||
|
int CMainDataUploader::SlotPushOneDataFrame()
|
||||||
|
{
|
||||||
|
Calibration();
|
||||||
|
UploadData();
|
||||||
|
m_vecData.clear();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CMainDataUploader::SlotUpdateErrorInfo()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// int CMainDataUploader::SlotInit_Self()
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// }
|
||||||
59
source/Uploader/MainDataUploader.h
Normal file
59
source/Uploader/MainDataUploader.h
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "pch.h"
|
||||||
|
#include <vector>
|
||||||
|
#include "ZZ_Types.h"
|
||||||
|
#include "DataFileTransfer.h"
|
||||||
|
#include "RadianceConverter.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace ZZ_MISCDEF::ZZ_DATAFILE;
|
||||||
|
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||||
|
using namespace ZZ_MISCDEF::IRIS::FS;
|
||||||
|
|
||||||
|
class CMainDataUploader :public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CMainDataUploader(QObject* parent = nullptr);
|
||||||
|
~CMainDataUploader();
|
||||||
|
public:
|
||||||
|
public:
|
||||||
|
|
||||||
|
//set attributes
|
||||||
|
void SetErr(ErrInfo struErrInfo);
|
||||||
|
void SetData(vector<vector<DataFrame>> vecData);
|
||||||
|
void SetRTGP(RunTimeGrabberParams struGrabberRTParams);
|
||||||
|
void SetContext(EContext struEC, MEContext struMEC);
|
||||||
|
|
||||||
|
//load calibration file after set attributes
|
||||||
|
int Initialize();
|
||||||
|
//int Init_Self();
|
||||||
|
|
||||||
|
void Calibration();
|
||||||
|
|
||||||
|
int UploadInfo();
|
||||||
|
int UploadErr();
|
||||||
|
int UploadData();
|
||||||
|
|
||||||
|
public:
|
||||||
|
RadConverter *m_pRadConverter = NULL;
|
||||||
|
ZZ_HttpTransfer *m_pTransfer = NULL;
|
||||||
|
private:
|
||||||
|
//ErrInfo m_struErrInfo;
|
||||||
|
EContext m_struEC;
|
||||||
|
MEContext m_struMEC;
|
||||||
|
RunTimeGrabberParams m_struGrabberRTParams;
|
||||||
|
vector<vector<DataFrame>> m_vecData;
|
||||||
|
vector<vector<CalFrame>> m_vecCalData;
|
||||||
|
vector<vector<CalDataFrame>> m_vecCalcedData;
|
||||||
|
|
||||||
|
QString m_qstrGrabDate;
|
||||||
|
public slots:
|
||||||
|
//int SlotPushOneDataFrame(vector<vector<DataFrame>> vecData);
|
||||||
|
int SlotPushOneDataFrame();
|
||||||
|
int SlotUpdateErrorInfo();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
//void SignalInit_Self();
|
||||||
|
|
||||||
|
};
|
||||||
72
source/Uploader/RadianceConverter.cpp
Normal file
72
source/Uploader/RadianceConverter.cpp
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#include "RadianceConverter.h"
|
||||||
|
RadConverter::RadConverter(QObject* parent /*= nullptr*/)
|
||||||
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
m_qstrCalFilePath = "E:/WorkSpace/TowerOptoSifAndSpectral/Cal";
|
||||||
|
#else
|
||||||
|
m_qstrCalFilePath = "/home/data/Cal";
|
||||||
|
#endif // DEBUG
|
||||||
|
}
|
||||||
|
|
||||||
|
RadConverter::~RadConverter()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int RadConverter::LoadCalibrationFrames(RunTimeGrabberParams struGrabberRTParams, vector<vector<CalFrame>> &struAllCalFrame)
|
||||||
|
{
|
||||||
|
/////param
|
||||||
|
int iScanPoints = struGrabberRTParams.apsParams.iTotalPosition - 1;
|
||||||
|
int iDevices = struGrabberRTParams.fscParams.ucDeviceNumber;
|
||||||
|
/////check dir
|
||||||
|
QDir qdirPath(m_qstrCalFilePath);
|
||||||
|
if (!qdirPath.exists())
|
||||||
|
{
|
||||||
|
qDebug() << "Calibration File not exist";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
/////check quantities
|
||||||
|
QStringList qslFilter;
|
||||||
|
qslFilter << "*.dat";
|
||||||
|
qdirPath.setNameFilters(qslFilter);
|
||||||
|
QFileInfoList qfiInfo = qdirPath.entryInfoList(qslFilter);
|
||||||
|
if (qfiInfo.size()!= iScanPoints * iDevices)
|
||||||
|
{
|
||||||
|
qDebug() << "Calibration Files quantities not match";
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////read file
|
||||||
|
QString qstrFilePath;
|
||||||
|
vector<CalFrame> vecOneDev;
|
||||||
|
CalFrame OneFile;
|
||||||
|
for (int j=0;j<iDevices;j++)
|
||||||
|
{
|
||||||
|
vecOneDev.clear();
|
||||||
|
for (int i = 0; i < iScanPoints; i++)
|
||||||
|
{
|
||||||
|
qstrFilePath = m_qstrCalFilePath+QString("/FS%1_").arg(j + 1)+ QString("P%1").arg(i + 1)+".dat";
|
||||||
|
QFile qfCalFile(qstrFilePath);
|
||||||
|
bool bRes = qfCalFile.open(QFile::ReadOnly);
|
||||||
|
|
||||||
|
using namespace ZZ_MISCDEF;
|
||||||
|
qfCalFile.read((char *)&OneFile.uiExposureTimeInMS,sizeof(ZZ_U32));//U32
|
||||||
|
qfCalFile.read((char*)&OneFile.fTemperature, sizeof(float));
|
||||||
|
qfCalFile.read((char*)&OneFile.iPixels,sizeof(int));
|
||||||
|
qfCalFile.read((char*)OneFile.fWaveLength, sizeof(float)*OneFile.iPixels);
|
||||||
|
qfCalFile.read((char*)OneFile.dCal_Gain, sizeof(double)*OneFile.iPixels);
|
||||||
|
qfCalFile.read((char*)OneFile.dCal_Offset, sizeof(double)*OneFile.iPixels);
|
||||||
|
|
||||||
|
/////check attribute
|
||||||
|
// if ()
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
|
||||||
|
vecOneDev.push_back(OneFile);
|
||||||
|
}
|
||||||
|
struAllCalFrame.push_back(vecOneDev);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
22
source/Uploader/RadianceConverter.h
Normal file
22
source/Uploader/RadianceConverter.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "pch.h"
|
||||||
|
#include "ZZ_Types.h"
|
||||||
|
using namespace std;
|
||||||
|
using namespace ZZ_MISCDEF::ZZ_DATAFILE;
|
||||||
|
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||||
|
using namespace ZZ_MISCDEF::IRIS::FS;
|
||||||
|
|
||||||
|
class RadConverter :public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
RadConverter(QObject* parent = nullptr);
|
||||||
|
~RadConverter();
|
||||||
|
public:
|
||||||
|
public:
|
||||||
|
int LoadCalibrationFrames(RunTimeGrabberParams struGrabberRTParams, vector<vector<CalFrame>> &struAllCalFrame);
|
||||||
|
private:
|
||||||
|
QString m_qstrCalFilePath;
|
||||||
|
private:
|
||||||
|
public slots:
|
||||||
|
};
|
||||||
@ -9,6 +9,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QMetaType>
|
||||||
////////////////////////////Thread
|
////////////////////////////Thread
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
@ -25,4 +26,8 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
////////////////////////////Serial I/O
|
////////////////////////////Serial I/O
|
||||||
#include <QtSerialPort/QSerialPort>
|
#include <QtSerialPort/QSerialPort>
|
||||||
#include <QtSerialPort/QSerialPortInfo>
|
#include <QtSerialPort/QSerialPortInfo>
|
||||||
|
////////////////////////////NetWork
|
||||||
|
#include "QNetworkRequest"
|
||||||
|
#include "QNetworkAccessManager"
|
||||||
|
#include "QNetworkReply"
|
||||||
Reference in New Issue
Block a user