I have this code in a console application where I use TCP / IP connection to connect to the scanning device I'm having connection established, I am constantly receiving scan measurements. But I need the user to stop the measurement at any point.
I'm thinking of getting it into a console application. Do I need to use threading for this? If users stop scanning when it is turned on, then I want to scan specifically and then exit (like the locks). I am just learning C ++ and C ++ / CLI .. Any suggestions will be helpful .. Thanks
if (sopas.GetScanData (soScan) == true) {printf ("continuous Scanning measurements \ n "); Processcounter = ProcessScan (Sosain, Proceconda, GP, Background); } This skeleton of the process scan
unsigned int ProcessScan (const SLms100Scan & soScan, int iProcessedScanCount, FILE * gp, vector & lt; double & gt; ; Amp; background) {static unsigned int ulDeg90_index = 0; // calculates static unsigned int ulProcessedScanCounter = 0 during the init phase; Int iDataCount = soScan.aDataChannel16.aFlexArrayData [0] .aData.uiFlexArrayLength; Int Diatambeel = Soscan.AdataChinaile 16.FlexAreredata [0]. Adata.uifxarelanthe; Vector & lt; Double & gt; AfXvalue (datalength); Vector & lt; Double & gt; AfYvalue (datalength); Pair of & lt; Double, double & gt; Coordination (int a, int b); Of vector & lt; Pair of & lt ;, double double & gt; & Gt; Coordinates; Int adidial [80]; integer number; Finding // blobs // Write hex values in data file int in success = 0; WriteFile (fname, soScan, success); If (success! = 0) {printf ("error in file printing"); } Blobdetector (soScan, iProcessedScanCount, Background, Coordinate); // Read XXYY co-calculation / read hex value for readfile (fname, aiDataReal, idx, success); If (success == -1) printf ("Error reading file"); // Calculation of Polar Cordinates XY ValuexAC (Soscan, FxValu, FAQ); // Writing XY values for writing files (wfname_XY, iDataCount, afXvalue, afYvalue, success); If (success == -1) printf ("error in printing file"); Plotdata (afXvalue, afYvalue, coordinates, gp, iProcessedScanCount); If (! Coordinate. Exemption ()) {// sendcordinates (soscan, coordinates); Writing file ("coordinate", soscan, coordinates); Coordinates.clear (); } IProcessedScanCount ++; Icrocasdance scan return; }
An easy way to use (on windows) and then If you do not block the ending, definitely do your job in case of CTRL_CLOSE_EVENT , you only have limited time on Win7 / Vista. You can use different mechanisms to signal your main program to complete your work. In my case I used the global variable in the main file, passed in the context of my internal loop and used it as a loop ending state. But it can also be obtained with other methods ( condition_variable , ...)
Comments
Post a Comment