COTSMsrPrjResultData.cs 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612
  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. public COTSSample GetSampleByIndex(int a_nIndex)
  438. {
  439. // safe check
  440. if (a_nIndex < 0 || a_nIndex >= (int)m_listSamples.Count)
  441. {
  442. // invalid sample id
  443. return null;
  444. }
  445. // get the matching sample
  446. COTSSample pSample = m_listSamples[a_nIndex];
  447. // return the sample
  448. return pSample;
  449. }
  450. public COTSSample GetSampleByName(String a_strSampleName)
  451. {
  452. bool IsChanged = false;
  453. COTSSample pOTSSample = null;
  454. for (int itr = 0; itr < m_listSamples.Count; itr++)
  455. {
  456. if (m_listSamples[itr].GetName() == a_strSampleName)
  457. {
  458. pOTSSample = m_listSamples[itr];
  459. //m_listSamples.RemoveAt(itr);
  460. IsChanged = true;
  461. }
  462. }
  463. if (IsChanged)
  464. {
  465. return pOTSSample;
  466. }
  467. return m_listSamples[0];
  468. }
  469. public void AddSample(COTSSample pSample)
  470. {
  471. // add the new sample into the samples list
  472. m_listSamples.Add(pSample);
  473. // set the project file modified.
  474. SetModify();
  475. // set the new as working sample
  476. m_nWorkingSampeIndex = (int)m_listSamples.Count - 1;
  477. // return the new sample
  478. }
  479. // get new sample name
  480. public bool DeleteSampleByIndex(int a_nIndex)
  481. {
  482. // check the index
  483. if (a_nIndex < 0 || a_nIndex >= (int)m_listSamples.Count)
  484. {
  485. // invalid input sample index
  486. return true;
  487. }
  488. // calculate new working sample index
  489. int nNewWorkingSampeIndex;
  490. if (a_nIndex < m_nWorkingSampeIndex)
  491. {
  492. nNewWorkingSampeIndex = m_nWorkingSampeIndex - 1;
  493. }
  494. else if (a_nIndex > m_nWorkingSampeIndex)
  495. {
  496. nNewWorkingSampeIndex = m_nWorkingSampeIndex;
  497. }
  498. else
  499. {
  500. // deleting working sample.
  501. if (a_nIndex == (int)m_listSamples.Count - 1)
  502. {
  503. // this is the last sample, select the above sample as working sample
  504. // if this is only sample in the list working sample index will be -1;
  505. nNewWorkingSampeIndex = m_nWorkingSampeIndex - 1;
  506. }
  507. else
  508. {
  509. // select next sample as working sample
  510. nNewWorkingSampeIndex = m_nWorkingSampeIndex;
  511. }
  512. }
  513. // delete the sample
  514. for (int i = m_listSamples.Count - 1; i >= 0; i--)
  515. {
  516. if (i == a_nIndex)
  517. {
  518. var sam = m_listSamples[i];
  519. sam.GetMsrStatus().ClearCompletedFieldsInfo();
  520. sam.GetMsrStatus().ClearCompletedFieldsInfo();
  521. sam.ClearFields();
  522. sam.GetMsrStatus().SetStatus(OTS_MSR_SAMPLE_STATUS.UNMEASURED);
  523. m_listSamples.Remove(m_listSamples[i]);
  524. break;
  525. }
  526. }
  527. // the file is modified.
  528. SetModify();
  529. // reset working sample index
  530. m_nWorkingSampeIndex = nNewWorkingSampeIndex;
  531. // ok, return TRUE
  532. return true;
  533. }
  534. public bool ChangeParamFromList(int iNamePos)
  535. {
  536. throw new NotImplementedException();
  537. }
  538. public bool GetParamFileList(ref int iNamePos, ref List<string> mParamFileNameList)
  539. {
  540. throw new NotImplementedException();
  541. }
  542. public bool DeleteSampleByName(String a_strSampleName)
  543. {
  544. // check input sample name
  545. a_strSampleName.Trim();
  546. if (a_strSampleName == "")
  547. {
  548. // input sample name is empty
  549. return false;
  550. }
  551. // go through sample list
  552. int nIndex = 0;
  553. foreach (var pSample in m_listSamples)
  554. {
  555. // return TRUE if this is not an exclude sample and its name is same with input
  556. String strSampleName = pSample.GetName();
  557. if (strSampleName.CompareTo(a_strSampleName) == 0)
  558. {
  559. // find the sample, return deleting result
  560. return DeleteSampleByIndex(nIndex);
  561. }
  562. ++nIndex;
  563. }
  564. // can't find the sample in the samples list, return FALSE
  565. return false;
  566. }
  567. public bool ResetSamplesListOrder(List<String> a_listSampleNames)
  568. {
  569. // no sample in the samples list; shouldn't be here
  570. if (m_listSamples.Count == 0)
  571. {
  572. return false;
  573. }
  574. // make sure that input sample names list size is same with the samples list
  575. if (m_listSamples.Count != a_listSampleNames.Count)
  576. {
  577. return false;
  578. }
  579. // new sample list
  580. List<COTSSample> listSamples = new List<COTSSample>();
  581. // go through the sample names list
  582. foreach (var strSampleName in a_listSampleNames)
  583. {
  584. bool IsChanged = false;
  585. for (int itr = 0; itr < m_listSamples.Count; itr++)
  586. {
  587. if (m_listSamples[itr].GetName() == strSampleName)
  588. {
  589. COTSSample pElementChemistry = m_listSamples[itr];
  590. IsChanged = true;
  591. }
  592. }
  593. if (!IsChanged)
  594. {
  595. return false;
  596. }
  597. }
  598. // reset the samples list
  599. m_listSamples.Clear();
  600. foreach (var pSample in listSamples)
  601. {
  602. m_listSamples.Add(pSample);
  603. }
  604. // set modify flag
  605. SetModify();
  606. // Ok, return TRUE
  607. return true;
  608. }
  609. public bool InsrtSample(COTSSample a_pSample, int a_nIndex)
  610. {
  611. // input check
  612. if (a_pSample != null)
  613. {
  614. // invalid input sample pointer
  615. return false;
  616. }
  617. if (m_listSamples.Count == 0 || a_nIndex >= (int)m_listSamples.Count)
  618. {
  619. m_listSamples.Add(a_pSample);
  620. }
  621. else if (a_nIndex <= 0)
  622. {
  623. m_listSamples.Insert(Convert.ToInt32(m_listSamples[a_nIndex]), a_pSample);
  624. }
  625. else
  626. {
  627. m_listSamples.Insert(Convert.ToInt32(m_listSamples[a_nIndex]) + a_nIndex, a_pSample);
  628. }
  629. // Ok, return TRUE
  630. return true;
  631. }
  632. public bool ChangeSamplePosition(int a_nIndexFrom, int a_nIndexTo)
  633. {
  634. // make sure both index are valid
  635. if (a_nIndexFrom < 0 || a_nIndexFrom >= (int)m_listSamples.Count)
  636. {
  637. // invalid from index
  638. return false;
  639. }
  640. if (a_nIndexTo < 0 || a_nIndexTo >= (int)m_listSamples.Count)
  641. {
  642. // invalid to index
  643. return false;
  644. }
  645. // need to do nothing if the two indexes are the same
  646. if (a_nIndexFrom != a_nIndexTo)
  647. {
  648. // move to last?
  649. bool bLast = (a_nIndexTo == ((int)m_listSamples.Count - 1));
  650. // get the sample
  651. COTSSample pSample = m_listSamples[a_nIndexFrom];
  652. // remove it from the samples list
  653. m_listSamples.Remove(pSample);
  654. // put the sample back in
  655. if (bLast)
  656. {
  657. m_listSamples.Add(pSample);
  658. }
  659. else
  660. {
  661. m_listSamples.Insert(Convert.ToInt32(m_listSamples[a_nIndexTo]) + a_nIndexTo, pSample);
  662. }
  663. }
  664. // Ok, return TRUE
  665. return true;
  666. }
  667. public bool MoveSamplePosition(COTSSample a_pTargetSample, COTSSample a_RefpSample, bool a_bBefore /*= TRUE*/)
  668. {
  669. // check input
  670. if (a_pTargetSample != null)
  671. {
  672. // invalid input target sample pointer
  673. return false;
  674. }
  675. if (a_RefpSample != null)
  676. {
  677. // invalid input ref sample pointer
  678. return false;
  679. }
  680. bool IsChanged = false;
  681. for (int itr = 0; itr < m_listSamples.Count; itr++)
  682. {
  683. if (m_listSamples[itr].GetName() == a_pTargetSample.GetName())
  684. {
  685. COTSSample pElementChemistry = m_listSamples[itr];
  686. // m_listSamples.RemoveAt(itr);
  687. IsChanged = true;
  688. }
  689. }
  690. if (!IsChanged)
  691. {
  692. return false;
  693. }
  694. for (int itr = 0; itr < m_listSamples.Count; itr++)
  695. {
  696. if (m_listSamples[itr].GetName() == a_RefpSample.GetName())
  697. {
  698. COTSSample pElementChemistry = m_listSamples[itr];
  699. //m_listSamples.RemoveAt(itr);
  700. IsChanged = true;
  701. }
  702. }
  703. if (!IsChanged)
  704. {
  705. return false;
  706. }
  707. // remove the sample from the samples list
  708. for (int itr = 0; itr < m_listSamples.Count; itr++)
  709. {
  710. if (m_listSamples[itr].GetName() == a_RefpSample.GetName())
  711. {
  712. COTSSample pElementChemistry = m_listSamples[itr];
  713. //m_listSamples.RemoveAt(itr);
  714. IsChanged = true;
  715. }
  716. }
  717. if (!IsChanged)
  718. {
  719. return false;
  720. }
  721. // put the sample back in
  722. if (a_bBefore)
  723. {
  724. m_listSamples.Insert(0, a_pTargetSample);
  725. }
  726. else
  727. {
  728. m_listSamples.Insert(1, a_pTargetSample);
  729. }
  730. // Ok, return TRUE
  731. return true;
  732. }
  733. public bool MoveSamplePosition(String a_strTargetSampleName, String a_strRefSampleName, bool a_bBefore /*= TRUE*/)
  734. {
  735. // input check
  736. a_strTargetSampleName.Trim();
  737. if (a_strTargetSampleName == "")
  738. {
  739. // input target sample is an empty string
  740. return false;
  741. }
  742. a_strRefSampleName.Trim();
  743. if (a_strRefSampleName == "")
  744. {
  745. // input ref sample is an empty string
  746. return false;
  747. }
  748. bool IsChanged = false;
  749. for (int itr = 0; itr < m_listSamples.Count; itr++)
  750. {
  751. if (m_listSamples[itr].GetName() == a_strTargetSampleName)
  752. {
  753. COTSSample pElementChemistry = m_listSamples[itr];
  754. IsChanged = true;
  755. }
  756. }
  757. if (!IsChanged)
  758. {
  759. return false;
  760. }
  761. COTSSample pTargetSample = m_listSamples[0];
  762. for (int itr = 0; itr < m_listSamples.Count; itr++)
  763. {
  764. if (m_listSamples[itr].GetName() == a_strTargetSampleName)
  765. {
  766. COTSSample pElementChemistry = m_listSamples[itr];
  767. IsChanged = true;
  768. }
  769. }
  770. if (!IsChanged)
  771. {
  772. return false;
  773. }
  774. COTSSample pRefSample = pTargetSample;
  775. // need to do nothing if the two name are same
  776. if (a_strTargetSampleName.CompareTo(a_strRefSampleName) != 0)
  777. {
  778. return MoveSamplePosition(pTargetSample, pRefSample, a_bBefore);
  779. }
  780. // Ok, return TRUE
  781. return true;
  782. }
  783. public COTSSample GetWorkingSample()
  784. {
  785. return GetSampleByIndex(m_nWorkingSampeIndex);
  786. }
  787. int GetWorkingSampleIndex() { return m_nWorkingSampeIndex; }
  788. void SetWorkingSampleIndex(int a_nWorkingSampleIndex) { m_nWorkingSampeIndex = a_nWorkingSampleIndex; }
  789. public bool SetWorkingSampleByIndex(int a_nIndex)
  790. {
  791. // special treatment
  792. if (a_nIndex == -1 && m_listSamples.Count == 0)
  793. {
  794. m_nWorkingSampeIndex = -1;
  795. return true;
  796. }
  797. // check if the working sample index
  798. if (0 > a_nIndex || a_nIndex >= (int)m_listSamples.Count)
  799. {
  800. // invalid sample index
  801. return false;
  802. }
  803. m_nWorkingSampeIndex = a_nIndex;
  804. return true;
  805. }
  806. public bool SetWorkingSampleByName(String a_pSampleName)
  807. {
  808. // check input sample name
  809. a_pSampleName.Trim();
  810. if (a_pSampleName == "")
  811. {
  812. // input sample name is empty
  813. return false;
  814. }
  815. // go through sample list
  816. int nIndex = 0;
  817. foreach (var pSample in m_listSamples)
  818. {
  819. // return TRUE if this is not an exclude sample and its name is same with input
  820. String strSampleName = pSample.GetName();
  821. if (strSampleName.CompareTo(a_pSampleName) == 0)
  822. {
  823. // find the sample, return deleting result
  824. return SetWorkingSampleByIndex(nIndex);
  825. }
  826. ++nIndex;
  827. }
  828. // failed to find the named sample
  829. // failed to find the named sample return FALSE
  830. return false;
  831. }
  832. public bool DeleteWorkingSample()
  833. {
  834. // check if the working sample index
  835. if (m_nWorkingSampeIndex < 0 || m_nWorkingSampeIndex >= (int)m_listSamples.Count)
  836. {
  837. // invalid working sample index
  838. return false;
  839. }
  840. // return the result of DeleteSampleByIndex
  841. return DeleteSampleByIndex(m_nWorkingSampeIndex);
  842. }
  843. // Sample hole BSE image list
  844. public List<CHoleBSEImg> GetHoleBESImgList() { return m_listHoleBSEImg; }
  845. // hole BSE images list
  846. public void SetHoleBESImgList(List<CHoleBSEImg> a_listHoleBSEImg, bool a_bClear/* = TRUE*/)
  847. {
  848. // clear the hole BSE image list if necessary
  849. if (a_bClear)
  850. {
  851. m_listHoleBSEImg.Clear();
  852. }
  853. m_listHoleBSEImg = a_listHoleBSEImg;
  854. //if (m_nWorkingSampeIndex != -1)
  855. //{
  856. // COTSSample pSample = GetWorkingSample();
  857. //}
  858. }
  859. // get modify flag
  860. public bool IsModified() { return m_bModify; }
  861. // file name
  862. public String GetFileName()
  863. {
  864. // make a copy of file path name
  865. String strPathName = m_strPathName;
  866. // is this a new file?
  867. if (strPathName.CompareTo(UNTITLED_FILE_NAME) == 0)
  868. {
  869. return strPathName;
  870. }
  871. // get file name
  872. String strFileName = GetFileNameWithoutExtension(strPathName);
  873. // return file name
  874. return strFileName;
  875. }
  876. // get file name without extension
  877. public String GetFileNameWithoutExtension(String a_strPathName)
  878. {
  879. string str = "";
  880. str = Path.GetFileNameWithoutExtension(a_strPathName);
  881. return str;
  882. }
  883. // if the new sample name can be used.
  884. public bool IsValidSampleName(String a_sName)
  885. {
  886. int nindex = -1;
  887. foreach (var pSample in m_listSamples)
  888. {
  889. nindex++;
  890. String sSampleName = pSample.GetName();
  891. if (a_sName.CompareTo(sSampleName) != 0)
  892. {
  893. if (nindex != m_nWorkingSampeIndex)
  894. {
  895. return false;
  896. }
  897. }
  898. }
  899. return true;
  900. }
  901. // get std file list, a_nPos = -1, current do not use any STD lib, a_nPos = 0, current use STD lib.
  902. public bool GetSTDFileList(ref int a_nPos, ref List<String> a_listSTDLibName)
  903. {
  904. String a_strFolderName = m_GenParam.GetPartSTDLibFolderName();
  905. if (a_strFolderName == "")
  906. {
  907. return false;
  908. }
  909. // lib name list
  910. a_listSTDLibName.Clear();
  911. // file list
  912. List<String> listSTDFile = new List<string>();
  913. listSTDFile.Clear();
  914. const String STD_LIB_EXT = ".db";
  915. // get file list
  916. if (!GetFileNameList(a_strFolderName, STD_LIB_EXT, listSTDFile))
  917. {
  918. return false;
  919. }
  920. foreach (var file in listSTDFile)
  921. {
  922. //string fileName = file.Left(file.GetLength() - 3);
  923. String fileName = file;
  924. a_listSTDLibName.Add(fileName);
  925. }
  926. if (a_listSTDLibName.Count > -1)
  927. {
  928. string m_NoSTDDB = "NoSTDDB";
  929. a_listSTDLibName.Add(m_NoSTDDB);
  930. }
  931. //before the use choose one STD, always should be null.
  932. a_nPos = -1;
  933. String sCurrentSTD;
  934. CSampleParam pCurrentParam;
  935. COTSSample pSample = GetWorkingSample();
  936. if (pSample == null)
  937. {
  938. }
  939. else
  940. {
  941. pCurrentParam = pSample.GetMsrParams();
  942. if (pCurrentParam == null)
  943. {
  944. }
  945. //将当前使用的数据库的名字与下拉菜单的名字对应起来
  946. sCurrentSTD = pCurrentParam.GetSTDName();
  947. for (int i = 0; i < (int)a_listSTDLibName.Count; i++)
  948. {
  949. a_nPos++;
  950. if (a_listSTDLibName[i].CompareTo(sCurrentSTD) == 0)
  951. break;
  952. }
  953. }
  954. return true;
  955. }
  956. // get file name list in a folder
  957. public bool GetFileNameList(String a_strFolderName, String a_strFileType, List<String> a_listFileName)
  958. {
  959. try
  960. {
  961. //find first file
  962. //int FindFileData = 0;
  963. // int file = FindFirstFile(a_strFolderName, FindFileData);
  964. string path = a_strFolderName;
  965. List<string> lineStringList = new List<string>();//存储所有读取到的文件
  966. DirectoryInfo[] dateDirArr = new DirectoryInfo(path).GetDirectories(); //取指定路径下的所有目录
  967. string[] dir = Directory.GetDirectories(path); //文件夹列表   
  968.                 DirectoryInfo fdir = new DirectoryInfo(path);
  969. FileInfo[] files = fdir.GetFiles();
  970. foreach (FileInfo file in files)
  971. {
  972. string extensionName = Path.GetExtension(file.FullName);
  973. if (extensionName == a_strFileType)
  974. {
  975. string FileNameWithoutExtension = Path.GetFileNameWithoutExtension(file.FullName);
  976. a_listFileName.Add(FileNameWithoutExtension);
  977. }
  978. }
  979. #region 原方法
  980. //foreach (DirectoryInfo directoryInfo in dateDirArr)
  981. //{
  982. // string fullName = directoryInfo.FullName + a_strFileType;
  983. // if (!File.Exists(fullName))
  984. // {
  985. // continue;//目录下不存在此文件,返回。
  986. // }
  987. // FileInfo file = new FileInfo(fullName);
  988. // StreamReader reader = new StreamReader(file.FullName);
  989. // while (!reader.EndOfStream)//判断是否读取完成
  990. // {
  991. // lineStringList.Add(reader.ReadLine());
  992. // }
  993. // reader.Close();
  994. //}
  995. //int INVALID_HANDLE_VALUE = 0;
  996. ////find other file
  997. //if (FindFileData != INVALID_HANDLE_VALUE)
  998. //{
  999. // a_listFileName.Add(FindFileData.ToString());
  1000. // bool bState = false;
  1001. // FindFile(a_strFolderName, FindFileData.ToString());
  1002. // while (bState)
  1003. // {
  1004. // a_listFileName.Add(FindFileData.ToString());
  1005. // FindFile(a_strFolderName, FindFileData.ToString());
  1006. // }
  1007. //}
  1008. #endregion
  1009. }
  1010. catch (Exception pe)
  1011. {
  1012. return false;
  1013. }
  1014. return true;
  1015. }
  1016. static String FindFile(String filename, String path)
  1017. {
  1018. if (Directory.Exists(path))
  1019. {
  1020. if (File.Exists(path + filename))
  1021. return path + filename;
  1022. String[] directorys = Directory.GetDirectories(path);
  1023. foreach (String d in directorys)
  1024. {
  1025. String p = FindFile(filename, d);
  1026. if (p != null)
  1027. return p;
  1028. }
  1029. }
  1030. return null;
  1031. }
  1032. //// change STD
  1033. public bool ChangeSTDFromList(int a_nPos)
  1034. {
  1035. String a_strFolderName = m_GenParam.GetPartSTDLibFolderName();
  1036. if (a_strFolderName == "")
  1037. {
  1038. return false;
  1039. }
  1040. // file list
  1041. List<String> listSTDFile = new List<string>();
  1042. listSTDFile.Clear();
  1043. const String STD_LIB_EXT = ".db";
  1044. // get file list
  1045. if (!GetFileNameList(a_strFolderName, STD_LIB_EXT, listSTDFile))
  1046. {
  1047. return false;
  1048. }
  1049. List<String> listSTDLibName = new List<string>();
  1050. listSTDLibName.Clear();
  1051. foreach (var file in listSTDFile)
  1052. {
  1053. //string fileName = file.Left(file.GetLength() - 3);
  1054. String fileName = file;
  1055. listSTDLibName.Add(fileName);
  1056. }
  1057. if (listSTDLibName.Count > 0)
  1058. {
  1059. listSTDLibName.Add("NoSTDDB");
  1060. }
  1061. if (a_nPos > (int)listSTDLibName.Count)
  1062. {
  1063. return false;
  1064. }
  1065. String STDName = listSTDLibName[a_nPos];
  1066. // updata STD to working sample
  1067. COTSSample pSample = GetWorkingSample();
  1068. CSampleParam pParam = pSample.GetMsrParams();
  1069. pParam.SetSTDName(STDName);
  1070. pSample.SetMsrParams(pParam);
  1071. return true;
  1072. }
  1073. // get measured sample list
  1074. public bool GetMsredSampleList(ref List<COTSSample> a_listMsredSample)
  1075. {
  1076. a_listMsredSample.Clear();
  1077. foreach (var pSample in m_listSamples)
  1078. {
  1079. if (pSample.GetMsrResults() == new CMsrDisplayResults())
  1080. {
  1081. continue;
  1082. }
  1083. else
  1084. {
  1085. a_listMsredSample.Add(pSample);//the reference count will increament automatically.
  1086. }
  1087. }
  1088. return true;
  1089. }
  1090. // calculate measurement area
  1091. public CDomain CalculateMsrArea(CHole a_pHole)
  1092. {
  1093. CDomain pMsrArea = new CDomain(a_pHole.GetShape(), a_pHole.GetDomainRect());
  1094. // create measurement area
  1095. // reset measurement area
  1096. // measurement area should smaller than the sample hole
  1097. Rectangle rectMsrArea = pMsrArea.GetDomainRect();
  1098. int nWidth = rectMsrArea.Width;
  1099. int nHeight = rectMsrArea.Height;
  1100. int nDeflateX = CalculateDeflateValue(nWidth);
  1101. int nDeflateY = CalculateDeflateValue(nHeight);
  1102. rectMsrArea.Offset(nDeflateX, nDeflateY);
  1103. pMsrArea.SetDomainRect(rectMsrArea);
  1104. // return measurement area
  1105. return pMsrArea;
  1106. }
  1107. // calculate deflate value
  1108. public int CalculateDeflateValue(int a_nWitchOrHeight)
  1109. {
  1110. const long LENGTH_THRESHOLD = 150000;
  1111. const long LENGTH_THRESHOLD_MIN = 10000;
  1112. const int EDGE = 1000;
  1113. const int EDGE_MIN = 500;
  1114. // deflate 1000 if width or height is greater than 15000
  1115. if (a_nWitchOrHeight >= LENGTH_THRESHOLD)
  1116. {
  1117. return EDGE;
  1118. }
  1119. // deflate 500 if width or height is greater than 15000
  1120. else if (a_nWitchOrHeight >= LENGTH_THRESHOLD_MIN)
  1121. {
  1122. return EDGE_MIN;
  1123. }
  1124. // otherwise, no deflate
  1125. return 0;
  1126. }
  1127. //合并后新添加的需要的方法
  1128. public void SetGenParam(COTSGeneralParam GenParam) { m_GenParam = GenParam; }
  1129. public COTSGeneralParam GetGenParam() { return m_GenParam; }
  1130. public bool Reclassify()
  1131. {
  1132. string strFilePath = FileHelper.GetFolderName(m_strPathName);
  1133. if(strFilePath==null)
  1134. {
  1135. return false;
  1136. }
  1137. foreach (var spl in m_listSamples)
  1138. {
  1139. //get the parameter MsrParam object
  1140. CSampleParam pMsrParam = spl.GetMsrParams();
  1141. string stdFileName = pMsrParam.GetSTDName();
  1142. if (!stdFileName.Contains(".db"))
  1143. {
  1144. stdFileName += ".db";
  1145. }
  1146. string filename = strFilePath + "\\" + spl.GetName() + "\\" + spl.GetName() + ".rst";
  1147. XmlDocument doc=new XmlDocument();
  1148. doc.Load(filename);
  1149. XmlNode root = doc.SelectSingleNode("XMLData");
  1150. string sem = "Sample";
  1151. var members = root.SelectNodes(sem);
  1152. foreach (XmlNode member1 in members)
  1153. {
  1154. var paramNode = member1.SelectSingleNode("MsrParams");
  1155. ((XmlElement)paramNode).SetAttribute("STDName",stdFileName);
  1156. }
  1157. doc.Save(filename);
  1158. //get the steel technology parameter
  1159. STEEL_TECHNOLOGY steelTech = pMsrParam.GetSteelTechnology();
  1160. foreach (var fld in spl.GetFieldsData())
  1161. {
  1162. foreach (var part in fld.GetListAnalysisParticles())
  1163. {
  1164. part.SetType((int)OTS_PARTCLE_TYPE.NOT_IDENTIFIED);
  1165. }
  1166. }
  1167. var analysisparts = new List<COTSParticleClr>();
  1168. foreach (var fld in spl.GetFieldsData())
  1169. {
  1170. foreach (var part in fld.GetListAnalysisParticles())
  1171. {
  1172. if (spl.GetMsrParams().GetSysSTDSwitch())
  1173. {
  1174. if (stdFileName != "NoSTDDB.db")
  1175. {
  1176. var m_classifyEngine = new CClassifyEngine();
  1177. IClassifyEngine engine = m_classifyEngine.GetParticleEngine(stdFileName);
  1178. if (!engine.Classify(part))
  1179. {
  1180. return false;
  1181. }
  1182. }
  1183. if (part.GetType() == (int)OTS_PARTCLE_TYPE.NOT_IDENTIFIED)
  1184. {
  1185. var m_classifyEngine = new CClassifyEngine();
  1186. IClassifyEngine engine = m_classifyEngine.GetIncClassifyEngine();
  1187. if (!engine.ClassifyIncA(part, (int)steelTech))
  1188. {
  1189. return false;
  1190. }
  1191. }
  1192. }
  1193. else
  1194. {
  1195. if (stdFileName != "NoSTDDB.db")
  1196. {
  1197. var m_classifyEngine = new CClassifyEngine();
  1198. IClassifyEngine engine = m_classifyEngine.GetParticleEngine(stdFileName);
  1199. if (!engine.Classify(part))
  1200. {
  1201. return false;
  1202. }
  1203. }
  1204. }
  1205. }
  1206. analysisparts.AddRange(fld.GetListAnalysisParticles());
  1207. }
  1208. string strFieldFileSubFolder = strFilePath + "\\" + spl.GetName() + "\\" + SMPL_MSR_RESULT_FIELDS_FILE_SUBFOLDER;
  1209. string strIncAFilename = strFieldFileSubFolder + "\\" + SMPL_MSR_RESULT_INCLUSION_FILE;
  1210. CIncAFileMgr pIncAFileMgr = new CIncAFileMgr(strIncAFilename);
  1211. pIncAFileMgr.UpdateIncAList(analysisparts);
  1212. }
  1213. return true;
  1214. }
  1215. /// <summary>
  1216. /// 设置样品中对象属性 赋值
  1217. /// </summary>
  1218. /// <param name="pSample"></param>
  1219. /// <param name="poMsrParams"></param>
  1220. /// <returns></returns>
  1221. void Serialize(bool isStoring, XmlDocument classDoc, XmlNode rootNode)
  1222. {
  1223. // copy data over
  1224. if (m_pSEMStageData == null)
  1225. {
  1226. m_pSEMStageData = new CSEMStageData();
  1227. }
  1228. if (m_pStage == null)
  1229. {
  1230. m_pStage = new CStage();
  1231. }
  1232. xInt xProjMgrFileMark = new xInt();
  1233. xString xProjMgrFileVersion = new xString();
  1234. xString xstrPathName = new xString();
  1235. xString xSystype = new xString();
  1236. Collection<CHoleBSEImg> xholeBSEImgs = new Collection<CHoleBSEImg>();
  1237. Collection<COTSSample> xsamples = new Collection<COTSSample>();
  1238. Slo slo = new Slo();
  1239. slo.Register("ProjMgrFileMark", xProjMgrFileMark);
  1240. slo.Register("ProjMgrFileVersion", xProjMgrFileVersion);
  1241. slo.Register("strPathName", xstrPathName);
  1242. slo.Register("SysType", xSystype);
  1243. slo.Register("SEMStageData", m_pSEMStageData);
  1244. slo.Register("Stage", m_pStage);
  1245. slo.Register("HoleBSEImg", xholeBSEImgs);
  1246. slo.Register("Samples", xsamples);
  1247. if (isStoring)
  1248. {
  1249. xProjMgrFileMark.AssignValue(0);
  1250. xProjMgrFileVersion.AssignValue("");
  1251. xSystype.AssignValue(m_nPackId.ToString());
  1252. xstrPathName.AssignValue(m_strPathName);
  1253. xholeBSEImgs.Clear();
  1254. //foreach (var hole in m_listHoleBSEImg)
  1255. //{
  1256. // xholeBSEImgs.addItem(hole);
  1257. //}
  1258. xsamples.Clear();
  1259. foreach (var sample in m_listSamples)
  1260. {
  1261. xsamples.addItem(sample);
  1262. }
  1263. slo.Serialize(true, classDoc, rootNode);
  1264. }
  1265. else
  1266. {
  1267. slo.Serialize(false, classDoc, rootNode);
  1268. m_strPathName = xstrPathName.value();
  1269. m_listHoleBSEImg.Clear();
  1270. //for (int i = 0; i < xholeBSEImgs.size(); i++)
  1271. //{
  1272. // m_listHoleBSEImg.Add(xholeBSEImgs.getItem(i));
  1273. //}
  1274. m_listSamples.Clear();
  1275. for (int i = 0; i < (int)xsamples.size(); i++)
  1276. {
  1277. m_listSamples.Add(xsamples.getItem(i));
  1278. }
  1279. if(xSystype.value()== "IncA")
  1280. {
  1281. m_nPackId = otsdataconst.OTS_SysType_ID.IncA;
  1282. }
  1283. else
  1284. {
  1285. m_nPackId = otsdataconst.OTS_SysType_ID.CleannessA;
  1286. }
  1287. }
  1288. }
  1289. }
  1290. }