diff --git a/html/config/calibrate.php b/html/config/calibrate.php
new file mode 100644
index 0000000..d9edfc3
--- /dev/null
+++ b/html/config/calibrate.php
@@ -0,0 +1,45 @@
+";
+//$cmd = 'ping 127.0.0.1';
+
+system("sudo pkill ocean_optics_calibration_console");
+system("sudo gpio write 1 1");
+$cmd="";
+
+
+
+
+if ($a==1)
+{
+ $cmd = 'sudo /home/pi/bin/ocean_optics_calibration_console -t 30 -slfs ocean_optics.lmp --cfon FSNsdfsd'.$a.'.data -p '.$a;
+}
+else
+{
+ $cmd = 'sudo /home/pi/bin/ocean_optics_calibration_console -t 30 -slfs 4000nit.dat --cfon FSNsdfsd'.$a.'.data -p '.$a;
+}
+
+
+
+
+while(@ ob_end_flush());
+
+$proc = popen($cmd, 'r');
+
+
+while(!feof($proc)){
+ echo fread($proc, 4096);
+ @ flush();
+}
+echo 'FINISH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!';
+echo '回到首页';
\ No newline at end of file
diff --git a/html/config/location.php b/html/config/location.php
new file mode 100644
index 0000000..4dd8476
--- /dev/null
+++ b/html/config/location.php
@@ -0,0 +1,48 @@
+定标
';
+echo '回到首页';
+
+/*
+$i = 100;
+while ($i<1000) {
+ ++$i;
+ //部分浏览器需要内容达到一定长度了才输出
+ if ($i === 103) {
+ echo"hello word".$i."
";;
+ } else {
+ echo"hello word".$i."
";;
+ }
+ sleep(1);
+
+}
+*/
diff --git a/html/config/position.html b/html/config/position.html
new file mode 100644
index 0000000..c13621f
--- /dev/null
+++ b/html/config/position.html
@@ -0,0 +1,15 @@
+
+
+
+
+ Title
+
+
+位置1
+位置2
+位置3
+位置4
+位置5
+位置try
+
+
\ No newline at end of file
diff --git a/othersoft/install.sh b/othersoft/install.sh
new file mode 100644
index 0000000..d205631
--- /dev/null
+++ b/othersoft/install.sh
@@ -0,0 +1,15 @@
+mkdir build
+cd build
+mkdir movingliner
+cd movingliner
+cmake ../../movingliner
+make -j4
+mkdir /home/pi/bin
+cp ./movingliner /home/pi/bin
+echo beging build shuttercali
+cd ../
+mkdir shuttercali
+cd shuttercali
+cmake ../../shuttercali
+make -j4
+cp ./shuttercali /home/pi/bin
diff --git a/othersoft/movingliner/CMakeLists.txt b/othersoft/movingliner/CMakeLists.txt
new file mode 100644
index 0000000..afdac17
--- /dev/null
+++ b/othersoft/movingliner/CMakeLists.txt
@@ -0,0 +1,32 @@
+cmake_minimum_required(VERSION 3.0)
+project(movingliner)
+IF (WIN32)
+
+ #MESSAGE(STATUS "Now is windows")
+
+ENDIF ()
+set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} C:/Qt/Qt5.12.7/5.12.7/mingw73_64)
+#set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} C:/Qt/Qt5.9.0/5.9/msvc2017_64/ )
+set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+set(CMAKE_AUTOUIC ON)
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+set(QT Core Gui Network WebSockets SerialPort Widgets)
+
+find_package(Qt5 REQUIRED ${QT})
+include_directories("source/LinearShutter")
+add_executable(movingliner
+ main.cpp
+ source/LinearShutter/VSMD12XControl.cpp
+ source/LinearShutter/VSMD12XControl.h
+ source/LinearShutter/ZZ_SeiralPort.cpp
+ source/LinearShutter/ZZ_SeiralPort.h
+
+ )
+qt5_use_modules(movingliner ${QT})
+
+
+
+
+
diff --git a/othersoft/movingliner/DeviceSettings.ini b/othersoft/movingliner/DeviceSettings.ini
new file mode 100644
index 0000000..2f87a5b
--- /dev/null
+++ b/othersoft/movingliner/DeviceSettings.ini
@@ -0,0 +1,27 @@
+[DEVICE INFO]
+TotalSpectrometer=1
+[FS2]
+Model=ISIF
+Port=/dev/ttyS1
+UID=QEP02975
+[FS1]
+Model=OSIFAlpha
+Port=-1
+UID=QEP02975
+AEMax=0.85
+AEMin=0.80
+Depth=200000
+[FS3]
+Model=Null
+[LINEAR SHUTTER]
+Port=COM12
+Type=1
+DCID=1
+TotalPosition=5
+Position0=10000
+Position1=91947
+Position2=219299
+Position3=347535
+Position4=474904
+[HUMITURE]
+Port=/dev/ttyUSB3
\ No newline at end of file
diff --git a/othersoft/movingliner/main.cpp b/othersoft/movingliner/main.cpp
new file mode 100644
index 0000000..279f59b
--- /dev/null
+++ b/othersoft/movingliner/main.cpp
@@ -0,0 +1,52 @@
+#include
+#include
+#include
+#include "qtextstream.h"
+QTextStream cout1(stdout, QIODevice::WriteOnly);
+void logout(QString str){
+ std::cout<";
+ std::fflush(stdout);
+}
+int main(int argc, char *argv[]) {
+ int aaa=1000;
+ QString str(argv[1]);
+ QCoreApplication a(argc, argv);
+ CVSMD12XControl Motercontrol;
+ QString m_qstrDeviceConfigFilePath;
+ // cout1<<"adfasdfsadfsd"<"<value("LINEAR SHUTTER/Position"+str).toLongLong();
+ if (positon==0)
+ {
+ logout("Can not Find the position<\/b>");
+ return 0;
+ }
+ cout1<<"Find Configfile in "< The Port of Motor is "<value("LINEAR SHUTTER/Port").toString()<<"
"<value("LINEAR SHUTTER/Position"+str).toLongLong()<<"
"<"<value("LINEAR SHUTTER/Port").toString()
+ Motercontrol.ILMES_InitializeComm(m_qsDeviceConfig->value("LINEAR SHUTTER/Port").toString());
+ ControllerParams cpTest;
+ Motercontrol.ILMES_InitializeParams(cpTest);
+
+
+
+
+ logout("Moving to Zero");
+ Motercontrol.StartBackZero();
+ //std::cout<<"beging to move position";
+ logout("Moving to The Position");
+ Motercontrol.MoveTo(positon);
+
+ logout("Finish the Task!!!<\/b>
Thanks For Using<\/b>");
+ return 0;
+ // return QCoreApplication::exec();
+}
diff --git a/othersoft/movingliner/source/LinearShutter/AbstractPort.h b/othersoft/movingliner/source/LinearShutter/AbstractPort.h
new file mode 100644
index 0000000..0c0118b
--- /dev/null
+++ b/othersoft/movingliner/source/LinearShutter/AbstractPort.h
@@ -0,0 +1,16 @@
+#pragma once
+#include "VSMD12XMiscDefines.h"
+#include
+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;
+
+};
+
diff --git a/othersoft/movingliner/source/LinearShutter/VSMD12XControl.cpp b/othersoft/movingliner/source/LinearShutter/VSMD12XControl.cpp
new file mode 100644
index 0000000..520e487
--- /dev/null
+++ b/othersoft/movingliner/source/LinearShutter/VSMD12XControl.cpp
@@ -0,0 +1,1416 @@
+#include "pch.h"
+#include "VSMD12XControl.h"
+#include "ZZ_SeiralPort.h"
+#include
+#define sprintf_s snprintf
+CVSMD12XControl::CVSMD12XControl()
+{
+ m_iProtocolType = 0;
+ m_iCID = 1;
+ m_bIsSyncMove = 0;
+ m_piPositionInPulses = NULL;
+ waitetime = 200;
+ waitetime = 200;
+}
+
+CVSMD12XControl::~CVSMD12XControl()
+{
+ if (m_piPositionInPulses!=NULL)
+ {
+ delete[] m_piPositionInPulses;
+ }
+}
+
+bool CVSMD12XControl::ILMES_InitializeComm(PortInfo portinfo, int iPortType /*= 1*/, int iCID /*= 1*/, bool bSyncMove /*= true*/)
+{
+ SetProtocolType(iPortType);
+ SetCID(iCID);
+ SetSyncMode(bSyncMove);
+
+ return InitAndOpenPort(portinfo);
+}
+bool CVSMD12XControl::ILMES_InitializeComm(QString portName, int bandrate, int iPortType , int iCID , bool bSyncMove )
+{
+ PortInfo pi;
+ pi.FullPortName = portName;
+
+ pi.iBaudRate = bandrate;
+ return ILMES_InitializeComm(pi, iPortType, iCID, bSyncMove);
+
+
+}
+
+bool CVSMD12XControl::ILMES_InitializeParams(ControllerParams cpParams)
+{
+ bool bRes = false;
+
+ bRes = CVSMD12XControl::SetBaudRate(cpParams.bdr);
+ if (!bRes)
+ {
+ qDebug() << "SetBaudRate Err";
+ //return false;
+ }
+
+ bRes = CVSMD12XControl::SetSpeed(cpParams.spd,cpParams.acc,cpParams.dec);
+ if (!bRes)
+ {
+ qDebug() << "SetSpeed Err";
+ //return false;
+ }
+
+ bRes = CVSMD12XControl::SetMicroSteps(cpParams.mcs);
+ if (!bRes)
+ {
+ qDebug() << "SetMicroSteps Err";
+ //return false;
+ }
+
+ bRes = CVSMD12XControl::SetCurrent(cpParams.cra,cpParams.crn,cpParams.crh);
+ if (!bRes)
+ {
+ qDebug() << "SetCurrent Err";
+ //return false;
+ }
+
+ bRes = CVSMD12XControl::SetZeroParams(cpParams.zmd,cpParams.osv, cpParams.snr,cpParams.zsd,cpParams.zsp);
+ if (!bRes)
+ {
+ qDebug() << "SetZeroParams Err";
+ //return false;
+ }
+ return bRes;
+}
+
+void CVSMD12XControl::ILMES_SetPosition(int *piPositionInPulse, size_t szSize)
+{
+ m_piPositionInPulses = new int[szSize];
+ for (size_t i=0;i< szSize;i++)
+ {
+ m_piPositionInPulses[i] = piPositionInPulse[i];
+ }
+}
+
+bool CVSMD12XControl::ILMES_MoveToPos(int iPositionIndex)
+{
+ bool bRes = false;
+ bRes = CVSMD12XControl::StartBackZero();
+ if (!bRes)
+ {
+ qDebug() << "StartBackZero Err";
+ return false;
+ }
+
+ bRes = CVSMD12XControl::MoveTo(m_piPositionInPulses[iPositionIndex]);
+ if (!bRes)
+ {
+ qDebug() << "MoveTo Err";
+ return false;
+ }
+
+ return bRes;
+}
+
+void CVSMD12XControl::SetProtocolType(int iProtocolType /*= 0*/)
+{
+ m_iProtocolType = iProtocolType;
+}
+
+void CVSMD12XControl::SetCID(int iID)
+{
+ m_iCID = iID;
+
+ char cmd[64];
+ sprintf_s(cmd, 64, "%d ", iID);
+ std::string strCID(cmd);
+ m_strCID = strCID;
+ return;
+}
+
+void CVSMD12XControl::SetSyncMode(bool bSyncMove /*= false*/)
+{
+ m_bIsSyncMove = bSyncMove;
+}
+
+bool CVSMD12XControl::InitAndOpenPort(PortInfo portinfo)
+{
+ bool bRes = false;
+ if (portinfo.iPortType==0)
+ {
+ m_pAbsPort = new CZZ_SeiralPort_QT;
+ }
+
+ m_pAbsPort->InitPort(portinfo);
+
+ bRes = m_pAbsPort->SetPort();
+ if (!bRes)
+ {
+ return bRes;
+ }
+ bRes = m_pAbsPort->Open();
+ return bRes;
+}
+
+std::string CVSMD12XControl::ReadReceive()
+{
+ return m_pAbsPort->ReadAll();
+}
+
+int CVSMD12XControl::SendCommand(const std::string strSend)
+{
+ return m_pAbsPort->Write(strSend);
+}
+
+bool CVSMD12XControl::InitController()
+{
+// std::string strTest = "this is a test message.";
+//
+// char *pcTest = new char[strTest.length()];
+// strTest.copy(pcTest, strTest.length(),0);
+//
+// memcpy(pcTest, strTest.c_str(), 23);
+//
+// char *pcTest1 = (char*)strTest.c_str();
+// std::string test=m_pAbsPort->ReadAll();
+ std::string strCMD = "dev\n";
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+ int iRet=m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+ std::string strRecv = m_pAbsPort->ReadAll();
+ ParseReturnedString(strRecv, 0);
+ std::string::size_type szPosition;
+ szPosition = strRecv.find("VSMD", 0);
+ if (szPosition != strRecv.npos)
+ {
+ return true;
+ }
+ return false;
+}
+
+bool CVSMD12XControl::GetStatus(MSInfo &stuMotorParam)
+{
+ std::string strCMD = "cts\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+
+ //QThread::msleep(200);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ ParseReturnedParam(strRecv);
+
+ stuMotorParam = m_stuMSInfo;
+ return true;
+}
+
+bool CVSMD12XControl::Move(int iRelPulse)
+{
+ using namespace ZZ_MISCDEF;
+ char cmd[64];
+ sprintf_s(cmd, 64, "rmv %d\n", iRelPulse);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+ QThread::msleep(200);
+ m_pAbsPort->ReadAll();
+ if (m_bIsSyncMove)
+ {
+ if (iRet != 0)
+ {
+ return false;
+ }
+
+ bool bFlagIsStopped=false;
+ while (!bFlagIsStopped)
+ {
+ QThread::msleep(200);
+ GetStatus(m_stuMSInfo);
+ ZZ_U8 ucFlag = m_stuMSInfo.uiFlags & 0x000000FF;
+ ucFlag = ucFlag & 0x10;
+ if (ucFlag==0x10 && m_stuMSInfo.fVelocity==0)
+ {
+ bFlagIsStopped = true;
+ }
+ }
+ return true;
+ }
+ else
+ {
+ if (iRet == 0)
+ {
+ return true;
+ }
+ return false;
+ }
+
+}
+
+bool CVSMD12XControl::Enable()
+{
+ std::string strCMD = "ena\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(200);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+bool CVSMD12XControl::Disable()
+{
+ std::string strCMD = "off\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(200);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+
+}
+
+bool CVSMD12XControl::MoveTo(int iAbsPulse)
+{
+ if (iAbsPulse > MAXDISTANCE)
+ {
+ //return false;
+ iAbsPulse = MAXDISTANCE;
+ }
+
+ char cmd[64];
+ sprintf_s(cmd, 64, "pos %d\n", iAbsPulse);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+
+ int iRet = m_pAbsPort->Write(strCMD);
+ if (waitetime!=0)
+ {
+ QThread::msleep(200);
+ }
+
+
+ m_pAbsPort->ReadAll();
+
+ if (m_bIsSyncMove)
+ {
+ if (iRet != 0)
+ {
+ return false;
+ }
+
+ bool bFlagIsStopped = false;
+ while (!bFlagIsStopped)
+ {
+ QThread::msleep(200);
+ GetStatus(m_stuMSInfo);
+ ZZ_U8 ucFlag = m_stuMSInfo.uiFlags & 0x000000FF;
+ ucFlag = ucFlag & 0x10;
+ if (ucFlag == 0x10 && m_stuMSInfo.fVelocity == 0)
+ {
+ bFlagIsStopped = true;
+ }
+ }
+ return true;
+ }
+ else
+ {
+ if (iRet == 0)
+ {
+ return true;
+ }
+ return false;
+ }
+// if (iRet == 0)
+// {
+// return true;
+// }
+// return false;
+// std::string strTest;
+// strTest.resize(7);
+// char test[7];
+// //memcpy(test, strCMD.c_str(), 7);
+// for (size_t i = 0; i < 7; i++)
+// {
+// strTest[i] = cmd[i];
+// }
+}
+
+bool CVSMD12XControl::Move_NoSyn(int iRelPulse)
+{
+ bool a;
+ waitetime = 0;
+ m_bIsSyncMove = false;
+ a = Move(iRelPulse);
+ m_bIsSyncMove = true;
+ waitetime = 200;
+ return a;
+
+}
+
+bool CVSMD12XControl::MoveTo_NoSyn(int iAbsPulse)
+{
+ bool a;
+ waitetime = 0;
+ m_bIsSyncMove = false;
+ a = MoveTo(iAbsPulse);
+ m_bIsSyncMove = true;
+ waitetime =200;
+ return a;
+}
+
+bool CVSMD12XControl::SetLogicZero()
+{
+ std::string strCMD = "org\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(200);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+bool CVSMD12XControl::StartBackZero()
+{
+ std::string strCMD = "zero start\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(200);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+
+ if (!ParseReturnedString(strRecv, -1))
+ {
+ return false;
+ }
+
+ bool bFlagIsStopped = false;
+ while (!bFlagIsStopped)
+ {
+ QThread::msleep(200);
+ GetStatus(m_stuMSInfo);
+ ZZ_U8 ucFlag = m_stuMSInfo.uiFlags & 0x000000FF;
+ ucFlag = ucFlag & 0x10;
+ if (ucFlag == 0x10 && m_stuMSInfo.fVelocity == 0)
+ {
+ bFlagIsStopped = true;
+ }
+ }
+ return true;
+// return ParseReturnedString(strRecv, -1);
+
+}
+
+bool CVSMD12XControl::StopBackZero()
+{
+ std::string strCMD = "zero stop\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(200);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+bool CVSMD12XControl::SetBaudRate(int iBaudRate)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg bdr=%d\n", iBaudRate);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+int CVSMD12XControl::GetBaudRate()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes= ParseReturnedParam(strRecv);
+ if (bRes=false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.bdr;
+ }
+}
+
+bool CVSMD12XControl::SetMicroSteps(int iMicroSteps)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg mcs=%d\n", iMicroSteps);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+int CVSMD12XControl::GetMicroSteps()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.mcs;
+ }
+}
+
+bool CVSMD12XControl::SetAccSpeed(float fAccSpd)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg acc=%f\n", fAccSpd);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+float CVSMD12XControl::GetAccSpeed()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.acc;
+ }
+}
+
+bool CVSMD12XControl::SetRunSpeed(float fRunSpeed)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg spd=%f\n", fRunSpeed);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+float CVSMD12XControl::GetRunSpeed()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.spd;
+ }
+}
+
+bool CVSMD12XControl::SetDecSpeed(float fDecSpeed)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg dec=%f\n", fDecSpeed);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+float CVSMD12XControl::GetDecSpeed()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.dec;
+ }
+}
+
+bool CVSMD12XControl::SetSpeed(float fRunSpeed, float fAccSpd, float fDecSpeed)
+{
+ char cmd[128];
+ sprintf_s(cmd, 128, "cfg spd=%f acc=%f dec=%f\n", fRunSpeed, fAccSpd, fDecSpeed);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+bool CVSMD12XControl::SetHoldCurrent(float fHoldCurrent)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg crh=%f\n", fHoldCurrent);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+float CVSMD12XControl::GetHoldCurrent()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.crh;
+ }
+}
+
+bool CVSMD12XControl::SetAccCurrent(float fAccCurrent)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg cra=%f\n", fAccCurrent);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+float CVSMD12XControl::GetAccCurrent()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.cra;
+ }
+}
+
+bool CVSMD12XControl::SetRunCurrent(float fRunCurrent)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg crn=%f\n", fRunCurrent);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+float CVSMD12XControl::GetRunCurrent()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.crn;
+ }
+}
+
+bool CVSMD12XControl::SetCurrent(float fAccCurrent, float fRunCurrent, float fHoldCurrent)
+{
+ char cmd[128];
+ sprintf_s(cmd, 128, "cfg cra=%f crn=%f crh=%f\n", fAccCurrent, fRunCurrent, fHoldCurrent);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+bool CVSMD12XControl::SetS1FETE(ZZ_U8 bS1FETE)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg s1f=%d\n", bS1FETE);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+ZZ_U8 CVSMD12XControl::GetS1FETE()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.s1f;
+ }
+}
+
+bool CVSMD12XControl::SetS1RETE(ZZ_U8 bS1RETE)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg s1r=%d\n", bS1RETE);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+ZZ_U8 CVSMD12XControl::GetS1RETE()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.s1r;
+ }
+}
+
+bool CVSMD12XControl::SetS2FETE(ZZ_U8 bS2FETE)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg s2f=%d\n", bS2FETE);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+ZZ_U8 CVSMD12XControl::GetS2FETE()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.s2f;
+ }
+}
+
+bool CVSMD12XControl::SetS2RETE(ZZ_U8 bS2RETE)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg s2r=%d\n", bS2RETE);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+ZZ_U8 CVSMD12XControl::GetS2RETE()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.s2r;
+ }
+}
+
+bool CVSMD12XControl::SetZeroParams(ZZ_U8 bZeroMode, ZZ_U8 bSwitchOpenVL, ZZ_U8 bZeroSensor, float fZeroVelocity, int iSafePosition)
+{
+ char cmd[128];
+ sprintf_s(cmd, 128, "cfg zmd=%d osv=%d snr=%d zsd=%f zsp=%d\n",
+ (int)bZeroMode, (int)bSwitchOpenVL, (int)bZeroSensor, fZeroVelocity, iSafePosition);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(800);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+
+ return ParseReturnedString(strRecv, -1);
+}
+
+ZZ_U8 CVSMD12XControl::GetZeroMode()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.zmd;
+ }
+}
+
+ZZ_U8 CVSMD12XControl::GetSwitchOpenVoltageLevel()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.osv;
+ }
+}
+
+ZZ_U8 CVSMD12XControl::GetZeroSensor()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.snr;
+ }
+}
+
+int CVSMD12XControl::GetSafePosition()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.zsp;
+ }
+}
+
+float CVSMD12XControl::GetZeroVelocity()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.zsp;
+ }
+}
+
+bool CVSMD12XControl::ParseReturnedString(std::string &strRecv, int iType)
+{
+ char cHead =(char) 0xFF;
+ if (iType == -1)
+ {
+ if (strRecv[0]== cHead)
+ {
+ return true;
+ }
+ return false;
+ }
+ else if (iType == 0)
+ {
+ if (strRecv.size()<3)
+ {
+ return false;
+ }
+ strRecv.erase(0, 3);
+ strRecv.erase(strRecv.size() - 3, 3);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+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 ii = 0;
+ while (strRecv.size() < 2)
+ {
+
+ std::string strRecv1 = m_pAbsPort->ReadAll(20);
+ if (strRecv1.size() == 0)
+ {
+ return false;
+
+ }
+ strRecv = strRecv + strRecv1;
+ ii++;
+ if (ii == 2)
+ {
+ return false;
+
+ }
+ }
+ if (strRecv[2]==0x2)
+ {
+ //strRecv.erase(0, 3);
+ //strRecv.erase(strRecv.size() - 3, 3);
+ int i = 0;
+ int izero = 0;
+ while (strRecv.size() != 21)
+ {
+ std::string strRecv1 = "";
+ strRecv1 = m_pAbsPort->ReadAll(20);
+ if (strRecv1.size()==0)
+ {
+ return false;
+
+ }
+ strRecv = strRecv + strRecv1;
+ i++;
+ if (i==5)
+ {
+ return false;
+
+ }
+ if (strRecv.size() > 21)
+ {
+ return false;
+ }
+ //return false;
+ }
+ ZZ_U8 *pbRecv = (ZZ_U8*)strRecv.c_str();
+
+ VSMD_BitShift(&pbRecv[3], &m_unValue);
+ m_stuMSInfo.fVelocity = m_unValue.fValue;
+ VSMD_BitShift(&pbRecv[8], &m_unValue);
+ m_stuMSInfo.iPosition = m_unValue.i32Value;
+ VSMD_BitShift(&pbRecv[13], &m_unValue);
+ m_stuMSInfo.uiFlags = m_unValue.u32Value;
+
+ //delete pbRecv;
+ return true;
+ }
+ else if (strRecv[2] == 0x3)
+ {
+ strRecv[strRecv.size() - 3] = 0;
+ char* pcParam = ((char*)strRecv.c_str())+3;
+
+ while (pcParam)
+ {
+ char* pcNext = VSMD_Split(pcParam, ' ');
+ char* pcValueStr = VSMD_Split(pcParam, '=');
+
+ //
+ if (pcValueStr)
+ {
+ if (strcmp(pcParam, "bdr") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.bdr = iValue;
+ }
+ else if (strcmp(pcParam, "mcs") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.mcs = iValue;
+ }
+ else if (strcmp(pcParam, "spd") == 0)
+ {
+ float fValue = (float)atof(pcValueStr);
+ m_stuControllerParams.spd = fValue;
+ }
+ else if (strcmp(pcParam, "acc") == 0)
+ {
+ float fValue = (float)atof(pcValueStr);
+ m_stuControllerParams.acc = fValue;
+ }
+ else if (strcmp(pcParam, "dec") == 0)
+ {
+ float fValue = (float)atof(pcValueStr);
+ m_stuControllerParams.dec = fValue;
+ }
+ else if (strcmp(pcParam, "cra") == 0)
+ {
+ float fValue = (float)atof(pcValueStr);
+ m_stuControllerParams.cra = fValue;
+ }
+ else if (strcmp(pcParam, "crn") == 0)
+ {
+ float fValue = (float)atof(pcValueStr);
+ m_stuControllerParams.crn = fValue;
+ }
+ else if (strcmp(pcParam, "crh") == 0)
+ {
+ float fValue = (float)atof(pcValueStr);
+ m_stuControllerParams.crh = fValue;
+ }
+ else if (strcmp(pcParam, "s1f") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.s1f = iValue;
+ }
+ else if (strcmp(pcParam, "s1r") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.s1r = iValue;
+ }
+ else if (strcmp(pcParam, "s2f") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.s2f = iValue;
+ }
+ else if (strcmp(pcParam, "s2r") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.s2r = iValue;
+ }
+ else if (strcmp(pcParam, "zmd") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.zmd = iValue;
+ }
+ else if (strcmp(pcParam, "osv") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.osv = iValue;
+ }
+ else if (strcmp(pcParam, "snr") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.snr = iValue;
+ }
+ else if (strcmp(pcParam, "zsd") == 0)
+ {
+ float fValue = (float)atof(pcValueStr);
+ m_stuControllerParams.zsd = fValue;
+ }
+ else if (strcmp(pcParam, "zsp") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.zsp = iValue;
+ }
+
+ }
+ pcParam = pcNext;
+ }
+ return true;
+ }
+
+ return false;
+}
+
+void CVSMD12XControl::VSMD_BitShift(ZZ_U8* src, unValue* dst)
+{
+ if (src)
+ {
+ dst->u32Value = src[0];
+
+ dst->u32Value <<= 7;
+ dst->u32Value |= src[1];
+
+ dst->u32Value <<= 7;
+ dst->u32Value |= src[2];
+
+ dst->u32Value <<= 7;
+ dst->u32Value |= src[3];
+
+ dst->u32Value <<= 7;
+ dst->u32Value |= src[4];
+ }
+}
+
+char* CVSMD12XControl::VSMD_Split(char* cStr, char cSplit)
+{
+ if (cStr)
+ {
+ for (char* cPtr = cStr; *cPtr; cPtr++)
+ {
+ if (*cPtr == cSplit)
+ {
+ *cPtr = '\0';
+ cPtr++;
+ return cPtr;
+ }
+ }
+ }
+
+ return NULL;
+}
+
+// int CVSMD12XControl::add(int a, int b)
+// {
+// return a + b;
+// }
diff --git a/othersoft/movingliner/source/LinearShutter/VSMD12XControl.h b/othersoft/movingliner/source/LinearShutter/VSMD12XControl.h
new file mode 100644
index 0000000..46e6a5f
--- /dev/null
+++ b/othersoft/movingliner/source/LinearShutter/VSMD12XControl.h
@@ -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 (-21474836472147483647)
+ bool MoveTo(int iAbsPulse);//absolute mode,pulse (-21474836472147483647)
+ bool Move_NoSyn(int iRelPulse); // relative move mode,pulse (-21474836472147483647)
+ bool MoveTo_NoSyn(int iAbsPulse);//absolute mode,pulse (-21474836472147483647)
+ 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 921600)
+ int GetBaudRate(); // -1:should retry;
+
+ bool SetMicroSteps(int iMicroSteps);//set micro steps (05)->(1/2/4/8/16/32)
+ int GetMicroSteps();
+
+ bool SetAccSpeed(float fAccSpd);//set acceleration speed in pulse (0 192000000)
+ float GetAccSpeed();
+
+ bool SetRunSpeed(float fRunSpeed);//set normal running speed in pulse (0 192000000)
+ float GetRunSpeed();
+
+ bool SetDecSpeed(float fDecSpeed);//set deceleration speed in pulse (0 192000000)
+ float GetDecSpeed();
+
+ bool SetSpeed(float fRunSpeed, float fAccSpd, float fDecSpeed);//see above three functions
+
+ bool SetHoldCurrent(float fHoldCurrent);//set hold current ( 0 8.0 )Amp? pay attention to your motor specification.
+ float GetHoldCurrent();
+
+ bool SetAccCurrent(float fAccCurrent);//set acceleration current ( 0 8.0 )Amp? pay attention to your motor specification.
+ float GetAccCurrent();
+
+ bool SetRunCurrent(float fRunCurrent);//set normal running current ( 0 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 -192000) 192000pulse)(SafePosition -2147483647) 2147483647)
+ 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);
+};
+
diff --git a/othersoft/movingliner/source/LinearShutter/VSMD12XMiscDefines.h b/othersoft/movingliner/source/LinearShutter/VSMD12XMiscDefines.h
new file mode 100644
index 0000000..6de39a7
--- /dev/null
+++ b/othersoft/movingliner/source/LinearShutter/VSMD12XMiscDefines.h
@@ -0,0 +1,108 @@
+#pragma once
+#include "ZZ_Types.h"
+#define MAXBUFFER 10240
+#include
+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, //������ֻ��״̬λ S1 �仯֪ͨ��
+ ResetZeroPosition, //��������ԭ��λ��
+ DecSpdStop, //����ֹͣ
+ DecSpdStopRZP, //����ֹͣ������ֹͣ����������ԭ��λ��
+ Stop, //����ֹͣ
+ StopRZP, //����ֹͣ������ֹͣ����������ԭ��λ��
+ RunningPosDirect, //����������ת�����ٶȣ�
+ RunningNegDirect, //����������ת�����ٶȣ�
+ OfflineModeOn, //����ģʽ����
+ OfflineModeOff //����ģʽֹͣ
+};
+
diff --git a/othersoft/movingliner/source/LinearShutter/ZZ_SeiralPort.cpp b/othersoft/movingliner/source/LinearShutter/ZZ_SeiralPort.cpp
new file mode 100644
index 0000000..d5767ad
--- /dev/null
+++ b/othersoft/movingliner/source/LinearShutter/ZZ_SeiralPort.cpp
@@ -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;iwrite(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();
+}
diff --git a/othersoft/movingliner/source/LinearShutter/ZZ_SeiralPort.h b/othersoft/movingliner/source/LinearShutter/ZZ_SeiralPort.h
new file mode 100644
index 0000000..5d7d0f4
--- /dev/null
+++ b/othersoft/movingliner/source/LinearShutter/ZZ_SeiralPort.h
@@ -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);
+
+};
+
diff --git a/othersoft/movingliner/source/LinearShutter/ZZ_Types.h b/othersoft/movingliner/source/LinearShutter/ZZ_Types.h
new file mode 100644
index 0000000..7ad1c54
--- /dev/null
+++ b/othersoft/movingliner/source/LinearShutter/ZZ_Types.h
@@ -0,0 +1,297 @@
+//////////////////////////////////////////////////////////////////////////
+//˵ļ
+//////////////////////////////////////////////////////////////////////////
+#pragma once
+#include "pch.h"
+#include
+#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ָת
+ 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
+ };
+
+ //֡
+ typedef struct tagATPDataFrame
+ {
+ unsigned short usExposureTime;
+ ZZ_U16 usData[4096];
+ float fTemperature;
+ double dTimes = 0;
+ }ATPDataFrame;
+
+ //豸Ϣ
+ typedef struct tagATPDeviceInfo
+ {
+ std::string strPN;
+ std::string strSN;
+ }ATPDeviceInfo;
+
+ //豸
+ typedef struct tagATPDeviceAttribute
+ {
+ int iPixels;
+ int iMaxIntegrationTime;
+ int iMinIntegrationTime;
+ float fWaveLength[4096];
+
+ }ATPDeviceAttribute;
+ //////////////////////////////////////////////////////////////////////////config file
+
+
+
+ }
+
+ //в
+ 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;
+ }
+
+ //ϵͳļṹ
+ 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;
+ }
+
+};
diff --git a/othersoft/movingliner/source/LinearShutter/pch.h b/othersoft/movingliner/source/LinearShutter/pch.h
new file mode 100644
index 0000000..d5ac3af
--- /dev/null
+++ b/othersoft/movingliner/source/LinearShutter/pch.h
@@ -0,0 +1,28 @@
+#pragma once
+#include
+////////////////////////////setings
+#include
+#include
+////////////////////////////Basic
+#include
+#include
+#include
+#include
+#include
+////////////////////////////Thread
+#include
+#include
+#include
+////////////////////////////json
+#include
+#include
+#include
+#include
+#include
+////////////////////////////time
+#include
+#include
+#include
+////////////////////////////Serial I/O
+#include
+#include
\ No newline at end of file
diff --git a/othersoft/movingliner/source/Settings/SystemConfigger.cpp b/othersoft/movingliner/source/Settings/SystemConfigger.cpp
new file mode 100644
index 0000000..46e8800
--- /dev/null
+++ b/othersoft/movingliner/source/Settings/SystemConfigger.cpp
@@ -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();
+
+ 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;
+ }
diff --git a/othersoft/movingliner/source/Settings/SystemConfigger.h b/othersoft/movingliner/source/Settings/SystemConfigger.h
new file mode 100644
index 0000000..6f237a2
--- /dev/null
+++ b/othersoft/movingliner/source/Settings/SystemConfigger.h
@@ -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;
+
+
+
+};
\ No newline at end of file
diff --git a/othersoft/shuttercali/project/LocationCali/CMakeLists.txt b/othersoft/shuttercali/project/LocationCali/CMakeLists.txt
new file mode 100644
index 0000000..3f78fd7
--- /dev/null
+++ b/othersoft/shuttercali/project/LocationCali/CMakeLists.txt
@@ -0,0 +1,46 @@
+cmake_minimum_required(VERSION 3.3)
+
+project(shutter_calibrate)
+set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} C:/Qt/Qt5.12.7/5.12.7/mingw73_64)
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTOUIC ON)
+set(CMAKE_AUTORCC ON)
+set(QT Core Gui Network WebSockets SerialPort Widgets)
+set(CMAKE_CXX_STANDARD 14)
+find_package(Qt5 REQUIRED ${QT})
+
+
+file(GLOB_RECURSE HDR_LIST "../../source/*.h")
+file(GLOB_RECURSE SRC_LIST "../../source/*.cpp")
+file(GLOB_RECURSE HDR_LIST1 "../../source_rlx/*.h")
+file(GLOB_RECURSE SRC_LIST1 "../../source_rlx/*.cpp")
+
+include_directories("../../source")
+include_directories("../../source/FS")
+include_directories("../../source/Logger")
+include_directories("../../source/ZZ_SDK")
+include_directories("../../source/Settings")
+include_directories("../../source/Thread")
+include_directories("../../source/LinearShutter")
+include_directories("../../source_rlx/ShutterCali")
+include_directories("../../source_rlx/sensor")
+include_directories("../../source/OSIF/include")
+include_directories("D:/02Raspberry/2020-12-17/SeaBreeze/include")
+link_directories("D:/02Raspberry/2020-12-17/SeaBreeze/lib")
+link_directories("/home/pi/SeaBrease/lib")
+add_executable( shutter_calibrate main.cpp
+ ${HDR_LIST}
+ ${SRC_LIST}
+ ${HDR_LIST1}
+ ${SRC_LIST1}
+)
+qt5_use_modules(shutter_calibrate ${QT})
+target_link_libraries(shutter_calibrate SeaBreeze)
+IF (WIN32)
+target_link_libraries(shutter_calibrate SeaBreeze)
+ELSE ()
+target_link_libraries(shutter_calibrate seabreeze usb stdc++ m)
+ENDIF ()
+set_target_properties(shutter_calibrate PROPERTIES AUTOMOC ON)
+
+
diff --git a/othersoft/shuttercali/project/LocationCali/SeaBreeze.dll b/othersoft/shuttercali/project/LocationCali/SeaBreeze.dll
new file mode 100644
index 0000000..66bc74c
Binary files /dev/null and b/othersoft/shuttercali/project/LocationCali/SeaBreeze.dll differ
diff --git a/othersoft/shuttercali/project/LocationCali/SeaBreeze.lib b/othersoft/shuttercali/project/LocationCali/SeaBreeze.lib
new file mode 100644
index 0000000..9f5efa5
Binary files /dev/null and b/othersoft/shuttercali/project/LocationCali/SeaBreeze.lib differ
diff --git a/othersoft/shuttercali/project/LocationCali/main.cpp b/othersoft/shuttercali/project/LocationCali/main.cpp
new file mode 100644
index 0000000..b725eaa
--- /dev/null
+++ b/othersoft/shuttercali/project/LocationCali/main.cpp
@@ -0,0 +1,202 @@
+#include
+#include
+#include "QTextCodec"
+#include "SensorMannager.h"
+#include"SensorOptoSky.h"
+#include"SensorQExPRO.h"
+#include
+#include
+#include
+QTextStream cout1(stdout, QIODevice::WriteOnly);
+void logout(QString str){
+ std::cout<";
+ std::fflush(stdout);
+}
+vector FindFeng(vector point1ist, vector valuelist);
+vector DengJianJu(int position, int distanc, int times = 10);
+vector PingHua(vector value, int step = 2);
+int main(int argc, char* argv[])
+{
+ QCoreApplication aaaaa(argc, argv);
+ cout1<<"Welcom to use the Auto Locate Application"<<"
"<initSensor();
+
+ cout1<<"Get Tempratrue:"<GettingTempratrue()<<"
"<Settingshuttertime(20);
+ aa->GetOnePlot(oneplot);
+ cout1<<"Position"<< oneplot.Plot[1000];
+
+
+
+
+ CVSMD12XControl Motercontrol;
+ Motercontrol.ILMES_InitializeComm("COM16");
+
+ //Motercontrol.ILMES_InitializeComm("/dev/ttyUSB1");
+ ControllerParams cpTest;
+ bool res = Motercontrol.ILMES_InitializeParams(cpTest);
+ Motercontrol.StartBackZero();
+ Motercontrol.SetRunSpeed(10000);
+ Motercontrol.MoveTo_NoSyn(550000);
+ aa->GetOnePlot(oneplot);
+ MSInfo temp;
+ Motercontrol.GetStatus(temp);
+ vector point1ist;
+ vector valuelist;
+ int i = 0;
+ Motercontrol.GetStatus(temp);
+ //outfile <GetOnePlot(oneplot);
+ //qDebug() << oneplot.BandNum;
+ //std::cout << temp.iPosition << std::endl;
+
+ Motercontrol.GetStatus(temp);
+ i++;
+ //outfile << i << "," << oneplot.Plot[1024] << "," << temp.iPosition << std::endl;
+ point1ist.push_back(temp.iPosition);
+ valuelist.push_back(oneplot.Plot[1024]);
+
+ }
+ Motercontrol.StartBackZero();
+ vector valuepinghua1 = PingHua(valuelist, 3);
+ vectorloction1=FindFeng(point1ist, valuepinghua1);
+ int lenth = loction1.size();
+ for (size_t i = 0; i < lenth; i++)
+ {
+ vector location1point = DengJianJu(loction1[i], 5000, 25);
+ vector valuepoint;
+ int lennow = location1point.size();
+ for (size_t ii = 0; ii < lennow; ii++)
+ {
+ Motercontrol.MoveTo(location1point[ii]);
+ aa->GetOnePlot(oneplot);
+ valuepoint.push_back(oneplot.Plot[1024]);
+ //outfile << ii << "," << oneplot.Plot[1024] << "," << location1point[ii] << std::endl;
+ }
+ vector valuepinghua = PingHua(valuepoint,3);
+ vectorloction2 = FindFeng(location1point, valuepinghua);
+ if (loction2.size() == 1)
+ {
+ outfile < FindFeng(vector point1ist, vector valuelist)
+{
+ vector ret;
+ int lenth = point1ist.size();
+ if (lenth<10)
+ {
+ ret.push_back(0);
+ return ret;
+ }
+ for (size_t i = 5; i < lenth-5; i++)
+ {
+ if (valuelist[i] > 5000&&valuelist[i]>valuelist[i-1]&& valuelist[i] > valuelist[i - 4]&& valuelist[i] >valuelist[i + 1]&& valuelist[i] > valuelist[i + 4]
+ && valuelist[i-1] > 5000 && valuelist[i-4]&& valuelist[i +1] > 5000 && valuelist[i + 4])
+ {
+ if (ret.size()!=0)
+ {
+ if (point1ist[i]-ret[ret.size()-1]<5000)
+ {
+ continue;
+ }
+
+ }
+ ret.push_back(point1ist[i]);
+
+
+ }
+
+ }
+ return ret;
+
+
+
+}
+vector DengJianJu(int position, int distanc, int times )
+{
+ int begin = position - distanc;
+ vector ret;
+ int eachstep = distanc / times;
+ for (size_t i = 0; i < 2*times; i++)
+ {
+ ret.push_back(begin + i * eachstep);
+ }
+ return ret;
+
+}
+vector PingHua(vector value,int step)
+{
+ vector ret;
+ if (value.size()<2*step)
+ {
+ return value;
+ }
+ int len = value.size();
+ for (size_t i = 0; i < step; i++)
+ {
+ ret.push_back(value[i]);
+ }
+ for (size_t i = step; i setPortName(qstrPortName);
+ m_pSerialPort->setReadBufferSize(512);
+ bool bRes = m_pSerialPort->setBaudRate(m_iBaudRate);
+ if (!bRes)
+ {
+ qDebug() << "Err:setBaudRate Failed.Exit Code:1";
+ //std::cout << "Err.setBaudRate Failed" << std::endl;
+ return 1;
+ }
+
+ bRes = m_pSerialPort->open(QIODevice::ReadWrite);
+ if (!bRes)
+ {
+ qDebug() << "Err:open Failed.Exit Code:2";
+ //std::cout << "Err.open Failed" << std::endl;
+ return 2;
+ }
+
+ return 0;
+}
+
+void ZZ_ATPControl_Serial_Qt::Close()
+{
+ m_pSerialPort->close();
+}
+int ZZ_ATPControl_Serial_Qt::GetDeviceInfo(DeviceInfo &Info)
+{
+ QByteArray qbSend, qbRecv;
+
+ qbSend.clear();
+ qbRecv.clear();
+ qbSend.append(GET_PN_NUMBER);
+ int iRes = SendCommand(qbSend);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:GetDeviceInfo Failed,Communication error.Exit Code:1";
+ return 1;
+ }
+ iRes = RecvData(qbRecv);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:GetDeviceInfo Failed,Communication error.Exit Code:1";
+ return 1;
+ }
+ iRes = ParseData(qbRecv);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:GetDeviceInfo Failed,Communication error.Exit Code:1";
+ return 1;
+ }
+ m_diDeviceInfo.strPN = qbRecv.data();
+
+ qbSend.clear();
+ qbRecv.clear();
+ qbSend.append(GET_SN_NUMBER);
+ iRes = SendCommand(qbSend);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:GetDeviceInfo Failed,Communication error.Exit Code:1";
+ return 1;
+ }
+ iRes = RecvData(qbRecv);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:GetDeviceInfo Failed,Communication error.Exit Code:1";
+ return 1;
+ }
+ iRes = ParseData(qbRecv);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:GetDeviceInfo Failed,Communication error.Exit Code:1";
+ return 1;
+ }
+ m_diDeviceInfo.strSN = qbRecv.data();
+
+
+ Info = m_diDeviceInfo;
+ return 0;
+}
+
+int ZZ_ATPControl_Serial_Qt::GetDeviceAttribute(DeviceAttribute &Attr)
+{
+ QByteArray qbSend, qbRecv;
+
+ qbSend.clear();
+ qbRecv.clear();
+ qbSend.append(GET_MIN_INTEGRATION_TIME);
+ int iRes = SendCommand(qbSend);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:GetDeviceAttribute Failed,Communication error.Exit Code:1";
+ return 1;
+ }
+ iRes = RecvData(qbRecv);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:GetDeviceAttribute Failed,Communication error.Exit Code:1";
+ return 1;
+ }
+ iRes = ParseData(qbRecv);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:GetDeviceAttribute Failed,Communication error.Exit Code:1";
+ return 1;
+ }
+ m_daDeviceAttr.iMinIntegrationTimeInMS = (ZZ_U8)qbRecv[1] + (ZZ_U8)qbRecv[0] * 256;
+
+ qbSend.clear();
+ qbRecv.clear();
+ qbSend.append(GET_MAX_INTEGRATION_TIME);
+ iRes = SendCommand(qbSend);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:GetDeviceAttribute Failed,Communication error.Exit Code:1";
+ return 1;
+ }
+ iRes = RecvData(qbRecv);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:GetDeviceAttribute Failed,Communication error.Exit Code:1";
+ return 1;
+ }
+ iRes = ParseData(qbRecv);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:GetDeviceAttribute Failed,Communication error.Exit Code:1";
+ return 1;
+ }
+ m_daDeviceAttr.iMaxIntegrationTimeInMS = (ZZ_U8)qbRecv[1] + (ZZ_U8)qbRecv[0] * 256;
+
+
+ iRes = SetExposureTime(m_daDeviceAttr.iMinIntegrationTimeInMS);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:GetDeviceAttribute Failed,Call SetExposureTime error.Exit Code:2";
+ return 2;
+ }
+ iRes = SingleShot(m_daDeviceAttr.iPixels);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:GetDeviceAttribute Failed,Call SingleShot error.Exit Code:3";
+ return 3;
+ }
+
+
+ qbSend.clear();
+ qbRecv.clear();
+ qbSend.append(GET_WAVELENGTH_CALIBRATION_COEF);
+ qbSend.resize(3);
+ qbSend[1] = 0x00;
+ qbSend[2] = 0x01;
+ iRes = SendCommand(qbSend);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:GetDeviceAttribute Failed,Communication error.Exit Code:1";
+ return 1;
+ }
+ iRes = RecvData(qbRecv);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:GetDeviceAttribute Failed,Communication error.Exit Code:1";
+ return 1;
+ }
+ iRes = ParseData(qbRecv);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:GetDeviceAttribute Failed,Communication error.Exit Code:1";
+ return 1;
+ }
+ float fWaveLengthCoef[4];
+ memcpy(fWaveLengthCoef, qbRecv.data()+16, 4 * sizeof(float));
+ for (int i=0;i< m_daDeviceAttr.iPixels;i++)
+ {
+ m_daDeviceAttr.fWaveLengthInNM[i] = fWaveLengthCoef[0] * i*i*i + fWaveLengthCoef[1] * i*i + fWaveLengthCoef[2] * i + fWaveLengthCoef[3];
+ }
+
+ Attr = m_daDeviceAttr;
+
+ return 0;
+}
+
+int ZZ_ATPControl_Serial_Qt::SetDeviceTemperature(float fTemperature)
+{
+ return 0;
+}
+
+int ZZ_ATPControl_Serial_Qt::SendCommand(QByteArray qbCommand)
+{
+ int iSize = qbCommand.size() + 3;
+ QByteArray qbSend;
+ qbSend.resize(4);
+ qbSend[0] = (ZZ_U8)0xAA;
+ qbSend[1] = 0x55;
+ qbSend[2] = iSize / 256;
+ qbSend[3] = iSize % 256;
+ qbSend.append(qbCommand);
+
+ int iSum = 0;
+ for (int i = 0; i < iSize - 1; i++)
+ {
+ iSum = iSum + qbSend[i + 2];
+ }
+
+ qbSend.append(iSum % 256);
+
+ qint64 qi64Write= m_pSerialPort->write(qbSend);
+ if (qi64Write != qbSend.size())
+ {
+ qDebug() << "Err:write Failed.Exit Code:1"<< qi64Write;
+ return 1;
+ }
+
+ return 0;
+}
+
+int ZZ_ATPControl_Serial_Qt::RecvData(QByteArray &qbData)
+{
+ qbData.clear();
+ qbData = m_pSerialPort->readAll();
+
+ int iCounter = 0;
+ while (qbData.size() < 4)
+ {
+ m_pSerialPort->waitForReadyRead(50);
+ QByteArray qbTemp = m_pSerialPort->readAll();
+ qbData.append(qbTemp);
+
+ if (iCounter > 10)
+ {
+ qDebug() << "Err:RecvData Failed,Not Enough Data.Exit Code:1"<< qbData.size();
+ return 1;
+ }
+ iCounter++;
+ }
+
+ if ((ZZ_U8)qbData[0] != (ZZ_U8)0xaa || (ZZ_U8)qbData[1] != (ZZ_U8)0x55)
+ {
+ qDebug() << "Err:RecvData Failed,Wrong Header.Exit Code:2" << qbData.size();
+ return 2;
+ }
+
+ iCounter = 0;
+ int iLength = qbData[2] * 256 + qbData[3] + 2;
+ while (qbData.size() < iLength)
+ {
+ m_pSerialPort->waitForReadyRead(50);
+ qbData.append(m_pSerialPort->readAll());
+
+ if (iCounter > 100)
+ {
+ qDebug() << "Err:RecvData Failed,Incomplete Data.Exit Code:3" << qbData.size();
+ return 3;
+ }
+ iCounter++;
+ }
+
+ if (qbData.size() > iLength)
+ {
+ qbData.remove(iLength - 1, qbData.size() - iLength);
+ }
+ int iCheckSumLength = iLength - 3;
+ ZZ_U16 usCheckSum = 0;
+ for (int i = 0; i < iCheckSumLength; i++)
+ {
+ usCheckSum += qbData[i+2];
+ }
+ usCheckSum = usCheckSum % 256;
+ ZZ_U8 ucTemp = qbData[qbData.size() - 1];
+ if ((ZZ_U8)usCheckSum != ucTemp)
+ {
+ qDebug() << "Err:RecvData Failed,Incorrect Check Sum.Exit Code:4" << qbData.size();
+ qbData.clear();
+ return 4;
+ }
+
+ return 0;
+}
+
+int ZZ_ATPControl_Serial_Qt::ParseData(QByteArray &qbData)
+{
+ if (qbData.size() < 6)
+ {
+ qDebug() << "Err:ParseData Failed,Not Enough Data.Exit Code:1" << qbData.size();
+ return 1;
+ }
+ qbData.remove(0, 5);
+ qbData.remove(qbData.size() - 1, 1);
+ return 0;
+}
+
+int ZZ_ATPControl_Serial_Qt::PerformAutoExposure(float fMinScaleFactor, float fMaxScaleFactor, float &fPredictedExposureTime)
+{
+ using namespace ZZ_MATH;
+ int iDeviceDepth = 65535;
+
+ bool bFlagIsOverTrying = false;
+ bool bFlagIsLowerMinExposureTime = false;
+ bool bFlagIsOverMaxExposureTime = false;
+ bool bFlagIsAutoExposureOK = false;
+ bool bFlagIsAutoExposureFailed = false;
+
+ bool bIsValueOverflow = false;
+ bool bIsLastValueOverflow = false;
+
+ float fExposureTime = 0;
+ float fTempExposureTime = 0;
+ double fLastExposureTime = 0.1;
+ int iRepeatCount = 0;
+
+ int iRes = SetExposureTime(2000);//need change to load from files
+ if (iRes != 0)
+ {
+ qDebug() << "Err:PerformAutoExposure Failed.Exit Code:1";
+ return 1;
+ }
+
+ while (!bFlagIsAutoExposureOK && !bFlagIsAutoExposureFailed)
+ {
+ DataFrame dfTemp;
+
+ if (iRepeatCount++ > 30)
+ {
+ bFlagIsAutoExposureFailed = true;
+ bFlagIsOverTrying = true;
+ break;
+ }
+
+ fExposureTime = (float)m_daDeviceAttr.iMinIntegrationTimeInMS;
+ fTempExposureTime = fExposureTime;
+
+ iRes = SingleShot(dfTemp);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:PerformAutoExposure Failed.Exit Code:2";
+ return 2;
+ }
+
+ HeapSort(dfTemp.usData, m_daDeviceAttr.iPixels);
+
+ double dSum = 0;
+ int iCount = m_daDeviceAttr.iPixels / 100;
+ for (int i = 0; i < iCount; i++)
+ {
+ dSum += dfTemp.usData[i];
+ }
+ double dTemp = dSum / iCount;
+
+ if (dTemp >= iDeviceDepth * 0.99)
+ {
+ bIsValueOverflow = true;
+ if (!bIsLastValueOverflow)
+ {
+ fExposureTime = (float)(fLastExposureTime + fExposureTime) / 2;
+ }
+ else
+ {
+ fExposureTime = fExposureTime / 2;
+ }
+ }
+
+ else if (iDeviceDepth * fMaxScaleFactor >= dTemp && dTemp >= iDeviceDepth * fMinScaleFactor)
+ {
+ bFlagIsAutoExposureOK = 1;
+ }
+ else if (dTemp > iDeviceDepth * fMaxScaleFactor)
+ {
+ bIsValueOverflow = true;
+ if (!bIsLastValueOverflow)
+ {
+ fExposureTime = (float)(fLastExposureTime + fExposureTime) / 2;
+ }
+ else
+ {
+ fExposureTime = fExposureTime * 3 / 4;
+ }
+ }
+ else if (dTemp < iDeviceDepth * fMinScaleFactor)
+ {
+ bIsValueOverflow = false;
+ if (bIsLastValueOverflow)
+ {
+ fExposureTime = (float)(fLastExposureTime + fExposureTime) / 2;
+ }
+ else
+ {
+ double dFactor;
+ dFactor = dTemp / (iDeviceDepth * fMaxScaleFactor);
+ fExposureTime = (float)(fExposureTime / dFactor);
+ }
+ if (/*fExposureTime > 100 || */fExposureTime < 10)
+ {
+ bFlagIsAutoExposureOK = false;
+ bFlagIsAutoExposureFailed = true;
+ bFlagIsLowerMinExposureTime = true;
+ }
+ }
+ bIsLastValueOverflow = bIsValueOverflow;
+ fLastExposureTime = fTempExposureTime;
+
+ if (fExposureTime > 13000)
+ {
+ bFlagIsAutoExposureOK = false;
+ bFlagIsAutoExposureFailed = true;
+ fPredictedExposureTime = 13000;
+ iRes = SetExposureTime(13000);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:PerformAutoExposure Failed.Exit Code:3";
+ return 3;
+ }
+ bFlagIsOverMaxExposureTime = true;
+ break;
+ }
+
+ iRes = SetExposureTime((int)fExposureTime);
+ if (iRes != 0)
+ {
+ qDebug() << "Err:PerformAutoExposure Failed.Exit Code:4";
+ return 3;
+ }
+ }
+ fPredictedExposureTime = fExposureTime;
+ return 0;
+}
+
+
+
+// int ZZ_ATPControl_Serial_Qt::SetExtShutter(int iShutterUP0, int iShutterDOWN1, int iShutterDOWN2, int iShutterDOWN3)
+// {
+// qDebug() << "stub code not implemented";
+// return -1;
+// }
+
+int ZZ_ATPControl_Serial_Qt::SetExposureTime(int iExposureTimeInMS)
+{
+ QByteArray qbExposureTime,qbRecv;
+ qbExposureTime.append(SET_INTEGRATION_TIME);
+ qbExposureTime.resize(3);
+ qbExposureTime[1] = iExposureTimeInMS >> 8;
+ qbExposureTime[2] = iExposureTimeInMS & 0xFF;
+
+ SendCommand(qbExposureTime);
+ RecvData(qbRecv);
+ ParseData(qbRecv);
+
+ if ((ZZ_U8)qbRecv[0] != 0)
+ {
+ qDebug() << "Err:SetExposureTime Failed.Exit Code:1" ;
+ return 1;
+ }
+
+ return 0;
+}
+
+int ZZ_ATPControl_Serial_Qt::GetExposureTime(int &iExposureTimeInMS)
+{
+ QByteArray qbSend, qbRecv;
+ qbSend.clear();
+ qbRecv.clear();
+ qbSend.append(GET_INTEGRATION_TIME);
+ qbSend.resize(3);
+ qbSend[1] = 0x00;
+ qbSend[2] = 0x01;
+ SendCommand(qbSend);
+ RecvData(qbRecv);
+ ParseData(qbRecv);
+ return 0;
+}
+
+int ZZ_ATPControl_Serial_Qt::SingleShot(DataFrame &dfData)
+{
+ QByteArray qbSend, qbRecv;
+ qbSend.clear();
+ qbRecv.clear();
+ qbSend.append(SYNC_GET_DATA);
+ qbSend.resize(3);
+ qbSend[1] = 0x00;
+ qbSend[2] = 0x01;
+ SendCommand(qbSend);
+ RecvData(qbRecv);
+ ParseData(qbRecv);
+
+ if ((ZZ_U8)qbRecv[0] != 0)
+ {
+ qDebug() << "Err:SingleShot Failed.Exit Code:1";
+ return 1;
+ }
+ else
+ {
+ int iDataSizeInPixel = (qbRecv.size() - 1) / 2;
+ memcpy(dfData.usData, qbRecv.data() + 1, iDataSizeInPixel * 2);
+
+ }
+
+ return 0;
+}
+
+int ZZ_ATPControl_Serial_Qt::SingleShot(int &iPixels)
+{
+ QByteArray qbSend, qbRecv;
+ qbSend.clear();
+ qbRecv.clear();
+ qbSend.append(SYNC_GET_DATA);
+ qbSend.resize(3);
+ qbSend[1] = 0x00;
+ qbSend[2] = 0x01;
+ SendCommand(qbSend);
+ RecvData(qbRecv);
+ ParseData(qbRecv);
+
+ if ((ZZ_U8)qbRecv[0] != 0)
+ {
+ qDebug() << "Err:SingleShot Failed.Exit Code:1";
+ return 1;
+ }
+ else
+ {
+ iPixels = (qbRecv.size() - 1) / 2;
+
+ }
+ return 0;
+}
+
+// int ZZ_ATPControl_Serial_Qt::SingleShotDark(ATPDataFrame &dfData)
+// {
+// SetExtShutter(0,0,0,0);
+// SingleShot(dfData);
+// return 0;
+// }
+
+int ZZ_ATPControl_Serial_Qt::GetDeviceTemperature(float &fTemperature)
+{
+ QByteArray qbSend, qbRecv;
+ qbSend.clear();
+ qbRecv.clear();
+ qbSend.append(GET_TEC_TEMP);
+ qbSend.resize(3);
+ qbSend[1] = 0x00;
+ qbSend[2] = 0x01;
+ SendCommand(qbSend);
+ RecvData(qbRecv);
+ ParseData(qbRecv);
+ return 0;
+}
+
+//void ZZ_ATPControl_Serial_Qt::ReadMessage()
+//{
+// QByteArray qbTemp, qbTemp1;
+// qbTemp = m_pSerialPort->readAll();
+// while (qbTemp.size()<2)
+// {
+// m_pSerialPort->waitForReadyRead(50);
+// qbTemp1 = m_pSerialPort->readAll();
+// qbTemp.append(qbTemp1);
+// }
+
+
+
+ //return;
+ // }
diff --git a/othersoft/shuttercali/source/FS/ATPControl_Serial_QT.h b/othersoft/shuttercali/source/FS/ATPControl_Serial_QT.h
new file mode 100644
index 0000000..dbb6456
--- /dev/null
+++ b/othersoft/shuttercali/source/FS/ATPControl_Serial_QT.h
@@ -0,0 +1,84 @@
+//////////////////////////////////////////////////////////////////////////
+//ATP豸ͨ
+//////////////////////////////////////////////////////////////////////////
+#pragma once
+#include "pch.h"
+#include "ZZ_Types.h"
+#include "IrisFiberSpectrometerBase.h"
+
+using namespace ZZ_MISCDEF;
+using namespace ZZ_MISCDEF::ATP;
+using namespace ZZ_MISCDEF::IRIS::FS;
+
+class ZZ_ATPControl_Serial_Qt:public CIrisFSBase
+{
+ //Q_OBJECT
+public:
+ ZZ_ATPControl_Serial_Qt();
+ virtual ~ZZ_ATPControl_Serial_Qt();
+
+public:
+ //ò
+ //int SetBaudRate(int iBaud);
+ //ʼ豸
+ int Initialize(bool bIsUSBMode, ZZ_U8 ucPortNumber, std::string strDeviceName);
+ //ر豸
+ void Close();
+
+ //βԲɼ ȷ豸
+ int SingleShot(int &iPixels);
+
+ //ݲɼ
+ int SingleShot(DataFrame &dfData);
+
+ //ΰɼ
+ //int SingleShotDark(ATPDataFrame &dfData);
+
+ //int SingleShotDeducted(ATPDataFrame &dfData);
+ //عʱ
+ int SetExposureTime(int iExposureTimeInMS);
+
+ //ȡعʱ
+ int GetExposureTime(int &iExposureTimeInMS);
+
+ //int GetWaveLength(float *pfWaveLength);
+
+ //ȡ豸Ϣ
+ int GetDeviceInfo(DeviceInfo &Info);
+
+ //ȡ豸
+ int GetDeviceAttribute(DeviceAttribute &Attr);
+
+ //int GetDeviceListInfo(); //use type name to enum
+
+ //¶
+ int SetDeviceTemperature(float fTemperature);
+
+ //ȡ¶
+ int GetDeviceTemperature(float &fTemperature);
+
+ //Զع
+ int PerformAutoExposure(float fMinScaleFactor, float fMaxScaleFactor, float &fPredictedExposureTime);
+
+#ifdef _DEBUG
+public:
+#else //
+private:
+#endif
+ //port
+ int m_iBaudRate;
+ QSerialPort *m_pSerialPort;
+
+ //ATP
+ DeviceInfo m_diDeviceInfo;
+ DeviceAttribute m_daDeviceAttr;
+
+ //////////////////////////////////////////////////////////////////////////shutter control stub code s
+ //int SetExtShutter(int iShutterUP0, int iShutterDOWN1,int iShutterDOWN2,int iShutterDOWN3); //0:close 1:open
+ //////////////////////////////////////////////////////////////////////////shutter control stub code e
+ int SendCommand(QByteArray qbCommand);
+ int RecvData(QByteArray &qbData);
+ int ParseData(QByteArray &qbData);
+//private slots :
+ //void ReadMessage();
+};
\ No newline at end of file
diff --git a/othersoft/shuttercali/source/FS/ATPDataFileProcessor.cpp b/othersoft/shuttercali/source/FS/ATPDataFileProcessor.cpp
new file mode 100644
index 0000000..e69de29
diff --git a/othersoft/shuttercali/source/FS/ATPDataFileProcessor.h b/othersoft/shuttercali/source/FS/ATPDataFileProcessor.h
new file mode 100644
index 0000000..6f70f09
--- /dev/null
+++ b/othersoft/shuttercali/source/FS/ATPDataFileProcessor.h
@@ -0,0 +1 @@
+#pragma once
diff --git a/othersoft/shuttercali/source/FS/IrisFiberSpectrometerBase.h b/othersoft/shuttercali/source/FS/IrisFiberSpectrometerBase.h
new file mode 100644
index 0000000..ebf17d7
--- /dev/null
+++ b/othersoft/shuttercali/source/FS/IrisFiberSpectrometerBase.h
@@ -0,0 +1,42 @@
+#include
+#include "ZZ_Types.h"
+#pragma once
+using namespace ZZ_MISCDEF;
+using namespace ZZ_MISCDEF::IRIS::FS;
+
+class CIrisFSBase
+{
+public:
+ //CIrisFSBase();
+ //virtual ~CIrisFSBase()= 0;
+public:
+ //ʼ豸
+ //˴stringΪָĸoceanǵIJиΪc/c++
+ //0Ϊͬ뷵زֵͬ
+ virtual int Initialize(bool bIsUSBMode,ZZ_U8 ucPortNumber,std::string strDeviceName) = 0;
+
+ //ر豸
+ virtual void Close() = 0;
+
+ //ݲɼ
+ virtual int SingleShot(DataFrame &dfData) = 0;
+
+ //عʱ
+ virtual int SetExposureTime(int iExposureTimeInMS) = 0;
+
+ //ȡعʱ
+ virtual int GetExposureTime(int &iExposureTimeInMS) = 0;
+
+ //Ŀ¶
+ virtual int SetDeviceTemperature(float fTemperature) = 0;
+
+ //ȡ¶
+ virtual int GetDeviceTemperature(float &fTemperature) = 0;
+
+ //ȡ豸Ϣ
+ virtual int GetDeviceInfo(DeviceInfo &Info) = 0;
+
+ //ȡ豸
+ virtual int GetDeviceAttribute(DeviceAttribute &Attr) = 0;
+
+};
diff --git a/othersoft/shuttercali/source/FS/ZZ_Types.h b/othersoft/shuttercali/source/FS/ZZ_Types.h
new file mode 100644
index 0000000..7ad1c54
--- /dev/null
+++ b/othersoft/shuttercali/source/FS/ZZ_Types.h
@@ -0,0 +1,297 @@
+//////////////////////////////////////////////////////////////////////////
+//˵ļ
+//////////////////////////////////////////////////////////////////////////
+#pragma once
+#include "pch.h"
+#include
+#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ָת
+ 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
+ };
+
+ //֡
+ typedef struct tagATPDataFrame
+ {
+ unsigned short usExposureTime;
+ ZZ_U16 usData[4096];
+ float fTemperature;
+ double dTimes = 0;
+ }ATPDataFrame;
+
+ //豸Ϣ
+ typedef struct tagATPDeviceInfo
+ {
+ std::string strPN;
+ std::string strSN;
+ }ATPDeviceInfo;
+
+ //豸
+ typedef struct tagATPDeviceAttribute
+ {
+ int iPixels;
+ int iMaxIntegrationTime;
+ int iMinIntegrationTime;
+ float fWaveLength[4096];
+
+ }ATPDeviceAttribute;
+ //////////////////////////////////////////////////////////////////////////config file
+
+
+
+ }
+
+ //в
+ 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;
+ }
+
+ //ϵͳļṹ
+ 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;
+ }
+
+};
diff --git a/othersoft/shuttercali/source/LinearShutter/AbstractPort.h b/othersoft/shuttercali/source/LinearShutter/AbstractPort.h
new file mode 100644
index 0000000..0c0118b
--- /dev/null
+++ b/othersoft/shuttercali/source/LinearShutter/AbstractPort.h
@@ -0,0 +1,16 @@
+#pragma once
+#include "VSMD12XMiscDefines.h"
+#include
+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;
+
+};
+
diff --git a/othersoft/shuttercali/source/LinearShutter/VSMD12XControl.cpp b/othersoft/shuttercali/source/LinearShutter/VSMD12XControl.cpp
new file mode 100644
index 0000000..4013b30
--- /dev/null
+++ b/othersoft/shuttercali/source/LinearShutter/VSMD12XControl.cpp
@@ -0,0 +1,1415 @@
+#include "pch.h"
+#include "VSMD12XControl.h"
+#include "ZZ_SeiralPort.h"
+#include
+#define sprintf_s snprintf
+CVSMD12XControl::CVSMD12XControl()
+{
+ m_iProtocolType = 0;
+ m_iCID = 1;
+ m_bIsSyncMove = 0;
+ m_piPositionInPulses = NULL;
+ waitetime = 200;
+ waitetime = 200;
+}
+
+CVSMD12XControl::~CVSMD12XControl()
+{
+ if (m_piPositionInPulses!=NULL)
+ {
+ delete[] m_piPositionInPulses;
+ }
+}
+
+bool CVSMD12XControl::ILMES_InitializeComm(PortInfo portinfo, int iPortType /*= 1*/, int iCID /*= 1*/, bool bSyncMove /*= true*/)
+{
+ SetProtocolType(iPortType);
+ SetCID(iCID);
+ SetSyncMode(bSyncMove);
+
+ return InitAndOpenPort(portinfo);
+}
+bool CVSMD12XControl::ILMES_InitializeComm(QString portName, int bandrate, int iPortType , int iCID , bool bSyncMove )
+{
+ PortInfo pi;
+ pi.FullPortName = portName;
+ pi.iBaudRate = bandrate;
+ return ILMES_InitializeComm(pi, iPortType, iCID, bSyncMove);
+
+
+}
+
+bool CVSMD12XControl::ILMES_InitializeParams(ControllerParams cpParams)
+{
+ bool bRes = false;
+
+ bRes = CVSMD12XControl::SetBaudRate(cpParams.bdr);
+ if (!bRes)
+ {
+ qDebug() << "SetBaudRate Err";
+ //return false;
+ }
+
+ bRes = CVSMD12XControl::SetSpeed(cpParams.spd,cpParams.acc,cpParams.dec);
+ if (!bRes)
+ {
+ qDebug() << "SetSpeed Err";
+ //return false;
+ }
+
+ bRes = CVSMD12XControl::SetMicroSteps(cpParams.mcs);
+ if (!bRes)
+ {
+ qDebug() << "SetMicroSteps Err";
+ //return false;
+ }
+
+ bRes = CVSMD12XControl::SetCurrent(cpParams.cra,cpParams.crn,cpParams.crh);
+ if (!bRes)
+ {
+ qDebug() << "SetCurrent Err";
+ //return false;
+ }
+
+ bRes = CVSMD12XControl::SetZeroParams(cpParams.zmd,cpParams.osv, cpParams.snr,cpParams.zsd,cpParams.zsp);
+ if (!bRes)
+ {
+ qDebug() << "SetZeroParams Err";
+ //return false;
+ }
+ return bRes;
+}
+
+void CVSMD12XControl::ILMES_SetPosition(int *piPositionInPulse, size_t szSize)
+{
+ m_piPositionInPulses = new int[szSize];
+ for (size_t i=0;i< szSize;i++)
+ {
+ m_piPositionInPulses[i] = piPositionInPulse[i];
+ }
+}
+
+bool CVSMD12XControl::ILMES_MoveToPos(int iPositionIndex)
+{
+ bool bRes = false;
+ bRes = CVSMD12XControl::StartBackZero();
+ if (!bRes)
+ {
+ qDebug() << "StartBackZero Err";
+ return false;
+ }
+
+ bRes = CVSMD12XControl::MoveTo(m_piPositionInPulses[iPositionIndex]);
+ if (!bRes)
+ {
+ qDebug() << "MoveTo Err";
+ return false;
+ }
+
+ return bRes;
+}
+
+void CVSMD12XControl::SetProtocolType(int iProtocolType /*= 0*/)
+{
+ m_iProtocolType = iProtocolType;
+}
+
+void CVSMD12XControl::SetCID(int iID)
+{
+ m_iCID = iID;
+
+ char cmd[64];
+ sprintf_s(cmd, 64, "%d ", iID);
+ std::string strCID(cmd);
+ m_strCID = strCID;
+ return;
+}
+
+void CVSMD12XControl::SetSyncMode(bool bSyncMove /*= false*/)
+{
+ m_bIsSyncMove = bSyncMove;
+}
+
+bool CVSMD12XControl::InitAndOpenPort(PortInfo portinfo)
+{
+ bool bRes = false;
+ if (portinfo.iPortType==0)
+ {
+ m_pAbsPort = new CZZ_SeiralPort_QT;
+ }
+
+ m_pAbsPort->InitPort(portinfo);
+
+ bRes = m_pAbsPort->SetPort();
+ if (!bRes)
+ {
+ return bRes;
+ }
+ bRes = m_pAbsPort->Open();
+ return bRes;
+}
+
+std::string CVSMD12XControl::ReadReceive()
+{
+ return m_pAbsPort->ReadAll();
+}
+
+int CVSMD12XControl::SendCommand(const std::string strSend)
+{
+ return m_pAbsPort->Write(strSend);
+}
+
+bool CVSMD12XControl::InitController()
+{
+// std::string strTest = "this is a test message.";
+//
+// char *pcTest = new char[strTest.length()];
+// strTest.copy(pcTest, strTest.length(),0);
+//
+// memcpy(pcTest, strTest.c_str(), 23);
+//
+// char *pcTest1 = (char*)strTest.c_str();
+// std::string test=m_pAbsPort->ReadAll();
+ std::string strCMD = "dev\n";
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+ int iRet=m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+ std::string strRecv = m_pAbsPort->ReadAll();
+ ParseReturnedString(strRecv, 0);
+ std::string::size_type szPosition;
+ szPosition = strRecv.find("VSMD", 0);
+ if (szPosition != strRecv.npos)
+ {
+ return true;
+ }
+ return false;
+}
+
+bool CVSMD12XControl::GetStatus(MSInfo &stuMotorParam)
+{
+ std::string strCMD = "cts\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+
+ //QThread::msleep(200);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ ParseReturnedParam(strRecv);
+
+ stuMotorParam = m_stuMSInfo;
+ return true;
+}
+
+bool CVSMD12XControl::Move(int iRelPulse)
+{
+ using namespace ZZ_MISCDEF;
+ char cmd[64];
+ sprintf_s(cmd, 64, "rmv %d\n", iRelPulse);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+ QThread::msleep(200);
+ m_pAbsPort->ReadAll();
+ if (m_bIsSyncMove)
+ {
+ if (iRet != 0)
+ {
+ return false;
+ }
+
+ bool bFlagIsStopped=false;
+ while (!bFlagIsStopped)
+ {
+ QThread::msleep(200);
+ GetStatus(m_stuMSInfo);
+ ZZ_U8 ucFlag = m_stuMSInfo.uiFlags & 0x000000FF;
+ ucFlag = ucFlag & 0x10;
+ if (ucFlag==0x10 && m_stuMSInfo.fVelocity==0)
+ {
+ bFlagIsStopped = true;
+ }
+ }
+ return true;
+ }
+ else
+ {
+ if (iRet == 0)
+ {
+ return true;
+ }
+ return false;
+ }
+
+}
+
+bool CVSMD12XControl::Enable()
+{
+ std::string strCMD = "ena\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(200);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+bool CVSMD12XControl::Disable()
+{
+ std::string strCMD = "off\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(200);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+
+}
+
+bool CVSMD12XControl::MoveTo(int iAbsPulse)
+{
+ if (iAbsPulse > MAXDISTANCE)
+ {
+ //return false;
+ iAbsPulse = MAXDISTANCE;
+ }
+
+ char cmd[64];
+ sprintf_s(cmd, 64, "pos %d\n", iAbsPulse);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+
+ int iRet = m_pAbsPort->Write(strCMD);
+ if (waitetime!=0)
+ {
+ QThread::msleep(200);
+ }
+
+
+ m_pAbsPort->ReadAll();
+
+ if (m_bIsSyncMove)
+ {
+ if (iRet != 0)
+ {
+ return false;
+ }
+
+ bool bFlagIsStopped = false;
+ while (!bFlagIsStopped)
+ {
+ QThread::msleep(200);
+ GetStatus(m_stuMSInfo);
+ ZZ_U8 ucFlag = m_stuMSInfo.uiFlags & 0x000000FF;
+ ucFlag = ucFlag & 0x10;
+ if (ucFlag == 0x10 && m_stuMSInfo.fVelocity == 0)
+ {
+ bFlagIsStopped = true;
+ }
+ }
+ return true;
+ }
+ else
+ {
+ if (iRet == 0)
+ {
+ return true;
+ }
+ return false;
+ }
+// if (iRet == 0)
+// {
+// return true;
+// }
+// return false;
+// std::string strTest;
+// strTest.resize(7);
+// char test[7];
+// //memcpy(test, strCMD.c_str(), 7);
+// for (size_t i = 0; i < 7; i++)
+// {
+// strTest[i] = cmd[i];
+// }
+}
+
+bool CVSMD12XControl::Move_NoSyn(int iRelPulse)
+{
+ bool a;
+ waitetime = 0;
+ m_bIsSyncMove = false;
+ a = Move(iRelPulse);
+ m_bIsSyncMove = true;
+ waitetime = 200;
+ return a;
+
+}
+
+bool CVSMD12XControl::MoveTo_NoSyn(int iAbsPulse)
+{
+ bool a;
+ waitetime = 0;
+ m_bIsSyncMove = false;
+ a = MoveTo(iAbsPulse);
+ m_bIsSyncMove = true;
+ waitetime =200;
+ return a;
+}
+
+bool CVSMD12XControl::SetLogicZero()
+{
+ std::string strCMD = "org\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(200);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+bool CVSMD12XControl::StartBackZero()
+{
+ std::string strCMD = "zero start\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(200);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+
+ if (!ParseReturnedString(strRecv, -1))
+ {
+ return false;
+ }
+
+ bool bFlagIsStopped = false;
+ while (!bFlagIsStopped)
+ {
+ QThread::msleep(200);
+ GetStatus(m_stuMSInfo);
+ ZZ_U8 ucFlag = m_stuMSInfo.uiFlags & 0x000000FF;
+ ucFlag = ucFlag & 0x10;
+ if (ucFlag == 0x10 && m_stuMSInfo.fVelocity == 0)
+ {
+ bFlagIsStopped = true;
+ }
+ }
+ return true;
+// return ParseReturnedString(strRecv, -1);
+
+}
+
+bool CVSMD12XControl::StopBackZero()
+{
+ std::string strCMD = "zero stop\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(200);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+bool CVSMD12XControl::SetBaudRate(int iBaudRate)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg bdr=%d\n", iBaudRate);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+int CVSMD12XControl::GetBaudRate()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes= ParseReturnedParam(strRecv);
+ if (bRes=false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.bdr;
+ }
+}
+
+bool CVSMD12XControl::SetMicroSteps(int iMicroSteps)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg mcs=%d\n", iMicroSteps);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+int CVSMD12XControl::GetMicroSteps()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.mcs;
+ }
+}
+
+bool CVSMD12XControl::SetAccSpeed(float fAccSpd)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg acc=%f\n", fAccSpd);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+float CVSMD12XControl::GetAccSpeed()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.acc;
+ }
+}
+
+bool CVSMD12XControl::SetRunSpeed(float fRunSpeed)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg spd=%f\n", fRunSpeed);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+float CVSMD12XControl::GetRunSpeed()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.spd;
+ }
+}
+
+bool CVSMD12XControl::SetDecSpeed(float fDecSpeed)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg dec=%f\n", fDecSpeed);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+float CVSMD12XControl::GetDecSpeed()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.dec;
+ }
+}
+
+bool CVSMD12XControl::SetSpeed(float fRunSpeed, float fAccSpd, float fDecSpeed)
+{
+ char cmd[128];
+ sprintf_s(cmd, 128, "cfg spd=%f acc=%f dec=%f\n", fRunSpeed, fAccSpd, fDecSpeed);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+bool CVSMD12XControl::SetHoldCurrent(float fHoldCurrent)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg crh=%f\n", fHoldCurrent);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+float CVSMD12XControl::GetHoldCurrent()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.crh;
+ }
+}
+
+bool CVSMD12XControl::SetAccCurrent(float fAccCurrent)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg cra=%f\n", fAccCurrent);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+float CVSMD12XControl::GetAccCurrent()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.cra;
+ }
+}
+
+bool CVSMD12XControl::SetRunCurrent(float fRunCurrent)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg crn=%f\n", fRunCurrent);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+float CVSMD12XControl::GetRunCurrent()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.crn;
+ }
+}
+
+bool CVSMD12XControl::SetCurrent(float fAccCurrent, float fRunCurrent, float fHoldCurrent)
+{
+ char cmd[128];
+ sprintf_s(cmd, 128, "cfg cra=%f crn=%f crh=%f\n", fAccCurrent, fRunCurrent, fHoldCurrent);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+bool CVSMD12XControl::SetS1FETE(ZZ_U8 bS1FETE)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg s1f=%d\n", bS1FETE);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+ZZ_U8 CVSMD12XControl::GetS1FETE()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.s1f;
+ }
+}
+
+bool CVSMD12XControl::SetS1RETE(ZZ_U8 bS1RETE)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg s1r=%d\n", bS1RETE);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+ZZ_U8 CVSMD12XControl::GetS1RETE()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.s1r;
+ }
+}
+
+bool CVSMD12XControl::SetS2FETE(ZZ_U8 bS2FETE)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg s2f=%d\n", bS2FETE);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+ZZ_U8 CVSMD12XControl::GetS2FETE()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.s2f;
+ }
+}
+
+bool CVSMD12XControl::SetS2RETE(ZZ_U8 bS2RETE)
+{
+ char cmd[64];
+ sprintf_s(cmd, 64, "cfg s2r=%d\n", bS2RETE);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ return ParseReturnedString(strRecv, -1);
+}
+
+ZZ_U8 CVSMD12XControl::GetS2RETE()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.s2r;
+ }
+}
+
+bool CVSMD12XControl::SetZeroParams(ZZ_U8 bZeroMode, ZZ_U8 bSwitchOpenVL, ZZ_U8 bZeroSensor, float fZeroVelocity, int iSafePosition)
+{
+ char cmd[128];
+ sprintf_s(cmd, 128, "cfg zmd=%d osv=%d snr=%d zsd=%f zsp=%d\n",
+ (int)bZeroMode, (int)bSwitchOpenVL, (int)bZeroSensor, fZeroVelocity, iSafePosition);
+ std::string strCMD(cmd);
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(800);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+
+ return ParseReturnedString(strRecv, -1);
+}
+
+ZZ_U8 CVSMD12XControl::GetZeroMode()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.zmd;
+ }
+}
+
+ZZ_U8 CVSMD12XControl::GetSwitchOpenVoltageLevel()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.osv;
+ }
+}
+
+ZZ_U8 CVSMD12XControl::GetZeroSensor()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.snr;
+ }
+}
+
+int CVSMD12XControl::GetSafePosition()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.zsp;
+ }
+}
+
+float CVSMD12XControl::GetZeroVelocity()
+{
+ std::string strCMD = "cfg\n";
+
+ if (m_iProtocolType)
+ {
+ strCMD = m_strCID + strCMD;
+ }
+
+ int iRet = m_pAbsPort->Write(strCMD);
+
+ QThread::msleep(500);
+
+ std::string strRecv = m_pAbsPort->ReadAll();
+ bool bRes = ParseReturnedParam(strRecv);
+ if (bRes = false)
+ {
+ return -1;
+ }
+ else
+ {
+ return m_stuControllerParams.zsp;
+ }
+}
+
+bool CVSMD12XControl::ParseReturnedString(std::string &strRecv, int iType)
+{
+ char cHead =(char) 0xFF;
+ if (iType == -1)
+ {
+ if (strRecv[0]== cHead)
+ {
+ return true;
+ }
+ return false;
+ }
+ else if (iType == 0)
+ {
+ if (strRecv.size()<3)
+ {
+ return false;
+ }
+ strRecv.erase(0, 3);
+ strRecv.erase(strRecv.size() - 3, 3);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+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 ii = 0;
+ while (strRecv.size() < 2)
+ {
+
+ std::string strRecv1 = m_pAbsPort->ReadAll(20);
+ if (strRecv1.size() == 0)
+ {
+ return false;
+
+ }
+ strRecv = strRecv + strRecv1;
+ ii++;
+ if (ii == 2)
+ {
+ return false;
+
+ }
+ }
+ if (strRecv[2]==0x2)
+ {
+ //strRecv.erase(0, 3);
+ //strRecv.erase(strRecv.size() - 3, 3);
+ int i = 0;
+ int izero = 0;
+ while (strRecv.size() != 21)
+ {
+ std::string strRecv1 = "";
+ strRecv1 = m_pAbsPort->ReadAll(20);
+ if (strRecv1.size()==0)
+ {
+ return false;
+
+ }
+ strRecv = strRecv + strRecv1;
+ i++;
+ if (i==5)
+ {
+ return false;
+
+ }
+ if (strRecv.size() > 21)
+ {
+ return false;
+ }
+ //return false;
+ }
+ ZZ_U8 *pbRecv = (ZZ_U8*)strRecv.c_str();
+
+ VSMD_BitShift(&pbRecv[3], &m_unValue);
+ m_stuMSInfo.fVelocity = m_unValue.fValue;
+ VSMD_BitShift(&pbRecv[8], &m_unValue);
+ m_stuMSInfo.iPosition = m_unValue.i32Value;
+ VSMD_BitShift(&pbRecv[13], &m_unValue);
+ m_stuMSInfo.uiFlags = m_unValue.u32Value;
+
+ //delete pbRecv;
+ return true;
+ }
+ else if (strRecv[2] == 0x3)
+ {
+ strRecv[strRecv.size() - 3] = 0;
+ char* pcParam = ((char*)strRecv.c_str())+3;
+
+ while (pcParam)
+ {
+ char* pcNext = VSMD_Split(pcParam, ' ');
+ char* pcValueStr = VSMD_Split(pcParam, '=');
+
+ //
+ if (pcValueStr)
+ {
+ if (strcmp(pcParam, "bdr") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.bdr = iValue;
+ }
+ else if (strcmp(pcParam, "mcs") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.mcs = iValue;
+ }
+ else if (strcmp(pcParam, "spd") == 0)
+ {
+ float fValue = (float)atof(pcValueStr);
+ m_stuControllerParams.spd = fValue;
+ }
+ else if (strcmp(pcParam, "acc") == 0)
+ {
+ float fValue = (float)atof(pcValueStr);
+ m_stuControllerParams.acc = fValue;
+ }
+ else if (strcmp(pcParam, "dec") == 0)
+ {
+ float fValue = (float)atof(pcValueStr);
+ m_stuControllerParams.dec = fValue;
+ }
+ else if (strcmp(pcParam, "cra") == 0)
+ {
+ float fValue = (float)atof(pcValueStr);
+ m_stuControllerParams.cra = fValue;
+ }
+ else if (strcmp(pcParam, "crn") == 0)
+ {
+ float fValue = (float)atof(pcValueStr);
+ m_stuControllerParams.crn = fValue;
+ }
+ else if (strcmp(pcParam, "crh") == 0)
+ {
+ float fValue = (float)atof(pcValueStr);
+ m_stuControllerParams.crh = fValue;
+ }
+ else if (strcmp(pcParam, "s1f") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.s1f = iValue;
+ }
+ else if (strcmp(pcParam, "s1r") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.s1r = iValue;
+ }
+ else if (strcmp(pcParam, "s2f") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.s2f = iValue;
+ }
+ else if (strcmp(pcParam, "s2r") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.s2r = iValue;
+ }
+ else if (strcmp(pcParam, "zmd") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.zmd = iValue;
+ }
+ else if (strcmp(pcParam, "osv") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.osv = iValue;
+ }
+ else if (strcmp(pcParam, "snr") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.snr = iValue;
+ }
+ else if (strcmp(pcParam, "zsd") == 0)
+ {
+ float fValue = (float)atof(pcValueStr);
+ m_stuControllerParams.zsd = fValue;
+ }
+ else if (strcmp(pcParam, "zsp") == 0)
+ {
+ int iValue = atoi(pcValueStr);
+ m_stuControllerParams.zsp = iValue;
+ }
+
+ }
+ pcParam = pcNext;
+ }
+ return true;
+ }
+
+ return false;
+}
+
+void CVSMD12XControl::VSMD_BitShift(ZZ_U8* src, unValue* dst)
+{
+ if (src)
+ {
+ dst->u32Value = src[0];
+
+ dst->u32Value <<= 7;
+ dst->u32Value |= src[1];
+
+ dst->u32Value <<= 7;
+ dst->u32Value |= src[2];
+
+ dst->u32Value <<= 7;
+ dst->u32Value |= src[3];
+
+ dst->u32Value <<= 7;
+ dst->u32Value |= src[4];
+ }
+}
+
+char* CVSMD12XControl::VSMD_Split(char* cStr, char cSplit)
+{
+ if (cStr)
+ {
+ for (char* cPtr = cStr; *cPtr; cPtr++)
+ {
+ if (*cPtr == cSplit)
+ {
+ *cPtr = '\0';
+ cPtr++;
+ return cPtr;
+ }
+ }
+ }
+
+ return NULL;
+}
+
+// int CVSMD12XControl::add(int a, int b)
+// {
+// return a + b;
+// }
diff --git a/othersoft/shuttercali/source/LinearShutter/VSMD12XControl.h b/othersoft/shuttercali/source/LinearShutter/VSMD12XControl.h
new file mode 100644
index 0000000..46e6a5f
--- /dev/null
+++ b/othersoft/shuttercali/source/LinearShutter/VSMD12XControl.h
@@ -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 (-21474836472147483647)
+ bool MoveTo(int iAbsPulse);//absolute mode,pulse (-21474836472147483647)
+ bool Move_NoSyn(int iRelPulse); // relative move mode,pulse (-21474836472147483647)
+ bool MoveTo_NoSyn(int iAbsPulse);//absolute mode,pulse (-21474836472147483647)
+ 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 921600)
+ int GetBaudRate(); // -1:should retry;
+
+ bool SetMicroSteps(int iMicroSteps);//set micro steps (05)->(1/2/4/8/16/32)
+ int GetMicroSteps();
+
+ bool SetAccSpeed(float fAccSpd);//set acceleration speed in pulse (0 192000000)
+ float GetAccSpeed();
+
+ bool SetRunSpeed(float fRunSpeed);//set normal running speed in pulse (0 192000000)
+ float GetRunSpeed();
+
+ bool SetDecSpeed(float fDecSpeed);//set deceleration speed in pulse (0 192000000)
+ float GetDecSpeed();
+
+ bool SetSpeed(float fRunSpeed, float fAccSpd, float fDecSpeed);//see above three functions
+
+ bool SetHoldCurrent(float fHoldCurrent);//set hold current ( 0 8.0 )Amp? pay attention to your motor specification.
+ float GetHoldCurrent();
+
+ bool SetAccCurrent(float fAccCurrent);//set acceleration current ( 0 8.0 )Amp? pay attention to your motor specification.
+ float GetAccCurrent();
+
+ bool SetRunCurrent(float fRunCurrent);//set normal running current ( 0 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 -192000) 192000pulse)(SafePosition -2147483647) 2147483647)
+ 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);
+};
+
diff --git a/othersoft/shuttercali/source/LinearShutter/VSMD12XMiscDefines.h b/othersoft/shuttercali/source/LinearShutter/VSMD12XMiscDefines.h
new file mode 100644
index 0000000..92e2ac2
--- /dev/null
+++ b/othersoft/shuttercali/source/LinearShutter/VSMD12XMiscDefines.h
@@ -0,0 +1,108 @@
+#pragma once
+#include "ZZ_Types.h"
+#define MAXBUFFER 10240
+#include
+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.4;
+ crn = 0.6;
+
+ 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, //ֻ״̬λ S1 仯֪ͨ
+ ResetZeroPosition, //ԭλ
+ DecSpdStop, //ֹͣ
+ DecSpdStopRZP, //ֹֹͣͣԭλ
+ Stop, //ֹͣ
+ StopRZP, //ֹֹͣͣԭλ
+ RunningPosDirect, //תٶȣ
+ RunningNegDirect, //תٶȣ
+ OfflineModeOn, //ģʽ
+ OfflineModeOff //ģʽֹͣ
+};
+
diff --git a/othersoft/shuttercali/source/LinearShutter/ZZ_SeiralPort.cpp b/othersoft/shuttercali/source/LinearShutter/ZZ_SeiralPort.cpp
new file mode 100644
index 0000000..d5767ad
--- /dev/null
+++ b/othersoft/shuttercali/source/LinearShutter/ZZ_SeiralPort.cpp
@@ -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;iwrite(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();
+}
diff --git a/othersoft/shuttercali/source/LinearShutter/ZZ_SeiralPort.h b/othersoft/shuttercali/source/LinearShutter/ZZ_SeiralPort.h
new file mode 100644
index 0000000..5d7d0f4
--- /dev/null
+++ b/othersoft/shuttercali/source/LinearShutter/ZZ_SeiralPort.h
@@ -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);
+
+};
+
diff --git a/othersoft/shuttercali/source/LinearShutter/pch.h b/othersoft/shuttercali/source/LinearShutter/pch.h
new file mode 100644
index 0000000..d5ac3af
--- /dev/null
+++ b/othersoft/shuttercali/source/LinearShutter/pch.h
@@ -0,0 +1,28 @@
+#pragma once
+#include
+////////////////////////////setings
+#include
+#include
+////////////////////////////Basic
+#include
+#include
+#include
+#include
+#include
+////////////////////////////Thread
+#include
+#include
+#include
+////////////////////////////json
+#include
+#include
+#include
+#include
+#include
+////////////////////////////time
+#include
+#include
+#include
+////////////////////////////Serial I/O
+#include
+#include
\ No newline at end of file
diff --git a/othersoft/shuttercali/source/Logger/Logger.h b/othersoft/shuttercali/source/Logger/Logger.h
new file mode 100644
index 0000000..cfbcf02
--- /dev/null
+++ b/othersoft/shuttercali/source/Logger/Logger.h
@@ -0,0 +1,90 @@
+//
+// Created by xin on 2021/8/17.
+//edit by zz.
+//fixed code page problem;added a new initialize function; --20211101
+#pragma once
+
+#include
+#include
+#include
+#include "qmutex.h"
+#include "QtMsgHandler"
+
+namespace QT_LOG
+{
+ static int m_LogLevel = 1;
+ static QString m_LogFile = QString("%1.log").arg(QDateTime::currentDateTime().toString("yyyyMMddhhmmss"));
+ QMutex m_LogMutex;
+
+ void customMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
+ {
+ if (type < m_LogLevel)
+ {
+ return;
+ }
+
+ QString log_info;
+ switch (type)
+ {
+ case QtDebugMsg:
+ log_info = QString("%1:%2").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"),msg);
+ break;
+
+ case QtWarningMsg:
+ log_info = QString("%1[Warning]:%2").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"),msg);
+ break;
+
+ case QtCriticalMsg:
+ log_info = QString("%1[Critical]:%2").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"),msg);
+ break;
+
+ case QtFatalMsg:
+ log_info = QString("%1[Fatal]:%2").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"),msg);
+ abort();
+ }
+
+ m_LogMutex.lock();
+
+ QFile outFile(m_LogFile);
+ outFile.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text);
+ QTextStream ts(&outFile);
+ ts << log_info << endl;
+ outFile.close();
+
+ m_LogMutex.unlock();
+ }
+ void logInit(QString logFile = "",int logLevel = 0)
+ {
+
+#ifndef DEBUG
+ if ((logLevel < 0) || (logLevel > 3))
+ {
+ m_LogLevel = 1;
+ }
+ else
+ {
+ m_LogLevel = logLevel;
+ }
+
+ if (!logFile.isEmpty())
+ {
+ m_LogFile = logFile+"/"+m_LogFile;
+ }
+
+ qInstallMessageHandler(customMessageHandler);
+ //qInstallMsgHandler(customMessageHandler);
+#endif
+ }
+
+ //added by IRIS_ZZ initialize from main
+ void ZZ_InitLogger(QString qstrDir)
+ {
+ QDir qdLogFolder;
+ qdLogFolder.mkdir(qstrDir);
+ qDebug() << QT_LOG::m_LogFile;
+ QT_LOG::logInit(qstrDir);
+ }
+};
+
+
+
diff --git a/othersoft/shuttercali/source/OSIF/DLib/SeaBreeze.dll b/othersoft/shuttercali/source/OSIF/DLib/SeaBreeze.dll
new file mode 100644
index 0000000..66bc74c
Binary files /dev/null and b/othersoft/shuttercali/source/OSIF/DLib/SeaBreeze.dll differ
diff --git a/othersoft/shuttercali/source/OSIF/DLib/SeaBreeze.lib b/othersoft/shuttercali/source/OSIF/DLib/SeaBreeze.lib
new file mode 100644
index 0000000..9f5efa5
Binary files /dev/null and b/othersoft/shuttercali/source/OSIF/DLib/SeaBreeze.lib differ
diff --git a/othersoft/shuttercali/source/OSIF/include/api/DeviceFactory.h b/othersoft/shuttercali/source/OSIF/include/api/DeviceFactory.h
new file mode 100644
index 0000000..12fae61
--- /dev/null
+++ b/othersoft/shuttercali/source/OSIF/include/api/DeviceFactory.h
@@ -0,0 +1,63 @@
+/***************************************************//**
+ * @file DeviceFactory.h
+ * @date February 2012
+ * @author Ocean Optics, Inc.
+ *
+ * Notes:
+ *
+ * This class allows Device class instances to be created
+ * using just the name of the class as a string.
+ *
+ * LICENSE:
+ *
+ * SeaBreeze Copyright (C) 2014, Ocean Optics Inc
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject
+ * to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef SEABREEZE_DEVICE_FACTORY_H
+#define SEABREEZE_DEVICE_FACTORY_H
+
+#include
+#include