mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-20 03:49:43 +08:00
修改shuttercali的校验和
This commit is contained in:
@ -12,7 +12,7 @@
|
|||||||
QTextStream cout1(stdout, QIODevice::WriteOnly);
|
QTextStream cout1(stdout, QIODevice::WriteOnly);
|
||||||
void logout(QString str){
|
void logout(QString str){
|
||||||
cout1<<str<<" <br>"<<flush;
|
cout1<<str<<" <br>"<<flush;
|
||||||
|
cout1<<endl;
|
||||||
// std::fflush(stdout);
|
// std::fflush(stdout);
|
||||||
}
|
}
|
||||||
vector<int> FindFeng(vector<int > point1ist, vector<float> valuelist);
|
vector<int> FindFeng(vector<int > point1ist, vector<float> valuelist);
|
||||||
@ -21,9 +21,11 @@ vector <float> PingHua(vector <float> value, int step = 2);
|
|||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
if (argc!=3)
|
if (argc!=4)
|
||||||
{
|
{
|
||||||
logout("Some Thing error Please check the input <br> The Correct Should Be application sensor numberofposition");
|
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: OSIFAlpha QEPRO");
|
||||||
logout("Senor: OSIFBeta QE65");
|
logout("Senor: OSIFBeta QE65");
|
||||||
logout("Senor: ISIF ATP6500");
|
logout("Senor: ISIF ATP6500");
|
||||||
@ -36,6 +38,7 @@ int main(int argc, char* argv[])
|
|||||||
int bandsnumber=1024;
|
int bandsnumber=1024;
|
||||||
QString SensorTypestr(argv[1]);
|
QString SensorTypestr(argv[1]);
|
||||||
QString PositionNumberstr(argv[2]);
|
QString PositionNumberstr(argv[2]);
|
||||||
|
int shuttertime=QString(argv[3]).toInt();
|
||||||
int PositionNumber=PositionNumberstr.toInt();
|
int PositionNumber=PositionNumberstr.toInt();
|
||||||
QCoreApplication aaaaa(argc, argv);
|
QCoreApplication aaaaa(argc, argv);
|
||||||
|
|
||||||
@ -48,17 +51,21 @@ int main(int argc, char* argv[])
|
|||||||
#endif
|
#endif
|
||||||
QSettings *m_qsDeviceConfig;
|
QSettings *m_qsDeviceConfig;
|
||||||
m_qsDeviceConfig = new QSettings(m_qstrDeviceConfigFilePath, QSettings::IniFormat);
|
m_qsDeviceConfig = new QSettings(m_qstrDeviceConfigFilePath, QSettings::IniFormat);
|
||||||
int numberofsensor=m_qsDeviceConfig->value("[DEVICE INFO]/TotalSpectrometer").toInt();
|
int numberofsensor=m_qsDeviceConfig->value("DEVICE INFO/TotalSpectrometer").toInt();
|
||||||
|
|
||||||
|
|
||||||
logout("Welcom to use the Auto Locate Application");
|
logout("Welcom to use the Auto Locate Application");
|
||||||
string hdrPath = "/home/data/test.csv";
|
string hdrPath = "/home/data/test.csv";
|
||||||
std::ofstream outfile(hdrPath.c_str());
|
std::ofstream outfile(hdrPath.c_str());
|
||||||
logout("Init Senser :QE");
|
string hdrPath1 = "/home/data/result.csv";
|
||||||
|
std::ofstream outfile1(hdrPath1.c_str());
|
||||||
|
|
||||||
|
logout("Sensor is "+SensorTypestr);
|
||||||
SensorBase* aa= nullptr;
|
SensorBase* aa= nullptr;
|
||||||
if (SensorTypestr=="OSIFAlpha")
|
if (SensorTypestr=="OSIFAlpha")
|
||||||
{
|
{
|
||||||
aa = new SensorQExPRO(QE65PRO_QE);
|
aa = new SensorQExPRO(QE65PRO_QE);
|
||||||
|
|
||||||
} else if (SensorTypestr=="OSIFBeta")
|
} else if (SensorTypestr=="OSIFBeta")
|
||||||
{
|
{
|
||||||
aa = new SensorQExPRO(QE65PRO_QE);
|
aa = new SensorQExPRO(QE65PRO_QE);
|
||||||
@ -69,6 +76,7 @@ int main(int argc, char* argv[])
|
|||||||
QString portname="";
|
QString portname="";
|
||||||
for (int i = 0; i < numberofsensor; ++i) {
|
for (int i = 0; i < numberofsensor; ++i) {
|
||||||
QString key="FS"+QString::number(i+1)+"/Model";
|
QString key="FS"+QString::number(i+1)+"/Model";
|
||||||
|
qDebug()<<key;
|
||||||
if (m_qsDeviceConfig->value(key).toString()==SensorTypestr)
|
if (m_qsDeviceConfig->value(key).toString()==SensorTypestr)
|
||||||
{
|
{
|
||||||
QString portstr=m_qsDeviceConfig->value("FS"+QString::number(i+1)+"/Port").toString();
|
QString portstr=m_qsDeviceConfig->value("FS"+QString::number(i+1)+"/Port").toString();
|
||||||
@ -76,11 +84,14 @@ int main(int argc, char* argv[])
|
|||||||
portname=strlist.at(strlist.length()-1);
|
portname=strlist.at(strlist.length()-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// qDebug()<<portname;
|
||||||
|
|
||||||
if (portname=="")
|
if (portname=="")
|
||||||
{
|
{
|
||||||
logout("Can not find the sensor"+SensorTypestr);
|
logout("<b style=\"color:red\">Can not find the sensor"+SensorTypestr+"<\/b>");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
logout("Sensor Port is "+portname);
|
||||||
aa=new SensorOptoSky(ATP6500,portname);
|
aa=new SensorOptoSky(ATP6500,portname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,25 +100,43 @@ int main(int argc, char* argv[])
|
|||||||
//SensorBase* aa = new SensorOptoSky(ATP6500,"ttyUSB0");
|
//SensorBase* aa = new SensorOptoSky(ATP6500,"ttyUSB0");
|
||||||
|
|
||||||
aa->initSensor();
|
aa->initSensor();
|
||||||
|
STRSensorInfo info= aa->SensorInfo;
|
||||||
cout1<<"Get Tempratrue:"<<aa->GettingTempratrue()<<"<br>"<<flush;
|
int bandsshow=info.BandNum/2;
|
||||||
|
logout("Sensor Bands to Show is "+QString::number(bandsshow));
|
||||||
STROnePlot oneplot;
|
STROnePlot oneplot;
|
||||||
aa->Settingshuttertime(20);
|
|
||||||
aa->GetOnePlot(oneplot);
|
|
||||||
cout1<<"Position"<< oneplot.Plot[1000];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CVSMD12XControl Motercontrol;
|
CVSMD12XControl Motercontrol;
|
||||||
Motercontrol.ILMES_InitializeComm("COM16");
|
//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;
|
||||||
|
}
|
||||||
|
|
||||||
//Motercontrol.ILMES_InitializeComm("/dev/ttyUSB1");
|
logout("The max Postion is "+QString::number(550000/4*PositionNumber));
|
||||||
ControllerParams cpTest;
|
ControllerParams cpTest;
|
||||||
bool res = Motercontrol.ILMES_InitializeParams(cpTest);
|
bool res = Motercontrol.ILMES_InitializeParams(cpTest);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
aa->Settingshuttertime(shuttertime);
|
||||||
|
aa->GetOnePlot(oneplot);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
logout("GO TO ZERO");
|
||||||
Motercontrol.StartBackZero();
|
Motercontrol.StartBackZero();
|
||||||
Motercontrol.SetRunSpeed(10000);
|
Motercontrol.SetRunSpeed(10000);
|
||||||
Motercontrol.MoveTo_NoSyn(550000);
|
logout("GO TO ZERO OK");
|
||||||
|
logout("Start Moving to "+QString::number(550000/4*PositionNumber));
|
||||||
|
Motercontrol.MoveTo_NoSyn(550000/4*PositionNumber);
|
||||||
aa->GetOnePlot(oneplot);
|
aa->GetOnePlot(oneplot);
|
||||||
MSInfo temp;
|
MSInfo temp;
|
||||||
Motercontrol.GetStatus(temp);
|
Motercontrol.GetStatus(temp);
|
||||||
@ -118,7 +147,7 @@ int main(int argc, char* argv[])
|
|||||||
//outfile <<i<<"," << oneplot.Plot[1024] << "," << temp.iPosition << std::endl;
|
//outfile <<i<<"," << oneplot.Plot[1024] << "," << temp.iPosition << std::endl;
|
||||||
|
|
||||||
point1ist.push_back(temp.iPosition);
|
point1ist.push_back(temp.iPosition);
|
||||||
valuelist.push_back(oneplot.Plot[1024]);
|
valuelist.push_back(oneplot.Plot[bandsshow]);
|
||||||
while (temp.fVelocity!=0)
|
while (temp.fVelocity!=0)
|
||||||
{
|
{
|
||||||
aa->GetOnePlot(oneplot);
|
aa->GetOnePlot(oneplot);
|
||||||
@ -127,38 +156,54 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
Motercontrol.GetStatus(temp);
|
Motercontrol.GetStatus(temp);
|
||||||
i++;
|
i++;
|
||||||
//outfile << i << "," << oneplot.Plot[1024] << "," << temp.iPosition << std::endl;
|
outfile << i << "," << oneplot.Plot[bandsshow] << "," << temp.iPosition << std::endl;
|
||||||
point1ist.push_back(temp.iPosition);
|
point1ist.push_back(temp.iPosition);
|
||||||
valuelist.push_back(oneplot.Plot[1024]);
|
valuelist.push_back(oneplot.Plot[bandsshow]);
|
||||||
|
|
||||||
}
|
}
|
||||||
Motercontrol.StartBackZero();
|
logout("FINISH Moving");
|
||||||
vector<float> valuepinghua1 = PingHua(valuelist, 3);
|
vector<float> valuepinghua1 = PingHua(valuelist, 3);
|
||||||
vector<int>loction1=FindFeng(point1ist, valuepinghua1);
|
vector<int>loction1=FindFeng(point1ist, valuepinghua1);
|
||||||
|
|
||||||
int lenth = loction1.size();
|
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++)
|
for (size_t i = 0; i < lenth; i++)
|
||||||
{
|
{
|
||||||
vector<int> location1point = DengJianJu(loction1[i], 5000, 25);
|
vector<int> location1point = DengJianJu(loction1[i], 5000, 25);
|
||||||
vector<float> valuepoint;
|
vector<float> valuepoint;
|
||||||
int lennow = location1point.size();
|
int lennow = location1point.size();
|
||||||
|
cout1<<"Detail find "<<i<<"point begin"<<"<br>"<<flush;
|
||||||
for (size_t ii = 0; ii < lennow; ii++)
|
for (size_t ii = 0; ii < lennow; ii++)
|
||||||
{
|
{
|
||||||
|
|
||||||
Motercontrol.MoveTo(location1point[ii]);
|
Motercontrol.MoveTo(location1point[ii]);
|
||||||
aa->GetOnePlot(oneplot);
|
aa->GetOnePlot(oneplot);
|
||||||
valuepoint.push_back(oneplot.Plot[1024]);
|
valuepoint.push_back(oneplot.Plot[bandsshow]);
|
||||||
//outfile << ii << "," << oneplot.Plot[1024] << "," << location1point[ii] << std::endl;
|
//outfile << ii << "," << oneplot.Plot[1024] << "," << location1point[ii] << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
vector<float> valuepinghua = PingHua(valuepoint,3);
|
vector<float> valuepinghua = PingHua(valuepoint,3);
|
||||||
vector<int>loction2 = FindFeng(location1point, valuepinghua);
|
vector<int>loction2 = FindFeng(location1point, valuepinghua);
|
||||||
|
|
||||||
if (loction2.size() == 1)
|
if (loction2.size() == 1)
|
||||||
{
|
{ cout1<<"find "<<i<<"point value is"<<loction2[0]<<"<br>"<<flush;
|
||||||
outfile <<i+1<<"," << loction2[0]<< std::endl;
|
outfile1 <<i+1<<"," << loction2[0]<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cc = 10;
|
int cc = 10;
|
||||||
cc++;
|
cc++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
logout("FINISH Moving");
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -172,11 +217,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
|
|
||||||
std::cout<<"totle:" << i;
|
std::cout<<"totle:" << i;
|
||||||
//Motercontrol.MoveTo(870000);
|
outfile.close();
|
||||||
//Motercontrol.MoveTo(570000);
|
|
||||||
//Motercontrol.MoveTo(870000);
|
|
||||||
//Motercontrol.MoveTo(900000);
|
|
||||||
//Motercontrol.MoveTo(1270000);
|
|
||||||
outfile.close();
|
outfile.close();
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
|
@ -97,7 +97,7 @@ lable1:
|
|||||||
QByteArray tempbuf = optoskyserial->readAll();
|
QByteArray tempbuf = optoskyserial->readAll();
|
||||||
data.append(tempbuf);
|
data.append(tempbuf);
|
||||||
|
|
||||||
if (time.elapsed() > 50000)
|
if (time.elapsed() > 10000)
|
||||||
{
|
{
|
||||||
logout::out("long time no data retrun ");
|
logout::out("long time no data retrun ");
|
||||||
return false;
|
return false;
|
||||||
@ -140,8 +140,8 @@ lable1:
|
|||||||
if (checknum != (unsigned char)data[data.size() - 1])
|
if (checknum != (unsigned char)data[data.size() - 1])
|
||||||
{
|
{
|
||||||
logout::out("checkerro " );
|
logout::out("checkerro " );
|
||||||
data.clear();
|
//data.clear();
|
||||||
return false;
|
//return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ bool OptoSky::GetReturn(QByteArray id, QByteArray &data)
|
|||||||
if (data[4]!=id[0])
|
if (data[4]!=id[0])
|
||||||
{
|
{
|
||||||
logout::out("retrun is not correct with ComId:" + QString::number(id[0], 16));
|
logout::out("retrun is not correct with ComId:" + QString::number(id[0], 16));
|
||||||
return false;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD><EFBFBD><EFBFBD>
|
return false;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><D8B2><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ش<F2B7B5BB><D8B4><EFBFBD>
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveHeaderandEnd(data);
|
RemoveHeaderandEnd(data);
|
||||||
|
@ -79,6 +79,7 @@ void SensorOptoSky::SettingTemprature(float temp)
|
|||||||
|
|
||||||
float SensorOptoSky::GettingTempratrue()
|
float SensorOptoSky::GettingTempratrue()
|
||||||
{
|
{
|
||||||
|
return 0.0;
|
||||||
if (!OptoSky::isSensorInit())
|
if (!OptoSky::isSensorInit())
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user