mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-18 19:39:43 +08:00
更新了底层逻辑
This commit is contained in:
@ -3,7 +3,8 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
|
||||
#include <string>
|
||||
#define MAX_DEVICENUMBER_FS 2
|
||||
namespace ZZ_MISCDEF
|
||||
{
|
||||
typedef unsigned char ZZ_U8;
|
||||
@ -40,8 +41,57 @@ namespace ZZ_MISCDEF
|
||||
}DeviceAttribute;
|
||||
}
|
||||
|
||||
enum DeviceModel
|
||||
{
|
||||
OSIFAlpha=0,
|
||||
OSIFBeta,
|
||||
ISIF,
|
||||
IS1,
|
||||
IS2
|
||||
};
|
||||
|
||||
// inline std::string GetDeviceModelName(int iModel)
|
||||
// {
|
||||
// switch (iModel)
|
||||
// {
|
||||
// case DeviceModel::OSIFAlpha: return "OSIFAlpha"; break;
|
||||
// case DeviceModel::OSIFBeta: return "OSIFBeta"; break;
|
||||
// case DeviceModel::ISIF: return "ISIF"; break;
|
||||
// case DeviceModel::IS1: return "IS1"; break;
|
||||
// case DeviceModel::IS2: return "IS2"; break;
|
||||
// default: return "error"; break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// inline int GetIndex(std::string strDeviceModelName)
|
||||
// {
|
||||
// if (strDeviceModelName== "OSIFAlpha")
|
||||
// {
|
||||
// return DeviceModel::OSIFAlpha;
|
||||
// }
|
||||
// else if (strDeviceModelName == "OSIFBeta")
|
||||
// {
|
||||
// return DeviceModel::OSIFBeta;
|
||||
// }
|
||||
// else if (strDeviceModelName == "ISIF")
|
||||
// {
|
||||
// return DeviceModel::ISIF;
|
||||
// }
|
||||
// else if (strDeviceModelName == "IS1")
|
||||
// {
|
||||
// return DeviceModel::IS1;
|
||||
// }
|
||||
// else if(strDeviceModelName == "IS2")
|
||||
// {
|
||||
// return DeviceModel::IS2;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
//ATPָ<50><D6B8>ת<EFBFBD><D7AA>
|
||||
namespace ATP
|
||||
@ -116,6 +166,12 @@ namespace ZZ_MISCDEF
|
||||
//<2F><><EFBFBD>в<EFBFBD><D0B2><EFBFBD>
|
||||
namespace ZZ_RUNPARAMS
|
||||
{
|
||||
typedef struct tagDeviceContext
|
||||
{
|
||||
ZZ_U8 ucDeviceNumber;
|
||||
ZZ_U8 ucDeviceModel[MAX_DEVICENUMBER_FS];
|
||||
}DeviceContext;
|
||||
|
||||
typedef struct tagAcquisitionTimeSettings
|
||||
{
|
||||
QTime qtStartTime;
|
||||
@ -123,6 +179,13 @@ namespace ZZ_MISCDEF
|
||||
QTime qtInterval;
|
||||
}AcqTimeSettings;
|
||||
|
||||
typedef struct tagRunTimeGrabberParams
|
||||
{
|
||||
DeviceContext dcParams;
|
||||
AcqTimeSettings atsParams;
|
||||
}RunTimeGrabberParams;
|
||||
|
||||
|
||||
typedef struct tagATPCalibrationSettings
|
||||
{
|
||||
//Up0 Down1,2,3
|
||||
@ -217,4 +280,4 @@ namespace ZZ_MISCDEF
|
||||
}ATPDataHeader;
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
@ -1,34 +1,59 @@
|
||||
#include "SystemConfigger.h"
|
||||
|
||||
|
||||
ZZ_SysConfigger::ZZ_SysConfigger(QObject *parent /*= nullptr*/)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
m_qstrFilePath = QCoreApplication::applicationDirPath() + "/home/data/Settings/DeviceSettings.ini";
|
||||
m_qstrJSONConfigFilePath = "E:/WorkSpace/TowerOptoSifAndSpectral/config/config.json";
|
||||
m_qstrDeviceConfigFilePath = "E:/WorkSpace/TowerOptoSifAndSpectral/config/DeviceSettings.ini";
|
||||
m_qstrJSONConfigFilePath = "E:/WorkSpace/TowerOptoSifAndSpectral/config/config.json";
|
||||
#else
|
||||
m_qstrJSONConfigFilePath = ("/home/data/Setting/config.json");
|
||||
#endif // DEBUG
|
||||
|
||||
m_qsDeviceConfig = NULL;
|
||||
}
|
||||
|
||||
ZZ_SysConfigger::~ZZ_SysConfigger()
|
||||
{
|
||||
if (qfConfig.isOpen())
|
||||
if (qfJConfig.isOpen())
|
||||
{
|
||||
qfConfig.close();
|
||||
qfJConfig.close();
|
||||
}
|
||||
}
|
||||
|
||||
int ZZ_SysConfigger::Initialize()
|
||||
{
|
||||
qfConfig.setFileName(m_qstrJSONConfigFilePath);
|
||||
bool bRes = qfConfig.open(QIODevice::ReadOnly);
|
||||
//////////////////////////////////////////////////////////////////////////load device settings
|
||||
using namespace ZZ_MISCDEF;
|
||||
QMetaEnum enumDeviceModel = QMetaEnum::fromType<ConfiggerDeviceModel>();
|
||||
|
||||
if (m_qsDeviceConfig!=NULL)
|
||||
{
|
||||
delete m_qsDeviceConfig;
|
||||
}
|
||||
m_qsDeviceConfig = new QSettings(m_qstrDeviceConfigFilePath, QSettings::IniFormat);
|
||||
m_struDeviceContext.ucDeviceNumber = m_qsDeviceConfig->value(QString("DEVICE INFO/TotalSpectrometer"),-1).toInt();
|
||||
if (m_struDeviceContext.ucDeviceNumber == -1)
|
||||
{
|
||||
qDebug() << "DEVICE INFO TotalSpectrometer Value Err.";
|
||||
return 3;
|
||||
}
|
||||
for (ZZ_U8 i=0;i< m_struDeviceContext.ucDeviceNumber;i++)
|
||||
{
|
||||
QString qstrTemp= m_qsDeviceConfig->value(QString("FS%1/Model").arg(i+1), "Null").toString();
|
||||
m_struDeviceContext.ucDeviceModel[i]= enumDeviceModel.keysToValue(qstrTemp.toLatin1().data());
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////load json settings
|
||||
qfJConfig.setFileName(m_qstrJSONConfigFilePath);
|
||||
bool bRes = qfJConfig.open(QIODevice::ReadOnly);
|
||||
if (!bRes)
|
||||
{
|
||||
qDebug() << "QFile open config file Err.";
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_qbaJData = qfConfig.readAll();
|
||||
m_qbaJData = qfJConfig.readAll();
|
||||
m_qjdJDoc= QJsonDocument::fromJson(m_qbaJData, &m_qjpeJErr);
|
||||
if (m_qjpeJErr.error != QJsonParseError::NoError)
|
||||
{
|
||||
@ -39,6 +64,13 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_SysConfigger::GetGrabberRunParams(RunTimeGrabberParams &struGrabberRTParams)
|
||||
{
|
||||
struGrabberRTParams.atsParams = m_struAcqTime;
|
||||
struGrabberRTParams.dcParams = m_struDeviceContext;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_SysConfigger::LoadSettingsFromFile_IS1()
|
||||
{
|
||||
m_struIS1Info.qstrCalFile_U0 = m_qjoJObj.value("IS1UpCalFile").toString();
|
||||
|
@ -4,7 +4,6 @@
|
||||
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||
using namespace ZZ_MISCDEF::ZZ_DATAFILE;
|
||||
|
||||
|
||||
class ZZ_SysConfigger :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -14,24 +13,38 @@ public:
|
||||
virtual ~ZZ_SysConfigger();
|
||||
public:
|
||||
int Initialize();
|
||||
|
||||
int GetGrabberRunParams(RunTimeGrabberParams &struGrabberRTParams);
|
||||
|
||||
int LoadSettingsFromFile_IS1();
|
||||
int LoadSettingsFromFile_iSIF();
|
||||
int LoadSettingsFromFile_System();
|
||||
int LoadSettingsFromFile_MISC();
|
||||
|
||||
int LoadSettings_Test();
|
||||
|
||||
public:
|
||||
AcqTimeSettings m_struAcqTime;
|
||||
enum ConfiggerDeviceModel
|
||||
{
|
||||
OSIFAlpha = 0,
|
||||
OSIFBeta,
|
||||
ISIF,
|
||||
IS1,
|
||||
IS2,
|
||||
Null
|
||||
};
|
||||
Q_ENUM(ConfiggerDeviceModel);
|
||||
//////////////////////////////////////////////////////////////////////////run-time settings
|
||||
AcqTimeSettings m_struAcqTime;
|
||||
DeviceContext m_struDeviceContext;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
EContext m_struEC;
|
||||
MEContext m_struMEC;
|
||||
IS1Info m_struIS1Info;
|
||||
ISIFInfo m_struISIFInfo;
|
||||
|
||||
private:
|
||||
QString m_qstrFilePath;
|
||||
QString m_qstrDeviceConfigFilePath;
|
||||
QString m_qstrJSONConfigFilePath;
|
||||
QFile qfConfig;
|
||||
QFile qfJConfig/*,qfDeviceConfig*/;
|
||||
QSettings *m_qsDeviceConfig;
|
||||
|
||||
QByteArray m_qbaJData;
|
||||
QJsonParseError m_qjpeJErr;
|
||||
|
@ -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;
|
||||
}
|
||||
|
10
source/pch.h
10
source/pch.h
@ -1,12 +1,15 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
////////////////////////////setings
|
||||
#include <QSettings>
|
||||
#include <QMetaEnum>
|
||||
////////////////////////////Basic
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
||||
#include <QDir>
|
||||
#include <QObject>
|
||||
////////////////////////////Thread
|
||||
#include <QThread>
|
||||
#include <QMutex>
|
||||
#include <QWaitCondition>
|
||||
@ -20,3 +23,6 @@
|
||||
#include <QtCore/QTime>
|
||||
#include <QDateTime>
|
||||
#include <QTimer>
|
||||
////////////////////////////Serial I/O
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
Reference in New Issue
Block a user