mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-19 03:49:42 +08:00
添加了位置定标程序 及位置移动相关程序源码
This commit is contained in:
46
othersoft/shuttercali/project/LocationCali/CMakeLists.txt
Normal file
46
othersoft/shuttercali/project/LocationCali/CMakeLists.txt
Normal file
@ -0,0 +1,46 @@
|
||||
cmake_minimum_required(VERSION 3.3)
|
||||
|
||||
project(shutter_calibrate)
|
||||
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} C:/Qt/Qt5.12.7/5.12.7/mingw73_64)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(QT Core Gui Network WebSockets SerialPort Widgets)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
find_package(Qt5 REQUIRED ${QT})
|
||||
|
||||
|
||||
file(GLOB_RECURSE HDR_LIST "../../source/*.h")
|
||||
file(GLOB_RECURSE SRC_LIST "../../source/*.cpp")
|
||||
file(GLOB_RECURSE HDR_LIST1 "../../source_rlx/*.h")
|
||||
file(GLOB_RECURSE SRC_LIST1 "../../source_rlx/*.cpp")
|
||||
|
||||
include_directories("../../source")
|
||||
include_directories("../../source/FS")
|
||||
include_directories("../../source/Logger")
|
||||
include_directories("../../source/ZZ_SDK")
|
||||
include_directories("../../source/Settings")
|
||||
include_directories("../../source/Thread")
|
||||
include_directories("../../source/LinearShutter")
|
||||
include_directories("../../source_rlx/ShutterCali")
|
||||
include_directories("../../source_rlx/sensor")
|
||||
include_directories("../../source/OSIF/include")
|
||||
include_directories("D:/02Raspberry/2020-12-17/SeaBreeze/include")
|
||||
link_directories("D:/02Raspberry/2020-12-17/SeaBreeze/lib")
|
||||
link_directories("/home/pi/SeaBrease/lib")
|
||||
add_executable( shutter_calibrate main.cpp
|
||||
${HDR_LIST}
|
||||
${SRC_LIST}
|
||||
${HDR_LIST1}
|
||||
${SRC_LIST1}
|
||||
)
|
||||
qt5_use_modules(shutter_calibrate ${QT})
|
||||
target_link_libraries(shutter_calibrate SeaBreeze)
|
||||
IF (WIN32)
|
||||
target_link_libraries(shutter_calibrate SeaBreeze)
|
||||
ELSE ()
|
||||
target_link_libraries(shutter_calibrate seabreeze usb stdc++ m)
|
||||
ENDIF ()
|
||||
set_target_properties(shutter_calibrate PROPERTIES AUTOMOC ON)
|
||||
|
||||
|
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.
202
othersoft/shuttercali/project/LocationCali/main.cpp
Normal file
202
othersoft/shuttercali/project/LocationCali/main.cpp
Normal file
@ -0,0 +1,202 @@
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include<VSMD12XControl.h>
|
||||
#include "QTextCodec"
|
||||
#include "SensorMannager.h"
|
||||
#include"SensorOptoSky.h"
|
||||
#include"SensorQExPRO.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <QTextstream>
|
||||
QTextStream cout1(stdout, QIODevice::WriteOnly);
|
||||
void logout(QString str){
|
||||
std::cout<<str.toStdString()<<"<br>";
|
||||
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[])
|
||||
{
|
||||
QCoreApplication aaaaa(argc, argv);
|
||||
cout1<<"Welcom to use the Auto Locate Application"<<"<br>"<<flush;
|
||||
string hdrPath = "/home/data/test.csv";
|
||||
std::ofstream outfile(hdrPath.c_str());
|
||||
logout("Init Senser :QE");
|
||||
SensorBase* aa = new SensorQExPRO(QE65PRO_QE);
|
||||
//SensorBase* aa = new SensorOptoSky(ATP6500,"ttyUSB0");
|
||||
|
||||
aa->initSensor();
|
||||
|
||||
cout1<<"Get Tempratrue:"<<aa->GettingTempratrue()<<"<br>"<<flush;
|
||||
STROnePlot oneplot;
|
||||
aa->Settingshuttertime(20);
|
||||
aa->GetOnePlot(oneplot);
|
||||
cout1<<"Position"<< oneplot.Plot[1000];
|
||||
|
||||
|
||||
|
||||
|
||||
CVSMD12XControl Motercontrol;
|
||||
Motercontrol.ILMES_InitializeComm("COM16");
|
||||
|
||||
//Motercontrol.ILMES_InitializeComm("/dev/ttyUSB1");
|
||||
ControllerParams cpTest;
|
||||
bool res = Motercontrol.ILMES_InitializeParams(cpTest);
|
||||
Motercontrol.StartBackZero();
|
||||
Motercontrol.SetRunSpeed(10000);
|
||||
Motercontrol.MoveTo_NoSyn(550000);
|
||||
aa->GetOnePlot(oneplot);
|
||||
MSInfo temp;
|
||||
Motercontrol.GetStatus(temp);
|
||||
vector<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[1024]);
|
||||
while (temp.fVelocity!=0)
|
||||
{
|
||||
aa->GetOnePlot(oneplot);
|
||||
//qDebug() << oneplot.BandNum;
|
||||
//std::cout << temp.iPosition << std::endl;
|
||||
|
||||
Motercontrol.GetStatus(temp);
|
||||
i++;
|
||||
//outfile << i << "," << oneplot.Plot[1024] << "," << temp.iPosition << std::endl;
|
||||
point1ist.push_back(temp.iPosition);
|
||||
valuelist.push_back(oneplot.Plot[1024]);
|
||||
|
||||
}
|
||||
Motercontrol.StartBackZero();
|
||||
vector<float> valuepinghua1 = PingHua(valuelist, 3);
|
||||
vector<int>loction1=FindFeng(point1ist, valuepinghua1);
|
||||
int lenth = loction1.size();
|
||||
for (size_t i = 0; i < lenth; i++)
|
||||
{
|
||||
vector<int> location1point = DengJianJu(loction1[i], 5000, 25);
|
||||
vector<float> valuepoint;
|
||||
int lennow = location1point.size();
|
||||
for (size_t ii = 0; ii < lennow; ii++)
|
||||
{
|
||||
Motercontrol.MoveTo(location1point[ii]);
|
||||
aa->GetOnePlot(oneplot);
|
||||
valuepoint.push_back(oneplot.Plot[1024]);
|
||||
//outfile << ii << "," << oneplot.Plot[1024] << "," << location1point[ii] << std::endl;
|
||||
}
|
||||
vector<float> valuepinghua = PingHua(valuepoint,3);
|
||||
vector<int>loction2 = FindFeng(location1point, valuepinghua);
|
||||
if (loction2.size() == 1)
|
||||
{
|
||||
outfile <<i+1<<"," << loction2[0]<< std::endl;
|
||||
}
|
||||
|
||||
int cc = 10;
|
||||
cc++;
|
||||
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
std::cout<<"totle:" << i;
|
||||
//Motercontrol.MoveTo(870000);
|
||||
//Motercontrol.MoveTo(570000);
|
||||
//Motercontrol.MoveTo(870000);
|
||||
//Motercontrol.MoveTo(900000);
|
||||
//Motercontrol.MoveTo(1270000);
|
||||
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;
|
||||
}
|
Reference in New Issue
Block a user