COTSMsrPrjResultData.cs 51 KB

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