COTSMsrPrjResultData.cs 50 KB

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