mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-18 19:39:43 +08:00
Merge remote-tracking branch 'origin/zhangzhuo'
This commit is contained in:
@ -18,6 +18,7 @@ include_directories("source/Logger")
|
||||
include_directories("source/ZZ_SDK")
|
||||
include_directories("source/Settings")
|
||||
include_directories("source/Thread")
|
||||
include_directories("source/LinearShutter")
|
||||
|
||||
add_executable( TowerOptoSifAndSpectral
|
||||
main.cpp
|
||||
|
20
config/DeviceSettings.ini
Normal file
20
config/DeviceSettings.ini
Normal file
@ -0,0 +1,20 @@
|
||||
[DEVICE INFO]
|
||||
TotalSpectrometer=2
|
||||
[FS1]
|
||||
Model=ISIF
|
||||
Port=2
|
||||
DUID=test1
|
||||
[FS2]
|
||||
Model=IS1
|
||||
Port=3
|
||||
DUID=test2
|
||||
[LINEAR SHUTTER]
|
||||
Port=4
|
||||
Type=0
|
||||
DCID=1
|
||||
TotalPosition=5
|
||||
Position0=0
|
||||
Position1=200000
|
||||
Position2=300000
|
||||
Position3=400000
|
||||
Position4=500000
|
@ -1,14 +0,0 @@
|
||||
[DEVICE INFO]
|
||||
TotalSpectrometer=1
|
||||
[FS1]
|
||||
Model=ISIF
|
||||
Port=2
|
||||
UID=
|
||||
[FS2]
|
||||
Model=IS1
|
||||
Port=3
|
||||
UID=
|
||||
[LinearShutter]
|
||||
TotalPosition=2
|
||||
Position0=100000
|
||||
Position1=200000
|
18
main.cpp
18
main.cpp
@ -16,9 +16,24 @@ int main(int argc, char *argv[])
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////configger
|
||||
ZZ_SysConfigger test;
|
||||
RunTimeGrabberParams testp;
|
||||
test.Initialize();
|
||||
test.LoadSettingsFromFile_System();
|
||||
test.GetGrabberRunParams(testp);
|
||||
//////////////////////////////////////////////////////////////////////////test
|
||||
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||
CMainDataGrabber testDG;
|
||||
QThread* m_pqDataGrabberThreadHolder = new QThread();
|
||||
testDG.moveToThread(m_pqDataGrabberThreadHolder);
|
||||
testDG.SetGrabberParams(testp);
|
||||
testDG.InitThreadStatus();
|
||||
testDG.InitializeWorkers();
|
||||
testDG.SetupMsgPipelines();
|
||||
testDG.StartWorkers();
|
||||
m_pqDataGrabberThreadHolder->start();
|
||||
|
||||
testDG.StartGrab();
|
||||
|
||||
//QString qstrTest = "This is a test message 2";
|
||||
//qDebug() << qstrTest;
|
||||
//cout << "This is a test message";
|
||||
@ -29,8 +44,7 @@ int main(int argc, char *argv[])
|
||||
//m_test.GrabOnce();
|
||||
//QThread* m_pqDataGrabberThreadHolder;
|
||||
|
||||
//m_pqDataGrabberThreadHolder = new QThread();
|
||||
//m_test.moveToThread(m_pqDataGrabberThreadHolder);
|
||||
|
||||
//m_pqDataGrabberThreadHolder->start();
|
||||
//m_test.TestGrabOnce();
|
||||
//m_test.StartGrabCall();
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "pch.h"
|
||||
#include <string>
|
||||
#define MAX_DEVICENUMBER_FS 2
|
||||
#define MAX_LINEARSHUTTER_POSITION 12
|
||||
namespace ZZ_MISCDEF
|
||||
{
|
||||
typedef unsigned char ZZ_U8;
|
||||
@ -166,11 +167,20 @@ namespace ZZ_MISCDEF
|
||||
//<2F><><EFBFBD>в<EFBFBD><D0B2><EFBFBD>
|
||||
namespace ZZ_RUNPARAMS
|
||||
{
|
||||
typedef struct tagDeviceContext
|
||||
typedef struct tagFiberSpecContext
|
||||
{
|
||||
ZZ_U8 ucDeviceNumber;
|
||||
ZZ_U8 ucDeviceModel[MAX_DEVICENUMBER_FS];
|
||||
}DeviceContext;
|
||||
ZZ_U8 ucDeviceNumber;
|
||||
ZZ_U8 ucDeviceModel[MAX_DEVICENUMBER_FS];
|
||||
int iInterface[MAX_DEVICENUMBER_FS];
|
||||
std::string strSN[MAX_DEVICENUMBER_FS];
|
||||
}FSContext;
|
||||
|
||||
typedef struct tagLinearShutterContext
|
||||
{
|
||||
ZZ_U8 ucPort;
|
||||
ZZ_U8 ucProtocolType;
|
||||
ZZ_U8 ucCmdID;
|
||||
}LSContext;
|
||||
|
||||
typedef struct tagAcquisitionTimeSettings
|
||||
{
|
||||
@ -179,22 +189,26 @@ namespace ZZ_MISCDEF
|
||||
QTime qtInterval;
|
||||
}AcqTimeSettings;
|
||||
|
||||
typedef struct tagAcquisitionPositionSettings
|
||||
{
|
||||
int iTotalPosition;
|
||||
int iPosition[MAX_LINEARSHUTTER_POSITION];
|
||||
}AcqPosSettings;
|
||||
|
||||
typedef struct tagRunTimeGrabberParams
|
||||
{
|
||||
DeviceContext dcParams;
|
||||
LSContext lscParam;
|
||||
FSContext fscParams;
|
||||
AcqTimeSettings atsParams;
|
||||
AcqPosSettings apsParams;
|
||||
}RunTimeGrabberParams;
|
||||
|
||||
|
||||
typedef struct tagATPCalibrationSettings
|
||||
{
|
||||
//Up0 Down1,2,3
|
||||
QString qsISIF_CalibrationFilePath[4];
|
||||
QString qsIS1_CalibrationFilePath[4];
|
||||
|
||||
}ATPCalibrationSettings;
|
||||
|
||||
|
||||
}
|
||||
|
||||
//ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ṹ
|
||||
|
16
source/LinearShutter/AbstractPort.h
Normal file
16
source/LinearShutter/AbstractPort.h
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include "VSMD12XMiscDefines.h"
|
||||
#include <string>
|
||||
class CAbstractPort
|
||||
{
|
||||
public:
|
||||
virtual void InitPort(PortInfo portinfo) = 0;
|
||||
virtual bool SetPort() = 0;
|
||||
virtual bool Open() = 0;
|
||||
virtual void Close() = 0;
|
||||
|
||||
virtual std::string ReadAll() = 0;
|
||||
virtual int Write(const std::string strSend) = 0;
|
||||
|
||||
};
|
||||
|
1323
source/LinearShutter/VSMD12XControl.cpp
Normal file
1323
source/LinearShutter/VSMD12XControl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
143
source/LinearShutter/VSMD12XControl.h
Normal file
143
source/LinearShutter/VSMD12XControl.h
Normal file
@ -0,0 +1,143 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#include "AbstractPort.h"
|
||||
using namespace std;
|
||||
// #ifdef IRIS_API_EXPORTS
|
||||
//
|
||||
// #ifdef __cplusplus
|
||||
// #define IRIS_API_FUNC extern "C" __declspec(dllexport)
|
||||
// #else
|
||||
// #define IRIS_API_FUNC __declspec(dllexport)
|
||||
// #endif
|
||||
//
|
||||
// #else
|
||||
//
|
||||
// #ifdef __cplusplus
|
||||
// #define IRIS_API_FUNC extern "C" __declspec(dllimport)
|
||||
// #else
|
||||
// #define IRIS_API_FUNC __declspec(dllimport)
|
||||
// #endif
|
||||
//
|
||||
// #endif
|
||||
//
|
||||
//
|
||||
// #ifdef IRIS_API_EXPORTS
|
||||
// #define IRIS_API_CLASS __declspec(dllexport)
|
||||
// #else
|
||||
// #define IRIS_API_CLASS __declspec(dllimport)
|
||||
// #endif
|
||||
|
||||
class /*IRIS_API_CLASS*/ CVSMD12XControl
|
||||
{
|
||||
public:
|
||||
CVSMD12XControl();
|
||||
~CVSMD12XControl();
|
||||
private:
|
||||
int *m_piPositionInPulses;
|
||||
bool m_bIsSyncMove;
|
||||
CAbstractPort *m_pAbsPort;
|
||||
unValue m_unValue;
|
||||
MSInfo m_stuMSInfo;
|
||||
ControllerParams m_stuControllerParams;
|
||||
int m_iProtocolType;
|
||||
int m_iCID;
|
||||
std::string m_strCID;
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//for IRIS Linear Motor - Electric Shutter
|
||||
|
||||
//Initialize communication setup iPortType(0:RS232 1:RS485) iCID(For RS485 device) bSyncMove(move mode)
|
||||
bool ILMES_InitializeComm(PortInfo portinfo,int iPortType = 1,int iCID = 1, bool bSyncMove = true);
|
||||
|
||||
//Initialize Controller params
|
||||
bool ILMES_InitializeParams(ControllerParams cpParams);
|
||||
|
||||
//Set the light hole position(pulses)
|
||||
void ILMES_SetPosition(int *piPositionInPulse,size_t szSize);
|
||||
|
||||
bool ILMES_MoveToPos(int iPositionIndex);
|
||||
|
||||
public:
|
||||
|
||||
////init port
|
||||
void SetProtocolType(int iProtocolType = 0);//0:RS232 1:RS485 call before send any command
|
||||
void SetCID(int iID);//set device id when using RS485 protocol call before send any command
|
||||
void SetSyncMode(bool bSyncMove = false);
|
||||
bool InitAndOpenPort(PortInfo portinfo);//Init comport by PortInfo Struct
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////for debug or unsupported function
|
||||
std::string ReadReceive();
|
||||
int SendCommand(const std::string strSend); // return indicates how many char has been sent
|
||||
//////////////////////////////////////////////////////////////////////////motor control
|
||||
////init&misc
|
||||
bool InitController(); //Init Motor controller hand shake
|
||||
|
||||
bool Enable(); //enbale
|
||||
bool Disable(); //disable
|
||||
|
||||
bool GetStatus(MSInfo &stuMotorParam); //load motor status see MSInfo Struct
|
||||
////motion control
|
||||
bool Move(int iRelPulse); // relative move mode,pulse (-2147483647<34><37>2147483647)
|
||||
bool MoveTo(int iAbsPulse);//absolute mode,pulse (-2147483647<34><37>2147483647)
|
||||
|
||||
bool SetLogicZero(); //set logic zero
|
||||
|
||||
bool StartBackZero();//back zero
|
||||
bool StopBackZero();// stop back zero & reset register
|
||||
////Set&Get
|
||||
bool SetBaudRate(int iBaudRate);//set controller baud rates,default B9600 (2400 <20><> 921600)
|
||||
int GetBaudRate(); // -1:should retry;
|
||||
|
||||
bool SetMicroSteps(int iMicroSteps);//set micro steps (0<><30>5)->(1/2/4/8/16/32)
|
||||
int GetMicroSteps();
|
||||
|
||||
bool SetAccSpeed(float fAccSpd);//set acceleration speed in pulse (0 <20><> 192000000)
|
||||
float GetAccSpeed();
|
||||
|
||||
bool SetRunSpeed(float fRunSpeed);//set normal running speed in pulse (0 <20><> 192000000)
|
||||
float GetRunSpeed();
|
||||
|
||||
bool SetDecSpeed(float fDecSpeed);//set deceleration speed in pulse (0 <20><> 192000000)
|
||||
float GetDecSpeed();
|
||||
|
||||
bool SetSpeed(float fRunSpeed, float fAccSpd, float fDecSpeed);//see above three functions
|
||||
|
||||
bool SetHoldCurrent(float fHoldCurrent);//set hold current ( 0 <20><> 8.0 )Amp? pay attention to your motor specification.
|
||||
float GetHoldCurrent();
|
||||
|
||||
bool SetAccCurrent(float fAccCurrent);//set acceleration current ( 0 <20><> 8.0 )Amp? pay attention to your motor specification.
|
||||
float GetAccCurrent();
|
||||
|
||||
bool SetRunCurrent(float fRunCurrent);//set normal running current ( 0 <20><> 8.0 )Amp? pay attention to your motor specification.
|
||||
float GetRunCurrent();
|
||||
|
||||
bool SetCurrent(float fAccCurrent, float fRunCurrent, float fHoldCurrent);//see above three functions
|
||||
|
||||
bool SetS1FETE(ZZ_U8 bS1FETE);//S1 register falling edge trigger event,see enum
|
||||
ZZ_U8 GetS1FETE();
|
||||
|
||||
bool SetS1RETE(ZZ_U8 bS1RETE);//S1 register rising edge trigger event
|
||||
ZZ_U8 GetS1RETE();
|
||||
|
||||
bool SetS2FETE(ZZ_U8 bS2FETE);//S2 register falling edge trigger event
|
||||
ZZ_U8 GetS2FETE();
|
||||
|
||||
bool SetS2RETE(ZZ_U8 bS2RETE);//S2 register rising edge trigger event
|
||||
ZZ_U8 GetS2RETE();
|
||||
|
||||
//(ZeroMode 0:off 1:once 2:once + safe position 3:twice 4:twice + safe position) (OpenVoltageLevel 0:Low Level 1:High Level)
|
||||
//(ZeroSensor 0:S1 1:S2 2:S3 3:S4 4:S5 5:S6)( ZeroVelocity <20><>-192000) <20><><EFBFBD><EFBFBD>192000<30><30>pulse)(SafePosition <20><>-2147483647) <20><><EFBFBD><EFBFBD>2147483647<34><37>)
|
||||
bool SetZeroParams(ZZ_U8 bZeroMode, ZZ_U8 bSwitchOpenVL, ZZ_U8 bZeroSensor, float fZeroVelocity, int iSafePosition);
|
||||
ZZ_U8 GetZeroMode();
|
||||
ZZ_U8 GetSwitchOpenVoltageLevel();
|
||||
ZZ_U8 GetZeroSensor();
|
||||
int GetSafePosition();
|
||||
float GetZeroVelocity();
|
||||
|
||||
private:
|
||||
bool ParseReturnedString(std::string &strRecv,int iType);
|
||||
bool ParseReturnedParam(std::string &strRecv);
|
||||
void VSMD_BitShift(ZZ_U8* src, unValue* dst);
|
||||
char* VSMD_Split(char* cStr, char cSplit);
|
||||
};
|
||||
|
79
source/LinearShutter/VSMD12XMiscDefines.h
Normal file
79
source/LinearShutter/VSMD12XMiscDefines.h
Normal file
@ -0,0 +1,79 @@
|
||||
#pragma once
|
||||
#include "ZZ_Types.h"
|
||||
#define MAXBUFFER 10240
|
||||
|
||||
using namespace ZZ_MISCDEF;
|
||||
|
||||
typedef struct tagTransportLayerInfomation
|
||||
{
|
||||
//Serial
|
||||
int iPortType;
|
||||
int iPortNumber;
|
||||
int indexBaudRate;
|
||||
int iBaudRate;
|
||||
int indexParity, indexBytesize, indexStopBits; //Mode
|
||||
bool Hw;
|
||||
bool Sw;
|
||||
bool Dtr, Rts;
|
||||
|
||||
//Bit
|
||||
//Stop
|
||||
//MODEM CONTROL setting
|
||||
//MODEM LINE STATUS
|
||||
|
||||
//TCP UDP
|
||||
|
||||
}PortInfo;
|
||||
|
||||
typedef struct tagMotorStatusInfo
|
||||
{
|
||||
float fVelocity;
|
||||
int iPosition;
|
||||
ZZ_U32 uiFlags;
|
||||
}MSInfo;
|
||||
|
||||
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
|
||||
float cra; //acc state current
|
||||
float crn; //normal state current
|
||||
float crh; //hold state current
|
||||
ZZ_U8 s1f;
|
||||
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
|
||||
}ControllerParams;
|
||||
|
||||
typedef union
|
||||
{
|
||||
ZZ_U8 byteValue[4];
|
||||
short i16Value[2];
|
||||
ZZ_U16 u16Value[2];
|
||||
int i32Value;
|
||||
float fValue;
|
||||
ZZ_U32 u32Value;
|
||||
}unValue;
|
||||
|
||||
enum emVSMDTriggerEvent
|
||||
{
|
||||
NoAction =0, //<2F><EFBFBD><DEB6><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>״̬λ S1 <20>仯֪ͨ<CDA8><D6AA>
|
||||
ResetZeroPosition, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>λ<EFBFBD><CEBB>
|
||||
DecSpdStop, //<2F><><EFBFBD><EFBFBD>ֹͣ
|
||||
DecSpdStopRZP, //<2F><><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>λ<EFBFBD><CEBB>
|
||||
Stop, //<2F><><EFBFBD><EFBFBD>ֹͣ
|
||||
StopRZP, //<2F><><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>λ<EFBFBD><CEBB>
|
||||
RunningPosDirect, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>ٶȣ<D9B6>
|
||||
RunningNegDirect, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>ٶȣ<D9B6>
|
||||
OfflineModeOn, //<2F><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
||||
OfflineModeOff //<2F><><EFBFBD><EFBFBD>ģʽֹͣ
|
||||
};
|
||||
|
123
source/LinearShutter/ZZ_SeiralPort.cpp
Normal file
123
source/LinearShutter/ZZ_SeiralPort.cpp
Normal file
@ -0,0 +1,123 @@
|
||||
#include "pch.h"
|
||||
#include "ZZ_SeiralPort.h"
|
||||
|
||||
CZZ_SeiralPort_QT::CZZ_SeiralPort_QT()
|
||||
{
|
||||
m_pSerialPort = new QSerialPort;
|
||||
}
|
||||
|
||||
CZZ_SeiralPort_QT::~CZZ_SeiralPort_QT()
|
||||
{
|
||||
if (m_pSerialPort != NULL)
|
||||
{
|
||||
delete m_pSerialPort;
|
||||
}
|
||||
}
|
||||
|
||||
void CZZ_SeiralPort_QT::InitPort(PortInfo portinfo)
|
||||
{
|
||||
|
||||
m_piSettings = portinfo;
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool CZZ_SeiralPort_QT::SetPort()
|
||||
{
|
||||
bool bRes = true;
|
||||
// int iRes = sio_ioctl(m_piSettings.iPortNumber, m_piSettings.indexBaudRate,
|
||||
// m_piSettings.indexParity | m_piSettings.indexBytesize | m_piSettings.indexStopBits);
|
||||
// if (iRes != SIO_OK)
|
||||
// {
|
||||
// bRes = false;
|
||||
// }
|
||||
QString qstrPortName = QString("COM%1").arg(m_piSettings.iPortNumber);
|
||||
m_pSerialPort->setPortName(qstrPortName);
|
||||
m_pSerialPort->setReadBufferSize(512);
|
||||
bRes = m_pSerialPort->setBaudRate(m_piSettings.iBaudRate);
|
||||
return bRes;
|
||||
}
|
||||
|
||||
bool CZZ_SeiralPort_QT::Open()
|
||||
{
|
||||
bool bRes = true;
|
||||
// int iRes = sio_open(m_piSettings.iPortNumber);
|
||||
// if (iRes!=SIO_OK)
|
||||
// {
|
||||
// bRes = false;
|
||||
// }
|
||||
bRes = m_pSerialPort->open(QIODevice::ReadWrite);
|
||||
if (!bRes)
|
||||
{
|
||||
qDebug() << "Err:open Failed.Exit Code:1";
|
||||
//std::cout << "Err.open Failed" << std::endl;
|
||||
return bRes;;
|
||||
}
|
||||
return bRes;
|
||||
}
|
||||
|
||||
void CZZ_SeiralPort_QT::Close()
|
||||
{
|
||||
m_pSerialPort->close();
|
||||
}
|
||||
|
||||
std::string CZZ_SeiralPort_QT::ReadAll()
|
||||
{
|
||||
m_pSerialPort->waitForReadyRead();
|
||||
qbaRecv.clear();
|
||||
qbaRecv = m_pSerialPort->readAll();
|
||||
std::string strRet(qbaRecv.constData(), qbaRecv.length());
|
||||
return strRet;
|
||||
|
||||
// std::string strRet;
|
||||
// char cBuf[MAXBUFFER];
|
||||
// int iRet = sio_read(m_piSettings.iPortNumber,cBuf, MAXBUFFER);
|
||||
// if (iRet==0)
|
||||
// {
|
||||
// strRet = "";
|
||||
//
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// char *pRecv = new char[iRet];
|
||||
// memcpy(pRecv, cBuf, iRet);
|
||||
// //std::string strRet(pRecv);
|
||||
// //delete pRecv;
|
||||
// //return strRet;
|
||||
//
|
||||
// strRet.resize(iRet);
|
||||
// for (int i=0;i<iRet;i++)
|
||||
// {
|
||||
// strRet[i] = pRecv[i];
|
||||
// }
|
||||
// delete pRecv;
|
||||
// }
|
||||
// return strRet;
|
||||
}
|
||||
|
||||
int CZZ_SeiralPort_QT::Write(const std::string strSend)
|
||||
{
|
||||
QByteArray qbaTest(strSend.c_str(),(int)strSend.length());
|
||||
qint64 qi64Write = m_pSerialPort->write(qbaTest);
|
||||
m_pSerialPort->waitForBytesWritten();
|
||||
if (qi64Write != qbaTest.size())
|
||||
{
|
||||
qDebug() << "Err:write Failed.Exit Code:1" << qi64Write;
|
||||
return qi64Write;
|
||||
}
|
||||
|
||||
return 0;
|
||||
// char* pcSend = (char*)strSend.c_str();
|
||||
// int iRet = sio_write(m_piSettings.iPortNumber, pcSend, (int)strSend.length());
|
||||
//
|
||||
// //delete pcSend;
|
||||
// if (iRet!= (int)strSend.length())
|
||||
// {
|
||||
// return iRet;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
// //sio_write();
|
||||
}
|
25
source/LinearShutter/ZZ_SeiralPort.h
Normal file
25
source/LinearShutter/ZZ_SeiralPort.h
Normal file
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
#include "VSMD12XMiscDefines.h"
|
||||
#include "AbstractPort.h"
|
||||
|
||||
class CZZ_SeiralPort_QT:public CAbstractPort
|
||||
{
|
||||
|
||||
private:
|
||||
PortInfo m_piSettings;
|
||||
QByteArray qbaSend, qbaRecv;
|
||||
QSerialPort *m_pSerialPort;
|
||||
public:
|
||||
CZZ_SeiralPort_QT();
|
||||
virtual ~CZZ_SeiralPort_QT();
|
||||
public:
|
||||
virtual void InitPort(PortInfo portinfo);
|
||||
virtual bool SetPort();
|
||||
virtual bool Open();
|
||||
virtual void Close();
|
||||
|
||||
virtual std::string ReadAll();
|
||||
virtual int Write(const std::string strSend);
|
||||
|
||||
};
|
||||
|
@ -42,8 +42,29 @@
|
||||
{
|
||||
QString qstrTemp= m_qsDeviceConfig->value(QString("FS%1/Model").arg(i+1), "Null").toString();
|
||||
m_struDeviceContext.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;
|
||||
|
||||
qstrTemp = m_qsDeviceConfig->value(QString("FS%1/UID").arg(i + 1), "Null").toString();
|
||||
m_struDeviceContext.strSN[i] = qstrTemp.toStdString();
|
||||
}
|
||||
|
||||
m_struAcqPosition.iTotalPosition = m_qsDeviceConfig->value(QString("LINEAR SHUTTER/TotalPosition"), -1).toInt();
|
||||
if (m_struAcqPosition.iTotalPosition == -1)
|
||||
{
|
||||
qDebug() << "LINEAR SHUTTER TotalPosition Value Err.";
|
||||
return 4;
|
||||
}
|
||||
|
||||
for (ZZ_U8 i = 0; i < m_struAcqPosition.iTotalPosition; i++)
|
||||
{
|
||||
int iPosition = m_qsDeviceConfig->value(QString("LINEAR SHUTTER/Position%1").arg(i), -2).toInt();
|
||||
m_struAcqPosition.iPosition[i] = iPosition;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////load json settings
|
||||
qfJConfig.setFileName(m_qstrJSONConfigFilePath);
|
||||
bool bRes = qfJConfig.open(QIODevice::ReadOnly);
|
||||
@ -67,7 +88,7 @@
|
||||
int ZZ_SysConfigger::GetGrabberRunParams(RunTimeGrabberParams &struGrabberRTParams)
|
||||
{
|
||||
struGrabberRTParams.atsParams = m_struAcqTime;
|
||||
struGrabberRTParams.dcParams = m_struDeviceContext;
|
||||
struGrabberRTParams.fscParams = m_struDeviceContext;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,8 @@ public:
|
||||
Q_ENUM(ConfiggerDeviceModel);
|
||||
//////////////////////////////////////////////////////////////////////////run-time settings
|
||||
AcqTimeSettings m_struAcqTime;
|
||||
DeviceContext m_struDeviceContext;
|
||||
FSContext m_struDeviceContext;
|
||||
AcqPosSettings m_struAcqPosition;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
EContext m_struEC;
|
||||
MEContext m_struMEC;
|
||||
|
@ -1,19 +1,22 @@
|
||||
#include "AbstractFSController.h"
|
||||
CAbstractFSController::CAbstractFSController(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
m_pFSCtrl = NULL;
|
||||
m_iThreadID = -1;
|
||||
m_iDeviceType = -1;
|
||||
}
|
||||
|
||||
CAbstractFSController::~CAbstractFSController()
|
||||
{
|
||||
|
||||
if (m_pFSCtrl!= 0 )
|
||||
{
|
||||
delete m_pFSCtrl;
|
||||
}
|
||||
}
|
||||
|
||||
int CAbstractFSController::SetRunParas(int iThreadID, int iDeviceType)
|
||||
int CAbstractFSController::SetRunParas(int iThreadID, FSInfo fsInfo)
|
||||
{
|
||||
m_iThreadID = iThreadID;
|
||||
m_iDeviceType = iDeviceType;
|
||||
m_fsInfo = fsInfo;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -21,12 +24,13 @@ int CAbstractFSController::SetRunParas(int iThreadID, int iDeviceType)
|
||||
|
||||
int CAbstractFSController::InitializeFSControl()
|
||||
{
|
||||
if (m_iThreadID == -1|| m_iDeviceTyp == -1)
|
||||
using namespace ZZ_MISCDEF::IRIS;
|
||||
if (m_iThreadID == -1/*|| m_iDeviceType == -1*/)
|
||||
{
|
||||
qDebug() << "Params Err. Call SetRunParas first";
|
||||
return 1;
|
||||
}
|
||||
switch (m_iDeviceType)
|
||||
switch (m_fsInfo.ucDeviceModel)
|
||||
{
|
||||
case DeviceModel::OSIFAlpha:
|
||||
|
||||
@ -35,12 +39,15 @@ int CAbstractFSController::InitializeFSControl()
|
||||
break;
|
||||
case DeviceModel::ISIF:
|
||||
m_pFSCtrl = new ZZ_ATPControl_Serial_Qt;
|
||||
m_pFSCtrl->Initialize(false, m_fsInfo.iInterface, NULL);
|
||||
break;
|
||||
case DeviceModel::IS1:
|
||||
m_pFSCtrl = new ZZ_ATPControl_Serial_Qt;
|
||||
m_pFSCtrl->Initialize(false, m_fsInfo.iInterface, NULL);
|
||||
break;
|
||||
case DeviceModel::IS2:
|
||||
m_pFSCtrl = new ZZ_ATPControl_Serial_Qt;
|
||||
m_pFSCtrl->Initialize(false, m_fsInfo.iInterface, NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -50,11 +57,18 @@ int CAbstractFSController::InitializeFSControl()
|
||||
|
||||
int CAbstractFSController::StartAcquisition()
|
||||
{
|
||||
//
|
||||
qDebug() << "Starting acq" << " Thread ID:" << m_iThreadID;
|
||||
QThread::msleep(5000);
|
||||
qDebug() << "Stop acq" << " Thread ID:" << m_iThreadID;
|
||||
emit SignalAcqFinished(m_iThreadID, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CAbstractFSController::StopAcquisition()
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,6 +3,13 @@
|
||||
#include "ATPControl_Serial_QT.h"
|
||||
#include <atomic>
|
||||
|
||||
typedef struct tagFSInfo
|
||||
{
|
||||
ZZ_U8 ucDeviceModel;
|
||||
int iInterface;
|
||||
std::string strSN;
|
||||
}FSInfo;
|
||||
|
||||
class CAbstractFSController :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -10,21 +17,19 @@ 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);
|
||||
virtual int SetRunParas(int iThreadID, FSInfo fsInfo);
|
||||
|
||||
//create derived class from base class
|
||||
virtual int InitializeFSControl();
|
||||
|
||||
virtual int StartAcquisition();
|
||||
private:
|
||||
CIrisFSBase *m_pFSCtrl;
|
||||
int m_iThreadID;
|
||||
FSInfo m_fsInfo;
|
||||
|
||||
public slots:
|
||||
virtual int StartAcquisition();
|
||||
virtual int StopAcquisition();
|
||||
|
||||
signals:
|
||||
|
@ -1,8 +1,46 @@
|
||||
#include "MainDataGrabber.h"
|
||||
|
||||
CMainDataGrabber::CMainDataGrabber(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
m_piFlagCaptureThreadStatus = NULL;
|
||||
}
|
||||
|
||||
CMainDataGrabber::~CMainDataGrabber()
|
||||
{
|
||||
if (m_pControlThread.size() != 0)
|
||||
{
|
||||
for (int i=0;i< m_pControlThread.size();i++)
|
||||
{
|
||||
delete m_pControlThread[i];
|
||||
}
|
||||
}
|
||||
m_pControlThread.clear();
|
||||
|
||||
if (m_piFlagCaptureThreadStatus!=NULL)
|
||||
{
|
||||
delete m_piFlagCaptureThreadStatus;
|
||||
}
|
||||
}
|
||||
|
||||
int CMainDataGrabber::SetGrabberParams(RunTimeGrabberParams struGrabberRTParams)
|
||||
{
|
||||
m_struAcqTime = struGrabberRTParams.atsParams;
|
||||
m_struDeviceContext = struGrabberRTParams.dcParams;
|
||||
m_struDeviceContext = struGrabberRTParams.fscParams;
|
||||
m_iTotalThreads = m_struDeviceContext.ucDeviceNumber;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMainDataGrabber::InitThreadStatus()
|
||||
{
|
||||
if (m_piFlagCaptureThreadStatus!=NULL)
|
||||
{
|
||||
delete m_piFlagCaptureThreadStatus;
|
||||
}
|
||||
m_piFlagCaptureThreadStatus = new int[m_iTotalThreads];
|
||||
for (int i = 0; i < m_iTotalThreads; i++)
|
||||
{
|
||||
m_piFlagCaptureThreadStatus[i] = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -10,8 +48,93 @@ int CMainDataGrabber::InitializeWorkers()
|
||||
{
|
||||
for (ZZ_U8 i = 0; i < m_struDeviceContext.ucDeviceNumber; i++)
|
||||
{
|
||||
m_piFlagCaptureThreadStatus[i] = 0;
|
||||
|
||||
FSInfo fsInfo;
|
||||
fsInfo.iInterface = m_struDeviceContext.iInterface[i];
|
||||
fsInfo.ucDeviceModel = m_struDeviceContext.ucDeviceModel[i];
|
||||
fsInfo.strSN = m_struDeviceContext.strSN[i];
|
||||
|
||||
CAbstractFSController* m_pWorkThread = new CAbstractFSController;
|
||||
m_pWorkThread->SetRunParas(i, fsInfo);
|
||||
//m_pWorkThread->InitializeFSControl();
|
||||
m_pControlThread.push_back(m_pWorkThread);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMainDataGrabber::StartWorkers()
|
||||
{
|
||||
|
||||
for (ZZ_U8 i = 0; i < m_struDeviceContext.ucDeviceNumber; i++)
|
||||
{
|
||||
QThread *pWorkThreadHolder = new QThread();
|
||||
m_pControlThread[i]->moveToThread(pWorkThreadHolder);
|
||||
pWorkThreadHolder->start();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMainDataGrabber::SetupMsgPipelines()
|
||||
{
|
||||
//connect(this, &CMainDataGrabber::SignalStartGrabOnce, this, &CMainDataGrabber::StartGrab);
|
||||
|
||||
for (ZZ_U8 i = 0; i < m_struDeviceContext.ucDeviceNumber; i++)
|
||||
{
|
||||
connect(this, &CMainDataGrabber::SignalStartGrabOnce, m_pControlThread[i], &CAbstractFSController::StartAcquisition);
|
||||
connect(m_pControlThread[i], &CAbstractFSController::SignalAcqFinished, this, &CMainDataGrabber::HandleThreadEvent);
|
||||
}
|
||||
|
||||
connect(this, &CMainDataGrabber::SignalGrabOnceFinished, this, &CMainDataGrabber::GrabFinished);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMainDataGrabber::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 CMainDataGrabber::StartGrab()
|
||||
{
|
||||
m_iFlagIsCapturing = true;
|
||||
emit SignalStartGrabOnce();
|
||||
while (m_iFlagIsCapturing)
|
||||
{
|
||||
QThread::msleep(1000);
|
||||
}
|
||||
|
||||
m_iFlagIsCapturing = true;
|
||||
InitThreadStatus();
|
||||
emit SignalStartGrabOnce();
|
||||
while (m_iFlagIsCapturing)
|
||||
{
|
||||
QThread::msleep(1000);
|
||||
}
|
||||
qDebug() << "Allgrab stopped" << " Thread ID:" <<2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CMainDataGrabber::GrabFinished()
|
||||
{
|
||||
m_iFlagIsCapturing = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -17,19 +17,28 @@ private:
|
||||
vector<CAbstractFSController *> m_pControlThread;
|
||||
vector<QThread* > m_pqThreadHolder;
|
||||
|
||||
int *m_piFlagCaptureThreadStatus;
|
||||
int m_iTotalThreads;
|
||||
|
||||
int m_iFlagIsCapturing;
|
||||
|
||||
AcqTimeSettings m_struAcqTime;
|
||||
DeviceContext m_struDeviceContext;
|
||||
FSContext m_struDeviceContext;
|
||||
|
||||
public:
|
||||
//Call this first
|
||||
int SetGrabberParams(RunTimeGrabberParams struGrabberRTParams);
|
||||
|
||||
int InitThreadStatus();
|
||||
int InitializeWorkers();
|
||||
int StartWorkers();
|
||||
|
||||
int SetupMsgPipelines();
|
||||
|
||||
public slots:
|
||||
int HandleThreadEvent(int iThreadID, int iFlagStatus);
|
||||
int StartGrab();
|
||||
int GrabFinished();
|
||||
|
||||
signals:
|
||||
void SignalStartGrabOnce();
|
||||
|
Reference in New Issue
Block a user