mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-23 21:09:44 +08:00
联调通过
This commit is contained in:
@ -37,7 +37,7 @@ int CAbstractFSController::InitializeFSControl()
|
||||
{
|
||||
case DeviceModel::OSIFAlpha:
|
||||
m_pFSCtrl = new OceanOptics_lib;
|
||||
if (m_pFSCtrl->Initialize(false, m_fsInfo.iInterface, m_fsInfo.strSN) != 0)
|
||||
if (m_pFSCtrl->Initialize(false, m_fsInfo.strInterface, m_fsInfo.strSN) != 0)
|
||||
{
|
||||
qDebug() << "OSIFAlpha Not Opened";
|
||||
return 2;
|
||||
@ -46,7 +46,7 @@ int CAbstractFSController::InitializeFSControl()
|
||||
break;
|
||||
case DeviceModel::OSIFBeta:
|
||||
m_pFSCtrl = new OceanOptics_lib;
|
||||
if (m_pFSCtrl->Initialize(false, m_fsInfo.iInterface, m_fsInfo.strSN) !=0)
|
||||
if (m_pFSCtrl->Initialize(false, m_fsInfo.strInterface, m_fsInfo.strSN) !=0)
|
||||
{
|
||||
qDebug() << "OSIFBeta Not Opened";
|
||||
return 2;
|
||||
@ -54,8 +54,8 @@ int CAbstractFSController::InitializeFSControl()
|
||||
break;
|
||||
case DeviceModel::ISIF:
|
||||
m_pFSCtrl = new ZZ_ATPControl_Serial_Qt;
|
||||
m_pFSCtrl->Initialize(false, m_fsInfo.iInterface, NULL);
|
||||
if (m_pFSCtrl->Initialize(false, m_fsInfo.iInterface, m_fsInfo.strSN) != 0)
|
||||
m_pFSCtrl->Initialize(false, m_fsInfo.strInterface, NULL);
|
||||
if (m_pFSCtrl->Initialize(false, m_fsInfo.strInterface, m_fsInfo.strSN) != 0)
|
||||
{
|
||||
qDebug() << "ISIF Not Opened";
|
||||
return 3;
|
||||
@ -63,8 +63,8 @@ int CAbstractFSController::InitializeFSControl()
|
||||
break;
|
||||
case DeviceModel::IS1:
|
||||
m_pFSCtrl = new ZZ_ATPControl_Serial_Qt;
|
||||
m_pFSCtrl->Initialize(false, m_fsInfo.iInterface, NULL);
|
||||
if (m_pFSCtrl->Initialize(false, m_fsInfo.iInterface, m_fsInfo.strSN) != 0)
|
||||
m_pFSCtrl->Initialize(false, m_fsInfo.strInterface, NULL);
|
||||
if (m_pFSCtrl->Initialize(false, m_fsInfo.strInterface, m_fsInfo.strSN) != 0)
|
||||
{
|
||||
qDebug() << "IS1 Not Opened";
|
||||
return 3;
|
||||
@ -72,8 +72,8 @@ int CAbstractFSController::InitializeFSControl()
|
||||
break;
|
||||
case DeviceModel::IS2:
|
||||
m_pFSCtrl = new ZZ_ATPControl_Serial_Qt;
|
||||
m_pFSCtrl->Initialize(false, m_fsInfo.iInterface, NULL);
|
||||
if (m_pFSCtrl->Initialize(false, m_fsInfo.iInterface, m_fsInfo.strSN) != 0)
|
||||
m_pFSCtrl->Initialize(false, m_fsInfo.strInterface, NULL);
|
||||
if (m_pFSCtrl->Initialize(false, m_fsInfo.strInterface, m_fsInfo.strSN) != 0)
|
||||
{
|
||||
qDebug() << "IS2 Not Opened";
|
||||
return 3;
|
||||
|
@ -8,7 +8,7 @@
|
||||
typedef struct tagFSInfo
|
||||
{
|
||||
ZZ_U8 ucDeviceModel;
|
||||
int iInterface;
|
||||
std::string strInterface;
|
||||
std::string strSN;
|
||||
long lDepth;
|
||||
float fMinFactor;
|
||||
|
@ -5,7 +5,7 @@ CMainDataGrabber::CMainDataGrabber(QObject* parent /*= nullptr*/)
|
||||
m_piFlagCaptureThreadStatus_Signal = NULL;
|
||||
m_piFlagCaptureThreadStatus_Dark = NULL;
|
||||
|
||||
m_GrabTimer = new QTimer(this);
|
||||
//m_GrabTimer = new QTimer(this);
|
||||
|
||||
m_iFlagIsCapturing = false;
|
||||
m_iFlagIsCapturing_Signal = false;
|
||||
@ -34,11 +34,11 @@ CMainDataGrabber::~CMainDataGrabber()
|
||||
}
|
||||
|
||||
|
||||
if (m_GrabTimer!=NULL)
|
||||
{
|
||||
m_GrabTimer->stop();
|
||||
delete m_GrabTimer;
|
||||
}
|
||||
// if (m_GrabTimer!=NULL)
|
||||
// {
|
||||
// m_GrabTimer->stop();
|
||||
// delete m_GrabTimer;
|
||||
// }
|
||||
}
|
||||
|
||||
void CMainDataGrabber::Delay_MSec(ZZ_U16 usMS)
|
||||
@ -73,6 +73,25 @@ int CMainDataGrabber::SetGrabberFileProcessor(DataFileProcessor &dfpSaver)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMainDataGrabber::SetTimer(Scheduler &sScheduler)
|
||||
{
|
||||
m_psScheduler = &sScheduler;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMainDataGrabber::InitLS()
|
||||
{
|
||||
PortInfo piTemp;
|
||||
piTemp.qstrFullPortName = QString::fromStdString(m_struLinearShutterContext.strInterface);
|
||||
m_ctrlLS.ILMES_InitializeComm(piTemp, m_struLinearShutterContext.ucProtocolType, m_struLinearShutterContext.ucCmdID);
|
||||
ControllerParams cpTemp;
|
||||
bool res = m_ctrlLS.ILMES_InitializeParams(cpTemp);
|
||||
|
||||
m_ctrlLS.ILMES_SetPosition(m_struAcqPosSetting.iPosition, m_struAcqPosSetting.iTotalPosition);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMainDataGrabber::InitThreadStatus()
|
||||
{
|
||||
if (m_piFlagCaptureThreadStatus_Signal!=NULL)
|
||||
@ -106,7 +125,7 @@ int CMainDataGrabber::InitializeWorkers()
|
||||
m_piFlagCaptureThreadStatus_Dark[i] = 0;
|
||||
|
||||
FSInfo fsInfo;
|
||||
fsInfo.iInterface = m_struDeviceContext.iInterface[i];
|
||||
fsInfo.strInterface = m_struDeviceContext.strInterface[i];
|
||||
fsInfo.ucDeviceModel = m_struDeviceContext.ucDeviceModel[i];
|
||||
fsInfo.strSN = m_struDeviceContext.strSN[i];
|
||||
fsInfo.fMaxFactor = m_struDeviceContext.fMaxFactor[i];
|
||||
@ -158,7 +177,8 @@ int CMainDataGrabber::SetupMsgPipelines()
|
||||
|
||||
connect(this, &CMainDataGrabber::SignalGrabOnceFinished, this, &CMainDataGrabber::GrabOnceFinished);
|
||||
|
||||
connect(m_GrabTimer, &QTimer::timeout, this, &CMainDataGrabber::OnTimeCounter);
|
||||
//connect(m_GrabTimer, &QTimer::timeout, this, &CMainDataGrabber::OnTimeCounter);
|
||||
connect(m_psScheduler, &Scheduler::SignalGrabOnce, this, &CMainDataGrabber::OnTimeCounter);
|
||||
|
||||
connect(this, &CMainDataGrabber::SignalStartGrab, this, &CMainDataGrabber::StartGrabTimer);
|
||||
|
||||
@ -245,8 +265,8 @@ int CMainDataGrabber::StartGrabTimer()
|
||||
// }
|
||||
|
||||
//start
|
||||
int iIntervalInMS =m_struAcqTime.qtInterval.hour()*3600*1000+ m_struAcqTime.qtInterval.minute()*60*1000+ m_struAcqTime.qtInterval.second()*1000;
|
||||
m_GrabTimer->start(3000);
|
||||
//int iIntervalInMS =m_struAcqTime.qtInterval.hour()*3600*1000+ m_struAcqTime.qtInterval.minute()*60*1000+ m_struAcqTime.qtInterval.second()*1000;
|
||||
//m_GrabTimer->start(3000);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////test
|
||||
// m_iFlagIsCapturing = true;
|
||||
@ -316,7 +336,8 @@ int CMainDataGrabber::GrabOnceFinished()
|
||||
}
|
||||
m_iFlagIsCapturing = 1;
|
||||
|
||||
m_struAcqPosSetting.iTotalPosition = 5;
|
||||
//return 0;
|
||||
// m_struAcqPosSetting.iTotalPosition = 5;
|
||||
|
||||
//m_pdfpSaver->WriteDataFile();
|
||||
for (ZZ_U8 i = 0; i < m_struDeviceContext.ucDeviceNumber; i++)
|
||||
@ -327,6 +348,7 @@ int CMainDataGrabber::GrabOnceFinished()
|
||||
for (int i=0;i< m_struAcqPosSetting.iTotalPosition-1;i++)
|
||||
{
|
||||
////move to
|
||||
m_ctrlLS.ILMES_MoveToPos(i+1);
|
||||
m_struAcqPosSetting.iPosition[i + 1];
|
||||
m_iFlagIsCapturing_Signal = 1;
|
||||
emit SignalStartGrabOnce_Signal();
|
||||
@ -337,6 +359,7 @@ int CMainDataGrabber::GrabOnceFinished()
|
||||
|
||||
|
||||
////move to
|
||||
m_ctrlLS.ILMES_MoveToPos(0);
|
||||
m_struAcqPosSetting.iPosition[0];
|
||||
m_iFlagIsCapturing_Dark = 1;
|
||||
emit SignalStartGrabOnce_Dark();
|
||||
@ -361,6 +384,8 @@ int CMainDataGrabber::GrabOnceFinished()
|
||||
}
|
||||
m_pdfpSaver->SetData(vecData);
|
||||
m_pdfpSaver->WriteDataFile();
|
||||
|
||||
|
||||
// qDebug() << "-------------------------------------------busy" << QTime::currentTime().toString();
|
||||
// QThread::msleep(5000);
|
||||
// return 0;
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include <vector>
|
||||
#include "AbstractFSController.h"
|
||||
#include "DataFileProcessor.h"
|
||||
#include "Scheduler.h"
|
||||
#include "VSMD12XControl.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||
@ -28,6 +30,9 @@ private:
|
||||
int m_iFlagIsCapturing_Dark;
|
||||
|
||||
DataFileProcessor* m_pdfpSaver;
|
||||
Scheduler * m_psScheduler;
|
||||
|
||||
CVSMD12XControl m_ctrlLS;
|
||||
|
||||
FSContext m_struDeviceContext;
|
||||
LSContext m_struLinearShutterContext;
|
||||
@ -35,7 +40,7 @@ private:
|
||||
AcqTimeSettings m_struAcqTime;
|
||||
|
||||
|
||||
QTimer *m_GrabTimer;
|
||||
//QTimer *m_GrabTimer;
|
||||
private:
|
||||
void Delay_MSec(ZZ_U16 usMS);
|
||||
void SubDataFrame(DataFrame& dfLeft, DataFrame const dfRight,int iCount);
|
||||
@ -43,7 +48,9 @@ public:
|
||||
//Call this first
|
||||
int SetGrabberParams(RunTimeGrabberParams struGrabberRTParams);
|
||||
int SetGrabberFileProcessor(DataFileProcessor &dfpSaver);
|
||||
int SetTimer(Scheduler &sScheduler);
|
||||
|
||||
int InitLS();
|
||||
int InitThreadStatus();
|
||||
int InitializeWorkers();
|
||||
int StartWorkers();
|
||||
|
63
source/Thread/Scheduler.cpp
Normal file
63
source/Thread/Scheduler.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
#include "Scheduler.h"
|
||||
|
||||
Scheduler::Scheduler(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
m_GrabTimer = new QTimer(this);
|
||||
connect(m_GrabTimer, &QTimer::timeout, this, &Scheduler::OnTimeCounter);
|
||||
connect(this, &Scheduler::SignalSelfStart, this, &Scheduler::StartAsPlanned);
|
||||
}
|
||||
|
||||
Scheduler::~Scheduler()
|
||||
{
|
||||
if (m_GrabTimer != NULL)
|
||||
{
|
||||
m_GrabTimer->stop();
|
||||
delete m_GrabTimer;
|
||||
}
|
||||
}
|
||||
|
||||
void Scheduler::SetAcqTimeParams(AcqTimeSettings struAcqTime)
|
||||
{
|
||||
m_struAcqTime = struAcqTime;
|
||||
}
|
||||
|
||||
void Scheduler::Preheating()
|
||||
{
|
||||
qDebug() << "Start Preheating";
|
||||
#ifdef _DEBUG
|
||||
QThread::msleep(5000);
|
||||
#else
|
||||
QThread::msleep(1000*60*5);
|
||||
#endif
|
||||
qDebug() << "Preheating Finished";
|
||||
}
|
||||
|
||||
void Scheduler::SelfStart()
|
||||
{
|
||||
emit SignalSelfStart();
|
||||
}
|
||||
|
||||
void Scheduler::StartAsPlanned()
|
||||
{
|
||||
bool bStopWait = false;
|
||||
QTime qtTime = QTime::currentTime();
|
||||
while (!bStopWait)
|
||||
{
|
||||
QThread::msleep(100);
|
||||
if (m_struAcqTime.qtStartTime >= qtTime && qtTime < m_struAcqTime.qtStopTime)
|
||||
{
|
||||
bStopWait = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int iIntervalInMS = m_struAcqTime.qtInterval.hour() * 3600 * 1000 + m_struAcqTime.qtInterval.minute() * 60 * 1000 + m_struAcqTime.qtInterval.second() * 1000;
|
||||
|
||||
m_GrabTimer->start(3000);
|
||||
}
|
||||
|
||||
int Scheduler::OnTimeCounter()
|
||||
{
|
||||
emit SignalGrabOnce();
|
||||
return 0;
|
||||
}
|
26
source/Thread/Scheduler.h
Normal file
26
source/Thread/Scheduler.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#include"pch.h"
|
||||
#include "ZZ_Types.h"
|
||||
using namespace std;
|
||||
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||
class Scheduler :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Scheduler(QObject* parent = nullptr);
|
||||
~Scheduler();
|
||||
private:
|
||||
QTimer *m_GrabTimer;
|
||||
AcqTimeSettings m_struAcqTime;
|
||||
private:
|
||||
void StartAsPlanned();
|
||||
public:
|
||||
void SetAcqTimeParams(AcqTimeSettings struAcqTime);
|
||||
void Preheating();
|
||||
void SelfStart();
|
||||
public slots:
|
||||
int OnTimeCounter();
|
||||
signals:
|
||||
void SignalGrabOnce();
|
||||
void SignalSelfStart();
|
||||
};
|
Reference in New Issue
Block a user