mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-19 11:49:42 +08:00
更新了底层逻辑
This commit is contained in:
@ -1,40 +0,0 @@
|
||||
#include "ATPAbstractController.h"
|
||||
|
||||
ZZ_ATPAbsCtrlThread::ZZ_ATPAbsCtrlThread(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ZZ_ATPAbsCtrlThread::~ZZ_ATPAbsCtrlThread()
|
||||
{
|
||||
|
||||
}
|
||||
//
|
||||
// void ZZ_ATPAbsCtrlThread::SetWaitCondition(QWaitCondition *pFinish, QMutex *pMutex)
|
||||
// {
|
||||
// m_pwcFinish = pFinish;
|
||||
// m_pMutex = pMutex;
|
||||
// }
|
||||
|
||||
int ZZ_ATPAbsCtrlThread::StartTestAcquisition()
|
||||
{
|
||||
m_bFlagIsCollecting = true;
|
||||
while (m_bFlagIsCollecting)
|
||||
{
|
||||
//QMutexLocker locker(&m_Mutex);
|
||||
QThread::msleep(1000);
|
||||
qDebug() << "ThreadATPAbsController busy";
|
||||
}
|
||||
qDebug() << "ThreadATPAbsController quit";
|
||||
|
||||
//m_pwcFinish->wakeAll();
|
||||
emit SignalAcqFinished(0,1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPAbsCtrlThread::StopTestAcquisition()
|
||||
{
|
||||
//QMutexLocker locker(&m_Mutex);
|
||||
m_bFlagIsCollecting = false;
|
||||
return 0;
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//ATP<54>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#include "ATPControl_Serial_QT.h"
|
||||
#include <atomic>
|
||||
|
||||
|
||||
class ZZ_ATPAbsCtrlThread :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
public:
|
||||
std::atomic<bool> m_bFlagIsCollecting;
|
||||
//QMutex *m_pMutex;
|
||||
//QWaitCondition *m_pwcFinish;
|
||||
public:
|
||||
ZZ_ATPAbsCtrlThread(QObject* parent = nullptr);
|
||||
virtual ~ZZ_ATPAbsCtrlThread();
|
||||
private:
|
||||
ZZ_ATPControl_Serial_Qt m_iSIFctrl;
|
||||
public slots:
|
||||
//virtual void SetWaitCondition(QWaitCondition *pFinish, QMutex *pMutex);
|
||||
virtual int StartTestAcquisition();
|
||||
int StopTestAcquisition();
|
||||
signals:
|
||||
void SignalAcqStarted();
|
||||
void SignalAcqFinished(int iThreadID,int iFlagStatus);
|
||||
};
|
60
source/Thread/AbstractFSController.cpp
Normal file
60
source/Thread/AbstractFSController.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
#include "AbstractFSController.h"
|
||||
CAbstractFSController::CAbstractFSController(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
m_iThreadID = -1;
|
||||
m_iDeviceType = -1;
|
||||
}
|
||||
|
||||
CAbstractFSController::~CAbstractFSController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int CAbstractFSController::SetRunParas(int iThreadID, int iDeviceType)
|
||||
{
|
||||
m_iThreadID = iThreadID;
|
||||
m_iDeviceType = iDeviceType;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int CAbstractFSController::InitializeFSControl()
|
||||
{
|
||||
if (m_iThreadID == -1|| m_iDeviceTyp == -1)
|
||||
{
|
||||
qDebug() << "Params Err. Call SetRunParas first";
|
||||
return 1;
|
||||
}
|
||||
switch (m_iDeviceType)
|
||||
{
|
||||
case DeviceModel::OSIFAlpha:
|
||||
|
||||
break;
|
||||
case DeviceModel::OSIFBeta:
|
||||
break;
|
||||
case DeviceModel::ISIF:
|
||||
m_pFSCtrl = new ZZ_ATPControl_Serial_Qt;
|
||||
break;
|
||||
case DeviceModel::IS1:
|
||||
m_pFSCtrl = new ZZ_ATPControl_Serial_Qt;
|
||||
break;
|
||||
case DeviceModel::IS2:
|
||||
m_pFSCtrl = new ZZ_ATPControl_Serial_Qt;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CAbstractFSController::StartAcquisition()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CAbstractFSController::StopAcquisition()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
33
source/Thread/AbstractFSController.h
Normal file
33
source/Thread/AbstractFSController.h
Normal file
@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#include "ATPControl_Serial_QT.h"
|
||||
#include <atomic>
|
||||
|
||||
class CAbstractFSController :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CAbstractFSController(QObject* parent = nullptr);
|
||||
virtual ~CAbstractFSController();
|
||||
public:
|
||||
private:
|
||||
CIrisFSBase *m_pFSCtrl;
|
||||
|
||||
int m_iThreadID;
|
||||
int m_iDeviceType;
|
||||
public slots:
|
||||
|
||||
//call first
|
||||
virtual int SetRunParas(int iThreadID, int iDeviceType);
|
||||
|
||||
//create derived class from base class
|
||||
virtual int InitializeFSControl();
|
||||
|
||||
virtual int StartAcquisition();
|
||||
|
||||
virtual int StopAcquisition();
|
||||
|
||||
signals:
|
||||
void SignalAcqStarted();
|
||||
void SignalAcqFinished(int iThreadID, int iFlagStatus);
|
||||
};
|
17
source/Thread/MainDataGrabber.cpp
Normal file
17
source/Thread/MainDataGrabber.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
int CMainDataGrabber::SetGrabberParams(RunTimeGrabberParams struGrabberRTParams)
|
||||
{
|
||||
m_struAcqTime = struGrabberRTParams.atsParams;
|
||||
m_struDeviceContext = struGrabberRTParams.dcParams;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMainDataGrabber::InitializeWorkers()
|
||||
{
|
||||
for (ZZ_U8 i = 0; i < m_struDeviceContext.ucDeviceNumber; i++)
|
||||
{
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
39
source/Thread/MainDataGrabber.h
Normal file
39
source/Thread/MainDataGrabber.h
Normal file
@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
#include"pch.h"
|
||||
#include <vector>
|
||||
#include "AbstractFSController.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||
|
||||
class CMainDataGrabber :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CMainDataGrabber(QObject* parent = nullptr);
|
||||
~CMainDataGrabber();
|
||||
|
||||
private:
|
||||
vector<CAbstractFSController *> m_pControlThread;
|
||||
vector<QThread* > m_pqThreadHolder;
|
||||
|
||||
int m_iTotalThreads;
|
||||
|
||||
AcqTimeSettings m_struAcqTime;
|
||||
DeviceContext m_struDeviceContext;
|
||||
|
||||
public:
|
||||
//Call this first
|
||||
int SetGrabberParams(RunTimeGrabberParams struGrabberRTParams);
|
||||
|
||||
int InitializeWorkers();
|
||||
public slots:
|
||||
int HandleThreadEvent(int iThreadID, int iFlagStatus);
|
||||
int StartGrab();
|
||||
|
||||
signals:
|
||||
void SignalStartGrabOnce();
|
||||
void SignalStopGrab();
|
||||
void SignalGrabOnceFinished();
|
||||
void SignalStartGrab();
|
||||
};
|
@ -1,165 +0,0 @@
|
||||
#include "ThreadDataGrabber.h"
|
||||
|
||||
ZZ_DataGrabberThread::ZZ_DataGrabberThread(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
m_GrabTimer = new QTimer(this);
|
||||
m_bFlagIsCollecting = false;
|
||||
|
||||
|
||||
|
||||
ZZ_ATPAbsCtrlThread* m_p1 = new ZZ_iSIFControlThread;
|
||||
m_pControlThread.push_back(m_p1);
|
||||
ZZ_ATPAbsCtrlThread* m_p2 = new ZZ_IS1ControlThread;
|
||||
m_pControlThread.push_back(m_p2);
|
||||
//m_iTotalThreads = 2;
|
||||
|
||||
InitThreadStatus();
|
||||
SetupSignals();
|
||||
StartGrabberThread();
|
||||
}
|
||||
|
||||
ZZ_DataGrabberThread::~ZZ_DataGrabberThread()
|
||||
{
|
||||
if (m_piFlagCaptureThreadStatus!=NULL)
|
||||
{
|
||||
delete m_piFlagCaptureThreadStatus;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ZZ_DataGrabberThread::SetGrabTimer(AcqTimeSettings struAcqTimer)
|
||||
{
|
||||
m_struAcqTime = struAcqTimer;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::SetupSignals()
|
||||
{
|
||||
connect(m_GrabTimer, &QTimer::timeout, this, &ZZ_DataGrabberThread::OnTimeCounter);
|
||||
|
||||
connect(this, &ZZ_DataGrabberThread::SignalStartGrab, this, &ZZ_DataGrabberThread::StartGrab);
|
||||
|
||||
//connect(this, &ZZ_DataGrabberThread::SignalStartGrabOnce, &m_tcISIFCtrlThread, &ZZ_ATPAbsCtrlThread::StartTestAcquisition);
|
||||
//connect(this, &ZZ_DataGrabberThread::SignalStartGrabOnce, &m_tcIS1CtrlThread, &ZZ_ATPAbsCtrlThread::StartTestAcquisition);
|
||||
|
||||
connect(this, &ZZ_DataGrabberThread::SignalStartGrabOnce, m_pControlThread[0], &ZZ_ATPAbsCtrlThread::StartTestAcquisition);
|
||||
connect(this, &ZZ_DataGrabberThread::SignalStartGrabOnce, m_pControlThread[1], &ZZ_ATPAbsCtrlThread::StartTestAcquisition);
|
||||
|
||||
//connect(this, &ZZ_DataGrabberThread::SignalStopGrab, &m_tcISIFCtrlThread, &ZZ_iSIFControlThread::StopTestAcquisition, Qt::DirectConnection);
|
||||
//connect(this, &ZZ_DataGrabberThread::SignalStopGrab, &m_tcIS1CtrlThread, &ZZ_IS1ControlThread::StopTestAcquisition, Qt::DirectConnection);
|
||||
|
||||
//connect(&m_tcISIFCtrlThread, &ZZ_iSIFControlThread::SignalAcqFinished, this, &ZZ_DataGrabberThread::HandleThreadEvent);
|
||||
//connect(&m_tcIS1CtrlThread, &ZZ_IS1ControlThread::SignalAcqFinished, this, &ZZ_DataGrabberThread::HandleThreadEvent);
|
||||
|
||||
connect(m_pControlThread[0], &ZZ_ATPAbsCtrlThread::SignalAcqFinished, this, &ZZ_DataGrabberThread::HandleThreadEvent);
|
||||
connect(m_pControlThread[1], &ZZ_ATPAbsCtrlThread::SignalAcqFinished, this, &ZZ_DataGrabberThread::HandleThreadEvent);
|
||||
|
||||
connect(this, &ZZ_DataGrabberThread::SignalGrabOnceFinished, this, &ZZ_DataGrabberThread::TestGrabOnce);
|
||||
//m_tcISIFCtrlThread.SetWaitCondition(&m_wcWaitISIF,&m_mTestMutex);
|
||||
//m_tcIS1CtrlThread.SetWaitCondition(&m_wcWaitIS1, &m_mTestMutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::StartGrabCall()
|
||||
{
|
||||
emit SignalStartGrab();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::StartGrab()
|
||||
{
|
||||
m_GrabTimer->start(1000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::StartGrabberThread()
|
||||
{
|
||||
// m_pqISIFThreadHolder = new QThread();
|
||||
// m_tcISIFCtrlThread.moveToThread(m_pqISIFThreadHolder);
|
||||
// m_pqISIFThreadHolder->start();
|
||||
//
|
||||
// m_pqIS1ThreadHolder = new QThread();
|
||||
// m_tcIS1CtrlThread.moveToThread(m_pqIS1ThreadHolder);
|
||||
// m_pqIS1ThreadHolder->start();
|
||||
|
||||
|
||||
m_pqISIFThreadHolder = new QThread();
|
||||
m_pControlThread[0]->moveToThread(m_pqISIFThreadHolder);
|
||||
m_pqISIFThreadHolder->start();
|
||||
|
||||
m_pqIS1ThreadHolder = new QThread();
|
||||
m_pControlThread[1]->moveToThread(m_pqIS1ThreadHolder);
|
||||
m_pqIS1ThreadHolder->start();
|
||||
//m_stCameraServiceThread.SetController(this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::InitThreadStatus()
|
||||
{
|
||||
m_piFlagCaptureThreadStatus = new int[m_iTotalThreads];
|
||||
for (int i=0;i< m_iTotalThreads;i++)
|
||||
{
|
||||
m_piFlagCaptureThreadStatus[i] = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::TestGrab()
|
||||
{
|
||||
m_bFlagIsCollecting = true;
|
||||
while (m_bFlagIsCollecting)
|
||||
{
|
||||
|
||||
emit SignalStartGrabOnce();
|
||||
//m_mTestMutex.lock();
|
||||
//m_wcWaitISIF.wait(&m_mTestMutex);
|
||||
//m_mTestMutex.lock();
|
||||
//m_wcWaitIS1.wait(&m_mTestMutex);
|
||||
//m_mTestMutex.unlock();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::TestGrabOnce()
|
||||
{
|
||||
InitThreadStatus();
|
||||
emit SignalStartGrabOnce();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::TestStopGrab()
|
||||
{
|
||||
//emit SignalStopGrab();
|
||||
m_tcISIFCtrlThread.StopTestAcquisition();
|
||||
m_tcIS1CtrlThread.StopTestAcquisition();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::HandleThreadEvent(int iThreadID, int iFlagStatus)
|
||||
{
|
||||
m_piFlagCaptureThreadStatus[iThreadID] = iFlagStatus;
|
||||
|
||||
bool bFinished = true;
|
||||
for (int i = 0; i < m_iTotalThreads; i++)
|
||||
{
|
||||
if (m_piFlagCaptureThreadStatus[i] != 1)
|
||||
{
|
||||
bFinished = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bFinished)
|
||||
{
|
||||
emit SignalGrabOnceFinished();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::OnTimeCounter()
|
||||
{
|
||||
qDebug() << "OnTimeCounter";
|
||||
return 0;
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//<2F><><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
#include"pch.h"
|
||||
#include "ThreadIS1Controller.h"
|
||||
#include "ThreadiSIFController.h"
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||
class ZZ_DataGrabberThread :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ZZ_DataGrabberThread(QObject* parent = nullptr);
|
||||
~ZZ_DataGrabberThread();
|
||||
|
||||
public:
|
||||
//QWaitCondition m_wcWaitISIF,m_wcWaitIS1;
|
||||
//QMutex m_mTestMutex;
|
||||
private:
|
||||
vector<ZZ_ATPAbsCtrlThread *> m_pControlThread;
|
||||
|
||||
ZZ_iSIFControlThread m_tcISIFCtrlThread;
|
||||
ZZ_IS1ControlThread m_tcIS1CtrlThread;
|
||||
QThread* m_pqISIFThreadHolder;
|
||||
QThread* m_pqIS1ThreadHolder;
|
||||
|
||||
std::atomic<bool> m_bFlagIsCollecting;
|
||||
std::atomic<bool> m_bFlagIsCollectingFinished;
|
||||
int *m_piFlagCaptureThreadStatus;
|
||||
const int m_iTotalThreads = 2;
|
||||
|
||||
QTimer *m_GrabTimer;
|
||||
AcqTimeSettings m_struAcqTime;
|
||||
public:
|
||||
void SetGrabTimer(AcqTimeSettings struAcqTimer);
|
||||
|
||||
int SetupSignals();
|
||||
int StartGrabCall();
|
||||
|
||||
private:
|
||||
int OnTimeCounter();
|
||||
int InitThreadStatus();
|
||||
int StartGrabberThread();
|
||||
public slots:
|
||||
int TestGrab();
|
||||
int TestGrabOnce();
|
||||
int TestStopGrab();
|
||||
int HandleThreadEvent(int iThreadID, int iFlagStatus);
|
||||
int StartGrab();
|
||||
signals:
|
||||
void SignalStartGrabOnce();
|
||||
void SignalStopGrab();
|
||||
void SignalGrabOnceFinished();
|
||||
void SignalStartGrab();
|
||||
};
|
@ -1,31 +0,0 @@
|
||||
#include "ThreadIS1Controller.h"
|
||||
|
||||
ZZ_IS1ControlThread::ZZ_IS1ControlThread(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ZZ_IS1ControlThread::~ZZ_IS1ControlThread()
|
||||
{
|
||||
}
|
||||
|
||||
int ZZ_IS1ControlThread::StartTestAcquisition()
|
||||
{
|
||||
// m_bFlagIsCollecting = true;
|
||||
// while (m_bFlagIsCollecting)
|
||||
// {
|
||||
// //QMutexLocker locker(&m_Mutex);
|
||||
// QThread::msleep(1000);
|
||||
// qDebug() << "ThreadIS1Controller busy";
|
||||
// }
|
||||
// qDebug() << "ThreadIS1Controller quit";
|
||||
|
||||
qDebug() << "ThreadIS1Controller busy";
|
||||
QThread::msleep(1000);
|
||||
qDebug() << "ThreadIS1Controller quit";
|
||||
|
||||
//m_pwcFinish->wakeAll();
|
||||
emit SignalAcqFinished(1,1);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
#include "ATPAbstractController.h"
|
||||
|
||||
class ZZ_IS1ControlThread :public ZZ_ATPAbsCtrlThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ZZ_IS1ControlThread(QObject* parent = nullptr);
|
||||
~ZZ_IS1ControlThread();
|
||||
private:
|
||||
public slots:
|
||||
int StartTestAcquisition();
|
||||
signals:
|
||||
};
|
@ -1,18 +0,0 @@
|
||||
#pragma once
|
||||
#include "ATPAbstractController.h"
|
||||
|
||||
|
||||
|
||||
class ZZ_iSIFControlThread :public ZZ_ATPAbsCtrlThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
private:
|
||||
public:
|
||||
ZZ_iSIFControlThread(QObject* parent = nullptr);
|
||||
~ZZ_iSIFControlThread();
|
||||
public slots:
|
||||
int StartTestAcquisition();
|
||||
int test();//
|
||||
};
|
@ -1,37 +0,0 @@
|
||||
#include "ThreadiSIFController.h"
|
||||
|
||||
ZZ_iSIFControlThread::ZZ_iSIFControlThread(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ZZ_iSIFControlThread::~ZZ_iSIFControlThread()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int ZZ_iSIFControlThread::test()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_iSIFControlThread::StartTestAcquisition()
|
||||
{
|
||||
// m_bFlagIsCollecting = true;
|
||||
// while (m_bFlagIsCollecting)
|
||||
// {
|
||||
// //QMutexLocker locker(&m_Mutex);
|
||||
// QThread::msleep(1000);
|
||||
// qDebug() << "ThreadiSIFController busy";
|
||||
// }
|
||||
// qDebug() << "ThreadiSIFController quit";
|
||||
|
||||
qDebug() << "ThreadiSIFController busy";
|
||||
QThread::msleep(2000);
|
||||
qDebug() << "ThreadiSIFController quit";
|
||||
|
||||
//m_pwcFinish->wakeAll();
|
||||
emit SignalAcqFinished(0,1);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user