CSmplMeasure.cs 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using OTSModelSharp.ServiceCenter;
  5. using static OTSDataType.otsdataconst;
  6. using OTSDataType;
  7. using System.Drawing;
  8. using System.Threading;
  9. using OTSCLRINTERFACE;
  10. using OTSMeasureApp._0_OTSModel.OTSDataType;
  11. using System.Windows.Forms;
  12. using System.Data;
  13. using System.IO;
  14. using OTSMeasureApp._1_OTSMeasure.Measure._3_MeasureFlow;
  15. namespace OTSModelSharp
  16. {
  17. using CHoleBSEImgsList = List<CHoleBSEImg>;
  18. public class CSmplMeasure
  19. {
  20. protected static NLog.Logger log ;
  21. protected bool bSaveThreadWorking;
  22. protected System.Threading.Thread m_thread_ptr;
  23. protected COTSSample m_Sample;
  24. protected COTSSample m_HolePreviewSample;
  25. protected CMeasure m_pMsrThread;
  26. string m_strWorkingFolder;
  27. protected CSmplMsrResult m_pSampleRstFile;
  28. CHoleBSEImgsList m_listHoleBSEImg;
  29. protected ISemController m_SemHardwareMgr;
  30. protected IScanController m_ScanHardwareMgr;
  31. protected IEDSController m_EDSController;
  32. protected Queue<COTSField> fieldQueue=new Queue<COTSField>();
  33. protected IClassifyEngine m_classifyEngine;
  34. public CSmplMeasure( string a_strWorkingFolder, COTSSample a_pSample)
  35. {
  36. m_Sample = a_pSample;
  37. log = NLog.LogManager.GetCurrentClassLogger();
  38. var expC = m_Sample.GetMsrParams().GetXRayParam().GetAnalyExpCount();
  39. var imgwidth = m_Sample.GetMsrParams().GetImageScanParam().GetImageResolutionSize().cx;
  40. var imgheight = m_Sample.GetMsrParams().GetImageScanParam().GetImageResolutionSize().cy;
  41. m_strWorkingFolder = a_strWorkingFolder;
  42. m_pSampleRstFile = new CSmplMsrResult( a_strWorkingFolder, a_pSample);
  43. m_SemHardwareMgr = SemController.GetSEMController();
  44. m_ScanHardwareMgr = ScanController.GetScanController();
  45. m_EDSController = EDSController.GetEDSController(imgwidth,imgheight,expC);
  46. m_listHoleBSEImg = new CHoleBSEImgsList();
  47. m_Sample = a_pSample;
  48. }
  49. public void SetSample(COTSSample a_pSample)
  50. {
  51. m_Sample = a_pSample;
  52. m_pSampleRstFile.SetSample(a_pSample);
  53. }
  54. public COTSSample GetSample() { return m_Sample; }
  55. public void SetHolePreviewSample(COTSSample a_pSample)
  56. {
  57. m_HolePreviewSample = a_pSample;
  58. }
  59. public COTSSample GetHolePreviewSample() { return m_HolePreviewSample; }
  60. public void SetMsrThread(CMeasure mt)
  61. {
  62. m_pMsrThread = mt;
  63. }
  64. bool SetSEMDataMrs(COTSSample sample)
  65. {
  66. var pSEMDataMsr = sample.GetSEMDataMsr();
  67. double dMag = pSEMDataMsr.GetMagnification();
  68. double dWorkDis = pSEMDataMsr.GetWorkingDistance();
  69. var pSEMCtrl = m_pMsrThread.GetSEMController();
  70. pSEMCtrl.SetMagnification(dMag);
  71. pSEMCtrl.SetWorkingDistance(dWorkDis);
  72. return true;
  73. }
  74. bool SetSEMExteralOn()
  75. {
  76. var pSEMCtrl = m_SemHardwareMgr;
  77. log.Warn("Set Scan Exteral on!");
  78. pSEMCtrl.SetScanExternal(true);
  79. return true;
  80. }
  81. // set SEM external off
  82. bool SetSEMExteralOff()
  83. {
  84. var pSEMCtrlPtr = m_SemHardwareMgr;
  85. log.Warn("Set SEM Exteral Off!");
  86. pSEMCtrlPtr.SetScanExternal(false);
  87. return true;
  88. }
  89. bool SetBSEParam()
  90. {
  91. // get scan controller
  92. var pScanController = m_ScanHardwareMgr;
  93. // scan parameters
  94. var pMsrParam = m_Sample.GetMsrParams();
  95. var pImgScanParam = pMsrParam.GetImageScanParam();
  96. // get image size
  97. var nImageSizeId = pImgScanParam.GetImageResulotion();
  98. int nResulotionId = RESOLUTION_ID_FIRST_TIE + (int)nImageSizeId;
  99. Size sizePixelImage = RESOLUTION_VALUE[nResulotionId];
  100. // get dwell time
  101. OTS_IMAGE_SCANSPEED_OPTIONS nDwellTime = pImgScanParam.GetScanImageSpeed();
  102. // convert dwell time to bruker dwell time
  103. int nBrukerDwellTimeId;
  104. switch (nDwellTime)
  105. {
  106. case OTS_IMAGE_SCANSPEED_OPTIONS.low:
  107. nBrukerDwellTimeId = 1;
  108. break;
  109. case OTS_IMAGE_SCANSPEED_OPTIONS.meddium:
  110. nBrukerDwellTimeId = 2;
  111. break;
  112. case OTS_IMAGE_SCANSPEED_OPTIONS.high:
  113. nBrukerDwellTimeId = 3;
  114. break;
  115. default:
  116. nBrukerDwellTimeId = 1;
  117. break;
  118. }
  119. long nBrukerDwellTime = OTSDataType.otsdataconst.DWELLTIME_BRUKER_VALUES[nBrukerDwellTimeId];
  120. if (!pScanController.Init())
  121. {
  122. log.Error("SetBSEParam: failed to get scan control.");
  123. return false;
  124. }
  125. // set dwell time
  126. if (!pScanController.SetDwellTime(nBrukerDwellTime))
  127. {
  128. log.Error("SetBSEParam: failed to set dwell time (%d) for bruker system.", nBrukerDwellTime);
  129. return false;
  130. }
  131. // set image size
  132. if (!pScanController.SetImageSize(sizePixelImage.Width,sizePixelImage.Height))
  133. {
  134. // failed to set dwell time
  135. log.Error("SetBSEParam: failed to set dwell time (%d).", sizePixelImage.Height);
  136. return false;
  137. }
  138. return true;
  139. }
  140. bool SetHoleBSEParam(COTSSample sample)
  141. {
  142. // get scan controller
  143. var pScanController = m_ScanHardwareMgr;
  144. // scan parameters
  145. var pMsrParam = sample.GetMsrParams();
  146. var pImgScanParam = pMsrParam.GetImageScanParam();
  147. // get image size
  148. var nImageSizeId = pImgScanParam.GetImageResulotion();
  149. int nResulotionId = RESOLUTION_ID_FIRST_TIE + (int)nImageSizeId;
  150. Size sizePixelImage = RESOLUTION_VALUE[nResulotionId];
  151. // get dwell time
  152. OTS_IMAGE_SCANSPEED_OPTIONS nDwellTime = pImgScanParam.GetScanImageSpeed();
  153. // convert dwell time to bruker dwell time
  154. long nBrukerDwellTime = DWELLTIME_BRUKER_VALUES[2];// choose the third option, so the dwell time will be 4 . there's no need to change here. it shoud be a const.
  155. if (!pScanController.Init())
  156. {
  157. log.Error("SetBSEParam: failed to get scan control.");
  158. return false;
  159. }
  160. // set dwell time
  161. if (!pScanController.SetDwellTime(nBrukerDwellTime))
  162. {
  163. log.Error("SetBSEParam: failed to set dwell time (%d) for bruker system.", nBrukerDwellTime);
  164. return false;
  165. }
  166. // set image size
  167. if (!pScanController.SetImageSize(sizePixelImage.Width/2, sizePixelImage.Height/2))
  168. {
  169. // failed to set dwell time
  170. log.Error("SetBSEParam: failed to set ImageSize");
  171. return false;
  172. }
  173. return true;
  174. }
  175. public void SetWorkingFolder(String a_strWorkingFolder)
  176. {
  177. // add "\\" at the string end if it is not "\\"
  178. if (a_strWorkingFolder.PadRight(1)!="\\")
  179. {
  180. a_strWorkingFolder += "\\";
  181. }
  182. m_strWorkingFolder = a_strWorkingFolder + m_Sample.GetName() + "\\";
  183. }
  184. bool CalculateUnMeasuredHoleImgCenters(COTSSample sample, out List<System.Drawing.Point> a_allpieldcenter, out List<System.Drawing.Point> a_listUnMsrFieldCenter)
  185. {
  186. // sample measure parameters
  187. CSampleParam pMsrParam = sample.GetMsrParams();
  188. COTSImgScanPrm poImageScanParam = pMsrParam.GetImageScanParam();
  189. COTSImageProcParam pImgProcParam = pMsrParam.GetImageProcessParam();
  190. CSEMDataMsr poSEMDataMsr = sample.GetSEMDataMsr();
  191. CMsrSampleStatus pStatus = sample.GetMsrStatus();
  192. // measured field centers list
  193. List<System.Drawing.PointF> listCompletedCenter = pStatus.GetCompletedFieldsCenter();
  194. // field centers list manager
  195. CFieldPositionHelper pFieldMgr = new CFieldPositionHelper();
  196. // init field centers list manager
  197. if (!pFieldMgr.Init(sample.GetMsrDomain(), poImageScanParam,0, poSEMDataMsr, listCompletedCenter))
  198. {
  199. log.Error("CalculateFieldsCenters: failed to init field centres list manager.");
  200. a_listUnMsrFieldCenter = new List<System.Drawing.Point>();
  201. a_allpieldcenter = new List<Point>();
  202. return false;
  203. }
  204. // get field centers list
  205. a_listUnMsrFieldCenter = pFieldMgr.GetUnmeasuredFieldCentrePoints();// GetFieldCentrePoints();
  206. a_allpieldcenter = pFieldMgr.GetFieldCentrePoints();
  207. // ok, return TRUE
  208. return true;
  209. }
  210. protected bool IsAborted()
  211. {
  212. return m_pMsrThread.IsMeasureStopped();
  213. }
  214. protected bool IsPaused()
  215. {
  216. var statu = m_pMsrThread.GetMsrThreadStatus();
  217. if (statu.GetStatus() == OTS_MSR_THREAD_STATUS.PAUSED)
  218. {
  219. return true;
  220. }
  221. else
  222. {
  223. return false;
  224. }
  225. }
  226. bool IsSampleOver(COTSImgScanPrm a_pScanParam)
  227. {
  228. string sStopMode = a_pScanParam.GetStopMode();
  229. int nStopField = a_pScanParam.GetStopParamFields();
  230. // completed fields number
  231. CMsrSampleStatus pMsrSampleStatus = m_Sample.GetMsrStatus();
  232. int nCompeltedField = pMsrSampleStatus.GetCompletedFields();
  233. CMsrResultItems pMsrResults = m_Sample.GetMsrResults();
  234. List<CMsrResultItem> listMsrResult = pMsrResults.GetResultItems();
  235. int nNumParticle = 0;
  236. foreach (var pResult in listMsrResult)
  237. {
  238. if (pResult.GetTypeId() > (int)OTS_PARTICLE_TYPE.NOT_IDENTIFIED)//summarize the number of the identified particle in this condition
  239. {
  240. nNumParticle += (int)pResult.GetNumber();
  241. }
  242. }
  243. TimeSpan timeSpan = pMsrSampleStatus.GetUsedTime();
  244. int nDay = timeSpan.Days;
  245. int nHour = timeSpan.Hours;
  246. int nMin = timeSpan.Minutes;
  247. int nSec = timeSpan.Seconds;
  248. int nUsedTime = nSec + nMin * 60 + nHour * 3600 + nDay * 86400;
  249. int NMeasArea = (int)pMsrResults.GetMeasuredArea();
  250. int nParticlAim = a_pScanParam.GetStopParamParticles();
  251. int nMeasTimeAim = a_pScanParam.GetStopParamMeasTime();
  252. int NMeasAreaAim = a_pScanParam.GetStopParamArea()*1000000 ;
  253. bool bRet = false;
  254. string[] str = sStopMode.Replace(" ", "").Split('+');
  255. for(int i=0;i< str.Length;i++)
  256. {
  257. switch (int.Parse(str[i].Split(':')[0])-1)
  258. {
  259. case (int)OTS_MEASURE_STOP_MODE.CoverMode:
  260. // completed fields number
  261. if (nCompeltedField == m_Sample.GetFieldsData().Count)
  262. {
  263. bRet = true;
  264. }
  265. break;
  266. case (int)OTS_MEASURE_STOP_MODE.FieldMode:
  267. if (nCompeltedField >= nStopField)
  268. {
  269. bRet = true;
  270. }
  271. break;
  272. case (int)OTS_MEASURE_STOP_MODE.ParticleMode:
  273. if (nNumParticle >= nParticlAim)
  274. {
  275. bRet = true;
  276. }
  277. break;
  278. case (int)OTS_MEASURE_STOP_MODE.TimeMode:
  279. if (nUsedTime >= nMeasTimeAim)
  280. {
  281. bRet = true;
  282. }
  283. break;
  284. case (int)OTS_MEASURE_STOP_MODE.AreaMode:
  285. if (NMeasArea >= NMeasAreaAim)
  286. {
  287. bRet = true;
  288. }
  289. break;
  290. default:
  291. break;
  292. }
  293. }
  294. return bRet;
  295. }
  296. // move SEM to the point
  297. bool MoveSEMToPoint(System.Drawing.PointF a_poi)
  298. {
  299. // get SEM controller
  300. var pSEMController = m_SemHardwareMgr;
  301. PointF a_SEMpt = new Point();
  302. CSEMStageData a_pCSEMStageData = m_pMsrThread.GetProjResultData().GetSEMStageData();
  303. int hardWareDelay = a_pCSEMStageData.GetHardWareDelay();
  304. if (!a_pCSEMStageData.ConvertOTSToSEMCoord(a_poi, ref a_SEMpt))
  305. {
  306. return false;
  307. }
  308. log.Info("Begin to move SEM stage to OTScoord:" + a_poi.X + "," + a_poi.Y);
  309. log.Info("Begin to move SEM stage to " + a_SEMpt.X + "," + a_SEMpt.Y);
  310. // move SEM to the position (rotation 0)
  311. if (!pSEMController.MoveSEMToPoint(a_SEMpt.X, a_SEMpt.Y))
  312. {
  313. log.Error("MoveSEMToPoint: failed to call MoveSEMToPoint method.");
  314. return false;
  315. }
  316. CSampleParam pMsrParam = m_Sample.GetMsrParams();
  317. if (pMsrParam.SlopParam.IsUsingSlopParam)
  318. {
  319. double wd = pMsrParam.SlopParam.GetWD(a_SEMpt);
  320. double originWd = 0;
  321. pSEMController.GetWorkingDistance(ref originWd);
  322. if ((wd - originWd) > 2)
  323. {
  324. log.Warn("Working Distance is invalid,outof the moving scope(2cm) wd=" + wd.ToString("F2"));
  325. }
  326. else
  327. {
  328. Thread.Sleep(hardWareDelay);
  329. pSEMController.SetWorkingDistance(wd);
  330. }
  331. }
  332. if (hardWareDelay > 0)
  333. {
  334. Thread.Sleep(hardWareDelay);
  335. }
  336. return true;
  337. }
  338. // Acquire a BSE image
  339. CBSEImgClr AcquireABSEImage()
  340. {
  341. // BSE image
  342. CBSEImgClr pBSEImage = null;
  343. // get scan controller
  344. var pScanController = m_ScanHardwareMgr;
  345. pBSEImage = pScanController.AcquireBSEImage();
  346. return pBSEImage;
  347. }
  348. public bool IsLowCounts(COTSParticleClr particle)
  349. {
  350. COTSXRayParam pXRayParam = m_Sample.GetMsrParams().GetXRayParam();
  351. if (pXRayParam.GetUsingXray() == true)
  352. {
  353. var thecount = particle.GetXray().GetTotalCount();
  354. var expect = pXRayParam.GetAnalyExpCount();
  355. if (thecount < expect)
  356. {
  357. particle.SetType((int)OTS_PARTICLE_TYPE.LOW_COUNT);
  358. particle.SetClassifyId((int)OTS_PARTICLE_TYPE.LOW_COUNT);
  359. particle.SetTypeColor("#000000");
  360. particle.SetTypeName("LowCounts");
  361. return true;
  362. }
  363. }
  364. return false;
  365. }
  366. public virtual void ClassifyFieldParticles(COTSField curFldData)
  367. {
  368. return;
  369. }
  370. private class SEMStateObject
  371. {
  372. private PointF pos;
  373. private double workingDistance;
  374. private CSEMDataGnr semdata;
  375. private COTSSample originalSample;
  376. private double magnification;
  377. public PointF Pos { get => pos; set => pos = value; }
  378. public double WorkingDistance { get => workingDistance; set => workingDistance = value; }
  379. public CSEMDataGnr Semdata { get => semdata; set => semdata = value; }
  380. public double Magnification { get => magnification; set => magnification = value; }
  381. public COTSSample OriginalSample { get => originalSample; set => originalSample = value; }
  382. }
  383. private class AutoResetSEMControl:IDisposable
  384. {
  385. CSmplMeasure sm;
  386. private SEMStateObject semState=null;
  387. public AutoResetSEMControl(CSmplMeasure s)
  388. {
  389. sm = s;
  390. }
  391. public SEMStateObject SemState
  392. {
  393. get => semState;
  394. set => semState = value;
  395. }
  396. public void Dispose()
  397. {
  398. if (semState != null)
  399. {
  400. sm.SetBSEParam();
  401. sm.m_SemHardwareMgr.SetMagnification(semState.Magnification);
  402. Thread.Sleep(100);
  403. sm.MoveSEMToPoint(semState.Pos);
  404. Thread.Sleep(100);
  405. sm.m_SemHardwareMgr.SetWorkingDistance(semState.WorkingDistance);
  406. }
  407. sm.SetSEMExteralOff();
  408. }
  409. }
  410. private bool GetSEMDataGnrFromHw(ref CSEMDataGnr SemDataGnr)
  411. {
  412. double kv = 0, brightness = 0, contrast = 0;
  413. var hw = SemController.GetSEMController();
  414. hw.GetSemHighTension(ref kv);
  415. hw.GetSemBrightness(ref brightness);
  416. hw.GetSemContrast(ref contrast);
  417. SemDataGnr.SetValue(kv, brightness, contrast);
  418. return true;
  419. }
  420. public void DoMeasureForOneSample()
  421. {
  422. using (AutoResetSEMControl autoReset = new AutoResetSEMControl(this)) //when this method exit ,the SetSEMExternalOff and ResetScan will be called automatically.
  423. {
  424. // let the main thread to know that this sample measurement starts
  425. var pStatus = m_Sample.GetMsrStatus();
  426. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.INPROCESS);
  427. // set current time to current time
  428. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.START);
  429. // let main App know that the sample begin to measure
  430. ST_MSTMsg MsgSmpStart = new ST_MSTMsg(m_Sample);
  431. MsgSmpStart.InitSampleStartMsg();
  432. m_pMsrThread.SendMessageToMeasureGUI(MsgSmpStart);
  433. log.Info(m_Sample.GetName() + " Measurement started!");
  434. // get SEM controller to set magnification and working distance
  435. if (!SetSEMDataMrs(m_Sample))
  436. {
  437. log.Error("DoMeasure: fail to set SEM data.");
  438. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  439. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  440. return;
  441. }
  442. // set the BSE scan param
  443. if (!SetBSEParam())
  444. {
  445. log.Error("DoMeasure: fail to set BSE param.");
  446. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  447. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  448. return;
  449. }
  450. var pSEMDataGnr = new CSEMDataGnr();
  451. log.Info("Get Kv, Brightness and Contrast!");
  452. GetSEMDataGnrFromHw(ref pSEMDataGnr);
  453. m_pSampleRstFile.SetSEMGnr(pSEMDataGnr);
  454. // record SEM data
  455. COTSMsrPrjResultData pProjMgrFile = m_pMsrThread.GetProjResultData();
  456. CSEMStageData pSEMStageData = pProjMgrFile.GetSEMStageData();
  457. m_pSampleRstFile.SetSEMStageData(pSEMStageData);
  458. // record stage
  459. CStage pStage = pProjMgrFile.GetStage();
  460. m_pSampleRstFile.SetSEMStage(pStage);
  461. //-----save the static measure result file data into xml file and the dynamic data of every field will be saved into sqlite database
  462. log.Info("Create result file!");
  463. if (!m_pSampleRstFile.CreateResultFiles())
  464. {// failed to call measure result file Save method
  465. log.Error("DoMeasure: failed to call measure result file Save method.");
  466. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  467. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  468. return;
  469. }
  470. //------
  471. var FldDatas = m_Sample.GetFieldsData();
  472. for (int i = 0; i < FldDatas.Count; ++i)
  473. {// check and break if stop button is clicked
  474. var curFld = FldDatas[i];
  475. if (curFld.GetIsMeasureComplete())
  476. {
  477. continue;
  478. }
  479. if (IsPaused())
  480. {// measure stopped
  481. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.PAUSED);
  482. // record end time
  483. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  484. //must wait for the saving data thread finished,or we'll get null pointer exception when we stop the measure process.
  485. while (fieldQueue.Count() > 0)
  486. {
  487. Thread.Sleep(100);
  488. }
  489. SetSEMExteralOff();
  490. // update thread measure status class, let the main thread know that this sample measurement stopped
  491. ST_MSTMsg MsgSmpStop = new ST_MSTMsg(m_Sample);
  492. MsgSmpStop.InitSamplePausedMsg();
  493. m_pMsrThread.SendMessageToMeasureGUI(MsgSmpStop);
  494. while (IsPaused())
  495. {
  496. Thread.Sleep(300);
  497. }
  498. }
  499. if (IsAborted())
  500. {// measure stopped
  501. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.STOPPED);
  502. // record end time
  503. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  504. //must wait for the saving data thread finished,or we'll get null pointer exception when we stop the measure process.
  505. while (fieldQueue.Count() > 0)
  506. {
  507. Thread.Sleep(100);
  508. }
  509. break;
  510. }
  511. // check if sample measurement completes
  512. COTSImgScanPrm pScanParam = m_Sample.GetMsrParams().GetImageScanParam();
  513. if (IsSampleOver(pScanParam))
  514. {
  515. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.SUCCESSED);
  516. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.COMPLT);
  517. break;
  518. }
  519. // get a field center
  520. System.Drawing.PointF poiFieldCentre = curFld.GetOTSPosition();
  521. // update thread measure status class, let the main thread know that starts a new field
  522. ST_MSTMsg MsgFieldStart = new ST_MSTMsg(m_Sample,curFld);
  523. MsgFieldStart.InitFieldStartMsg();
  524. m_pMsrThread.SendMessageToMeasureGUI(MsgFieldStart);
  525. int fldNo = curFld.GetId();
  526. log.Warn("Current field:" + fldNo.ToString());
  527. // move SEM to the field center
  528. if (!MoveSEMToPoint(poiFieldCentre))
  529. {// failed to move SEM to the position
  530. log.Error("DoMeasure: failed to move SEM to the field centre point.");
  531. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  532. // record end time
  533. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  534. return;
  535. }
  536. log.Info("Begin to Acquire BSE image!");
  537. // take BSE image for the fields
  538. CBSEImgClr pBSEImg = AcquireABSEImage();
  539. // let the main thread to know that image process is completed
  540. if (pBSEImg == null)
  541. {
  542. log.Error("ImageProcess: can't get BSE image.");
  543. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  544. return;
  545. }
  546. curFld.SetBSEImage(pBSEImg);
  547. //BSEData
  548. ST_MSTMsg MsgFieldBSE = new ST_MSTMsg(m_Sample,curFld);
  549. MsgFieldBSE.InitFieldBSEImageMsg();
  550. m_pMsrThread.SendMessageToMeasureGUI(MsgFieldBSE);
  551. log.Info("Acquire BSE image success! Processing image...");
  552. // image process
  553. FieldImageProcess(curFld);
  554. MsgFieldBSE.InitFieldBSEAnalysisPartsDataMsg();
  555. m_pMsrThread.SendMessageToMeasureGUI(MsgFieldBSE);
  556. COTSXRayParam pXRayParam = m_Sample.GetMsrParams().GetXRayParam();
  557. if (pXRayParam.GetUsingXray() == true)
  558. {
  559. foreach (var p in curFld.GetListAnalysisParticles())
  560. {
  561. p.SetIsXrayParticle(true);
  562. }
  563. CollectParticlesXrayData(curFld);
  564. }
  565. m_Sample.GetMsrStatus().SetStatus(OTS_MSR_SAMPLE_STATUS.SUCCESSED);
  566. curFld.SetIsMeasureComplete(true);
  567. log.Info("Begin to classify particles! particle num:" + curFld.GetListAnalysisParticles().Count);
  568. ClassifyFieldParticles(curFld);
  569. MsgFieldBSE.InitFieldSTDColoredPartsDataMsg();
  570. m_pMsrThread.SendMessageToMeasureGUI(MsgFieldBSE);
  571. //start db save
  572. StartSaveFileThread(ref curFld);
  573. SendFieldParticlesInfoToGUI(curFld, m_Sample.GetMsrStatus());
  574. }
  575. while (bSaveThreadWorking)//wait untill all the field data has been saved.
  576. {
  577. Thread.Sleep(1000);
  578. log.Warn("db saving!");
  579. }
  580. TheLastWorkOfSampleMeasure();
  581. }
  582. }
  583. public void TheLastWorkOfSampleMeasure()
  584. {
  585. COTSSample theSample = m_Sample;
  586. var pStatus = theSample.GetMsrStatus();
  587. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.COMPLT);
  588. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.SUCCESSED);
  589. // let main thread to know that this sample measurement completes
  590. ST_MSTMsg MsgSmplEnd = new ST_MSTMsg(m_Sample);
  591. MsgSmplEnd.InitSampleCompleteMsg();
  592. m_pMsrThread.SendMessageToMeasureGUI(MsgSmplEnd);
  593. string userdB = m_Sample.GetMsrParams().GetSTDName();
  594. if(userdB.ToLower() != "nostddb" && userdB.ToLower() != "nostddb.db")
  595. {
  596. try
  597. {
  598. string userdBpath= System.Windows.Forms.Application.StartupPath + "\\Config\\SysData\\" + m_Sample.GetMsrParams().GetSTDName() + ".db";
  599. File.Copy(userdBpath, m_pSampleRstFile.GetFieldFileSubFolderStr().Remove(m_pSampleRstFile.GetFieldFileSubFolderStr().IndexOf("FIELD_FILES")) + m_Sample.GetMsrParams().GetSTDName() + ".db", true);
  600. }
  601. catch(Exception ex)
  602. {
  603. MessageBox.Show("userdB copy failed:" + ex.ToString());
  604. }
  605. }
  606. }
  607. public bool DoMEasureForReMeasure()
  608. {
  609. return true;
  610. }
  611. public virtual void FieldImageProcess(COTSField curFldData)
  612. {
  613. PointF fldCenter = curFldData.GetOTSPosition();
  614. CSEMStageData a_pCSEMStageData = m_pMsrThread.GetProjResultData().GetSEMStageData();
  615. PointF semPos = new Point();
  616. a_pCSEMStageData.ConvertOTSToSEMCoord(fldCenter, ref semPos);
  617. curFldData.SetSemPos(semPos);
  618. //first step:remove background of the bse image and compound all the finded particles.
  619. log.Info("Begin to process image and get all particles!");
  620. //according to the ECD scope,filter out the effective particles,remove the noise.
  621. curFldData.GetOriginalParticles(m_Sample.GetMsrParams(), m_Sample.CalculatePixelSize());
  622. log.Info("Begin to filter particles!");
  623. curFldData.FilterParticles(m_Sample.GetMsrParams().GetXRayParam());//filter according to the xraylimit
  624. log.Info("Begin to Calculate the image property of every particle!");
  625. var analysisparts = curFldData.GetListAnalysisParticles();
  626. curFldData.CalParticleImageProp(analysisparts);//calculate particle image property such as feret diameter, DMAX etc.
  627. CSampleParam pMsrParam = m_Sample.GetMsrParams();
  628. COTSImageProcParam pImgProcessParam = pMsrParam.GetImageProcessParam();
  629. curFldData.SelectParticlesAccordingImgProp(pImgProcessParam);
  630. var overlap = pImgProcessParam.GetOverlapParam();
  631. if (overlap > 0)
  632. {
  633. curFldData.RemoveDuplicateOverlapParticles(overlap);
  634. }
  635. curFldData.CalculateParticleAbsolutPos(m_pMsrThread.GetProjResultData().GetSEMStageData());
  636. curFldData.InitParticles(pImgProcessParam);
  637. return ;
  638. }
  639. public virtual void CollectParticlesXrayData(COTSField curFldData)
  640. {
  641. var allParts = curFldData.GetListXrayParticles();
  642. var smallparts = new List<COTSParticleClr>();
  643. var bigparts = new List<COTSParticleClr>();
  644. double quantifyThreshold = m_Sample.GetMsrParams().GetXRayParam().GetFeatureModeMinSize();
  645. foreach (var part in allParts)
  646. {
  647. double equalCircleDiameter = Math.Sqrt(part.GetActualArea() / 3.14159) * 2f;
  648. if (equalCircleDiameter < quantifyThreshold)
  649. {
  650. smallparts.Add(part);
  651. }
  652. else
  653. {
  654. bigparts.Add(part);
  655. }
  656. }
  657. log.Info("SmallQuantifyParts (<" + quantifyThreshold.ToString("f2") + "): " + smallparts.Count);
  658. log.Info("BigQuantifyParts (>=" + quantifyThreshold.ToString("f2") + "): " + bigparts.Count);
  659. curFldData.CreateXrayList(smallparts);
  660. curFldData.CreateXrayList(bigparts);
  661. // get x-ray parameters
  662. COTSXRayParam pXRayParam = m_Sample.GetMsrParams().GetXRayParam();
  663. var workmode = pXRayParam.GetScanMode();
  664. if (workmode == OTS_X_RAY_SCAN_MODE.PointMode)
  665. {
  666. uint nXRayAQTime;
  667. if (bigparts.Count > 0)
  668. {
  669. nXRayAQTime = (uint)pXRayParam.GetMidAnalyAQTime();
  670. log.Info("Begin to collect xraydata:" + bigparts.Count +"(" +nXRayAQTime.ToString()+") on " + workmode.ToString());
  671. m_EDSController.GetXRayByParts(bigparts, nXRayAQTime, true);
  672. }
  673. if (smallparts.Count > 0)
  674. {
  675. Thread.Sleep(500);//add delay here,or else the eds system will halt.
  676. nXRayAQTime = (uint)pXRayParam.GetSmallPartXrayTime();
  677. log.Info("Begin to collect xraydata:" + smallparts.Count + "(" + nXRayAQTime.ToString() + ") on " + workmode.ToString());
  678. m_EDSController.GetXRayByParts(smallparts, nXRayAQTime, true);
  679. }
  680. }
  681. else if (workmode == OTS_X_RAY_SCAN_MODE.FeatureMode)
  682. {
  683. uint nXRayAQTime;
  684. if (bigparts.Count > 0)
  685. {
  686. log.Info("Begin to collect xraydata:" + bigparts.Count + " on " + OTS_X_RAY_SCAN_MODE.FeatureMode.ToString());
  687. nXRayAQTime = (uint)pXRayParam.GetMidAnalyAQTime();
  688. m_EDSController.GetXRayByFeatures(bigparts, nXRayAQTime, true);
  689. }
  690. if (smallparts.Count > 0)
  691. {
  692. Thread.Sleep(500);
  693. log.Info("Begin to collect xraydata:" + smallparts.Count + " on " + OTS_X_RAY_SCAN_MODE.PointMode.ToString());
  694. nXRayAQTime = (uint)pXRayParam.GetSmallPartXrayTime();
  695. m_EDSController.GetXRayByParts(smallparts, nXRayAQTime, true);
  696. }
  697. }
  698. return;
  699. }
  700. public virtual void QuantifyParticlesXrayData(COTSField curFldData)
  701. {
  702. var parts = curFldData.GetListXrayParticles();
  703. foreach (var p in parts)
  704. {
  705. m_EDSController.QuantifyXrayByPart(p);
  706. }
  707. }
  708. public void DoHolePreview()
  709. {
  710. using (AutoResetSEMControl autoReset = new AutoResetSEMControl(this))
  711. {
  712. //----------memorize the state of sem
  713. var semstate = new SEMStateObject();
  714. double dMagnification = m_Sample.GetSEMDataMsr().GetMagnification();
  715. double wd = m_Sample.GetSEMDataMsr().GetWorkingDistance();
  716. ISemController sem = m_SemHardwareMgr;
  717. double posX=0, posY=0,posR=0;
  718. sem.GetSemPositionXY(ref posX, ref posY, ref posR);
  719. CSEMStageData a_pCSEMStageData = m_pMsrThread.GetProjResultData().GetSEMStageData();
  720. Point pos = new Point((int)posX, (int)posY);
  721. PointF otsPos = new Point(0, 0);
  722. if (!a_pCSEMStageData.ConvertSEMToOTSCoord(pos, ref otsPos))
  723. {
  724. return;
  725. }
  726. semstate.Pos = otsPos;
  727. semstate.Magnification = dMagnification;
  728. semstate.WorkingDistance = wd;
  729. autoReset.SemState = semstate;
  730. //-------------------------------------
  731. // let the main thread to know that this sample measurement starts
  732. CMsrSampleStatus pStatus = m_HolePreviewSample.GetMsrStatus();
  733. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.INPROCESS);
  734. // set current time to current time
  735. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.START);
  736. // get SEM controller to set magnification and working distance
  737. if (!SetSEMDataMrs(m_HolePreviewSample))
  738. {
  739. log.Error("DoHolePreview: fail to set SEM data.");
  740. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  741. // record end time
  742. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  743. return;
  744. }
  745. // set the BSE scan param
  746. if (!SetHoleBSEParam(m_HolePreviewSample))
  747. {
  748. log.Error("DoHolePreview: fail to set BSE param.");
  749. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  750. // record end time
  751. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  752. return;
  753. }
  754. // calculate field centers
  755. List<System.Drawing.Point> listFieldCenter;
  756. List<System.Drawing.Point> alllistFieldCenter ;
  757. if (!CalculateUnMeasuredHoleImgCenters(m_HolePreviewSample, out alllistFieldCenter,out listFieldCenter))
  758. {// failed to calculate field centers
  759. log.Error("DoHolePreview: failed to calculate field centers.");
  760. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  761. // record end time
  762. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  763. return;
  764. }
  765. // go through each field
  766. //int nNewFieldId = 0;
  767. for ( int i = 0; i < listFieldCenter.Count; ++i)
  768. {// check and break if stop button is clicked
  769. if (IsAborted())
  770. {// measure stopped
  771. log.Trace("DoHolePreview: measure thread is stopped.");
  772. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.STOPPED);
  773. // record end time
  774. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  775. return;
  776. }
  777. // check if sample measurement completes
  778. COTSImgScanPrm pScanParam = m_Sample.GetMsrParams().GetImageScanParam();
  779. int nTotalFieldSize = listFieldCenter.Count;
  780. // get a field center
  781. System.Drawing.Point poiFieldCentre = listFieldCenter[i];
  782. // move SEM to the field center
  783. if (!MoveSEMToPoint(poiFieldCentre))
  784. {// failed to move SEM to the position
  785. log.Error("DoHolePreview: failed to move SEM to the field centre point.");
  786. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  787. // record end time
  788. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  789. return;
  790. }
  791. // take BSE image for the fields
  792. CBSEImgClr pBSEIamge = AcquireABSEImage();
  793. if (pBSEIamge==null)
  794. {
  795. // failed to acquire a BSE image
  796. log.Error("DoHolePreview: failed to acquire a BSE image.");
  797. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  798. // record end time
  799. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  800. return;
  801. }
  802. //BSEData
  803. ST_MSTMsg MsgFieldBSE=new ST_MSTMsg(m_HolePreviewSample);
  804. MsgFieldBSE.InitHolePreBSEDataMsg(pBSEIamge,poiFieldCentre);
  805. m_pMsrThread.SendHolePreviewMessageToMeasureGUI(MsgFieldBSE);
  806. if (pStatus.GetStatus() != OTS_MSR_SAMPLE_STATUS.INPROCESS)
  807. {
  808. // measurement failed or stopped
  809. log.Error("DoHolePreview: measurement failed or stopped.");
  810. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  811. // record end time
  812. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  813. return;
  814. }
  815. //save the result to project file
  816. Rectangle oImageRect = (Rectangle)pBSEIamge.GetImageRect();
  817. CHoleBSEImg pHoleBSEImg =new CHoleBSEImg(oImageRect,poiFieldCentre);
  818. pHoleBSEImg.SetImageData( pBSEIamge.GetImageDataPtr(),oImageRect.Width,oImageRect.Height);
  819. m_listHoleBSEImg.Add(pHoleBSEImg);
  820. }
  821. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  822. //calculate measure time
  823. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.SUCCESSED);
  824. // let main thread to know that this sample measurement completes
  825. ST_MSTMsg MsgSmplEnd=new ST_MSTMsg(m_HolePreviewSample);
  826. MsgSmplEnd.InitHolePreSampleEndMsg();
  827. m_pMsrThread.SendHolePreviewMessageToMeasureGUI(MsgSmplEnd);
  828. }
  829. }
  830. // Cumulate field data info
  831. public virtual bool CumulateFieldData( List<COTSParticleClr> listParticles, double a_nMeasuredArea)
  832. {
  833. // get measure result items of the sample
  834. CMsrResultItems pMsrResults = m_Sample.GetMsrResults();
  835. // go through the particles list
  836. foreach (COTSParticleClr pParticle in listParticles)
  837. {
  838. // create a measure result item
  839. pMsrResults.CumulateMeasureResult(pParticle);
  840. }
  841. pMsrResults.CumulateMeasuredArea(a_nMeasuredArea);
  842. // cumulate ratio
  843. double dRatio = pMsrResults.GetTotalParticleArea();
  844. dRatio = dRatio / pMsrResults.GetMeasuredArea();
  845. pMsrResults.SetRatio(dRatio);
  846. m_Sample.SetMsrResults(pMsrResults);
  847. return true;
  848. }
  849. public bool SaveFieldData(COTSField fldData, string filedFileFoler)
  850. {
  851. string strFieldFileFolder = filedFileFoler;
  852. CBSEImageFileMgr pBSEImgFileMgr = new CBSEImageFileMgr();
  853. pBSEImgFileMgr.SetBSEImg(fldData.GetBSEImage());
  854. int nId = fldData.GetId();
  855. string sFieldId;
  856. sFieldId = nId.ToString();
  857. string strBSEFilePathname = strFieldFileFolder + "\\" + m_pSampleRstFile.SMPL_MSR_RESULT_FIELDS_BSE + sFieldId + pBSEImgFileMgr.BMP_IMG_FILE_EXT;
  858. if (!pBSEImgFileMgr.SaveIntoBitmap(strBSEFilePathname))
  859. {
  860. log.Error("SaveFieldFiles: save BSE file failed.");
  861. return false;
  862. }
  863. // IncA Data list
  864. CIncAFileMgr pDBFileMgr = m_pSampleRstFile.DBFileMgr;
  865. pDBFileMgr.SaveStatusDataToDB();
  866. var fldDB = pDBFileMgr.GetFieldDB();
  867. log.Warn("Start saving particle data.");
  868. var fldcmd = fldDB.GetSavingAFieldcmdObj(fldData.GetId(), fldData.GetOTSPosition(), fldData.GetSemPos());
  869. List<KeyValuePair<string, System.Data.SQLite.SQLiteParameter[]>> fldcmds = new List<KeyValuePair<string, System.Data.SQLite.SQLiteParameter[]>>();
  870. fldcmds.Add(fldcmd);
  871. pDBFileMgr.ExecuteNonQueryBatch(ref fldcmds);
  872. //remomove the invalid particles
  873. var cmds = pDBFileMgr.GetSavingParticleDataToDBCmds(fldData.GetListAnalysisParticles(), fldData.GetOTSPosition());
  874. pDBFileMgr.ExecuteNonQueryBatch(ref cmds);
  875. CPosXrayDBMgr PosXrayDBMgr = pDBFileMgr.GetPosXrayDBMgr();
  876. var listAnalysisPosXray = new List<CPosXrayClr>();
  877. foreach (var p in fldData.GetListXrayParticles())
  878. {
  879. listAnalysisPosXray.Add(p.GetXray());
  880. }
  881. var cmds1 = PosXrayDBMgr.GetSavingXrayCmds(listAnalysisPosXray, true);
  882. pDBFileMgr.ExecuteNonQueryBatch(ref cmds1);
  883. return true;
  884. }
  885. protected void SaveFieldMgrData()
  886. {
  887. while (bSaveThreadWorking)
  888. {
  889. while (fieldQueue.Count() > 0)
  890. {
  891. COTSField f = fieldQueue.Dequeue();
  892. //save to disk first ,then pop . if the size is 0,then we know all the saving work is done.
  893. log.Info("Begin to save particles data! particle num:" + f.GetListAnalysisParticles().Count);
  894. SaveFieldData(f, m_pSampleRstFile.GetFieldFileSubFolderStr());
  895. }
  896. if (fieldQueue.Count() == 0)
  897. {
  898. bSaveThreadWorking = false; //must set this flag,so the main thread can know this thread has exited.
  899. log.Warn("finished batch saving");
  900. return;
  901. }
  902. }
  903. return;
  904. }
  905. private void SendFieldParticlesInfoToGUI(COTSField curFld,CMsrSampleStatus pStatus)
  906. {
  907. double measuredArea = 0; // this area should be the field area
  908. var a_pBSEImg = curFld.GetBSEImage();
  909. double dPixelSize = curFld.GetPixelSize();
  910. measuredArea = a_pBSEImg.GetHeight() * a_pBSEImg.GetWidth() * dPixelSize * dPixelSize; //Get measured area
  911. CumulateFieldData(curFld.GetListAnalysisParticles(), measuredArea);
  912. log.Info("Send field data to screen!");
  913. pStatus.AddCompletedFieldCenter(curFld.GetOTSPosition());
  914. //Field Data
  915. // record end time
  916. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  917. ST_MSTMsg MsgFieldEnd = new ST_MSTMsg(m_Sample,curFld);
  918. MsgFieldEnd.InitFieldDataMsg();
  919. m_pMsrThread.SendMessageToMeasureGUI(MsgFieldEnd);
  920. }
  921. protected void StartSaveFileThread(ref COTSField a_pFieldMgr)
  922. {
  923. fieldQueue.Enqueue(a_pFieldMgr);
  924. if (fieldQueue.Count() > 0) //if there's data in the queue and the previous thread has finished then start a new thread.
  925. {
  926. if (bSaveThreadWorking == false)
  927. {
  928. bSaveThreadWorking = true;
  929. m_thread_ptr = new System.Threading.Thread(this.SaveFieldMgrData);//m_thread_ptr = shared_ptr<thread>(new thread(&CSmplMeasureInc::SaveFieldMgrData, this));
  930. m_thread_ptr.IsBackground = true;
  931. m_thread_ptr.Start();
  932. }
  933. }
  934. }
  935. }
  936. }