mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-18 19:39:43 +08:00
修改shuttercali的校验和
This commit is contained in:
@ -11,8 +11,8 @@
|
||||
|
||||
QTextStream cout1(stdout, QIODevice::WriteOnly);
|
||||
void logout(QString str){
|
||||
cout1<<str<<"<br>"<<flush;
|
||||
|
||||
cout1<<str<<" <br>"<<flush;
|
||||
cout1<<endl;
|
||||
// std::fflush(stdout);
|
||||
}
|
||||
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[])
|
||||
{
|
||||
|
||||
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: OSIFBeta QE65");
|
||||
logout("Senor: ISIF ATP6500");
|
||||
@ -36,6 +38,7 @@ int main(int argc, char* argv[])
|
||||
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);
|
||||
|
||||
@ -48,17 +51,21 @@ int main(int argc, char* argv[])
|
||||
#endif
|
||||
QSettings *m_qsDeviceConfig;
|
||||
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");
|
||||
string hdrPath = "/home/data/test.csv";
|
||||
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;
|
||||
if (SensorTypestr=="OSIFAlpha")
|
||||
{
|
||||
aa = new SensorQExPRO(QE65PRO_QE);
|
||||
|
||||
} else if (SensorTypestr=="OSIFBeta")
|
||||
{
|
||||
aa = new SensorQExPRO(QE65PRO_QE);
|
||||
@ -69,6 +76,7 @@ int main(int argc, char* argv[])
|
||||
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();
|
||||
@ -76,11 +84,14 @@ int main(int argc, char* argv[])
|
||||
portname=strlist.at(strlist.length()-1);
|
||||
}
|
||||
}
|
||||
// qDebug()<<portname;
|
||||
|
||||
if (portname=="")
|
||||
{
|
||||
logout("Can not find the sensor"+SensorTypestr);
|
||||
logout("<b style=\"color:red\">Can not find the sensor"+SensorTypestr+"<\/b>");
|
||||
return 1;
|
||||
}
|
||||
logout("Sensor Port is "+portname);
|
||||
aa=new SensorOptoSky(ATP6500,portname);
|
||||
}
|
||||
|
||||
@ -89,25 +100,43 @@ int main(int argc, char* argv[])
|
||||
//SensorBase* aa = new SensorOptoSky(ATP6500,"ttyUSB0");
|
||||
|
||||
aa->initSensor();
|
||||
|
||||
cout1<<"Get Tempratrue:"<<aa->GettingTempratrue()<<"<br>"<<flush;
|
||||
STRSensorInfo info= aa->SensorInfo;
|
||||
int bandsshow=info.BandNum/2;
|
||||
logout("Sensor Bands to Show is "+QString::number(bandsshow));
|
||||
STROnePlot oneplot;
|
||||
aa->Settingshuttertime(20);
|
||||
aa->GetOnePlot(oneplot);
|
||||
cout1<<"Position"<< oneplot.Plot[1000];
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
||||
|
||||
CVSMD12XControl Motercontrol;
|
||||
Motercontrol.ILMES_InitializeComm("COM16");
|
||||
|
||||
//Motercontrol.ILMES_InitializeComm("/dev/ttyUSB1");
|
||||
ControllerParams cpTest;
|
||||
bool res = Motercontrol.ILMES_InitializeParams(cpTest);
|
||||
aa->Settingshuttertime(shuttertime);
|
||||
aa->GetOnePlot(oneplot);
|
||||
|
||||
|
||||
|
||||
|
||||
logout("GO TO ZERO");
|
||||
Motercontrol.StartBackZero();
|
||||
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);
|
||||
MSInfo temp;
|
||||
Motercontrol.GetStatus(temp);
|
||||
@ -118,7 +147,7 @@ int main(int argc, char* argv[])
|
||||
//outfile <<i<<"," << oneplot.Plot[1024] << "," << temp.iPosition << std::endl;
|
||||
|
||||
point1ist.push_back(temp.iPosition);
|
||||
valuelist.push_back(oneplot.Plot[1024]);
|
||||
valuelist.push_back(oneplot.Plot[bandsshow]);
|
||||
while (temp.fVelocity!=0)
|
||||
{
|
||||
aa->GetOnePlot(oneplot);
|
||||
@ -127,38 +156,54 @@ int main(int argc, char* argv[])
|
||||
|
||||
Motercontrol.GetStatus(temp);
|
||||
i++;
|
||||
//outfile << i << "," << oneplot.Plot[1024] << "," << temp.iPosition << std::endl;
|
||||
outfile << i << "," << oneplot.Plot[bandsshow] << "," << temp.iPosition << std::endl;
|
||||
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<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[1024]);
|
||||
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)
|
||||
{
|
||||
outfile <<i+1<<"," << loction2[0]<< std::endl;
|
||||
{ cout1<<"find "<<i<<"point value is"<<loction2[0]<<"<br>"<<flush;
|
||||
outfile1 <<i+1<<"," << loction2[0]<< std::endl;
|
||||
}
|
||||
|
||||
int cc = 10;
|
||||
cc++;
|
||||
|
||||
}
|
||||
logout("FINISH Moving");
|
||||
|
||||
;
|
||||
|
||||
@ -172,12 +217,8 @@ int main(int argc, char* argv[])
|
||||
|
||||
|
||||
std::cout<<"totle:" << i;
|
||||
//Motercontrol.MoveTo(870000);
|
||||
//Motercontrol.MoveTo(570000);
|
||||
//Motercontrol.MoveTo(870000);
|
||||
//Motercontrol.MoveTo(900000);
|
||||
//Motercontrol.MoveTo(1270000);
|
||||
outfile.close();
|
||||
outfile.close();
|
||||
if (!res)
|
||||
{
|
||||
return 0;
|
||||
|
@ -97,7 +97,7 @@ lable1:
|
||||
QByteArray tempbuf = optoskyserial->readAll();
|
||||
data.append(tempbuf);
|
||||
|
||||
if (time.elapsed() > 50000)
|
||||
if (time.elapsed() > 10000)
|
||||
{
|
||||
logout::out("long time no data retrun ");
|
||||
return false;
|
||||
@ -140,8 +140,8 @@ lable1:
|
||||
if (checknum != (unsigned char)data[data.size() - 1])
|
||||
{
|
||||
logout::out("checkerro " );
|
||||
data.clear();
|
||||
return false;
|
||||
//data.clear();
|
||||
//return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -157,7 +157,7 @@ bool OptoSky::GetReturn(QByteArray id, QByteArray &data)
|
||||
if (data[4]!=id[0])
|
||||
{
|
||||
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);
|
||||
|
@ -79,6 +79,7 @@ void SensorOptoSky::SettingTemprature(float temp)
|
||||
|
||||
float SensorOptoSky::GettingTempratrue()
|
||||
{
|
||||
return 0.0;
|
||||
if (!OptoSky::isSensorInit())
|
||||
{
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user