COTSMsrPrjResultData.cs 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625
  1. using OTSDataType;
  2. using OTSModelSharp.ServiceInterface;
  3. using OTSModelSharp.DTLBase;
  4. using OTSModelSharp.ImageProcess;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Drawing;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows;
  13. using System.Windows.Forms;
  14. using static OTSDataType.otsdataconst;
  15. using System.Xml;
  16. using OTSCLRINTERFACE;
  17. using OTSModelSharp.ServiceCenter;
  18. namespace OTSModelSharp
  19. {
  20. public class COTSMsrPrjResultData
  21. {
  22. // SEM stage data
  23. CSEMStageData m_pSEMStageData;
  24. //// stage
  25. CStage m_pStage;
  26. // general parameter
  27. COTSGeneralParam m_GenParam;
  28. // sample list
  29. List<COTSSample> m_listSamples = new List<COTSSample>();
  30. List<CHoleBSEImg> m_listHoleBSEImg = new List<CHoleBSEImg>();
  31. bool m_bModify;
  32. // path name
  33. String m_strPathName;
  34. // working sample index
  35. int m_nWorkingSampeIndex;
  36. const String UNTITLED_FILE_NAME = "Untitled";
  37. const String SMPL_MSR_RESULT_FIELDS_FILE_SUBFOLDER = "FIELD_FILES";
  38. // Inclusion file name
  39. const String SMPL_MSR_RESULT_INCLUSION_FILE = "Inclusion.db";//put all the table in one db file so that report can make join query.
  40. public otsdataconst.OTS_SysType_ID m_nPackId;
  41. public COTSMsrPrjResultData()
  42. {
  43. Init();
  44. }
  45. // initialization
  46. public void Init()
  47. {
  48. m_listSamples.Clear();
  49. m_listHoleBSEImg.Clear();
  50. m_bModify = false;
  51. m_strPathName = "";
  52. m_nWorkingSampeIndex = -1;
  53. }
  54. // duplication
  55. public void Duplicate(COTSMsrPrjResultData a_oSource)
  56. {
  57. // initialization
  58. Init();
  59. // copy data over
  60. m_pSEMStageData = new CSEMStageData(a_oSource.m_pSEMStageData);
  61. m_pStage = new CStage(a_oSource.m_pStage);
  62. foreach (var pHoleBSEImg in a_oSource.m_listHoleBSEImg)
  63. {
  64. CHoleBSEImg pHoleBSEImgNew = (new CHoleBSEImg(pHoleBSEImg));
  65. m_listHoleBSEImg.Add(pHoleBSEImgNew);
  66. }
  67. foreach (var pSample in a_oSource.m_listSamples)
  68. {
  69. COTSSample pSampleNew = new COTSSample();
  70. m_listSamples.Add(pSampleNew);
  71. }
  72. m_bModify = a_oSource.m_bModify;
  73. m_strPathName = a_oSource.m_strPathName;
  74. m_nWorkingSampeIndex = a_oSource.m_nWorkingSampeIndex;
  75. }
  76. // file
  77. public void SetPathName(String a_strPathName) { m_strPathName = a_strPathName; }
  78. public bool Load()
  79. {
  80. String strPathName = "";
  81. strPathName.Trim();
  82. if (strPathName == "")
  83. {
  84. // file open dialog
  85. OpenFileDialog openFileDialog = new OpenFileDialog();
  86. if (openFileDialog.ShowDialog() != DialogResult.OK)
  87. {
  88. return false;
  89. }
  90. strPathName = openFileDialog.FileName;
  91. }
  92. //Init data
  93. Cleanup();
  94. // check if the file exist
  95. if (!FileExists(strPathName))
  96. {
  97. // shouldn't happen, file does not exist
  98. return false;
  99. }
  100. //获取测量项目文件
  101. XmlDocument doc = new XmlDocument();
  102. //载入xml文件
  103. doc.Load(strPathName);
  104. XmlNode root = doc.SelectSingleNode("XMLData");
  105. Serialize(false, doc, root);
  106. //设置测量项目文件路径
  107. m_strPathName = strPathName;
  108. //-------------
  109. foreach (var smpl in m_listSamples)
  110. {
  111. // get path of the pathname
  112. String strFilePath = GetFolderName(strPathName);
  113. if (strFilePath == "")
  114. {
  115. // file path string is an empty string
  116. return false;
  117. }
  118. // field file sub folder string
  119. String strFieldFileSubFolder = strFilePath + "\\" + smpl.GetName() + "\\" + SMPL_MSR_RESULT_FIELDS_FILE_SUBFOLDER + "\\";
  120. // check if the field file sub folder exists
  121. if (!DirectoryExists(strFieldFileSubFolder))
  122. {// field files folder doesn't exist
  123. continue;
  124. }
  125. String strIncAFilename = strFieldFileSubFolder + "\\" + SMPL_MSR_RESULT_INCLUSION_FILE;
  126. CIncAFileMgr pIncAFileMgr = new CIncAFileMgr(strIncAFilename);
  127. List<COTSFieldData> allFlds = new List<COTSFieldData>();
  128. CMsrSampleStatus poMsrStatus = new CMsrSampleStatus();
  129. poMsrStatus.GetStatus();
  130. CMsrDisplayResults poMsrResults = smpl.GetMsrResults();
  131. double aFldArea = smpl.CalculateAFieldArea();
  132. SetPathName(strIncAFilename);
  133. if (GetAllFieldsFromDB(ref allFlds, poMsrStatus, poMsrResults, aFldArea))
  134. {
  135. smpl.SetFieldsData(allFlds);
  136. // file validation
  137. smpl.SetMsrStatus(poMsrStatus);
  138. smpl.SetMsrResults(poMsrResults);
  139. // set pathname
  140. SetPathName(strPathName);
  141. // set working sample
  142. if (m_listSamples.Count > 0)
  143. {
  144. m_nWorkingSampeIndex = 0;
  145. }
  146. else
  147. {
  148. m_nWorkingSampeIndex = -1;
  149. }
  150. }
  151. else
  152. {
  153. return false;
  154. }
  155. }
  156. if (m_listSamples != null)
  157. {
  158. if (m_listSamples.Count > 0)
  159. {
  160. m_nWorkingSampeIndex = 0;
  161. }
  162. }
  163. //-----------------------------------------
  164. return true;
  165. }
  166. // gets the name of the folder
  167. public String GetFolderName(String a_strPathName)
  168. {
  169. string str = "";
  170. str = Path.GetDirectoryName(a_strPathName);
  171. return str.ToString();
  172. }
  173. public bool FileExists(string a_sPath)
  174. {
  175. bool b_IsExists = File.Exists(a_sPath);
  176. return b_IsExists;
  177. }
  178. public bool DirectoryExists(string a_sPath)
  179. {
  180. bool b_IsExists = Directory.Exists(a_sPath);
  181. return b_IsExists;
  182. }
  183. // cleanup
  184. public void Cleanup()
  185. {
  186. m_listHoleBSEImg.Clear();
  187. m_listSamples.Clear();
  188. m_bModify = false;
  189. m_strPathName = "";
  190. m_nWorkingSampeIndex = -1;
  191. }
  192. // set modify flag
  193. public void SetModify(bool a_bModify = true) { m_bModify = a_bModify; }
  194. // file pathname
  195. public String GetPathName() { return m_strPathName; }
  196. public bool GetAllFieldsFromDB(ref List<COTSFieldData> allFlds, CMsrSampleStatus status, CMsrDisplayResults rst, double aFieldArea)
  197. {
  198. String sDatabaseName = m_strPathName;
  199. if (!FileExists(sDatabaseName))
  200. {
  201. return false;
  202. }
  203. List<System.Drawing.Point> completedflds = new List<System.Drawing.Point>();
  204. CIncAFileMgr incAFileMgr = new CIncAFileMgr(sDatabaseName);
  205. var m_IncADataDB = incAFileMgr.GetIncADB();
  206. m_IncADataDB.GetAllFieldsRecord(ref allFlds);
  207. var eleChemistryDB = incAFileMgr.GetPosXrayDBMgr().GetElementChemistryDB();
  208. Dictionary<string, CPosXrayClr> mapXrayInfo=new Dictionary<string, CPosXrayClr>();
  209. eleChemistryDB.GetAllMapedXrayInfo(ref mapXrayInfo);
  210. foreach (var f in allFlds)
  211. {
  212. foreach (var p in f.GetListAnalysisParticles())
  213. {
  214. int curFldId = f.GetId();
  215. int xrayId = p.GetAnalysisId();
  216. string fldvec="";
  217. fldvec+=curFldId.ToString();
  218. fldvec+="_";
  219. fldvec += xrayId.ToString();
  220. //auto cXray = mapXrayInfo.find(fldvec);
  221. if (mapXrayInfo.ContainsKey(fldvec))
  222. {
  223. var xray = mapXrayInfo[fldvec];
  224. p.SetXray(xray);
  225. }
  226. }
  227. }
  228. var xrayDataDBDB = incAFileMgr.GetPosXrayDBMgr().GetXrayDataDB();
  229. Dictionary<string, CPosXrayClr> mapXrayData=new Dictionary<string, CPosXrayClr>();// map structure:[(fieldId,xrayId),CPosXrayPtr],every element of this map represent one unique xraydata.
  230. xrayDataDBDB.GetAllMapedXrayData(ref mapXrayData);
  231. foreach (var f in allFlds)
  232. {
  233. foreach (var p in f.GetListAnalysisParticles())
  234. {
  235. int curFldId = f.GetId();
  236. int xrayId = p.GetAnalysisId();
  237. string fldvec="";
  238. fldvec+=curFldId.ToString();
  239. fldvec += "_";
  240. fldvec += xrayId.ToString();
  241. //auto cXray = mapXrayData.find(fldvec);
  242. if (mapXrayData.ContainsKey(fldvec))
  243. {
  244. var xray = mapXrayData[fldvec];
  245. CPosXrayClr t2 = p.GetXray();
  246. if (t2 == null)
  247. {
  248. t2 =new CPosXrayClr();
  249. p.SetXray(t2);
  250. }
  251. t2.SetXrayData(xray.GetXrayData());
  252. }
  253. }
  254. }
  255. CSegmentDB SegmentDB = incAFileMgr.GetSegmentDB();
  256. double msrFldsArea = 0;
  257. Dictionary<int, List<COTSParticleClr>> mapTypeParticles = new Dictionary<int,List<COTSParticleClr>>();//record typeId relevants particlelist;
  258. List<COTSSegmentClr> AllSegments = new List<COTSSegmentClr>();
  259. Dictionary<string, List<COTSSegmentClr>> mapSegments = new Dictionary<string, List<COTSSegmentClr>>();
  260. if (SegmentDB.GetAllSegmentsRecord(mapSegments))
  261. {
  262. foreach (var fld in allFlds)
  263. {
  264. int fldId = fld.GetId();
  265. List<COTSParticleClr> parts = fld.GetListAnalysisParticles();
  266. foreach (var part in parts)
  267. {
  268. string fldvec = "";
  269. fldvec+=fldId.ToString();
  270. fldvec += "_";
  271. fldvec+=part.GetTagId().ToString();
  272. if (mapSegments.ContainsKey(fldvec))
  273. {
  274. COTSFeatureClr f = new COTSFeatureClr();
  275. AllSegments = mapSegments[fldvec];
  276. f.SetSegmentsList(AllSegments, true);
  277. part.SetFeature(f);
  278. if (mapTypeParticles.ContainsKey(part.GetType()))
  279. {
  280. mapTypeParticles[part.GetType()].Add(part);
  281. }
  282. else
  283. {
  284. List<COTSParticleClr> ps = new List<COTSParticleClr>();
  285. ps.Add(part);
  286. mapTypeParticles.Add(part.GetType(), ps);
  287. }
  288. }
  289. msrFldsArea += aFieldArea;
  290. }
  291. completedflds.Add(fld.GetOTSPosition());
  292. }
  293. // get MsrStatus info from DB.
  294. var m_GenInfoDB = incAFileMgr.GetGeneralInfoDB();//DBStoreFile类
  295. String strTimeStart = "";
  296. String strTimeEnd = "";
  297. String strRstStatus = "";
  298. m_GenInfoDB.GetStringValue(m_GenInfoDB.GetTableItemNameTimeStart(), ref strTimeStart);
  299. m_GenInfoDB.GetStringValue(m_GenInfoDB.GetTableItemNameTimeEnd(), ref strTimeEnd);
  300. m_GenInfoDB.GetStringValue(m_GenInfoDB.GetTableItemNameResultStatus(), ref strRstStatus);
  301. status.SetCompletedFieldsCenter(completedflds);
  302. //status.SetCompletedFields(completedflds.Count);
  303. DateTime timeStart, timeEnd;
  304. try
  305. {
  306. timeStart = Convert.ToDateTime(ConvertFormatOfDateString(strTimeStart)); //此处为兼容之前得测量得结果可以打开,故在此进行数据格式变换
  307. timeEnd = Convert.ToDateTime(ConvertFormatOfDateString(strTimeEnd));
  308. }
  309. catch
  310. {
  311. timeStart = Convert.ToDateTime(strTimeStart); //此处为兼容之前得测量得结果可以打开,故在此进行数据格式变换
  312. timeEnd = Convert.ToDateTime(strTimeEnd);
  313. }
  314. status.SetStartTime(timeStart);
  315. status.SetEndTime(timeEnd);
  316. status.SetUsedTime(timeEnd - timeStart);
  317. status.SetStatus((OTS_MSR_SAMPLE_STATUS)Convert.ToInt32(strRstStatus));
  318. //get MsrResults data from map.
  319. List<CMsrResultItem> rstItms = new List<CMsrResultItem>();
  320. double allPartArea = 0;
  321. int typeNum = 0;
  322. double typeArea = 0;
  323. foreach (var typeParticles in mapTypeParticles)
  324. {
  325. CMsrResultItem rstItm = new CMsrResultItem();
  326. foreach (var p in typeParticles.Value)
  327. {
  328. typeNum += 1;
  329. typeArea +=p.GetActualArea();
  330. }
  331. rstItm.SetTypeId(typeParticles.Key);
  332. rstItm.SetNumber((uint)typeNum);
  333. rstItm.SetArea((uint)typeArea);
  334. rstItms.Add(rstItm);
  335. allPartArea += typeArea;
  336. }
  337. rst.SetResultItems(rstItms);
  338. rst.SetMeasuredArea(Convert.ToUInt64(msrFldsArea * 1000000));
  339. rst.SetRatio(allPartArea / (msrFldsArea * 1000000));
  340. return true;
  341. }
  342. return false;
  343. }
  344. string ConvertFormatOfDateString(string Time)
  345. {
  346. string[] str1 = Time.Split(' ');
  347. string[] str2 = str1[0].Split('/');
  348. return str2[2] + "/" + str2[1] + "/" + str2[0] +" "+ str1[1];
  349. }
  350. public bool Save()
  351. {
  352. // Save or Save As, if strPathName is not empty, it is exist in the computer, this is a save action
  353. String strPathName = GetPathName();
  354. if (strPathName.CompareTo(UNTITLED_FILE_NAME) == 0)
  355. {
  356. // this is a new file
  357. // return save as result
  358. return SaveAs();
  359. }
  360. // is this a new file?
  361. strPathName.Trim();
  362. //保存测量项目文件 .prj
  363. XmlDocument doc = new XmlDocument();
  364. doc.Load(strPathName);
  365. doc.RemoveAll();
  366. //添加xml文件头申明
  367. XmlDeclaration xmldecl = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
  368. doc.AppendChild(xmldecl);
  369. XmlElement rootNode = doc.CreateElement("XMLData");
  370. doc.AppendChild(rootNode);
  371. Serialize(true, doc, rootNode);
  372. try
  373. {
  374. doc.Save(strPathName);
  375. }
  376. catch
  377. {
  378. return false;
  379. }
  380. // set file modify flag
  381. SetModify(false);
  382. // Ok, return TRUE
  383. return true;
  384. }
  385. public bool SaveAs()
  386. {
  387. // get file name
  388. String strPathName = "";
  389. // file open dialog
  390. SaveFileDialog saveFileDialog = new SaveFileDialog();
  391. saveFileDialog.FileName = m_strPathName.Split('\\')[m_strPathName.Split('\\').Length-1];
  392. saveFileDialog.Filter = "Probject Files (*.prj)|*.prj|All files (*.*)|*.*";
  393. if (saveFileDialog.ShowDialog() != DialogResult.OK)
  394. {
  395. return false;
  396. }
  397. // get file pathname
  398. strPathName = saveFileDialog.FileName;
  399. //保存测量项目文件 .prj
  400. XmlDocument doc = new XmlDocument();
  401. //添加xml文件头申明
  402. XmlDeclaration xmldecl = doc.CreateXmlDeclaration("1.0", "UTF-8", null);
  403. doc.AppendChild(xmldecl);
  404. XmlElement rootNode = doc.CreateElement("XMLData");
  405. doc.AppendChild(rootNode);
  406. Serialize(true, doc, rootNode);
  407. try
  408. {
  409. doc.Save(strPathName);
  410. }
  411. catch
  412. {
  413. return false;
  414. }
  415. // set file modify flag
  416. m_bModify = false;
  417. // Set project Path
  418. SetPathName(strPathName);
  419. // Ok, return TRUE
  420. return true;
  421. }
  422. // SEM stage data
  423. public CSEMStageData GetSEMStageData() { return m_pSEMStageData; }
  424. // SEM stage data
  425. public void SetSEMStageData(CSEMStageData a_pCSEMStageData)
  426. {
  427. m_pSEMStageData = a_pCSEMStageData;
  428. }
  429. // stage
  430. public CStage GetStage() { return m_pStage; }
  431. public void SetStage(CStage a_pStage)
  432. {
  433. m_pStage = new CStage(a_pStage);
  434. }
  435. // samples list
  436. public List<COTSSample> GetSampleList() { return m_listSamples; }
  437. // samples list
  438. //public bool SetSampleList(List<COTSSample> a_listSample, bool a_bClear/* = TRUE*/)
  439. //{
  440. // // clear samples list if necessary
  441. // if (a_bClear)
  442. // {
  443. // m_listSamples.Clear();
  444. // }
  445. // // go through the sample list of the source
  446. // foreach (var pSample in a_listSample)
  447. // {
  448. // // add the new sample into sample list
  449. // m_listSamples.Add(pSample);
  450. // }
  451. // return true;
  452. //}
  453. public COTSSample GetSampleByIndex(int a_nIndex)
  454. {
  455. // safe check
  456. if (a_nIndex < 0 || a_nIndex >= (int)m_listSamples.Count)
  457. {
  458. // invalid sample id
  459. return null;
  460. }
  461. // get the matching sample
  462. COTSSample pSample = m_listSamples[a_nIndex];
  463. // return the sample
  464. return pSample;
  465. }
  466. public COTSSample GetSampleByName(String a_strSampleName)
  467. {
  468. bool IsChanged = false;
  469. COTSSample pOTSSample = null;
  470. for (int itr = 0; itr < m_listSamples.Count; itr++)
  471. {
  472. if (m_listSamples[itr].GetName() == a_strSampleName)
  473. {
  474. pOTSSample = m_listSamples[itr];
  475. //m_listSamples.RemoveAt(itr);
  476. IsChanged = true;
  477. }
  478. }
  479. if (IsChanged)
  480. {
  481. return pOTSSample;
  482. }
  483. return m_listSamples[0];
  484. }
  485. public void AddSample(COTSSample pSample)
  486. {
  487. // add the new sample into the samples list
  488. m_listSamples.Add(pSample);
  489. // set the project file modified.
  490. SetModify();
  491. // set the new as working sample
  492. m_nWorkingSampeIndex = (int)m_listSamples.Count - 1;
  493. // return the new sample
  494. }
  495. // get new sample name
  496. public bool DeleteSampleByIndex(int a_nIndex)
  497. {
  498. // check the index
  499. if (a_nIndex < 0 || a_nIndex >= (int)m_listSamples.Count)
  500. {
  501. // invalid input sample index
  502. return true;
  503. }
  504. // calculate new working sample index
  505. int nNewWorkingSampeIndex;
  506. if (a_nIndex < m_nWorkingSampeIndex)
  507. {
  508. nNewWorkingSampeIndex = m_nWorkingSampeIndex - 1;
  509. }
  510. else if (a_nIndex > m_nWorkingSampeIndex)
  511. {
  512. nNewWorkingSampeIndex = m_nWorkingSampeIndex;
  513. }
  514. else
  515. {
  516. // deleting working sample.
  517. if (a_nIndex == (int)m_listSamples.Count - 1)
  518. {
  519. // this is the last sample, select the above sample as working sample
  520. // if this is only sample in the list working sample index will be -1;
  521. nNewWorkingSampeIndex = m_nWorkingSampeIndex - 1;
  522. }
  523. else
  524. {
  525. // select next sample as working sample
  526. nNewWorkingSampeIndex = m_nWorkingSampeIndex;
  527. }
  528. }
  529. // delete the sample
  530. for (int i = m_listSamples.Count - 1; i >= 0; i--)
  531. {
  532. if (i == a_nIndex)
  533. {
  534. m_listSamples.Remove(m_listSamples[i]);
  535. break;
  536. }
  537. }
  538. // the file is modified.
  539. SetModify();
  540. // reset working sample index
  541. m_nWorkingSampeIndex = nNewWorkingSampeIndex;
  542. // ok, return TRUE
  543. return true;
  544. }
  545. public bool ChangeParamFromList(int iNamePos)
  546. {
  547. throw new NotImplementedException();
  548. }
  549. public bool GetParamFileList(ref int iNamePos, ref List<string> mParamFileNameList)
  550. {
  551. throw new NotImplementedException();
  552. }
  553. public bool DeleteSampleByName(String a_strSampleName)
  554. {
  555. // check input sample name
  556. a_strSampleName.Trim();
  557. if (a_strSampleName == "")
  558. {
  559. // input sample name is empty
  560. return false;
  561. }
  562. // go through sample list
  563. int nIndex = 0;
  564. foreach (var pSample in m_listSamples)
  565. {
  566. // return TRUE if this is not an exclude sample and its name is same with input
  567. String strSampleName = pSample.GetName();
  568. if (strSampleName.CompareTo(a_strSampleName) == 0)
  569. {
  570. // find the sample, return deleting result
  571. return DeleteSampleByIndex(nIndex);
  572. }
  573. ++nIndex;
  574. }
  575. // can't find the sample in the samples list, return FALSE
  576. return false;
  577. }
  578. public bool ResetSamplesListOrder(List<String> a_listSampleNames)
  579. {
  580. // no sample in the samples list; shouldn't be here
  581. if (m_listSamples.Count == 0)
  582. {
  583. return false;
  584. }
  585. // make sure that input sample names list size is same with the samples list
  586. if (m_listSamples.Count != a_listSampleNames.Count)
  587. {
  588. return false;
  589. }
  590. // new sample list
  591. List<COTSSample> listSamples = new List<COTSSample>();
  592. // go through the sample names list
  593. foreach (var strSampleName in a_listSampleNames)
  594. {
  595. bool IsChanged = false;
  596. for (int itr = 0; itr < m_listSamples.Count; itr++)
  597. {
  598. if (m_listSamples[itr].GetName() == strSampleName)
  599. {
  600. COTSSample pElementChemistry = m_listSamples[itr];
  601. IsChanged = true;
  602. }
  603. }
  604. if (!IsChanged)
  605. {
  606. return false;
  607. }
  608. }
  609. // reset the samples list
  610. m_listSamples.Clear();
  611. foreach (var pSample in listSamples)
  612. {
  613. m_listSamples.Add(pSample);
  614. }
  615. // set modify flag
  616. SetModify();
  617. // Ok, return TRUE
  618. return true;
  619. }
  620. public bool InsrtSample(COTSSample a_pSample, int a_nIndex)
  621. {
  622. // input check
  623. if (a_pSample != null)
  624. {
  625. // invalid input sample pointer
  626. return false;
  627. }
  628. if (m_listSamples.Count == 0 || a_nIndex >= (int)m_listSamples.Count)
  629. {
  630. m_listSamples.Add(a_pSample);
  631. }
  632. else if (a_nIndex <= 0)
  633. {
  634. m_listSamples.Insert(Convert.ToInt32(m_listSamples[a_nIndex]), a_pSample);
  635. }
  636. else
  637. {
  638. m_listSamples.Insert(Convert.ToInt32(m_listSamples[a_nIndex]) + a_nIndex, a_pSample);
  639. }
  640. // Ok, return TRUE
  641. return true;
  642. }
  643. public bool ChangeSamplePosition(int a_nIndexFrom, int a_nIndexTo)
  644. {
  645. // make sure both index are valid
  646. if (a_nIndexFrom < 0 || a_nIndexFrom >= (int)m_listSamples.Count)
  647. {
  648. // invalid from index
  649. return false;
  650. }
  651. if (a_nIndexTo < 0 || a_nIndexTo >= (int)m_listSamples.Count)
  652. {
  653. // invalid to index
  654. return false;
  655. }
  656. // need to do nothing if the two indexes are the same
  657. if (a_nIndexFrom != a_nIndexTo)
  658. {
  659. // move to last?
  660. bool bLast = (a_nIndexTo == ((int)m_listSamples.Count - 1));
  661. // get the sample
  662. COTSSample pSample = m_listSamples[a_nIndexFrom];
  663. // remove it from the samples list
  664. m_listSamples.Remove(pSample);
  665. // put the sample back in
  666. if (bLast)
  667. {
  668. m_listSamples.Add(pSample);
  669. }
  670. else
  671. {
  672. m_listSamples.Insert(Convert.ToInt32(m_listSamples[a_nIndexTo]) + a_nIndexTo, pSample);
  673. }
  674. }
  675. // Ok, return TRUE
  676. return true;
  677. }
  678. public bool MoveSamplePosition(COTSSample a_pTargetSample, COTSSample a_RefpSample, bool a_bBefore /*= TRUE*/)
  679. {
  680. // check input
  681. if (a_pTargetSample != null)
  682. {
  683. // invalid input target sample pointer
  684. return false;
  685. }
  686. if (a_RefpSample != null)
  687. {
  688. // invalid input ref sample pointer
  689. return false;
  690. }
  691. bool IsChanged = false;
  692. for (int itr = 0; itr < m_listSamples.Count; itr++)
  693. {
  694. if (m_listSamples[itr].GetName() == a_pTargetSample.GetName())
  695. {
  696. COTSSample pElementChemistry = m_listSamples[itr];
  697. // m_listSamples.RemoveAt(itr);
  698. IsChanged = true;
  699. }
  700. }
  701. if (!IsChanged)
  702. {
  703. return false;
  704. }
  705. for (int itr = 0; itr < m_listSamples.Count; itr++)
  706. {
  707. if (m_listSamples[itr].GetName() == a_RefpSample.GetName())
  708. {
  709. COTSSample pElementChemistry = m_listSamples[itr];
  710. //m_listSamples.RemoveAt(itr);
  711. IsChanged = true;
  712. }
  713. }
  714. if (!IsChanged)
  715. {
  716. return false;
  717. }
  718. // remove the sample from the samples list
  719. for (int itr = 0; itr < m_listSamples.Count; itr++)
  720. {
  721. if (m_listSamples[itr].GetName() == a_RefpSample.GetName())
  722. {
  723. COTSSample pElementChemistry = m_listSamples[itr];
  724. //m_listSamples.RemoveAt(itr);
  725. IsChanged = true;
  726. }
  727. }
  728. if (!IsChanged)
  729. {
  730. return false;
  731. }
  732. // put the sample back in
  733. if (a_bBefore)
  734. {
  735. m_listSamples.Insert(0, a_pTargetSample);
  736. }
  737. else
  738. {
  739. m_listSamples.Insert(1, a_pTargetSample);
  740. }
  741. // Ok, return TRUE
  742. return true;
  743. }
  744. public bool MoveSamplePosition(String a_strTargetSampleName, String a_strRefSampleName, bool a_bBefore /*= TRUE*/)
  745. {
  746. // input check
  747. a_strTargetSampleName.Trim();
  748. if (a_strTargetSampleName == "")
  749. {
  750. // input target sample is an empty string
  751. return false;
  752. }
  753. a_strRefSampleName.Trim();
  754. if (a_strRefSampleName == "")
  755. {
  756. // input ref sample is an empty string
  757. return false;
  758. }
  759. bool IsChanged = false;
  760. for (int itr = 0; itr < m_listSamples.Count; itr++)
  761. {
  762. if (m_listSamples[itr].GetName() == a_strTargetSampleName)
  763. {
  764. COTSSample pElementChemistry = m_listSamples[itr];
  765. IsChanged = true;
  766. }
  767. }
  768. if (!IsChanged)
  769. {
  770. return false;
  771. }
  772. COTSSample pTargetSample = m_listSamples[0];
  773. for (int itr = 0; itr < m_listSamples.Count; itr++)
  774. {
  775. if (m_listSamples[itr].GetName() == a_strTargetSampleName)
  776. {
  777. COTSSample pElementChemistry = m_listSamples[itr];
  778. IsChanged = true;
  779. }
  780. }
  781. if (!IsChanged)
  782. {
  783. return false;
  784. }
  785. COTSSample pRefSample = pTargetSample;
  786. // need to do nothing if the two name are same
  787. if (a_strTargetSampleName.CompareTo(a_strRefSampleName) != 0)
  788. {
  789. return MoveSamplePosition(pTargetSample, pRefSample, a_bBefore);
  790. }
  791. // Ok, return TRUE
  792. return true;
  793. }
  794. public COTSSample GetWorkingSample()
  795. {
  796. return GetSampleByIndex(m_nWorkingSampeIndex);
  797. }
  798. int GetWorkingSampleIndex() { return m_nWorkingSampeIndex; }
  799. void SetWorkingSampleIndex(int a_nWorkingSampleIndex) { m_nWorkingSampeIndex = a_nWorkingSampleIndex; }
  800. public bool SetWorkingSampleByIndex(int a_nIndex)
  801. {
  802. // special treatment
  803. if (a_nIndex == -1 && m_listSamples.Count == 0)
  804. {
  805. m_nWorkingSampeIndex = -1;
  806. return true;
  807. }
  808. // check if the working sample index
  809. if (0 > a_nIndex || a_nIndex >= (int)m_listSamples.Count)
  810. {
  811. // invalid sample index
  812. return false;
  813. }
  814. m_nWorkingSampeIndex = a_nIndex;
  815. return true;
  816. }
  817. public bool SetWorkingSampleByName(String a_pSampleName)
  818. {
  819. // check input sample name
  820. a_pSampleName.Trim();
  821. if (a_pSampleName == "")
  822. {
  823. // input sample name is empty
  824. return false;
  825. }
  826. // go through sample list
  827. int nIndex = 0;
  828. foreach (var pSample in m_listSamples)
  829. {
  830. // return TRUE if this is not an exclude sample and its name is same with input
  831. String strSampleName = pSample.GetName();
  832. if (strSampleName.CompareTo(a_pSampleName) == 0)
  833. {
  834. // find the sample, return deleting result
  835. return SetWorkingSampleByIndex(nIndex);
  836. }
  837. ++nIndex;
  838. }
  839. // failed to find the named sample
  840. // failed to find the named sample return FALSE
  841. return false;
  842. }
  843. public bool DeleteWorkingSample()
  844. {
  845. // check if the working sample index
  846. if (m_nWorkingSampeIndex < 0 || m_nWorkingSampeIndex >= (int)m_listSamples.Count)
  847. {
  848. // invalid working sample index
  849. return false;
  850. }
  851. // return the result of DeleteSampleByIndex
  852. return DeleteSampleByIndex(m_nWorkingSampeIndex);
  853. }
  854. // Sample hole BSE image list
  855. public List<CHoleBSEImg> GetHoleBESImgList() { return m_listHoleBSEImg; }
  856. // hole BSE images list
  857. public void SetHoleBESImgList(List<CHoleBSEImg> a_listHoleBSEImg, bool a_bClear/* = TRUE*/)
  858. {
  859. // clear the hole BSE image list if necessary
  860. if (a_bClear)
  861. {
  862. m_listHoleBSEImg.Clear();
  863. }
  864. m_listHoleBSEImg = a_listHoleBSEImg;
  865. if (m_nWorkingSampeIndex != -1)
  866. {
  867. COTSSample pSample = GetWorkingSample();
  868. }
  869. }
  870. // get modify flag
  871. public bool IsModified() { return m_bModify; }
  872. // file name
  873. public String GetFileName()
  874. {
  875. // make a copy of file path name
  876. String strPathName = m_strPathName;
  877. // is this a new file?
  878. if (strPathName.CompareTo(UNTITLED_FILE_NAME) == 0)
  879. {
  880. return strPathName;
  881. }
  882. // get file name
  883. String strFileName = GetFileNameWithoutExtension(strPathName);
  884. // return file name
  885. return strFileName;
  886. }
  887. // get file name without extension
  888. public String GetFileNameWithoutExtension(String a_strPathName)
  889. {
  890. string str = "";
  891. str = Path.GetFileNameWithoutExtension(a_strPathName);
  892. return str;
  893. }
  894. // if the new sample name can be used.
  895. public bool IsValidSampleName(String a_sName)
  896. {
  897. int nindex = -1;
  898. foreach (var pSample in m_listSamples)
  899. {
  900. nindex++;
  901. String sSampleName = pSample.GetName();
  902. if (a_sName.CompareTo(sSampleName) != 0)
  903. {
  904. if (nindex != m_nWorkingSampeIndex)
  905. {
  906. return false;
  907. }
  908. }
  909. }
  910. return true;
  911. }
  912. // get std file list, a_nPos = -1, current do not use any STD lib, a_nPos = 0, current use STD lib.
  913. public bool GetSTDFileList(ref int a_nPos, ref List<String> a_listSTDLibName)
  914. {
  915. String a_strFolderName = m_GenParam.GetPartSTDLibFolderName();
  916. if (a_strFolderName == "")
  917. {
  918. return false;
  919. }
  920. // lib name list
  921. a_listSTDLibName.Clear();
  922. // file list
  923. List<String> listSTDFile = new List<string>();
  924. listSTDFile.Clear();
  925. const String STD_LIB_EXT = ".db";
  926. // get file list
  927. if (!GetFileNameList(a_strFolderName, STD_LIB_EXT, listSTDFile))
  928. {
  929. return false;
  930. }
  931. foreach (var file in listSTDFile)
  932. {
  933. //string fileName = file.Left(file.GetLength() - 3);
  934. String fileName = file;
  935. a_listSTDLibName.Add(fileName);
  936. }
  937. if (a_listSTDLibName.Count > -1)
  938. {
  939. string m_NoSTDDB = "NoSTDDB";
  940. a_listSTDLibName.Add(m_NoSTDDB);
  941. }
  942. //before the use choose one STD, always should be null.
  943. a_nPos = -1;
  944. String sCurrentSTD;
  945. CSampleParam pCurrentParam;
  946. COTSSample pSample = GetWorkingSample();
  947. if (pSample == null)
  948. {
  949. }
  950. else
  951. {
  952. pCurrentParam = pSample.GetMsrParams();
  953. if (pCurrentParam == null)
  954. {
  955. }
  956. //将当前使用的数据库的名字与下拉菜单的名字对应起来
  957. sCurrentSTD = pCurrentParam.GetSTDName();
  958. for (int i = 0; i < (int)a_listSTDLibName.Count; i++)
  959. {
  960. a_nPos++;
  961. if (a_listSTDLibName[i].CompareTo(sCurrentSTD) == 0)
  962. break;
  963. }
  964. }
  965. return true;
  966. }
  967. // get file name list in a folder
  968. public bool GetFileNameList(String a_strFolderName, String a_strFileType, List<String> a_listFileName)
  969. {
  970. try
  971. {
  972. //find first file
  973. //int FindFileData = 0;
  974. // int file = FindFirstFile(a_strFolderName, FindFileData);
  975. string path = a_strFolderName;
  976. List<string> lineStringList = new List<string>();//存储所有读取到的文件
  977. DirectoryInfo[] dateDirArr = new DirectoryInfo(path).GetDirectories(); //取指定路径下的所有目录
  978. string[] dir = Directory.GetDirectories(path); //文件夹列表   
  979.                 DirectoryInfo fdir = new DirectoryInfo(path);
  980. FileInfo[] files = fdir.GetFiles();
  981. foreach (FileInfo file in files)
  982. {
  983. string extensionName = Path.GetExtension(file.FullName);
  984. if (extensionName == a_strFileType)
  985. {
  986. string FileNameWithoutExtension = Path.GetFileNameWithoutExtension(file.FullName);
  987. a_listFileName.Add(FileNameWithoutExtension);
  988. }
  989. }
  990. #region 原方法
  991. //foreach (DirectoryInfo directoryInfo in dateDirArr)
  992. //{
  993. // string fullName = directoryInfo.FullName + a_strFileType;
  994. // if (!File.Exists(fullName))
  995. // {
  996. // continue;//目录下不存在此文件,返回。
  997. // }
  998. // FileInfo file = new FileInfo(fullName);
  999. // StreamReader reader = new StreamReader(file.FullName);
  1000. // while (!reader.EndOfStream)//判断是否读取完成
  1001. // {
  1002. // lineStringList.Add(reader.ReadLine());
  1003. // }
  1004. // reader.Close();
  1005. //}
  1006. //int INVALID_HANDLE_VALUE = 0;
  1007. ////find other file
  1008. //if (FindFileData != INVALID_HANDLE_VALUE)
  1009. //{
  1010. // a_listFileName.Add(FindFileData.ToString());
  1011. // bool bState = false;
  1012. // FindFile(a_strFolderName, FindFileData.ToString());
  1013. // while (bState)
  1014. // {
  1015. // a_listFileName.Add(FindFileData.ToString());
  1016. // FindFile(a_strFolderName, FindFileData.ToString());
  1017. // }
  1018. //}
  1019. #endregion
  1020. }
  1021. catch (Exception pe)
  1022. {
  1023. return false;
  1024. }
  1025. return true;
  1026. }
  1027. static String FindFile(String filename, String path)
  1028. {
  1029. if (Directory.Exists(path))
  1030. {
  1031. if (File.Exists(path + filename))
  1032. return path + filename;
  1033. String[] directorys = Directory.GetDirectories(path);
  1034. foreach (String d in directorys)
  1035. {
  1036. String p = FindFile(filename, d);
  1037. if (p != null)
  1038. return p;
  1039. }
  1040. }
  1041. return null;
  1042. }
  1043. //// change STD
  1044. public bool ChangeSTDFromList(int a_nPos)
  1045. {
  1046. String a_strFolderName = m_GenParam.GetPartSTDLibFolderName();
  1047. if (a_strFolderName == "")
  1048. {
  1049. return false;
  1050. }
  1051. // file list
  1052. List<String> listSTDFile = new List<string>();
  1053. listSTDFile.Clear();
  1054. const String STD_LIB_EXT = ".db";
  1055. // get file list
  1056. if (!GetFileNameList(a_strFolderName, STD_LIB_EXT, listSTDFile))
  1057. {
  1058. return false;
  1059. }
  1060. List<String> listSTDLibName = new List<string>();
  1061. listSTDLibName.Clear();
  1062. foreach (var file in listSTDFile)
  1063. {
  1064. //string fileName = file.Left(file.GetLength() - 3);
  1065. String fileName = file;
  1066. listSTDLibName.Add(fileName);
  1067. }
  1068. if (listSTDLibName.Count > 0)
  1069. {
  1070. listSTDLibName.Add("NoSTDDB");
  1071. }
  1072. if (a_nPos > (int)listSTDLibName.Count)
  1073. {
  1074. return false;
  1075. }
  1076. String STDName = listSTDLibName[a_nPos];
  1077. // updata STD to working sample
  1078. COTSSample pSample = GetWorkingSample();
  1079. CSampleParam pParam = pSample.GetMsrParams();
  1080. pParam.SetSTDName(STDName);
  1081. pSample.SetMsrParams(pParam);
  1082. return true;
  1083. }
  1084. // get measured sample list
  1085. public bool GetMsredSampleList(ref List<COTSSample> a_listMsredSample)
  1086. {
  1087. a_listMsredSample.Clear();
  1088. foreach (var pSample in m_listSamples)
  1089. {
  1090. if (pSample.GetMsrResults() == new CMsrDisplayResults())
  1091. {
  1092. continue;
  1093. }
  1094. else
  1095. {
  1096. a_listMsredSample.Add(pSample);//the reference count will increament automatically.
  1097. }
  1098. }
  1099. return true;
  1100. }
  1101. // calculate measurement area
  1102. public CDomain CalculateMsrArea(CHole a_pHole)
  1103. {
  1104. CDomain pMsrArea = new CDomain(a_pHole.GetShape(), a_pHole.GetDomainRect());
  1105. // create measurement area
  1106. // reset measurement area
  1107. // measurement area should smaller than the sample hole
  1108. Rectangle rectMsrArea = pMsrArea.GetDomainRect();
  1109. int nWidth = rectMsrArea.Width;
  1110. int nHeight = rectMsrArea.Height;
  1111. int nDeflateX = CalculateDeflateValue(nWidth);
  1112. int nDeflateY = CalculateDeflateValue(nHeight);
  1113. rectMsrArea.Offset(nDeflateX, nDeflateY);
  1114. pMsrArea.SetDomainRect(rectMsrArea);
  1115. // return measurement area
  1116. return pMsrArea;
  1117. }
  1118. // calculate deflate value
  1119. public int CalculateDeflateValue(int a_nWitchOrHeight)
  1120. {
  1121. const long LENGTH_THRESHOLD = 150000;
  1122. const long LENGTH_THRESHOLD_MIN = 10000;
  1123. const int EDGE = 1000;
  1124. const int EDGE_MIN = 500;
  1125. // deflate 1000 if width or height is greater than 15000
  1126. if (a_nWitchOrHeight >= LENGTH_THRESHOLD)
  1127. {
  1128. return EDGE;
  1129. }
  1130. // deflate 500 if width or height is greater than 15000
  1131. else if (a_nWitchOrHeight >= LENGTH_THRESHOLD_MIN)
  1132. {
  1133. return EDGE_MIN;
  1134. }
  1135. // otherwise, no deflate
  1136. return 0;
  1137. }
  1138. //合并后新添加的需要的方法
  1139. public void SetGenParam(COTSGeneralParam GenParam) { m_GenParam = GenParam; }
  1140. public COTSGeneralParam GetGenParam() { return m_GenParam; }
  1141. public bool Reclassify()
  1142. {
  1143. string strFilePath = FileHelper.GetFolderName(m_strPathName);
  1144. if(strFilePath==null)
  1145. {
  1146. return false;
  1147. }
  1148. foreach (var spl in m_listSamples)
  1149. {
  1150. //get the parameter MsrParam object
  1151. CSampleParam pMsrParam = spl.GetMsrParams();
  1152. string stdFileName = pMsrParam.GetSTDName();
  1153. if (!stdFileName.Contains(".db"))
  1154. {
  1155. stdFileName += ".db";
  1156. }
  1157. string filename = strFilePath + "\\" + spl.GetName() + "\\" + spl.GetName() + ".rst";
  1158. XmlDocument doc=new XmlDocument();
  1159. doc.Load(filename);
  1160. XmlNode root = doc.SelectSingleNode("XMLData");
  1161. string sem = "Sample";
  1162. var members = root.SelectNodes(sem);
  1163. foreach (XmlNode member1 in members)
  1164. {
  1165. var paramNode = member1.SelectSingleNode("MsrParams");
  1166. ((XmlElement)paramNode).SetAttribute("STDName",stdFileName);
  1167. }
  1168. doc.Save(filename);
  1169. //get the steel technology parameter
  1170. STEEL_TECHNOLOGY steelTech = pMsrParam.GetSteelTechnology();
  1171. foreach (var fld in spl.GetFieldsData())
  1172. {
  1173. foreach (var part in fld.GetListAnalysisParticles())
  1174. {
  1175. part.SetType((int)OTS_PARTCLE_TYPE.NOT_IDENTIFIED);
  1176. }
  1177. }
  1178. var analysisparts = new List<COTSParticleClr>();
  1179. foreach (var fld in spl.GetFieldsData())
  1180. {
  1181. foreach (var part in fld.GetListAnalysisParticles())
  1182. {
  1183. if (spl.GetMsrParams().GetSysSTDSwitch())
  1184. {
  1185. if (stdFileName != "NoSTDDB.db")
  1186. {
  1187. var m_classifyEngine = new CClassifyEngine();
  1188. IClassifyEngine engine = m_classifyEngine.GetParticleEngine(stdFileName);
  1189. if (!engine.Classify(part))
  1190. {
  1191. return false;
  1192. }
  1193. }
  1194. if (part.GetType() == (int)OTS_PARTCLE_TYPE.NOT_IDENTIFIED)
  1195. {
  1196. var m_classifyEngine = new CClassifyEngine();
  1197. IClassifyEngine engine = m_classifyEngine.GetIncClassifyEngine();
  1198. if (!engine.ClassifyIncA(part, (int)steelTech))
  1199. {
  1200. return false;
  1201. }
  1202. }
  1203. }
  1204. else
  1205. {
  1206. if (stdFileName != "NoSTDDB")
  1207. {
  1208. var m_classifyEngine = new CClassifyEngine();
  1209. IClassifyEngine engine = m_classifyEngine.GetParticleEngine(stdFileName);
  1210. if (!engine.Classify(part))
  1211. {
  1212. return false;
  1213. }
  1214. }
  1215. }
  1216. }
  1217. analysisparts.AddRange(fld.GetListAnalysisParticles());
  1218. }
  1219. string strFieldFileSubFolder = strFilePath + "\\" + spl.GetName() + "\\" + SMPL_MSR_RESULT_FIELDS_FILE_SUBFOLDER;
  1220. string strIncAFilename = strFieldFileSubFolder + "\\" + SMPL_MSR_RESULT_INCLUSION_FILE;
  1221. CIncAFileMgr pIncAFileMgr = new CIncAFileMgr(strIncAFilename);
  1222. pIncAFileMgr.UpdateIncAList(analysisparts);
  1223. }
  1224. return true;
  1225. }
  1226. /// <summary>
  1227. /// 设置样品中对象属性 赋值
  1228. /// </summary>
  1229. /// <param name="pSample"></param>
  1230. /// <param name="poMsrParams"></param>
  1231. /// <returns></returns>
  1232. void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
  1233. {
  1234. // copy data over
  1235. if (m_pSEMStageData == null)
  1236. {
  1237. m_pSEMStageData = new CSEMStageData();
  1238. }
  1239. if (m_pStage == null)
  1240. {
  1241. m_pStage = new CStage();
  1242. }
  1243. xInt xProjMgrFileMark = new xInt();
  1244. xString xProjMgrFileVersion = new xString();
  1245. xString xstrPathName = new xString();
  1246. xString xSystype = new xString();
  1247. Collection<CHoleBSEImg> xholeBSEImgs = new Collection<CHoleBSEImg>();
  1248. Collection<COTSSample> xsamples = new Collection<COTSSample>();
  1249. Slo slo = new Slo();
  1250. slo.Register("ProjMgrFileMark", xProjMgrFileMark);
  1251. slo.Register("ProjMgrFileVersion", xProjMgrFileVersion);
  1252. slo.Register("strPathName", xstrPathName);
  1253. slo.Register("SysType", xSystype);
  1254. slo.Register("SEMStageData", m_pSEMStageData);
  1255. slo.Register("Stage", m_pStage);
  1256. slo.Register("HoleBSEImg", xholeBSEImgs);
  1257. slo.Register("Samples", xsamples);
  1258. if (isStoring)
  1259. {
  1260. xProjMgrFileMark.AssignValue(0);
  1261. xProjMgrFileVersion.AssignValue("");
  1262. xSystype.AssignValue(m_nPackId.ToString());
  1263. xstrPathName.AssignValue(m_strPathName);
  1264. xholeBSEImgs.Clear();
  1265. //foreach (var hole in m_listHoleBSEImg)
  1266. //{
  1267. // xholeBSEImgs.addItem(hole);
  1268. //}
  1269. xsamples.Clear();
  1270. foreach (var sample in m_listSamples)
  1271. {
  1272. xsamples.addItem(sample);
  1273. }
  1274. slo.Serialize(true, classDoc, rootNode);
  1275. }
  1276. else
  1277. {
  1278. slo.Serialize(false, classDoc, rootNode);
  1279. m_strPathName = xstrPathName.value();
  1280. m_listHoleBSEImg.Clear();
  1281. //for (int i = 0; i < xholeBSEImgs.size(); i++)
  1282. //{
  1283. // m_listHoleBSEImg.Add(xholeBSEImgs.getItem(i));
  1284. //}
  1285. m_listSamples.Clear();
  1286. for (int i = 0; i < (int)xsamples.size(); i++)
  1287. {
  1288. m_listSamples.Add(xsamples.getItem(i));
  1289. }
  1290. if(xSystype.value()== "IncA")
  1291. {
  1292. m_nPackId = otsdataconst.OTS_SysType_ID.IncA;
  1293. }
  1294. else
  1295. {
  1296. m_nPackId = otsdataconst.OTS_SysType_ID.CleannessA;
  1297. }
  1298. }
  1299. }
  1300. }
  1301. }