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:
16
othersoft/movingliner/source/LinearShutter/AbstractPort.h
Normal file
16
othersoft/movingliner/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(int waite=5000) = 0;
|
||||
virtual int Write(const std::string strSend) = 0;
|
||||
|
||||
};
|
||||
|
1416
othersoft/movingliner/source/LinearShutter/VSMD12XControl.cpp
Normal file
1416
othersoft/movingliner/source/LinearShutter/VSMD12XControl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
146
othersoft/movingliner/source/LinearShutter/VSMD12XControl.h
Normal file
146
othersoft/movingliner/source/LinearShutter/VSMD12XControl.h
Normal file
@ -0,0 +1,146 @@
|
||||
#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
|
||||
#define MAXDISTANCE 1265000
|
||||
class /*IRIS_API_CLASS*/ CVSMD12XControl
|
||||
{
|
||||
public:
|
||||
CVSMD12XControl();
|
||||
~CVSMD12XControl();
|
||||
private:
|
||||
int *m_piPositionInPulses;
|
||||
|
||||
CAbstractPort *m_pAbsPort;
|
||||
unValue m_unValue;
|
||||
MSInfo m_stuMSInfo;
|
||||
ControllerParams m_stuControllerParams;
|
||||
int m_iProtocolType;
|
||||
int m_iCID;
|
||||
std::string m_strCID;
|
||||
public:
|
||||
bool m_bIsSyncMove;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//for IRIS Linear Motor - Electric Shutter
|
||||
//Initialize communication setup iPortType(0:RS232 1:RS485) iCID(For RS485 device) bSyncMove(move mode)
|
||||
bool ILMES_InitializeComm(QString portName,int bandrate=9600, int iPortType = 1, int iCID = 1, bool bSyncMove = true);
|
||||
//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:
|
||||
int waitetime;
|
||||
////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 Move_NoSyn(int iRelPulse); // relative move mode,pulse (-2147483647<34><37>2147483647)
|
||||
bool MoveTo_NoSyn(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);
|
||||
};
|
||||
|
108
othersoft/movingliner/source/LinearShutter/VSMD12XMiscDefines.h
Normal file
108
othersoft/movingliner/source/LinearShutter/VSMD12XMiscDefines.h
Normal file
@ -0,0 +1,108 @@
|
||||
#pragma once
|
||||
#include "ZZ_Types.h"
|
||||
#define MAXBUFFER 10240
|
||||
#include<qstring.h>
|
||||
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;
|
||||
QString FullPortName;
|
||||
tagTransportLayerInfomation() {
|
||||
iPortType = 0;
|
||||
indexParity = 0;
|
||||
iPortNumber = 8;
|
||||
iBaudRate = 9600;
|
||||
indexBytesize = 3;
|
||||
indexStopBits = 0;
|
||||
FullPortName = "";
|
||||
}
|
||||
|
||||
//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
|
||||
tagControllerParams() {
|
||||
bdr = 9600;
|
||||
|
||||
cra = 0.8;
|
||||
crh = 0.1;
|
||||
crn = 0.8;
|
||||
|
||||
acc = 100000;
|
||||
dec = 100000;
|
||||
spd = 64000;
|
||||
|
||||
osv = 0;
|
||||
snr = 0;
|
||||
zmd = 3;
|
||||
zsp = 20;
|
||||
zsd = 50000;
|
||||
|
||||
mcs = 6;
|
||||
}
|
||||
}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>ģʽֹͣ
|
||||
};
|
||||
|
147
othersoft/movingliner/source/LinearShutter/ZZ_SeiralPort.cpp
Normal file
147
othersoft/movingliner/source/LinearShutter/ZZ_SeiralPort.cpp
Normal file
@ -0,0 +1,147 @@
|
||||
#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;
|
||||
if (m_piSettings.FullPortName!="")
|
||||
{
|
||||
qstrPortName = m_piSettings.FullPortName;
|
||||
qDebug() << m_piSettings.FullPortName;
|
||||
}
|
||||
else {
|
||||
qstrPortName = QString("COM%1").arg(m_piSettings.iPortNumber);
|
||||
}
|
||||
// qstrPortName = "COM4";
|
||||
// QString qstrPortName = m_piSettings.FullPortName;//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(int waite)
|
||||
{
|
||||
if (!m_pSerialPort->waitForReadyRead(waite))
|
||||
{
|
||||
return "";
|
||||
|
||||
}
|
||||
if (
|
||||
m_pSerialPort->bytesAvailable() == 0
|
||||
)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
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(5000);
|
||||
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();
|
||||
}
|
26
othersoft/movingliner/source/LinearShutter/ZZ_SeiralPort.h
Normal file
26
othersoft/movingliner/source/LinearShutter/ZZ_SeiralPort.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#include "VSMD12XMiscDefines.h"
|
||||
#include "AbstractPort.h"
|
||||
#include"qobject.h"
|
||||
class CZZ_SeiralPort_QT :public CAbstractPort,QObject
|
||||
{
|
||||
|
||||
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(int waittime = 5000);
|
||||
|
||||
virtual int Write(const std::string strSend);
|
||||
|
||||
};
|
||||
|
297
othersoft/movingliner/source/LinearShutter/ZZ_Types.h
Normal file
297
othersoft/movingliner/source/LinearShutter/ZZ_Types.h
Normal file
@ -0,0 +1,297 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//<2F><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ļ<EFBFBD>
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#include <string>
|
||||
#define MAX_DEVICENUMBER_FS 2
|
||||
#define MAX_LINEARSHUTTER_POSITION 12
|
||||
namespace ZZ_MISCDEF
|
||||
{
|
||||
typedef unsigned char ZZ_U8;
|
||||
typedef unsigned short int ZZ_U16;
|
||||
typedef unsigned long int ZZ_U32;
|
||||
|
||||
|
||||
namespace IRIS
|
||||
{
|
||||
//Fiber Spectrometer
|
||||
namespace FS
|
||||
{
|
||||
typedef struct tagDataFrame
|
||||
{
|
||||
ZZ_U16 usExposureTimeInMS;
|
||||
ZZ_U16 usData[4096];
|
||||
float fTemperature;
|
||||
double dTimes = 0;
|
||||
}DataFrame;
|
||||
|
||||
typedef struct tagDeviceInfo
|
||||
{
|
||||
std::string strPN;
|
||||
std::string strSN;
|
||||
}DeviceInfo;
|
||||
|
||||
typedef struct tagDeviceAttribute
|
||||
{
|
||||
int iPixels;
|
||||
int iMaxIntegrationTimeInMS;
|
||||
int iMinIntegrationTimeInMS;
|
||||
float fWaveLengthInNM[4096];
|
||||
|
||||
}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
|
||||
{
|
||||
const int MAX_SPECTRUM_SIZE = 4096;
|
||||
|
||||
const int GET_MODULECIRCUIT_TEMP = 0x01;
|
||||
const int GET_PN_NUMBER = 0x03;
|
||||
const int GET_SN_NUMBER = 0x04;
|
||||
const int GET_MANUFACTURE_DATA = 0x06;
|
||||
const int GET_MANUFACTURE_INFO = 0x09;
|
||||
const int GET_PIXEL_LENGTH = 0x0a;
|
||||
const int GET_TEC_TEMP = 0x13;
|
||||
const int SET_TEC_TEMP = 0x12;
|
||||
const int GET_OPTICS_TEMP = 0x35;
|
||||
const int GET_CIRCUITBOARD_TEMP = 0x36;
|
||||
const int SET_INTEGRATION_TIME = 0x14;
|
||||
const int GET_INTEGRATION_TIME = 0x41;
|
||||
const int GET_MAX_INTEGRATION_TIME = 0x42;
|
||||
const int GET_MIN_INTEGRATION_TIME = 0x43;
|
||||
const int ASYNC_COLLECT_DARK = 0x23;
|
||||
const int ASYNC_START_COLLECTION = 0x16;
|
||||
const int ASYNC_READ_DATA = 0x17;
|
||||
const int SET_AVERAGE_NUMBER = 0x28;
|
||||
const int SYNC_GET_DATA = 0x1e;
|
||||
const int SYNC_GET_DARK = 0x2f;
|
||||
const int EXTERNAL_TRIGGER_ENABLE = 0x1f;
|
||||
const int SET_XENON_LAMP_DELAY_TIME = 0x24;
|
||||
const int GET_WAVELENGTH_CALIBRATION_COEF = 0x55;
|
||||
const int GET_STAT_LAMPOUT = 0x60;
|
||||
const int SET_GPIO = 0x61;
|
||||
//const int SYNCHRONIZATION_GET_DARK = 0x23
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////device
|
||||
enum Model
|
||||
{
|
||||
ATP1010 = 0,
|
||||
ATP6500
|
||||
};
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>
|
||||
typedef struct tagATPDataFrame
|
||||
{
|
||||
unsigned short usExposureTime;
|
||||
ZZ_U16 usData[4096];
|
||||
float fTemperature;
|
||||
double dTimes = 0;
|
||||
}ATPDataFrame;
|
||||
|
||||
//<2F>豸<EFBFBD><E8B1B8>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
||||
typedef struct tagATPDeviceInfo
|
||||
{
|
||||
std::string strPN;
|
||||
std::string strSN;
|
||||
}ATPDeviceInfo;
|
||||
|
||||
//<2F>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
typedef struct tagATPDeviceAttribute
|
||||
{
|
||||
int iPixels;
|
||||
int iMaxIntegrationTime;
|
||||
int iMinIntegrationTime;
|
||||
float fWaveLength[4096];
|
||||
|
||||
}ATPDeviceAttribute;
|
||||
//////////////////////////////////////////////////////////////////////////config file
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD>в<EFBFBD><D0B2><EFBFBD>
|
||||
namespace ZZ_RUNPARAMS
|
||||
{
|
||||
typedef struct tagFiberSpecContext
|
||||
{
|
||||
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
|
||||
{
|
||||
QTime qtStartTime;
|
||||
QTime qtStopTime;
|
||||
QTime qtInterval;
|
||||
}AcqTimeSettings;
|
||||
|
||||
typedef struct tagAcquisitionPositionSettings
|
||||
{
|
||||
int iTotalPosition;
|
||||
int iPosition[MAX_LINEARSHUTTER_POSITION];
|
||||
}AcqPosSettings;
|
||||
|
||||
typedef struct tagRunTimeGrabberParams
|
||||
{
|
||||
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>ṹ
|
||||
namespace ZZ_DATAFILE
|
||||
{
|
||||
typedef struct tagEnvironmentalContext
|
||||
{
|
||||
QString qstrUTCDateTime;
|
||||
QString qstrLocation;
|
||||
QString qstrGPS_Longtitude;
|
||||
QString qstrGPS_Latitude;
|
||||
QString qstrGPS_Altitude;
|
||||
QString qstrGPS_North;
|
||||
QString qstrCaseTemperature;
|
||||
QString qstrCaseHumidity;
|
||||
|
||||
}EContext;
|
||||
|
||||
typedef struct tagManmadeEnviromentalContext
|
||||
{
|
||||
QString qstrOriFileName;
|
||||
QString qstrInstallationTime;
|
||||
QString qstrISIFCalibrationTime;
|
||||
QString qstrIS1CalibrationTime;
|
||||
QString qstrNameOfMaintenanceStaff;
|
||||
QString qstrPhoneNumberOfMaintenanceStaff;
|
||||
QString qstrDownloadUserID;
|
||||
QString qstrDownlaodAddress;
|
||||
QString qstrHTTPServer;
|
||||
}MEContext;
|
||||
|
||||
|
||||
typedef struct tagIS1Information
|
||||
{
|
||||
QString qstrSN_ATP;
|
||||
QString qstrSN_IRIS;
|
||||
|
||||
QString qstrCalFile_U0;
|
||||
QString qstrCalFile_D1;
|
||||
QString qstrCalFile_D2;
|
||||
QString qstrCalFile_D3;
|
||||
|
||||
int iPixelCount;
|
||||
|
||||
int iExposureTimeInMS_U0;
|
||||
int iExposureTimeInMS_D1;
|
||||
int iExposureTimeInMS_D2;
|
||||
int iExposureTimeInMS_D3;
|
||||
|
||||
float fTemperature_U0;
|
||||
float fTemperature_D1;
|
||||
float fTemperature_D2;
|
||||
float fTemperature_D3;
|
||||
}IS1Info;
|
||||
|
||||
typedef struct tagISIFInformation
|
||||
{
|
||||
QString qstrSN_ATP;
|
||||
QString qstrSN_IRIS;
|
||||
|
||||
QString qstrCalFile_U0;
|
||||
QString qstrCalFile_D1;
|
||||
QString qstrCalFile_D2;
|
||||
QString qstrCalFile_D3;
|
||||
|
||||
int iPixelCount;
|
||||
|
||||
int iExposureTimeInMS_U0;
|
||||
int iExposureTimeInMS_D1;
|
||||
int iExposureTimeInMS_D2;
|
||||
int iExposureTimeInMS_D3;
|
||||
|
||||
float fTemperature_U0;
|
||||
float fTemperature_D1;
|
||||
float fTemperature_D2;
|
||||
float fTemperature_D3;
|
||||
}ISIFInfo;
|
||||
|
||||
typedef struct tagATPDataHeader
|
||||
{
|
||||
|
||||
|
||||
}ATPDataHeader;
|
||||
}
|
||||
|
||||
};
|
28
othersoft/movingliner/source/LinearShutter/pch.h
Normal file
28
othersoft/movingliner/source/LinearShutter/pch.h
Normal file
@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
////////////////////////////setings
|
||||
#include <QSettings>
|
||||
#include <QMetaEnum>
|
||||
////////////////////////////Basic
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QObject>
|
||||
////////////////////////////Thread
|
||||
#include <QThread>
|
||||
#include <QMutex>
|
||||
#include <QWaitCondition>
|
||||
////////////////////////////json
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QJsonParseError>
|
||||
////////////////////////////time
|
||||
#include <QtCore/QTime>
|
||||
#include <QDateTime>
|
||||
#include <QTimer>
|
||||
////////////////////////////Serial I/O
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
191
othersoft/movingliner/source/Settings/SystemConfigger.cpp
Normal file
191
othersoft/movingliner/source/Settings/SystemConfigger.cpp
Normal file
@ -0,0 +1,191 @@
|
||||
#include "SystemConfigger.h"
|
||||
|
||||
|
||||
ZZ_SysConfigger::ZZ_SysConfigger(QObject *parent /*= nullptr*/)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
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 (qfJConfig.isOpen())
|
||||
{
|
||||
qfJConfig.close();
|
||||
}
|
||||
}
|
||||
|
||||
int ZZ_SysConfigger::Initialize()
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////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());
|
||||
|
||||
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);
|
||||
if (!bRes)
|
||||
{
|
||||
qDebug() << "QFile open config file Err.";
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_qbaJData = qfJConfig.readAll();
|
||||
m_qjdJDoc= QJsonDocument::fromJson(m_qbaJData, &m_qjpeJErr);
|
||||
if (m_qjpeJErr.error != QJsonParseError::NoError)
|
||||
{
|
||||
qDebug() << m_qjpeJErr.errorString();
|
||||
return 2;
|
||||
}
|
||||
m_qjoJObj = m_qjdJDoc.object();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_SysConfigger::GetGrabberRunParams(RunTimeGrabberParams &struGrabberRTParams)
|
||||
{
|
||||
struGrabberRTParams.atsParams = m_struAcqTime;
|
||||
struGrabberRTParams.fscParams = m_struDeviceContext;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_SysConfigger::LoadSettingsFromFile_IS1()
|
||||
{
|
||||
m_struIS1Info.qstrCalFile_U0 = m_qjoJObj.value("IS1UpCalFile").toString();
|
||||
m_struIS1Info.qstrCalFile_D1 = m_qjoJObj.value("IS1DownCalFile1").toString();
|
||||
m_struIS1Info.qstrCalFile_D2 = m_qjoJObj.value("IS1DownCalFile2").toString();
|
||||
m_struIS1Info.qstrCalFile_D3 = m_qjoJObj.value("IS1DownCalFile3").toString();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_SysConfigger::LoadSettingsFromFile_iSIF()
|
||||
{
|
||||
m_struISIFInfo.qstrCalFile_U0 = m_qjoJObj.value("SIFUpCalFile").toString();
|
||||
m_struISIFInfo.qstrCalFile_D1 = m_qjoJObj.value("SIFDownCalFile1").toString();
|
||||
m_struISIFInfo.qstrCalFile_D2 = m_qjoJObj.value("SIFDownCalFile2").toString();
|
||||
m_struISIFInfo.qstrCalFile_D3 = m_qjoJObj.value("SIFDownCalFile3").toString();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_SysConfigger::LoadSettingsFromFile_System()
|
||||
{
|
||||
// QString qstr = m_qjoJObj.value("IntervalTime").toString();
|
||||
m_struAcqTime.qtStartTime=QTime::fromString(m_qjoJObj.value("BeginTime").toString(), "hh:mm");
|
||||
if (!m_struAcqTime.qtStartTime.isValid())
|
||||
{
|
||||
qDebug() << "Invalid BeginTime";
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
m_struAcqTime.qtInterval = QTime::fromString(m_qjoJObj.value("IntervalTime").toString(), "ss");
|
||||
if (!m_struAcqTime.qtInterval.isValid())
|
||||
{
|
||||
qDebug() << "Invalid IntervalTime";
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
m_struAcqTime.qtInterval = QTime::fromString(m_qjoJObj.value("IntervalTime").toString(), "mm");
|
||||
if (!m_struAcqTime.qtInterval.isValid())
|
||||
{
|
||||
qDebug() << "Invalid IntervalTime";
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_struAcqTime.qtStopTime = QTime::fromString(m_qjoJObj.value("EndTime").toString(), "hh:mm");
|
||||
if (!m_struAcqTime.qtStopTime.isValid())
|
||||
{
|
||||
qDebug() << "Invalid EndTime";
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_SysConfigger::LoadSettingsFromFile_MISC()
|
||||
{
|
||||
m_struEC.qstrLocation = m_qjoJObj.value("Location").toString();
|
||||
m_struEC.qstrGPS_Altitude = m_qjoJObj.value("GPS_Altitude").toString();
|
||||
m_struEC.qstrGPS_Latitude = m_qjoJObj.value("GPS_Latitude").toString();
|
||||
m_struEC.qstrGPS_Longtitude = m_qjoJObj.value("GPS_Longtitude").toString();
|
||||
m_struEC.qstrGPS_North = m_qjoJObj.value("GPS_North").toString();
|
||||
|
||||
m_struMEC.qstrInstallationTime = m_qjoJObj.value("InstallationTime").toString();
|
||||
m_struMEC.qstrISIFCalibrationTime = m_qjoJObj.value("ISIFCalibrationTime").toString();
|
||||
m_struMEC.qstrIS1CalibrationTime = m_qjoJObj.value("IS1CalibrationTime").toString();
|
||||
m_struMEC.qstrNameOfMaintenanceStaff = m_qjoJObj.value("NameOfMaintenanceStaff").toString();
|
||||
m_struMEC.qstrPhoneNumberOfMaintenanceStaff = m_qjoJObj.value("PhoneNumberOfMaintenanceStaff").toString();
|
||||
m_struMEC.qstrDownloadUserID = m_qjoJObj.value("DownloadUserID").toString();
|
||||
m_struMEC.qstrDownlaodAddress = m_qjoJObj.value("DownlaodAddress").toString();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_SysConfigger::LoadSettings_Test()
|
||||
{
|
||||
QFile qfTest(m_qstrJSONConfigFilePath);
|
||||
|
||||
qfTest.open(QFile::ReadOnly);
|
||||
|
||||
QByteArray qbJData = qfTest.readAll();
|
||||
|
||||
QJsonParseError jerr;
|
||||
QJsonDocument jdoc(QJsonDocument::fromJson(qbJData, &jerr));
|
||||
if (jerr.error!= QJsonParseError::NoError)
|
||||
{
|
||||
qDebug() << jerr.errorString();
|
||||
}
|
||||
|
||||
QJsonObject rootobj = jdoc.object();
|
||||
QStringList key = rootobj.keys();
|
||||
QString qtest1 = rootobj.value(rootobj.keys().at(15)).toString();
|
||||
return 0;
|
||||
}
|
57
othersoft/movingliner/source/Settings/SystemConfigger.h
Normal file
57
othersoft/movingliner/source/Settings/SystemConfigger.h
Normal file
@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#include "ZZ_Types.h"
|
||||
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||
using namespace ZZ_MISCDEF::ZZ_DATAFILE;
|
||||
|
||||
class ZZ_SysConfigger :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ZZ_SysConfigger(QObject *parent = nullptr);
|
||||
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:
|
||||
enum ConfiggerDeviceModel
|
||||
{
|
||||
OSIFAlpha = 0,
|
||||
OSIFBeta,
|
||||
ISIF,
|
||||
IS1,
|
||||
IS2,
|
||||
Null
|
||||
};
|
||||
Q_ENUM(ConfiggerDeviceModel);
|
||||
//////////////////////////////////////////////////////////////////////////run-time settings
|
||||
AcqTimeSettings m_struAcqTime;
|
||||
FSContext m_struDeviceContext;
|
||||
AcqPosSettings m_struAcqPosition;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
EContext m_struEC;
|
||||
MEContext m_struMEC;
|
||||
IS1Info m_struIS1Info;
|
||||
ISIFInfo m_struISIFInfo;
|
||||
|
||||
private:
|
||||
QString m_qstrDeviceConfigFilePath;
|
||||
QString m_qstrJSONConfigFilePath;
|
||||
QFile qfJConfig/*,qfDeviceConfig*/;
|
||||
QSettings *m_qsDeviceConfig;
|
||||
|
||||
QByteArray m_qbaJData;
|
||||
QJsonParseError m_qjpeJErr;
|
||||
QJsonObject m_qjoJObj;
|
||||
QJsonDocument m_qjdJDoc;
|
||||
|
||||
|
||||
|
||||
};
|
Reference in New Issue
Block a user