TCP / IP接続を使用してスキャンデバイスに接続しているコンソールアプリケーションに次のコードがあり、接続が確立された後、スキャン測定値を継続的に取得していますが、ユーザーはいつでも測定を停止する必要があります。
コンソールアプリケーション自体でそれを実行することを考えています。これにはスレッドを使用する必要がありますか?スキャンの進行中にユーザーが停止した場合は、特定のスキャンを終了し、その後終了します(ロックなど)。c++とc ++/cliを学習しているだけです。何か提案があれば役に立ちます。ありがとうございます。
if (sopas.GetScanData(soScan) == true)
{
printf("Continuous Scanning Measurement \n");
processcounter = ProcessScan(soScan,processcounter,gp,Background);
}
プロセススキャンのこのスケルトンは
unsigned int ProcessScan(const SLms100Scan& soScan,int iProcessedScanCount,FILE* gp,vector <double> &Background)
{
static unsigned int ulDeg90_index = 0; // Calculated during init phase
static unsigned int ulProcessedScanCounter = 0;
int iDataCount = soScan.aDataChannel16.aFlexArrayData[0].aData.uiFlexArrayLength;
int datalength = soScan.aDataChannel16.aFlexArrayData[0].aData.uiFlexArrayLength;
vector <double> afXvalue(datalength);
vector <double> afYvalue(datalength);
pair<double,double> coord(int a,int b);
vector< pair<double,double>> coordinates;
int aiDataReal[80];
int count;
//Finding the blobs
// Write hex values of data in to the file
int success = 0;
writefile(fname,soScan,success);
if (success != 0)
{
printf("Error in printing the file");
}
blobdetector(soScan, iProcessedScanCount,Background,coordinates);
// Read the hex value for XY co-ordinate calculation
//readfile(fname,aiDataReal,idx,success);
if (success == -1)
printf("Error in reading the file");
//calculation of Polar Coardinates to XY values
findXY(soScan,afXvalue,afYvalue);
//writing the XY values to the file
writefile( wfname_XY,iDataCount,afXvalue,afYvalue,success);
if (success == -1)
printf("Error in printing the file");
plotdata(afXvalue,afYvalue,coordinates,gp,iProcessedScanCount);
if (!coordinates.empty())
{
//sendcoordinates(soScan,coordinates);
writefile( "coordinates",soScan,coordinates);
coordinates.clear();
}
iProcessedScanCount++;
return iProcessedScanCount;
}