CSmplMeasure.cs 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using OTSModelSharp.ServiceInterface;
  7. using static OTSDataType.otsdataconst;
  8. using OTSDataType;
  9. using System.Diagnostics;
  10. using System.Drawing;
  11. using System.Threading;
  12. using OTSModelSharp.DTLBase;
  13. using OTSCLRINTERFACE;
  14. using OTSModelSharp.ServiceCenter;
  15. namespace OTSModelSharp
  16. {
  17. using CHoleBSEImgsList = List<CHoleBSEImg>;
  18. 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 CMeasure m_pMsrThread;
  25. string m_strWorkingFolder;
  26. protected CSmplMsrResult m_pSampleRstFile;
  27. CHoleBSEImgsList m_listHoleBSEImg;
  28. //CFunExportClass loger;
  29. protected SemController m_SemHardwareMgr;
  30. protected ScanController m_ScanHardwareMgr;
  31. protected EDSController m_EDSHardwareMgr;
  32. protected Queue<COTSFieldData> fieldQueue=new Queue<COTSFieldData>();
  33. protected COTSFieldData curFldData;
  34. protected IClassifyEngine m_classifyEngine;
  35. public CSmplMeasure()
  36. {
  37. log = NLog.LogManager.GetCurrentClassLogger();
  38. m_pSampleRstFile = new CSmplMsrResult();
  39. m_SemHardwareMgr = SemController.GetSEMController();
  40. m_ScanHardwareMgr = ScanController.GetScanController();
  41. m_EDSHardwareMgr = EDSController.GetEDSController();
  42. m_listHoleBSEImg = new CHoleBSEImgsList();
  43. }
  44. public CSmplMeasure( string a_strWorkingFolder, COTSSample a_pSample)
  45. {
  46. log = NLog.LogManager.GetCurrentClassLogger();
  47. m_strWorkingFolder = a_strWorkingFolder;
  48. m_pSampleRstFile = new CSmplMsrResult( a_strWorkingFolder, a_pSample);// new CSmplMsrResultFile(m_strWorkingFolder,a_pSample);
  49. m_SemHardwareMgr = SemController.GetSEMController();
  50. m_ScanHardwareMgr = ScanController.GetScanController();
  51. m_EDSHardwareMgr = EDSController.GetEDSController();
  52. m_listHoleBSEImg = new CHoleBSEImgsList();
  53. m_Sample = a_pSample;
  54. }
  55. public void SetSample(COTSSample a_pSample)
  56. {
  57. m_Sample = a_pSample;
  58. m_pSampleRstFile.SetSample(a_pSample);
  59. }
  60. public void SetMsrThread(CMeasure mt)
  61. {
  62. m_pMsrThread = mt;
  63. }
  64. bool SetSEMDataMrs()
  65. {
  66. var pSEMDataMsr = m_Sample.GetSEMDataMsr();
  67. //ASSERT(pSEMDataMsr);
  68. double dMag = pSEMDataMsr.GetMagnification();
  69. double dWorkDis = pSEMDataMsr.GetWorkingDistance();
  70. //CSemBasePtr pSEMCtrlPtr = GetSEMControl();
  71. var pSEMCtrl = m_pMsrThread.GetSEMController();
  72. // get SEM controller
  73. if (!pSEMCtrl.IsConnected())
  74. {
  75. if (!pSEMCtrl.Connect())
  76. {
  77. log.Error("SetSEMDataMrs: can't connect SEM.");
  78. return false;
  79. }
  80. }
  81. log.Info("set magnification:" + dMag.ToString());
  82. log.Info("set Working Distance:" + dWorkDis.ToString());
  83. pSEMCtrl.SetMagnification(dMag);
  84. pSEMCtrl.SetWorkingDistance(dWorkDis);
  85. return true;
  86. }
  87. bool SetSEMExteralOn()
  88. {
  89. var pSEMCtrl = m_SemHardwareMgr;
  90. // get SEM controller
  91. if (!pSEMCtrl.IsConnected())
  92. {
  93. if (!pSEMCtrl.Connect())
  94. {
  95. log.Error("SetSEMExteralOn: can't connect SEM.");
  96. return false;
  97. }
  98. }
  99. log.Warn("Set Scan Exteral on!");
  100. pSEMCtrl.SetScanExternal(true);
  101. return true;
  102. }
  103. // set SEM external off
  104. bool SetSEMExteralOff()
  105. {
  106. var pSEMCtrlPtr = m_SemHardwareMgr;
  107. // get SEM controller
  108. if (!pSEMCtrlPtr.IsConnected())
  109. {
  110. if (!pSEMCtrlPtr.Connect())
  111. {
  112. log.Error("SetSEMExteralOff: can't connect SEM.");
  113. return false;
  114. }
  115. }
  116. log.Warn("Set SEM Exteral Off!");
  117. pSEMCtrlPtr.SetScanExternal(false);
  118. return true;
  119. }
  120. bool SetBSEParam()
  121. {
  122. // get SEM controller
  123. var pSEMController = m_SemHardwareMgr;
  124. // get scan controller
  125. var pScanController = m_ScanHardwareMgr;
  126. // scan parameters
  127. var pMsrParam = m_Sample.GetMsrParams();
  128. var pImgScanParam = pMsrParam.GetImageScanParam();
  129. // get image size
  130. var nImageSizeId = pImgScanParam.GetImageResulotion();
  131. int nResulotionId = RESOLUTION_ID_FIRST_TIE + (int)nImageSizeId;
  132. Size sizePixelImage = RESOLUTION_VALUE[nResulotionId];
  133. // get SEM controller
  134. if (!pSEMController.IsConnected())
  135. {
  136. if (!pSEMController.Connect())
  137. {
  138. log.Error("SetBSEParam: can't connect SEM.");
  139. return false;
  140. }
  141. }
  142. // get dwell time
  143. OTS_IMAGE_SCANSPEED_OPTIONS nDwellTime = pImgScanParam.GetScanImageSpeed();
  144. // convert dwell time to bruker dwell time (8, 16, 32)
  145. int nBrukerDwellTimeId=3;
  146. switch (nDwellTime)
  147. {
  148. case OTS_IMAGE_SCANSPEED_OPTIONS.low:
  149. nBrukerDwellTimeId = 3;
  150. break;
  151. case OTS_IMAGE_SCANSPEED_OPTIONS.meddium:
  152. nBrukerDwellTimeId = 4;
  153. break;
  154. case OTS_IMAGE_SCANSPEED_OPTIONS.high:
  155. nBrukerDwellTimeId = 5;
  156. break;
  157. default:
  158. nBrukerDwellTimeId = 3;
  159. break;
  160. }
  161. long nBrukerDwellTime = OTSDataType.otsdataconst.DWELLTIME_BRUKER_VALUES[nBrukerDwellTimeId];
  162. if (!pScanController.Init())
  163. {
  164. log.Error("SetBSEParam: failed to get scan control.");
  165. return false;
  166. }
  167. // set dwell time
  168. if (!pScanController.SetDwellTime(nBrukerDwellTime))
  169. {
  170. log.Error("SetBSEParam: failed to set dwell time (%d) for bruker system.", nBrukerDwellTime);
  171. return false;
  172. }
  173. // set image size
  174. if (!pScanController.SetImageSize(sizePixelImage.Width,sizePixelImage.Height))
  175. {
  176. // failed to set dwell time
  177. log.Error("SetBSEParam: failed to set dwell time (%d).", sizePixelImage.Height);
  178. return false;
  179. }
  180. return true;
  181. }
  182. bool SetHoleBSEParam()
  183. {
  184. // get SEM controller
  185. var pSEMController = m_SemHardwareMgr;
  186. // get scan controller
  187. var pScanController = m_ScanHardwareMgr;
  188. // scan parameters
  189. var pMsrParam = m_Sample.GetMsrParams();
  190. var pImgScanParam = pMsrParam.GetImageScanParam();
  191. // get image size
  192. var nImageSizeId = pImgScanParam.GetImageResulotion();
  193. int nResulotionId = RESOLUTION_ID_FIRST_TIE + (int)nImageSizeId;
  194. Size sizePixelImage = RESOLUTION_VALUE[nResulotionId];
  195. // get SEM controller
  196. if (!pSEMController.IsConnected())
  197. {
  198. if (!pSEMController.Connect())
  199. {
  200. log.Error("SetBSEParam: can't connect SEM.");
  201. return false;
  202. }
  203. }
  204. // get dwell time
  205. OTS_IMAGE_SCANSPEED_OPTIONS nDwellTime = pImgScanParam.GetScanImageSpeed();
  206. // convert dwell time to bruker dwell time (6, 16, 32)
  207. 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.
  208. if (!pScanController.Init())
  209. {
  210. log.Error("SetBSEParam: failed to get scan control.");
  211. return false;
  212. }
  213. // set dwell time
  214. if (!pScanController.SetDwellTime(nBrukerDwellTime))
  215. {
  216. log.Error("SetBSEParam: failed to set dwell time (%d) for bruker system.", nBrukerDwellTime);
  217. return false;
  218. }
  219. // set image size
  220. if (!pScanController.SetImageSize(sizePixelImage.Width/2, sizePixelImage.Height/2))
  221. {
  222. // failed to set dwell time
  223. log.Error("SetBSEParam: failed to set dwell time (%d).", sizePixelImage.Height);
  224. return false;
  225. }
  226. return true;
  227. }
  228. public void SetWorkingFolder(String a_strWorkingFolder)
  229. {
  230. // add "\\" at the string end if it is not "\\"
  231. if (a_strWorkingFolder.PadRight(1)!="\\")
  232. {
  233. a_strWorkingFolder += "\\";
  234. }
  235. m_strWorkingFolder = a_strWorkingFolder + m_Sample.GetName() + "\\";
  236. }
  237. bool CalculateUnMeasuredFieldsCenters(out List<System.Drawing.Point> a_allpieldcenter,out List<System.Drawing.Point> a_listFieldCenter)
  238. {
  239. // sample measure parameters
  240. CSampleParam pMsrParam = m_Sample.GetMsrParams();
  241. COTSImgScanPrm poImageScanParam = pMsrParam.GetImageScanParam();
  242. CSEMDataMsr poSEMDataMsr = m_Sample.GetSEMDataMsr();
  243. CMsrSampleStatus pStatus = m_Sample.GetMsrStatus();
  244. // measured field centers list
  245. List<System.Drawing.Point> listCompletedCenter = pStatus.GetCompletedFieldsCenter();
  246. // field centers list manager
  247. CFieldPositionMgr pFieldMgr = new CFieldPositionMgr();
  248. // init field centers list manager
  249. if (!pFieldMgr.Init(m_Sample.GetMsrArea(), poImageScanParam, poSEMDataMsr, listCompletedCenter))
  250. {
  251. log.Error("CalculateFieldsCenters: failed to init field centres list manager.");
  252. a_listFieldCenter = new List<System.Drawing.Point>();
  253. a_allpieldcenter = new List<Point>();
  254. return false;
  255. }
  256. // get field centers list
  257. a_listFieldCenter = pFieldMgr.GetUnmeasuredFieldCentrePoints();// GetFieldCentrePoints();
  258. a_allpieldcenter = pFieldMgr.GetFieldCentrePoints();
  259. // ok, return TRUE
  260. return true;
  261. }
  262. protected bool IsAborted()
  263. {
  264. //Debug.Assert(m_pMsrThread == null);
  265. return m_pMsrThread.IsMeasureStopped();
  266. }
  267. bool IsSampleOver(COTSImgScanPrm a_pScanParam, int a_nTotalFields)
  268. {
  269. int nStopMode = (int)a_pScanParam.GetStopMode();
  270. int nStopField = a_pScanParam.GetStopParamFields();
  271. // completed fields number
  272. CMsrSampleStatus pMsrSampleStatus = m_Sample.GetMsrStatus();
  273. int nCompeltedField = pMsrSampleStatus.GetCompletedFields();
  274. CMsrDisplayResults pMsrResults = m_Sample.GetMsrResults();
  275. List<CMsrResultItem> listMsrResult = pMsrResults.GetResultItems();
  276. int nNumParticle = 0;
  277. foreach (var pResult in listMsrResult)
  278. {
  279. if (pResult.GetTypeId() > (int)OTS_PARTCLE_TYPE.NO_ANALYSIS_X_RAY)//summarize the number of the identified particle in this condition
  280. {
  281. nNumParticle += (int)pResult.GetNumber();
  282. }
  283. }
  284. TimeSpan timeSpan = pMsrSampleStatus.GetUsedTime();
  285. int nDay = timeSpan.Days;
  286. int nHour = timeSpan.Hours;
  287. int nMin = timeSpan.Minutes;
  288. int nSec = timeSpan.Seconds;
  289. int nUsedTime = nSec + nMin * 60 + nHour * 3600 + nDay * 86400;
  290. int nParticlAim = a_pScanParam.GetStopParamParticles();
  291. int nMeasTimeAim = a_pScanParam.GetStopParamMeasTime();
  292. bool bRet = true;
  293. switch (nStopMode)
  294. {
  295. case (int)OTS_MEASURE_STOP_MODE.CoverMode:
  296. // completed fields number
  297. if (nCompeltedField < a_nTotalFields)
  298. {
  299. bRet = false;
  300. }
  301. break;
  302. case (int)OTS_MEASURE_STOP_MODE.FieldMode:
  303. if (nCompeltedField < nStopField)
  304. {
  305. bRet = false;
  306. }
  307. break;
  308. case (int)OTS_MEASURE_STOP_MODE.ParticleMode:
  309. if (nNumParticle < nParticlAim)
  310. {
  311. bRet = false;
  312. }
  313. break;
  314. case (int)OTS_MEASURE_STOP_MODE.TimeMode:
  315. if (nUsedTime < nMeasTimeAim)
  316. {
  317. bRet = false;
  318. }
  319. break;
  320. default:
  321. break;
  322. }
  323. return bRet;
  324. }
  325. // move SEM to the point
  326. bool MoveSEMToPoint(System.Drawing.Point a_poi)
  327. {
  328. // get SEM controller
  329. var pSEMController = m_SemHardwareMgr;
  330. Point a_SEMpt = new Point();
  331. CSEMStageData a_pCSEMStageData = m_pMsrThread.GetProjResultData().GetSEMStageData();
  332. int hardWareDelay = a_pCSEMStageData.GetHardWareDelay();
  333. if (!a_pCSEMStageData.ConverOTSToSEMPoint(a_poi, ref a_SEMpt))
  334. {
  335. return false;
  336. }
  337. if (!pSEMController.IsConnected())
  338. {
  339. if (!pSEMController.Connect())
  340. {
  341. log.Error("MoveSEMToPoint: can't connect SEM.");
  342. return false;
  343. }
  344. }
  345. log.Info("Begin to move SEM stage to " + a_SEMpt.X + "," + a_SEMpt.Y);
  346. // move SEM to the position (rotation 0)
  347. if (!pSEMController.MoveSEMToPoint(a_SEMpt))
  348. {
  349. log.Error("MoveSEMToPoint: failed to call MoveSEMToPoint method.");
  350. return false;
  351. }
  352. Thread.Sleep(hardWareDelay);
  353. return true;
  354. }
  355. // Acquire a BSE image
  356. CBSEImgClr AcquireABSEImage()
  357. {
  358. // BSE image
  359. CBSEImgClr pBSEImage = null;
  360. // get scan controller
  361. var pScanController = m_ScanHardwareMgr;
  362. pBSEImage = pScanController.AcquireBSEImage(0, 0, 2);
  363. return pBSEImage;
  364. }
  365. public virtual bool FieldImageProcess(Point fldCenter, CBSEImgClr imageData)
  366. {
  367. return true;
  368. }
  369. public virtual void ClassifyFieldParticles()
  370. {
  371. return;
  372. }
  373. public virtual void ClassifyMergedParticles(List<COTSParticleClr> parts)
  374. {
  375. return;
  376. }
  377. private class AutoResetSEMControl:IDisposable
  378. {
  379. CSmplMeasure sm;
  380. public AutoResetSEMControl(CSmplMeasure s)
  381. {
  382. sm = s;
  383. }
  384. public void Dispose()
  385. {
  386. sm.SetSEMExteralOff();
  387. }
  388. }
  389. public void DoMeasureForOneSample()
  390. {
  391. using (AutoResetSEMControl autoReset = new AutoResetSEMControl(this)) //when this method exit ,the SetSEMExternalOff and ResetScan will be called automatically.
  392. {
  393. // let the main thread to know that this sample measurement starts
  394. var pStatus = m_Sample.GetMsrStatus();
  395. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.INPROCESS);
  396. // set current time to current time
  397. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.START);
  398. // let main App know that the sample begin to measure
  399. ST_MSTMsg MsgSmpStart = new ST_MSTMsg();
  400. MsgSmpStart.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  401. MsgSmpStart.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.INPROCESS;
  402. MsgSmpStart.STMSampleStu.cSampleName = m_Sample.GetName();
  403. m_pMsrThread.SendMessageToMeasureApp(MsgSmpStart);
  404. log.Info(m_Sample.GetName() + " Measurement started!");
  405. // get SEM controller to set magnification and working distance
  406. if (!SetSEMDataMrs())
  407. {
  408. log.Error("DoMeasure: fail to set SEM data.");
  409. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  410. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  411. return;
  412. }
  413. // set the BSE scan param
  414. if (!SetBSEParam())
  415. {
  416. log.Error("DoMeasure: fail to set BSE param.");
  417. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  418. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  419. return;
  420. }
  421. var pSEMDataGnr = new CSEMDataGnr();
  422. log.Info("Get Kv, Brightness and Contrast!");
  423. m_SemHardwareMgr.GetSEMDataGnrFromHw(ref pSEMDataGnr);
  424. m_pSampleRstFile.SetSEMGnr(pSEMDataGnr);
  425. // record SEM data
  426. COTSMsrPrjResultData pProjMgrFile = m_pMsrThread.GetProjResultData();
  427. CSEMStageData pSEMStageData = pProjMgrFile.GetSEMStageData();
  428. m_pSampleRstFile.SetSEMStageData(pSEMStageData);
  429. // record stage
  430. CStage pStage = pProjMgrFile.GetStage();
  431. m_pSampleRstFile.SetSEMStage(pStage);
  432. // calculate field centers
  433. List<System.Drawing.Point> umMeasuredlistFieldCenter;
  434. List<System.Drawing.Point> alllistFieldCenter;
  435. if (!CalculateUnMeasuredFieldsCenters(out alllistFieldCenter,out umMeasuredlistFieldCenter))
  436. {// failed to calculate field centers
  437. log.Error("DoMeasure: failed to calculate field centers.");
  438. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  439. // record end time
  440. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  441. return;
  442. }
  443. //-----save the static measure result file data into xml file and the dynamic data of every field will be saved into sqlite database
  444. log.Info("Create result file!");
  445. if (!m_pSampleRstFile.CreateResultFiles())
  446. {// failed to call measure result file Save method
  447. log.Error("DoMeasure: failed to call measure result file Save method.");
  448. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  449. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  450. return;
  451. }
  452. //------
  453. int nNewFieldId = 0;
  454. int numOfAllFields = pStatus.GetCompletedFields() + umMeasuredlistFieldCenter.Count;//
  455. int completedFields = pStatus.GetCompletedFields();
  456. log.Info("Unmeasured fields:" + umMeasuredlistFieldCenter.Count);
  457. for (int i = 0; i < (int)umMeasuredlistFieldCenter.Count; ++i)
  458. {// check and break if stop button is clicked
  459. if (IsAborted())
  460. {// measure stopped
  461. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.STOPPED);
  462. // record end time
  463. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  464. //must wait for the saving data thread finished,or we'll get null pointer exception when we stop the measure process.
  465. while (fieldQueue.Count() > 0)
  466. {
  467. Thread.Sleep(100);
  468. }
  469. return;
  470. }
  471. // check if sample measurement completes
  472. COTSImgScanPrm pScanParam = m_Sample.GetMsrParams().GetImageScanParam();
  473. int nTotalFieldSize = (int)umMeasuredlistFieldCenter.Count;
  474. if (IsSampleOver(pScanParam, numOfAllFields))
  475. {
  476. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  477. break;
  478. }
  479. // get a field center
  480. System.Drawing.Point poiFieldCentre = umMeasuredlistFieldCenter[i];
  481. // update thread measure status class, let the main thread know that starts a new field
  482. ST_MSTMsg MsgFieldStart = new ST_MSTMsg();
  483. MsgFieldStart.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  484. MsgFieldStart.STMSampleRetData.iRetDataType = MSAMPLE_RET.START_MSR_FIELD;
  485. MsgFieldStart.STMSampleRetData.SMsrField.FieldPos = poiFieldCentre;
  486. m_pMsrThread.SendMessageToMeasureApp(MsgFieldStart);
  487. int fldNo = completedFields + i + 1;
  488. log.Warn("Current field:" + fldNo.ToString());
  489. // move SEM to the field center
  490. if (!MoveSEMToPoint(poiFieldCentre))
  491. {// failed to move SEM to the position
  492. log.Error("DoMeasure: failed to move SEM to the field centre point.");
  493. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  494. // record end time
  495. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  496. return;
  497. }
  498. log.Info("Begin to Acquire BSE image!");
  499. // take BSE image for the fields
  500. CBSEImgClr pBSEImg = AcquireABSEImage();
  501. // let the main thread to know that image process is completed
  502. if (pBSEImg == null)
  503. {
  504. log.Error("ImageProcess: can't get no background image.");
  505. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  506. return;
  507. }
  508. //BSEData
  509. ST_MSTMsg MsgFieldBSE = new ST_MSTMsg();
  510. MsgFieldBSE.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  511. MsgFieldBSE.STMSampleRetData.iRetDataType = MSAMPLE_RET.BSE_DATA;
  512. MsgFieldBSE.STMSampleRetData.BSEData.pos.X = poiFieldCentre.X;
  513. MsgFieldBSE.STMSampleRetData.BSEData.pos.Y = poiFieldCentre.Y;
  514. MsgFieldBSE.STMSampleRetData.BSEData.iBSEDataHeight = pBSEImg.GetHeight();
  515. MsgFieldBSE.STMSampleRetData.BSEData.iBSEDataWidth = pBSEImg.GetWidth();
  516. byte[] pImgData = pBSEImg.GetImageDataPtr();
  517. MsgFieldBSE.STMSampleRetData.BSEData.lpBSEData = pImgData;
  518. m_pMsrThread.SendMessageToMeasureApp(MsgFieldBSE);
  519. // get a new field id
  520. log.Info("Acquire BSE image success! Processing image...");
  521. // image process
  522. var rst = FieldImageProcess(poiFieldCentre, pBSEImg);
  523. if (rst == true)
  524. {
  525. // add the field into the field
  526. m_pSampleRstFile.AddAField(curFldData);
  527. }
  528. ++nNewFieldId;
  529. double measuredArea = 0; // this area should be the field area
  530. var a_pBSEImg = curFldData.GetBSEImage();
  531. double dPixelSize = m_Sample.CalculatePixelSize();
  532. measuredArea = a_pBSEImg.GetHeight() * a_pBSEImg.GetWidth()* dPixelSize * dPixelSize + 0.5; //Get measured area
  533. if (!CumulateFieldData(curFldData.GetListAnalysisParticles(), measuredArea))
  534. { // failed to call SaveFieldFile method
  535. log.Error("ImageProcess: call CumulateFieldData method.");
  536. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  537. return;
  538. }
  539. log.Info("Send field data to screen!");
  540. // completed fields
  541. pStatus.SetCompletedFields(pStatus.GetCompletedFields() + 1);
  542. // completed fieldCenter
  543. List<System.Drawing.Point> listCpltedCenter = pStatus.GetCompletedFieldsCenter();
  544. listCpltedCenter.Add(poiFieldCentre);
  545. //Field Data
  546. // record end time
  547. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  548. ST_MSTMsg MsgFieldEnd = new ST_MSTMsg();
  549. MsgFieldEnd.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  550. MsgFieldEnd.STMSampleRetData.iRetDataType = MSAMPLE_RET.FIELD_DATA;
  551. MsgFieldEnd.STMSampleRetData.SFieldData.iCompleteFieldCount = pStatus.GetCompletedFields();
  552. MsgFieldEnd.STMSampleRetData.SFieldData.iMeasureFieldCount = numOfAllFields;
  553. MsgFieldEnd.STMSampleRetData.SFieldData.iSParticleCount = (int)curFldData.GetListAnalysisParticles().Count;
  554. MsgFieldEnd.STMSampleRetData.SFieldData.FieldPos.X = Convert.ToInt32(poiFieldCentre.X);
  555. MsgFieldEnd.STMSampleRetData.SFieldData.FieldPos.Y = Convert.ToInt32(poiFieldCentre.Y);
  556. m_pMsrThread.SendMessageToMeasureApp(MsgFieldEnd);
  557. }
  558. while (bSaveThreadWorking)//wait untill all the field data has been saved.
  559. {
  560. Thread.Sleep(1000);
  561. log.Warn("db saving!");
  562. }
  563. //merging particles
  564. log.Info("Merging big particles which are crossing the field edge!");
  565. CImageHandler imgpro = new CImageHandler();
  566. int scanfldsize = m_Sample.GetSEMDataMsr().GetScanFieldSize();
  567. List<COTSParticleClr> mergedParticles = new List<COTSParticleClr>();
  568. double pixelSize = m_Sample.CalculatePixelSize();
  569. imgpro.MergeBigBoundaryParticles(m_pSampleRstFile.GetFieldData(), pixelSize, scanfldsize, m_Sample.GetResolutionSize(), ref mergedParticles);
  570. CalculateMergedPartProperty(mergedParticles,pixelSize);
  571. ClassifyMergedParticles(mergedParticles);
  572. log.Info("begin merged particle data db saving...");
  573. SaveMergedParticles(mergedParticles);
  574. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.COMPLT);
  575. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.SUCCESSED);
  576. // let main thread to know that this sample measurement completes
  577. ST_MSTMsg MsgSmplEnd = new ST_MSTMsg();
  578. MsgSmplEnd.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  579. MsgSmplEnd.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.SUCCESSED;
  580. MsgSmplEnd.STMSampleStu.cSampleName = m_Sample.GetName();
  581. m_pMsrThread.SendMessageToMeasureApp(MsgSmplEnd);
  582. }
  583. }
  584. private void CalculateMergedPartProperty(List<COTSParticleClr> mergedParticles,double pixelSize)
  585. {
  586. var m_ImagePro = new CImageHandler();
  587. foreach (COTSParticleClr part in mergedParticles)
  588. {
  589. m_ImagePro.CalParticleImageProp(part, pixelSize);
  590. }
  591. }
  592. public void DoHolePreview(int a_nHoleID)
  593. {
  594. using (AutoResetSEMControl autoReset = new AutoResetSEMControl(this))
  595. {
  596. // let the main thread to know that this sample measurement starts
  597. CMsrSampleStatus pStatus = m_Sample.GetMsrStatus();
  598. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.INPROCESS);
  599. // set current time to current time
  600. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.START);
  601. // let main App know that the sample begin to measure
  602. ST_MSTMsg MsgSmpStart=new ST_MSTMsg();
  603. MsgSmpStart.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  604. MsgSmpStart.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.INPROCESS;
  605. MsgSmpStart.STMSampleStu.cSampleName=m_Sample.GetName();
  606. // get SEM controller to set magnification and working distance
  607. if (!SetSEMDataMrs())
  608. {
  609. log.Error("DoHolePreview: fail to set SEM data.");
  610. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  611. // record end time
  612. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  613. return;
  614. }
  615. // set the BSE scan param
  616. if (!SetHoleBSEParam())
  617. {
  618. log.Error("DoMeasure: fail to set BSE param.");
  619. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  620. // record end time
  621. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  622. return;
  623. }
  624. // check if measurement is aborted
  625. if (IsAborted())
  626. {// measurement aborted
  627. log.Trace("DoHolePreview: measurement aborted before get SEM condition.");
  628. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.STOPPED);
  629. // record end time
  630. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  631. return;
  632. }
  633. // calculate field centers
  634. List<System.Drawing.Point> listFieldCenter=new List<System.Drawing.Point>();
  635. List<System.Drawing.Point> alllistFieldCenter = new List<System.Drawing.Point>();
  636. // listFieldCenter.clear();
  637. if (!CalculateUnMeasuredFieldsCenters(out alllistFieldCenter,out listFieldCenter))
  638. {// failed to calculate field centers
  639. log.Error("DoHolePreview: failed to calculate field centers.");
  640. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  641. // record end time
  642. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  643. return;
  644. }
  645. // go through each field
  646. int nNewFieldId = 0;
  647. for ( int i = 0; i < listFieldCenter.Count; ++i)
  648. {// check and break if stop button is clicked
  649. if (IsAborted())
  650. {// measure stopped
  651. log.Trace("DoHolePreview: measure thread is stopped.");
  652. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.STOPPED);
  653. // record end time
  654. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  655. return;
  656. }
  657. // check if sample measurement completes
  658. COTSImgScanPrm pScanParam = m_Sample.GetMsrParams().GetImageScanParam();
  659. int nTotalFieldSize = listFieldCenter.Count;
  660. if (IsSampleOver(pScanParam, nTotalFieldSize))
  661. {
  662. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  663. break;
  664. }
  665. // get a field center
  666. System.Drawing.Point poiFieldCentre = listFieldCenter[i];
  667. // update thread measure status class, let the main thread know that starts a new field
  668. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  669. ST_MSTMsg MsgFieldStart=new ST_MSTMsg();
  670. MsgFieldStart.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  671. MsgFieldStart.STMSampleRetData.iRetDataType = MSAMPLE_RET.START_MSR_FIELD;
  672. MsgFieldStart.STMSampleRetData.SMsrField.FieldPos = poiFieldCentre;
  673. m_pMsrThread.SendMessageToMeasureApp(MsgFieldStart);
  674. // move SEM to the field center
  675. if (!MoveSEMToPoint(poiFieldCentre))
  676. {// failed to move SEM to the position
  677. log.Error("DoHolePreview: failed to move SEM to the field centre point.");
  678. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  679. // record end time
  680. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  681. return;
  682. }
  683. // take BSE image for the fields
  684. CBSEImgClr pBSEIamge = AcquireABSEImage();
  685. if (pBSEIamge==null)
  686. {
  687. // failed to acquire a BSE image
  688. log.Error("DoHolePreview: failed to acquire a BSE image.");
  689. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  690. // record end time
  691. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  692. return;
  693. }
  694. //BSEData
  695. ST_MSTMsg MsgFieldBSE=new ST_MSTMsg();
  696. // memset(&MsgFieldBSE, 0, sizeof(ST_MSTMsg));
  697. MsgFieldBSE.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  698. MsgFieldBSE.STMSampleRetData.iRetDataType = MSAMPLE_RET.BSE_DATA;
  699. MsgFieldBSE.STMSampleRetData.BSEData.pos = poiFieldCentre;
  700. //MsgFieldBSE.STMSampleRetData.BSEData.pos.y = poiFieldCentre.y;
  701. MsgFieldBSE.STMSampleRetData.BSEData.iBSEDataHeight = pBSEIamge.GetHeight();
  702. MsgFieldBSE.STMSampleRetData.BSEData.iBSEDataWidth = pBSEIamge.GetWidth();
  703. byte[] pImgData = pBSEIamge.GetImageDataPtr();
  704. MsgFieldBSE.STMSampleRetData.BSEData.lpBSEData = pImgData;
  705. m_pMsrThread.SendMessageToMeasureApp(MsgFieldBSE);
  706. if (pStatus.GetStatus() != OTS_MSR_SAMPLE_STATUS.INPROCESS)
  707. {
  708. // measurement failed or stopped
  709. log.Error("DoHolePreview: measurement failed or stopped.");
  710. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.FAILED);
  711. // record end time
  712. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  713. return;
  714. }
  715. //save the result to project file
  716. Rectangle oImageRect = (Rectangle)pBSEIamge.GetImageRect();
  717. CHoleBSEImg pHoleBSEImg =new CHoleBSEImg(oImageRect,a_nHoleID, poiFieldCentre);
  718. pHoleBSEImg.SetImageData( pBSEIamge.GetImageDataPtr(),oImageRect.Width,oImageRect.Height);
  719. m_listHoleBSEImg.Add(pHoleBSEImg);
  720. COTSMsrPrjResultData pProjMgrFile = m_pMsrThread.GetProjResultData();
  721. pProjMgrFile.SetHoleBESImgList(m_listHoleBSEImg,true);
  722. // prepare for the next
  723. ++nNewFieldId;
  724. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  725. ST_MSTMsg MsgFieldEnd=new ST_MSTMsg();
  726. MsgFieldEnd.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  727. MsgFieldEnd.STMSampleRetData.iRetDataType = MSAMPLE_RET.FIELD_DATA;
  728. MsgFieldEnd.STMSampleRetData.SFieldData.iCompleteFieldCount = (i + 1);
  729. MsgFieldEnd.STMSampleRetData.SFieldData.iMeasureFieldCount = listFieldCenter.Count;
  730. MsgFieldEnd.STMSampleRetData.SFieldData.iSParticleCount = 0;
  731. MsgFieldEnd.STMSampleRetData.SFieldData.FieldPos = poiFieldCentre;
  732. m_pMsrThread.SendMessageToMeasureApp(MsgFieldEnd);
  733. //break;
  734. }
  735. pStatus.ComputeTime(OTS_MSR_TIME_TYPE.STOPPED);
  736. //calculate measure time
  737. pStatus.SetStatus(OTS_MSR_SAMPLE_STATUS.SUCCESSED);
  738. // let main thread to know that this sample measurement completes
  739. ST_MSTMsg MsgSmplEnd=new ST_MSTMsg();
  740. MsgSmplEnd.iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
  741. MsgSmplEnd.STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.COMPLETED;
  742. m_pMsrThread.SendMessageToMeasureApp(MsgSmplEnd);
  743. }
  744. }
  745. // Cumulate field data info
  746. public virtual bool CumulateFieldData( List<COTSParticleClr> listParticles, double a_nMeasuredArea)
  747. {
  748. // get measure result items of the sample
  749. CMsrDisplayResults pMsrResults = m_Sample.GetMsrResults();
  750. // cumulate field data info
  751. //pMsrResults.CumulateMeasureResults(listResultItems);
  752. pMsrResults.CumulateMeasuredArea(a_nMeasuredArea);
  753. // cumulate ratio
  754. double dRatio = 10000 * pMsrResults.GetTotalParticleArea();
  755. dRatio = dRatio / pMsrResults.GetMeasuredArea();
  756. pMsrResults.SetRatio(dRatio);
  757. // go through the particles list
  758. foreach (COTSParticleClr pParticle in listParticles)
  759. {
  760. // create a measure result item
  761. pMsrResults.CumulateMeasureResult(pParticle);
  762. }
  763. // ok, return TRUE
  764. return true;
  765. }
  766. // hole BSE images list
  767. void SetHoleBESImgList(CHoleBSEImgsList a_listHoleBSEImg, bool a_bClear/* = TRUE*/)
  768. {// clear the hole BSE image list if necessary
  769. if (a_bClear)
  770. {
  771. m_listHoleBSEImg.Clear();
  772. }
  773. // go through the input list
  774. foreach (var pHoleBSEImg in a_listHoleBSEImg)
  775. {// add the new hole BSE image into HoleBSEImage list
  776. m_listHoleBSEImg.Add(pHoleBSEImg);
  777. }
  778. }
  779. public bool SaveMergedParticles(List<COTSParticleClr> mergedParts)
  780. {
  781. CIncAFileMgr pDBFileMgr = m_pSampleRstFile.DBFileMgr;
  782. var mergedpartdb = pDBFileMgr.GetMergedParticleDB();
  783. foreach (COTSParticleClr part in mergedParts)
  784. {
  785. mergedpartdb.SaveAParticle(part, part.GetXray(), (Point)part.GetAbsolutPos());
  786. }
  787. CPosXrayDBMgr pXrayDBMgr = pDBFileMgr.GetPosXrayDBMgr();
  788. CElementChemistryDB xraydb = pXrayDBMgr.GetElementChemistryDB();
  789. List<CPosXrayClr> ches = new List<CPosXrayClr>();
  790. foreach (COTSParticleClr part in mergedParts)
  791. {
  792. ches.Add(part.GetXray());
  793. }
  794. xraydb.SaveElementChemistriesList(ches);
  795. return true;
  796. }
  797. public bool SaveFieldData(COTSFieldData fldData, string filedFileFoler)
  798. {
  799. //loger.Warn("begin bitmap saving...");
  800. string strFieldFileFolder = filedFileFoler;
  801. CBSEImageFileMgr pBSEImgFileMgr = new CBSEImageFileMgr();
  802. pBSEImgFileMgr.SetBSEImg(fldData.GetBSEImage());
  803. int nId = fldData.GetId();
  804. string sFieldId;
  805. sFieldId = nId.ToString();
  806. string strBSEFilePathname = strFieldFileFolder + "\\" + m_pSampleRstFile.SMPL_MSR_RESULT_FIELDS_BSE + sFieldId + pBSEImgFileMgr.BMP_IMG_FILE_EXT;
  807. if (!pBSEImgFileMgr.SaveIntoBitmap(strBSEFilePathname))
  808. {
  809. log.Error("SaveFieldFiles: save BSE file failed.");
  810. return false;
  811. }
  812. // IncA Data list
  813. CIncAFileMgr pDBFileMgr = m_pSampleRstFile.DBFileMgr;
  814. pDBFileMgr.SaveStatusDataToDB();
  815. var fldDB = pDBFileMgr.GetFieldDB();
  816. log.Warn("Start saving particle data.");
  817. var fldcmd = fldDB.GetSavingAFieldcmdObj(fldData.GetId(), fldData.GetOTSPosition(), fldData.SemPos);
  818. List<KeyValuePair<string, System.Data.SQLite.SQLiteParameter[]>> fldcmds = new List<KeyValuePair<string, System.Data.SQLite.SQLiteParameter[]>>();
  819. fldcmds.Add(fldcmd);
  820. pDBFileMgr.ExecuteNonQueryBatch(ref fldcmds);
  821. //remomove the invalid particles
  822. var cmds = pDBFileMgr.GetSavingIncADataToDBCmds(curFldData.GetListAnalysisParticles(), fldData.GetOTSPosition());
  823. pDBFileMgr.ExecuteNonQueryBatch(ref cmds);
  824. CPosXrayDBMgr PosXrayDBMgr = pDBFileMgr.GetPosXrayDBMgr();
  825. var listAnalysisPosXray = new List<CPosXrayClr>();
  826. foreach (var p in curFldData.GetListXrayParticles())
  827. {
  828. listAnalysisPosXray.Add(p.GetXray());
  829. }
  830. var cmds1 = PosXrayDBMgr.GetSavingXrayCmds(listAnalysisPosXray, true);
  831. pDBFileMgr.ExecuteNonQueryBatch(ref cmds1);
  832. return true;
  833. }
  834. protected void SaveFieldMgrData()
  835. {
  836. while (bSaveThreadWorking)
  837. {
  838. while (fieldQueue.Count() > 0)
  839. {
  840. COTSFieldData f = fieldQueue.Dequeue();
  841. //save to disk first ,then pop . if the size is 0,then we know all the saving work is done.
  842. SaveFieldData(f, m_pSampleRstFile.GetFieldFileSubFolderStr());
  843. }
  844. if (fieldQueue.Count() == 0)
  845. {
  846. bSaveThreadWorking = false; //must set this flag,so the main thread can know this thread has exited.
  847. log.Warn("finished batch saving");
  848. return;
  849. }
  850. }
  851. return;
  852. }
  853. protected void StartSaveFileThread(COTSFieldData a_pFieldMgr)
  854. {
  855. fieldQueue.Enqueue(a_pFieldMgr);
  856. if (fieldQueue.Count() > 0) //if there's data in the queue and the previous thread has finished then start a new thread.
  857. {
  858. if (bSaveThreadWorking == false)
  859. {
  860. bSaveThreadWorking = true;
  861. m_thread_ptr = new System.Threading.Thread(this.SaveFieldMgrData);//m_thread_ptr = shared_ptr<thread>(new thread(&CSmplMeasureInc::SaveFieldMgrData, this));
  862. m_thread_ptr.IsBackground = true;
  863. m_thread_ptr.Start();
  864. }
  865. }
  866. }
  867. public void ParticleSpecialTreatment(COTSFieldData fld)
  868. {
  869. //we adopt such a strategy here:if some particles satisfy the predefined condition then we go through the second collecting with max EDS time,so that we got a more acurate result.
  870. Dictionary<COTSParticleClr, int> mapPartXray = new Dictionary<COTSParticleClr, int>(); //std.map<COTSParticlePtr, int> mapPartXray = new std.map<COTSParticlePtr, int>();
  871. double edsTime = 0; //to store the EDSTime returned from the engine.
  872. var bigparts = fld.GetListXrayParticles();
  873. var m_ClassifyEngine = new CClassifyEngine();
  874. for (int i = 0; i < bigparts.Count(); i++)
  875. {
  876. var engine = m_ClassifyEngine.GetParticleEngine(m_Sample.GetMsrParams().GetSTDName());
  877. var p = bigparts[i];
  878. // there will be very less particle satisfied the condition ,so we use only one MaxEDS time,though we set MaxEDSTime for every rule separately .Here we store the last one.
  879. //if the particle satisfied the MaxEDS condition then we go through the second colleting.Here we record the particle and the EDSTime and the corresponding xray position.
  880. edsTime = engine.IfNeedMaxEDS(p);
  881. if (edsTime > 0)
  882. {
  883. mapPartXray[p] = i;
  884. }
  885. }
  886. List<COTSParticleClr> partsMax = new List<COTSParticleClr>();
  887. if (mapPartXray.Count() > 0)
  888. {
  889. foreach (var p in mapPartXray)
  890. {
  891. partsMax.Add(p.Key);
  892. }
  893. List<CPosXrayClr> maxEDSXrays = new List<CPosXrayClr>();
  894. m_EDSHardwareMgr.GetXRayByFeatures(partsMax, edsTime, true);
  895. }
  896. }
  897. public void CalculateParticleAbsolutPos()
  898. {
  899. double dPixelSize = m_Sample.CalculatePixelSize();
  900. CSEMStageData pCSEMStageData = m_pMsrThread.GetProjResultData().GetSEMStageData();
  901. foreach (var p in curFldData.GetListAnalysisParticles())
  902. {
  903. Point fldOtsPos = new Point(curFldData.OTSPos.X, curFldData.OTSPos.Y);
  904. Point semPos = new Point();
  905. pCSEMStageData.ConverOTSToSEMPoint(fldOtsPos, ref semPos);
  906. p.SetAbsolutPos(semPos);
  907. }
  908. }
  909. }
  910. }