mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-18 19:39:43 +08:00
hebing
This commit is contained in:
5
Data/2021_12_13/beijing_13_46_16.csv
Normal file
5
Data/2021_12_13/beijing_13_46_16.csv
Normal file
File diff suppressed because one or more lines are too long
10
Data/2021_12_13/beijing_15_53_16.csv
Normal file
10
Data/2021_12_13/beijing_15_53_16.csv
Normal file
File diff suppressed because one or more lines are too long
10
Data/2021_12_13/beijing_16_34_28.csv
Normal file
10
Data/2021_12_13/beijing_16_34_28.csv
Normal file
File diff suppressed because one or more lines are too long
10
Data/2021_12_13/beijing_16_38_46.csv
Normal file
10
Data/2021_12_13/beijing_16_38_46.csv
Normal file
File diff suppressed because one or more lines are too long
10
Data/2021_12_13/beijing_16_40_16.csv
Normal file
10
Data/2021_12_13/beijing_16_40_16.csv
Normal file
File diff suppressed because one or more lines are too long
10
Data/2021_12_13/beijing_17_01_19.csv
Normal file
10
Data/2021_12_13/beijing_17_01_19.csv
Normal file
File diff suppressed because one or more lines are too long
10
Data/2021_12_13/beijing_17_05_22.csv
Normal file
10
Data/2021_12_13/beijing_17_05_22.csv
Normal file
File diff suppressed because one or more lines are too long
10
Data/2021_12_13/beijing_17_10_58.csv
Normal file
10
Data/2021_12_13/beijing_17_10_58.csv
Normal file
File diff suppressed because one or more lines are too long
@ -1,26 +1,31 @@
|
||||
[DEVICE INFO]
|
||||
TotalSpectrometer=2
|
||||
TotalSpectrometer=1
|
||||
|
||||
[FS1]
|
||||
Model=OSIFAlpha
|
||||
Port=-1
|
||||
UID=QEP02975
|
||||
AEMax=0.85
|
||||
AEMin=0.75
|
||||
Depth=230000
|
||||
[FS2]
|
||||
Model=OSIFBeta
|
||||
Port=-1
|
||||
UID=FLMS15815
|
||||
AEMax=0.85
|
||||
AEMin=0.75
|
||||
Depth=65535
|
||||
[FS2]
|
||||
Model=OSIFAlpha
|
||||
Port=-1
|
||||
UID=QEP02975
|
||||
AEMax=0.85
|
||||
AEMin=0.75
|
||||
Depth=65535
|
||||
[FS3]
|
||||
Model=Null
|
||||
[LINEAR SHUTTER]
|
||||
Port=4
|
||||
Type=0
|
||||
Port=COM8
|
||||
Type=1
|
||||
DCID=1
|
||||
TotalPosition=2
|
||||
Position0=100000
|
||||
Position1=200000
|
||||
TotalPosition=6
|
||||
Position0=2000
|
||||
Position1=110000
|
||||
Position2=220000
|
||||
Position3=330000
|
||||
Position4=440000
|
||||
Position5=550000
|
||||
|
||||
|
18
main.cpp
18
main.cpp
@ -4,6 +4,7 @@
|
||||
#include "SystemConfigger.h"
|
||||
#include "MainDataGrabber.h"
|
||||
#include "DataFileProcessor.h"
|
||||
#include "Scheduler.h"
|
||||
using namespace std;
|
||||
#pragma once
|
||||
|
||||
@ -18,6 +19,8 @@ int main(int argc, char *argv[])
|
||||
//////////////////////////////////////////////////////////////////////////configger
|
||||
DataFileProcessor testdp;
|
||||
ZZ_SysConfigger test;
|
||||
Scheduler testS;
|
||||
|
||||
RunTimeGrabberParams testp;
|
||||
EContext testEC;
|
||||
MEContext testMEC;
|
||||
@ -28,6 +31,10 @@ int main(int argc, char *argv[])
|
||||
test.GetECParams(testEC);
|
||||
test.GetMECParams(testMEC);
|
||||
|
||||
testS.SetAcqTimeParams(testp.atsParams);
|
||||
|
||||
|
||||
|
||||
testdp.SetEnvironmentContex(testEC);
|
||||
testdp.SetManmadeEnviromentalContext(testMEC);
|
||||
//testdp.WriteDataFile();
|
||||
@ -38,19 +45,22 @@ int main(int argc, char *argv[])
|
||||
testDG.moveToThread(m_pqDataGrabberThreadHolder);
|
||||
testDG.SetGrabberFileProcessor(testdp);
|
||||
testDG.SetGrabberParams(testp);
|
||||
testDG.SetTimer(testS);
|
||||
testDG.InitThreadStatus();
|
||||
testDG.InitializeWorkers();
|
||||
testDG.InitLS();
|
||||
testDG.SetupMsgPipelines();
|
||||
testDG.StartWorkers();
|
||||
|
||||
|
||||
|
||||
m_pqDataGrabberThreadHolder->start();
|
||||
testDG.StartGrab();
|
||||
|
||||
|
||||
|
||||
//testDG.StartGrab();
|
||||
|
||||
QThread* m_pqTimerThreadHolder = new QThread();
|
||||
testS.moveToThread(m_pqTimerThreadHolder);
|
||||
m_pqTimerThreadHolder->start();
|
||||
testS.SelfStart();
|
||||
|
||||
//QString qstrTest = "This is a test message 2";
|
||||
//qDebug() << qstrTest;
|
||||
|
@ -25,9 +25,9 @@ ZZ_ATPControl_Serial_Qt::~ZZ_ATPControl_Serial_Qt()
|
||||
// }
|
||||
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::Initialize(bool bIsUSBMode, ZZ_U8 ucPortNumber, std::string strDeviceName)
|
||||
int ZZ_ATPControl_Serial_Qt::Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName)
|
||||
{
|
||||
QString qstrPortName = QString("COM%1").arg(ucPortNumber);
|
||||
QString qstrPortName = QString::fromStdString(ucPortNumber);
|
||||
|
||||
m_pSerialPort->setPortName(qstrPortName);
|
||||
m_pSerialPort->setReadBufferSize(512);
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
//<2F><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>
|
||||
//int SetBaudRate(int iBaud);
|
||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>豸
|
||||
int Initialize(bool bIsUSBMode, ZZ_U8 ucPortNumber, std::string strDeviceName);
|
||||
int Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName);
|
||||
//<2F>ر<EFBFBD><D8B1>豸
|
||||
void Close();
|
||||
|
||||
|
@ -15,7 +15,7 @@ public:
|
||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>豸
|
||||
//<2F>˴<EFBFBD>stringΪָ<CEAA><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD>ocean<61><6E><EFBFBD><EFBFBD><EFBFBD>ǵIJ<C7B5><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>c/c++<2B><><EFBFBD><D7BC><EFBFBD><EFBFBD>
|
||||
//0Ϊ<30><EFBFBD><DEB4><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>뷵<EFBFBD>ز<EFBFBD>ֵͬ
|
||||
virtual int Initialize(bool bIsUSBMode,ZZ_U8 ucPortNumber,std::string strDeviceName) = 0;
|
||||
virtual int Initialize(bool bIsUSBMode, std::string ucPortNumber,std::string strDeviceName) = 0;
|
||||
|
||||
//<2F>ر<EFBFBD><D8B1>豸
|
||||
virtual void Close() = 0;
|
||||
|
@ -13,7 +13,7 @@ OceanOptics_lib::~OceanOptics_lib()
|
||||
}
|
||||
|
||||
//ʹ<><CAB9>ͷ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>#include "api/SeaBreezeWrapper.h"
|
||||
int OceanOptics_lib::Initialize(bool bIsUSBMode, ZZ_U8 ucPortNumber, std::string strDeviceName)
|
||||
int OceanOptics_lib::Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName)
|
||||
{
|
||||
int flag;
|
||||
int error;
|
||||
|
@ -16,7 +16,7 @@ public:
|
||||
//初始化设备
|
||||
//此处string为指明连接哪个ocean光谱仪的参数,可自行更换为其他c/c++标准类型
|
||||
//0为无错误,不同错误请返回不同值(不能确定:当不成功时SeaBreeze返回的错误代码error不为0 → 不敢将error直接返回)
|
||||
int Initialize(bool bIsUSBMode, ZZ_U8 ucPortNumber, std::string strDeviceName);//ok
|
||||
int Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName);//ok
|
||||
int Initialize();//ok
|
||||
|
||||
//关闭设备
|
||||
|
@ -183,7 +183,7 @@ namespace ZZ_MISCDEF
|
||||
{
|
||||
ZZ_U8 ucDeviceNumber;
|
||||
ZZ_U8 ucDeviceModel[MAX_DEVICENUMBER_FS];
|
||||
int iInterface[MAX_DEVICENUMBER_FS];
|
||||
std::string strInterface[MAX_DEVICENUMBER_FS];
|
||||
std::string strSN[MAX_DEVICENUMBER_FS];
|
||||
long lDepth[MAX_DEVICENUMBER_FS];
|
||||
float fMinFactor[MAX_DEVICENUMBER_FS];
|
||||
@ -194,7 +194,7 @@ namespace ZZ_MISCDEF
|
||||
|
||||
typedef struct tagLinearShutterContext
|
||||
{
|
||||
ZZ_U8 ucPort;
|
||||
std::string strInterface;
|
||||
ZZ_U8 ucProtocolType;
|
||||
ZZ_U8 ucCmdID;
|
||||
}LSContext;
|
||||
|
@ -10,6 +10,7 @@ public:
|
||||
virtual void Close() = 0;
|
||||
|
||||
virtual std::string ReadAll() = 0;
|
||||
virtual std::string ReadAll(int iWait) = 0;
|
||||
virtual int Write(const std::string strSend) = 0;
|
||||
|
||||
};
|
||||
|
@ -188,7 +188,7 @@ bool CVSMD12XControl::GetStatus(MSInfo &stuMotorParam)
|
||||
|
||||
int iRet = m_pAbsPort->Write(strCMD);
|
||||
|
||||
QThread::msleep(200);
|
||||
//QThread::msleep(200);
|
||||
|
||||
std::string strRecv = m_pAbsPort->ReadAll();
|
||||
ParseReturnedParam(strRecv);
|
||||
@ -295,6 +295,7 @@ bool CVSMD12XControl::MoveTo(int iAbsPulse)
|
||||
int iRet = m_pAbsPort->Write(strCMD);
|
||||
|
||||
QThread::msleep(200);
|
||||
//Delay_MSec(200);
|
||||
|
||||
m_pAbsPort->ReadAll();
|
||||
|
||||
@ -309,6 +310,7 @@ bool CVSMD12XControl::MoveTo(int iAbsPulse)
|
||||
while (!bFlagIsStopped)
|
||||
{
|
||||
QThread::msleep(200);
|
||||
//Delay_MSec(200);
|
||||
GetStatus(m_stuMSInfo);
|
||||
ZZ_U8 ucFlag = m_stuMSInfo.uiFlags & 0x000000FF;
|
||||
ucFlag = ucFlag & 0x10;
|
||||
@ -370,7 +372,8 @@ bool CVSMD12XControl::StartBackZero()
|
||||
|
||||
int iRet = m_pAbsPort->Write(strCMD);
|
||||
|
||||
QThread::msleep(200);
|
||||
//QThread::msleep(200);
|
||||
//Delay_MSec(200);
|
||||
|
||||
std::string strRecv = m_pAbsPort->ReadAll();
|
||||
|
||||
@ -383,6 +386,7 @@ bool CVSMD12XControl::StartBackZero()
|
||||
while (!bFlagIsStopped)
|
||||
{
|
||||
QThread::msleep(200);
|
||||
//Delay_MSec(200);
|
||||
GetStatus(m_stuMSInfo);
|
||||
ZZ_U8 ucFlag = m_stuMSInfo.uiFlags & 0x000000FF;
|
||||
ucFlag = ucFlag & 0x10;
|
||||
@ -1151,10 +1155,63 @@ bool CVSMD12XControl::ParseReturnedString(std::string &strRecv, int iType)
|
||||
|
||||
bool CVSMD12XControl::ParseReturnedParam(std::string &strRecv)
|
||||
{
|
||||
while (uchar(strRecv[0]) != 0xff && strRecv.size() > 0)
|
||||
{
|
||||
//std::cout << strRecv.size() << endl;
|
||||
strRecv.erase(strRecv.begin());
|
||||
//std::cout << strRecv.size() << endl;
|
||||
|
||||
}
|
||||
int iTry = 0;
|
||||
while (strRecv.size() < 2)
|
||||
{
|
||||
|
||||
std::string strRecv1 = m_pAbsPort->ReadAll();
|
||||
if (strRecv1.size() == 0)
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
strRecv = strRecv + strRecv1;
|
||||
iTry++;
|
||||
if (iTry == 2)
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (strRecv[2]==0x2)
|
||||
{
|
||||
//strRecv.erase(0, 3);
|
||||
//strRecv.erase(strRecv.size() - 3, 3);
|
||||
|
||||
int iRetry = 0;
|
||||
while (strRecv.size() != 21)
|
||||
{
|
||||
std::string strRecvTemp = "";
|
||||
strRecvTemp = m_pAbsPort->ReadAll(20);
|
||||
if (strRecvTemp.size() == 0)
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
strRecv = strRecv + strRecvTemp;
|
||||
iRetry++;
|
||||
if (iRetry == 5)
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
if (strRecv.size() > 21)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//return false;
|
||||
}
|
||||
|
||||
|
||||
if (strRecv.size() != 21)
|
||||
{
|
||||
return false;
|
||||
@ -1317,6 +1374,13 @@ char* CVSMD12XControl::VSMD_Split(char* cStr, char cSplit)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CVSMD12XControl::Delay_MSec(ZZ_U16 usMS)
|
||||
{
|
||||
QEventLoop qeLoop;
|
||||
QTimer::singleShot(usMS, &qeLoop, SLOT(quit()));
|
||||
qeLoop.exec();
|
||||
}
|
||||
|
||||
// int CVSMD12XControl::add(int a, int b)
|
||||
// {
|
||||
// return a + b;
|
||||
|
@ -139,5 +139,8 @@ private:
|
||||
bool ParseReturnedParam(std::string &strRecv);
|
||||
void VSMD_BitShift(ZZ_U8* src, unValue* dst);
|
||||
char* VSMD_Split(char* cStr, char cSplit);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////qt
|
||||
void Delay_MSec(ZZ_U16 usMS);
|
||||
};
|
||||
|
||||
|
@ -7,15 +7,15 @@ using namespace ZZ_MISCDEF;
|
||||
typedef struct tagTransportLayerInfomation
|
||||
{
|
||||
//Serial
|
||||
int iPortType;
|
||||
int iPortType = 0;
|
||||
int iPortNumber;
|
||||
int indexBaudRate;
|
||||
int iBaudRate;
|
||||
int indexParity, indexBytesize, indexStopBits; //Mode
|
||||
int iIndexBaudRate;
|
||||
int iBaudRate = 9600;
|
||||
int indexParity = 0, indexBytesize = 3, indexStopBits = 0; //Mode
|
||||
bool Hw;
|
||||
bool Sw;
|
||||
bool Dtr, Rts;
|
||||
|
||||
QString qstrFullPortName = "";
|
||||
//Bit
|
||||
//Stop
|
||||
//MODEM CONTROL setting
|
||||
@ -34,11 +34,11 @@ typedef struct tagMotorStatusInfo
|
||||
|
||||
typedef struct tagControllerParams
|
||||
{
|
||||
int bdr; //baud
|
||||
int mcs; //microsteps 0:full 1:half 2:4 3:8 4:16 5:32 6:64 7:128 8:256
|
||||
float spd; //velocity
|
||||
float acc; //acceleration
|
||||
float dec; //deceleration
|
||||
int bdr = 9600; //baud
|
||||
int mcs = 6; //microsteps 0:full 1:half 2:4 3:8 4:16 5:32 6:64 7:128 8:256
|
||||
float spd = 64000; //velocity
|
||||
float acc = 100000; //acceleration
|
||||
float dec = 100000; //deceleration
|
||||
float cra; //acc state current
|
||||
float crn; //normal state current
|
||||
float crh; //hold state current
|
||||
@ -46,11 +46,11 @@ typedef struct tagControllerParams
|
||||
ZZ_U8 s1r;
|
||||
ZZ_U8 s2f;
|
||||
ZZ_U8 s2r;
|
||||
ZZ_U8 zmd; //zero mode
|
||||
ZZ_U8 osv; //open state sensor value
|
||||
ZZ_U8 snr; //zero sensor
|
||||
ZZ_U8 zsp; //zero safe position
|
||||
float zsd; //zero velocity
|
||||
ZZ_U8 zmd = 3; //zero mode
|
||||
ZZ_U8 osv = 0; //open state sensor value
|
||||
ZZ_U8 snr = 0; //zero sensor
|
||||
ZZ_U8 zsp = 200; //zero safe position
|
||||
float zsd = 50000; //zero velocity
|
||||
}ControllerParams;
|
||||
|
||||
typedef union
|
||||
|
@ -31,7 +31,17 @@ CZZ_SeiralPort_QT::~CZZ_SeiralPort_QT()
|
||||
// {
|
||||
// bRes = false;
|
||||
// }
|
||||
QString qstrPortName = QString("COM%1").arg(m_piSettings.iPortNumber);
|
||||
QString qstrPortName;
|
||||
if (m_piSettings.qstrFullPortName != "")
|
||||
{
|
||||
qstrPortName = m_piSettings.qstrFullPortName;
|
||||
qDebug() << m_piSettings.qstrFullPortName;
|
||||
}
|
||||
else
|
||||
{
|
||||
qstrPortName = QString("COM%1").arg(m_piSettings.iPortNumber);
|
||||
}
|
||||
//QString qstrPortName = QString("COM%1").arg(m_piSettings.iPortNumber);
|
||||
m_pSerialPort->setPortName(qstrPortName);
|
||||
m_pSerialPort->setReadBufferSize(512);
|
||||
bRes = m_pSerialPort->setBaudRate(m_piSettings.iBaudRate);
|
||||
@ -63,7 +73,7 @@ void CZZ_SeiralPort_QT::Close()
|
||||
|
||||
std::string CZZ_SeiralPort_QT::ReadAll()
|
||||
{
|
||||
m_pSerialPort->waitForReadyRead(5000);
|
||||
m_pSerialPort->waitForReadyRead();
|
||||
qbaRecv.clear();
|
||||
qbaRecv = m_pSerialPort->readAll();
|
||||
std::string strRet(qbaRecv.constData(), qbaRecv.length());
|
||||
@ -95,6 +105,15 @@ std::string CZZ_SeiralPort_QT::ReadAll()
|
||||
// return strRet;
|
||||
}
|
||||
|
||||
std::string CZZ_SeiralPort_QT::ReadAll(int iWait)
|
||||
{
|
||||
m_pSerialPort->waitForReadyRead(iWait);
|
||||
qbaRecv.clear();
|
||||
qbaRecv = m_pSerialPort->readAll();
|
||||
std::string strRet(qbaRecv.constData(), qbaRecv.length());
|
||||
return strRet;
|
||||
}
|
||||
|
||||
int CZZ_SeiralPort_QT::Write(const std::string strSend)
|
||||
{
|
||||
QByteArray qbaTest(strSend.c_str(),(int)strSend.length());
|
||||
|
@ -19,6 +19,7 @@ public:
|
||||
virtual void Close();
|
||||
|
||||
virtual std::string ReadAll();
|
||||
virtual std::string ReadAll(int iWait);
|
||||
virtual int Write(const std::string strSend);
|
||||
|
||||
};
|
||||
|
@ -33,31 +33,31 @@
|
||||
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)
|
||||
m_struFSContext.ucDeviceNumber = m_qsDeviceConfig->value(QString("DEVICE INFO/TotalSpectrometer"),-1).toInt();
|
||||
if (m_struFSContext.ucDeviceNumber == -1)
|
||||
{
|
||||
qDebug() << "DEVICE INFO TotalSpectrometer Value Err.";
|
||||
return 3;
|
||||
}
|
||||
for (ZZ_U8 i=0;i< m_struDeviceContext.ucDeviceNumber;i++)
|
||||
for (ZZ_U8 i=0;i< m_struFSContext.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());
|
||||
m_struFSContext.ucDeviceModel[i]= enumDeviceModel.keysToValue(qstrTemp.toLatin1().data());
|
||||
|
||||
int iInterface= m_qsDeviceConfig->value(QString("FS%1/Port").arg(i + 1), -2).toInt();
|
||||
m_struDeviceContext.iInterface[i] = iInterface;
|
||||
m_struFSContext.strInterface[i] = iInterface;
|
||||
|
||||
qstrTemp = m_qsDeviceConfig->value(QString("FS%1/UID").arg(i + 1), "Null").toString();
|
||||
m_struDeviceContext.strSN[i] = qstrTemp.toStdString();
|
||||
m_struFSContext.strSN[i] = qstrTemp.toStdString();
|
||||
|
||||
float fAEMax= m_qsDeviceConfig->value(QString("FS%1/AEMax").arg(i + 1), 0.9).toFloat();
|
||||
m_struDeviceContext.fMaxFactor[i] = fAEMax;
|
||||
m_struFSContext.fMaxFactor[i] = fAEMax;
|
||||
|
||||
float fAEMin = m_qsDeviceConfig->value(QString("FS%1/AEMin").arg(i + 1), 0.8).toFloat();
|
||||
m_struDeviceContext.fMinFactor[i] = fAEMin;
|
||||
m_struFSContext.fMinFactor[i] = fAEMin;
|
||||
|
||||
long lDepth = m_qsDeviceConfig->value(QString("FS%1/Depth").arg(i + 1), 63219).toInt();
|
||||
m_struDeviceContext.lDepth[i] = lDepth;
|
||||
m_struFSContext.lDepth[i] = lDepth;
|
||||
}
|
||||
|
||||
m_struAcqPosition.iTotalPosition = m_qsDeviceConfig->value(QString("LINEAR SHUTTER/TotalPosition"), -1).toInt();
|
||||
@ -74,7 +74,9 @@
|
||||
}
|
||||
|
||||
|
||||
|
||||
m_struLSContext.ucCmdID = m_qsDeviceConfig->value(QString("LINEAR SHUTTER/DCID")).toInt();
|
||||
m_struLSContext.ucProtocolType = m_qsDeviceConfig->value(QString("LINEAR SHUTTER/Type")).toInt();
|
||||
m_struLSContext.strInterface = m_qsDeviceConfig->value(QString("LINEAR SHUTTER/Port")).toString().toStdString();
|
||||
//////////////////////////////////////////////////////////////////////////load json settings
|
||||
qfJConfig.setFileName(m_qstrJSONConfigFilePath);
|
||||
bool bRes = qfJConfig.open(QIODevice::ReadOnly);
|
||||
@ -98,7 +100,9 @@
|
||||
int ZZ_SysConfigger::GetGrabberRunParams(RunTimeGrabberParams &struGrabberRTParams)
|
||||
{
|
||||
struGrabberRTParams.atsParams = m_struAcqTime;
|
||||
struGrabberRTParams.fscParams = m_struDeviceContext;
|
||||
struGrabberRTParams.fscParams = m_struFSContext;
|
||||
struGrabberRTParams.lscParam = m_struLSContext;
|
||||
struGrabberRTParams.apsParams = m_struAcqPosition;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,8 @@ public:
|
||||
Q_ENUM(ConfiggerDeviceModel);
|
||||
//////////////////////////////////////////////////////////////////////////run-time settings
|
||||
AcqTimeSettings m_struAcqTime;
|
||||
FSContext m_struDeviceContext;
|
||||
LSContext m_struLSContext;
|
||||
FSContext m_struFSContext;
|
||||
AcqPosSettings m_struAcqPosition;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
EContext m_struEC;
|
||||
|
@ -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