first commnit
This commit is contained in:
21
.gitignore
vendored
Normal file
21
.gitignore
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
################################################################################
|
||||
# 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。
|
||||
################################################################################
|
||||
|
||||
/build
|
||||
/.vs
|
||||
/build_d
|
||||
/html/.idea
|
||||
/out
|
||||
/cmake-build-debug/
|
||||
/.idea
|
||||
/othersoft/shuttercali/project/LocationCali/build/
|
||||
/Data/2022_01_11
|
||||
/othersoft/movingliner/build
|
||||
/othersoft/calibration_console/.idea/
|
||||
/othersoft/calibration_console/build/
|
||||
/othersoft/shuttercali/project/LocationCali/cmake-build-debug
|
||||
/othersoft/calibration_console/cmake-build-debug/
|
||||
/othersoft/movingliner/cmake-build-debug/
|
||||
/othersoft/movingliner/cmake-build-debug-toweris2/
|
||||
/othersoft/movingliner/cmake-build-release/
|
||||
42
CMakeLists.txt
Normal file
42
CMakeLists.txt
Normal file
@ -0,0 +1,42 @@
|
||||
cmake_minimum_required(VERSION 3.3)
|
||||
|
||||
project(TowerOptoSifAndSpectral_Tooling)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(QT Core 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")
|
||||
|
||||
include_directories("source")
|
||||
include_directories("source/FS")
|
||||
include_directories("source/Logger")
|
||||
include_directories("source/ZZ_SDK")
|
||||
include_directories("source/Settings")
|
||||
include_directories("source/CaptureThread")
|
||||
include_directories("source/LinearShutter")
|
||||
include_directories("source/OSIF/include")
|
||||
include_directories("source/Misc_Detector")
|
||||
include_directories("source/Uploader")
|
||||
|
||||
link_directories("source/OSIF/DLib")
|
||||
link_directories("/home/pi/SeaBrease/lib")
|
||||
add_executable( TowerOptoSifAndSpectral_Tooling
|
||||
main.cpp
|
||||
${HDR_LIST}
|
||||
${SRC_LIST}
|
||||
)
|
||||
IF (WIN32)
|
||||
target_link_libraries(TowerOptoSifAndSpectral_Tooling SeaBreeze)
|
||||
ELSE ()
|
||||
target_link_libraries(TowerOptoSifAndSpectral_Tooling seabreeze usb stdc++ m)
|
||||
ENDIF ()
|
||||
qt5_use_modules(TowerOptoSifAndSpectral_Tooling ${QT})
|
||||
set_target_properties(TowerOptoSifAndSpectral_Tooling PROPERTIES AUTOMOC ON)
|
||||
|
||||
|
||||
34
CMakeSettings.json
Normal file
34
CMakeSettings.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux-GCC-Debug",
|
||||
"generator": "Unix Makefiles",
|
||||
"configurationType": "Debug",
|
||||
"cmakeExecutable": "/opt/cmake/bin/cmake",
|
||||
"remoteCopySourcesExclusionList": [ ".vs", ".git", "out" ],
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": "",
|
||||
"inheritEnvironments": [ "linux_arm" ],
|
||||
"intelliSenseMode": "linux-gcc-x64",
|
||||
"remoteMachineName": "243120617;172.16.0.232 (username=root, port=22, authentication=Password)",
|
||||
"remoteCMakeListsRoot": "/home/pi/SIF0/src",
|
||||
"remoteBuildRoot": "/home/pi/SIF0/out/build_d/${name}",
|
||||
"remoteInstallRoot": "/home/pi/SIF0/out/install/${name}",
|
||||
"remoteCopySources": true,
|
||||
"rsyncCommandArgs": "-t --delete --delete-excluded",
|
||||
"remoteCopyBuildOutput": true,
|
||||
"remoteCopySourcesMethod": "rsync"
|
||||
},
|
||||
{
|
||||
"name": "x64-Debug",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Debug",
|
||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||
"cmakeCommandArgs": "",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": "",
|
||||
"inheritEnvironments": [ "msvc_x64_x64" ]
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
Cal/FS1_P1.dat
Normal file
BIN
Cal/FS1_P1.dat
Normal file
Binary file not shown.
BIN
Cal/FS1_P2.dat
Normal file
BIN
Cal/FS1_P2.dat
Normal file
Binary file not shown.
BIN
Cal/FS1_P3.dat
Normal file
BIN
Cal/FS1_P3.dat
Normal file
Binary file not shown.
BIN
Cal/FS1_P4.dat
Normal file
BIN
Cal/FS1_P4.dat
Normal file
Binary file not shown.
BIN
Cal/FS2_P1.dat
Normal file
BIN
Cal/FS2_P1.dat
Normal file
Binary file not shown.
BIN
Cal/FS2_P2.dat
Normal file
BIN
Cal/FS2_P2.dat
Normal file
Binary file not shown.
BIN
Cal/FS2_P3.dat
Normal file
BIN
Cal/FS2_P3.dat
Normal file
Binary file not shown.
BIN
Cal/FS2_P4.dat
Normal file
BIN
Cal/FS2_P4.dat
Normal file
Binary file not shown.
BIN
Data/2021_12_13.7z
Normal file
BIN
Data/2021_12_13.7z
Normal file
Binary file not shown.
9
Data/2022_01_14/beijing_16_36_46.csv
Normal file
9
Data/2022_01_14/beijing_16_36_46.csv
Normal file
File diff suppressed because one or more lines are too long
9
Data/2022_01_14/beijing_16_37_51.csv
Normal file
9
Data/2022_01_14/beijing_16_37_51.csv
Normal file
File diff suppressed because one or more lines are too long
9
Data/2022_01_14/beijing_16_38_01.csv
Normal file
9
Data/2022_01_14/beijing_16_38_01.csv
Normal file
File diff suppressed because one or more lines are too long
9
Data/2022_01_14/beijing_16_38_11.csv
Normal file
9
Data/2022_01_14/beijing_16_38_11.csv
Normal file
File diff suppressed because one or more lines are too long
0
Data/2022_01_14/beijing_16_40_17.csv
Normal file
0
Data/2022_01_14/beijing_16_40_17.csv
Normal file
|
|
9
Data/2022_01_17/beijing_11_25_44.csv
Normal file
9
Data/2022_01_17/beijing_11_25_44.csv
Normal file
File diff suppressed because one or more lines are too long
18
README.md
Normal file
18
README.md
Normal file
@ -0,0 +1,18 @@
|
||||
软件开发总则
|
||||
|
||||
项目管理工具:CMAKE
|
||||
|
||||
版本管理工具:Git 地址:http://xin@172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
|
||||
|
||||
备注:
|
||||
|
||||
多使用#ifdefine WIN32
|
||||
|
||||
源文件统一(除main.cpp)放入source文件
|
||||
|
||||
源文件要进行分类并新建文件夹
|
||||
|
||||
在文件包含上尽量少些嵌套 层次不要太多
|
||||
|
||||
|
||||
|
||||
61
UnSupported/ATPAbstractController.cpp
Normal file
61
UnSupported/ATPAbstractController.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
#include "ATPAbstractController.h"
|
||||
|
||||
ZZ_ATPAbsCtrlThread::ZZ_ATPAbsCtrlThread(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ZZ_ATPAbsCtrlThread::~ZZ_ATPAbsCtrlThread()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int ZZ_ATPAbsCtrlThread::InitializeFSControl()
|
||||
{
|
||||
qDebug() << "base class not implemented";
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPAbsCtrlThread::StartAcquisition()
|
||||
{
|
||||
qDebug() << "base class not implemented";
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPAbsCtrlThread::StopAcquisition()
|
||||
{
|
||||
qDebug() << "base class not implemented";
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// void ZZ_ATPAbsCtrlThread::SetWaitCondition(QWaitCondition *pFinish, QMutex *pMutex)
|
||||
// {
|
||||
// m_pwcFinish = pFinish;
|
||||
// m_pMutex = pMutex;
|
||||
// }
|
||||
|
||||
int ZZ_ATPAbsCtrlThread::StartTestAcquisition()
|
||||
{
|
||||
qDebug() << "base class not implemented";
|
||||
return 0;
|
||||
// m_bFlagIsCollecting = true;
|
||||
// while (m_bFlagIsCollecting)
|
||||
// {
|
||||
// //QMutexLocker locker(&m_Mutex);
|
||||
// QThread::msleep(1000);
|
||||
// qDebug() << "ThreadATPAbsController busy";
|
||||
// }
|
||||
// qDebug() << "ThreadATPAbsController quit";
|
||||
//
|
||||
// //m_pwcFinish->wakeAll();
|
||||
// emit SignalAcqFinished(0,1);
|
||||
}
|
||||
|
||||
int ZZ_ATPAbsCtrlThread::StopTestAcquisition()
|
||||
{
|
||||
qDebug() << "base class not implemented";
|
||||
return 0;
|
||||
//QMutexLocker locker(&m_Mutex);
|
||||
//m_bFlagIsCollecting = false;
|
||||
}
|
||||
38
UnSupported/ATPAbstractController.h
Normal file
38
UnSupported/ATPAbstractController.h
Normal file
@ -0,0 +1,38 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//ATP<54>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#include "ATPControl_Serial_QT.h"
|
||||
#include <atomic>
|
||||
|
||||
|
||||
class ZZ_ATPAbsCtrlThread :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
std::atomic<bool> m_bFlagIsCollecting;
|
||||
//QMutex *m_pMutex;
|
||||
//QWaitCondition *m_pwcFinish;
|
||||
public:
|
||||
ZZ_ATPAbsCtrlThread(QObject* parent = nullptr);
|
||||
virtual ~ZZ_ATPAbsCtrlThread();
|
||||
private:
|
||||
CIrisFSBase *m_pFSCtrl;
|
||||
//ZZ_ATPControl_Serial_Qt m_iSIFctrl;
|
||||
public slots:
|
||||
|
||||
//create derived class from base class
|
||||
virtual int InitializeFSControl();
|
||||
|
||||
virtual int StartAcquisition();
|
||||
virtual int StopAcquisition();
|
||||
|
||||
virtual int StartTestAcquisition();
|
||||
int StopTestAcquisition();
|
||||
|
||||
//virtual void SetWaitCondition(QWaitCondition *pFinish, QMutex *pMutex);
|
||||
signals:
|
||||
void SignalAcqStarted();
|
||||
void SignalAcqFinished(int iThreadID,int iFlagStatus);
|
||||
};
|
||||
165
UnSupported/ThreadDataGrabber.cpp
Normal file
165
UnSupported/ThreadDataGrabber.cpp
Normal file
@ -0,0 +1,165 @@
|
||||
#include "ThreadDataGrabber.h"
|
||||
|
||||
ZZ_DataGrabberThread::ZZ_DataGrabberThread(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
m_GrabTimer = new QTimer(this);
|
||||
m_bFlagIsCollecting = false;
|
||||
|
||||
|
||||
|
||||
ZZ_ATPAbsCtrlThread* m_p1 = new ZZ_iSIFControlThread;
|
||||
m_pControlThread.push_back(m_p1);
|
||||
ZZ_ATPAbsCtrlThread* m_p2 = new ZZ_IS1ControlThread;
|
||||
m_pControlThread.push_back(m_p2);
|
||||
//m_iTotalThreads = 2;
|
||||
|
||||
InitThreadStatus();
|
||||
SetupSignals();
|
||||
StartGrabberThread();
|
||||
}
|
||||
|
||||
ZZ_DataGrabberThread::~ZZ_DataGrabberThread()
|
||||
{
|
||||
if (m_piFlagCaptureThreadStatus!=NULL)
|
||||
{
|
||||
delete m_piFlagCaptureThreadStatus;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ZZ_DataGrabberThread::SetGrabTimer(AcqTimeSettings struAcqTimer)
|
||||
{
|
||||
m_struAcqTime = struAcqTimer;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::SetupSignals()
|
||||
{
|
||||
connect(m_GrabTimer, &QTimer::timeout, this, &ZZ_DataGrabberThread::OnTimeCounter);
|
||||
|
||||
connect(this, &ZZ_DataGrabberThread::SignalStartGrab, this, &ZZ_DataGrabberThread::StartGrab);
|
||||
|
||||
//connect(this, &ZZ_DataGrabberThread::SignalStartGrabOnce, &m_tcISIFCtrlThread, &ZZ_ATPAbsCtrlThread::StartTestAcquisition);
|
||||
//connect(this, &ZZ_DataGrabberThread::SignalStartGrabOnce, &m_tcIS1CtrlThread, &ZZ_ATPAbsCtrlThread::StartTestAcquisition);
|
||||
|
||||
connect(this, &ZZ_DataGrabberThread::SignalStartGrabOnce, m_pControlThread[0], &ZZ_ATPAbsCtrlThread::StartTestAcquisition);
|
||||
connect(this, &ZZ_DataGrabberThread::SignalStartGrabOnce, m_pControlThread[1], &ZZ_ATPAbsCtrlThread::StartTestAcquisition);
|
||||
|
||||
//connect(this, &ZZ_DataGrabberThread::SignalStopGrab, &m_tcISIFCtrlThread, &ZZ_iSIFControlThread::StopTestAcquisition, Qt::DirectConnection);
|
||||
//connect(this, &ZZ_DataGrabberThread::SignalStopGrab, &m_tcIS1CtrlThread, &ZZ_IS1ControlThread::StopTestAcquisition, Qt::DirectConnection);
|
||||
|
||||
//connect(&m_tcISIFCtrlThread, &ZZ_iSIFControlThread::SignalAcqFinished, this, &ZZ_DataGrabberThread::HandleThreadEvent);
|
||||
//connect(&m_tcIS1CtrlThread, &ZZ_IS1ControlThread::SignalAcqFinished, this, &ZZ_DataGrabberThread::HandleThreadEvent);
|
||||
|
||||
connect(m_pControlThread[0], &ZZ_ATPAbsCtrlThread::SignalAcqFinished, this, &ZZ_DataGrabberThread::HandleThreadEvent);
|
||||
connect(m_pControlThread[1], &ZZ_ATPAbsCtrlThread::SignalAcqFinished, this, &ZZ_DataGrabberThread::HandleThreadEvent);
|
||||
|
||||
connect(this, &ZZ_DataGrabberThread::SignalGrabOnceFinished, this, &ZZ_DataGrabberThread::TestGrabOnce);
|
||||
//m_tcISIFCtrlThread.SetWaitCondition(&m_wcWaitISIF,&m_mTestMutex);
|
||||
//m_tcIS1CtrlThread.SetWaitCondition(&m_wcWaitIS1, &m_mTestMutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::StartGrabCall()
|
||||
{
|
||||
emit SignalStartGrab();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::StartGrab()
|
||||
{
|
||||
m_GrabTimer->start(1000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::StartGrabberThread()
|
||||
{
|
||||
// m_pqISIFThreadHolder = new QThread();
|
||||
// m_tcISIFCtrlThread.moveToThread(m_pqISIFThreadHolder);
|
||||
// m_pqISIFThreadHolder->start();
|
||||
//
|
||||
// m_pqIS1ThreadHolder = new QThread();
|
||||
// m_tcIS1CtrlThread.moveToThread(m_pqIS1ThreadHolder);
|
||||
// m_pqIS1ThreadHolder->start();
|
||||
|
||||
|
||||
m_pqISIFThreadHolder = new QThread();
|
||||
m_pControlThread[0]->moveToThread(m_pqISIFThreadHolder);
|
||||
m_pqISIFThreadHolder->start();
|
||||
|
||||
m_pqIS1ThreadHolder = new QThread();
|
||||
m_pControlThread[1]->moveToThread(m_pqIS1ThreadHolder);
|
||||
m_pqIS1ThreadHolder->start();
|
||||
//m_stCameraServiceThread.SetController(this);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::InitThreadStatus()
|
||||
{
|
||||
m_piFlagCaptureThreadStatus = new int[m_iTotalThreads];
|
||||
for (int i=0;i< m_iTotalThreads;i++)
|
||||
{
|
||||
m_piFlagCaptureThreadStatus[i] = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::TestGrab()
|
||||
{
|
||||
m_bFlagIsCollecting = true;
|
||||
while (m_bFlagIsCollecting)
|
||||
{
|
||||
|
||||
emit SignalStartGrabOnce();
|
||||
//m_mTestMutex.lock();
|
||||
//m_wcWaitISIF.wait(&m_mTestMutex);
|
||||
//m_mTestMutex.lock();
|
||||
//m_wcWaitIS1.wait(&m_mTestMutex);
|
||||
//m_mTestMutex.unlock();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::TestGrabOnce()
|
||||
{
|
||||
InitThreadStatus();
|
||||
emit SignalStartGrabOnce();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::TestStopGrab()
|
||||
{
|
||||
//emit SignalStopGrab();
|
||||
m_tcISIFCtrlThread.StopTestAcquisition();
|
||||
m_tcIS1CtrlThread.StopTestAcquisition();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::HandleThreadEvent(int iThreadID, int iFlagStatus)
|
||||
{
|
||||
m_piFlagCaptureThreadStatus[iThreadID] = iFlagStatus;
|
||||
|
||||
bool bFinished = true;
|
||||
for (int i = 0; i < m_iTotalThreads; i++)
|
||||
{
|
||||
if (m_piFlagCaptureThreadStatus[i] != 1)
|
||||
{
|
||||
bFinished = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bFinished)
|
||||
{
|
||||
emit SignalGrabOnceFinished();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_DataGrabberThread::OnTimeCounter()
|
||||
{
|
||||
qDebug() << "OnTimeCounter";
|
||||
return 0;
|
||||
}
|
||||
55
UnSupported/ThreadDataGrabber.h
Normal file
55
UnSupported/ThreadDataGrabber.h
Normal file
@ -0,0 +1,55 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//<2F><><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
#include"pch.h"
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||
class ZZ_DataGrabberThread :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ZZ_DataGrabberThread(QObject* parent = nullptr);
|
||||
~ZZ_DataGrabberThread();
|
||||
|
||||
public:
|
||||
//QWaitCondition m_wcWaitISIF,m_wcWaitIS1;
|
||||
//QMutex m_mTestMutex;
|
||||
private:
|
||||
vector<ZZ_ATPAbsCtrlThread *> m_pControlThread;
|
||||
|
||||
//ZZ_iSIFControlThread m_tcISIFCtrlThread;
|
||||
//ZZ_IS1ControlThread m_tcIS1CtrlThread;
|
||||
QThread* m_pqISIFThreadHolder;
|
||||
QThread* m_pqIS1ThreadHolder;
|
||||
|
||||
std::atomic<bool> m_bFlagIsCollecting;
|
||||
std::atomic<bool> m_bFlagIsCollectingFinished;
|
||||
int *m_piFlagCaptureThreadStatus;
|
||||
const int m_iTotalThreads = 2;
|
||||
|
||||
QTimer *m_GrabTimer;
|
||||
AcqTimeSettings m_struAcqTime;
|
||||
public:
|
||||
void SetGrabTimer(AcqTimeSettings struAcqTimer);
|
||||
|
||||
int SetupSignals();
|
||||
int StartGrabCall();
|
||||
|
||||
private:
|
||||
int OnTimeCounter();
|
||||
int InitThreadStatus();
|
||||
int StartGrabberThread();
|
||||
public slots:
|
||||
int TestGrab();
|
||||
int TestGrabOnce();
|
||||
int TestStopGrab();
|
||||
int HandleThreadEvent(int iThreadID, int iFlagStatus);
|
||||
int StartGrab();
|
||||
signals:
|
||||
void SignalStartGrabOnce();
|
||||
void SignalStopGrab();
|
||||
void SignalGrabOnceFinished();
|
||||
void SignalStartGrab();
|
||||
};
|
||||
31
UnSupported/ThreadIS1Controller.cpp
Normal file
31
UnSupported/ThreadIS1Controller.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include "ThreadIS1Controller.h"
|
||||
|
||||
ZZ_IS1ControlThread::ZZ_IS1ControlThread(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ZZ_IS1ControlThread::~ZZ_IS1ControlThread()
|
||||
{
|
||||
}
|
||||
|
||||
int ZZ_IS1ControlThread::StartTestAcquisition()
|
||||
{
|
||||
// m_bFlagIsCollecting = true;
|
||||
// while (m_bFlagIsCollecting)
|
||||
// {
|
||||
// //QMutexLocker locker(&m_Mutex);
|
||||
// QThread::msleep(1000);
|
||||
// qDebug() << "ThreadIS1Controller busy";
|
||||
// }
|
||||
// qDebug() << "ThreadIS1Controller quit";
|
||||
|
||||
qDebug() << "ThreadIS1Controller busy";
|
||||
QThread::msleep(1000);
|
||||
qDebug() << "ThreadIS1Controller quit";
|
||||
|
||||
//m_pwcFinish->wakeAll();
|
||||
emit SignalAcqFinished(1,1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
14
UnSupported/ThreadIS1Controller.h
Normal file
14
UnSupported/ThreadIS1Controller.h
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "ATPAbstractController.h"
|
||||
|
||||
class ZZ_IS1ControlThread :public ZZ_ATPAbsCtrlThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ZZ_IS1ControlThread(QObject* parent = nullptr);
|
||||
~ZZ_IS1ControlThread();
|
||||
private:
|
||||
public slots:
|
||||
int StartTestAcquisition();
|
||||
signals:
|
||||
};
|
||||
1
UnSupported/ThreadOSIFAController.cpp
Normal file
1
UnSupported/ThreadOSIFAController.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "ThreadOSIFAController.h"
|
||||
12
UnSupported/ThreadOSIFAController.h
Normal file
12
UnSupported/ThreadOSIFAController.h
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include "ATPAbstractController.h"
|
||||
|
||||
|
||||
class ZZ_OSIFAControlThread :public ZZ_ATPAbsCtrlThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ZZ_OSIFAControlThread(QObject* parent = nullptr);
|
||||
~ZZ_OSIFAControlThread();
|
||||
public slots:
|
||||
};
|
||||
1
UnSupported/ThreadOSIFBController.cpp
Normal file
1
UnSupported/ThreadOSIFBController.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "ThreadOSIFBController.h"
|
||||
11
UnSupported/ThreadOSIFBController.h
Normal file
11
UnSupported/ThreadOSIFBController.h
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include "ATPAbstractController.h"
|
||||
|
||||
class ZZ_OSIFBControlThread :public ZZ_ATPAbsCtrlThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ZZ_OSIFBControlThread(QObject* parent = nullptr);
|
||||
~ZZ_OSIFBControlThread();
|
||||
public slots:
|
||||
};
|
||||
37
UnSupported/ThreadiSIFController.cpp
Normal file
37
UnSupported/ThreadiSIFController.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include "ThreadiSIFController.h"
|
||||
|
||||
ZZ_iSIFControlThread::ZZ_iSIFControlThread(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
ZZ_iSIFControlThread::~ZZ_iSIFControlThread()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int ZZ_iSIFControlThread::test()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_iSIFControlThread::StartTestAcquisition()
|
||||
{
|
||||
// m_bFlagIsCollecting = true;
|
||||
// while (m_bFlagIsCollecting)
|
||||
// {
|
||||
// //QMutexLocker locker(&m_Mutex);
|
||||
// QThread::msleep(1000);
|
||||
// qDebug() << "ThreadiSIFController busy";
|
||||
// }
|
||||
// qDebug() << "ThreadiSIFController quit";
|
||||
|
||||
qDebug() << "ThreadiSIFController busy";
|
||||
QThread::msleep(2000);
|
||||
qDebug() << "ThreadiSIFController quit";
|
||||
|
||||
//m_pwcFinish->wakeAll();
|
||||
emit SignalAcqFinished(0,1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
18
UnSupported/ThreadiSIFController.h
Normal file
18
UnSupported/ThreadiSIFController.h
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include "ATPAbstractController.h"
|
||||
|
||||
|
||||
|
||||
class ZZ_iSIFControlThread :public ZZ_ATPAbsCtrlThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
private:
|
||||
public:
|
||||
ZZ_iSIFControlThread(QObject* parent = nullptr);
|
||||
~ZZ_iSIFControlThread();
|
||||
public slots:
|
||||
int StartTestAcquisition();
|
||||
int test();//
|
||||
};
|
||||
38
config/DeviceSettings.ini
Normal file
38
config/DeviceSettings.ini
Normal file
@ -0,0 +1,38 @@
|
||||
[DEVICE INFO]
|
||||
TotalSpectrometer=1
|
||||
[FS1]
|
||||
Model=ISIF
|
||||
Port=COM7
|
||||
UID=21351029
|
||||
AEMax=0.85
|
||||
AEMin=0.75
|
||||
Depth=65535
|
||||
[FS2]
|
||||
Model=OSIFBeta
|
||||
Port=-1
|
||||
UID=QEP02975
|
||||
AEMax=0.85
|
||||
AEMin=0.75
|
||||
Depth=230000
|
||||
[FS3]
|
||||
Model=Null
|
||||
[FS4]
|
||||
Model=OSIFAlpha
|
||||
Port=-1
|
||||
UID=FLMS15815
|
||||
AEMax=0.85
|
||||
AEMin=0.75
|
||||
Depth=65535
|
||||
[LINEAR SHUTTER]
|
||||
Port=COM8
|
||||
Type=1
|
||||
DCID=1
|
||||
TotalPosition=5
|
||||
Position0=2000
|
||||
Position1=110000
|
||||
Position2=220000
|
||||
Position3=330000
|
||||
Position4=440000
|
||||
Position5=550000
|
||||
[HUMITURE]
|
||||
Port=COM11
|
||||
0
config/SystemSettings.ini
Normal file
0
config/SystemSettings.ini
Normal file
1
config/config.json
Normal file
1
config/config.json
Normal file
@ -0,0 +1 @@
|
||||
{"BeginTime":"08:00","IntervalTime":"02","EndTime":"23:00","Dev_SN":"0000001","Location":"beijing","GPS_North":"on","GPS_Longtitude":"117","GPS_Latitude":"41","GPS_Altitude":"100","InstallationTime":"2021-12-24","ISIFCalibrationTime":"2021-12-24","IS1CalibrationTime":"2021-12-24","NameOfMaintenanceStaff":"renlixin","PhoneNumberOfMaintenanceStaff":"1110010010","DownloadUserID":"xin","DownlaodAddress":"http:\/\/www.iris-rs.cn","HTTPServer":"http:\/\/82.156.1.111","OSIFAlpha_CaliFileMainName":""}
|
||||
20
config/isif+is1/DeviceSettings.ini
Normal file
20
config/isif+is1/DeviceSettings.ini
Normal file
@ -0,0 +1,20 @@
|
||||
[DEVICE INFO]
|
||||
TotalSpectrometer=2
|
||||
[FS1]
|
||||
Model=ISIF
|
||||
Port=2
|
||||
DUID=test1
|
||||
[FS2]
|
||||
Model=IS1
|
||||
Port=3
|
||||
DUID=test2
|
||||
[LINEAR SHUTTER]
|
||||
Port=4
|
||||
Type=0
|
||||
DCID=1
|
||||
TotalPosition=5
|
||||
Position0=0
|
||||
Position1=200000
|
||||
Position2=300000
|
||||
Position3=400000
|
||||
Position4=500000
|
||||
70
document/20211105会议记录.md
Normal file
70
document/20211105会议记录.md
Normal file
@ -0,0 +1,70 @@
|
||||
# 20211105会议记录
|
||||
|
||||
参会人员:任立新 韩善龍 张卓
|
||||
|
||||
1. **文件名称定义**
|
||||
|
||||
英文地名_起始时间_结束时间 精确到秒 时间 年_月_日_时_分_秒
|
||||
|
||||
2. **路径定义**
|
||||
|
||||
```
|
||||
总路径 /home/data
|
||||
/Setting
|
||||
/Data
|
||||
/2021_10_15
|
||||
/Beijing_2021_10_15_15_31_00_2021_10_15_15_31_50.csv
|
||||
/2021_10_16
|
||||
/Log
|
||||
其他
|
||||
```
|
||||
|
||||
3. **数据内容确定**
|
||||
|
||||
```
|
||||
按照《SIF加地物光谱仪本地数据存储格式说明.pdf》存储
|
||||
```
|
||||
|
||||
4. **shutter切换顺序**
|
||||
|
||||
```
|
||||
U1->D1->D2->D3 U1是向上光纤 D1、D2、D3由用户定义
|
||||
```
|
||||
|
||||
5. **自动曝光上限及方式**
|
||||
|
||||
```
|
||||
上限:40秒
|
||||
IS1曝光完成后 等待ISIF自动曝光
|
||||
不采用比值法推算ISIF曝光时间
|
||||
```
|
||||
|
||||
6. **数据采集流程**
|
||||
|
||||
```
|
||||
自动曝光->暗电流->采集数据
|
||||
执行过程中 IS1需要等待ISIF往常当前步骤 在执行下一操作
|
||||
```
|
||||
|
||||
7. **异常报警**
|
||||
|
||||
```
|
||||
以下情况需要推送异常
|
||||
1、不返回数据
|
||||
2、TEC温度异常
|
||||
3、快门异常(开机15分内检测 通过IS1来检测)
|
||||
4、机箱温湿度异常报警
|
||||
推送方式 http (本地log中也需体现)
|
||||
```
|
||||
|
||||
8. **采集时间间隔**
|
||||
|
||||
```
|
||||
采用间隔法 采集间隔最小30分钟
|
||||
```
|
||||
|
||||
9. **添加温湿度传感器**
|
||||
|
||||
```
|
||||
添加温湿度传感器
|
||||
```
|
||||
117
document/20211123 研发会议记录.md
Normal file
117
document/20211123 研发会议记录.md
Normal file
@ -0,0 +1,117 @@
|
||||
# 20211123 研发会议记录
|
||||
|
||||
*参会人员:任立新 韩善龍 张卓 唐超*
|
||||
|
||||
##### 名称确认
|
||||
|
||||
海洋光学系列
|
||||
|
||||
1. OSIF_α :QEPro
|
||||
|
||||
2. OSIF_β :QE6500
|
||||
|
||||
奥普天成
|
||||
|
||||
1. ISIF : ATP6500
|
||||
|
||||
2. IS1 : ATP1010
|
||||
|
||||
3. IS2 : ATP5020
|
||||
|
||||
应用平台
|
||||
|
||||
1. 塔上平台
|
||||
|
||||
2. 便携式
|
||||
|
||||
快门
|
||||
|
||||
1. 双通道光闸
|
||||
|
||||
2. 多通道光闸
|
||||
|
||||
光纤
|
||||
|
||||
1. 一分二熔接光纤
|
||||
- 50:50
|
||||
|
||||
- 75:25
|
||||
|
||||
- 90:10
|
||||
2. 单芯光纤
|
||||
- 200um
|
||||
- 400um
|
||||
- 1000um
|
||||
|
||||
|
||||
##### 项目基本情况介绍
|
||||
|
||||
两个系统
|
||||
|
||||
- ISIF+IS1+多通道光闸+光纤+塔上系统
|
||||
- OSIF++多通道光闸+光纤+塔上系统
|
||||
|
||||
张负责ISIF+IS1系统及控制的实现
|
||||
|
||||
唐负责OSIF基础类的编写
|
||||
|
||||
##### 4
|
||||
|
||||
0为暗背景
|
||||
|
||||
1为向上
|
||||
|
||||
##### 唐超与张卓初步确认了传感基类的具体接口 会后深入讨论
|
||||
|
||||
```c++
|
||||
class CIrisFSBase
|
||||
{
|
||||
public:
|
||||
//CIrisFSBase();
|
||||
//virtual ~CIrisFSBase()= 0;
|
||||
public:
|
||||
//初始化设备
|
||||
//此处string为指明连接哪个ocean光谱仪的参数,可自行更换为其他c/c++标准类型
|
||||
//0为无错误,不同错误请返回不同值
|
||||
virtual int Initialize(bool bIsUSBMode,ZZ_U8 ucPortNumber,std::string) = 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;
|
||||
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
|
||||
##### 张卓重新规划下整体框架
|
||||
|
||||
##### 快门控制从传感器Class移除,放置到控制Class中
|
||||
|
||||
##### 不实现便携式SIF逻辑
|
||||
|
||||
##### 不实现双通道shutter
|
||||
|
||||
##### 光纤名称改为0,1,2,3,
|
||||
|
||||
|
||||
181
document/SIF加地物光谱仪本地数据存储格式说明.md
Normal file
181
document/SIF加地物光谱仪本地数据存储格式说明.md
Normal file
@ -0,0 +1,181 @@
|
||||
# SIF加地物光谱仪本地数据存储格式说明
|
||||
|
||||
注意:本文仅对存储内容进行说明 文件名称及存储路径策略另行讨论
|
||||
|
||||
本次存储的文件以CSV格式存储 逗号分隔值(Comma-Separated Values,CSV,有时也称为字符分隔值,因为分隔字符也可以不是逗号),其文件以纯文本形式存储表格数据(数字和文本)。纯文本意味着该文件是一个字符序列,不含必须像二进制数字那样被解读的数据。CSV文件由任意数目的记录组成,记录间以某种换行符分隔;每条记录由字段组成,字段间的分隔符是其它字符或字符串,最常见的是逗号或制表符。通常,所有记录都有完全相同的字段序列。通常都是纯文本文件。
|
||||
|
||||
数据分为数据区域与数据描述区
|
||||
|
||||
# 一 数据描述区
|
||||
|
||||
即元数据 元数据(Metadata),又称中介数据、中继数据,为描述数据的数据(data about data),主要是描述数据属性。本设备元数据主要包含以下六部分内容
|
||||
|
||||
**红色为配置文件给出 蓝色存疑**
|
||||
|
||||
## 1.1、环境信息
|
||||
|
||||
包括自然环境与人工环境
|
||||
|
||||
### 自然环境信息
|
||||
|
||||
**时间信息**:主要记录数据开始采集时间,时间信息统一采用UTC时间 格林威治时间。世界统一时间、世界标准时间、国际协调时间、世界协调时间,UTC协调世界时即格林威治平太阳时间,是指格林威治所在地的标准时间,也是表示地球自转速率的一种形式,UTC基于国际原子时间,通过不规则的加入闰秒来抵消地球自转变慢的影响,是世界上调节时钟和时间的主要时间标准。其中年月日中间以下划线“_”(英文输入法 ASCII 95)分割。其中年用4位数表示,月和日均两位,如下所示
|
||||
|
||||
XXXX_XX_XX
|
||||
|
||||
时间采取24小时制,时间中间以冒号“:”分割,均以两位填充,不足两位补零格式如下
|
||||
|
||||
XX:XX:XX
|
||||
|
||||
年与时间中间以空格分开最终格式如下所示
|
||||
|
||||
XXXX_XX_XX XX:XX:XX
|
||||
|
||||
**<font color='red'>地点:</font>**设备所处的行政范围 具体到乡。一个设备应该对应唯一地点,一个地点可以对应多个设备
|
||||
|
||||
名称中不应出现中文、“*”、“,“、”/“、”#“等特殊符号,每一级首字母应该大写 其他字母采用小写。级与级之间应该以下划线为分割 如下 XXXX省XXXXXX市XXXXX县XXXXX乡如果有缺级,则直接省略
|
||||
|
||||
**温度**:设备采集时的机箱温度,采用摄氏度。小数点保存两位
|
||||
|
||||
**湿度:**设备采集时的机箱湿度。 两位有效数字
|
||||
|
||||
**<font color='red'>GPS_longtitude</font>**:数据所在位置的GPS坐标的经度值,GPS采用WGS84坐标 小数点个数后8位。
|
||||
|
||||
**<font color='red'>GPS_Latitude</font>:** 数据所在位置的GPS坐标的纬度值,GPS采用WGS84坐标,数据保留小数点后8位
|
||||
|
||||
**<font color='red'>GPS_半球</font>**:设备所在地球半球位置 其中N表示北半球 S表示南半球
|
||||
|
||||
**<font color='red'>GPS_高程</font>**:设备的海拔高度 属于相对搞成
|
||||
|
||||
**<font color='red'>高程坐标系统</font>:**高程的系统。
|
||||
|
||||
**<font color='cornflowerblue'>降雨:</font>**设备采集数据时是否有下雨发生
|
||||
|
||||
**<font color='cornflowerblue'>风速</font>**:设备采集时的风速
|
||||
|
||||
*注意:上述顺序不代表数据存储数据,数据以键 值进行存储,在读取时应进行键值判断。*
|
||||
|
||||
### 人工环境
|
||||
|
||||
**数据存储名称**:设备采集时存储文件的名称 防止用户后期修改文件名时无法找到对应的文件名称
|
||||
|
||||
**<font color='red'>设备安装时间</font>:**设备安装日期 格式与时间信息一致
|
||||
|
||||
**<font color='red'>ISIF定标时间</font>:**设备1定标时间 格式与时间信息一致
|
||||
|
||||
**<font color='red'>设备2定标时间</font>:**设备2定标时间 格式与时间信息一致
|
||||
|
||||
**<font color='red'>设备维护人员姓名</font>**:设备维护人员名称
|
||||
|
||||
**<font color='red'>设维护人员电话</font>**:设备维护人员电话
|
||||
|
||||
**<font color='red'>远程资源用户id</font>**:公司会将设备必要的文件存储至云上,届时用户可以通过网络对数据进行下载
|
||||
|
||||
**<font color='red'>定标文件下载路径</font>**:云服务的路径
|
||||
|
||||
*注意:上述顺序不代表数据存储数据,数据以键 值进行存储,在读取时应进行键值判断。*
|
||||
|
||||
## 1.2、ISIF设备信息
|
||||
|
||||
**设备序列号:**ISIF出厂序列号 由设备厂商出具
|
||||
|
||||
**产品序列号:**由IRIS确定的序列号,格式为型号-序列号 如ISIF-101
|
||||
|
||||
**向上光纤U1曝光时间(shutter1)**单位毫秒 整型
|
||||
|
||||
**向下光纤D1曝光时间(shutter2):**单位毫秒 整型
|
||||
|
||||
**向下光纤D2曝光时间(shutter3):**单位毫秒 整型
|
||||
|
||||
**向下光纤D3曝光时间(shutter4):**单位毫秒 整型
|
||||
|
||||
**波段数量:**设备波段个数
|
||||
|
||||
**向上定标文件名**:向上光纤ISIF设备的定标文件名称
|
||||
|
||||
**向下定标文件名1**:向下光纤1 加ISIF设备定标文件名称
|
||||
|
||||
**向下定标文件名2:**向下光纤2 加ISIF设备定标文件名称
|
||||
|
||||
**向下定标文件名3:**向下光纤3 加ISIF设备定标文件名称
|
||||
|
||||
**向上测量时TEC温度:**单位摄氏度 保留一位小数
|
||||
|
||||
**向下测量1时TEC温度:**单位摄氏度 保留一位小数
|
||||
|
||||
**向下测量2时TEC温度:**单位摄氏度 保留一位小数
|
||||
|
||||
**向下测量3时TEC温度:**单位摄氏度 保留一位小数
|
||||
|
||||
**....** : ....
|
||||
|
||||
## 1.3、ISIF波长数据
|
||||
|
||||
**ISIF设备的波长文件:**波长数据,采用两位有效数字
|
||||
|
||||
## 1.4、IS1设备信息
|
||||
|
||||
**IS1设备序列号:**光谱设备出厂序列号 由设备厂商出具
|
||||
|
||||
**IS1产品序列号:**由IRIS确定的序列号,格式为型号-序列号
|
||||
|
||||
**向上光纤U1曝光时间(shutter1):**单位毫秒 整型
|
||||
|
||||
**向下光纤D1曝光时间(shutter2):**单位毫秒 整型
|
||||
|
||||
**向下光纤D2曝光时间(shutter3):**单位毫秒 整型
|
||||
|
||||
**向下光纤D3曝光时间(shutter4):**单位毫秒 整型
|
||||
|
||||
**波段数量:**设备波段个数
|
||||
|
||||
**向上定标文件名**:向上光纤ISIF设备的定标文件名称
|
||||
|
||||
**向下定标文件名1**:向下光纤1 加ISIF设备定标文件名称
|
||||
|
||||
**向下定标文件名2:**向下光纤2 加ISIF设备定标文件名称
|
||||
|
||||
**向下定标文件名3:**向下光纤3 加ISIF设备定标文件名称
|
||||
|
||||
**向上测量时TEC温度:**单位摄氏度 保留一位小数
|
||||
|
||||
**向下测量1时TEC温度:**单位摄氏度 保留一位小数
|
||||
|
||||
**向下测量2时TEC温度:**单位摄氏度 保留一位小数
|
||||
|
||||
**向下测量3时TEC温度:**单位摄氏度 保留一位小数
|
||||
|
||||
**....** : ....
|
||||
|
||||
## 1.5、IS1波长数据
|
||||
|
||||
**光谱设备的波长文件** :波长数据,采用两位有效数字
|
||||
|
||||
# 二 数据区
|
||||
|
||||
<font color='red'>规则:</font>
|
||||
|
||||
1. 光纤明明为P1,P2,P3,P4
|
||||
2. <font color='red'>数据存储按行来 一行数据存储</font>
|
||||
3. <font color='red'>单行数据中第一列为数据名称 名称按第一条规则定义</font>
|
||||
4. <font color='red'>第二列数据为数据状态表示 valid有效 invalid表示无效</font>
|
||||
5. <font color='red'>单行数据中从第三列开始为数据 数据采用整形存储</font>
|
||||
|
||||
## 三 数据展示
|
||||
|
||||
```csv
|
||||
TotalSpectrometer,2
|
||||
environmental factor,Date,XXXX_XX_XX XX:XX:XX,Location,Beijing_Haidian
|
||||
Device1_Info,Modle,ISIF,SN,10085,......
|
||||
wavelenth,300.00,301.00,.........
|
||||
Device2_Info,Modle,IS1,SN,10085,......
|
||||
wavelenth,300.00,301.00,.........
|
||||
Data_Start
|
||||
Device1_P1,valid,shuttertime,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
|
||||
Device1_P2,valid,shuttertime,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
|
||||
Device1_P3,valid,shuttertime,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
|
||||
Device1_P4,valid,shuttertime,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
|
||||
Device2_P1,valid,shuttertime,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
|
||||
Device2_P2,valid,shuttertime,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
|
||||
Device2_P3,valid,shuttertime,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
|
||||
Device2_P4,valid,shuttertime,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
|
||||
```
|
||||
13
document/sample.csv
Normal file
13
document/sample.csv
Normal file
@ -0,0 +1,13 @@
|
||||
环境信息,时间,年月日时分秒,地点,名称,,,,,,,,,,,,,,,
|
||||
设备1信息,id,10085,曝光时间,100ms,,,,,,,,,,,,,,,
|
||||
设备波长,,,,,,,,,,,,,,,,,,,
|
||||
设备2信息,id,10085,曝光时间,100ms,,,,,,,,,,,,,,,
|
||||
设备波长,,,,,,,,,,,,,,,,,,,
|
||||
数据名称1,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
|
||||
数据名称2,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
|
||||
数据名称3,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
|
||||
数据名称4,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
|
||||
数据名称5,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
|
||||
数据名称6,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
|
||||
数据名称7,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
|
||||
数据名称8,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data,data
|
||||
|
98
html/config.html
Normal file
98
html/config.html
Normal file
@ -0,0 +1,98 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<link rel="stylesheet" type="text/css" href="/css/config.css">
|
||||
</head>
|
||||
<body class="body" >
|
||||
<div>
|
||||
<h1 class="title1">Sif And Spectral</h1>
|
||||
</div>
|
||||
<div style="margin-left:auto;margin-right:auto;width:80%;" >
|
||||
<table style="width: 100%">
|
||||
<tr>
|
||||
<td width="100px">程序运行状态</td>
|
||||
<td width="50px" id="statid"></td>
|
||||
<td ></td>
|
||||
<td><input type="button" value="重启" onclick="rebootclicked()"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<form action="/php/config.php" method="POST" >
|
||||
<div style="margin-left:auto;margin-right:auto;width:80%;" >
|
||||
|
||||
<div class="mainframe" >
|
||||
<table class="linetb">
|
||||
<tr>
|
||||
<td><h2>控制设置</h2></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div align="center">
|
||||
<table class="linetb" >
|
||||
|
||||
<tr style="width:80%">
|
||||
|
||||
<td style="width:33%">开始时间
|
||||
<input type="time" id="BeginTime" name="BeginTime" class="TextInput"></td>
|
||||
<td style="width:33%">时间间隔
|
||||
<input type="number" id="IntervalTime" name="IntervalTime" class="TextInput"></td>
|
||||
<td style="width:33%">停止时间
|
||||
<input type="time" id="EndTime" class="TextInput" name="EndTime"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<p></p>
|
||||
<p></p>
|
||||
<div>
|
||||
<h2>描述信息</h2>
|
||||
</div>
|
||||
<div align="center">
|
||||
<table style="width:100%">
|
||||
<tr>
|
||||
|
||||
<td>设备序列号 <input class="TextInput" id="Dev_SN" name="Dev_SN" value="1000000"></td>
|
||||
<td>地点 <input class="TextInput" name="Location" id="Location"></td>
|
||||
<td>北半球 <input type="checkbox" name="GPS_North" id="GPS_North"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>GPS经度 <input type="text" class="TextInput" name="GPS_Longtitude" id="GPS_Longtitude"></td>
|
||||
<td>GPS经度 <input type="text" class="TextInput" name="GPS_Latitude" id="GPS_Latitude"> </td>
|
||||
<td>GPS高程 <input type="text" class="TextInput" name="GPS_Atitude" id="GPS_Atitude"> </td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
<p></p>
|
||||
<table style="width:100%">
|
||||
<tr>
|
||||
<td>安装时间 <input type="date" name="InstallTime" id="InstallTime"></td>
|
||||
<td>ISIF定标时间 <input type="date" name="ISIFCalibrationTime" id="ISIFCalibrationTime"> </td>
|
||||
<td>IS1定标时间 <input type="date" name="IS1CalibrationTime" id="IS1CalibrationTime"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>设备维护人员 <input type="text" class="TextInput" name="NameOfMaintenance" id="NameOfMaintenance"></td>
|
||||
<td>维护人员电话 <input type="number" name="PhoneOfMaintenance" id="PhoneOfMaintenance" style="width: 100px" ></td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td>远程资源用户ID <input type="text" name="DownloadUserID" class="TextInput" id="DownloadUserID"></td>
|
||||
<td>定标文件下载路径<input type="text" name="DownlaodAddress" id="DownlaodAddress"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div id="devinfo">
|
||||
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2></h2>
|
||||
<input type="submit" value="提交" >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script type="text/javascript" src="/javascript/comment.js"></script>
|
||||
<script type="text/javascript" src="/javascript/config.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
59
html/config/LocationCali.php
Normal file
59
html/config/LocationCali.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
//var_dump($_GET);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$sensor=$_GET['sensor'];
|
||||
$number=$_GET['positionnumber'];
|
||||
$shuter=$_GET['shutterTime'];
|
||||
|
||||
set_time_limit(0);
|
||||
ob_end_clean();//清空(擦除)缓冲区并关闭输出缓冲
|
||||
ob_implicit_flush(1);//将打开或关闭绝对(隐式)刷送。绝对(隐式)刷送将导致在每次输出调用后有一次刷送操作,以便不再需要对 flush() 的显式调用
|
||||
system("sudo gpio mode 1 out");
|
||||
system("sudo gpio write 1 1");
|
||||
system("sudo killall Mywathdog.sh");
|
||||
system("sudo killall TowerOptoSifAndSpectral");
|
||||
system("sudo pkill shutter_calibrate");
|
||||
|
||||
|
||||
$cmd = 'sudo /home/pi/bin/shutter_calibrate '.$sensor." ".$number.' '.$shuter;
|
||||
echo $cmd.'<br>';
|
||||
|
||||
while(@ ob_end_flush());
|
||||
|
||||
$proc = popen($cmd, 'r');
|
||||
|
||||
|
||||
while(!feof($proc)){
|
||||
echo fread($proc, 4096);
|
||||
@ flush();
|
||||
}
|
||||
echo "<br>";
|
||||
echo "finish";
|
||||
|
||||
echo '<a href=/config/position.html>回到首页</a>';
|
||||
|
||||
$file=fopen('/home/data/test.csv','r');
|
||||
|
||||
while ($data = fgetcsv($file)) { //每次读取CSV里面的一行内容
|
||||
//print_r($data); //此为一个数组,要获得每一个数据,访问数组下标即可
|
||||
$goods_list[] = $data;
|
||||
}
|
||||
|
||||
//var_dump($goods_list[0]);
|
||||
$hang=count($goods_list);
|
||||
$x=$goods_list[0][2];
|
||||
$y=$goods_list[0][1];;
|
||||
for($i=1;$i<$hang;$i++)
|
||||
{
|
||||
$x=$x.','.$goods_list[$i][2];
|
||||
$y=$y.','.$goods_list[$i][1];
|
||||
}
|
||||
echo '<div id="main" style="width: 600px;height:400px;"></div> ';
|
||||
|
||||
echo ' <script src="/config/js/echarts.js"></script>';
|
||||
echo '<script>var xx=['.$x.']; var yy=['.$y.']; </script>';
|
||||
echo '<script src="/config/js/printercaliresult.js"></script>';
|
||||
95096
html/config/js/echarts.js
Normal file
95096
html/config/js/echarts.js
Normal file
File diff suppressed because it is too large
Load Diff
30
html/config/js/printercaliresult.js
Normal file
30
html/config/js/printercaliresult.js
Normal file
@ -0,0 +1,30 @@
|
||||
var chartDom = document.getElementById('main');
|
||||
var myChart = echarts.init(chartDom);
|
||||
// 指定图表的配置项和数据
|
||||
var option = {
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: [1,2,3,4,5,6]
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
tooltip:{
|
||||
trigger:'axis'
|
||||
},
|
||||
dataZoom:[{
|
||||
type:"inside" //详细配置可见echarts官网
|
||||
}],
|
||||
series: [
|
||||
{
|
||||
name: 'DN',
|
||||
data: [150, 230, 224, 218, 135, 147, 260],
|
||||
type: 'line'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
option.xAxis.data=xx;
|
||||
option.series[0].data=yy;
|
||||
option
|
||||
myChart.setOption(option);
|
||||
66
html/config/location.php
Normal file
66
html/config/location.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
$a=$_GET["p"];
|
||||
|
||||
if ($a==0)
|
||||
{
|
||||
echo "error";
|
||||
return;
|
||||
}
|
||||
set_time_limit(0);
|
||||
ob_end_clean();//清空(擦除)缓冲区并关闭输出缓冲
|
||||
ob_implicit_flush(1);//将打开或关闭绝对(隐式)刷送。绝对(隐式)刷送将导致在每次输出调用后有一次刷送操作,以便不再需要对 flush() 的显式调用
|
||||
//echo shell_exec("D:\\03MyGit\\linux\\movingliner\\cmake-build-debug-mingw\\movingliner.exe");
|
||||
//$cmd = 'ping 127.0.0.1';
|
||||
//sy""
|
||||
system("sudo killall Mywathdog.sh");
|
||||
system("sudo killall TowerOptoSifAndSpectral");
|
||||
system("sudo pkill movingliner");
|
||||
Echo $a;
|
||||
$cmd = 'sudo /home/pi/bin/movingliner '.$a;
|
||||
|
||||
while(@ ob_end_flush());
|
||||
|
||||
$proc = popen($cmd, 'r');
|
||||
|
||||
|
||||
while(!feof($proc)){
|
||||
echo fread($proc, 4096);
|
||||
@ flush();
|
||||
}
|
||||
|
||||
|
||||
echo '<form action="/config/calibrate.php" method="get" target="_blank">';
|
||||
|
||||
echo '设备<input id="sensor" name="sensor" type="text" list="typelist" placeholder="请选择">
|
||||
|
||||
<datalist id="typelist">
|
||||
<option>IS1</option>
|
||||
<option>IS2</option>
|
||||
<option>ISIF</option>
|
||||
<option>OSIFAlpha</option>
|
||||
<option>OSIFBeta</option>
|
||||
</datalist>';
|
||||
echo '尼特 <input type="number" name="nite" id="nite"/>';
|
||||
echo '<input id="p" name="p" type="hidden" value="'.$a.'">';
|
||||
echo '<input type="submit" value="定标">';
|
||||
|
||||
echo '</form>';
|
||||
|
||||
|
||||
echo '<a href=/config/position.html>回到首页</a>';
|
||||
|
||||
/*
|
||||
$i = 100;
|
||||
while ($i<1000) {
|
||||
++$i;
|
||||
//部分浏览器需要内容达到一定长度了才输出
|
||||
if ($i === 103) {
|
||||
echo"<p>hello word".$i."</p>";;
|
||||
} else {
|
||||
echo"<p>hello word".$i."</p>";;
|
||||
}
|
||||
sleep(1);
|
||||
|
||||
}
|
||||
*/
|
||||
66
html/config/position.html
Normal file
66
html/config/position.html
Normal file
@ -0,0 +1,66 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="/config/location.php?p=1">位置1</a>
|
||||
<a href="/config/location.php?p=2">位置2</a>
|
||||
<a href="/config/location.php?p=3">位置3</a>
|
||||
<a href="/config/location.php?p=4">位置4</a>
|
||||
<a href="/config/location.php?p=5">位置5</a>
|
||||
<a href="/config/location.php?p=12">位置try</a>
|
||||
|
||||
<form action="LocationCali.php" method="get">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
位置自动计算:
|
||||
</td>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td>设备<input id="sensor" name="sensor" type="text" list="typelist" placeholder="请选择">
|
||||
|
||||
<datalist id="typelist">
|
||||
<option>IS1</option>
|
||||
<option>IS2</option>
|
||||
<option>ISIF</option>
|
||||
<option>OSIFAlpha</option>
|
||||
<option>OSIFBeta</option>
|
||||
</datalist>
|
||||
</td>
|
||||
<td>
|
||||
预估位置数量
|
||||
<input id="positionnumber" name="positionnumber" type="number" list="positionnumbertypelist" placeholder="请选择">
|
||||
|
||||
<datalist id="positionnumbertypelist">
|
||||
<option>1</option>
|
||||
<option>2</option>
|
||||
<option>3</option>
|
||||
<option>4</option>
|
||||
<option>5</option>
|
||||
<option>6</option>
|
||||
<option>7</option>
|
||||
<option>8</option>
|
||||
<option>9</option>
|
||||
<option>10</option>
|
||||
</datalist>
|
||||
</td>
|
||||
<td>
|
||||
曝光事件
|
||||
<input id="shutterTime" name="shutterTime" type="number" value="10">ms
|
||||
</td>
|
||||
<td>
|
||||
<input type="submit" value="开始">
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
32
html/css/config.css
Normal file
32
html/css/config.css
Normal file
@ -0,0 +1,32 @@
|
||||
.title1 {
|
||||
align-content: center;
|
||||
font-style: normal;
|
||||
font-weight: 900;
|
||||
}
|
||||
h2 {
|
||||
width: 100%;
|
||||
border-bottom: 1px dashed rgba(0, 0, 0, 1.00);
|
||||
}
|
||||
.linetb {
|
||||
width: 100%;
|
||||
}
|
||||
.TextInput{
|
||||
width: 80px;
|
||||
}
|
||||
body{
|
||||
text-align:center;
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
}
|
||||
h2 {
|
||||
text-align: left;
|
||||
margin-left: 0px;
|
||||
margin-top: 5px;
|
||||
margin-right: 0px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.mainframe {
|
||||
border: 1px ridge rgba(0, 0, 0, 1.00);
|
||||
|
||||
|
||||
}
|
||||
100
html/index.html
Normal file
100
html/index.html
Normal file
@ -0,0 +1,100 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<link rel="stylesheet" type="text/css" href="/css/config.css">
|
||||
</head>
|
||||
<body class="body" >
|
||||
<div>
|
||||
<h1 class="title1">Sif And Spectral</h1>
|
||||
</div>
|
||||
<div style="margin-left:auto;margin-right:auto;width:80%;" >
|
||||
<table style="width: 100%">
|
||||
<tr>
|
||||
<td width="100px">程序运行状态</td>
|
||||
<td width="50px" id="statid"></td>
|
||||
<td ></td>
|
||||
<td><input type="button" value="重启" onclick="rebootclicked()"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<form action="/php/config.php" method="POST" >
|
||||
<div style="margin-left:auto;margin-right:auto;width:80%;" >
|
||||
|
||||
<div class="mainframe" >
|
||||
<table class="linetb">
|
||||
<tr>
|
||||
<td><h2>控制设置</h2></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div align="center">
|
||||
<table class="linetb" >
|
||||
|
||||
<tr style="width:80%">
|
||||
|
||||
<td style="width:33%">开始时间
|
||||
<input type="time" id="BeginTime" name="BeginTime" class="TextInput"></td>
|
||||
<td style="width:33%">时间间隔
|
||||
<input type="number" id="IntervalTime" name="IntervalTime" class="TextInput"></td>
|
||||
<td style="width:33%">停止时间
|
||||
<input type="time" id="EndTime" class="TextInput" name="EndTime"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<p></p>
|
||||
<p></p>
|
||||
<div>
|
||||
<h2>描述信息</h2>
|
||||
</div>
|
||||
<div align="center">
|
||||
<table style="width:100%">
|
||||
<tr>
|
||||
|
||||
<td>设备序列号 <input class="TextInput" id="Dev_SN" name="Dev_SN" value="1000000"></td>
|
||||
<td>地点 <input class="TextInput" name="Location" id="Location"></td>
|
||||
<td>北半球 <input type="checkbox" name="GPS_North" id="GPS_North"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>GPS经度 <input type="text" class="TextInput" name="GPS_Longtitude" id="GPS_Longtitude"></td>
|
||||
<td>GPS经度 <input type="text" class="TextInput" name="GPS_Latitude" id="GPS_Latitude"> </td>
|
||||
<td>GPS高程 <input type="text" class="TextInput" name="GPS_Altitude" id="GPS_Altitude"> </td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
<p></p>
|
||||
<table style="width:100%">
|
||||
<tr>
|
||||
<td>安装时间 <input type="date" name="InstallationTime" id="InstallationTime"></td>
|
||||
<td>ISIF定标时间 <input type="date" name="ISIFCalibrationTime" id="ISIFCalibrationTime"> </td>
|
||||
<td>IS1定标时间 <input type="date" name="IS1CalibrationTime" id="IS1CalibrationTime"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>设备维护人员 <input type="text" class="TextInput" name="NameOfMaintenanceStaff" id="NameOfMaintenanceStaff"></td>
|
||||
<td>维护人员电话 <input type="number" name="PhoneNumberOfMaintenanceStaff" id="PhoneNumberOfMaintenanceStaff" style="width: 100px" ></td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td>远程资源用户ID <input type="text" name="DownloadUserID" class="TextInput" id="DownloadUserID"></td>
|
||||
<td>定标文件下载路径<input type="url" name="DownlaodAddress" id="DownlaodAddress"></td>
|
||||
<td>远程服务器<input type="url" name="HTTPServer" id="HTTPServer"></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
<div id="devinfo">
|
||||
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2></h2>
|
||||
<input type="submit" value="提交" >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script type="text/javascript" src="/javascript/comment.js"></script>
|
||||
<script type="text/javascript" src="/javascript/config.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
69
html/javascript/comment.js
Normal file
69
html/javascript/comment.js
Normal file
@ -0,0 +1,69 @@
|
||||
function ajaxObject() {
|
||||
var xmlHttp;
|
||||
try {
|
||||
// Firefox, Opera 8.0+, Safari
|
||||
xmlHttp = new XMLHttpRequest();
|
||||
}
|
||||
catch (e) {
|
||||
// Internet Explorer
|
||||
try {
|
||||
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch (e) {
|
||||
try {
|
||||
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} catch (e) {
|
||||
alert("您的浏览器不支持AJAX!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return xmlHttp;
|
||||
}
|
||||
function httppost ( url , data , fnSucceed ){// fnFail , fnLoading ) {
|
||||
var ajax = ajaxObject();
|
||||
ajax.open( "post" , url , true );
|
||||
// ajax.setRequestHeader( "Content-Type" , "application/octet-binary" );
|
||||
ajax.onreadystatechange = function () {
|
||||
if( ajax.readyState == 4 ) {
|
||||
if( ajax.status == 200 ) {
|
||||
|
||||
fnSucceed( ajax.response);
|
||||
|
||||
//ajax.response.size();
|
||||
}
|
||||
else {
|
||||
// fnFail( "HTTP请求错误!错误码:"+ajax.status );
|
||||
}
|
||||
}
|
||||
else {
|
||||
//fnLoading();
|
||||
}
|
||||
}
|
||||
// ajax.responseType="arraybuffer";
|
||||
ajax.send( data );
|
||||
|
||||
}
|
||||
function httpget ( url , data , fnSucceed ){// fnFail , fnLoading ) {
|
||||
var ajax = ajaxObject();
|
||||
ajax.open( "get" , url , true );
|
||||
// ajax.setRequestHeader( "Content-Type" , "application/octet-binary" );
|
||||
ajax.onreadystatechange = function () {
|
||||
if( ajax.readyState == 4 ) {
|
||||
if( ajax.status == 200 ) {
|
||||
|
||||
fnSucceed( ajax.response);
|
||||
|
||||
//ajax.response.size();
|
||||
}
|
||||
else {
|
||||
// fnFail( "HTTP请求错误!错误码:"+ajax.status );
|
||||
}
|
||||
}
|
||||
else {
|
||||
//fnLoading();
|
||||
}
|
||||
}
|
||||
// ajax.responseType="arraybuffer";
|
||||
ajax.send( data );
|
||||
|
||||
}
|
||||
61
html/javascript/config.js
Normal file
61
html/javascript/config.js
Normal file
@ -0,0 +1,61 @@
|
||||
function getConfigRentrun(reson)
|
||||
{
|
||||
var aa=JSON.parse(reson);
|
||||
for (var obj in aa)
|
||||
{
|
||||
var temmp=document.getElementById(obj);
|
||||
temmp.value=aa[obj];
|
||||
if (obj=="GPS_North")
|
||||
{
|
||||
if (aa[obj]=="on")
|
||||
{
|
||||
temmp.checked=true;
|
||||
}else {
|
||||
temmp.checked=false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
function getDevinfoRetrun(retrun)
|
||||
{
|
||||
var div=document.getElementById('devinfo');
|
||||
div.innerHTML=retrun;
|
||||
init()
|
||||
}
|
||||
function getstataRetrun(retrun){
|
||||
var div=document.getElementById('statid');
|
||||
div.innerHTML=retrun;
|
||||
}
|
||||
|
||||
|
||||
var datad;
|
||||
function init()
|
||||
{
|
||||
httpget("/php/GetConfig.php",datad,getConfigRentrun)
|
||||
|
||||
}
|
||||
|
||||
function getinit()
|
||||
{
|
||||
httpget("/php/GetIniFile.php",datad,getDevinfoRetrun)
|
||||
httpget("/php/GetSata.php",datad,getstataRetrun)
|
||||
}
|
||||
|
||||
function rebootclicked()
|
||||
{
|
||||
|
||||
httpget("/php/reboot.php",datad,getrebootRentrun)
|
||||
var div=document.getElementById('statid');
|
||||
div.innerHTML="";
|
||||
|
||||
}
|
||||
function getrebootRentrun(ret)
|
||||
{
|
||||
alert(ret)
|
||||
|
||||
setTimeout(() => {
|
||||
location.reload()
|
||||
}, 100);
|
||||
}
|
||||
window.onload=getinit;
|
||||
4
html/php/GetConfig.php
Normal file
4
html/php/GetConfig.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
header("Content-type:application/json");
|
||||
$a=file_get_contents("/home/data/Setting/config.json");
|
||||
echo $a;
|
||||
17
html/php/GetIniFile.php
Normal file
17
html/php/GetIniFile.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
$a=parse_ini_file("/home/data/Setting/DeviceSettings.ini",true);
|
||||
|
||||
$numberofsensor=intval($a['DEVICE INFO']['TotalSpectrometer']);
|
||||
$b=array_values($a);
|
||||
|
||||
echo '<h2>设备信息</h2>';
|
||||
echo '设备数量 '.$numberofsensor.'';
|
||||
echo '<table>';
|
||||
for ($i=0;$i<$numberofsensor;$i++)
|
||||
{
|
||||
echo '<tr>';
|
||||
echo '<td>'.$b[$i+1]['Model'].'_定标文件主名称'.'</td>';
|
||||
echo '<td><input type="text" id="'.$b[$i+1]['Model'].'_CaliFileMainName'.'" name="'.$b[$i+1]['Model'].'_CaliFileMainName'.'"></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
10
html/php/GetSata.php
Normal file
10
html/php/GetSata.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
exec("ps -ef | grep TowerOptoSifAndSpectral | grep -v grep",$output,$return);
|
||||
//var_dump( $output);
|
||||
if ( count($output)>0)
|
||||
{
|
||||
echo '<div style="width: 40px;height: 20px;background: green"></div>';
|
||||
}else{
|
||||
echo '<div style="width: 40px;height: 20px;background: red"></div>';
|
||||
}
|
||||
1
html/php/config.json
Normal file
1
html/php/config.json
Normal file
@ -0,0 +1 @@
|
||||
{"BeginTime":"","IntervalTime":"","EndTime":"","Dev_SN":"1000000","Location":"","GPS_Longtitude":"","GPS_Latitude":"","GPS_Atitude":"","InstallTime":"","ISIFCalibrationTime":"","IS1CalibrationTime":"","NameOfMaintenance":"","PhoneOfMaintenance":"","DownloadUserID":"","DownlaodAddress":""}
|
||||
7
html/php/config.php
Normal file
7
html/php/config.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
var_dump($_POST);
|
||||
exec("sudo touch /home/data/Setting/config.json");
|
||||
exec("sudo chmod 777 /home/data/Setting/config.json");
|
||||
file_put_contents("/home/data/Setting/config.json",json_encode($_POST));
|
||||
echo "提交成功";
|
||||
8
html/php/reboot.php
Normal file
8
html/php/reboot.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
ignore_user_abort(true);
|
||||
set_time_limit(0);
|
||||
echo system("sudo killall Mywathdog.sh");
|
||||
echo system("sudo killall TowerOptoSifAndSpectral");
|
||||
echo system("sudo ./reboot.sh &");
|
||||
echo "系统已重启";
|
||||
//var_dump($output);
|
||||
3
html/php/reboot.sh
Normal file
3
html/php/reboot.sh
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
/root/Mywathdog.sh>>log.txt &
|
||||
|
||||
223
main.cpp
Normal file
223
main.cpp
Normal file
@ -0,0 +1,223 @@
|
||||
#include "pch.h"
|
||||
#include "ATPControl_Serial_QT.h"
|
||||
#include "Logger.h"
|
||||
#include "SystemConfigger.h"
|
||||
#include "MainDataGrabber.h"
|
||||
#include "DataFileProcessor.h"
|
||||
#include "Scheduler.h"
|
||||
#include "GY39Controller.h"
|
||||
#include "MainDataUploader.h"
|
||||
#include "VSMD12XMovementTest.h"
|
||||
using namespace std;
|
||||
#pragma once
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||
using namespace ZZ_MISCDEF::MISC_DETECTOR;
|
||||
|
||||
QCoreApplication a(argc, argv);
|
||||
//////////////////////////////////////////////////////////////////////////logger
|
||||
///create main system logger
|
||||
QT_LOG::ZZ_InitLogger("/home/data/Log/");
|
||||
//////////////////////////////////////////////////////////////////////////for test
|
||||
system("gpio mode 1 out");
|
||||
qDebug() << "gpio write 1 1......" << endl;
|
||||
|
||||
ZZ_SysConfigger m_scConfiggerLoader;
|
||||
MovementTest m_testVSMD12X;
|
||||
|
||||
RunTimeGrabberParams m_struRuntimeParams;
|
||||
EContext m_struEC;
|
||||
MEContext m_struMEC;
|
||||
HumitureDeviceInfo m_struHumitureDI;
|
||||
|
||||
QThread::msleep(5000);
|
||||
bool bRes = m_scConfiggerLoader.Initialize();
|
||||
if (bRes)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_scConfiggerLoader.GetParams(m_struRuntimeParams, m_struEC, m_struMEC, m_struHumitureDI);
|
||||
|
||||
m_testVSMD12X.SetTestParam(m_struRuntimeParams);
|
||||
m_testVSMD12X.TestAsLinearShutter();
|
||||
//CVSMD12XControl m_ctrlLS;
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//system("gpio mode 1 output");//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ų<EFBFBD>ʼ<EFBFBD><CABC>
|
||||
//qDebug() << "gpio mode 1 output......" << endl;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////
|
||||
//GY39Controller m_ctrlHumitureDetector;
|
||||
//DataFileProcessor m_dfpSaver;
|
||||
//Scheduler m_sTimer;
|
||||
//CMainDataGrabber m_mdgGrabber;
|
||||
//CMainDataUploader m_mduUploader;
|
||||
//ErrInfo m_eiErrInfo;
|
||||
// m_eiErrInfo.fChassisTempErr = 0;
|
||||
// m_eiErrInfo.fTecTempErr = 0;
|
||||
// m_eiErrInfo.iDataTransferErr = 0;
|
||||
// m_eiErrInfo.iShutterErr = 0;
|
||||
////
|
||||
//bool bRes;
|
||||
//float m_fChassisTemp = 0, m_fChassisHum = 0;
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////config
|
||||
///turn on power supply
|
||||
|
||||
//////add support to dual channel
|
||||
|
||||
|
||||
// QString qstrCMD_A, qstrCMD_B, qstrCMD_Temp;
|
||||
// qstrCMD_Temp = QString::fromStdString("4");
|
||||
// qDebug() << qstrCMD_Temp << endl;
|
||||
// qstrCMD_A = "gpio write " + qstrCMD_Temp + " 0";
|
||||
//
|
||||
// qstrCMD_Temp = QString::fromStdString("5");
|
||||
// qDebug() << qstrCMD_Temp << endl;
|
||||
// qstrCMD_B = "gpio write " + qstrCMD_Temp + " 0";
|
||||
//
|
||||
// qDebug() << qstrCMD_A << endl;
|
||||
// qDebug() << qstrCMD_B << endl;
|
||||
// system(qstrCMD_A.toLatin1());
|
||||
// system(qstrCMD_B.toLatin1());
|
||||
|
||||
|
||||
|
||||
//m_sTimer.SetAcqTimeParams(m_struRuntimeParams.atsParams);
|
||||
//m_dfpSaver.SetEnvironmentContex(m_struEC);
|
||||
//m_dfpSaver.SetManmadeEnviromentalContext(m_struMEC);
|
||||
|
||||
//m_mduUploader.SetContext(m_struEC, m_struMEC);
|
||||
//m_mduUploader.Initialize();
|
||||
//m_ctrlHumitureDetector.Initialize(m_struHumitureDI.qstrInterfaceName.toStdString());
|
||||
//////////////////////////////////////////////////////////////////////////prepare
|
||||
//m_sTimer.Preheating();
|
||||
//m_ctrlHumitureDetector.GetHumiture_retry(m_fChassisTemp, m_fChassisHum);
|
||||
|
||||
//m_struEC.qstrCaseTemperature= QString("%1").arg(m_fChassisTemp);
|
||||
//m_struEC.qstrCaseHumidity = QString("%1").arg(m_fChassisHum);
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// QThread* m_pqDataGrabberThreadHolder = new QThread();
|
||||
// QThread* m_pqTimerThreadHolder = new QThread();
|
||||
// QThread* m_pqUploaderThreadHolder = new QThread();
|
||||
//
|
||||
// m_mdgGrabber.moveToThread(m_pqDataGrabberThreadHolder);
|
||||
// m_sTimer.moveToThread(m_pqTimerThreadHolder);
|
||||
// m_mduUploader.moveToThread(m_pqUploaderThreadHolder);
|
||||
//
|
||||
//
|
||||
// //m_mdgGrabber.SetContext(m_struRuntimeParams, m_dfpSaver, m_sTimer);
|
||||
// m_mdgGrabber.SetContext(m_struRuntimeParams, m_dfpSaver, m_sTimer, m_mduUploader);
|
||||
// m_mdgGrabber.Init_Normal();
|
||||
//
|
||||
// m_mduUploader.Initialize();
|
||||
// m_mduUploader.SetErr(m_eiErrInfo);
|
||||
// m_mduUploader.UploadInfo();
|
||||
// m_mduUploader.UploadErr();
|
||||
//
|
||||
// m_pqDataGrabberThreadHolder->start();
|
||||
// m_pqTimerThreadHolder->start();
|
||||
// m_pqUploaderThreadHolder->start();
|
||||
//
|
||||
// m_mdgGrabber.Init_Self();
|
||||
// m_sTimer.SelfStart();
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////test
|
||||
// DataFileProcessor testdp;
|
||||
// ZZ_SysConfigger test;
|
||||
// Scheduler testS;
|
||||
//
|
||||
// RunTimeGrabberParams testp;
|
||||
// EContext testEC;
|
||||
// MEContext testMEC;
|
||||
// test.Initialize();
|
||||
// test.LoadSettingsFromFile_System();
|
||||
// test.LoadSettingsFromFile_MISC();
|
||||
// test.GetGrabberRunParams(testp);
|
||||
// test.GetECParams(testEC);
|
||||
// test.GetMECParams(testMEC);
|
||||
//
|
||||
// testS.SetAcqTimeParams(testp.atsParams);
|
||||
// testdp.SetEnvironmentContex(testEC);
|
||||
// testdp.SetManmadeEnviromentalContext(testMEC);
|
||||
//testdp.WriteDataFile();
|
||||
//////////////////////////////////////////////////////////////////////////test
|
||||
//CMainDataGrabber testDG;
|
||||
//QThread* m_pqDataGrabberThreadHolder = new QThread();
|
||||
//testDG.moveToThread(m_pqDataGrabberThreadHolder);
|
||||
//testDG.SetContext(testp, testdp, testS);
|
||||
//testDG.Init_Normal();
|
||||
//testDG.SetGrabberFileProcessor(testdp);
|
||||
//testDG.SetGrabberParams(testp);
|
||||
//testDG.SetTimer(testS);
|
||||
//testDG.InitThreadStatus();
|
||||
//testDG.InitializeWorkers();
|
||||
//testDG.SetupMsgPipelines();
|
||||
//testDG.StartWorkers();
|
||||
//m_pqDataGrabberThreadHolder->start();
|
||||
//testDG.Init_Self();
|
||||
//testDG.InitThreadStatus();
|
||||
//testDG.InitializeWorkers();
|
||||
//testDG.InitLS();
|
||||
//testDG.SetupMsgPipelines();
|
||||
//testDG.StartWorkers();
|
||||
//testDG.StartGrab();
|
||||
//
|
||||
//QThread* m_pqTimerThreadHolder = new QThread();
|
||||
//testS.moveToThread(m_pqTimerThreadHolder);
|
||||
//m_pqTimerThreadHolder->start();
|
||||
//testS.SelfStart();
|
||||
//
|
||||
//QString qstrTest = "This is a test message 2";
|
||||
//qDebug() << qstrTest;
|
||||
//cout << "This is a test message";
|
||||
//
|
||||
//test.LoadSettings_Test();
|
||||
//
|
||||
//ZZ_DataGrabberThread m_test;
|
||||
//m_test.GrabOnce();
|
||||
//QThread* m_pqDataGrabberThreadHolder;
|
||||
//
|
||||
//
|
||||
//m_pqDataGrabberThreadHolder->start();
|
||||
//m_test.TestGrabOnce();
|
||||
//m_test.StartGrabCall();
|
||||
//QThread::msleep(5000);
|
||||
//
|
||||
//m_test.StopTestGrab();
|
||||
// ZZ_ATPControl_Serial_Qt m_ctrlATP;
|
||||
// QByteArray qbTest;
|
||||
// m_ctrlATP.ATPInitialize(7);
|
||||
// m_ctrlATP.GetDeviceAttribute();
|
||||
// m_ctrlATP.SetExposureTime(m_ctrlATP.m_adaDeviceAttr.iMinIntegrationTime);
|
||||
// m_ctrlATP.RecvData(qbTest);
|
||||
//m_test123;
|
||||
//m_test123.Initialize("COM11");
|
||||
//m_test123.GetHumiture(fTemp, fHum);
|
||||
// int aaaaa = sizeof(unsigned long int);
|
||||
// CalFrame OneFile;
|
||||
// QString aa = "C:/Users/ZhangZhuo/Desktop/qepro.cal";
|
||||
// QFile qfCalFile(aa);
|
||||
// bRes = qfCalFile.open(QFile::ReadOnly);
|
||||
// using namespace ZZ_MISCDEF;
|
||||
// qfCalFile.read((char *)&OneFile.uiExposureTimeInMS, sizeof(ZZ_U32));//U32
|
||||
// qfCalFile.read((char*)&OneFile.fTemperature, sizeof(double));
|
||||
// qfCalFile.read((char*)&OneFile.iPixels, sizeof(int));
|
||||
// qfCalFile.read((char*)OneFile.fWaveLength, sizeof(double)*OneFile.iPixels);
|
||||
// qfCalFile.read((char*)OneFile.dCal_Gain, sizeof(double)*OneFile.iPixels);
|
||||
// qfCalFile.read((char*)OneFile.dCal_Offset, sizeof(double)*OneFile.iPixels);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
|
||||
|
||||
52
othersoft/calibration_console/CMakeLists.txt
Normal file
52
othersoft/calibration_console/CMakeLists.txt
Normal file
@ -0,0 +1,52 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(ocean_optics_calibration_console)#ocean_optics_calibration_console
|
||||
|
||||
#编译32位的程序
|
||||
#option(USE_32BITS "Compile for 32bits processors(linux only)" OFF)
|
||||
#
|
||||
#
|
||||
#if(USE_32BITS)
|
||||
# message(STATUS "using 32bits")
|
||||
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
|
||||
#
|
||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
|
||||
#else()
|
||||
#endif(USE_32BITS)
|
||||
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
|
||||
SET(CMAKE_INSTALL_PREFIX < /home/pi/bin >)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
set(CMAKE_PREFIX_PATH "/home/iris-xport/Qt5.9.0/5.9/gcc_64/")#tc_add: https://blog.csdn.net/aiyun5666/article/details/101915628
|
||||
set(QT Core Network SerialPort)
|
||||
set(TEMPLATE app)
|
||||
set(TARGET ximeaImageRecorder)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
find_package(Qt5 REQUIRED ${QT})
|
||||
|
||||
#include_directories(/home/iris-xport/projects/ocean/seabreeze-3.0.11/SeaBreeze/include/)
|
||||
#LINK_DIRECTORIES(/home/iris-xport/projects/ocean/seabreeze-3.0.11/SeaBreeze/lib/)
|
||||
include_directories(/home/pi/SeaBrease/include/)
|
||||
LINK_DIRECTORIES(/home/pi/SeaBrease/lib/)
|
||||
|
||||
include_directories(.)#包含头文件
|
||||
include_directories(/usr/include/eigen3)#包含头文件,安装eigen:sudo apt-get install libeigen3-dev
|
||||
|
||||
|
||||
file(GLOB_RECURSE SRC_h ./Header_Files/*.h)
|
||||
file(GLOB_RECURSE SRC_CPP ./Source_Files/*.cpp)
|
||||
|
||||
add_executable(${CMAKE_PROJECT_NAME} ${SRC_h} ${SRC_CPP})
|
||||
|
||||
|
||||
qt5_use_modules(${CMAKE_PROJECT_NAME} ${QT})
|
||||
|
||||
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME}
|
||||
seabreeze
|
||||
usb
|
||||
)
|
||||
@ -0,0 +1,102 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//ATP<54><50><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
//#include "pch.h"
|
||||
|
||||
#include "ZZ_Types.h"
|
||||
#include "ZZ_Math.h"
|
||||
#include <QSerialPort>
|
||||
#include <QtEndian>
|
||||
#include <QDebug>
|
||||
#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(QObject* parent = nullptr);
|
||||
virtual ~ZZ_ATPControl_Serial_Qt();
|
||||
|
||||
public:
|
||||
//do not call
|
||||
//int ReInit();
|
||||
//<2F><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>
|
||||
//int SetBaudRate(int iBaud);
|
||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>豸
|
||||
int Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName);
|
||||
|
||||
//<2F>ر<EFBFBD><D8B1>豸
|
||||
void Close();
|
||||
|
||||
//<2F><><EFBFBD>β<EFBFBD><CEB2>Բɼ<D4B2> <20><><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int SingleShot(int &iPixels);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲɼ<DDB2>
|
||||
int SingleShot(DataFrame &dfData);
|
||||
|
||||
//<2F><><EFBFBD>ΰ<EFBFBD><CEB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>
|
||||
//int SingleShotDark(ATPDataFrame &dfData);
|
||||
|
||||
//int SingleShotDeducted(ATPDataFrame &dfData);
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
int SetExposureTime(int iExposureTimeInMS);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int GetExposureTime(int &iExposureTimeInMS);
|
||||
|
||||
//int GetWaveLength(float *pfWaveLength);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
||||
int GetDeviceInfo(DeviceInfo &Info);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int GetDeviceAttribute(DeviceAttribute &Attr);
|
||||
|
||||
//int GetDeviceListInfo(); //use type name to enum
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
||||
int SetDeviceTemperature(float fTemperature);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>¶<EFBFBD>
|
||||
int GetDeviceTemperature(float &fTemperature);
|
||||
|
||||
//<2F>Զ<EFBFBD><D4B6>ع<EFBFBD>
|
||||
int PerformAutoExposure(float fMinScaleFactor, float fMaxScaleFactor, float &fPredictedExposureTime);
|
||||
private:
|
||||
int SetAvgTimes(int iTimes = 1);
|
||||
|
||||
#ifdef _DEBUG
|
||||
public:
|
||||
#else //
|
||||
private:
|
||||
#endif
|
||||
//port
|
||||
int m_iBaudRate;
|
||||
QSerialPort *m_pSerialPort;
|
||||
|
||||
//ATP
|
||||
DeviceInfo m_diDeviceInfo;
|
||||
DeviceAttribute m_daDeviceAttr;
|
||||
|
||||
//Attr
|
||||
int m_iExposureTime;
|
||||
//////////////////////////////////////////////////////////////////////////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 GetExposureTime_Init();
|
||||
int SendCommand(QByteArray qbCommand);
|
||||
int RecvData(QByteArray &qbData);
|
||||
int RecvData_ShortLag(QByteArray &qbData);
|
||||
int ParseData(QByteArray &qbData);
|
||||
public slots:
|
||||
int Init_Self();
|
||||
signals:
|
||||
void SignalInit_Self();
|
||||
//private slots :
|
||||
//void ReadMessage();
|
||||
};
|
||||
@ -0,0 +1,61 @@
|
||||
//
|
||||
// Created by tangchao on 2022/1/11.
|
||||
//
|
||||
|
||||
#ifndef OCEAN_OPTICS_CALIBRATION_CONSOLE_FIBERSPECTROMETEROPERATIONBASE_H
|
||||
#define OCEAN_OPTICS_CALIBRATION_CONSOLE_FIBERSPECTROMETEROPERATIONBASE_H
|
||||
|
||||
|
||||
#include "ZZ_Types.h"
|
||||
|
||||
using namespace ZZ_MISCDEF;
|
||||
using namespace ZZ_MISCDEF::IRIS::FS;
|
||||
|
||||
class FiberSpectrometerOperationBase
|
||||
{
|
||||
|
||||
public:
|
||||
// FiberSpectrometerOperationBase();
|
||||
// ~FiberSpectrometerOperationBase();
|
||||
|
||||
virtual void connectFiberSpectrometer(QString& sn, QString& pixelCount, QString& wavelengthInfo) = 0;
|
||||
virtual void disconnectFiberSpectrometer() = 0;
|
||||
virtual void getDeviceAttribute(DeviceAttribute& deviceAttribute) = 0;
|
||||
virtual void getDeviceInfo(DeviceInfo& deviceInfo) = 0;
|
||||
|
||||
virtual void setExposureTime(int iExposureTimeInMS) = 0;
|
||||
|
||||
virtual void getExposureTime(int &iExposureTimeInMS) = 0;
|
||||
virtual void getDeviceTemperature(float &fTemperature) = 0;
|
||||
|
||||
virtual void singleShot(DataFrame &dfData) = 0;
|
||||
|
||||
// typedef struct coeffs
|
||||
// {
|
||||
// ZZ_U32 coeffsCounter;
|
||||
// double coeffs[100];
|
||||
// }coeffsFrame;
|
||||
virtual void getNonlinearityCoeffs(coeffsFrame &coeffs) = 0;
|
||||
|
||||
|
||||
// ZZ_S32 GetMaxValue(ZZ_S32 * dark, int number) = 0;
|
||||
|
||||
DataFrame m_IntegratingSphereData;
|
||||
DataFrame m_DarkData;
|
||||
protected:
|
||||
ZZ_U32 m_MaxValueOfFiberSpectrometer;
|
||||
private:
|
||||
|
||||
|
||||
|
||||
public slots:
|
||||
virtual void recordDark(QString path) = 0;
|
||||
virtual void recordTarget(int recordTimes, QString path) = 0;
|
||||
virtual void autoExpose() = 0;
|
||||
|
||||
signals:
|
||||
void sendExposureTimeSignal(int exposureTime);
|
||||
|
||||
};
|
||||
|
||||
#endif //OCEAN_OPTICS_CALIBRATION_CONSOLE_FIBERSPECTROMETEROPERATIONBASE_H
|
||||
@ -0,0 +1,43 @@
|
||||
#include "QObject"
|
||||
#include <string>
|
||||
#include "ZZ_Types.h"
|
||||
#pragma once
|
||||
using namespace ZZ_MISCDEF;
|
||||
using namespace ZZ_MISCDEF::IRIS::FS;
|
||||
|
||||
class CIrisFSBase:public QObject
|
||||
{
|
||||
public:
|
||||
//CIrisFSBase();
|
||||
//virtual ~CIrisFSBase()= 0;
|
||||
public:
|
||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>豸
|
||||
//<2F>˴<EFBFBD>stringΪָ<CEAA><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD>ocean<61><6E><EFBFBD><EFBFBD><EFBFBD>ǵIJ<C7B5><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>c/c++<2B><><EFBFBD><D7BC><EFBFBD><EFBFBD>
|
||||
//0Ϊ<30><EFBFBD><DEB4><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>뷵<EFBFBD>ز<EFBFBD>ֵͬ
|
||||
virtual int Initialize(bool bIsUSBMode,std::string ucPortNumber,std::string strDeviceName) = 0;
|
||||
|
||||
//<2F>ر<EFBFBD><D8B1>豸
|
||||
virtual void Close() = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲɼ<DDB2>
|
||||
virtual int SingleShot(DataFrame &dfData) = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
virtual int SetExposureTime(int iExposureTimeInMS) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
virtual int GetExposureTime(int &iExposureTimeInMS) = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>¶<EFBFBD>
|
||||
virtual int SetDeviceTemperature(float fTemperature) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>¶<EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
virtual int GetDeviceTemperature(float &fTemperature) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
||||
virtual int GetDeviceInfo(DeviceInfo &Info) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
virtual int GetDeviceAttribute(DeviceAttribute &Attr) = 0;
|
||||
|
||||
};
|
||||
121
othersoft/calibration_console/Header_Files/ZZ_Math.h
Normal file
121
othersoft/calibration_console/Header_Files/ZZ_Math.h
Normal file
@ -0,0 +1,121 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#//#include "Dense"
|
||||
#include "Eigen/Dense"
|
||||
#include <unsupported/Eigen/Splines>
|
||||
#pragma once
|
||||
|
||||
namespace ZZ_MATH
|
||||
{
|
||||
template<typename T>
|
||||
void MinHeapify(T*arry, int size, int element)
|
||||
{
|
||||
int lchild = element * 2 + 1, rchild = lchild + 1;
|
||||
while (rchild < size)
|
||||
{
|
||||
if (arry[element] <= arry[lchild] && arry[element] <= arry[rchild])
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (arry[lchild] <= arry[rchild])
|
||||
{
|
||||
std::swap(arry[element], arry[lchild]);
|
||||
element = lchild;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::swap(arry[element], arry[rchild]);
|
||||
element = rchild;
|
||||
}
|
||||
lchild = element * 2 + 1;
|
||||
rchild = lchild + 1;
|
||||
}
|
||||
if (lchild < size&&arry[lchild] < arry[element])
|
||||
{
|
||||
std::swap(arry[lchild], arry[element]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void MaxHeapify(T*arry, int size, int element)
|
||||
{
|
||||
int lchild = element * 2 + 1, rchild = lchild + 1;
|
||||
while (rchild < size)
|
||||
{
|
||||
if (arry[element] >= arry[lchild] && arry[element] >= arry[rchild])
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (arry[lchild] >= arry[rchild])
|
||||
{
|
||||
std::swap(arry[element], arry[lchild]);
|
||||
element = lchild;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::swap(arry[element], arry[rchild]);
|
||||
element = rchild;
|
||||
}
|
||||
lchild = element * 2 + 1;
|
||||
rchild = lchild + 1;
|
||||
}
|
||||
if (lchild<size&&arry[lchild]>arry[element])
|
||||
{
|
||||
std::swap(arry[lchild], arry[element]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
void HeapSort(T*arry, int size)
|
||||
{
|
||||
int i;
|
||||
for (i = size - 1; i >= 0; i--)
|
||||
{
|
||||
MinHeapify(arry, size, i);
|
||||
}
|
||||
while (size > 0)
|
||||
{
|
||||
std::swap(arry[size - 1], arry[0]);
|
||||
|
||||
size--;
|
||||
MinHeapify(arry, size, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
namespace PolyFit
|
||||
{
|
||||
void Eigen_Polyfit(const std::vector<double> &xv, const std::vector<double> &yv, std::vector<double> &coeff, int order);
|
||||
double Eigen_Polyeval(std::vector<double> coeffs, double x);
|
||||
};
|
||||
|
||||
namespace SplineFit
|
||||
{
|
||||
using namespace Eigen;
|
||||
VectorXd Eigen_Normalize(const VectorXd &x);
|
||||
void Test(std::vector<double> const &x_vec, std::vector<double> const &y_vec);// do not call
|
||||
|
||||
|
||||
class SplineInterpolation
|
||||
{
|
||||
public:
|
||||
SplineInterpolation(Eigen::VectorXd const &x_vec,Eigen::VectorXd const &y_vec);
|
||||
double operator()(double x) const;
|
||||
|
||||
private:
|
||||
double x_min;
|
||||
double x_max;
|
||||
|
||||
double scaled_value(double x) const;
|
||||
Eigen::RowVectorXd scaled_values(Eigen::VectorXd const &x_vec) const;
|
||||
|
||||
Eigen::Spline<double, 1> spline_;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
354
othersoft/calibration_console/Header_Files/ZZ_Types.h
Normal file
354
othersoft/calibration_console/Header_Files/ZZ_Types.h
Normal file
@ -0,0 +1,354 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//<2F><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ļ<EFBFBD>
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <QTime>
|
||||
|
||||
#define MAX_DEVICENUMBER_FS 2
|
||||
#define MAX_LINEARSHUTTER_POSITION 12
|
||||
#define ZZ_Enum2String(x) #x
|
||||
|
||||
namespace ZZ_MISCDEF
|
||||
{
|
||||
typedef unsigned char ZZ_U8;
|
||||
typedef unsigned short int ZZ_U16;
|
||||
typedef unsigned int ZZ_U32;
|
||||
typedef int ZZ_S32;
|
||||
|
||||
|
||||
namespace IRIS
|
||||
{
|
||||
//Fiber Spectrometer
|
||||
namespace FS
|
||||
{
|
||||
typedef struct tagDataFrame
|
||||
{
|
||||
ZZ_U32 usExposureTimeInMS;
|
||||
ZZ_S32 lData[4096];
|
||||
float fTemperature = 0;
|
||||
double dTimes = 0;
|
||||
}DataFrame;
|
||||
|
||||
typedef struct coeffs//tc<74><63><EFBFBD><EFBFBD>-----------------------
|
||||
{
|
||||
ZZ_U32 coeffsCounter;
|
||||
double coeffs[100];
|
||||
}coeffsFrame;
|
||||
|
||||
typedef struct tagDeviceInfo
|
||||
{
|
||||
std::string strPN;
|
||||
std::string strSN;
|
||||
}DeviceInfo;
|
||||
|
||||
typedef struct tagDeviceAttribute
|
||||
{
|
||||
int iPixels;
|
||||
int iMaxIntegrationTimeInMS;
|
||||
int iMinIntegrationTimeInMS;
|
||||
float fWaveLengthInNM[4096];
|
||||
|
||||
}DeviceAttribute;
|
||||
|
||||
// inline DataFrame GetIndex(DataFrame dfDark, DataFrame dfSignal)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
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????<3F><>???
|
||||
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
|
||||
};
|
||||
|
||||
//???????<3F><>??
|
||||
typedef struct tagATPDataFrame
|
||||
{
|
||||
unsigned short usExposureTime;
|
||||
ZZ_U16 usData[4096];
|
||||
float fTemperature;
|
||||
double dTimes = 0;
|
||||
}ATPDataFrame;
|
||||
|
||||
//?<3F><><EFBFBD><EFBFBD>??????<3F><>??
|
||||
typedef struct tagATPDeviceInfo
|
||||
{
|
||||
std::string strPN;
|
||||
std::string strSN;
|
||||
}ATPDeviceInfo;
|
||||
|
||||
//?<3F><><EFBFBD><EFBFBD>????<3F><>?<3F><>??
|
||||
typedef struct tagATPDeviceAttribute
|
||||
{
|
||||
int iPixels;
|
||||
int iMaxIntegrationTime;
|
||||
int iMinIntegrationTime;
|
||||
float fWaveLength[4096];
|
||||
|
||||
}ATPDeviceAttribute;
|
||||
//////////////////////////////////////////////////////////////////////////config file
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//????????
|
||||
namespace ZZ_RUNPARAMS
|
||||
{
|
||||
typedef struct tagErrorInfo
|
||||
{
|
||||
int iDataTransferErr = -1000;
|
||||
float fTecTempErr = -1000;
|
||||
int iShutterErr = -1000;
|
||||
float fChassisTempErr = -1000;
|
||||
}ErrInfo;
|
||||
|
||||
typedef struct tagFiberSpecContext
|
||||
{
|
||||
ZZ_U8 ucDeviceNumber;
|
||||
ZZ_U8 ucDeviceModel[MAX_DEVICENUMBER_FS];
|
||||
std::string strInterface[MAX_DEVICENUMBER_FS];
|
||||
std::string strSN[MAX_DEVICENUMBER_FS];
|
||||
long lDepth[MAX_DEVICENUMBER_FS];
|
||||
float fMinFactor[MAX_DEVICENUMBER_FS];
|
||||
float fMaxFactor[MAX_DEVICENUMBER_FS];
|
||||
ZZ_U16 usPixels[MAX_DEVICENUMBER_FS];
|
||||
float fWavelength[MAX_DEVICENUMBER_FS][4096];
|
||||
}FSContext;
|
||||
|
||||
typedef struct tagLinearShutterContext
|
||||
{
|
||||
std::string strInterface;
|
||||
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;
|
||||
}
|
||||
|
||||
//?????????????<3F><>??
|
||||
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;
|
||||
QString qstrDEV_SN;
|
||||
}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;
|
||||
|
||||
typedef struct tagCalibrationFrame
|
||||
{
|
||||
ZZ_U32 uiExposureTimeInMS;
|
||||
float fTemperature;
|
||||
int iPixels;
|
||||
float fWaveLength[4096] = { 0 };
|
||||
double dCal_Gain[4096] = { 0 };
|
||||
double dCal_Offset[4096] = { 0 };
|
||||
}CalFrame;
|
||||
|
||||
typedef struct tagCalDataFrame
|
||||
{
|
||||
ZZ_U32 usExposureTimeInMS;
|
||||
float fTemperature = 0;
|
||||
int iPixels;
|
||||
float fData[4096];
|
||||
QString qstrGrabDate;
|
||||
}CalDataFrame;
|
||||
}
|
||||
|
||||
//misc detector
|
||||
namespace MISC_DETECTOR
|
||||
{
|
||||
typedef struct tagHumitureDeviceInfo
|
||||
{
|
||||
QString qstrInterfaceName;
|
||||
}HumitureDeviceInfo;
|
||||
}
|
||||
};
|
||||
53
othersoft/calibration_console/Header_Files/atpFiberImager.h
Normal file
53
othersoft/calibration_console/Header_Files/atpFiberImager.h
Normal file
@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
#include <qthread.h>
|
||||
//#include <QFileDialog>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include "ATPControl_Serial_QT.h"
|
||||
#include "FiberSpectrometerOperationBase.h"
|
||||
|
||||
class ATPFiberImager :public QObject,public FiberSpectrometerOperationBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ATPFiberImager(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName);
|
||||
~ATPFiberImager();
|
||||
|
||||
ZZ_ATPControl_Serial_Qt * m_FiberSpectrometer;
|
||||
|
||||
void connectFiberSpectrometer(QString& sn, QString& pixelCount, QString& wavelengthInfo);
|
||||
void disconnectFiberSpectrometer();
|
||||
void getDeviceAttribute(DeviceAttribute& deviceAttribute);
|
||||
void getDeviceInfo(DeviceInfo& deviceInfo);
|
||||
|
||||
void setExposureTime(int iExposureTimeInMS);
|
||||
|
||||
void getExposureTime(int &iExposureTimeInMS);//ok
|
||||
void getDeviceTemperature(float &fTemperature);//ok
|
||||
|
||||
void singleShot(DataFrame &dfData);
|
||||
|
||||
void getNonlinearityCoeffs(coeffsFrame &coeffs);
|
||||
|
||||
ZZ_S32 GetMaxValue(ZZ_S32 * dark, int number);
|
||||
|
||||
// DataFrame m_IntegratingSphereData;
|
||||
// DataFrame m_DarkData;
|
||||
protected:
|
||||
private:
|
||||
std::string mUcPortNumber;
|
||||
|
||||
// ZZ_U32 m_MaxValueOfFiberSpectrometer;
|
||||
|
||||
public slots:
|
||||
void recordDark(QString path);
|
||||
void recordTarget(int recordTimes, QString path);
|
||||
void autoExpose();
|
||||
|
||||
signals:
|
||||
void sendExposureTimeSignal(int exposureTime);
|
||||
};
|
||||
51
othersoft/calibration_console/Header_Files/calibration.h
Normal file
51
othersoft/calibration_console/Header_Files/calibration.h
Normal file
@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
#include <qthread.h>
|
||||
//#include <QFileDialog>
|
||||
#include <QFile>
|
||||
#include <QDataStream>
|
||||
#include <QFileInfo>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include "ZZ_Types.h"
|
||||
#include "ZZ_Math.h"
|
||||
//#include "Dense"
|
||||
#include "Eigen/Dense"
|
||||
#include "unsupported/Eigen/Splines"
|
||||
|
||||
using namespace ZZ_MISCDEF::IRIS::FS;
|
||||
|
||||
class CalibrationAlgorithm :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CalibrationAlgorithm();
|
||||
~CalibrationAlgorithm();
|
||||
|
||||
void readAndResample_StandardLightFile(QString filePath, int integratingSphereDetectorValue, DeviceAttribute deviceAttribute, DeviceInfo deviceInfo);//
|
||||
|
||||
void produceCalfile(QString calFilePath, DeviceAttribute deviceAttribute, DataFrame integratingSphereData, DataFrame darkData);
|
||||
|
||||
|
||||
protected:
|
||||
private:
|
||||
double m_dStandardLightDataBase;//<2F><><EFBFBD><D7BC><EFBFBD>ļ<EFBFBD><C4BC>Ļ<EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD>
|
||||
double * m_dStandardLightWavelength;
|
||||
double * m_dStandardLightData;
|
||||
|
||||
double * m_dStandardLightWavelengthResampled;
|
||||
double * m_dStandardLightDataResampled;
|
||||
|
||||
double * m_gain;
|
||||
double * m_offset;
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
71
othersoft/calibration_console/Header_Files/library.h
Normal file
71
othersoft/calibration_console/Header_Files/library.h
Normal file
@ -0,0 +1,71 @@
|
||||
#ifndef OCEAN_LIB_LIBRARY_H
|
||||
#define OCEAN_LIB_LIBRARY_H
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
//#include <unistd.h>
|
||||
#include <chrono>
|
||||
|
||||
#include "api/SeaBreezeWrapper.h"
|
||||
|
||||
#include "IrisFiberSpectrometerBase.h"
|
||||
#include "api/seabreezeapi/SeaBreezeAPI.h"
|
||||
#include "api/seabreezeapi/NonlinearityCoeffsFeatureAdapter.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
class OceanOptics_lib :public CIrisFSBase
|
||||
{
|
||||
public:
|
||||
OceanOptics_lib();
|
||||
virtual ~OceanOptics_lib();
|
||||
public:
|
||||
//初始化设备
|
||||
//此处string为指明连接哪个ocean光谱仪的参数,可自行更换为其他c/c++标准类型
|
||||
//0为无错误,不同错误请返回不同值(不能确定:当不成功时SeaBreeze返回的错误代码error不为0 → 不敢将error直接返回)
|
||||
int Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName);//ok
|
||||
int Initialize();//ok
|
||||
|
||||
//关闭设备
|
||||
void Close();//ok
|
||||
|
||||
//单次数据采集
|
||||
int SingleShot(DataFrame &dfData);
|
||||
|
||||
//设置曝光时间
|
||||
int SetExposureTime(int iExposureTimeInMS);//ok
|
||||
|
||||
//获取曝光时间设置
|
||||
int GetExposureTime(int &iExposureTimeInMS);//ok
|
||||
|
||||
//设置目标温度
|
||||
int SetDeviceTemperature(float fTemperature);//ok
|
||||
|
||||
//获取温度设置
|
||||
int GetDeviceTemperature(float &fTemperature);//ok
|
||||
|
||||
//获取设备信息
|
||||
int GetDeviceInfo(DeviceInfo &Info);//ok
|
||||
|
||||
//获取设备特征数据
|
||||
int GetDeviceAttribute(DeviceAttribute &Attr);//ok
|
||||
|
||||
//tc
|
||||
static const char* get_error_string(int error);
|
||||
void test_nonlinearity_coeffs_feature();
|
||||
private:
|
||||
int m_iSpectralmeterHandle;
|
||||
DeviceInfo m_deviceInfo;
|
||||
int m_iExposureTime;
|
||||
|
||||
bool isSuccess(char* resultStr);
|
||||
|
||||
string GetDeviceType(int index);
|
||||
string GetSerialNumber(int index);
|
||||
};
|
||||
|
||||
#endif //OCEAN_LIB_LIBRARY_H
|
||||
|
||||
|
||||
@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
#include <qthread.h>
|
||||
//#include <QFileDialog>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include "library.h"
|
||||
#include "FiberSpectrometerOperationBase.h"
|
||||
|
||||
class OceanOpticsFiberImager :public QObject,public FiberSpectrometerOperationBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OceanOpticsFiberImager(double * nonlinearityCoeffs, int numberOfCoeffs);
|
||||
~OceanOpticsFiberImager();
|
||||
|
||||
OceanOptics_lib * m_FiberSpectrometer;
|
||||
|
||||
void connectFiberSpectrometer(QString& sn, QString& pixelCount, QString& wavelengthInfo);
|
||||
void disconnectFiberSpectrometer();
|
||||
void getDeviceAttribute(DeviceAttribute& deviceAttribute);
|
||||
void getDeviceInfo(DeviceInfo& deviceInfo);
|
||||
|
||||
void setExposureTime(int iExposureTimeInMS);
|
||||
|
||||
void getExposureTime(int &iExposureTimeInMS);//ok
|
||||
void getDeviceTemperature(float &fTemperature);//ok
|
||||
|
||||
void singleShot(DataFrame &dfData);
|
||||
|
||||
void getNonlinearityCoeffs(coeffsFrame &coeffs);
|
||||
|
||||
ZZ_S32 GetMaxValue(ZZ_S32 * dark, int number);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD>ζ<EFBFBD><CEB6><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
DeviceInfo m_deviceInfo;
|
||||
DeviceAttribute m_deviceAttribute;
|
||||
|
||||
// DataFrame m_IntegratingSphereData;
|
||||
// DataFrame m_DarkData;
|
||||
protected:
|
||||
private:
|
||||
double * m_nonlinearityCoeffs;
|
||||
int m_iNumberOfNonlinearityCoeffs;
|
||||
|
||||
// ZZ_U32 m_MaxValueOfFiberSpectrometer;
|
||||
|
||||
public slots:
|
||||
void recordDark(QString path);
|
||||
void recordTarget(int recordTimes, QString path);
|
||||
void autoExpose();
|
||||
|
||||
signals:
|
||||
void sendExposureTimeSignal(int exposureTime);
|
||||
};
|
||||
@ -0,0 +1,886 @@
|
||||
//#include "pch.h"
|
||||
#include "Header_Files/ATPControl_Serial_QT.h"
|
||||
//#include "ZZ_Math_HDRONLY.h"
|
||||
|
||||
ZZ_ATPControl_Serial_Qt::ZZ_ATPControl_Serial_Qt(QObject* parent /*= nullptr*/)
|
||||
{
|
||||
m_pSerialPort = new QSerialPort;
|
||||
m_iBaudRate = 115200;
|
||||
//emit SignalInit_Self();
|
||||
}
|
||||
|
||||
ZZ_ATPControl_Serial_Qt::~ZZ_ATPControl_Serial_Qt()//
|
||||
{
|
||||
if (m_pSerialPort != NULL)
|
||||
{
|
||||
delete m_pSerialPort;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// int ZZ_ATPControl_Serial_Qt::ReInit()
|
||||
// {
|
||||
// m_pSerialPort->close();
|
||||
// delete m_pSerialPort;
|
||||
//
|
||||
// m_pSerialPort = new QSerialPort;
|
||||
//
|
||||
// m_pSerialPort->setPortName("COM7");
|
||||
// m_pSerialPort->setReadBufferSize(512);
|
||||
// bool bRes = m_pSerialPort->setBaudRate(m_iBaudRate);
|
||||
// bRes = m_pSerialPort->open(QIODevice::ReadWrite);
|
||||
// }
|
||||
|
||||
// int ZZ_ATPControl_Serial_Qt::SetBaudRate(int iBaud)
|
||||
// {
|
||||
// m_iBaudRate = iBaud;
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName)
|
||||
{
|
||||
//connect(this, &ZZ_ATPControl_Serial_Qt::SignalInit_Self, this, &ZZ_ATPControl_Serial_Qt::Init_Self);
|
||||
//emit SignalInit_Self();
|
||||
|
||||
QString qstrPortName = QString::fromStdString(ucPortNumber);
|
||||
|
||||
m_pSerialPort->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;
|
||||
}
|
||||
|
||||
// int testi;
|
||||
// GetDeviceAttribute(m_daDeviceAttr);
|
||||
// GetExposureTime(testi);
|
||||
// SetExposureTime(10000);
|
||||
// DataFrame test;
|
||||
// SingleShot(test);
|
||||
|
||||
GetDeviceInfo(m_diDeviceInfo);
|
||||
GetExposureTime_Init();
|
||||
SetAvgTimes(1);
|
||||
|
||||
std::string::size_type szPostion = m_diDeviceInfo.strSN.find(strDeviceName);
|
||||
if (szPostion == std::string::npos)
|
||||
{
|
||||
qDebug() << "Err:FS serial number not match.Exit Code:3";
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
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;
|
||||
|
||||
///
|
||||
int iTempExpTime = 0;
|
||||
GetExposureTime(iTempExpTime);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
SetExposureTime(iTempExpTime);
|
||||
///
|
||||
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::SetAvgTimes(int iTimes /*= 1*/)
|
||||
{
|
||||
QByteArray qbSend, qbRecv;
|
||||
qbSend.clear();
|
||||
qbRecv.clear();
|
||||
qbSend.append(SET_AVERAGE_NUMBER);
|
||||
qbSend.resize(3);
|
||||
qbSend[1] = 0x00;
|
||||
qbSend[2] = 0x01;
|
||||
int iRes = SendCommand(qbSend);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SetAvgTimes Failed.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = RecvData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SetAvgTimes Failed.Exit Code:2";
|
||||
return 2;
|
||||
}
|
||||
iRes = ParseData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SetAvgTimes Failed.Exit Code:3";
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::GetExposureTime_Init()
|
||||
{
|
||||
QByteArray qbSend, qbRecv;
|
||||
qbSend.clear();
|
||||
qbRecv.clear();
|
||||
qbSend.append(GET_INTEGRATION_TIME);
|
||||
qbSend.resize(3);
|
||||
qbSend[1] = 0x00;
|
||||
qbSend[2] = 0x01;
|
||||
int iRes = SendCommand(qbSend);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetExposureTime Failed.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = RecvData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetExposureTime Failed.Exit Code:2";
|
||||
return 2;
|
||||
}
|
||||
iRes = ParseData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetExposureTime Failed.Exit Code:3";
|
||||
return 3;
|
||||
}
|
||||
|
||||
m_iExposureTime = (ZZ_U8)qbRecv[1] + (ZZ_U8)qbRecv[0] * 256;
|
||||
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(5000);
|
||||
QByteArray qbTemp = m_pSerialPort->readAll();
|
||||
qbData.append(qbTemp);
|
||||
|
||||
if (iCounter > 150)
|
||||
{
|
||||
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(5000);
|
||||
qbData.append(m_pSerialPort->readAll());
|
||||
|
||||
if (iCounter > 200)
|
||||
{
|
||||
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" << "Total Recv:" << qbData.size() << "Check Sum:" << usCheckSum << "Not Equal To" << ucTemp;
|
||||
//qbData.clear();
|
||||
//return 4;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::RecvData_ShortLag(QByteArray &qbData)
|
||||
{
|
||||
qbData.clear();
|
||||
qbData = m_pSerialPort->readAll();
|
||||
|
||||
int iCounter = 0;
|
||||
while (qbData.size() < 4)
|
||||
{
|
||||
m_pSerialPort->waitForReadyRead(100);
|
||||
QByteArray qbTemp = m_pSerialPort->readAll();
|
||||
qbData.append(qbTemp);
|
||||
|
||||
if (iCounter > 6)
|
||||
{
|
||||
qDebug() << "Err:RecvData_ShortLag 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_ShortLag 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(100);
|
||||
qbData.append(m_pSerialPort->readAll());
|
||||
|
||||
if (iCounter > 6)
|
||||
{
|
||||
qDebug() << "Err:RecvData_ShortLag 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_ShortLag Failed,Incorrect Check Sum.Exit Code:4" << "Total Recv:" << qbData.size() << "Check Sum:" << usCheckSum << "Not Equal To" << ucTemp;
|
||||
//qbData.clear();
|
||||
//return 4;
|
||||
return 0;
|
||||
}
|
||||
|
||||
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::Init_Self()
|
||||
{
|
||||
m_pSerialPort = new QSerialPort;
|
||||
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(m_daDeviceAttr.iMinIntegrationTimeInMS);//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;
|
||||
qDebug() << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>30<EFBFBD><EFBFBD>"<<endl;
|
||||
break;
|
||||
}
|
||||
|
||||
// fExposureTime = (float)m_daDeviceAttr.iMinIntegrationTimeInMS;
|
||||
int tc_tmp;
|
||||
GetExposureTime(tc_tmp);
|
||||
fExposureTime=tc_tmp;
|
||||
fTempExposureTime = fExposureTime;
|
||||
|
||||
iRes = SingleShot(dfTemp);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:PerformAutoExposure Failed.Exit Code:2"<<endl;
|
||||
return 2;
|
||||
}
|
||||
|
||||
HeapSort(dfTemp.lData, m_daDeviceAttr.iPixels);
|
||||
|
||||
double dSum = 0;
|
||||
int iCount = m_daDeviceAttr.iPixels / 100;
|
||||
for (int i = 0; i < iCount; i++)
|
||||
{
|
||||
dSum += dfTemp.lData[i];
|
||||
}
|
||||
double dTemp = dSum / iCount;
|
||||
qDebug() << "1111111111111111111111111111111" << dTemp << endl;
|
||||
|
||||
|
||||
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;
|
||||
continue;
|
||||
}
|
||||
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 < m_daDeviceAttr.iMinIntegrationTimeInMS)
|
||||
{
|
||||
bFlagIsAutoExposureOK = false;
|
||||
bFlagIsAutoExposureFailed = true;
|
||||
bFlagIsLowerMinExposureTime = true;
|
||||
|
||||
qDebug() << "lower-----------------------"<<endl;
|
||||
}
|
||||
|
||||
}
|
||||
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)
|
||||
{
|
||||
m_iExposureTime = iExposureTimeInMS;
|
||||
|
||||
QByteArray qbExposureTime, qbRecv;
|
||||
//qbExposureTime.append(SET_INTEGRATION_TIME);
|
||||
qbExposureTime.resize(3);
|
||||
qbExposureTime[0] = SET_INTEGRATION_TIME;
|
||||
qbExposureTime[1] = iExposureTimeInMS >> 8;
|
||||
qbExposureTime[2] = iExposureTimeInMS & 0xFF;
|
||||
|
||||
int iRes = SendCommand(qbExposureTime);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SetExposureTime Failed.Exit Code:2";
|
||||
return 2;
|
||||
}
|
||||
iRes = RecvData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SetExposureTime Failed.Exit Code:3";
|
||||
return 3;
|
||||
}
|
||||
iRes = ParseData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SetExposureTime Failed.Exit Code:4";
|
||||
return 4;
|
||||
}
|
||||
|
||||
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;
|
||||
// int iRes = SendCommand(qbSend);
|
||||
// if (iRes != 0)
|
||||
// {
|
||||
// qDebug() << "Err:GetExposureTime Failed.Exit Code:1";
|
||||
// return 1;
|
||||
// }
|
||||
// iRes = RecvData(qbRecv);
|
||||
// if (iRes != 0)
|
||||
// {
|
||||
// qDebug() << "Err:GetExposureTime Failed.Exit Code:2";
|
||||
// return 2;
|
||||
// }
|
||||
// iRes = ParseData(qbRecv);
|
||||
// if (iRes != 0)
|
||||
// {
|
||||
// qDebug() << "Err:GetExposureTime Failed.Exit Code:3";
|
||||
// return 3;
|
||||
// }
|
||||
//
|
||||
// iExposureTimeInMS = (ZZ_U8)qbRecv[1] + (ZZ_U8)qbRecv[0] * 256;
|
||||
iExposureTimeInMS = m_iExposureTime;
|
||||
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;
|
||||
qbSend[1] = m_iExposureTime >> 8;;
|
||||
qbSend[2] = m_iExposureTime & 0xFF;
|
||||
|
||||
qDebug() << "-------------"<<m_iExposureTime<<endl;
|
||||
|
||||
int iRes = SendCommand(qbSend);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SingleShot Failed.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = RecvData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SingleShot Failed.Exit Code:2";
|
||||
return 2;
|
||||
}
|
||||
iRes = ParseData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SingleShot Failed.Exit Code:3";
|
||||
return 3;
|
||||
}
|
||||
|
||||
ZZ_U16 usData[4096] = { 0 };
|
||||
|
||||
if ((ZZ_U8)qbRecv[0] != 0)
|
||||
{
|
||||
qDebug() << "Err:SingleShot Failed.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
//int aaa = qbRecv.size();
|
||||
int iDataSizeInPixel = (qbRecv.size() - 1) / 2;
|
||||
memcpy(usData, qbRecv.data() + 1, iDataSizeInPixel * 2);
|
||||
for (size_t i = 0; i < iDataSizeInPixel; i++)
|
||||
{
|
||||
dfData.lData[i] = qToBigEndian(usData[i]);
|
||||
|
||||
|
||||
}
|
||||
// for (int i = 0; i < iDataSizeInPixel; i++)
|
||||
// {
|
||||
// dfData.lData[i] = usData[i];
|
||||
// }
|
||||
}
|
||||
|
||||
dfData.usExposureTimeInMS = m_iExposureTime;
|
||||
|
||||
|
||||
|
||||
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;
|
||||
int iRes = SendCommand(qbSend);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SingleShotP Failed.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = RecvData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SingleShotP Failed.Exit Code:2";
|
||||
return 2;
|
||||
}
|
||||
iRes = ParseData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:SingleShot Failed.Exit Code:3";
|
||||
return 3;
|
||||
}
|
||||
|
||||
if ((ZZ_U8)qbRecv[0] != 0)
|
||||
{
|
||||
qDebug() << "Err:SingleShotP Failed.Exit Code:4";
|
||||
return 4;
|
||||
}
|
||||
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)
|
||||
{
|
||||
fTemperature = 0;
|
||||
|
||||
QByteArray qbSend, qbRecv;
|
||||
qbSend.clear();
|
||||
qbRecv.clear();
|
||||
qbSend.append(GET_TEC_TEMP);
|
||||
qbSend.resize(3);
|
||||
qbSend[1] = 0x00;
|
||||
qbSend[2] = 0x01;
|
||||
int iRes = SendCommand(qbSend);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceTemperature Failed.Exit Code:1";
|
||||
return 1;
|
||||
}
|
||||
iRes = RecvData_ShortLag(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceTemperature Failed.Exit Code:2";
|
||||
return 2;
|
||||
}
|
||||
iRes = ParseData(qbRecv);
|
||||
if (iRes != 0)
|
||||
{
|
||||
qDebug() << "Err:GetDeviceTemperature Failed.Exit Code:3";
|
||||
return 3;
|
||||
}
|
||||
|
||||
QString qstrTemp = qbRecv.data();
|
||||
fTemperature = qstrTemp.toFloat();
|
||||
|
||||
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;
|
||||
// }
|
||||
113
othersoft/calibration_console/Source_Files/ZZ_Math.cpp
Normal file
113
othersoft/calibration_console/Source_Files/ZZ_Math.cpp
Normal file
@ -0,0 +1,113 @@
|
||||
//#include "pch.h"
|
||||
#include "Header_Files/ZZ_Math.h"
|
||||
|
||||
void ZZ_MATH::PolyFit::Eigen_Polyfit(const std::vector<double> &xv, const std::vector<double> &yv, std::vector<double> &coeff, int order)
|
||||
{
|
||||
Eigen::MatrixXd A(xv.size(), order + 1);
|
||||
Eigen::VectorXd yv_mapped = Eigen::VectorXd::Map(&yv.front(), yv.size());
|
||||
Eigen::VectorXd result;
|
||||
|
||||
assert(xv.size() == yv.size());
|
||||
assert(xv.size() >= order + 1);
|
||||
|
||||
|
||||
for (size_t i = 0; i < xv.size(); i++)
|
||||
{
|
||||
for (size_t j = 0; j < order + 1; j++)
|
||||
{
|
||||
A(i, j) = pow(xv.at(i), j);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
result = A.householderQr().solve(yv_mapped);
|
||||
|
||||
coeff.resize(order + 1);
|
||||
for (size_t i = 0; i < order + 1; i++)
|
||||
{
|
||||
coeff[i] = result[i];
|
||||
}
|
||||
}
|
||||
|
||||
double ZZ_MATH::PolyFit::Eigen_Polyeval(std::vector<double> coeffs, double x)
|
||||
{
|
||||
double result = 0.0;
|
||||
|
||||
for (int i = 0; i < coeffs.size(); i++)
|
||||
{
|
||||
result += coeffs[i] * pow(x, i);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Eigen::VectorXd ZZ_MATH::SplineFit::Eigen_Normalize(const Eigen::VectorXd &x)
|
||||
{
|
||||
using namespace Eigen;
|
||||
VectorXd x_norm;
|
||||
x_norm.resize(x.size());
|
||||
const double min = x.minCoeff();
|
||||
const double max = x.maxCoeff();
|
||||
|
||||
for (int k = 0; k < x.size(); k++)
|
||||
{
|
||||
x_norm(k) = (x(k) - min) / (max - min);
|
||||
}
|
||||
|
||||
return x_norm;
|
||||
|
||||
}
|
||||
|
||||
void ZZ_MATH::SplineFit::Test(std::vector<double> const &x_vec, std::vector<double> const &y_vec)
|
||||
{
|
||||
typedef Spline<double, 1> Spline1D;
|
||||
typedef SplineFitting<Spline1D> Spline1DFitting;
|
||||
|
||||
|
||||
//VectorXd vx,vy;
|
||||
//vx.resize(x_vec.size());
|
||||
//vy.resize(y_vec.size());
|
||||
//vx.Map(&x_vec.front(), x_vec.size());
|
||||
//vy.Map(&y_vec.front(), y_vec.size());
|
||||
|
||||
Eigen::VectorXd vx = Eigen::VectorXd::Map(&x_vec.front(), 5/*x_vec.size()*/);
|
||||
Eigen::VectorXd vy = Eigen::VectorXd::Map(&y_vec.front(), 5/*y_vec.size()*/);
|
||||
|
||||
const double scale = 1 / (vx.maxCoeff() - vx.minCoeff());
|
||||
const double scale_sq = scale * scale;
|
||||
|
||||
//VectorXd knots = Eigen_Normalize(vx);
|
||||
//Spline1D spline = Spline1DFitting::Interpolate(vy.transpose(),3, knots);
|
||||
//double a;
|
||||
// a = spline.derivatives(0,1)(0);
|
||||
//Eigen::VectorXd xvals(5);
|
||||
//Eigen::VectorXd yvals(xvals.rows());
|
||||
//xvals << 0, 1, 2,3,4;
|
||||
//yvals << 0, 1, 4,9,16;
|
||||
|
||||
SplineInterpolation s(vx, vy);
|
||||
}
|
||||
|
||||
ZZ_MATH::SplineFit::SplineInterpolation::SplineInterpolation(Eigen::VectorXd const &x_vec, Eigen::VectorXd const &y_vec):
|
||||
x_min(x_vec.minCoeff()), x_max(x_vec.maxCoeff()),
|
||||
spline_(Eigen::SplineFitting<Eigen::Spline<double, 1>>::
|
||||
Interpolate(y_vec.transpose(), 3, scaled_values(x_vec)))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
double ZZ_MATH::SplineFit::SplineInterpolation::operator()(double x) const
|
||||
{
|
||||
return spline_(scaled_value(x))(0);
|
||||
}
|
||||
|
||||
double ZZ_MATH::SplineFit::SplineInterpolation::scaled_value(double x) const
|
||||
{
|
||||
return (x - x_min) / (x_max - x_min);
|
||||
}
|
||||
|
||||
Eigen::RowVectorXd ZZ_MATH::SplineFit::SplineInterpolation::scaled_values(Eigen::VectorXd const &x_vec) const
|
||||
{
|
||||
return x_vec.unaryExpr([this](double x) { return scaled_value(x); }).transpose();
|
||||
}
|
||||
194
othersoft/calibration_console/Source_Files/atpFiberImager.cpp
Normal file
194
othersoft/calibration_console/Source_Files/atpFiberImager.cpp
Normal file
@ -0,0 +1,194 @@
|
||||
#include "Header_Files/atpFiberImager.h"
|
||||
|
||||
ATPFiberImager::ATPFiberImager(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName)
|
||||
{
|
||||
m_FiberSpectrometer = NULL;
|
||||
|
||||
mUcPortNumber=ucPortNumber;
|
||||
}
|
||||
|
||||
ATPFiberImager::~ATPFiberImager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ATPFiberImager::connectFiberSpectrometer(QString& SN, QString& pixelCount, QString& wavelengthInfo)
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
m_FiberSpectrometer = new ZZ_ATPControl_Serial_Qt();
|
||||
|
||||
m_FiberSpectrometer->Initialize(false, mUcPortNumber, "OPTOSKY");
|
||||
|
||||
DeviceInfo deviceInfo;//
|
||||
DeviceAttribute deviceAttribute;
|
||||
|
||||
m_FiberSpectrometer->GetDeviceInfo(deviceInfo);
|
||||
m_FiberSpectrometer->GetDeviceAttribute(deviceAttribute);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
SN = QString::fromStdString(deviceInfo.strSN);
|
||||
pixelCount = QString::number(deviceAttribute.iPixels);
|
||||
wavelengthInfo = QString::number(deviceAttribute.fWaveLengthInNM[0]) + "--" + QString::number(deviceAttribute.fWaveLengthInNM[deviceAttribute.iPixels - 1]);
|
||||
|
||||
m_FiberSpectrometer->SetDeviceTemperature(-10);
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>dnֵ<6E><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD>
|
||||
string qepro = "QEP";//?????????????????????????????????????????????????????????????????????????????????????????
|
||||
string flame = "FLMS";//?????????????????????????????????????????????????????????????????????????????????????????
|
||||
if (deviceInfo.strSN.find(qepro) != string::npos)
|
||||
{
|
||||
m_MaxValueOfFiberSpectrometer = 200000;
|
||||
}
|
||||
else if (deviceInfo.strSN.find(flame) != string::npos)
|
||||
{
|
||||
m_MaxValueOfFiberSpectrometer = 65535;
|
||||
}
|
||||
else//û<><C3BB><EFBFBD>ҵ<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> dnֵ<6E><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ATPFiberImager::disconnectFiberSpectrometer()
|
||||
{
|
||||
m_FiberSpectrometer->Close();
|
||||
}
|
||||
|
||||
void ATPFiberImager::getDeviceAttribute(DeviceAttribute& deviceAttribute)
|
||||
{
|
||||
m_FiberSpectrometer->GetDeviceAttribute(deviceAttribute);
|
||||
}
|
||||
|
||||
void ATPFiberImager::getDeviceInfo(DeviceInfo& deviceInfo)
|
||||
{
|
||||
m_FiberSpectrometer->GetDeviceInfo(deviceInfo);
|
||||
}
|
||||
|
||||
void ATPFiberImager::setExposureTime(int iExposureTimeInMS)
|
||||
{
|
||||
m_FiberSpectrometer->SetExposureTime(iExposureTimeInMS);
|
||||
}
|
||||
|
||||
void ATPFiberImager::getExposureTime(int &iExposureTimeInMS)
|
||||
{
|
||||
m_FiberSpectrometer->GetExposureTime(iExposureTimeInMS);
|
||||
}
|
||||
|
||||
void ATPFiberImager::getDeviceTemperature(float &fTemperature)
|
||||
{
|
||||
m_FiberSpectrometer->GetDeviceTemperature(fTemperature);
|
||||
}
|
||||
|
||||
void ATPFiberImager::singleShot(DataFrame &dfData)
|
||||
{
|
||||
m_FiberSpectrometer->SingleShot(dfData);
|
||||
}
|
||||
|
||||
void ATPFiberImager::getNonlinearityCoeffs(coeffsFrame &coeffs)
|
||||
{
|
||||
printf("This is ATPFiberImager.\n");
|
||||
}
|
||||
|
||||
void ATPFiberImager::recordDark(QString path)
|
||||
{
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
||||
DeviceAttribute attribute;
|
||||
DeviceInfo deviceInfo;
|
||||
getDeviceAttribute(attribute);
|
||||
getDeviceInfo(deviceInfo);
|
||||
|
||||
//<2F>ɼ<EFBFBD><C9BC><EFBFBD>֡
|
||||
singleShot(m_DarkData);
|
||||
|
||||
// //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>csv
|
||||
// QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
// QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss");
|
||||
// QString fileName = path + "/" + currentTime + "_" + QString::fromStdString(deviceInfo.strSN) + "_darkSpectral.csv";
|
||||
// std::ofstream outfile(fileName.toStdString().c_str());
|
||||
//
|
||||
// for (int i = 0; i < attribute.iPixels; i++)
|
||||
// {
|
||||
// if (i==0)
|
||||
// {
|
||||
// outfile << m_DarkData.usExposureTimeInMS << std::endl;
|
||||
// }
|
||||
// outfile << attribute.fWaveLengthInNM[i] << "," << m_DarkData.lData[i] << std::endl;
|
||||
// }
|
||||
//
|
||||
// outfile.close();
|
||||
}
|
||||
|
||||
void ATPFiberImager::recordTarget(int recordTimes, QString path)
|
||||
{
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
||||
DeviceAttribute attribute;
|
||||
DeviceInfo deviceInfo;
|
||||
getDeviceAttribute(attribute);
|
||||
getDeviceInfo(deviceInfo);
|
||||
|
||||
|
||||
DataFrame integratingSphereData_tmp;
|
||||
|
||||
for (int i = 0; i < recordTimes; i++)
|
||||
{
|
||||
singleShot(integratingSphereData_tmp);
|
||||
|
||||
if (i == 0)//<2F><>integratingSphereData_tmp<6D>е<EFBFBD><D0B5>ع<EFBFBD>ʱ<EFBFBD>䡢<EFBFBD>¶ȵ<C2B6><C8B5><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>m_IntegratingSphereData
|
||||
{
|
||||
m_IntegratingSphereData = integratingSphereData_tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < attribute.iPixels; i++)
|
||||
{
|
||||
m_IntegratingSphereData.lData[i] += integratingSphereData_tmp.lData[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < attribute.iPixels; i++)
|
||||
{
|
||||
m_IntegratingSphereData.lData[i] = m_IntegratingSphereData.lData[i] / recordTimes;
|
||||
}
|
||||
|
||||
|
||||
// //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>csv
|
||||
// QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
// QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss");
|
||||
// QString fileName = path + "/" + currentTime + "_" + QString::fromStdString(deviceInfo.strSN) + "_integratingSphereSpectral.csv";
|
||||
// std::ofstream outfile(fileName.toStdString().c_str());
|
||||
//
|
||||
// for (int i = 0; i < attribute.iPixels; i++)
|
||||
// {
|
||||
// if (i==0)
|
||||
// {
|
||||
// outfile << m_IntegratingSphereData.usExposureTimeInMS << std::endl;
|
||||
// }
|
||||
// outfile << attribute.fWaveLengthInNM[i] << "," << m_IntegratingSphereData.lData[i] << std::endl;
|
||||
// }
|
||||
//
|
||||
// outfile.close();
|
||||
}
|
||||
|
||||
void ATPFiberImager::autoExpose()
|
||||
{
|
||||
float fPredictedExposureTime;
|
||||
m_FiberSpectrometer->PerformAutoExposure(0.6,0.9,fPredictedExposureTime);
|
||||
}
|
||||
|
||||
ZZ_S32 ATPFiberImager::GetMaxValue(ZZ_S32 * dark, int number)
|
||||
{
|
||||
ZZ_S32 max = 0;
|
||||
for (size_t i = 0; i < number; i++)
|
||||
{
|
||||
if (dark[i] > max)
|
||||
{
|
||||
max = dark[i];
|
||||
}
|
||||
}
|
||||
//std::cout << "<22><>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>ֵΪ" << max << std::endl;
|
||||
return max;
|
||||
}
|
||||
246
othersoft/calibration_console/Source_Files/calibration.cpp
Normal file
246
othersoft/calibration_console/Source_Files/calibration.cpp
Normal file
@ -0,0 +1,246 @@
|
||||
#include "Header_Files/calibration.h"
|
||||
|
||||
CalibrationAlgorithm::CalibrationAlgorithm()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CalibrationAlgorithm::~CalibrationAlgorithm()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CalibrationAlgorithm::readAndResample_StandardLightFile(QString filePath, int integratingSphereDetectorValue, DeviceAttribute deviceAttribute, DeviceInfo deviceInfo)
|
||||
{
|
||||
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
std::cout << "<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>" << std::endl;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int lineCount = 0;
|
||||
while (!file.atEnd())
|
||||
{
|
||||
QByteArray tmp = file.readLine();
|
||||
lineCount++;
|
||||
}
|
||||
double * StandardLightWavelength_tmp = new double[lineCount - 1];
|
||||
double * StandardLightData_tmp = new double[lineCount - 1];
|
||||
|
||||
|
||||
file.seek(0);
|
||||
for (size_t i = 0; i < lineCount; i++)
|
||||
{
|
||||
QByteArray line = file.readLine();
|
||||
QString str(line);
|
||||
//cout << str.section('\t', 1).trimmed().toStdString() << endl;
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
QString first = str.section('\t', 0, 0);
|
||||
m_dStandardLightDataBase = first.toDouble();
|
||||
}
|
||||
else
|
||||
{
|
||||
QString first = str.section('\t', 0, 0);
|
||||
QString second = str.section('\t', 1, 1);
|
||||
StandardLightWavelength_tmp[i - 1] = first.toDouble();
|
||||
StandardLightData_tmp[i - 1] = second.toDouble();
|
||||
|
||||
//if (i== lineCount-1)//<2F>鿴<EFBFBD><E9BFB4><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ȷ
|
||||
//{
|
||||
// double xx = first.toDouble();
|
||||
// double yy = second.toDouble();
|
||||
// std::cout << "xx<78><78>" << xx <<std::endl;
|
||||
// std::cout << "yy<79><79>" << yy << std::endl;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD>Ч<EFBFBD><D0A7>
|
||||
int startPos, endPos;
|
||||
int buffer = 3;//<2F><>Ҫ<EFBFBD><D2AA><EFBFBD>DZ<EFBFBD><EFBFBD><D7BC>ԭʼ<D4AD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//QString biaozhundengfanwei = QString::number(StandardLightWavelength_tmp[0]) + "--" + QString::number(StandardLightWavelength_tmp[lineCount - 2]);
|
||||
|
||||
if (deviceAttribute.fWaveLengthInNM[0] < StandardLightWavelength_tmp[0])//<2F><><EFBFBD><D7BC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Χδ<CEA7><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>
|
||||
{
|
||||
startPos = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t i = 0; i < lineCount - 1; i++)
|
||||
{
|
||||
if (deviceAttribute.fWaveLengthInNM[0] < StandardLightWavelength_tmp[i])
|
||||
{
|
||||
startPos = i - buffer;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (deviceAttribute.fWaveLengthInNM[deviceAttribute.iPixels - 1] > StandardLightWavelength_tmp[lineCount - 2])//<2F><><EFBFBD><D7BC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>Χδ<CEA7><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
endPos = lineCount - 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t i = 0; i < lineCount - 1; i++)
|
||||
{
|
||||
if (deviceAttribute.fWaveLengthInNM[deviceAttribute.iPixels - 1] < StandardLightWavelength_tmp[i])
|
||||
{
|
||||
endPos = i + buffer;//??
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_dStandardLightWavelength = new double[endPos - startPos];
|
||||
m_dStandardLightData = new double[endPos - startPos];
|
||||
|
||||
for (size_t i = 0; i < endPos - startPos; i++)
|
||||
{
|
||||
m_dStandardLightWavelength[i] = StandardLightWavelength_tmp[i + startPos];
|
||||
m_dStandardLightData[i] = StandardLightData_tmp[i + startPos];
|
||||
}
|
||||
|
||||
|
||||
|
||||
// //<2F><><EFBFBD>ضϱ<D8B6><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>csv
|
||||
// QFileInfo fileInfo(filePath);
|
||||
// QString standardLightFileFolder = fileInfo.path();
|
||||
// QString standardLightFileName = fileInfo.fileName();
|
||||
//
|
||||
// QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
// QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss");
|
||||
//
|
||||
// QString tmp = standardLightFileFolder + "/" + currentTime + "_" + QString::fromStdString(deviceInfo.strSN) +"_"+ standardLightFileName + "_truncation.csv";
|
||||
//
|
||||
// std::ofstream outfile1(tmp.toStdString().c_str());
|
||||
//
|
||||
// for (size_t i = 0; i < endPos - startPos; i++)
|
||||
// {
|
||||
// if (i == 0)
|
||||
// {
|
||||
// outfile1 << m_dStandardLightDataBase << std::endl;
|
||||
// }
|
||||
//
|
||||
// outfile1 << m_dStandardLightWavelength[i] << "," << m_dStandardLightData[i] << std::endl;
|
||||
// }
|
||||
// outfile1.close();
|
||||
|
||||
|
||||
|
||||
//<2F>ز<EFBFBD><D8B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Eigen::VectorXd vx = Eigen::VectorXd::Map(m_dStandardLightWavelength, endPos - startPos/*x_vec.size()*/);
|
||||
Eigen::VectorXd vy = Eigen::VectorXd::Map(m_dStandardLightData, endPos - startPos/*y_vec.size()*/);
|
||||
|
||||
using namespace ZZ_MATH::SplineFit;
|
||||
SplineInterpolation m_sfLine(vx, vy);
|
||||
|
||||
m_dStandardLightWavelengthResampled = new double[deviceAttribute.iPixels];
|
||||
m_dStandardLightDataResampled = new double[deviceAttribute.iPixels];
|
||||
|
||||
double dTemp,scaleFactor;
|
||||
if(integratingSphereDetectorValue <= 0)
|
||||
scaleFactor=1;
|
||||
else
|
||||
scaleFactor=integratingSphereDetectorValue/m_dStandardLightDataBase;
|
||||
|
||||
for (size_t i = 0; i < deviceAttribute.iPixels; i++)
|
||||
{
|
||||
if (deviceAttribute.fWaveLengthInNM[i] < StandardLightWavelength_tmp[0])//<2F>˲<EFBFBD><CBB2><EFBFBD> < <20><><EFBFBD><D7BC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>
|
||||
{
|
||||
dTemp = m_sfLine(StandardLightWavelength_tmp[0]);//???????????????
|
||||
}
|
||||
else if (StandardLightWavelength_tmp[lineCount - 2] < deviceAttribute.fWaveLengthInNM[i])//<2F><><EFBFBD><D7BC><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD> < <20>˲<EFBFBD><CBB2><EFBFBD>
|
||||
{
|
||||
dTemp = m_sfLine(StandardLightWavelength_tmp[lineCount - 2]);//???????????????
|
||||
}
|
||||
else
|
||||
{
|
||||
dTemp = m_sfLine(deviceAttribute.fWaveLengthInNM[i]);//?????
|
||||
}
|
||||
|
||||
//double dTemp2 = m_sfLine(deviceAttribute.fWaveLengthInNM[i]);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ʹ<EFBFBD><CAB9>
|
||||
|
||||
m_dStandardLightWavelengthResampled[i] = deviceAttribute.fWaveLengthInNM[i];
|
||||
m_dStandardLightDataResampled[i] = dTemp * scaleFactor;
|
||||
}
|
||||
|
||||
|
||||
// //<2F><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>csv
|
||||
// QString outputName = standardLightFileFolder + "/" + currentTime + "_" + QString::fromStdString(deviceInfo.strSN) + "_" + standardLightFileName + "_resample.csv";
|
||||
// std::ofstream outfile2(outputName.toStdString().c_str());
|
||||
// for (size_t i = 0; i < deviceAttribute.iPixels; i++)
|
||||
// {
|
||||
// if (i == 0)
|
||||
// {
|
||||
// outfile2 << m_dStandardLightDataBase << std::endl;
|
||||
// }
|
||||
//
|
||||
// outfile2 << deviceAttribute.fWaveLengthInNM[i] << "," << m_dStandardLightDataResampled[i] << std::endl;
|
||||
// }
|
||||
// outfile2.close();
|
||||
}
|
||||
|
||||
void CalibrationAlgorithm::produceCalfile(QString calFilePath, DeviceAttribute deviceAttribute, DataFrame integratingSphereData, DataFrame darkData)
|
||||
{
|
||||
using namespace ZZ_MISCDEF;//ZZ_U32
|
||||
|
||||
int errorCode;
|
||||
size_t writeCounter;
|
||||
|
||||
double* m_gain = new double[deviceAttribute.iPixels];//double*
|
||||
double* m_offset = new double[deviceAttribute.iPixels];//double*
|
||||
|
||||
for (size_t i = 0; i < deviceAttribute.iPixels; i++)
|
||||
{
|
||||
if (integratingSphereData.lData[i] - darkData.lData[i] == 0)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸΪ<C4B8><CEAA>
|
||||
{
|
||||
m_gain[i] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_gain[i] = m_dStandardLightDataResampled[i] / (integratingSphereData.lData[i] - darkData.lData[i]);
|
||||
}
|
||||
|
||||
m_offset[i] = 0;
|
||||
}
|
||||
|
||||
//д<>뵽<EFBFBD><EBB5BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
FILE * calFileHandle = fopen(calFilePath.toStdString().c_str(), "wb");
|
||||
|
||||
writeCounter = fwrite(&integratingSphereData.usExposureTimeInMS,sizeof(ZZ_U32), 1, calFileHandle);//<2F>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
writeCounter = fwrite(&integratingSphereData.fTemperature, sizeof(float), 1, calFileHandle);//<2F>¶<EFBFBD>
|
||||
writeCounter = fwrite(&deviceAttribute.iPixels, sizeof(int), 1, calFileHandle);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
writeCounter = fwrite(&deviceAttribute.fWaveLengthInNM, sizeof(float), deviceAttribute.iPixels, calFileHandle);//<2F><><EFBFBD><EFBFBD>
|
||||
writeCounter = fwrite(m_gain, sizeof(double), deviceAttribute.iPixels, calFileHandle);//gain
|
||||
writeCounter = fwrite(m_offset, sizeof(double), deviceAttribute.iPixels, calFileHandle);//offset
|
||||
|
||||
fclose(calFileHandle);
|
||||
|
||||
|
||||
//д<>뵽CSV<53>ļ<EFBFBD>
|
||||
QString calFile_csv = calFilePath.split(".")[0] + ".csv";
|
||||
std::ofstream outfile(calFile_csv.toStdString().c_str());
|
||||
for (int i = 0; i < deviceAttribute.iPixels; i++)
|
||||
{
|
||||
if (i==0)
|
||||
{
|
||||
outfile << integratingSphereData.usExposureTimeInMS << std::endl;
|
||||
}
|
||||
|
||||
outfile << deviceAttribute.fWaveLengthInNM[i] << "," << m_gain[i] << std::endl;
|
||||
}
|
||||
outfile.close();
|
||||
|
||||
delete[] m_gain;
|
||||
}
|
||||
635
othersoft/calibration_console/Source_Files/library.cpp
Normal file
635
othersoft/calibration_console/Source_Files/library.cpp
Normal file
@ -0,0 +1,635 @@
|
||||
#include "Header_Files/library.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
|
||||
OceanOptics_lib::OceanOptics_lib()
|
||||
{
|
||||
m_iSpectralmeterHandle = -100;
|
||||
}
|
||||
|
||||
OceanOptics_lib::~OceanOptics_lib()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//ʹ<><CAB9>ͷ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>#include "api/SeaBreezeWrapper.h"
|
||||
int OceanOptics_lib::Initialize(bool bIsUSBMode, std::string ucPortNumber, std::string strDeviceName)
|
||||
{
|
||||
int flag;
|
||||
int error;
|
||||
char type[16];
|
||||
int device_count = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < SEABREEZE_MAX_DEVICES; i++)
|
||||
{
|
||||
// printf("\nOpening spectrometer %d.\n", i);
|
||||
flag = seabreeze_open_spectrometer(i, &error);
|
||||
// printf("Open spectrometer result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
if (0 == flag)
|
||||
{
|
||||
device_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
string sn = GetSerialNumber(i);
|
||||
|
||||
if (strcmp(sn.c_str(), strDeviceName.c_str()) == 0)
|
||||
{
|
||||
m_iSpectralmeterHandle = i;
|
||||
// printf("\nfind!!!!!!!!!!!!\n");
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// printf("\nClosing spectrometer %d.\n", i);
|
||||
flag = seabreeze_close_spectrometer(i, &error);
|
||||
// printf("Close spectrometer result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
}
|
||||
}
|
||||
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
// printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
seabreeze_set_trigger_mode(m_iSpectralmeterHandle, &error, 0);
|
||||
|
||||
long test = seabreeze_get_buffer_capacity_minimum(m_iSpectralmeterHandle, &error);
|
||||
seabreeze_set_buffer_capacity(m_iSpectralmeterHandle, &error, test);
|
||||
|
||||
// printf("seabreeze_set_trigger_mode: Result is [%s]\n", get_error_string(error));
|
||||
|
||||
|
||||
|
||||
//<2F><><EFBFBD>ó<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
long minimum_time;
|
||||
minimum_time = seabreeze_get_min_integration_time_microsec(m_iSpectralmeterHandle, &error);
|
||||
//printf("...Minimum is %ld microseconds, result is [%s]\n", minimum_time, get_error_string(error));
|
||||
bool ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
// printf("\n-------------------û<>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (minimum_time < 0) {
|
||||
/* If there was an error, reset to a time that is supported widely. */
|
||||
minimum_time = 15000;
|
||||
return 1;
|
||||
}
|
||||
|
||||
SetExposureTime(minimum_time / 1000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//ʹ<><CAB9>ͷ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>#include "api/SeaBreezeWrapper.h"
|
||||
int OceanOptics_lib::Initialize()
|
||||
{
|
||||
int flag;
|
||||
int error;
|
||||
char type[16];
|
||||
int device_count = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < SEABREEZE_MAX_DEVICES; i++)
|
||||
{
|
||||
printf("\nOpening spectrometer %d.\n", i);
|
||||
flag = seabreeze_open_spectrometer(i, &error);
|
||||
//printf("Open spectrometer result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
if (0 == flag)
|
||||
{
|
||||
m_iSpectralmeterHandle = i;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
seabreeze_set_trigger_mode(m_iSpectralmeterHandle, &error, 0);
|
||||
seabreeze_set_trigger_mode(m_iSpectralmeterHandle, &error, 0);
|
||||
seabreeze_set_trigger_mode(m_iSpectralmeterHandle, &error, 0);
|
||||
|
||||
long test = seabreeze_get_buffer_capacity_minimum(m_iSpectralmeterHandle, &error);
|
||||
printf("seabreeze_get_buffer_capacity_minimum: Result is [%s]\n", get_error_string(error));
|
||||
seabreeze_set_buffer_capacity(m_iSpectralmeterHandle, &error, test);
|
||||
printf("seabreeze_set_buffer_capacity: Result is [%s]\n", get_error_string(error));
|
||||
|
||||
// printf("seabreeze_set_trigger_mode: Result is [%s]\n", get_error_string(error));
|
||||
|
||||
//<2F><><EFBFBD>ó<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
long minimum_time;
|
||||
|
||||
minimum_time = seabreeze_get_min_integration_time_microsec(m_iSpectralmeterHandle, &error);
|
||||
//printf("...Minimum is %ld microseconds, result is [%s]\n", minimum_time, get_error_string(error));
|
||||
bool ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
// printf("\n-------------------û<>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (minimum_time < 0) {
|
||||
/* If there was an error, reset to a time that is supported widely. */
|
||||
minimum_time = 15000;
|
||||
return 1;
|
||||
}
|
||||
|
||||
SetExposureTime(minimum_time / 1000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//ʹ<><CAB9>ͷ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>#include "api/seabreezeapi/SeaBreezeAPI.h"
|
||||
//int OceanOptics_lib::Initialize(bool bIsUSBMode,ZZ_U8 ucPortNumber,std::string strDeviceName)
|
||||
//{
|
||||
// int number_of_devices;
|
||||
// long *device_ids;
|
||||
// int i;
|
||||
// int flag;
|
||||
// int error = 0;
|
||||
// char nameBuffer[80];
|
||||
// char *serialNumber;
|
||||
//
|
||||
//
|
||||
//// /* Give the driver a chance to initialize itself */
|
||||
//// sbapi_initialize();
|
||||
//
|
||||
// printf("Probing for devices...\n"); fflush(stdout);
|
||||
// sbapi_probe_devices();
|
||||
//
|
||||
// printf("Getting device count...\n"); fflush(stdout);
|
||||
// number_of_devices = sbapi_get_number_of_device_ids();
|
||||
// std::cout<<"Device count is "<< number_of_devices <<std::endl;
|
||||
// if(0 == number_of_devices) {
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// printf("Getting device IDs...\n");
|
||||
// device_ids = (long *)calloc(number_of_devices, sizeof(long));
|
||||
// number_of_devices = sbapi_get_device_ids(device_ids, number_of_devices);
|
||||
// printf("Got %d device ID%s.\n", number_of_devices, number_of_devices == 1 ? "" : "s"); fflush(stdout);
|
||||
//
|
||||
//
|
||||
// for(i = 0; i < number_of_devices; i++)
|
||||
// {
|
||||
// printf("%d: Device 0x%02lX:\n", i, device_ids[i]);
|
||||
//// printf("\tGetting device type...\n");
|
||||
// flag = sbapi_get_device_type(device_ids[i], &error, nameBuffer, 79);
|
||||
//// printf("\t\tResult is (%d) [%s]\n", flag, sbapi_get_error_string(error));
|
||||
// if(flag > 0) {
|
||||
// printf("\tDevice type: [%s]\n", nameBuffer);
|
||||
// }
|
||||
//
|
||||
// serialNumber = GetSerialNumber(device_ids[i]);
|
||||
// serialNumber = GetSerialNumber(device_ids[i]);
|
||||
//
|
||||
// printf("\tSerial number tc: [%s]\n", serialNumber);
|
||||
//
|
||||
//// /* Open the device */
|
||||
//// printf("\tAttempting to open:\n");
|
||||
//// flag = sbapi_open_device(device_ids[i], &error);
|
||||
//// printf("\t\tResult is (%d) [%s]\n", flag, sbapi_get_error_string(error));
|
||||
////
|
||||
//// // jump to the next iteration if there was a problem
|
||||
//// if(flag != 0) {
|
||||
//// continue;
|
||||
//// }
|
||||
////
|
||||
//// // log deviations
|
||||
//// unsupportedFeatureCount=0;
|
||||
//// testFailureCount=0;
|
||||
////
|
||||
//// /* Test the device */
|
||||
//// for(test_index = 0; test_index < __test_function_count; test_index++) {
|
||||
//// /* Invoke each of the test functions against this device */
|
||||
//// __test_functions[test_index](device_ids[i], &unsupportedFeatureCount, &testFailureCount);
|
||||
//// }
|
||||
////
|
||||
//// /* Close the device */
|
||||
//// printf("\tAttempting to close:\n");
|
||||
//// sbapi_close_device(device_ids[i], &error);
|
||||
//// printf("\t\tResult is (%d) [%s]\n", flag, sbapi_get_error_string(error));
|
||||
//// printf("%d: Device 0x%02lX: \n\tNumber of unsupported features = %d\n\tNumber of test failures = %d\n", i, device_ids[i], unsupportedFeatureCount, testFailureCount);
|
||||
// }
|
||||
//
|
||||
// flag = sbapi_get_device_type(device_ids[i], &error, nameBuffer, 79);
|
||||
//
|
||||
// return 1;
|
||||
//}
|
||||
|
||||
//<2F>ر<EFBFBD><D8B1>豸
|
||||
void OceanOptics_lib::Close()
|
||||
{
|
||||
int flag;
|
||||
int error;
|
||||
|
||||
flag = seabreeze_close_spectrometer(m_iSpectralmeterHandle, &error);
|
||||
// printf("Close spectrometer result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲɼ<DDB2>
|
||||
int OceanOptics_lib::SingleShot(DataFrame &dfData)
|
||||
{
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int error;
|
||||
int flag;
|
||||
int spec_length;
|
||||
double *spectrum = 0;
|
||||
bool ret;
|
||||
|
||||
// printf("\n\nGetting formatted spectrum length.\n");
|
||||
spec_length = seabreeze_get_formatted_spectrum_length(m_iSpectralmeterHandle, &error);
|
||||
//printf("Get formatted spectrum_length result is (%d) [%s]\n", spec_length, get_error_string(error));
|
||||
ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (spec_length > 0)
|
||||
{
|
||||
spectrum = (double *)calloc((size_t)spec_length, sizeof(double));
|
||||
seabreeze_clear_buffer(m_iSpectralmeterHandle, &error);
|
||||
|
||||
auto startTime = std::chrono::high_resolution_clock::now();
|
||||
|
||||
flag = seabreeze_get_formatted_spectrum(m_iSpectralmeterHandle, &error, spectrum, spec_length);
|
||||
|
||||
auto endTime = std::chrono::high_resolution_clock::now();
|
||||
std::chrono::duration<double, std::milli> fp_ms = endTime - startTime;
|
||||
std::cout << "<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD>ʱΪ<EFBFBD><EFBFBD>" << fp_ms.count() / 1000 << "s." << std::endl;
|
||||
|
||||
// printf("Get formatted spectrum result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
// printf("\tPixel value 20 is %1.2f\n", spectrum[20]);
|
||||
ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (int tmp = 0; tmp < spec_length; tmp++)
|
||||
{
|
||||
dfData.lData[tmp] = spectrum[tmp];
|
||||
}
|
||||
|
||||
int exposureTimeInMS;
|
||||
GetExposureTime(exposureTimeInMS);
|
||||
dfData.usExposureTimeInMS = exposureTimeInMS;
|
||||
|
||||
float temperature;
|
||||
GetDeviceTemperature(temperature);
|
||||
dfData.fTemperature = temperature;
|
||||
|
||||
free(spectrum);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
int OceanOptics_lib::SetExposureTime(int iExposureTimeInMS)
|
||||
{
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
// printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int error;
|
||||
|
||||
seabreeze_set_trigger_mode(m_iSpectralmeterHandle, &error, 0); // trigger to normal
|
||||
seabreeze_set_integration_time_microsec(m_iSpectralmeterHandle, &error, iExposureTimeInMS * 1000);
|
||||
printf("Set integration time result is [%s]\n", get_error_string(error));
|
||||
|
||||
bool ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_iExposureTime = iExposureTimeInMS;
|
||||
|
||||
|
||||
|
||||
// //----------------------------------------------------------------------------------------------------------------
|
||||
// int error;
|
||||
// long *spectrometer_ids;
|
||||
// int number_of_spectrometers;
|
||||
//
|
||||
// number_of_spectrometers = sbapi_get_number_of_spectrometer_features(m_iSpectralmeterHandle, &error);
|
||||
// printf("\t\t\tResult is %d [%s]\n", number_of_spectrometers, sbapi_get_error_string(error));
|
||||
// spectrometer_ids = (long *)calloc(number_of_spectrometers, sizeof(long));
|
||||
// number_of_spectrometers = sbapi_get_spectrometer_features(m_iSpectralmeterHandle, &error, spectrometer_ids, number_of_spectrometers);
|
||||
// printf("\t\t\tResult is %d [%s]\n", number_of_spectrometers, sbapi_get_error_string(error));
|
||||
//
|
||||
// sbapi_spectrometer_set_integration_time_micros(m_iSpectralmeterHandle, spectrometer_ids[0], &error, iExposureTimeInMS*1000);
|
||||
// printf("\t\t\t\tResult is [%s]\n", sbapi_get_error_string(error));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int OceanOptics_lib::GetExposureTime(int &iExposureTimeInMS)
|
||||
{
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
iExposureTimeInMS = m_iExposureTime;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>¶<EFBFBD>
|
||||
int OceanOptics_lib::SetDeviceTemperature(float fTemperature)
|
||||
{
|
||||
bool ret;
|
||||
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int error;
|
||||
|
||||
// printf("\nSetting TEC temperature to -5C\n");
|
||||
seabreeze_set_tec_temperature(m_iSpectralmeterHandle, &error, fTemperature);
|
||||
// printf("Set tec temperature result is [%s]\n", get_error_string(error));
|
||||
ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
// printf("\nSetting TEC enable to true\n");
|
||||
seabreeze_set_tec_enable(m_iSpectralmeterHandle, &error, 1);
|
||||
// printf("Set tec enable result is [%s]\n", get_error_string(error));
|
||||
ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD>¶<EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
int OceanOptics_lib::GetDeviceTemperature(float &fTemperature)
|
||||
{
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
double temp;
|
||||
int error;
|
||||
|
||||
// usleep(1000000);
|
||||
// printf("\nGetting TEC temperature\n");
|
||||
temp = seabreeze_read_tec_temperature(m_iSpectralmeterHandle, &error);
|
||||
// printf("Read tec temperature result is %1.2f C [%s]\n", temp, get_error_string(error));
|
||||
bool ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
fTemperature = temp;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
||||
int OceanOptics_lib::GetDeviceInfo(DeviceInfo &Info)
|
||||
{
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
string deviceType = GetDeviceType(m_iSpectralmeterHandle);
|
||||
string SN = GetSerialNumber(m_iSpectralmeterHandle);
|
||||
|
||||
Info.strPN = deviceType;
|
||||
Info.strSN = SN;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int OceanOptics_lib::GetDeviceAttribute(DeviceAttribute &Attr)
|
||||
{
|
||||
if (m_iSpectralmeterHandle == -100)
|
||||
{
|
||||
printf("\nNo!!!!!!!!!!!!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int error;
|
||||
int flag;
|
||||
int spec_length;
|
||||
double *wls = 0;
|
||||
|
||||
// printf("\n\nGetting formatted spectrum length.\n");
|
||||
spec_length = seabreeze_get_formatted_spectrum_length(m_iSpectralmeterHandle, &error);
|
||||
// printf("Get formatted spectrum length result is (%d) [%s]\n", spec_length, get_error_string(error));
|
||||
bool ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
Attr.iPixels = spec_length;
|
||||
|
||||
long minimum_time;
|
||||
minimum_time = seabreeze_get_min_integration_time_microsec(m_iSpectralmeterHandle, &error);
|
||||
Attr.iMinIntegrationTimeInMS = minimum_time/1000;
|
||||
Attr.iMaxIntegrationTimeInMS = 60000;
|
||||
|
||||
if (spec_length > 0) {
|
||||
wls = (double *)calloc((size_t)spec_length, sizeof(double));
|
||||
|
||||
// printf("\nGetting wavelengths.\n");
|
||||
flag = seabreeze_get_wavelengths(m_iSpectralmeterHandle, &error, wls, spec_length);
|
||||
// printf("Get wavelengths result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
// printf("\tPixel 20 is wavelength %1.2f nm\n", wls[20]);
|
||||
bool ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (int tmp = 0; tmp < spec_length; tmp++)
|
||||
{
|
||||
Attr.fWaveLengthInNM[tmp] = wls[tmp];
|
||||
}
|
||||
|
||||
free(wls);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool OceanOptics_lib::isSuccess(char* resultStr)
|
||||
{
|
||||
if (strstr(resultStr, "Success") == NULL)//<2F><>a<EFBFBD>в<EFBFBD><D0B2><EFBFBD>b<EFBFBD><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>
|
||||
{
|
||||
//cout << "not found\n";//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
return false;
|
||||
}
|
||||
else//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڡ<EFBFBD>
|
||||
{
|
||||
//cout <<"found\n"; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
const char* OceanOptics_lib::get_error_string(int error)
|
||||
{
|
||||
static char buffer[32];
|
||||
seabreeze_get_error_string(error, buffer, sizeof(buffer));
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void OceanOptics_lib::test_nonlinearity_coeffs_feature()
|
||||
{
|
||||
using namespace seabreeze;
|
||||
using namespace seabreeze::api;
|
||||
using namespace std;
|
||||
|
||||
NonlinearityCoeffsFeatureAdapter tmp();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// int error = 0;
|
||||
// int number_of_nonlinearity_coeff_features;
|
||||
// long *nonlinearity_coeff_feature_ids = 0;
|
||||
// double buffer[10];
|
||||
// int i;
|
||||
// int length;
|
||||
//
|
||||
// printf("\n\tTesting nonlinearity coefficient features:\n");
|
||||
//
|
||||
// printf("\t\tGetting number of nonlinearity coefficient features:\n");
|
||||
// number_of_nonlinearity_coeff_features =
|
||||
// sbapi_get_number_of_nonlinearity_coeffs_features(m_iSpectralmeterHandle, &error);
|
||||
// printf("\t\t\tResult is %d [%s]\n", number_of_nonlinearity_coeff_features,
|
||||
// sbapi_get_error_string(error));
|
||||
//
|
||||
// if(0 == number_of_nonlinearity_coeff_features) {
|
||||
// printf("\tNo nonlinearity coefficient capabilities found.\n");
|
||||
//// tallyUnsupportedFeatures(unsupportedFeatureCount);
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// nonlinearity_coeff_feature_ids =
|
||||
// (long *)calloc(number_of_nonlinearity_coeff_features, sizeof(long));
|
||||
// printf("\t\tGetting nonlinearity coefficient feature IDs...\n");
|
||||
// number_of_nonlinearity_coeff_features = sbapi_get_nonlinearity_coeffs_features(
|
||||
// m_iSpectralmeterHandle, &error, nonlinearity_coeff_feature_ids,
|
||||
// number_of_nonlinearity_coeff_features);
|
||||
// printf("\t\t\tResult is %d [%s]\n", number_of_nonlinearity_coeff_features,
|
||||
// sbapi_get_error_string(error));
|
||||
//
|
||||
// for(i = 0; i < number_of_nonlinearity_coeff_features; i++) {
|
||||
// printf("\t\t%d: Testing device 0x%02lX, nonlinearity coeffs 0x%02lX\n",
|
||||
// i, m_iSpectralmeterHandle, nonlinearity_coeff_feature_ids[i]);
|
||||
//
|
||||
// printf("\t\t\tAttempting to get nonlinearity coefficients...\n");
|
||||
// memset(buffer, (int)0, sizeof(buffer));
|
||||
// length = sbapi_nonlinearity_coeffs_get(m_iSpectralmeterHandle,
|
||||
// nonlinearity_coeff_feature_ids[i], &error, buffer, 10);
|
||||
// printf("\t\t\t\tResult is %d [%s]\n", length, sbapi_get_error_string(error));
|
||||
//
|
||||
// if(0 == error && length > 0) {
|
||||
// printf("\t\t\t\tFirst calibration term: %1.2e\n", buffer[0]);
|
||||
// }
|
||||
//
|
||||
// printf("\t\t%d: Finished testing device 0x%02lX, nonlinearity coeffs 0x%02lX\n",
|
||||
// i, m_iSpectralmeterHandle, nonlinearity_coeff_feature_ids[i]);
|
||||
// }
|
||||
// free(nonlinearity_coeff_feature_ids);
|
||||
//
|
||||
// printf("\tFinished testing nonlinearity coefficient capabilities.\n");
|
||||
}
|
||||
|
||||
string OceanOptics_lib::GetDeviceType(int index)
|
||||
{
|
||||
char type[16];
|
||||
int error;
|
||||
|
||||
seabreeze_get_model(index, &error, type, sizeof(type));
|
||||
// printf("...Result is (%s) [%s]\n", type, get_error_string(error));
|
||||
bool ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
type[15] = '\0';
|
||||
|
||||
string deviceType = type;
|
||||
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
string OceanOptics_lib::GetSerialNumber(int index)
|
||||
{
|
||||
static char serial_number[32];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>static<69><63><EFBFBD>˱<EFBFBD><CBB1><EFBFBD><EFBFBD>ᶨ<EFBFBD><E1B6A8><EFBFBD><EFBFBD>stack<63><6B><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>غ<D8BA><F3A3ACBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int flag;
|
||||
int error;
|
||||
|
||||
// printf("\n\nGetting serial number.\n");
|
||||
flag = seabreeze_get_serial_number(index, &error, serial_number, 32);
|
||||
// printf("Get serial number result is (%d) [%s]\n", flag, get_error_string(error));
|
||||
bool ret = isSuccess((char*)get_error_string(error));
|
||||
if (!ret)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
serial_number[31] = '\0';
|
||||
if (flag > 0) {
|
||||
printf("\tSerial number: [%s]\n", serial_number);
|
||||
}
|
||||
|
||||
string sn = serial_number;
|
||||
|
||||
return sn;
|
||||
}
|
||||
|
||||
|
||||
683
othersoft/calibration_console/Source_Files/main.cpp
Normal file
683
othersoft/calibration_console/Source_Files/main.cpp
Normal file
@ -0,0 +1,683 @@
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QTextStream>
|
||||
#include <QCommandLineParser>
|
||||
#include <QDir>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "Header_Files/oceanOpticsFiberImager.h"
|
||||
#include "Header_Files/atpFiberImager.h"
|
||||
#include "Header_Files/calibration.h"
|
||||
|
||||
enum CommandLineParseResult
|
||||
{
|
||||
CommandLineOk,
|
||||
CommandLineError,
|
||||
CommandLineVersionRequested,
|
||||
CommandLineHelpRequested
|
||||
};
|
||||
|
||||
enum DeviceType
|
||||
{
|
||||
OPTOSKY,
|
||||
OceanOptics,
|
||||
UnknownDevice
|
||||
};
|
||||
|
||||
struct TcQuery
|
||||
{
|
||||
DeviceType deviceType;
|
||||
QString serialPort;
|
||||
|
||||
int sleepTimeinSecond;//<2F><>Ĭ<EFBFBD><C4AC>ֵ
|
||||
int averageTimes;
|
||||
int position;
|
||||
int integratingSphereDetectorValue;
|
||||
|
||||
QString calFileOutputDirectory;//<2F><>Ĭ<EFBFBD><C4AC>ֵ
|
||||
QString calFileOutputName;
|
||||
QString standardLightFilePath;
|
||||
|
||||
bool justRecord;
|
||||
};
|
||||
|
||||
CommandLineParseResult parseCommandLine2(QCommandLineParser &parser, TcQuery *query, QString *errorMessage);
|
||||
bool copyFileToPath(QString sourceDir ,QString toDir, bool coverFileIfExist);
|
||||
void logout(QString str);
|
||||
void createDirectory(QString fullPath);
|
||||
bool isFileExist(QString fullFileName);
|
||||
|
||||
int getNonlinearityCoeffs2(long deviceID, double * nonlinearityCoeffs);
|
||||
int getNonlinearityCoeffs1(double * nonlinearityCoeffs);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
QCoreApplication::setApplicationName("Ocean optics radiance calibration software");
|
||||
QCoreApplication::setApplicationVersion("1.0");
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>в<EFBFBD><D0B2><EFBFBD>
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription("This software is used for doing radiance calibration for ocean optics fiber imager.");
|
||||
TcQuery query;
|
||||
QString errorMessage;
|
||||
|
||||
switch (parseCommandLine2(parser, &query, &errorMessage))
|
||||
{
|
||||
case CommandLineOk:
|
||||
break;
|
||||
case CommandLineError:
|
||||
errorMessage = "<br><b style=\"color:red\">" + errorMessage + "s!</b>";
|
||||
logout(errorMessage);
|
||||
|
||||
// fputs(qPrintable(errorMessage), stderr);
|
||||
fputs("\n\n", stderr);
|
||||
fputs(qPrintable(parser.helpText()), stderr);
|
||||
return 1;
|
||||
case CommandLineVersionRequested:
|
||||
printf("%s %s\n", qPrintable(QCoreApplication::applicationName()),
|
||||
qPrintable(QCoreApplication::applicationVersion()));
|
||||
return 0;
|
||||
case CommandLineHelpRequested:
|
||||
parser.showHelp();
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD><C7B6><EFBFBD>
|
||||
FiberSpectrometerOperationBase * m_FiberSpectrometer;
|
||||
bool isOcean = false;
|
||||
double * nonlinearityCoeffs;
|
||||
int numberOfNonlinearityCoeffs;
|
||||
switch (query.deviceType)
|
||||
{
|
||||
case OPTOSKY:
|
||||
m_FiberSpectrometer = new ATPFiberImager(false,query.serialPort.toStdString(),"OPTOSKY");
|
||||
break;
|
||||
case OceanOptics:
|
||||
{
|
||||
//ʹ<><CAB9>sbapi<70><69>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
nonlinearityCoeffs = new double[100];
|
||||
numberOfNonlinearityCoeffs = getNonlinearityCoeffs1(nonlinearityCoeffs);
|
||||
|
||||
m_FiberSpectrometer = new OceanOpticsFiberImager(nonlinearityCoeffs, numberOfNonlinearityCoeffs);
|
||||
isOcean = true;
|
||||
break;
|
||||
}
|
||||
case UnknownDevice:
|
||||
parser.showHelp();
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
|
||||
|
||||
//<2F><><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD>
|
||||
QString message;
|
||||
QString SN;
|
||||
QString pixelCount;
|
||||
QString wavelengthInfo;
|
||||
logout("<br><b style=\"color:red\">Connectting the fiber spectrometer!</b>");
|
||||
m_FiberSpectrometer->connectFiberSpectrometer(SN, pixelCount, wavelengthInfo);
|
||||
|
||||
|
||||
|
||||
//<2F>Զ<EFBFBD><D4B6>ع<EFBFBD>
|
||||
logout("<br><b style=\"color:red\">AutoExpose!</b>");
|
||||
m_FiberSpectrometer->autoExpose();//
|
||||
|
||||
int iExposureTime;
|
||||
m_FiberSpectrometer->getExposureTime(iExposureTime);
|
||||
|
||||
message="<br><b style=\"color:red\">ExposureTime: " + QString::number(iExposureTime) + "</b>";
|
||||
logout(message);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>sleep<65><70><EFBFBD>ȴ<EFBFBD><C8B4>رտ<D8B1><D5BF><EFBFBD>
|
||||
message="<br><b style=\"color:red\">Please close the lamp in " + QString::number(query.sleepTimeinSecond) + "s!</b>";
|
||||
logout(message);
|
||||
QThread::sleep(query.sleepTimeinSecond);
|
||||
|
||||
//<2F>ɼ<EFBFBD><C9BC><EFBFBD>֡
|
||||
logout("<br><b style=\"color:red\">Record dark frame!</b>");
|
||||
m_FiberSpectrometer->recordDark(query.calFileOutputDirectory);
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>sleep<65><70><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD><F2BFAABF><EFBFBD>
|
||||
message="<br><b style=\"color:red\">Please open the lamp in " + QString::number(query.sleepTimeinSecond) + "s!</b>";
|
||||
logout(message);
|
||||
QThread::sleep(query.sleepTimeinSecond);
|
||||
|
||||
//<2F>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
logout("<br><b style=\"color:red\">Record integrating sphere frame!</b>");
|
||||
m_FiberSpectrometer->recordTarget(query.averageTimes, query.calFileOutputDirectory);
|
||||
|
||||
//<><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||
logout("<br><b style=\"color:red\">readAndResample_StandardLightFile!</b>");
|
||||
DeviceAttribute deviceAttribute;
|
||||
DeviceInfo deviceInfo;
|
||||
m_FiberSpectrometer->getDeviceAttribute(deviceAttribute);
|
||||
m_FiberSpectrometer->getDeviceInfo(deviceInfo);
|
||||
|
||||
CalibrationAlgorithm * m_CalibrationAlgorithm = new CalibrationAlgorithm();
|
||||
m_CalibrationAlgorithm->readAndResample_StandardLightFile(query.standardLightFilePath,query.integratingSphereDetectorValue, deviceAttribute, deviceInfo);
|
||||
|
||||
//<2F><><EFBFBD>ɷ<EFBFBD><C9B7>䶨<EFBFBD><E4B6A8><EFBFBD>ļ<EFBFBD>
|
||||
if (query.calFileOutputName.isEmpty())//query->calFileOutputName==""
|
||||
{
|
||||
QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss");
|
||||
QString calFileName = QDir::cleanPath(query.calFileOutputDirectory + QDir::separator() + currentTime + "_" + QString::fromStdString(deviceInfo.strSN) + ".dat");
|
||||
|
||||
query.calFileOutputName=calFileName;
|
||||
}
|
||||
logout("<br><b style=\"color:red\">Produce calibration file!</b>");
|
||||
m_CalibrationAlgorithm->produceCalfile(query.calFileOutputName, deviceAttribute, m_FiberSpectrometer->m_IntegratingSphereData, m_FiberSpectrometer->m_DarkData);
|
||||
|
||||
//<2F><><EFBFBD>Ʒ<EFBFBD><C6B7>䶨<EFBFBD><E4B6A8><EFBFBD>ļ<EFBFBD>
|
||||
QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss");
|
||||
QString destName = QDir::cleanPath(query.calFileOutputDirectory + QDir::separator() + currentTime + "_" + QString::fromStdString(deviceInfo.strSN) + "_" +QString::number(query.position) + ".cal");
|
||||
copyFileToPath(query.calFileOutputName,destName,true);
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
if (isOcean)
|
||||
{
|
||||
QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss");
|
||||
QString nonlinearityCoeffsName = QDir::cleanPath(query.calFileOutputDirectory + QDir::separator() + currentTime + "_" + QString::fromStdString(deviceInfo.strSN) + ".nonLinear");
|
||||
|
||||
// for (int i = 0; i < numberOfNonlinearityCoeffs; ++i)
|
||||
// {
|
||||
// printf("\n");
|
||||
//
|
||||
// printf("nonlinearityCoeffs(<28><>%d<><64>): %1.2e\n",i , nonlinearityCoeffs[i]);
|
||||
//
|
||||
// printf("\n");
|
||||
// }
|
||||
|
||||
std::ofstream outfile(nonlinearityCoeffsName.toStdString().c_str());
|
||||
|
||||
for (int i = 0; i < numberOfNonlinearityCoeffs; i++)
|
||||
{
|
||||
outfile << nonlinearityCoeffs[i] << std::endl;
|
||||
}
|
||||
outfile.close();
|
||||
|
||||
free(nonlinearityCoeffs);
|
||||
}
|
||||
|
||||
//<2F>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
m_FiberSpectrometer->disconnectFiberSpectrometer();//Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD>free(nonlinearityCoeffs);
|
||||
//return a.exec();
|
||||
}
|
||||
|
||||
CommandLineParseResult parseCommandLine2(QCommandLineParser &parser, TcQuery *query, QString *errorMessage)
|
||||
{
|
||||
parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
|
||||
|
||||
QCommandLineOption deviceType("deviceType", "Device type. Options are OPTOSKY and OceanOptics", "deviceType");
|
||||
parser.addOption(deviceType);
|
||||
|
||||
QCommandLineOption serialPort("serialPort", "Serial port.", "serialPort");
|
||||
parser.addOption(serialPort);
|
||||
|
||||
QCommandLineOption sleepTimeinSecond("t", "The time app sleep.", "sleepTimeinSecond");
|
||||
sleepTimeinSecond.setDefaultValue("30");//<2F><><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD>
|
||||
parser.addOption(sleepTimeinSecond);
|
||||
|
||||
QCommandLineOption averageTimes("a", "Average times.", "average_times");
|
||||
averageTimes.setDefaultValue("5");//<2F><><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD>
|
||||
parser.addOption(averageTimes);//
|
||||
|
||||
QCommandLineOption position("position", "Position.", "position");
|
||||
parser.addOption(position);
|
||||
|
||||
QCommandLineOption integratingSphereDetectorValue("integratingSphereDetectorValue", "integratingSphereDetectorValue.", "integratingSphereDetectorValue");
|
||||
parser.addOption(integratingSphereDetectorValue);
|
||||
|
||||
// parser.addPositionalArgument("name", "The name to look up.");//????????????????????????????????????????????????????????????????????????????
|
||||
QCommandLineOption helpOption = parser.addHelpOption();//Adds the help option (-h, --help and -? on Windows) This option is handled automatically by QCommandLineParser.
|
||||
QCommandLineOption versionOption = parser.addVersionOption();//This option is handled automatically by QCommandLineParser.
|
||||
|
||||
|
||||
//// A boolean option with a single name (-p)
|
||||
//QCommandLineOption showProgressOption("p", QCoreApplication::translate("main", "Show progress during copy"));
|
||||
//parser.addOption(showProgressOption);
|
||||
|
||||
// A boolean option with multiple names (-r, --record)
|
||||
QCommandLineOption recordOption(QStringList() << "f" << "record",
|
||||
QCoreApplication::translate("main", "Just record one spectral."));
|
||||
parser.addOption(recordOption);
|
||||
|
||||
|
||||
//<2F><><EFBFBD><D7BC><EFBFBD>ļ<EFBFBD>
|
||||
QCommandLineOption standardLightFilePath(QStringList() << "slfp" << "standard-light-file-path",
|
||||
QCoreApplication::translate("main", "set standard light file."),
|
||||
QCoreApplication::translate("main", "file"));
|
||||
parser.addOption(standardLightFilePath);
|
||||
|
||||
QCommandLineOption standardLightFileSelector(QStringList() << "slfs" << "standard-light-file-selector",
|
||||
QCoreApplication::translate("main", "select standard light file."),
|
||||
QCoreApplication::translate("main", "file"));
|
||||
parser.addOption(standardLightFileSelector);
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
||||
// An option with a value
|
||||
QCommandLineOption calFileOutputDirectory(QStringList() << "cfod" << "calibration-file-output-directory",
|
||||
QCoreApplication::translate("main", "Save cal file into <directory>."),
|
||||
QCoreApplication::translate("main", "directory"));
|
||||
// QString tmpPath1 = QDir::cleanPath(QDir::rootPath() + QDir::separator()+"calFile");
|
||||
QString tmpPath1 = "/home/data/Cal/";
|
||||
calFileOutputDirectory.setDefaultValue(tmpPath1);//<2F><><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD>QCoreApplication::applicationDirPath()<29><>standardLightFile
|
||||
parser.addOption(calFileOutputDirectory);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
// An option with a value
|
||||
QCommandLineOption calFileOutputName(QStringList() << "cfon" << "calibration-file-output-name",
|
||||
QCoreApplication::translate("main", "Cal file name."),
|
||||
QCoreApplication::translate("main", "fileName"));
|
||||
parser.addOption(calFileOutputName);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (!parser.parse(QCoreApplication::arguments()))//Process the actual command line arguments given by the user
|
||||
{
|
||||
*errorMessage = parser.errorText();
|
||||
return CommandLineError;
|
||||
}
|
||||
|
||||
if (parser.isSet(versionOption))
|
||||
return CommandLineVersionRequested;
|
||||
|
||||
if (parser.isSet(helpOption))
|
||||
return CommandLineHelpRequested;
|
||||
|
||||
if (parser.isSet(deviceType))
|
||||
{
|
||||
const QString deviceTypeTmp = parser.value(deviceType);
|
||||
|
||||
if (deviceTypeTmp=="OPTOSKY")
|
||||
{
|
||||
query->deviceType = OPTOSKY;
|
||||
}
|
||||
else if(deviceTypeTmp=="OceanOptics")
|
||||
{
|
||||
query->deviceType = OceanOptics;
|
||||
}
|
||||
else
|
||||
{
|
||||
*errorMessage = "DeviceType set error.";
|
||||
return CommandLineError;
|
||||
}
|
||||
|
||||
}
|
||||
else//Ĭ<>ϲ<EFBFBD><CFB2><EFBFBD>
|
||||
{
|
||||
*errorMessage = "No deviceType set.";
|
||||
return CommandLineError;
|
||||
}
|
||||
|
||||
if (parser.isSet(serialPort))
|
||||
{
|
||||
const QString serialPortTmp = parser.value(serialPort);
|
||||
query->serialPort = serialPortTmp;
|
||||
}
|
||||
else//Ĭ<>ϲ<EFBFBD><CFB2><EFBFBD>
|
||||
{
|
||||
if (query->deviceType == OceanOptics)
|
||||
{
|
||||
;
|
||||
} else if (query->deviceType == OPTOSKY)
|
||||
{
|
||||
*errorMessage = "No serialPort set.";
|
||||
return CommandLineError;
|
||||
}
|
||||
}
|
||||
|
||||
if (parser.isSet(sleepTimeinSecond))
|
||||
{
|
||||
const QString timeTmp = parser.value(sleepTimeinSecond);
|
||||
query->sleepTimeinSecond = timeTmp.toInt();
|
||||
}
|
||||
else//Ĭ<>ϲ<EFBFBD><CFB2><EFBFBD>
|
||||
{
|
||||
QStringList tmp = sleepTimeinSecond.defaultValues();
|
||||
query->sleepTimeinSecond = tmp[0].toInt();
|
||||
}
|
||||
|
||||
if (parser.isSet(averageTimes))
|
||||
{
|
||||
const QString averageTimesTmp = parser.value(averageTimes);
|
||||
|
||||
string tttt=averageTimesTmp.toStdString();
|
||||
|
||||
query->averageTimes = averageTimesTmp.toInt();
|
||||
}
|
||||
else//Ĭ<>ϲ<EFBFBD><CFB2><EFBFBD>
|
||||
{
|
||||
QStringList tmp = averageTimes.defaultValues();
|
||||
query->averageTimes = tmp[0].toInt();
|
||||
}
|
||||
|
||||
if (parser.isSet(position))
|
||||
{
|
||||
const QString positionTmp = parser.value(position);
|
||||
query->position = positionTmp.toInt();
|
||||
}
|
||||
else
|
||||
{
|
||||
*errorMessage = "No position set.";
|
||||
return CommandLineError;
|
||||
}
|
||||
|
||||
query->justRecord = parser.isSet(recordOption);
|
||||
|
||||
|
||||
if (!parser.isSet(standardLightFilePath) && !parser.isSet(standardLightFileSelector))//û<><C3BB><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><C3B6>걣<EFBFBD><EAB1A3><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>
|
||||
{
|
||||
*errorMessage = "No standard light file set.";
|
||||
return CommandLineError;
|
||||
}
|
||||
|
||||
if (parser.isSet(standardLightFileSelector))//
|
||||
{
|
||||
QString selector = parser.value(standardLightFileSelector);
|
||||
// QString standardLightFilePath_tmp = QDir::cleanPath(QDir::rootPath() + QDir::separator() + "standardLightFile" + QDir::separator() + selector);
|
||||
|
||||
QString tmp = "/home/data/Setting/StandardLightFile";
|
||||
QString standardLightFilePath_tmp = tmp + QDir::separator() + selector;
|
||||
|
||||
string xx=standardLightFilePath_tmp.toStdString();
|
||||
|
||||
//<2F>ж϶<D0B6><CFB6><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (!isFileExist(standardLightFilePath_tmp))
|
||||
{
|
||||
*errorMessage = "Standard light file '" + selector + "' does not exist!";
|
||||
return CommandLineError;
|
||||
}
|
||||
|
||||
query->standardLightFilePath = standardLightFilePath_tmp;
|
||||
}
|
||||
|
||||
if (parser.isSet(standardLightFilePath))//
|
||||
{
|
||||
query->standardLightFilePath = parser.value(standardLightFilePath);
|
||||
}
|
||||
|
||||
if (parser.isSet(integratingSphereDetectorValue))
|
||||
{
|
||||
if(query->standardLightFilePath.contains("ocean_optics.lmp",Qt::CaseSensitive))
|
||||
{
|
||||
query->integratingSphereDetectorValue = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
const QString integratingSphereDetectorValueTmp = parser.value(integratingSphereDetectorValue);
|
||||
query->integratingSphereDetectorValue = integratingSphereDetectorValueTmp.toInt();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*errorMessage = "No integratingSphereDetectorValue set.";
|
||||
return CommandLineError;
|
||||
}
|
||||
|
||||
|
||||
if (parser.isSet(calFileOutputDirectory))//<2F><><EFBFBD>걣<EFBFBD><EAB1A3><EFBFBD>ļ<EFBFBD>·<EFBFBD><C2B7>
|
||||
{
|
||||
query->calFileOutputDirectory = parser.value(calFileOutputDirectory);
|
||||
createDirectory(query->calFileOutputDirectory);//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD>
|
||||
}
|
||||
else//Ĭ<>ϲ<EFBFBD><CFB2><EFBFBD>
|
||||
{
|
||||
QStringList tmp = calFileOutputDirectory.defaultValues();
|
||||
QString directory = tmp[0];
|
||||
|
||||
createDirectory(directory);//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>в<EFBFBD><D0B2><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD>
|
||||
|
||||
query->calFileOutputDirectory = directory;
|
||||
}
|
||||
|
||||
if (parser.isSet(calFileOutputName))//-------
|
||||
{
|
||||
QString calFileOutputNameTmp = QDir::cleanPath(query->calFileOutputDirectory + QDir::separator() + parser.value(calFileOutputName));
|
||||
query->calFileOutputName = calFileOutputNameTmp;
|
||||
}
|
||||
else//Ĭ<>ϲ<EFBFBD><CFB2><EFBFBD>
|
||||
{
|
||||
query->calFileOutputName = "";//ʹ<>ô˲<C3B4><CBB2><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>query->calFileOutputNameΪ<65><CEAA> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>˱<EFBFBD><CBB1><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
}
|
||||
|
||||
// const QStringList positionalArguments = parser.positionalArguments();
|
||||
// if (positionalArguments.isEmpty())
|
||||
// {
|
||||
// *errorMessage = "Argument 'name' missing.";
|
||||
// return CommandLineError;
|
||||
// }
|
||||
// if (positionalArguments.size() > 1)
|
||||
// {
|
||||
// *errorMessage = "Several 'name' arguments specified.";
|
||||
// return CommandLineError;
|
||||
// }
|
||||
|
||||
return CommandLineOk;
|
||||
}
|
||||
|
||||
bool copyFileToPath(QString sourceDir ,QString toDir, bool coverFileIfExist)
|
||||
{
|
||||
toDir.replace("\\","/");
|
||||
if (sourceDir == toDir){
|
||||
return true;
|
||||
}
|
||||
if (!QFile::exists(sourceDir)){
|
||||
return false;
|
||||
}
|
||||
QDir *createfile = new QDir;
|
||||
bool exist = createfile->exists(toDir);
|
||||
if (exist){
|
||||
if(coverFileIfExist){
|
||||
createfile->remove(toDir);
|
||||
}
|
||||
}//end if
|
||||
|
||||
if(!QFile::copy(sourceDir, toDir))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void logout(QString str)
|
||||
{
|
||||
std::cout << str.toStdString() << "<br>";
|
||||
std::fflush(stdout);
|
||||
}
|
||||
|
||||
void createDirectory(QString fullPath)//
|
||||
{
|
||||
QDir dir(fullPath);
|
||||
if (dir.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool ok = dir.mkdir(fullPath);//ֻ<><D6BB><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뱣֤<EBB1A3>ϼ<EFBFBD>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD>
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool isFileExist(QString fullFileName)
|
||||
{
|
||||
QFileInfo fileInfo(fullFileName);
|
||||
if (fileInfo.isFile())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int getNonlinearityCoeffs1(double * nonlinearityCoeffs)
|
||||
{
|
||||
int number_of_devices;
|
||||
long *device_ids;
|
||||
int i;
|
||||
int test_index;
|
||||
int flag;
|
||||
int error = 0;
|
||||
char nameBuffer[80];
|
||||
|
||||
|
||||
/* Give the driver a chance to initialize itself */
|
||||
sbapi_initialize();
|
||||
|
||||
// printf("Probing for devices...\n"); fflush(stdout);
|
||||
sbapi_probe_devices();
|
||||
|
||||
//#define RS232_TEST
|
||||
#ifdef RS232_TEST
|
||||
printf("Adding an STS at 9600 baud...\n");
|
||||
/* Uncomment for Linux */
|
||||
//sbapi_add_RS232_device_location("STS", "/dev/ttyS0", 9600);
|
||||
//sbapi_add_RS232_device_location("STS", "/dev/ttyUSB0", 9600);
|
||||
|
||||
/* Uncomment for Windows */
|
||||
//sbapi_add_RS232_device_location("STS", "COM1", 9600);
|
||||
|
||||
/* Uncomment for e.g. USB-RS232 adapter under OSX */
|
||||
//sbapi_add_RS232_device_location("STS", "/dev/tty.KeySerial1", 9600);
|
||||
//sbapi_add_RS232_device_location("STS", "/dev/tty.usbserial", 9600);
|
||||
#endif
|
||||
|
||||
/* This shows how to add network devices (note that most use TCP/IP) */
|
||||
//sbapi_add_TCPIPv4_device_location("Jaz", "192.168.1.150", 7654);
|
||||
//sbapi_add_TCPIPv4_device_location("Blaze", "192.168.1.151", 57357);
|
||||
|
||||
// printf("Getting device count...\n"); fflush(stdout);
|
||||
number_of_devices = sbapi_get_number_of_device_ids();
|
||||
|
||||
// printf("Device count is %d\n", number_of_devices);
|
||||
if(0 == number_of_devices) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// printf("Getting device IDs...\n");
|
||||
device_ids = (long *)calloc(number_of_devices, sizeof(long));
|
||||
number_of_devices = sbapi_get_device_ids(device_ids, number_of_devices);
|
||||
// printf("Got %d device ID%s.\n", number_of_devices, number_of_devices == 1 ? "" : "s");
|
||||
|
||||
int number;
|
||||
for(i = 0; i < number_of_devices; i++) {
|
||||
// printf("%d: Device 0x%02lX:\n", i, device_ids[i]);
|
||||
// printf("\tGetting device type...\n");
|
||||
flag = sbapi_get_device_type(device_ids[i], &error, nameBuffer, 79);
|
||||
// printf("\t\tResult is (%d) [%s]\n", flag, sbapi_get_error_string(error));
|
||||
if(flag > 0) {
|
||||
// printf("\tDevice type: [%s]\n", nameBuffer);
|
||||
}
|
||||
|
||||
/* Open the device */
|
||||
// printf("\tAttempting to open:\n");
|
||||
flag = sbapi_open_device(device_ids[i], &error);
|
||||
// printf("\t\tResult is (%d) [%s]\n", flag, sbapi_get_error_string(error));
|
||||
|
||||
// jump to the next iteration if there was a problem
|
||||
if(flag != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
number = getNonlinearityCoeffs2(device_ids[i],nonlinearityCoeffs);
|
||||
|
||||
/* Close the device */
|
||||
// printf("\tAttempting to close:\n");
|
||||
sbapi_close_device(device_ids[i], &error);
|
||||
// printf("\t\tResult is (%d) [%s]\n", flag, sbapi_get_error_string(error));
|
||||
}
|
||||
free(device_ids);
|
||||
|
||||
// printf("Finished testing.\n");
|
||||
|
||||
/* Clean up memory allocated by the driver */
|
||||
sbapi_shutdown();
|
||||
|
||||
return number;
|
||||
}//
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>ϵ<EFBFBD><CFB5><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD>
|
||||
int getNonlinearityCoeffs2(long deviceID, double * nonlinearityCoeffs)
|
||||
{
|
||||
int error = 0;
|
||||
int number_of_nonlinearity_coeff_features;
|
||||
long *nonlinearity_coeff_feature_ids = 0;
|
||||
double buffer[10];
|
||||
int i;
|
||||
int length = 0;
|
||||
|
||||
// printf("\n\tTesting nonlinearity coefficient features:\n");
|
||||
|
||||
// printf("\t\tGetting number of nonlinearity coefficient features:\n");
|
||||
number_of_nonlinearity_coeff_features =
|
||||
sbapi_get_number_of_nonlinearity_coeffs_features(deviceID, &error);
|
||||
// printf("\t\t\tResult is %d [%s]\n", number_of_nonlinearity_coeff_features,
|
||||
// sbapi_get_error_string(error));
|
||||
|
||||
if(0 == number_of_nonlinearity_coeff_features) {
|
||||
printf("\tNo nonlinearity coefficient capabilities found.\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
nonlinearity_coeff_feature_ids =
|
||||
(long *)calloc(number_of_nonlinearity_coeff_features, sizeof(long));
|
||||
// printf("\t\tGetting nonlinearity coefficient feature IDs...\n");
|
||||
number_of_nonlinearity_coeff_features = sbapi_get_nonlinearity_coeffs_features(
|
||||
deviceID, &error, nonlinearity_coeff_feature_ids,
|
||||
number_of_nonlinearity_coeff_features);
|
||||
// printf("\t\t\tResult is %d [%s]\n", number_of_nonlinearity_coeff_features,
|
||||
// sbapi_get_error_string(error));
|
||||
|
||||
for(i = 0; i < number_of_nonlinearity_coeff_features; i++)
|
||||
{
|
||||
// printf("\t\t%d: Testing device 0x%02lX, nonlinearity coeffs 0x%02lX\n",
|
||||
// i, deviceID, nonlinearity_coeff_feature_ids[i]);
|
||||
|
||||
// printf("\t\t\tAttempting to get nonlinearity coefficients...\n");
|
||||
memset(nonlinearityCoeffs, (int)0, 20);//----------------------------------------------------------------------------
|
||||
length = sbapi_nonlinearity_coeffs_get(deviceID,
|
||||
nonlinearity_coeff_feature_ids[i], &error, nonlinearityCoeffs, 20);
|
||||
// printf("\t\t\t\tResult is %d [%s]\n", length, sbapi_get_error_string(error));
|
||||
|
||||
if(0 == error && length > 0) {
|
||||
// printf("\t\t\t\tFirst calibration term: %1.2e\n", nonlinearityCoeffs[0]);
|
||||
// printf("\t\t\t\tFirst calibration term: %1.2e\n", nonlinearityCoeffs[1]);
|
||||
// printf("\t\t\t\tFirst calibration term: %1.2e\n", nonlinearityCoeffs[2]);
|
||||
// printf("\t\t\t\tFirst calibration term: %1.2e\n", nonlinearityCoeffs[3]);
|
||||
// printf("\t\t\t\tFirst calibration term: %1.2e\n", nonlinearityCoeffs[4]);
|
||||
// printf("\t\t\t\tFirst calibration term: %1.2e\n", nonlinearityCoeffs[5]);
|
||||
// printf("\t\t\t\tFirst calibration term: %1.2e\n", nonlinearityCoeffs[6]);
|
||||
}
|
||||
|
||||
// printf("\t\t%d: Finished testing device 0x%02lX, nonlinearity coeffs 0x%02lX\n",
|
||||
// i, deviceID, nonlinearity_coeff_feature_ids[i]);
|
||||
}
|
||||
free(nonlinearity_coeff_feature_ids);
|
||||
|
||||
|
||||
|
||||
// printf("\tFinished testing nonlinearity coefficient capabilities.\n");
|
||||
|
||||
return length;
|
||||
}
|
||||
@ -0,0 +1,276 @@
|
||||
#include "Header_Files/oceanOpticsFiberImager.h"
|
||||
|
||||
OceanOpticsFiberImager::OceanOpticsFiberImager(double * nonlinearityCoeffs, int numberOfCoeffs)
|
||||
{
|
||||
m_FiberSpectrometer = NULL;
|
||||
|
||||
m_nonlinearityCoeffs = nonlinearityCoeffs;
|
||||
m_iNumberOfNonlinearityCoeffs = numberOfCoeffs;
|
||||
}
|
||||
|
||||
OceanOpticsFiberImager::~OceanOpticsFiberImager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OceanOpticsFiberImager::connectFiberSpectrometer(QString& SN, QString& pixelCount, QString& wavelengthInfo)
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
m_FiberSpectrometer = new OceanOptics_lib();
|
||||
|
||||
m_FiberSpectrometer->Initialize();
|
||||
|
||||
getDeviceInfo(m_deviceInfo);
|
||||
// m_FiberSpectrometer->GetDeviceInfo(m_deviceInfo);
|
||||
|
||||
getDeviceAttribute(m_deviceAttribute);
|
||||
// m_FiberSpectrometer->GetDeviceAttribute(m_deviceAttribute);
|
||||
|
||||
SN = QString::fromStdString(m_deviceInfo.strSN);
|
||||
pixelCount = QString::number(m_deviceAttribute.iPixels);
|
||||
wavelengthInfo = QString::number(m_deviceAttribute.fWaveLengthInNM[0]) + "--" + QString::number(m_deviceAttribute.fWaveLengthInNM[m_deviceAttribute.iPixels - 1]);
|
||||
|
||||
m_FiberSpectrometer->SetDeviceTemperature(-10);
|
||||
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>dnֵ<6E><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD>
|
||||
string qepro = "QEP";
|
||||
string flame = "FLMS";
|
||||
if (m_deviceInfo.strSN.find(qepro) != string::npos)
|
||||
{
|
||||
m_MaxValueOfFiberSpectrometer = 200000;
|
||||
}
|
||||
else if (m_deviceInfo.strSN.find(flame) != string::npos)
|
||||
{
|
||||
m_MaxValueOfFiberSpectrometer = 65535;
|
||||
}
|
||||
else//û<><C3BB><EFBFBD>ҵ<EFBFBD>ƥ<EFBFBD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> dnֵ<6E><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void OceanOpticsFiberImager::disconnectFiberSpectrometer()
|
||||
{
|
||||
m_FiberSpectrometer->Close();
|
||||
}
|
||||
|
||||
void OceanOpticsFiberImager::getDeviceAttribute(DeviceAttribute& deviceAttribute)
|
||||
{
|
||||
m_FiberSpectrometer->GetDeviceAttribute(deviceAttribute);
|
||||
}
|
||||
|
||||
void OceanOpticsFiberImager::getDeviceInfo(DeviceInfo& deviceInfo)
|
||||
{
|
||||
m_FiberSpectrometer->GetDeviceInfo(deviceInfo);
|
||||
}
|
||||
|
||||
void OceanOpticsFiberImager::setExposureTime(int iExposureTimeInMS)
|
||||
{
|
||||
m_FiberSpectrometer->SetExposureTime(iExposureTimeInMS);
|
||||
}
|
||||
|
||||
void OceanOpticsFiberImager::getExposureTime(int &iExposureTimeInMS)
|
||||
{
|
||||
m_FiberSpectrometer->GetExposureTime(iExposureTimeInMS);
|
||||
}
|
||||
|
||||
void OceanOpticsFiberImager::getDeviceTemperature(float &fTemperature)
|
||||
{
|
||||
m_FiberSpectrometer->GetDeviceTemperature(fTemperature);
|
||||
}
|
||||
|
||||
void OceanOpticsFiberImager::singleShot(DataFrame &dfData)
|
||||
{
|
||||
m_FiberSpectrometer->SingleShot(dfData);
|
||||
|
||||
if(m_iNumberOfNonlinearityCoeffs==0)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0<CEAA><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD>Ͳ<EFBFBD><CDB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>
|
||||
for (int i = 0; i < m_deviceAttribute.iPixels; i++)
|
||||
{
|
||||
dfData.lData[i] = dfData.lData[i] / (m_nonlinearityCoeffs[0]
|
||||
+ m_nonlinearityCoeffs[1] * dfData.lData[i]
|
||||
+ m_nonlinearityCoeffs[2] * pow(dfData.lData[i], 2)
|
||||
+ m_nonlinearityCoeffs[3] * pow(dfData.lData[i], 3)
|
||||
+ m_nonlinearityCoeffs[4] * pow(dfData.lData[i], 4)
|
||||
+ m_nonlinearityCoeffs[5] * pow(dfData.lData[i], 5)
|
||||
+ m_nonlinearityCoeffs[6] * pow(dfData.lData[i], 6)
|
||||
+ m_nonlinearityCoeffs[7] * pow(dfData.lData[i], 7)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void OceanOpticsFiberImager::getNonlinearityCoeffs(coeffsFrame &coeffs)
|
||||
{
|
||||
printf("This is OceanOpticsFiberImager.\n");
|
||||
|
||||
m_FiberSpectrometer->test_nonlinearity_coeffs_feature();
|
||||
}
|
||||
|
||||
void OceanOpticsFiberImager::recordDark(QString path)
|
||||
{
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
||||
DeviceAttribute attribute;
|
||||
DeviceInfo deviceInfo;
|
||||
getDeviceAttribute(attribute);
|
||||
getDeviceInfo(deviceInfo);
|
||||
|
||||
//<2F>ɼ<EFBFBD><C9BC><EFBFBD>֡
|
||||
singleShot(m_DarkData);
|
||||
|
||||
// //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>csv
|
||||
// QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
// QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss");
|
||||
//
|
||||
// QString fileName = path + "/" + currentTime + "_" + QString::fromStdString(deviceInfo.strSN) + "_darkSpectral.csv";
|
||||
// std::ofstream outfile(fileName.toStdString().c_str());
|
||||
//
|
||||
// for (int i = 0; i < attribute.iPixels; i++)
|
||||
// {
|
||||
// if (i==0)
|
||||
// {
|
||||
// outfile << m_DarkData.usExposureTimeInMS << std::endl;//
|
||||
// }
|
||||
// outfile << attribute.fWaveLengthInNM[i] << "," << m_DarkData.lData[i] << std::endl;
|
||||
// }
|
||||
//
|
||||
// outfile.close();
|
||||
}
|
||||
|
||||
void OceanOpticsFiberImager::recordTarget(int recordTimes, QString path)
|
||||
{
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
||||
DeviceAttribute attribute;
|
||||
DeviceInfo deviceInfo;
|
||||
getDeviceAttribute(attribute);
|
||||
getDeviceInfo(deviceInfo);
|
||||
|
||||
|
||||
DataFrame integratingSphereData_tmp;
|
||||
|
||||
for (int i = 0; i < recordTimes; i++)
|
||||
{
|
||||
singleShot(integratingSphereData_tmp);
|
||||
|
||||
if (i == 0)//<2F><>integratingSphereData_tmp<6D>е<EFBFBD><D0B5>ع<EFBFBD>ʱ<EFBFBD>䡢<EFBFBD>¶ȵ<C2B6><C8B5><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>m_IntegratingSphereData
|
||||
{
|
||||
m_IntegratingSphereData = integratingSphereData_tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < attribute.iPixels; i++)
|
||||
{
|
||||
m_IntegratingSphereData.lData[i] += integratingSphereData_tmp.lData[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (int i = 0; i < attribute.iPixels; i++)
|
||||
{
|
||||
m_IntegratingSphereData.lData[i] = m_IntegratingSphereData.lData[i] / recordTimes;
|
||||
}
|
||||
|
||||
|
||||
// //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>csv
|
||||
// QDateTime curDateTime = QDateTime::currentDateTime();
|
||||
// QString currentTime = curDateTime.toString("yyyy_MM_dd_hh_mm_ss");
|
||||
//
|
||||
// QString fileName = path + "/" + currentTime + "_" + QString::fromStdString(deviceInfo.strSN) + "_integratingSphereSpectral.csv";
|
||||
// std::ofstream outfile(fileName.toStdString().c_str());
|
||||
//
|
||||
// for (int i = 0; i < attribute.iPixels; i++)//
|
||||
// {
|
||||
// if (i==0)
|
||||
// {
|
||||
// outfile << m_IntegratingSphereData.usExposureTimeInMS << std::endl;
|
||||
// }
|
||||
// outfile << attribute.fWaveLengthInNM[i] << "," << m_IntegratingSphereData.lData[i] << std::endl;
|
||||
// }
|
||||
//
|
||||
// outfile.close();
|
||||
}
|
||||
|
||||
void OceanOpticsFiberImager::autoExpose()
|
||||
{
|
||||
DeviceAttribute attribute;
|
||||
getDeviceAttribute(attribute);
|
||||
|
||||
int iterations = 0;//<2F><>¼<EFBFBD>Զ<EFBFBD><D4B6>ع<EFBFBD><D8B9>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
|
||||
int maxIterations = 10;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
ZZ_U32 thresholdValue = m_MaxValueOfFiberSpectrometer * 0.8;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ80%
|
||||
ZZ_U16 range = 10000;
|
||||
|
||||
//<2F><><EFBFBD>ó<EFBFBD>ʼ<EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
int exposureTimeInMS = 200;
|
||||
setExposureTime(exposureTimeInMS);
|
||||
emit sendExposureTimeSignal(exposureTimeInMS);
|
||||
|
||||
DataFrame integratingSphereData_tmp;
|
||||
while (true)
|
||||
{
|
||||
if (iterations > maxIterations)//<2F>Ƿ<C7B7><F1B3ACB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
singleShot(integratingSphereData_tmp);
|
||||
ZZ_S32 maxValue = GetMaxValue(integratingSphereData_tmp.lData, attribute.iPixels);
|
||||
|
||||
if (maxValue < thresholdValue && maxValue < (thresholdValue - range))//<2F>ع<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>С
|
||||
{
|
||||
double scale = 1 + ((double)(thresholdValue - maxValue) / (double)thresholdValue);
|
||||
|
||||
int exposureTime;
|
||||
m_FiberSpectrometer->GetExposureTime(exposureTime);
|
||||
m_FiberSpectrometer->SetExposureTime(exposureTime * scale);
|
||||
|
||||
emit sendExposureTimeSignal(exposureTime);
|
||||
|
||||
ZZ_S32 m = GetMaxValue(integratingSphereData_tmp.lData, attribute.iPixels);
|
||||
|
||||
std::cout << "<EFBFBD>Զ<EFBFBD><EFBFBD>ع<EFBFBD>-----------" << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪ" << m << std::endl;
|
||||
}
|
||||
else if (maxValue > thresholdValue && maxValue > (thresholdValue + range))//<2F>ع<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
double scale = 1 - ((double)(maxValue - thresholdValue) / (double)thresholdValue);
|
||||
|
||||
int exposureTime;
|
||||
m_FiberSpectrometer->GetExposureTime(exposureTime);
|
||||
m_FiberSpectrometer->SetExposureTime(exposureTime * scale);
|
||||
|
||||
emit sendExposureTimeSignal(exposureTime);
|
||||
|
||||
ZZ_S32 m = GetMaxValue(integratingSphereData_tmp.lData, attribute.iPixels);
|
||||
|
||||
std::cout << "<EFBFBD>Զ<EFBFBD><EFBFBD>ع<EFBFBD>-----------" << "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪ" << m << std::endl;
|
||||
}
|
||||
else//<2F>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD>䣬<EFBFBD><E4A3AC><EFBFBD><EFBFBD>whileѭ<65><D1AD>
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
iterations++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ZZ_S32 OceanOpticsFiberImager::GetMaxValue(ZZ_S32 * dark, int number)
|
||||
{
|
||||
ZZ_S32 max = 0;
|
||||
for (size_t i = 0; i < number; i++)
|
||||
{
|
||||
if (dark[i] > max)
|
||||
{
|
||||
max = dark[i];
|
||||
}
|
||||
}
|
||||
//std::cout << "<22><>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>ֵΪ" << max << std::endl;
|
||||
return max;
|
||||
}
|
||||
133
othersoft/findtty.sh
Normal file
133
othersoft/findtty.sh
Normal file
@ -0,0 +1,133 @@
|
||||
|
||||
stty -F /dev/ttyUSB0 raw speed 9600
|
||||
sleep 1s
|
||||
stty -F /dev/ttyUSB0 raw speed 9600
|
||||
echo -e "0 dev\n" > /dev/ttyUSB0
|
||||
cat /dev/ttyUSB0 > 1.txt &
|
||||
sleep 1s
|
||||
pkill cat
|
||||
if test -s 1.txt;then
|
||||
echo '/dev/ttyUSB0 may be linermotor'> /home/data/Setting/tryfindtty.txt
|
||||
fi
|
||||
|
||||
stty -F /dev/ttyUSB1 raw speed 9600
|
||||
sleep 1s
|
||||
stty -F /dev/ttyUSB1 raw speed 9600
|
||||
echo -e "0 dev\n" > /dev/ttyUSB1
|
||||
cat /dev/ttyUSB1 > 1.txt &
|
||||
sleep 1s
|
||||
pkill cat
|
||||
if test -s 1.txt;then
|
||||
echo '/dev/ttyUSB1 may be linermotor'> /home/data/Setting/tryfindtty.txt
|
||||
fi
|
||||
|
||||
stty -F /dev/ttyUSB2 raw speed 9600
|
||||
sleep 1s
|
||||
stty -F /dev/ttyUSB2 raw speed 9600
|
||||
echo -e "0 dev\n" > /dev/ttyUSB2
|
||||
cat /dev/ttyUSB2 > 1.txt &
|
||||
sleep 1s
|
||||
pkill cat
|
||||
if test -s 1.txt;then
|
||||
echo '/dev/ttyUSB2 may be linermotor'> /home/data/Setting/tryfindtty.txt
|
||||
fi
|
||||
|
||||
stty -F /dev/ttyUSB3 raw speed 9600
|
||||
sleep 1s
|
||||
stty -F /dev/ttyUSB3 raw speed 9600
|
||||
echo -e "0 dev\n" > /dev/ttyUSB3
|
||||
cat /dev/ttyUSB3 > 1.txt &
|
||||
sleep 1s
|
||||
pkill cat
|
||||
if test -s 1.txt;then
|
||||
echo '/dev/ttyUSB3 may be linermotor'> /home/data/Setting/tryfindtty.txt
|
||||
fi
|
||||
|
||||
|
||||
stty -F /dev/ttyS1 raw speed 115200
|
||||
sleep 1s
|
||||
stty -F /dev/ttyS1 raw speed 115200
|
||||
cat -e /dev/ttyS1 > 1.txt &
|
||||
sleep 1s
|
||||
echo aa5500040307 | xxd -r -ps > /dev/ttyS1
|
||||
sleep 1s
|
||||
pkill cat
|
||||
sleep 1s
|
||||
|
||||
if test -s 1.txt;then
|
||||
echo '/dev/ttyS1 is ISIF or IS2'>> /home/data/Setting/tryfindtty.txt
|
||||
fi
|
||||
|
||||
|
||||
stty -F /dev/ttyS2 raw speed 115200
|
||||
sleep 1s
|
||||
stty -F /dev/ttyS2 raw speed 115200
|
||||
cat -e /dev/ttyS2 > 1.txt &
|
||||
sleep 1s
|
||||
echo aa5500040307 | xxd -r -ps > /dev/ttyS2
|
||||
sleep 1s
|
||||
pkill cat
|
||||
sleep 1s
|
||||
|
||||
if test -s 1.txt;then
|
||||
echo '/dev/ttyS2 is ISIF or IS2'>> /home/data/Setting/tryfindtty.txt
|
||||
fi
|
||||
|
||||
stty -F /dev/ttyUSB0 raw speed 115200
|
||||
sleep 1s
|
||||
stty -F /dev/ttyUSB0 raw speed 115200
|
||||
cat -e /dev/ttyUSB0 > 1.txt &
|
||||
sleep 1s
|
||||
echo aa5500040307 | xxd -r -ps > /dev/ttyUSB0
|
||||
sleep 1s
|
||||
pkill cat
|
||||
sleep 1s
|
||||
|
||||
if test -s 1.txt;then
|
||||
echo '/dev/ttyUSB0 is IS1'>> /home/data/Setting/tryfindtty.txt
|
||||
fi
|
||||
|
||||
stty -F /dev/ttyUSB1 raw speed 115200
|
||||
sleep 1s
|
||||
stty -F /dev/ttyUSB1 raw speed 115200
|
||||
cat -e /dev/ttyUSB1 > 1.txt &
|
||||
sleep 1s
|
||||
echo aa5500040307 | xxd -r -ps > /dev/ttyS1
|
||||
sleep 1s
|
||||
pkill cat
|
||||
sleep 1s
|
||||
if test -s 1.txt;then
|
||||
echo '/dev/ttyUSB1 is IS1'>> /home/data/Setting/tryfindtty.txt
|
||||
fi
|
||||
|
||||
stty -F /dev/ttyUSB2 raw speed 115200
|
||||
sleep 1s
|
||||
stty -F /dev/ttyUSB2 raw speed 115200
|
||||
cat -e /dev/ttyUSB2 > 1.txt &
|
||||
sleep 1s
|
||||
echo aa5500040307 | xxd -r -ps > /dev/ttyUSB2
|
||||
sleep 1s
|
||||
pkill cat
|
||||
sleep 1s
|
||||
if test -s 1.txt;then
|
||||
echo '/dev/ttyUSB2 is IS1'>> /home/data/Setting/tryfindtty.txt
|
||||
fi
|
||||
|
||||
|
||||
stty -F /dev/ttyUSB3 raw speed 115200
|
||||
sleep 1s
|
||||
stty -F /dev/ttyUSB3 raw speed 115200
|
||||
cat -e /dev/ttyUSB3 > 1.txt &
|
||||
sleep 1s
|
||||
echo aa5500040307 | xxd -r -ps > /dev/ttyUSB3
|
||||
sleep 1s
|
||||
pkill cat
|
||||
sleep 1s
|
||||
|
||||
if test -s 1.txt;then
|
||||
echo '/dev/ttyUSB3 is IS1'>> /home/data/Setting/tryfindtty.txt
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
51
othersoft/install.sh
Normal file
51
othersoft/install.sh
Normal file
@ -0,0 +1,51 @@
|
||||
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/project/LocationCali
|
||||
make -j4
|
||||
cp ./shutter_calibrate /home/pi/bin
|
||||
|
||||
cd ../
|
||||
|
||||
mkdir console
|
||||
cd console
|
||||
cmake ../../calibration_console
|
||||
make -j4
|
||||
cp ./ocean_optics_calibration_console /home/pi/bin
|
||||
cd ../
|
||||
sudo killall Mywathdog.sh
|
||||
sudo killall TowerOptoSifAndSpectral
|
||||
cd ../../
|
||||
cp -r ./html/* /var/www/html
|
||||
chmod +x /var/www/html/php/*.sh
|
||||
cd ./build
|
||||
cp TowerOptoSifAndSpectral /home/pi/bin
|
||||
cd ../
|
||||
cp ./root/Mywathdog.sh /root
|
||||
cp ./root/start.sh /root
|
||||
chmod +x /root/start.sh
|
||||
mkdir /home/data
|
||||
cd ../
|
||||
rm -rf ./TowerOptoSifAndSpectral
|
||||
cd /root/filebrew
|
||||
chmod +x ./filebrowser
|
||||
./filebrowser config set -a 0.0.0.0
|
||||
./filebrowser config set -r /home/data
|
||||
sudo apt-get install -y timedatectl
|
||||
timedatectl set-timezone Asia/Shanghai
|
||||
date -R
|
||||
sudo hwclock -w -f /dev/rtc0
|
||||
|
||||
#tc
|
||||
32
othersoft/movingliner/CMakeLists.txt
Normal file
32
othersoft/movingliner/CMakeLists.txt
Normal file
@ -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})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
27
othersoft/movingliner/DeviceSettings.ini
Normal file
27
othersoft/movingliner/DeviceSettings.ini
Normal file
@ -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
|
||||
83
othersoft/movingliner/main.cpp
Normal file
83
othersoft/movingliner/main.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include<VSMD12XControl.h>
|
||||
#include "qtextstream.h"
|
||||
QTextStream cout1(stdout, QIODevice::WriteOnly);
|
||||
void logout(QString str){
|
||||
std::cout<<str.toStdString()<<"<br>";
|
||||
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"<<flush;
|
||||
cout1<<"Your position number is "<<str<<"<br>"<<flush;
|
||||
#ifdef WIN32
|
||||
m_qstrDeviceConfigFilePath = ("D:\\03MyGit\\linux\\movingliner\\DeviceSettings.ini");
|
||||
#else
|
||||
m_qstrDeviceConfigFilePath = ("/home/data/Setting/DeviceSettings.ini");
|
||||
#endif
|
||||
|
||||
QSettings *m_qsDeviceConfig;
|
||||
m_qsDeviceConfig = new QSettings(m_qstrDeviceConfigFilePath, QSettings::IniFormat);
|
||||
long positon =m_qsDeviceConfig->value("LINEAR SHUTTER/Position"+str).toLongLong();
|
||||
if (positon==0)
|
||||
{
|
||||
logout("<b style=\"color:red\">Can not Find the position<\/b>");
|
||||
return 0;
|
||||
}
|
||||
cout1<<"Find Configfile in "<<m_qstrDeviceConfigFilePath<<" <br> The Port of Motor is "<<m_qsDeviceConfig->value("LINEAR SHUTTER/Port").toString()<<"<br>"<<flush;
|
||||
cout1<<"Position Find Value is "<<m_qsDeviceConfig->value("LINEAR SHUTTER/Position"+str).toLongLong()<<"<br>"<<flush;
|
||||
cout1<<"Configing The Motor <br>"<<flush;
|
||||
// m_qsDeviceConfig->value("LINEAR SHUTTER/Port").toString()
|
||||
if( m_qsDeviceConfig->value("LINEAR SHUTTER/Port").toString()=="GPIO")
|
||||
{
|
||||
//cout1<<"ERROR number position"<<flush;
|
||||
int positionnumber=m_qsDeviceConfig->value("LINEAR SHUTTER/TotalPosition").toInt();
|
||||
if (str.toInt()>=positionnumber)
|
||||
{
|
||||
cout1<<"ERROR number position"<<flush;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int targetpos=m_qsDeviceConfig->value("LINEAR SHUTTER/Position"+str).toLongLong();
|
||||
|
||||
for (int ii = 0; ii < positionnumber; ++ii) {
|
||||
int tempgpio=m_qsDeviceConfig->value("LINEAR SHUTTER/Position"+QString::number(ii)).toInt();
|
||||
QString com="gpio mode "+QString::number(tempgpio)+" out";
|
||||
system(com.toStdString().c_str());
|
||||
com="gpio write "+QString::number(tempgpio)+" 0";
|
||||
system(com.toStdString().c_str());
|
||||
|
||||
}
|
||||
QThread::msleep(500);
|
||||
QString com="gpio write "+QString::number(targetpos)+" 1";
|
||||
system(com.toStdString().c_str());
|
||||
QThread::msleep(500);
|
||||
cout1<<"FINISH Change Shutter <br>"<<flush;
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
}
|
||||
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("<b style=\"color:green\">Finish the Task!!!<\/b> <br><b>Thanks For Using<\/b>");
|
||||
return 0;
|
||||
// return QCoreApplication::exec();
|
||||
}
|
||||
16
othersoft/movingliner/source/LinearShutter/AbstractPort.h
Normal file
16
othersoft/movingliner/source/LinearShutter/AbstractPort.h
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include "VSMD12XMiscDefines.h"
|
||||
#include <string>
|
||||
class CAbstractPort
|
||||
{
|
||||
public:
|
||||
virtual void InitPort(PortInfo portinfo) = 0;
|
||||
virtual bool SetPort() = 0;
|
||||
virtual bool Open() = 0;
|
||||
virtual void Close() = 0;
|
||||
|
||||
virtual std::string ReadAll(int waite=5000) = 0;
|
||||
virtual int Write(const std::string strSend) = 0;
|
||||
|
||||
};
|
||||
|
||||
1459
othersoft/movingliner/source/LinearShutter/VSMD12XControl.cpp
Normal file
1459
othersoft/movingliner/source/LinearShutter/VSMD12XControl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
146
othersoft/movingliner/source/LinearShutter/VSMD12XControl.h
Normal file
146
othersoft/movingliner/source/LinearShutter/VSMD12XControl.h
Normal file
@ -0,0 +1,146 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#include "AbstractPort.h"
|
||||
using namespace std;
|
||||
// #ifdef IRIS_API_EXPORTS
|
||||
//
|
||||
// #ifdef __cplusplus
|
||||
// #define IRIS_API_FUNC extern "C" __declspec(dllexport)
|
||||
// #else
|
||||
// #define IRIS_API_FUNC __declspec(dllexport)
|
||||
// #endif
|
||||
//
|
||||
// #else
|
||||
//
|
||||
// #ifdef __cplusplus
|
||||
// #define IRIS_API_FUNC extern "C" __declspec(dllimport)
|
||||
// #else
|
||||
// #define IRIS_API_FUNC __declspec(dllimport)
|
||||
// #endif
|
||||
//
|
||||
// #endif
|
||||
//
|
||||
//
|
||||
// #ifdef IRIS_API_EXPORTS
|
||||
// #define IRIS_API_CLASS __declspec(dllexport)
|
||||
// #else
|
||||
// #define IRIS_API_CLASS __declspec(dllimport)
|
||||
// #endif
|
||||
#define MAXDISTANCE 1265000
|
||||
class /*IRIS_API_CLASS*/ CVSMD12XControl
|
||||
{
|
||||
public:
|
||||
CVSMD12XControl();
|
||||
~CVSMD12XControl();
|
||||
private:
|
||||
int *m_piPositionInPulses;
|
||||
|
||||
CAbstractPort *m_pAbsPort;
|
||||
unValue m_unValue;
|
||||
MSInfo m_stuMSInfo;
|
||||
ControllerParams m_stuControllerParams;
|
||||
int m_iProtocolType;
|
||||
int m_iCID;
|
||||
std::string m_strCID;
|
||||
public:
|
||||
bool m_bIsSyncMove;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//for IRIS Linear Motor - Electric Shutter
|
||||
//Initialize communication setup iPortType(0:RS232 1:RS485) iCID(For RS485 device) bSyncMove(move mode)
|
||||
bool ILMES_InitializeComm(QString portName,int bandrate=9600, int iPortType = 1, int iCID = 1, bool bSyncMove = true);
|
||||
//Initialize communication setup iPortType(0:RS232 1:RS485) iCID(For RS485 device) bSyncMove(move mode)
|
||||
bool ILMES_InitializeComm(PortInfo portinfo,int iPortType = 1,int iCID = 1, bool bSyncMove = true);
|
||||
|
||||
//Initialize Controller params
|
||||
bool ILMES_InitializeParams(ControllerParams cpParams);
|
||||
|
||||
//Set the light hole position(pulses)
|
||||
void ILMES_SetPosition(int *piPositionInPulse,size_t szSize);
|
||||
|
||||
bool ILMES_MoveToPos(int iPositionIndex);
|
||||
bool IsMotionFinished();
|
||||
public:
|
||||
int waitetime;
|
||||
////init port
|
||||
void SetProtocolType(int iProtocolType = 0);//0:RS232 1:RS485 call before send any command
|
||||
void SetCID(int iID);//set device id when using RS485 protocol call before send any command
|
||||
void SetSyncMode(bool bSyncMove = false);
|
||||
bool InitAndOpenPort(PortInfo portinfo);//Init comport by PortInfo Struct
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////for debug or unsupported function
|
||||
std::string ReadReceive();
|
||||
int SendCommand(const std::string strSend); // return indicates how many char has been sent
|
||||
//////////////////////////////////////////////////////////////////////////motor control
|
||||
////init&misc
|
||||
bool InitController(); //Init Motor controller hand shake
|
||||
|
||||
bool Enable(); //enbale
|
||||
bool Disable(); //disable
|
||||
|
||||
bool GetStatus(MSInfo &stuMotorParam); //load motor status see MSInfo Struct
|
||||
////motion control
|
||||
bool Move(int iRelPulse); // relative move mode,pulse (-2147483647<34><37>2147483647)
|
||||
bool MoveTo(int iAbsPulse);//absolute mode,pulse (-2147483647<34><37>2147483647)
|
||||
bool Move_NoSyn(int iRelPulse); // relative move mode,pulse (-2147483647<34><37>2147483647)
|
||||
bool MoveTo_NoSyn(int iAbsPulse);//absolute mode,pulse (-2147483647<34><37>2147483647)
|
||||
bool SetLogicZero(); //set logic zero
|
||||
|
||||
bool StartBackZero();//back zero
|
||||
bool StopBackZero();// stop back zero & reset register
|
||||
////Set&Get
|
||||
bool SetBaudRate(int iBaudRate);//set controller baud rates,default B9600 (2400 <20><> 921600)
|
||||
int GetBaudRate(); // -1:should retry;
|
||||
|
||||
bool SetMicroSteps(int iMicroSteps);//set micro steps (0<><30>5)->(1/2/4/8/16/32)
|
||||
int GetMicroSteps();
|
||||
|
||||
bool SetAccSpeed(float fAccSpd);//set acceleration speed in pulse (0 <20><> 192000000)
|
||||
float GetAccSpeed();
|
||||
|
||||
bool SetRunSpeed(float fRunSpeed);//set normal running speed in pulse (0 <20><> 192000000)
|
||||
float GetRunSpeed();
|
||||
|
||||
bool SetDecSpeed(float fDecSpeed);//set deceleration speed in pulse (0 <20><> 192000000)
|
||||
float GetDecSpeed();
|
||||
|
||||
bool SetSpeed(float fRunSpeed, float fAccSpd, float fDecSpeed);//see above three functions
|
||||
|
||||
bool SetHoldCurrent(float fHoldCurrent);//set hold current ( 0 <20><> 8.0 )Amp? pay attention to your motor specification.
|
||||
float GetHoldCurrent();
|
||||
|
||||
bool SetAccCurrent(float fAccCurrent);//set acceleration current ( 0 <20><> 8.0 )Amp? pay attention to your motor specification.
|
||||
float GetAccCurrent();
|
||||
|
||||
bool SetRunCurrent(float fRunCurrent);//set normal running current ( 0 <20><> 8.0 )Amp? pay attention to your motor specification.
|
||||
float GetRunCurrent();
|
||||
|
||||
bool SetCurrent(float fAccCurrent, float fRunCurrent, float fHoldCurrent);//see above three functions
|
||||
|
||||
bool SetS1FETE(ZZ_U8 bS1FETE);//S1 register falling edge trigger event,see enum
|
||||
ZZ_U8 GetS1FETE();
|
||||
|
||||
bool SetS1RETE(ZZ_U8 bS1RETE);//S1 register rising edge trigger event
|
||||
ZZ_U8 GetS1RETE();
|
||||
|
||||
bool SetS2FETE(ZZ_U8 bS2FETE);//S2 register falling edge trigger event
|
||||
ZZ_U8 GetS2FETE();
|
||||
|
||||
bool SetS2RETE(ZZ_U8 bS2RETE);//S2 register rising edge trigger event
|
||||
ZZ_U8 GetS2RETE();
|
||||
|
||||
//(ZeroMode 0:off 1:once 2:once + safe position 3:twice 4:twice + safe position) (OpenVoltageLevel 0:Low Level 1:High Level)
|
||||
//(ZeroSensor 0:S1 1:S2 2:S3 3:S4 4:S5 5:S6)( ZeroVelocity <20><>-192000) <20><><EFBFBD><EFBFBD>192000<30><30>pulse)(SafePosition <20><>-2147483647) <20><><EFBFBD><EFBFBD>2147483647<34><37>)
|
||||
bool SetZeroParams(ZZ_U8 bZeroMode, ZZ_U8 bSwitchOpenVL, ZZ_U8 bZeroSensor, float fZeroVelocity, int iSafePosition);
|
||||
ZZ_U8 GetZeroMode();
|
||||
ZZ_U8 GetSwitchOpenVoltageLevel();
|
||||
ZZ_U8 GetZeroSensor();
|
||||
int GetSafePosition();
|
||||
float GetZeroVelocity();
|
||||
|
||||
private:
|
||||
bool ParseReturnedString(std::string &strRecv,int iType);
|
||||
bool ParseReturnedParam(std::string &strRecv);
|
||||
void VSMD_BitShift(ZZ_U8* src, unValue* dst);
|
||||
char* VSMD_Split(char* cStr, char cSplit);
|
||||
};
|
||||
|
||||
108
othersoft/movingliner/source/LinearShutter/VSMD12XMiscDefines.h
Normal file
108
othersoft/movingliner/source/LinearShutter/VSMD12XMiscDefines.h
Normal file
@ -0,0 +1,108 @@
|
||||
#pragma once
|
||||
#include "ZZ_Types.h"
|
||||
#define MAXBUFFER 10240
|
||||
#include<qstring.h>
|
||||
using namespace ZZ_MISCDEF;
|
||||
|
||||
typedef struct tagTransportLayerInfomation
|
||||
{
|
||||
//Serial
|
||||
int iPortType;
|
||||
int iPortNumber;
|
||||
int indexBaudRate;
|
||||
int iBaudRate;
|
||||
int indexParity, indexBytesize, indexStopBits; //Mode
|
||||
bool Hw;
|
||||
bool Sw;
|
||||
bool Dtr, Rts;
|
||||
QString FullPortName;
|
||||
tagTransportLayerInfomation() {
|
||||
iPortType = 0;
|
||||
indexParity = 0;
|
||||
iPortNumber = 8;
|
||||
iBaudRate = 9600;
|
||||
indexBytesize = 3;
|
||||
indexStopBits = 0;
|
||||
FullPortName = "";
|
||||
}
|
||||
|
||||
//Bit
|
||||
//Stop
|
||||
//MODEM CONTROL setting
|
||||
//MODEM LINE STATUS
|
||||
|
||||
//TCP UDP
|
||||
|
||||
}PortInfo;
|
||||
|
||||
typedef struct tagMotorStatusInfo
|
||||
{
|
||||
float fVelocity;
|
||||
int iPosition;
|
||||
ZZ_U32 uiFlags;
|
||||
}MSInfo;
|
||||
|
||||
typedef struct tagControllerParams
|
||||
{
|
||||
int bdr; //baud
|
||||
int mcs; //microsteps 0:full 1:half 2:4 3:8 4:16 5:32 6:64 7:128 8:256
|
||||
float spd; //velocity
|
||||
float acc; //acceleration
|
||||
float dec; //deceleration
|
||||
float cra; //acc state current
|
||||
float crn; //normal state current
|
||||
float crh; //hold state current
|
||||
ZZ_U8 s1f;
|
||||
ZZ_U8 s1r;
|
||||
ZZ_U8 s2f;
|
||||
ZZ_U8 s2r;
|
||||
ZZ_U8 zmd; //zero mode
|
||||
ZZ_U8 osv; //open state sensor value
|
||||
ZZ_U8 snr; //zero sensor
|
||||
ZZ_U8 zsp; //zero safe position
|
||||
float zsd; //zero velocity
|
||||
tagControllerParams() {
|
||||
bdr = 9600;
|
||||
|
||||
cra = 0.8;
|
||||
crh = 0.1;
|
||||
crn = 0.8;
|
||||
|
||||
acc = 100000;
|
||||
dec = 100000;
|
||||
spd = 64000;
|
||||
|
||||
osv = 0;
|
||||
snr = 0;
|
||||
zmd = 3;
|
||||
zsp = 20;
|
||||
zsd = 50000;
|
||||
|
||||
mcs = 6;
|
||||
}
|
||||
}ControllerParams;
|
||||
|
||||
typedef union
|
||||
{
|
||||
ZZ_U8 byteValue[4];
|
||||
short i16Value[2];
|
||||
ZZ_U16 u16Value[2];
|
||||
int i32Value;
|
||||
float fValue;
|
||||
ZZ_U32 u32Value;
|
||||
}unValue;
|
||||
|
||||
enum emVSMDTriggerEvent
|
||||
{
|
||||
NoAction =0, //<2F><EFBFBD><DEB6><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>״̬λ S1 <20>仯֪ͨ<CDA8><D6AA>
|
||||
ResetZeroPosition, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>λ<EFBFBD><CEBB>
|
||||
DecSpdStop, //<2F><><EFBFBD><EFBFBD>ֹͣ
|
||||
DecSpdStopRZP, //<2F><><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>λ<EFBFBD><CEBB>
|
||||
Stop, //<2F><><EFBFBD><EFBFBD>ֹͣ
|
||||
StopRZP, //<2F><><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>λ<EFBFBD><CEBB>
|
||||
RunningPosDirect, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>ٶȣ<D9B6>
|
||||
RunningNegDirect, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>ٶȣ<D9B6>
|
||||
OfflineModeOn, //<2F><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
||||
OfflineModeOff //<2F><><EFBFBD><EFBFBD>ģʽֹͣ
|
||||
};
|
||||
|
||||
147
othersoft/movingliner/source/LinearShutter/ZZ_SeiralPort.cpp
Normal file
147
othersoft/movingliner/source/LinearShutter/ZZ_SeiralPort.cpp
Normal file
@ -0,0 +1,147 @@
|
||||
#include "pch.h"
|
||||
#include "ZZ_SeiralPort.h"
|
||||
|
||||
CZZ_SeiralPort_QT::CZZ_SeiralPort_QT()
|
||||
{
|
||||
m_pSerialPort = new QSerialPort();
|
||||
}
|
||||
|
||||
CZZ_SeiralPort_QT::~CZZ_SeiralPort_QT()
|
||||
{
|
||||
if (m_pSerialPort != NULL)
|
||||
{
|
||||
delete m_pSerialPort;
|
||||
}
|
||||
}
|
||||
|
||||
void CZZ_SeiralPort_QT::InitPort(PortInfo portinfo)
|
||||
{
|
||||
|
||||
m_piSettings = portinfo;
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool CZZ_SeiralPort_QT::SetPort()
|
||||
{
|
||||
bool bRes = true;
|
||||
// int iRes = sio_ioctl(m_piSettings.iPortNumber, m_piSettings.indexBaudRate,
|
||||
// m_piSettings.indexParity | m_piSettings.indexBytesize | m_piSettings.indexStopBits);
|
||||
// if (iRes != SIO_OK)
|
||||
// {
|
||||
// bRes = false;
|
||||
// }
|
||||
QString qstrPortName;
|
||||
if (m_piSettings.FullPortName!="")
|
||||
{
|
||||
qstrPortName = m_piSettings.FullPortName;
|
||||
qDebug() << m_piSettings.FullPortName;
|
||||
}
|
||||
else {
|
||||
qstrPortName = QString("COM%1").arg(m_piSettings.iPortNumber);
|
||||
}
|
||||
// qstrPortName = "COM4";
|
||||
// QString qstrPortName = m_piSettings.FullPortName;//QString("COM%1").arg(m_piSettings.iPortNumber);
|
||||
m_pSerialPort->setPortName(qstrPortName);
|
||||
m_pSerialPort->setReadBufferSize(512);
|
||||
bRes = m_pSerialPort->setBaudRate(m_piSettings.iBaudRate);
|
||||
return bRes;
|
||||
}
|
||||
|
||||
bool CZZ_SeiralPort_QT::Open()
|
||||
{
|
||||
bool bRes = true;
|
||||
// int iRes = sio_open(m_piSettings.iPortNumber);
|
||||
// if (iRes!=SIO_OK)
|
||||
// {
|
||||
// bRes = false;
|
||||
// }
|
||||
bRes = m_pSerialPort->open(QIODevice::ReadWrite);
|
||||
if (!bRes)
|
||||
{
|
||||
qDebug() << "Err:open Failed.Exit Code:1";
|
||||
//std::cout << "Err.open Failed" << std::endl;
|
||||
return bRes;;
|
||||
}
|
||||
return bRes;
|
||||
}
|
||||
|
||||
void CZZ_SeiralPort_QT::Close()
|
||||
{
|
||||
m_pSerialPort->close();
|
||||
}
|
||||
|
||||
std::string CZZ_SeiralPort_QT::ReadAll(int waite)
|
||||
{
|
||||
if (!m_pSerialPort->waitForReadyRead(waite))
|
||||
{
|
||||
return "";
|
||||
|
||||
}
|
||||
if (
|
||||
m_pSerialPort->bytesAvailable() == 0
|
||||
)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
qbaRecv.clear();
|
||||
|
||||
qbaRecv = m_pSerialPort->readAll();
|
||||
|
||||
|
||||
std::string strRet(qbaRecv.constData(), qbaRecv.length());
|
||||
return strRet;
|
||||
|
||||
// std::string strRet;
|
||||
// char cBuf[MAXBUFFER];
|
||||
// int iRet = sio_read(m_piSettings.iPortNumber,cBuf, MAXBUFFER);
|
||||
// if (iRet==0)
|
||||
// {
|
||||
// strRet = "";
|
||||
//
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// char *pRecv = new char[iRet];
|
||||
// memcpy(pRecv, cBuf, iRet);
|
||||
// //std::string strRet(pRecv);
|
||||
// //delete pRecv;
|
||||
// //return strRet;
|
||||
//
|
||||
// strRet.resize(iRet);
|
||||
// for (int i=0;i<iRet;i++)
|
||||
// {
|
||||
// strRet[i] = pRecv[i];
|
||||
// }
|
||||
// delete pRecv;
|
||||
// }
|
||||
// return strRet;
|
||||
}
|
||||
|
||||
int CZZ_SeiralPort_QT::Write(const std::string strSend)
|
||||
{
|
||||
QByteArray qbaTest(strSend.c_str(),(int)strSend.length());
|
||||
qint64 qi64Write = m_pSerialPort->write(qbaTest);
|
||||
m_pSerialPort->waitForBytesWritten(5000);
|
||||
if (qi64Write != qbaTest.size())
|
||||
{
|
||||
qDebug() << "Err:write Failed.Exit Code:1" << qi64Write;
|
||||
return qi64Write;
|
||||
}
|
||||
|
||||
return 0;
|
||||
// char* pcSend = (char*)strSend.c_str();
|
||||
// int iRet = sio_write(m_piSettings.iPortNumber, pcSend, (int)strSend.length());
|
||||
//
|
||||
// //delete pcSend;
|
||||
// if (iRet!= (int)strSend.length())
|
||||
// {
|
||||
// return iRet;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
// //sio_write();
|
||||
}
|
||||
26
othersoft/movingliner/source/LinearShutter/ZZ_SeiralPort.h
Normal file
26
othersoft/movingliner/source/LinearShutter/ZZ_SeiralPort.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#include "VSMD12XMiscDefines.h"
|
||||
#include "AbstractPort.h"
|
||||
#include"qobject.h"
|
||||
class CZZ_SeiralPort_QT :public CAbstractPort,QObject
|
||||
{
|
||||
|
||||
private:
|
||||
PortInfo m_piSettings;
|
||||
QByteArray qbaSend, qbaRecv;
|
||||
QSerialPort *m_pSerialPort;
|
||||
public:
|
||||
CZZ_SeiralPort_QT();
|
||||
virtual ~CZZ_SeiralPort_QT();
|
||||
public:
|
||||
virtual void InitPort(PortInfo portinfo);
|
||||
virtual bool SetPort();
|
||||
virtual bool Open();
|
||||
virtual void Close();
|
||||
|
||||
virtual std::string ReadAll(int waittime = 5000);
|
||||
|
||||
virtual int Write(const std::string strSend);
|
||||
|
||||
};
|
||||
|
||||
297
othersoft/movingliner/source/LinearShutter/ZZ_Types.h
Normal file
297
othersoft/movingliner/source/LinearShutter/ZZ_Types.h
Normal file
@ -0,0 +1,297 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//<2F><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ļ<EFBFBD>
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#include <string>
|
||||
#define MAX_DEVICENUMBER_FS 2
|
||||
#define MAX_LINEARSHUTTER_POSITION 12
|
||||
namespace ZZ_MISCDEF
|
||||
{
|
||||
typedef unsigned char ZZ_U8;
|
||||
typedef unsigned short int ZZ_U16;
|
||||
typedef unsigned long int ZZ_U32;
|
||||
|
||||
|
||||
namespace IRIS
|
||||
{
|
||||
//Fiber Spectrometer
|
||||
namespace FS
|
||||
{
|
||||
typedef struct tagDataFrame
|
||||
{
|
||||
ZZ_U16 usExposureTimeInMS;
|
||||
ZZ_U16 usData[4096];
|
||||
float fTemperature;
|
||||
double dTimes = 0;
|
||||
}DataFrame;
|
||||
|
||||
typedef struct tagDeviceInfo
|
||||
{
|
||||
std::string strPN;
|
||||
std::string strSN;
|
||||
}DeviceInfo;
|
||||
|
||||
typedef struct tagDeviceAttribute
|
||||
{
|
||||
int iPixels;
|
||||
int iMaxIntegrationTimeInMS;
|
||||
int iMinIntegrationTimeInMS;
|
||||
float fWaveLengthInNM[4096];
|
||||
|
||||
}DeviceAttribute;
|
||||
}
|
||||
|
||||
enum DeviceModel
|
||||
{
|
||||
OSIFAlpha=0,
|
||||
OSIFBeta,
|
||||
ISIF,
|
||||
IS1,
|
||||
IS2
|
||||
};
|
||||
|
||||
// inline std::string GetDeviceModelName(int iModel)
|
||||
// {
|
||||
// switch (iModel)
|
||||
// {
|
||||
// case DeviceModel::OSIFAlpha: return "OSIFAlpha"; break;
|
||||
// case DeviceModel::OSIFBeta: return "OSIFBeta"; break;
|
||||
// case DeviceModel::ISIF: return "ISIF"; break;
|
||||
// case DeviceModel::IS1: return "IS1"; break;
|
||||
// case DeviceModel::IS2: return "IS2"; break;
|
||||
// default: return "error"; break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// inline int GetIndex(std::string strDeviceModelName)
|
||||
// {
|
||||
// if (strDeviceModelName== "OSIFAlpha")
|
||||
// {
|
||||
// return DeviceModel::OSIFAlpha;
|
||||
// }
|
||||
// else if (strDeviceModelName == "OSIFBeta")
|
||||
// {
|
||||
// return DeviceModel::OSIFBeta;
|
||||
// }
|
||||
// else if (strDeviceModelName == "ISIF")
|
||||
// {
|
||||
// return DeviceModel::ISIF;
|
||||
// }
|
||||
// else if (strDeviceModelName == "IS1")
|
||||
// {
|
||||
// return DeviceModel::IS1;
|
||||
// }
|
||||
// else if(strDeviceModelName == "IS2")
|
||||
// {
|
||||
// return DeviceModel::IS2;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
|
||||
};
|
||||
|
||||
//ATPָ<50><D6B8>ת<EFBFBD><D7AA>
|
||||
namespace ATP
|
||||
{
|
||||
const int MAX_SPECTRUM_SIZE = 4096;
|
||||
|
||||
const int GET_MODULECIRCUIT_TEMP = 0x01;
|
||||
const int GET_PN_NUMBER = 0x03;
|
||||
const int GET_SN_NUMBER = 0x04;
|
||||
const int GET_MANUFACTURE_DATA = 0x06;
|
||||
const int GET_MANUFACTURE_INFO = 0x09;
|
||||
const int GET_PIXEL_LENGTH = 0x0a;
|
||||
const int GET_TEC_TEMP = 0x13;
|
||||
const int SET_TEC_TEMP = 0x12;
|
||||
const int GET_OPTICS_TEMP = 0x35;
|
||||
const int GET_CIRCUITBOARD_TEMP = 0x36;
|
||||
const int SET_INTEGRATION_TIME = 0x14;
|
||||
const int GET_INTEGRATION_TIME = 0x41;
|
||||
const int GET_MAX_INTEGRATION_TIME = 0x42;
|
||||
const int GET_MIN_INTEGRATION_TIME = 0x43;
|
||||
const int ASYNC_COLLECT_DARK = 0x23;
|
||||
const int ASYNC_START_COLLECTION = 0x16;
|
||||
const int ASYNC_READ_DATA = 0x17;
|
||||
const int SET_AVERAGE_NUMBER = 0x28;
|
||||
const int SYNC_GET_DATA = 0x1e;
|
||||
const int SYNC_GET_DARK = 0x2f;
|
||||
const int EXTERNAL_TRIGGER_ENABLE = 0x1f;
|
||||
const int SET_XENON_LAMP_DELAY_TIME = 0x24;
|
||||
const int GET_WAVELENGTH_CALIBRATION_COEF = 0x55;
|
||||
const int GET_STAT_LAMPOUT = 0x60;
|
||||
const int SET_GPIO = 0x61;
|
||||
//const int SYNCHRONIZATION_GET_DARK = 0x23
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////device
|
||||
enum Model
|
||||
{
|
||||
ATP1010 = 0,
|
||||
ATP6500
|
||||
};
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>
|
||||
typedef struct tagATPDataFrame
|
||||
{
|
||||
unsigned short usExposureTime;
|
||||
ZZ_U16 usData[4096];
|
||||
float fTemperature;
|
||||
double dTimes = 0;
|
||||
}ATPDataFrame;
|
||||
|
||||
//<2F>豸<EFBFBD><E8B1B8>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
||||
typedef struct tagATPDeviceInfo
|
||||
{
|
||||
std::string strPN;
|
||||
std::string strSN;
|
||||
}ATPDeviceInfo;
|
||||
|
||||
//<2F>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
typedef struct tagATPDeviceAttribute
|
||||
{
|
||||
int iPixels;
|
||||
int iMaxIntegrationTime;
|
||||
int iMinIntegrationTime;
|
||||
float fWaveLength[4096];
|
||||
|
||||
}ATPDeviceAttribute;
|
||||
//////////////////////////////////////////////////////////////////////////config file
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD>в<EFBFBD><D0B2><EFBFBD>
|
||||
namespace ZZ_RUNPARAMS
|
||||
{
|
||||
typedef struct tagFiberSpecContext
|
||||
{
|
||||
ZZ_U8 ucDeviceNumber;
|
||||
ZZ_U8 ucDeviceModel[MAX_DEVICENUMBER_FS];
|
||||
int iInterface[MAX_DEVICENUMBER_FS];
|
||||
std::string strSN[MAX_DEVICENUMBER_FS];
|
||||
}FSContext;
|
||||
|
||||
typedef struct tagLinearShutterContext
|
||||
{
|
||||
ZZ_U8 ucPort;
|
||||
ZZ_U8 ucProtocolType;
|
||||
ZZ_U8 ucCmdID;
|
||||
}LSContext;
|
||||
|
||||
typedef struct tagAcquisitionTimeSettings
|
||||
{
|
||||
QTime qtStartTime;
|
||||
QTime qtStopTime;
|
||||
QTime qtInterval;
|
||||
}AcqTimeSettings;
|
||||
|
||||
typedef struct tagAcquisitionPositionSettings
|
||||
{
|
||||
int iTotalPosition;
|
||||
int iPosition[MAX_LINEARSHUTTER_POSITION];
|
||||
}AcqPosSettings;
|
||||
|
||||
typedef struct tagRunTimeGrabberParams
|
||||
{
|
||||
LSContext lscParam;
|
||||
FSContext fscParams;
|
||||
AcqTimeSettings atsParams;
|
||||
AcqPosSettings apsParams;
|
||||
}RunTimeGrabberParams;
|
||||
|
||||
typedef struct tagATPCalibrationSettings
|
||||
{
|
||||
//Up0 Down1,2,3
|
||||
QString qsISIF_CalibrationFilePath[4];
|
||||
QString qsIS1_CalibrationFilePath[4];
|
||||
}ATPCalibrationSettings;
|
||||
}
|
||||
|
||||
//ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ṹ
|
||||
namespace ZZ_DATAFILE
|
||||
{
|
||||
typedef struct tagEnvironmentalContext
|
||||
{
|
||||
QString qstrUTCDateTime;
|
||||
QString qstrLocation;
|
||||
QString qstrGPS_Longtitude;
|
||||
QString qstrGPS_Latitude;
|
||||
QString qstrGPS_Altitude;
|
||||
QString qstrGPS_North;
|
||||
QString qstrCaseTemperature;
|
||||
QString qstrCaseHumidity;
|
||||
|
||||
}EContext;
|
||||
|
||||
typedef struct tagManmadeEnviromentalContext
|
||||
{
|
||||
QString qstrOriFileName;
|
||||
QString qstrInstallationTime;
|
||||
QString qstrISIFCalibrationTime;
|
||||
QString qstrIS1CalibrationTime;
|
||||
QString qstrNameOfMaintenanceStaff;
|
||||
QString qstrPhoneNumberOfMaintenanceStaff;
|
||||
QString qstrDownloadUserID;
|
||||
QString qstrDownlaodAddress;
|
||||
QString qstrHTTPServer;
|
||||
}MEContext;
|
||||
|
||||
|
||||
typedef struct tagIS1Information
|
||||
{
|
||||
QString qstrSN_ATP;
|
||||
QString qstrSN_IRIS;
|
||||
|
||||
QString qstrCalFile_U0;
|
||||
QString qstrCalFile_D1;
|
||||
QString qstrCalFile_D2;
|
||||
QString qstrCalFile_D3;
|
||||
|
||||
int iPixelCount;
|
||||
|
||||
int iExposureTimeInMS_U0;
|
||||
int iExposureTimeInMS_D1;
|
||||
int iExposureTimeInMS_D2;
|
||||
int iExposureTimeInMS_D3;
|
||||
|
||||
float fTemperature_U0;
|
||||
float fTemperature_D1;
|
||||
float fTemperature_D2;
|
||||
float fTemperature_D3;
|
||||
}IS1Info;
|
||||
|
||||
typedef struct tagISIFInformation
|
||||
{
|
||||
QString qstrSN_ATP;
|
||||
QString qstrSN_IRIS;
|
||||
|
||||
QString qstrCalFile_U0;
|
||||
QString qstrCalFile_D1;
|
||||
QString qstrCalFile_D2;
|
||||
QString qstrCalFile_D3;
|
||||
|
||||
int iPixelCount;
|
||||
|
||||
int iExposureTimeInMS_U0;
|
||||
int iExposureTimeInMS_D1;
|
||||
int iExposureTimeInMS_D2;
|
||||
int iExposureTimeInMS_D3;
|
||||
|
||||
float fTemperature_U0;
|
||||
float fTemperature_D1;
|
||||
float fTemperature_D2;
|
||||
float fTemperature_D3;
|
||||
}ISIFInfo;
|
||||
|
||||
typedef struct tagATPDataHeader
|
||||
{
|
||||
|
||||
|
||||
}ATPDataHeader;
|
||||
}
|
||||
|
||||
};
|
||||
28
othersoft/movingliner/source/LinearShutter/pch.h
Normal file
28
othersoft/movingliner/source/LinearShutter/pch.h
Normal file
@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
////////////////////////////setings
|
||||
#include <QSettings>
|
||||
#include <QMetaEnum>
|
||||
////////////////////////////Basic
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QObject>
|
||||
////////////////////////////Thread
|
||||
#include <QThread>
|
||||
#include <QMutex>
|
||||
#include <QWaitCondition>
|
||||
////////////////////////////json
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
#include <QJsonParseError>
|
||||
////////////////////////////time
|
||||
#include <QtCore/QTime>
|
||||
#include <QDateTime>
|
||||
#include <QTimer>
|
||||
////////////////////////////Serial I/O
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
||||
191
othersoft/movingliner/source/Settings/SystemConfigger.cpp
Normal file
191
othersoft/movingliner/source/Settings/SystemConfigger.cpp
Normal file
@ -0,0 +1,191 @@
|
||||
#include "SystemConfigger.h"
|
||||
|
||||
|
||||
ZZ_SysConfigger::ZZ_SysConfigger(QObject *parent /*= nullptr*/)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
m_qstrDeviceConfigFilePath = "E:/WorkSpace/TowerOptoSifAndSpectral/config/DeviceSettings.ini";
|
||||
m_qstrJSONConfigFilePath = "E:/WorkSpace/TowerOptoSifAndSpectral/config/config.json";
|
||||
#else
|
||||
m_qstrJSONConfigFilePath = ("/home/data/Setting/config.json");
|
||||
#endif // DEBUG
|
||||
|
||||
m_qsDeviceConfig = NULL;
|
||||
}
|
||||
|
||||
ZZ_SysConfigger::~ZZ_SysConfigger()
|
||||
{
|
||||
if (qfJConfig.isOpen())
|
||||
{
|
||||
qfJConfig.close();
|
||||
}
|
||||
}
|
||||
|
||||
int ZZ_SysConfigger::Initialize()
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////load device settings
|
||||
using namespace ZZ_MISCDEF;
|
||||
QMetaEnum enumDeviceModel = QMetaEnum::fromType<ConfiggerDeviceModel>();
|
||||
|
||||
if (m_qsDeviceConfig!=NULL)
|
||||
{
|
||||
delete m_qsDeviceConfig;
|
||||
}
|
||||
m_qsDeviceConfig = new QSettings(m_qstrDeviceConfigFilePath, QSettings::IniFormat);
|
||||
m_struDeviceContext.ucDeviceNumber = m_qsDeviceConfig->value(QString("DEVICE INFO/TotalSpectrometer"),-1).toInt();
|
||||
if (m_struDeviceContext.ucDeviceNumber == -1)
|
||||
{
|
||||
qDebug() << "DEVICE INFO TotalSpectrometer Value Err.";
|
||||
return 3;
|
||||
}
|
||||
for (ZZ_U8 i=0;i< m_struDeviceContext.ucDeviceNumber;i++)
|
||||
{
|
||||
QString qstrTemp= m_qsDeviceConfig->value(QString("FS%1/Model").arg(i+1), "Null").toString();
|
||||
m_struDeviceContext.ucDeviceModel[i]= enumDeviceModel.keysToValue(qstrTemp.toLatin1().data());
|
||||
|
||||
int iInterface= m_qsDeviceConfig->value(QString("FS%1/Port").arg(i + 1), -2).toInt();
|
||||
m_struDeviceContext.iInterface[i] = iInterface;
|
||||
|
||||
qstrTemp = m_qsDeviceConfig->value(QString("FS%1/UID").arg(i + 1), "Null").toString();
|
||||
m_struDeviceContext.strSN[i] = qstrTemp.toStdString();
|
||||
}
|
||||
|
||||
m_struAcqPosition.iTotalPosition = m_qsDeviceConfig->value(QString("LINEAR SHUTTER/TotalPosition"), -1).toInt();
|
||||
if (m_struAcqPosition.iTotalPosition == -1)
|
||||
{
|
||||
qDebug() << "LINEAR SHUTTER TotalPosition Value Err.";
|
||||
return 4;
|
||||
}
|
||||
|
||||
for (ZZ_U8 i = 0; i < m_struAcqPosition.iTotalPosition; i++)
|
||||
{
|
||||
int iPosition = m_qsDeviceConfig->value(QString("LINEAR SHUTTER/Position%1").arg(i), -2).toInt();
|
||||
m_struAcqPosition.iPosition[i] = iPosition;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////load json settings
|
||||
qfJConfig.setFileName(m_qstrJSONConfigFilePath);
|
||||
bool bRes = qfJConfig.open(QIODevice::ReadOnly);
|
||||
if (!bRes)
|
||||
{
|
||||
qDebug() << "QFile open config file Err.";
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_qbaJData = qfJConfig.readAll();
|
||||
m_qjdJDoc= QJsonDocument::fromJson(m_qbaJData, &m_qjpeJErr);
|
||||
if (m_qjpeJErr.error != QJsonParseError::NoError)
|
||||
{
|
||||
qDebug() << m_qjpeJErr.errorString();
|
||||
return 2;
|
||||
}
|
||||
m_qjoJObj = m_qjdJDoc.object();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_SysConfigger::GetGrabberRunParams(RunTimeGrabberParams &struGrabberRTParams)
|
||||
{
|
||||
struGrabberRTParams.atsParams = m_struAcqTime;
|
||||
struGrabberRTParams.fscParams = m_struDeviceContext;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_SysConfigger::LoadSettingsFromFile_IS1()
|
||||
{
|
||||
m_struIS1Info.qstrCalFile_U0 = m_qjoJObj.value("IS1UpCalFile").toString();
|
||||
m_struIS1Info.qstrCalFile_D1 = m_qjoJObj.value("IS1DownCalFile1").toString();
|
||||
m_struIS1Info.qstrCalFile_D2 = m_qjoJObj.value("IS1DownCalFile2").toString();
|
||||
m_struIS1Info.qstrCalFile_D3 = m_qjoJObj.value("IS1DownCalFile3").toString();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_SysConfigger::LoadSettingsFromFile_iSIF()
|
||||
{
|
||||
m_struISIFInfo.qstrCalFile_U0 = m_qjoJObj.value("SIFUpCalFile").toString();
|
||||
m_struISIFInfo.qstrCalFile_D1 = m_qjoJObj.value("SIFDownCalFile1").toString();
|
||||
m_struISIFInfo.qstrCalFile_D2 = m_qjoJObj.value("SIFDownCalFile2").toString();
|
||||
m_struISIFInfo.qstrCalFile_D3 = m_qjoJObj.value("SIFDownCalFile3").toString();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_SysConfigger::LoadSettingsFromFile_System()
|
||||
{
|
||||
// QString qstr = m_qjoJObj.value("IntervalTime").toString();
|
||||
m_struAcqTime.qtStartTime=QTime::fromString(m_qjoJObj.value("BeginTime").toString(), "hh:mm");
|
||||
if (!m_struAcqTime.qtStartTime.isValid())
|
||||
{
|
||||
qDebug() << "Invalid BeginTime";
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
m_struAcqTime.qtInterval = QTime::fromString(m_qjoJObj.value("IntervalTime").toString(), "ss");
|
||||
if (!m_struAcqTime.qtInterval.isValid())
|
||||
{
|
||||
qDebug() << "Invalid IntervalTime";
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
m_struAcqTime.qtInterval = QTime::fromString(m_qjoJObj.value("IntervalTime").toString(), "mm");
|
||||
if (!m_struAcqTime.qtInterval.isValid())
|
||||
{
|
||||
qDebug() << "Invalid IntervalTime";
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_struAcqTime.qtStopTime = QTime::fromString(m_qjoJObj.value("EndTime").toString(), "hh:mm");
|
||||
if (!m_struAcqTime.qtStopTime.isValid())
|
||||
{
|
||||
qDebug() << "Invalid EndTime";
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_SysConfigger::LoadSettingsFromFile_MISC()
|
||||
{
|
||||
m_struEC.qstrLocation = m_qjoJObj.value("Location").toString();
|
||||
m_struEC.qstrGPS_Altitude = m_qjoJObj.value("GPS_Altitude").toString();
|
||||
m_struEC.qstrGPS_Latitude = m_qjoJObj.value("GPS_Latitude").toString();
|
||||
m_struEC.qstrGPS_Longtitude = m_qjoJObj.value("GPS_Longtitude").toString();
|
||||
m_struEC.qstrGPS_North = m_qjoJObj.value("GPS_North").toString();
|
||||
|
||||
m_struMEC.qstrInstallationTime = m_qjoJObj.value("InstallationTime").toString();
|
||||
m_struMEC.qstrISIFCalibrationTime = m_qjoJObj.value("ISIFCalibrationTime").toString();
|
||||
m_struMEC.qstrIS1CalibrationTime = m_qjoJObj.value("IS1CalibrationTime").toString();
|
||||
m_struMEC.qstrNameOfMaintenanceStaff = m_qjoJObj.value("NameOfMaintenanceStaff").toString();
|
||||
m_struMEC.qstrPhoneNumberOfMaintenanceStaff = m_qjoJObj.value("PhoneNumberOfMaintenanceStaff").toString();
|
||||
m_struMEC.qstrDownloadUserID = m_qjoJObj.value("DownloadUserID").toString();
|
||||
m_struMEC.qstrDownlaodAddress = m_qjoJObj.value("DownlaodAddress").toString();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ZZ_SysConfigger::LoadSettings_Test()
|
||||
{
|
||||
QFile qfTest(m_qstrJSONConfigFilePath);
|
||||
|
||||
qfTest.open(QFile::ReadOnly);
|
||||
|
||||
QByteArray qbJData = qfTest.readAll();
|
||||
|
||||
QJsonParseError jerr;
|
||||
QJsonDocument jdoc(QJsonDocument::fromJson(qbJData, &jerr));
|
||||
if (jerr.error!= QJsonParseError::NoError)
|
||||
{
|
||||
qDebug() << jerr.errorString();
|
||||
}
|
||||
|
||||
QJsonObject rootobj = jdoc.object();
|
||||
QStringList key = rootobj.keys();
|
||||
QString qtest1 = rootobj.value(rootobj.keys().at(15)).toString();
|
||||
return 0;
|
||||
}
|
||||
57
othersoft/movingliner/source/Settings/SystemConfigger.h
Normal file
57
othersoft/movingliner/source/Settings/SystemConfigger.h
Normal file
@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#include "ZZ_Types.h"
|
||||
using namespace ZZ_MISCDEF::ZZ_RUNPARAMS;
|
||||
using namespace ZZ_MISCDEF::ZZ_DATAFILE;
|
||||
|
||||
class ZZ_SysConfigger :public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ZZ_SysConfigger(QObject *parent = nullptr);
|
||||
virtual ~ZZ_SysConfigger();
|
||||
public:
|
||||
int Initialize();
|
||||
int GetGrabberRunParams(RunTimeGrabberParams &struGrabberRTParams);
|
||||
|
||||
int LoadSettingsFromFile_IS1();
|
||||
int LoadSettingsFromFile_iSIF();
|
||||
int LoadSettingsFromFile_System();
|
||||
int LoadSettingsFromFile_MISC();
|
||||
int LoadSettings_Test();
|
||||
public:
|
||||
enum ConfiggerDeviceModel
|
||||
{
|
||||
OSIFAlpha = 0,
|
||||
OSIFBeta,
|
||||
ISIF,
|
||||
IS1,
|
||||
IS2,
|
||||
Null
|
||||
};
|
||||
Q_ENUM(ConfiggerDeviceModel);
|
||||
//////////////////////////////////////////////////////////////////////////run-time settings
|
||||
AcqTimeSettings m_struAcqTime;
|
||||
FSContext m_struDeviceContext;
|
||||
AcqPosSettings m_struAcqPosition;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
EContext m_struEC;
|
||||
MEContext m_struMEC;
|
||||
IS1Info m_struIS1Info;
|
||||
ISIFInfo m_struISIFInfo;
|
||||
|
||||
private:
|
||||
QString m_qstrDeviceConfigFilePath;
|
||||
QString m_qstrJSONConfigFilePath;
|
||||
QFile qfJConfig/*,qfDeviceConfig*/;
|
||||
QSettings *m_qsDeviceConfig;
|
||||
|
||||
QByteArray m_qbaJData;
|
||||
QJsonParseError m_qjpeJErr;
|
||||
QJsonObject m_qjoJObj;
|
||||
QJsonDocument m_qjdJDoc;
|
||||
|
||||
|
||||
|
||||
};
|
||||
47
othersoft/shuttercali/project/LocationCali/CMakeLists.txt
Normal file
47
othersoft/shuttercali/project/LocationCali/CMakeLists.txt
Normal file
@ -0,0 +1,47 @@
|
||||
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)
|
||||
#target_link_libraries(shutter_calibrate seabreeze usb stdc++ m)
|
||||
ELSE ()
|
||||
target_link_libraries(shutter_calibrate seabreeze usb stdc++ m)
|
||||
ENDIF ()
|
||||
set_target_properties(shutter_calibrate PROPERTIES AUTOMOC ON)
|
||||
|
||||
|
||||
BIN
othersoft/shuttercali/project/LocationCali/SeaBreeze.dll
Normal file
BIN
othersoft/shuttercali/project/LocationCali/SeaBreeze.dll
Normal file
Binary file not shown.
BIN
othersoft/shuttercali/project/LocationCali/SeaBreeze.lib
Normal file
BIN
othersoft/shuttercali/project/LocationCali/SeaBreeze.lib
Normal file
Binary file not shown.
305
othersoft/shuttercali/project/LocationCali/main.cpp
Normal file
305
othersoft/shuttercali/project/LocationCali/main.cpp
Normal file
@ -0,0 +1,305 @@
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include<VSMD12XControl.h>
|
||||
#include "QTextCodec"
|
||||
#include "SensorMannager.h"
|
||||
#include"SensorOptoSky.h"
|
||||
#include"SensorQExPRO.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <QTextStream>
|
||||
#include <QSettings>
|
||||
|
||||
QTextStream cout1(stdout, QIODevice::WriteOnly);
|
||||
void logout(QString str){
|
||||
cout1<<str<<" <br>"<<flush;
|
||||
cout1<<endl;
|
||||
// std::fflush(stdout);
|
||||
}
|
||||
vector<int> FindFeng(vector<int > point1ist, vector<float> valuelist);
|
||||
vector<int> DengJianJu(int position, int distanc, int times = 10);
|
||||
vector <float> PingHua(vector <float> value, int step = 2);
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
if (argc!=4)
|
||||
{
|
||||
logout("Some Thing error Please check the input");
|
||||
logout( "The Correct Should Be application sensor numberofposition");
|
||||
logout( "apllication Sensor positionneed shutter_time");
|
||||
logout("Senor: OSIFAlpha QEPRO");
|
||||
logout("Senor: OSIFBeta QE65");
|
||||
logout("Senor: ISIF ATP6500");
|
||||
logout("Senor: IS1 ATP1010");
|
||||
logout("Senor: IS2 ATP5020");
|
||||
|
||||
return 0;
|
||||
}
|
||||
// cali;
|
||||
int bandsnumber=1024;
|
||||
QString SensorTypestr(argv[1]);
|
||||
QString PositionNumberstr(argv[2]);
|
||||
int shuttertime=QString(argv[3]).toInt();
|
||||
int PositionNumber=PositionNumberstr.toInt();
|
||||
QCoreApplication aaaaa(argc, argv);
|
||||
|
||||
QString m_qstrDeviceConfigFilePath;
|
||||
|
||||
#ifdef WIN32
|
||||
m_qstrDeviceConfigFilePath = ("D:\\03MyGit\\linux\\movingliner\\DeviceSettings.ini");
|
||||
#else
|
||||
m_qstrDeviceConfigFilePath = ("/home/data/Setting/DeviceSettings.ini");
|
||||
#endif
|
||||
QSettings *m_qsDeviceConfig;
|
||||
m_qsDeviceConfig = new QSettings(m_qstrDeviceConfigFilePath, QSettings::IniFormat);
|
||||
int numberofsensor=m_qsDeviceConfig->value("DEVICE INFO/TotalSpectrometer").toInt();
|
||||
|
||||
|
||||
logout("Welcom to use the Auto Locate Application");
|
||||
string hdrPath = "/home/data/test.csv";
|
||||
std::ofstream outfile(hdrPath.c_str());
|
||||
string hdrPath1 = "/home/data/result.csv";
|
||||
std::ofstream outfile1(hdrPath1.c_str());
|
||||
|
||||
logout("Sensor is "+SensorTypestr);
|
||||
SensorBase* aa= nullptr;
|
||||
if (SensorTypestr=="OSIFAlpha")
|
||||
{
|
||||
aa = new SensorQExPRO(QE65PRO_QE);
|
||||
|
||||
} else if (SensorTypestr=="OSIFBeta")
|
||||
{
|
||||
aa = new SensorQExPRO(QE65PRO_QE);
|
||||
|
||||
}
|
||||
if(aa== nullptr)
|
||||
{
|
||||
QString portname="";
|
||||
for (int i = 0; i < numberofsensor; ++i) {
|
||||
QString key="FS"+QString::number(i+1)+"/Model";
|
||||
qDebug()<<key;
|
||||
if (m_qsDeviceConfig->value(key).toString()==SensorTypestr)
|
||||
{
|
||||
QString portstr=m_qsDeviceConfig->value("FS"+QString::number(i+1)+"/Port").toString();
|
||||
QStringList strlist=portstr.split('/');
|
||||
portname=strlist.at(strlist.length()-1);
|
||||
}
|
||||
}
|
||||
// qDebug()<<portname;
|
||||
|
||||
if (portname=="")
|
||||
{
|
||||
logout("<b style=\"color:red\">Can not find the sensor"+SensorTypestr+"<\/b>");
|
||||
return 1;
|
||||
}
|
||||
logout("Sensor Port is "+portname);
|
||||
aa=new SensorOptoSky(ATP6500,portname);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//SensorBase* aa = new SensorOptoSky(ATP6500,"ttyUSB0");
|
||||
|
||||
aa->initSensor();
|
||||
STRSensorInfo info= aa->SensorInfo;
|
||||
int bandsshow=info.BandNum/2;
|
||||
logout("Sensor Bands to Show is "+QString::number(bandsshow));
|
||||
STROnePlot oneplot;
|
||||
|
||||
|
||||
CVSMD12XControl Motercontrol;
|
||||
//Motercontrol.ILMES_InitializeComm("COM16");
|
||||
if ( m_qsDeviceConfig->value("LINEAR SHUTTER/Port").toString()!="")
|
||||
{
|
||||
logout("Find the motor port:"+m_qsDeviceConfig->value("LINEAR SHUTTER/Port").toString());
|
||||
Motercontrol.ILMES_InitializeComm( m_qsDeviceConfig->value("LINEAR SHUTTER/Port").toString());
|
||||
} else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
logout("The max Postion is "+QString::number(550000/4*PositionNumber));
|
||||
ControllerParams cpTest;
|
||||
bool res = Motercontrol.ILMES_InitializeParams(cpTest);
|
||||
|
||||
|
||||
|
||||
|
||||
aa->Settingshuttertime(shuttertime);
|
||||
aa->GetOnePlot(oneplot);
|
||||
|
||||
|
||||
|
||||
|
||||
logout("GO TO ZERO");
|
||||
Motercontrol.StartBackZero();
|
||||
Motercontrol.SetRunSpeed(10000);
|
||||
logout("GO TO ZERO OK");
|
||||
logout("Start Moving to "+QString::number(550000/4*PositionNumber));
|
||||
Motercontrol.MoveTo_NoSyn(550000/4*PositionNumber);
|
||||
aa->GetOnePlot(oneplot);
|
||||
MSInfo temp;
|
||||
Motercontrol.GetStatus(temp);
|
||||
vector<int > point1ist;
|
||||
vector<float> valuelist;
|
||||
int i = 0;
|
||||
Motercontrol.GetStatus(temp);
|
||||
//outfile <<i<<"," << oneplot.Plot[1024] << "," << temp.iPosition << std::endl;
|
||||
|
||||
point1ist.push_back(temp.iPosition);
|
||||
valuelist.push_back(oneplot.Plot[bandsshow]);
|
||||
while (temp.fVelocity!=0)
|
||||
{
|
||||
aa->GetOnePlot(oneplot);
|
||||
//qDebug() << oneplot.BandNum;
|
||||
//std::cout << temp.iPosition << std::endl;
|
||||
|
||||
Motercontrol.GetStatus(temp);
|
||||
i++;
|
||||
outfile << i << "," << oneplot.Plot[bandsshow] << "," << temp.iPosition << std::endl;
|
||||
point1ist.push_back(temp.iPosition);
|
||||
valuelist.push_back(oneplot.Plot[bandsshow]);
|
||||
|
||||
}
|
||||
logout("FINISH Moving");
|
||||
vector<float> valuepinghua1 = PingHua(valuelist, 3);
|
||||
vector<int>loction1=FindFeng(point1ist, valuepinghua1);
|
||||
|
||||
int lenth = loction1.size();
|
||||
if (lenth!=PositionNumber)
|
||||
{
|
||||
logout("<b style=\"color:red\">can not find all position please change the shutter time and try agin<\/b>");
|
||||
}
|
||||
cout1<<"First find "<<lenth<<" point "<<"<br>"<<flush;
|
||||
|
||||
logout("GO TO ZERO");
|
||||
Motercontrol.StartBackZero();
|
||||
logout("GO TO ZERO OK");
|
||||
logout("Start Moving");
|
||||
for (size_t i = 0; i < lenth; i++)
|
||||
{
|
||||
vector<int> location1point = DengJianJu(loction1[i], 5000, 25);
|
||||
vector<float> valuepoint;
|
||||
int lennow = location1point.size();
|
||||
cout1<<"Detail find "<<i<<" point begin"<<"<br>"<<flush;
|
||||
for (size_t ii = 0; ii < lennow; ii++)
|
||||
{
|
||||
|
||||
Motercontrol.MoveTo(location1point[ii]);
|
||||
aa->GetOnePlot(oneplot);
|
||||
valuepoint.push_back(oneplot.Plot[bandsshow]);
|
||||
//outfile << ii << "," << oneplot.Plot[1024] << "," << location1point[ii] << std::endl;
|
||||
|
||||
}
|
||||
vector<float> valuepinghua = PingHua(valuepoint,3);
|
||||
vector<int>loction2 = FindFeng(location1point, valuepinghua);
|
||||
|
||||
if (loction2.size() == 1)
|
||||
{ cout1<<"find "<<i<<"point value is <b color=\'green\'>"<<loction2[0]<<"<\/b><br>"<<flush;
|
||||
outfile1 <<i+1<<"," << loction2[0]<< std::endl;
|
||||
}
|
||||
|
||||
int cc = 10;
|
||||
cc++;
|
||||
|
||||
}
|
||||
logout("FINISH Moving");
|
||||
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
std::cout<<"totle:" << i;
|
||||
outfile.close();
|
||||
outfile.close();
|
||||
if (!res)
|
||||
{
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
return aaaaa.exec();
|
||||
|
||||
}
|
||||
|
||||
|
||||
vector<int> FindFeng(vector<int > point1ist, vector<float> valuelist)
|
||||
{
|
||||
vector<int> 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<int> DengJianJu(int position, int distanc, int times )
|
||||
{
|
||||
int begin = position - distanc;
|
||||
vector<int> ret;
|
||||
int eachstep = distanc / times;
|
||||
for (size_t i = 0; i < 2*times; i++)
|
||||
{
|
||||
ret.push_back(begin + i * eachstep);
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
vector <float> PingHua(vector <float> value,int step)
|
||||
{
|
||||
vector <float> 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 <len-step; i++)
|
||||
{
|
||||
float sumi = 0;
|
||||
for (size_t ii = 0; ii < 2*step+1; ii++)
|
||||
{
|
||||
sumi += value[i - step + ii];
|
||||
}
|
||||
ret.push_back(sumi / (2 * step + 1));
|
||||
}
|
||||
for (size_t i = len - step; i < len; i++)
|
||||
{
|
||||
ret.push_back(value[i]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
591
othersoft/shuttercali/source/FS/ATPControl_Serial_QT.cpp
Normal file
591
othersoft/shuttercali/source/FS/ATPControl_Serial_QT.cpp
Normal file
@ -0,0 +1,591 @@
|
||||
#include "pch.h"
|
||||
#include "ATPControl_Serial_QT.h"
|
||||
#include "ZZ_Math_HDRONLY.h"
|
||||
|
||||
ZZ_ATPControl_Serial_Qt::ZZ_ATPControl_Serial_Qt()
|
||||
{
|
||||
m_pSerialPort = new QSerialPort;
|
||||
//connect(m_pSerialPort, &QSerialPort::readyRead, this, &ZZ_ATPControl_Serial_Qt::ReadMessage);
|
||||
m_iBaudRate = 115200;
|
||||
}
|
||||
|
||||
ZZ_ATPControl_Serial_Qt::~ZZ_ATPControl_Serial_Qt()
|
||||
{
|
||||
if (m_pSerialPort != NULL)
|
||||
{
|
||||
delete m_pSerialPort;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// int ZZ_ATPControl_Serial_Qt::SetBaudRate(int iBaud)
|
||||
// {
|
||||
// m_iBaudRate = iBaud;
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
|
||||
int ZZ_ATPControl_Serial_Qt::Initialize(bool bIsUSBMode, ZZ_U8 ucPortNumber, std::string strDeviceName)
|
||||
{
|
||||
QString qstrPortName = QString("COM%1").arg(ucPortNumber);
|
||||
|
||||
m_pSerialPort->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;
|
||||
// }
|
||||
84
othersoft/shuttercali/source/FS/ATPControl_Serial_QT.h
Normal file
84
othersoft/shuttercali/source/FS/ATPControl_Serial_QT.h
Normal file
@ -0,0 +1,84 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//ATP<54><50><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#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:
|
||||
//<2F><><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>
|
||||
//int SetBaudRate(int iBaud);
|
||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>豸
|
||||
int Initialize(bool bIsUSBMode, ZZ_U8 ucPortNumber, std::string strDeviceName);
|
||||
//<2F>ر<EFBFBD><D8B1>豸
|
||||
void Close();
|
||||
|
||||
//<2F><><EFBFBD>β<EFBFBD><CEB2>Բɼ<D4B2> <20><><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int SingleShot(int &iPixels);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲɼ<DDB2>
|
||||
int SingleShot(DataFrame &dfData);
|
||||
|
||||
//<2F><><EFBFBD>ΰ<EFBFBD><CEB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>
|
||||
//int SingleShotDark(ATPDataFrame &dfData);
|
||||
|
||||
//int SingleShotDeducted(ATPDataFrame &dfData);
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
int SetExposureTime(int iExposureTimeInMS);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int GetExposureTime(int &iExposureTimeInMS);
|
||||
|
||||
//int GetWaveLength(float *pfWaveLength);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
||||
int GetDeviceInfo(DeviceInfo &Info);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
int GetDeviceAttribute(DeviceAttribute &Attr);
|
||||
|
||||
//int GetDeviceListInfo(); //use type name to enum
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>
|
||||
int SetDeviceTemperature(float fTemperature);
|
||||
|
||||
//<2F><>ȡ<EFBFBD>¶<EFBFBD>
|
||||
int GetDeviceTemperature(float &fTemperature);
|
||||
|
||||
//<2F>Զ<EFBFBD><D4B6>ع<EFBFBD>
|
||||
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();
|
||||
};
|
||||
1
othersoft/shuttercali/source/FS/ATPDataFileProcessor.h
Normal file
1
othersoft/shuttercali/source/FS/ATPDataFileProcessor.h
Normal file
@ -0,0 +1 @@
|
||||
#pragma once
|
||||
42
othersoft/shuttercali/source/FS/IrisFiberSpectrometerBase.h
Normal file
42
othersoft/shuttercali/source/FS/IrisFiberSpectrometerBase.h
Normal file
@ -0,0 +1,42 @@
|
||||
#include <string>
|
||||
#include "ZZ_Types.h"
|
||||
#pragma once
|
||||
using namespace ZZ_MISCDEF;
|
||||
using namespace ZZ_MISCDEF::IRIS::FS;
|
||||
|
||||
class CIrisFSBase
|
||||
{
|
||||
public:
|
||||
//CIrisFSBase();
|
||||
//virtual ~CIrisFSBase()= 0;
|
||||
public:
|
||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>豸
|
||||
//<2F>˴<EFBFBD>stringΪָ<CEAA><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD>ocean<61><6E><EFBFBD><EFBFBD><EFBFBD>ǵIJ<C7B5><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>c/c++<2B><><EFBFBD><D7BC><EFBFBD><EFBFBD>
|
||||
//0Ϊ<30><EFBFBD><DEB4><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>뷵<EFBFBD>ز<EFBFBD>ֵͬ
|
||||
virtual int Initialize(bool bIsUSBMode,ZZ_U8 ucPortNumber,std::string strDeviceName) = 0;
|
||||
|
||||
//<2F>ر<EFBFBD><D8B1>豸
|
||||
virtual void Close() = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݲɼ<DDB2>
|
||||
virtual int SingleShot(DataFrame &dfData) = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
virtual int SetExposureTime(int iExposureTimeInMS) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>ع<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
virtual int GetExposureTime(int &iExposureTimeInMS) = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>¶<EFBFBD>
|
||||
virtual int SetDeviceTemperature(float fTemperature) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>¶<EFBFBD><C2B6><EFBFBD><EFBFBD><EFBFBD>
|
||||
virtual int GetDeviceTemperature(float &fTemperature) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8>Ϣ
|
||||
virtual int GetDeviceInfo(DeviceInfo &Info) = 0;
|
||||
|
||||
//<2F><>ȡ<EFBFBD>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
virtual int GetDeviceAttribute(DeviceAttribute &Attr) = 0;
|
||||
|
||||
};
|
||||
297
othersoft/shuttercali/source/FS/ZZ_Types.h
Normal file
297
othersoft/shuttercali/source/FS/ZZ_Types.h
Normal file
@ -0,0 +1,297 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//<2F><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD>ļ<EFBFBD>
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
#include <string>
|
||||
#define MAX_DEVICENUMBER_FS 2
|
||||
#define MAX_LINEARSHUTTER_POSITION 12
|
||||
namespace ZZ_MISCDEF
|
||||
{
|
||||
typedef unsigned char ZZ_U8;
|
||||
typedef unsigned short int ZZ_U16;
|
||||
typedef unsigned long int ZZ_U32;
|
||||
|
||||
|
||||
namespace IRIS
|
||||
{
|
||||
//Fiber Spectrometer
|
||||
namespace FS
|
||||
{
|
||||
typedef struct tagDataFrame
|
||||
{
|
||||
ZZ_U16 usExposureTimeInMS;
|
||||
ZZ_U16 usData[4096];
|
||||
float fTemperature;
|
||||
double dTimes = 0;
|
||||
}DataFrame;
|
||||
|
||||
typedef struct tagDeviceInfo
|
||||
{
|
||||
std::string strPN;
|
||||
std::string strSN;
|
||||
}DeviceInfo;
|
||||
|
||||
typedef struct tagDeviceAttribute
|
||||
{
|
||||
int iPixels;
|
||||
int iMaxIntegrationTimeInMS;
|
||||
int iMinIntegrationTimeInMS;
|
||||
float fWaveLengthInNM[4096];
|
||||
|
||||
}DeviceAttribute;
|
||||
}
|
||||
|
||||
enum DeviceModel
|
||||
{
|
||||
OSIFAlpha=0,
|
||||
OSIFBeta,
|
||||
ISIF,
|
||||
IS1,
|
||||
IS2
|
||||
};
|
||||
|
||||
// inline std::string GetDeviceModelName(int iModel)
|
||||
// {
|
||||
// switch (iModel)
|
||||
// {
|
||||
// case DeviceModel::OSIFAlpha: return "OSIFAlpha"; break;
|
||||
// case DeviceModel::OSIFBeta: return "OSIFBeta"; break;
|
||||
// case DeviceModel::ISIF: return "ISIF"; break;
|
||||
// case DeviceModel::IS1: return "IS1"; break;
|
||||
// case DeviceModel::IS2: return "IS2"; break;
|
||||
// default: return "error"; break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// inline int GetIndex(std::string strDeviceModelName)
|
||||
// {
|
||||
// if (strDeviceModelName== "OSIFAlpha")
|
||||
// {
|
||||
// return DeviceModel::OSIFAlpha;
|
||||
// }
|
||||
// else if (strDeviceModelName == "OSIFBeta")
|
||||
// {
|
||||
// return DeviceModel::OSIFBeta;
|
||||
// }
|
||||
// else if (strDeviceModelName == "ISIF")
|
||||
// {
|
||||
// return DeviceModel::ISIF;
|
||||
// }
|
||||
// else if (strDeviceModelName == "IS1")
|
||||
// {
|
||||
// return DeviceModel::IS1;
|
||||
// }
|
||||
// else if(strDeviceModelName == "IS2")
|
||||
// {
|
||||
// return DeviceModel::IS2;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return -1;
|
||||
// }
|
||||
// }
|
||||
|
||||
};
|
||||
|
||||
//ATPָ<50><D6B8>ת<EFBFBD><D7AA>
|
||||
namespace ATP
|
||||
{
|
||||
const int MAX_SPECTRUM_SIZE = 4096;
|
||||
|
||||
const int GET_MODULECIRCUIT_TEMP = 0x01;
|
||||
const int GET_PN_NUMBER = 0x03;
|
||||
const int GET_SN_NUMBER = 0x04;
|
||||
const int GET_MANUFACTURE_DATA = 0x06;
|
||||
const int GET_MANUFACTURE_INFO = 0x09;
|
||||
const int GET_PIXEL_LENGTH = 0x0a;
|
||||
const int GET_TEC_TEMP = 0x13;
|
||||
const int SET_TEC_TEMP = 0x12;
|
||||
const int GET_OPTICS_TEMP = 0x35;
|
||||
const int GET_CIRCUITBOARD_TEMP = 0x36;
|
||||
const int SET_INTEGRATION_TIME = 0x14;
|
||||
const int GET_INTEGRATION_TIME = 0x41;
|
||||
const int GET_MAX_INTEGRATION_TIME = 0x42;
|
||||
const int GET_MIN_INTEGRATION_TIME = 0x43;
|
||||
const int ASYNC_COLLECT_DARK = 0x23;
|
||||
const int ASYNC_START_COLLECTION = 0x16;
|
||||
const int ASYNC_READ_DATA = 0x17;
|
||||
const int SET_AVERAGE_NUMBER = 0x28;
|
||||
const int SYNC_GET_DATA = 0x1e;
|
||||
const int SYNC_GET_DARK = 0x2f;
|
||||
const int EXTERNAL_TRIGGER_ENABLE = 0x1f;
|
||||
const int SET_XENON_LAMP_DELAY_TIME = 0x24;
|
||||
const int GET_WAVELENGTH_CALIBRATION_COEF = 0x55;
|
||||
const int GET_STAT_LAMPOUT = 0x60;
|
||||
const int SET_GPIO = 0x61;
|
||||
//const int SYNCHRONIZATION_GET_DARK = 0x23
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////device
|
||||
enum Model
|
||||
{
|
||||
ATP1010 = 0,
|
||||
ATP6500
|
||||
};
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>
|
||||
typedef struct tagATPDataFrame
|
||||
{
|
||||
unsigned short usExposureTime;
|
||||
ZZ_U16 usData[4096];
|
||||
float fTemperature;
|
||||
double dTimes = 0;
|
||||
}ATPDataFrame;
|
||||
|
||||
//<2F>豸<EFBFBD><E8B1B8>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
||||
typedef struct tagATPDeviceInfo
|
||||
{
|
||||
std::string strPN;
|
||||
std::string strSN;
|
||||
}ATPDeviceInfo;
|
||||
|
||||
//<2F>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
typedef struct tagATPDeviceAttribute
|
||||
{
|
||||
int iPixels;
|
||||
int iMaxIntegrationTime;
|
||||
int iMinIntegrationTime;
|
||||
float fWaveLength[4096];
|
||||
|
||||
}ATPDeviceAttribute;
|
||||
//////////////////////////////////////////////////////////////////////////config file
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD>в<EFBFBD><D0B2><EFBFBD>
|
||||
namespace ZZ_RUNPARAMS
|
||||
{
|
||||
typedef struct tagFiberSpecContext
|
||||
{
|
||||
ZZ_U8 ucDeviceNumber;
|
||||
ZZ_U8 ucDeviceModel[MAX_DEVICENUMBER_FS];
|
||||
int iInterface[MAX_DEVICENUMBER_FS];
|
||||
std::string strSN[MAX_DEVICENUMBER_FS];
|
||||
}FSContext;
|
||||
|
||||
typedef struct tagLinearShutterContext
|
||||
{
|
||||
ZZ_U8 ucPort;
|
||||
ZZ_U8 ucProtocolType;
|
||||
ZZ_U16 usCmdID;
|
||||
}LSContext;
|
||||
|
||||
typedef struct tagAcquisitionTimeSettings
|
||||
{
|
||||
QTime qtStartTime;
|
||||
QTime qtStopTime;
|
||||
QTime qtInterval;
|
||||
}AcqTimeSettings;
|
||||
|
||||
typedef struct tagAcquisitionPositionSettings
|
||||
{
|
||||
int iTotalPosition;
|
||||
int iPosition[MAX_LINEARSHUTTER_POSITION];
|
||||
}AcqPosSettings;
|
||||
|
||||
typedef struct tagRunTimeGrabberParams
|
||||
{
|
||||
LSContext lscParam;
|
||||
FSContext fscParams;
|
||||
AcqTimeSettings atsParams;
|
||||
AcqPosSettings apsParams;
|
||||
}RunTimeGrabberParams;
|
||||
|
||||
typedef struct tagATPCalibrationSettings
|
||||
{
|
||||
//Up0 Down1,2,3
|
||||
QString qsISIF_CalibrationFilePath[4];
|
||||
QString qsIS1_CalibrationFilePath[4];
|
||||
}ATPCalibrationSettings;
|
||||
}
|
||||
|
||||
//ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ṹ
|
||||
namespace ZZ_DATAFILE
|
||||
{
|
||||
typedef struct tagEnvironmentalContext
|
||||
{
|
||||
QString qstrUTCDateTime;
|
||||
QString qstrLocation;
|
||||
QString qstrGPS_Longtitude;
|
||||
QString qstrGPS_Latitude;
|
||||
QString qstrGPS_Altitude;
|
||||
QString qstrGPS_North;
|
||||
QString qstrCaseTemperature;
|
||||
QString qstrCaseHumidity;
|
||||
|
||||
}EContext;
|
||||
|
||||
typedef struct tagManmadeEnviromentalContext
|
||||
{
|
||||
QString qstrOriFileName;
|
||||
QString qstrInstallationTime;
|
||||
QString qstrISIFCalibrationTime;
|
||||
QString qstrIS1CalibrationTime;
|
||||
QString qstrNameOfMaintenanceStaff;
|
||||
QString qstrPhoneNumberOfMaintenanceStaff;
|
||||
QString qstrDownloadUserID;
|
||||
QString qstrDownlaodAddress;
|
||||
QString qstrHTTPServer;
|
||||
}MEContext;
|
||||
|
||||
|
||||
typedef struct tagIS1Information
|
||||
{
|
||||
QString qstrSN_ATP;
|
||||
QString qstrSN_IRIS;
|
||||
|
||||
QString qstrCalFile_U0;
|
||||
QString qstrCalFile_D1;
|
||||
QString qstrCalFile_D2;
|
||||
QString qstrCalFile_D3;
|
||||
|
||||
int iPixelCount;
|
||||
|
||||
int iExposureTimeInMS_U0;
|
||||
int iExposureTimeInMS_D1;
|
||||
int iExposureTimeInMS_D2;
|
||||
int iExposureTimeInMS_D3;
|
||||
|
||||
float fTemperature_U0;
|
||||
float fTemperature_D1;
|
||||
float fTemperature_D2;
|
||||
float fTemperature_D3;
|
||||
}IS1Info;
|
||||
|
||||
typedef struct tagISIFInformation
|
||||
{
|
||||
QString qstrSN_ATP;
|
||||
QString qstrSN_IRIS;
|
||||
|
||||
QString qstrCalFile_U0;
|
||||
QString qstrCalFile_D1;
|
||||
QString qstrCalFile_D2;
|
||||
QString qstrCalFile_D3;
|
||||
|
||||
int iPixelCount;
|
||||
|
||||
int iExposureTimeInMS_U0;
|
||||
int iExposureTimeInMS_D1;
|
||||
int iExposureTimeInMS_D2;
|
||||
int iExposureTimeInMS_D3;
|
||||
|
||||
float fTemperature_U0;
|
||||
float fTemperature_D1;
|
||||
float fTemperature_D2;
|
||||
float fTemperature_D3;
|
||||
}ISIFInfo;
|
||||
|
||||
typedef struct tagATPDataHeader
|
||||
{
|
||||
|
||||
|
||||
}ATPDataHeader;
|
||||
}
|
||||
|
||||
};
|
||||
16
othersoft/shuttercali/source/LinearShutter/AbstractPort.h
Normal file
16
othersoft/shuttercali/source/LinearShutter/AbstractPort.h
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include "VSMD12XMiscDefines.h"
|
||||
#include <string>
|
||||
class CAbstractPort
|
||||
{
|
||||
public:
|
||||
virtual void InitPort(PortInfo portinfo) = 0;
|
||||
virtual bool SetPort() = 0;
|
||||
virtual bool Open() = 0;
|
||||
virtual void Close() = 0;
|
||||
|
||||
virtual std::string ReadAll(int waite=5000) = 0;
|
||||
virtual int Write(const std::string strSend) = 0;
|
||||
|
||||
};
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user