COTSMeasureParam.cs 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410
  1. using OTSModelSharp;
  2. using OTSDataType;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.IO;
  8. using OTSModelSharp.ResourceManage;
  9. using static OTSModelSharp.ResourceManage.ResourceID;
  10. using static OTSModelSharp.ResourceManage.ResourceData;
  11. using static OTSDataType.otsdataconst;
  12. using System.Windows.Forms;
  13. using OTSMeasureApp._0_OTSModel.OTSDataType;
  14. namespace OTSMeasureApp
  15. {
  16. //设置线程状态
  17. public enum MSR_RUN_TYPE
  18. {
  19. RUNMEASURE = 1, //normal
  20. RUNSampleHoleImage = 2 //take photo of the measure area.
  21. };
  22. enum SAMPLE_FAULT_WARN_CODE
  23. {
  24. INVALID = -1,
  25. MIN = 0,
  26. SEM_DATA_ERROR = 0,
  27. AREA_OUTSIDE_HOLE = 1,
  28. RESOLUTION_LOW = 2,
  29. FINISHED = 3,
  30. NO_ERROR_WARNING = 4,
  31. FILE_NOT_SAVED = 5,
  32. MAX = 5
  33. };
  34. enum SAMPLE_CHECK_RESULT_TYPE
  35. {
  36. INVALID = -1,
  37. MIN = 0,
  38. SWITCH_ON = 0,
  39. FINISHED = 1,
  40. SETTING_ERROR = 2,
  41. SETTING_WARNING = 3,
  42. MEASURABLE = 4,
  43. NO_ERROR_WARNING = 5,
  44. MAX = 5
  45. };
  46. public class COTSMeasureParam
  47. {
  48. OTSIncAMeasureAppForm m_MeasureAppFrom = null;
  49. /// <summary></summary>
  50. /// <remarks>创建</remarks>
  51. private COTSMsrPrjResultData resultData;
  52. //参数文件
  53. private COTSDefaultParam defaultParam = null;
  54. //样品台文件(读取样品台数据等)
  55. private CStageParam stageParam = null;
  56. private CSpecialGrayRangeParam specialRanges = null;
  57. //测量样品链表
  58. List<COTSSample> m_MeasureSampleList = new List<COTSSample>();
  59. NLog.Logger log ;
  60. public CSpecialGrayRangeParam SpecialRanges { get => specialRanges; set => specialRanges = value; }
  61. public List<COTSSample> MeasureSampleList { get => m_MeasureSampleList; set => m_MeasureSampleList = value; }
  62. public CStageParam GetStageParam()
  63. {
  64. return stageParam;
  65. }
  66. public void SetStageParam(CStageParam value)
  67. {
  68. stageParam = value;
  69. }
  70. public COTSDefaultParam GetDefaultParam()
  71. {
  72. return defaultParam;
  73. }
  74. public void SetDefaultParam(COTSDefaultParam value)
  75. {
  76. defaultParam = value;
  77. }
  78. public COTSMsrPrjResultData GetResultData()
  79. {
  80. return resultData;
  81. }
  82. public void SetResultData(COTSMsrPrjResultData value)
  83. {
  84. resultData = value;
  85. }
  86. public COTSMeasureParam(OTSIncAMeasureAppForm MeasureApp)
  87. {
  88. log = NLog.LogManager.GetCurrentClassLogger();
  89. m_MeasureAppFrom = MeasureApp;
  90. SetResultData(new COTSMsrPrjResultData());
  91. }
  92. //检查参数文件是否存在
  93. public bool LoadParamFile()
  94. {
  95. //加载样品参数文件: \Config\SysData\OTSProgMgrParam.pmf
  96. SetDefaultParam(new COTSDefaultParam());
  97. return GetDefaultParam().LoadInfoFromProgMgrFile();
  98. }
  99. //检查参数样品台文件是否存在
  100. public bool LoadStageParamFile()
  101. {
  102. SetStageParam(new CStageParam());
  103. // 加载样品台文件; \Config\SysData\OTSStage.stg
  104. if (!GetStageParam().Load(true, false))
  105. {
  106. return false;
  107. }
  108. return true;
  109. }
  110. public bool LoadSpecialGrayRangeParamFile()
  111. {
  112. SpecialRanges = new CSpecialGrayRangeParam();
  113. if (!SpecialRanges.LoadParam())
  114. {
  115. return false;
  116. }
  117. return true;
  118. }
  119. //获取系统文件是否存在和有效
  120. public bool InitResultData(bool bNewFileFlag = true)
  121. {
  122. //打开文件,则文件中保存有样品台信息,不需要使用系统样品名信息
  123. if (bNewFileFlag)
  124. {
  125. //设置样品台参数
  126. CStage Stage = GetStageParam().GetWorkingStage();
  127. if (null == Stage)
  128. {
  129. return false;
  130. }
  131. GetResultData().SetStage(Stage);
  132. // 设置 SEM stage data
  133. CSEMStageData SEMData = GetDefaultParam().GetStageDataParam();
  134. if (null == SEMData)
  135. {
  136. return false;
  137. }
  138. GetResultData().SetSEMStageData(SEMData);
  139. }
  140. //设置 general parameter
  141. COTSGeneralParam GenParam = GetDefaultParam().GetGenParam();
  142. if (null == GenParam)
  143. {
  144. return false;
  145. }
  146. GetResultData().SetGenParam(GenParam);
  147. if (GetResultData().GetPathName()=="")
  148. {
  149. GetResultData().SetPathName("Untitled");
  150. }
  151. GetResultData().SystemTypeId = GetDefaultParam().SystemTypeId;
  152. return true;
  153. }
  154. //新建样品工作文件 0:报错 1:正常 2:取消
  155. public int CreateNewFile()
  156. {
  157. if (GetResultData().IsModified()) // 文件被修改
  158. {
  159. int iRev = m_MeasureAppFrom.ShowSaveInfoMsgBox();
  160. if ((int)MessageBoxRev.DIALOG_YES == iRev)
  161. {
  162. if (!GetResultData().Save())
  163. {
  164. return 0;
  165. }
  166. }
  167. else if((int)MessageBoxRev.DIALOG_CANCEL == iRev)
  168. {
  169. return 2;
  170. }
  171. }
  172. //新建新的工作文件
  173. //重新生成一个工作文件对象
  174. COTSMsrPrjResultData ProjDataMgr = new COTSMsrPrjResultData();
  175. GetResultData().SetPathName("Untitled");
  176. SetResultData(ProjDataMgr);
  177. this.LoadStageParamFile();
  178. if (!this.InitResultData())
  179. {
  180. return 0;
  181. }
  182. return 1;
  183. }
  184. //将样品台坐标转换为Sem 坐标
  185. public PointF ConvertOTSToSemCoord(PointF POTSCoord)
  186. {
  187. System.Drawing.PointF VSemCoord = new System.Drawing.PointF();
  188. GetDefaultParam().GetStageDataParam().ConvertOTSToSEMCoord(POTSCoord, ref VSemCoord);
  189. return VSemCoord;
  190. }
  191. //将Sem 坐标转换为样品台坐标
  192. public PointF ConverSEMToOTSCoord(PointF PSEMCoord)
  193. {
  194. System.Drawing.PointF VOTSCoord = new System.Drawing.PointF();
  195. GetDefaultParam().GetStageDataParam().ConvertSEMToOTSCoord(PSEMCoord, ref VOTSCoord);
  196. return VOTSCoord;
  197. }
  198. public OTSSampleVisualPropertyInfo AddNewSampleMeasure(string a_strHoleName = "")
  199. {
  200. COTSSample NewSample = new COTSSample();
  201. SetSampleDefaultPara(ref NewSample, a_strHoleName);
  202. //NewSample.
  203. //添加样品
  204. GetResultData().AddSample(NewSample);
  205. // 获取样品的属性值
  206. OTSSampleVisualPropertyInfo MeasureInfo = new OTSSampleVisualPropertyInfo(NewSample, defaultParam.GetSysType());
  207. return MeasureInfo;
  208. }
  209. public void InitWorkingSampleData(int startfieldNo)
  210. {
  211. COTSSample Sample = GetWorkSample();
  212. if (Sample == null) return ;
  213. var sname= Sample.GetName();
  214. var pathname = resultData.GetFolderName(resultData.GetPathName());
  215. var sampleResultFolder = pathname + "\\" + sname;
  216. if (Directory.Exists(sampleResultFolder))
  217. {
  218. resultData.DeleteWorkingSampleFieldDataByFieldNo(startfieldNo);
  219. //Directory.Delete(sampleResultFolder, true);
  220. var flds = Sample.GetFieldsData();
  221. foreach (var f in flds)
  222. {
  223. if (f.GetMeasureSequence() >= startfieldNo)
  224. {
  225. f.ClearAllMeausredData();
  226. f.SetIsMeasureComplete(false);
  227. }
  228. }
  229. }
  230. var sta = Sample.GetMsrStatus();
  231. sta.ClearCompletedFieldsInfo();
  232. sta.SetStatus(OTS_MSR_SAMPLE_STATUS.UNMEASURED);
  233. var rsts = Sample.GetMsrResults();
  234. var itms = rsts.GetResultItems();
  235. itms.Clear();
  236. rsts.SetResultItems(itms);
  237. rsts.SetMeasuredArea(0);
  238. rsts.SetRatio(0);
  239. }
  240. public OTSSampleVisualPropertyInfo GetWorkingSampleVisualPropertyInfo()
  241. {
  242. COTSSample Sample = GetWorkSample();
  243. if (Sample == null) return null;
  244. OTSSampleVisualPropertyInfo MeasureInfo = new OTSSampleVisualPropertyInfo(Sample, defaultParam.GetSysType());
  245. return MeasureInfo;
  246. }
  247. protected COTSSample SetSampleDefaultPara(ref COTSSample pSample, String a_strHoleName)
  248. {
  249. // get new sample name
  250. String strNewSampleName = GetNewSampleName();
  251. // make sure the new sample name is not an empty string
  252. strNewSampleName.Trim();
  253. // get a suitable sample hole for the new sample
  254. CHole pHole = SelectASmpleHole(a_strHoleName);
  255. // check the sample hole
  256. if (pHole == null)
  257. {
  258. // failed to get sample hole for the new sample
  259. return null;
  260. }
  261. // measurement area
  262. CDomain pMsrArea = CalculateDefaultArea(pHole);
  263. // measure data parameters containing particle analysis std, image scan parameter, image process parameter and x-ray parameter
  264. CSampleParam poMsrParams = new CSampleParam();
  265. poMsrParams.m_nPackId = GetDefaultParam().SystemTypeId;
  266. poMsrParams.m_runmode = GetDefaultParam().m_runmode;
  267. var m_pParam = GetDefaultParam().GetGenParam();
  268. MEMBRANE_TYPE a_nVal = (MEMBRANE_TYPE)m_pParam.GetMembraneType();
  269. poMsrParams.SetImageScanParam(GetDefaultParam().GetImageScanParam ());
  270. poMsrParams.SetImageProcessParam(GetDefaultParam().GetImageProcParam());
  271. poMsrParams.SetXRayParam(GetDefaultParam().GetXRayParam());
  272. String sSTDName = m_pParam.GetSTDSelect();
  273. poMsrParams.SetSTDName(sSTDName);
  274. poMsrParams.SetSteelTechnology((STEEL_TECHNOLOGY)m_pParam.GetSteelTechnology());
  275. poMsrParams.SetSpecialGrayRangeParam(SpecialRanges);
  276. // set sample parameters
  277. pSample.SetName(strNewSampleName);
  278. pSample.SetSampleHoleName(pHole.GetName());
  279. pSample.SetSwitch(m_pParam.GetMeasurementSwitch());
  280. poMsrParams.SetSysSTDSwitch(m_pParam.GetSysSTD());
  281. pSample.SetMsrDomain(pMsrArea);
  282. //pSample.SetMembraneType(a_nVal);
  283. pSample.SetMsrParams(poMsrParams);
  284. CSEMDataMsr semData = new CSEMDataMsr();
  285. var m_pSEMStageData = GetDefaultParam().GetStageDataParam();
  286. var imageScanParam = GetDefaultParam().GetImageScanParam();
  287. string resol = imageScanParam.GetImageResulotion().ToString();
  288. double resWidth = Convert.ToDouble(resol.Split('_')[1]);
  289. double resHeight = Convert.ToDouble(resol.Split('_')[2]);
  290. double heightWidthRatio = resHeight / resWidth;
  291. semData.SetScanFieldSize100(m_pSEMStageData.GetScanFieldSize100());
  292. double fieldHeight = m_pSEMStageData.GetScanFieldSize100() * heightWidthRatio;
  293. semData.SetScanFieldHeight100((int)fieldHeight);
  294. pSample.SetSEMDataMsr(semData);
  295. return pSample;
  296. }
  297. public String GetNewSampleName()
  298. {
  299. // new sample name
  300. String strNewSmplName = "";
  301. // safety check
  302. var m_pParam = GetDefaultParam().GetGenParam();
  303. if (m_pParam == null)
  304. {
  305. // shouldn't happen, invalid general parameter pointer.
  306. return strNewSmplName;
  307. }
  308. // new sample name base
  309. String strNewSmplNameBase = m_pParam.GetSampleName() + @"{0}";
  310. int nIndex = 1;
  311. do
  312. {
  313. // new sample name is new sample name base + number string
  314. strNewSmplName = string.Format(strNewSmplNameBase, nIndex);
  315. ++nIndex;
  316. }
  317. // make sure that the new sample name is not same with any sample in the samples list
  318. while (SameNameInList(strNewSmplName));
  319. // new sample name
  320. return strNewSmplName;
  321. }
  322. public bool SameNameInList(String a_strSampleName, int a_nExclude = -1)
  323. {
  324. // make sure the input sample name is not empty
  325. a_strSampleName.Trim();
  326. if (a_strSampleName == "")
  327. {
  328. // shouldn't happen, input name is an empty string
  329. return false;
  330. }
  331. // go through sample list
  332. int nIndex = 0;
  333. var m_listSamples = GetResultData().GetSampleList();
  334. foreach (var pSample in m_listSamples)
  335. {
  336. // return TRUE if this is not an exclude sample and its name is same with input
  337. String strSampleName = pSample.GetName();
  338. if (nIndex != a_nExclude && strSampleName.CompareTo(a_strSampleName) == 0)
  339. {
  340. // find a same name sample
  341. return true;
  342. }
  343. ++nIndex;
  344. }
  345. // no, same name sample in the same list, return FALSE
  346. return false;
  347. }
  348. // select a suitable sample hole for a new sample
  349. public CHole SelectASmpleHole(String a_strHoleName /*= _T("")*/)
  350. {
  351. // get holes list of the stage
  352. var m_pStage = GetStageParam().GetWorkingStage();
  353. List<CHole> listHoles = m_pStage.GetHoleList();
  354. //返回样品孔对象
  355. CHole cReHole ;
  356. // make sure the holes list is not empty
  357. if (listHoles.Count == 0)
  358. {
  359. // shouldn't happen, stage have no hole.
  360. return null;
  361. }
  362. // check the input hole name
  363. a_strHoleName.Trim();
  364. if (a_strHoleName != "")
  365. {
  366. // try to find matched hole
  367. for (int i = 0; i < listHoles.Count; i++)
  368. {
  369. if (listHoles[i].GetName() == a_strHoleName)
  370. {
  371. cReHole = listHoles[i];
  372. return cReHole;
  373. }
  374. }
  375. }
  376. // can't find a matched hole, then pick the first empty hole
  377. // go through the holes list
  378. foreach (var pHole in listHoles)
  379. {
  380. // has this hole any sample in it?
  381. String strHoleName = pHole.GetName();
  382. bool IsChanged = false;
  383. var m_listSamples = GetResultData().GetSampleList();
  384. foreach (COTSSample sampleItem in m_listSamples)
  385. {
  386. if (strHoleName == sampleItem.GetSampleHoleName())
  387. {
  388. IsChanged = true;
  389. }
  390. }
  391. if (!IsChanged)
  392. {
  393. return pHole;
  394. }
  395. }
  396. // no empty hole, then the first hole will be the one
  397. return listHoles[0];
  398. }
  399. public CDomain CalculateDefaultArea(CHole a_pHole)
  400. {
  401. RectangleF rectHole = a_pHole.GetDomainRect();
  402. System.Drawing.PointF ptCenter = new System.Drawing.PointF((rectHole.Left + rectHole.Right) / 2, (rectHole.Top + rectHole.Bottom) / 2);
  403. var m_pParam = GetDefaultParam().GetGenParam();
  404. DOMAIN_SHAPE nShape = m_pParam.GetShape();
  405. double dArea = m_pParam.GetArea() * 1000000;
  406. System.Drawing.PointF ptLeftTop = new System.Drawing.Point();
  407. System.Drawing.SizeF ptSize = new System.Drawing.Size();
  408. int nEdge = 0;
  409. int nRadius = 0;
  410. switch ((int)nShape)
  411. {
  412. case (int)DOMAIN_SHAPE.RECTANGLE:
  413. nEdge = (int)Math.Sqrt(dArea) / 2;
  414. ptLeftTop.X = ptCenter.X - nEdge;
  415. ptLeftTop.Y = ptCenter.Y - nEdge;
  416. ptSize.Width = ptCenter.X + nEdge - ptLeftTop.X;
  417. ptSize.Height = ptCenter.Y + nEdge - ptLeftTop.Y;
  418. break;
  419. case (int)DOMAIN_SHAPE.ROUND:
  420. nRadius = (int)Math.Sqrt(dArea / 3.1415926);
  421. ptLeftTop.X = ptCenter.X - nRadius;
  422. ptLeftTop.Y = ptCenter.Y - nRadius;
  423. ptSize.Width = ptCenter.X + nRadius - ptLeftTop.X;
  424. ptSize.Height = ptCenter.Y + nRadius - ptLeftTop.Y;
  425. break;
  426. }
  427. RectangleF MsrRect = new RectangleF(ptLeftTop, ptSize);
  428. CDomain pMsrArea = new CDomain(nShape, MsrRect);
  429. return pMsrArea;
  430. }
  431. //设置工作样品的属性值
  432. public bool SetSampleParamVal(OTS_SAMPLE_PROP_GRID_ITEMS ItemId, OTS_ITEM_TYPES ValType, object objVal)
  433. {
  434. COTSSample WSample = GetResultData().GetWorkingSample();
  435. OTSSampleVisualPropertyInfo MeasureInfo = new OTSSampleVisualPropertyInfo(WSample, defaultParam.GetSysType());
  436. bool bSetFalg = false;
  437. bSetFalg = MeasureInfo.SetParamVal(ItemId, ValType, objVal);
  438. if (bSetFalg)
  439. {
  440. GetResultData().SetModify(true);
  441. }
  442. return bSetFalg;
  443. }
  444. //获取工作样品名称
  445. public string GetWorkSampleName()
  446. {
  447. COTSSample WSample = GetResultData().GetWorkingSample();
  448. if (null == WSample)
  449. {
  450. return "";
  451. }
  452. string sWorkSampleName = WSample.GetName();
  453. if ("" == sWorkSampleName)
  454. {
  455. return "";
  456. }
  457. return sWorkSampleName;
  458. }
  459. //设置工作样品
  460. //string sNewWorkSampleName: 新工作样品
  461. public bool SetWorkSample(string sNewWorkSampleName)
  462. {
  463. if ("" == sNewWorkSampleName)
  464. {
  465. return false;
  466. }
  467. if (!GetResultData().SetWorkingSampleByName(sNewWorkSampleName))
  468. {
  469. return false;
  470. }
  471. return true;
  472. }
  473. //获取工作样品
  474. // 返回工作样品对象
  475. public COTSSample GetWorkSample()
  476. {
  477. COTSSample WSample = GetResultData().GetWorkingSample();
  478. return WSample;
  479. }
  480. //删除工作样品
  481. //string sWorkSampleName : 删除工作样品名称
  482. public bool DeleteWorkSample(string sWorkSampleName)
  483. {
  484. return GetResultData().DeleteSampleByName(sWorkSampleName);
  485. }
  486. // 获取样品总数
  487. //返回样品总数
  488. public int GetSampleCount()
  489. {
  490. return GetResultData().GetSampleList().Count();
  491. }
  492. //改变工作样品名称
  493. //String sWSampleNewName
  494. public bool ChangeWorkSampleName(String sWSampleNewName)
  495. {
  496. if (!GetResultData().IsValidSampleName(sWSampleNewName))
  497. {
  498. return false;
  499. }
  500. COTSSample WorkSample = GetResultData().GetWorkingSample();
  501. if (null == WorkSample)
  502. {
  503. return false;
  504. }
  505. WorkSample.SetName(sWSampleNewName);
  506. GetResultData().SetModify(true);
  507. return true;
  508. }
  509. //移动工作样品到其他样品孔,样品孔名称和测量区域都要改变,重新设置工作样品参数
  510. public void SetWorkSampleHoleAndMeasureArea(SampleMeasurePara SMeasurePara)
  511. {
  512. COTSSample WSample = GetResultData().GetWorkingSample();
  513. if (null == WSample)
  514. {
  515. return ;
  516. }
  517. CDomain Domain = new CDomain();
  518. Domain.SetShape((otsdataconst.DOMAIN_SHAPE)SMeasurePara.iShape);
  519. Domain.SetRectDomain(SMeasurePara.MeasureRect);
  520. if (SMeasurePara.DrawPolygonPointList != null)
  521. {
  522. List<Point> PolygonPoint = new List<Point>();
  523. foreach (var item in SMeasurePara.DrawPolygonPointList)
  524. {
  525. PolygonPoint.Add(new Point((int)item.X, (int)item.Y));
  526. }
  527. Domain.SetPolygonPoint(PolygonPoint);
  528. }
  529. WSample.SetSampleHoleName(SMeasurePara.sampleHoleName);
  530. WSample.SetMsrDomain(Domain);
  531. return ;
  532. }
  533. //设置测量区域的形状 (通过RIBBON 上的画圆,画矩形 设置)
  534. //int iShape: 测量区域形状 0: 圆形; 1 :矩形
  535. public void SetMeasureAreaShape(ShapeType iShape)
  536. {
  537. COTSSample WSample = GetResultData().GetWorkingSample();
  538. if (null == WSample)
  539. {
  540. return;
  541. }
  542. CDomain Domain = new CDomain();
  543. Domain.SetShape((otsdataconst.DOMAIN_SHAPE)iShape);
  544. }
  545. public bool SetWorkSampleParamLock(bool ParaLockFlag)
  546. {
  547. COTSSample WSample = GetResultData().GetWorkingSample();
  548. if (null == WSample)
  549. {
  550. return false;
  551. }
  552. WSample.SetParamLock(ParaLockFlag);
  553. GetResultData().SetModify(true);
  554. return true;
  555. }
  556. public bool CheckSampleParam(bool bCheckFlag)
  557. {
  558. m_MeasureSampleList.Clear();
  559. List<COTSSample> MSampleList = new List<COTSSample>();
  560. if (!CheckMeasureParam(GetResultData(), ref MSampleList, bCheckFlag))
  561. {
  562. return false;
  563. }
  564. if (MSampleList.Count > 0)
  565. {
  566. m_MeasureSampleList = MSampleList;
  567. return true;
  568. }
  569. return false;
  570. }
  571. public bool CheckMeasureParam(COTSMsrPrjResultData a_pProjMgrFile, ref List<COTSSample> a_listMeasuableSamples, bool a_bCheckSetting)
  572. {
  573. // go through the sample list to check setting parameters
  574. int nSwitchSmplNo = 0;
  575. int nCompletedSmplNo = 0;
  576. int nErrorSmplNo = 0;
  577. int nWarningSmplNo = 0;
  578. List<String> listSamplMessages = new List<string>();
  579. List<COTSSample> listSamples = a_pProjMgrFile.GetSampleList();
  580. List<COTSSample> listMeasurableSamples = new List<COTSSample>();
  581. List<COTSSample> listWithWarningMeasurableSamples = new List<COTSSample>();
  582. foreach (var pSample in listSamples)
  583. {
  584. // is the sample switch on
  585. if (pSample.GetSwitch())
  586. {
  587. ++nSwitchSmplNo;
  588. String strSmplMessage;
  589. strSmplMessage = pSample.GetName() + ":" + "\r\n";
  590. // is this a measurement completed sample
  591. if (IsMeasureCompletedSmpl(pSample))
  592. { // measurement completed sample
  593. ++nCompletedSmplNo;
  594. string str2 = GetSampleErrorWarnString(SAMPLE_FAULT_WARN_CODE.FINISHED);
  595. strSmplMessage += str2;
  596. strSmplMessage += "\r\n";
  597. }
  598. else
  599. {
  600. // errors
  601. List<SAMPLE_FAULT_WARN_CODE> a_listErrorCodes = new List<SAMPLE_FAULT_WARN_CODE>();
  602. GetSampleErrorCodes(a_pProjMgrFile, pSample, ref a_listErrorCodes);
  603. if (a_listErrorCodes.Count != 0)
  604. {
  605. // has error, this is not a measurable sample
  606. ++nErrorSmplNo;
  607. foreach (var nErrorCode in a_listErrorCodes)
  608. {
  609. String str3 = GetSampleErrorWarnString(nErrorCode);
  610. strSmplMessage += str3;
  611. strSmplMessage += "\r\n";
  612. }
  613. }
  614. else
  615. {
  616. // no error, this is a measurable sample
  617. listMeasurableSamples.Add(pSample);
  618. }
  619. // warnings
  620. List<SAMPLE_FAULT_WARN_CODE> a_listWarningCodes = new List<SAMPLE_FAULT_WARN_CODE>();
  621. GetSampleWarningCodes(a_pProjMgrFile, pSample, ref a_listWarningCodes);
  622. if (a_listWarningCodes.Count != 0)
  623. {
  624. ++nWarningSmplNo;
  625. foreach (var nWarningCode in a_listWarningCodes)
  626. {
  627. String str3 = GetSampleErrorWarnString(nWarningCode);
  628. strSmplMessage += str3;
  629. strSmplMessage += "\r\n";
  630. }
  631. // has no error?
  632. if (a_listErrorCodes.Count == 0)
  633. {
  634. // this is a measurable sample but with setting warnings
  635. listWithWarningMeasurableSamples.Add(pSample);
  636. }
  637. }
  638. // no error and warning
  639. if (a_listErrorCodes.Count == 0 && a_listWarningCodes.Count == 0)
  640. {
  641. String str3 = GetSampleErrorWarnString(SAMPLE_FAULT_WARN_CODE.NO_ERROR_WARNING);
  642. strSmplMessage += str3;
  643. strSmplMessage += "\r\n";
  644. }
  645. }
  646. // add
  647. listSamplMessages.Add(strSmplMessage);
  648. }
  649. }
  650. // dlg message string
  651. String strDlgMessage = "";
  652. String str;
  653. String str1;
  654. str1 = GetResourceByKey(GrpOtherParam, IDS_SAMPLE_CHECK_RESULT + (int)SAMPLE_CHECK_RESULT_TYPE.SWITCH_ON);
  655. str1 = str1.Replace("%d", "{0}");
  656. str = string.Format(str1, nSwitchSmplNo);
  657. strDlgMessage += str;
  658. strDlgMessage += "\r\n";
  659. // add more string if there switch on sample
  660. if (nSwitchSmplNo > 0)
  661. {
  662. // completed sample number (optional)
  663. if (nCompletedSmplNo > 0)
  664. {
  665. str1 = GetResourceByKey(GrpOtherParam, IDS_SAMPLE_CHECK_RESULT + (int)SAMPLE_CHECK_RESULT_TYPE.FINISHED);
  666. str1 = str1.Replace("%d", "{0}");
  667. str = string.Format(str1, nCompletedSmplNo);
  668. strDlgMessage += str;
  669. strDlgMessage += "\r\n";
  670. }
  671. // any unmeasured switch on samples?
  672. if (nSwitchSmplNo > nCompletedSmplNo)
  673. {
  674. // with setting error sample number
  675. str1 = GetResourceByKey(GrpOtherParam, IDS_SAMPLE_CHECK_RESULT + (int)SAMPLE_CHECK_RESULT_TYPE.SETTING_ERROR);
  676. str1 = str1.Replace("%d", "{0}");
  677. str = string.Format(str1, nErrorSmplNo);
  678. strDlgMessage += str;
  679. strDlgMessage += "\r\n";
  680. // with setting warning sample number
  681. str1 = GetResourceByKey(GrpOtherParam, IDS_SAMPLE_CHECK_RESULT + (int)SAMPLE_CHECK_RESULT_TYPE.SETTING_WARNING);
  682. str1 = str1.Replace("%d", "{0}");
  683. str = string.Format(str1, nWarningSmplNo);
  684. strDlgMessage += str;
  685. strDlgMessage += "\r\n";
  686. }
  687. }
  688. // add an empty line strDlgMessage
  689. strDlgMessage += "\r\n";
  690. // add sample messages
  691. foreach (var strSmplMessage in listSamplMessages)
  692. {
  693. strDlgMessage += strSmplMessage;
  694. strDlgMessage += "\r\n";
  695. }
  696. // do we need to show dialog box?
  697. if (nSwitchSmplNo == 0)
  698. {
  699. return false;
  700. }
  701. // measure button clicked?
  702. if (a_bCheckSetting)
  703. {
  704. // there are measurable samples but no setting warnings samples
  705. if (listMeasurableSamples.Count > 0 && listWithWarningMeasurableSamples.Count == 0)
  706. {
  707. // set output measurable samples list
  708. foreach (var pSample in listMeasurableSamples)
  709. {
  710. a_listMeasuableSamples.Add(pSample);
  711. }
  712. return true;
  713. }
  714. }
  715. //when there is sample setting error, and setting with no error and no warning samples, the dlg will not be show.??
  716. //show the result dlg
  717. DIALOG_CHECK_PARAM_RESULT dlg = new DIALOG_CHECK_PARAM_RESULT();
  718. int nTatolMeasuableSmplNo = listMeasurableSamples.Count;
  719. int nWithWarningMeasuableSmplNo = listWithWarningMeasurableSamples.Count;
  720. // set the dlg parameters
  721. dlg.SetCheckOnlyFlag(a_bCheckSetting);
  722. dlg.SetMessageBase(strDlgMessage);
  723. dlg.SetTatolMeasuableSmplNo(nTatolMeasuableSmplNo);
  724. dlg.SetWithWarningMeasuableSmplNo(nWithWarningMeasuableSmplNo);
  725. //no error not show dlg
  726. if (nTatolMeasuableSmplNo == nSwitchSmplNo - nCompletedSmplNo && listMeasurableSamples.Count != 0)
  727. {
  728. foreach (var pSample in listMeasurableSamples)
  729. {
  730. var itr = listWithWarningMeasurableSamples.Find(s => { return s.GetName() == pSample.GetName(); });
  731. if (itr == null)
  732. {
  733. a_listMeasuableSamples.Add(pSample);
  734. }
  735. }
  736. if (a_listMeasuableSamples.Count == listMeasurableSamples.Count)
  737. {
  738. return true;
  739. }
  740. }
  741. //show dlg
  742. DialogResult dResult = dlg.ShowDialog();
  743. if (!(dResult == System.Windows.Forms.DialogResult.OK))
  744. {
  745. // do something here
  746. return false;
  747. }
  748. else
  749. {
  750. //if warnDo, back the listMeasuableSample
  751. if (dlg.GetWarnDo())
  752. {
  753. foreach (var pSample in listMeasurableSamples)
  754. {
  755. a_listMeasuableSamples.Add(pSample);
  756. }
  757. }
  758. else // back with no warn sample
  759. {
  760. foreach (var pSample in listMeasurableSamples)
  761. {
  762. var itr = listWithWarningMeasurableSamples.Find(e => { return e.GetName() == pSample.GetName(); });
  763. if (itr == null)
  764. {
  765. a_listMeasuableSamples.Add(pSample);
  766. }
  767. }
  768. }
  769. }
  770. return true;
  771. }
  772. bool IsMeasureCompletedSmpl(COTSSample a_pSample)
  773. {
  774. // safety check
  775. if (a_pSample.GetMsrStatus().GetStatus() != OTSDataType.OTS_MSR_SAMPLE_STATUS.SUCCESSED)
  776. {
  777. return false;
  778. }
  779. return true;
  780. }
  781. string GetSampleErrorWarnString(SAMPLE_FAULT_WARN_CODE a_nSampleFaultWarn)
  782. {
  783. // check input
  784. if (a_nSampleFaultWarn < SAMPLE_FAULT_WARN_CODE.MIN && a_nSampleFaultWarn > SAMPLE_FAULT_WARN_CODE.MAX)
  785. {
  786. return "";
  787. }
  788. // error/waring string
  789. string strErrorWarn;
  790. strErrorWarn = GetResourceByKey(GrpOtherParam, IDS_ERROR_WARNING + (int)a_nSampleFaultWarn);
  791. return strErrorWarn;
  792. }
  793. // get error codes list of a sample
  794. void GetSampleErrorCodes(COTSMsrPrjResultData a_pProjMgrFile, COTSSample a_pSample, ref List<SAMPLE_FAULT_WARN_CODE> a_listErrorCodes)
  795. {
  796. const string UNTITLED_FILE_NAME = "Untitled";
  797. // file has not been saved
  798. String strPathName = a_pProjMgrFile.GetPathName();
  799. // is this a file no saved?
  800. strPathName.Trim();
  801. if (strPathName == UNTITLED_FILE_NAME || strPathName == "")
  802. {
  803. a_listErrorCodes.Add(SAMPLE_FAULT_WARN_CODE.FILE_NOT_SAVED);
  804. }
  805. }
  806. // get warning codes list of a sample
  807. void GetSampleWarningCodes(COTSMsrPrjResultData a_pProjMgrFile, COTSSample a_pSample, ref List<SAMPLE_FAULT_WARN_CODE> a_listWarningCodes)
  808. {
  809. // get the work stage
  810. CStage pStage = a_pProjMgrFile.GetStage();
  811. //get hole
  812. String sHoleName = a_pSample.GetSampleHoleName();
  813. //look for the hole Domain
  814. CHole pSampleHole = pStage.GetHoleByName(sHoleName);
  815. if (pSampleHole == null)
  816. {
  817. return;
  818. }
  819. if (a_pSample.GetSEMDataMsr() != null)
  820. {
  821. // compute pixel size
  822. double dPixleSize = a_pSample.CalculatePixelSize();
  823. // get min size
  824. COTSImageProcParam pImageProcParam = a_pSample.GetMsrParams().GetImageProcessParam();
  825. double dMinSize = pImageProcParam.GetIncAreaRange().GetStart();
  826. // if pixel size is bigger than 1/2 of the min size,than can't see the object clearly on current magnification
  827. if (dPixleSize >= dMinSize * 0.5)
  828. {
  829. // resolution low
  830. a_listWarningCodes.Add(SAMPLE_FAULT_WARN_CODE.RESOLUTION_LOW);
  831. }
  832. }
  833. if(a_pSample.GetSEMDataMsr().GetTotalFields()==0
  834. && a_pSample.GetSEMDataMsr().GetScanFieldSize() == 0
  835. && a_pSample.GetSEMDataMsr().GetWorkingDistance() == 0)
  836. {
  837. // SEM_DATA_ERROR
  838. a_listWarningCodes.Add(SAMPLE_FAULT_WARN_CODE.SEM_DATA_ERROR);
  839. }
  840. }
  841. //public bool SaveWorkMeasureFile()
  842. //{
  843. // CSampleParamMgr SMeasureParamData = new CSampleParamMgr();
  844. // COTSSample WSample = GetResultData().GetWorkingSample();
  845. // if (null == WSample)
  846. // {
  847. // return false;
  848. // }
  849. // if (!SMeasureParamData.SetMsrParamFile(WSample.GetMsrParams()))
  850. // {
  851. // return false;
  852. // }
  853. // // file open dialog
  854. // CSampleParamMgr cSampleParamMgr = new CSampleParamMgr();
  855. // SaveFileDialog saveFileDialog = new SaveFileDialog();
  856. // saveFileDialog.FileName = WSample.GetName() +"_Config"+ cSampleParamMgr.MESUREMENT_PARAM_FILE_EXT;
  857. // saveFileDialog.Filter = cSampleParamMgr.MESUREMENT_PARAM_FILE_FILTER;
  858. // if (saveFileDialog.ShowDialog() != DialogResult.OK)
  859. // {
  860. // return false;
  861. // }
  862. // // get file pathname
  863. // string strPathName = saveFileDialog.FileName;
  864. // SMeasureParamData.Save(strPathName);
  865. // return true;
  866. //}
  867. //打开工作样品的测量参数文件
  868. public bool LoadWorkMeasureFile()
  869. {
  870. CSampleParamMgr SMeasureParamData = new CSampleParamMgr();
  871. OpenFileDialog openFileDialog = new OpenFileDialog();
  872. openFileDialog.Filter = SMeasureParamData.MESUREMENT_PARAM_FILE_FILTER;
  873. if (openFileDialog.ShowDialog() != DialogResult.OK)
  874. {
  875. return false;
  876. }
  877. // get file pathname
  878. string strPathName = openFileDialog.FileName;
  879. if (!SMeasureParamData.Load(strPathName, true))
  880. {
  881. return false;
  882. }
  883. COTSSample WSample = GetResultData().GetWorkingSample();
  884. if (null == WSample)
  885. {
  886. return false;
  887. }
  888. WSample.SetMsrParams(SMeasureParamData.GetMsrParams());
  889. //更新样品GRID值测量文件名
  890. OTSSampleVisualPropertyInfo SMInfo = new OTSSampleVisualPropertyInfo(WSample,defaultParam.GetSysType());
  891. m_MeasureAppFrom.m_SPropertyWindows.DisplaySampleMeasureInfo(SMInfo);
  892. return true;
  893. }
  894. //判断是否允许修改样品名
  895. public bool CheckSampleNameIsValid(string sNewName)
  896. {
  897. return GetResultData().IsValidSampleName(sNewName);
  898. }
  899. //设置电镜参数
  900. //int iScanFieldSize: Field扫描参数
  901. //int iWDistance: 电镜工作距离
  902. //double dMagni: 放大倍数
  903. public void SetWorkingSampleSEMData(double iWDistance, double dMagni)
  904. {
  905. GetResultData().GetWorkingSample().GetSEMDataMsr().SetWorkingDistance(iWDistance);
  906. GetResultData().GetWorkingSample().GetSEMDataMsr().SetMagnification(dMagni);
  907. }
  908. //public void SetFliedsCount(int FliedsCount)
  909. //{
  910. // GetResultData().GetWorkingSample().GetSEMDataMsr().SetTotalFields(FliedsCount);
  911. //}
  912. public void GetWorkingSampleSEMData(ref double iWDistance, ref double dMagni)
  913. {
  914. iWDistance = GetResultData().GetWorkingSample().GetSEMDataMsr().GetWorkingDistance();
  915. dMagni = GetResultData().GetWorkingSample().GetSEMDataMsr().GetMagnification();
  916. }
  917. //public int GetTotalFieldsCount()
  918. //{
  919. // int icount = GetResultData().GetWorkingSample().GetSEMDataMsr().GetTotalFields();
  920. // return icount;
  921. //}
  922. //获取工作样品的测量区域
  923. //int iShape :测量区域形状
  924. //Rectangle Srect: 测量区域大小
  925. //public bool GetWorkSampleMrsArea(ref int iShape, ref RectangleF Srect)
  926. //{
  927. // COTSSample WSample = GetResultData().GetWorkingSample();
  928. // if (null == WSample)
  929. // {
  930. // return false;
  931. // }
  932. // CDomain pMsrArea = new CDomain();
  933. // pMsrArea = WSample.GetMsrDomain();
  934. // if (null == pMsrArea)
  935. // {
  936. // return false;
  937. // }
  938. // iShape = (int)pMsrArea.GetShape();
  939. // Srect = pMsrArea.GetRectDomain();
  940. // return true;
  941. //}
  942. //检查Samplelist中的sample的checkbox状态
  943. //当Samplelist中的链表有sample 的checkbox状态是选中状态,则返回TRUE. 说明可以测量
  944. public bool GetSampleCheckBoxStatus()
  945. {
  946. COTSSample WSample = GetResultData().GetWorkingSample();
  947. if (null == WSample)
  948. {
  949. return false;
  950. }
  951. List<COTSSample> SampleList = new List<COTSSample>();
  952. SampleList = GetResultData().GetSampleList();
  953. int iCount = SampleList.Count();
  954. if (0 == iCount)
  955. {
  956. return false;
  957. }
  958. for (int i = 0; i < iCount; i++)
  959. {
  960. if (SampleList[i].GetSwitch())
  961. {
  962. return true;
  963. }
  964. }
  965. return false;
  966. }
  967. //获取BSE图像数据
  968. public bool GetBSEImageSize(ref int iHeight, ref int iWidth)
  969. {
  970. COTSSample WSample = GetResultData().GetWorkingSample();
  971. if (null == WSample)
  972. {
  973. return false;
  974. }
  975. if (!WSample.GetBSESize(out iHeight, out iWidth))
  976. {
  977. return false;
  978. }
  979. return true;
  980. }
  981. //获取图像尺寸
  982. public string GetBSEImageResolutionStr()
  983. {
  984. try
  985. {
  986. COTSSample WSample = GetResultData().GetWorkingSample();
  987. var res= WSample.GetMsrParams().GetImageScanParam().GetImageResolutionSize();
  988. return res.cx+"X"+res.cy;
  989. }
  990. catch (Exception)
  991. {
  992. return "";
  993. }
  994. }
  995. //获取放大倍数和工作距离
  996. public bool GetMagAndDistance(ref double SemMag, ref double dDistance)
  997. {
  998. COTSSample WSample = GetResultData().GetWorkingSample();
  999. if (null == WSample)
  1000. {
  1001. return false;
  1002. }
  1003. GetWorkingSampleSEMData(ref dDistance, ref SemMag);
  1004. return true;
  1005. }
  1006. //保存测量样品的
  1007. //public bool SaveMeasureSampleInfo()
  1008. //{
  1009. // if (!GetResultData().Save())
  1010. // {
  1011. // return false;
  1012. // }
  1013. // return true;
  1014. //}
  1015. //获取测量Sample的开始时间
  1016. public bool GetMsrSampleStartTime(ref DateTime MsrFieldStartTime)
  1017. {
  1018. COTSSample WSample = GetResultData().GetWorkingSample();
  1019. if (null == WSample)
  1020. {
  1021. return false;
  1022. }
  1023. MsrFieldStartTime = (DateTime)WSample.GetMsrStatus().GetStartTime();
  1024. return true;
  1025. }
  1026. //获取测量已用时间
  1027. public bool GetMsrSampleUsedTime(ref TimeSpan TUsedTime)
  1028. {
  1029. COTSSample WSample = GetResultData().GetWorkingSample();
  1030. if (null == WSample)
  1031. {
  1032. return false;
  1033. }
  1034. TUsedTime = (TimeSpan)WSample.GetMsrStatus().GetUsedTime();
  1035. return true;
  1036. }
  1037. // 获取测量样品中之前已经测量完成Field帧图,(上一次未测量完成继续测试)
  1038. public bool GetBeforeCompleteField(ref string MsrSampleName, ref List<PointF> FieldList)
  1039. {
  1040. COTSSample WSample = GetResultData().GetWorkingSample();
  1041. if (null == WSample)
  1042. {
  1043. return false;
  1044. }
  1045. MsrSampleName = WSample.GetName();
  1046. FieldList = WSample.GetMsrStatus().GetCompletedFieldsCenter();
  1047. return true;
  1048. }
  1049. /// <summary>
  1050. /// 通过样品孔信息 返回默认测量区域大小
  1051. /// </summary>
  1052. /// <param name="cHoleClr"></param>
  1053. /// <returns></returns>
  1054. public RectangleF CalculateMsrArea(string cHoleName)
  1055. {
  1056. CHole cHoleClr = null;
  1057. foreach (CHole item in GetResultData().GetStage().GetHoleList())
  1058. {
  1059. if (item.GetName() == cHoleName)
  1060. {
  1061. cHoleClr = item;
  1062. }
  1063. }
  1064. CDomain CDomain = GetResultData().CalculateMsrArea(cHoleClr);
  1065. return CDomain.GetRectDomain();
  1066. }
  1067. /// <summary>
  1068. /// 获取已完成测量的结果文件路径
  1069. /// </summary>
  1070. /// <param name="mrFilePathList">返回测量结果文件路径</param>
  1071. /// <returns></returns>
  1072. public bool GetCompletedMeasureFileName(ref List<string> mrFilePathList)
  1073. {
  1074. //测量文件路径
  1075. string proFilePath = GetResultData().GetPathName();
  1076. //样品列表
  1077. List<COTSSample> sampleList = GetResultData().GetSampleList();
  1078. //获取样品数量
  1079. int sampleCount = sampleList.Count;
  1080. string mrSuffix = ".rst";
  1081. int existsCount = 0;
  1082. //获取测量文件路径
  1083. if (proFilePath.Equals("Untitled"))
  1084. {
  1085. return false;
  1086. }
  1087. string mrFolderPath = string.Empty;
  1088. try
  1089. {
  1090. mrFolderPath = proFilePath.Substring(0, proFilePath.LastIndexOf("\\"));
  1091. }
  1092. catch (Exception)
  1093. {
  1094. mrFolderPath = string.Empty;
  1095. }
  1096. for (int sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++)
  1097. {
  1098. int CompleteFieldsCount = sampleList[sampleIndex].GetMsrStatus().GetCompletedFields();
  1099. //如果样品已测量成功后再加载至报告程序中
  1100. if (CompleteFieldsCount > 0)
  1101. {
  1102. string sampleName = sampleList[sampleIndex].GetName();
  1103. string mrFilePath = mrFolderPath + "\\" + sampleName + "\\" + sampleName + mrSuffix;
  1104. //判断文件是否存在
  1105. if (File.Exists(mrFilePath))
  1106. {
  1107. if (mrFilePathList != null)
  1108. {
  1109. mrFilePathList.Add(mrFilePath);
  1110. }
  1111. existsCount++;
  1112. }
  1113. }
  1114. }
  1115. if (existsCount > 0)
  1116. {
  1117. return true;
  1118. }
  1119. return false;
  1120. }
  1121. /// <summary>
  1122. /// 获取工作样品的测量状态
  1123. /// </summary>
  1124. /// <param name="workingSampleName"></param>
  1125. /// <returns></returns>
  1126. public bool GetWorkSampleMeasureStatus()
  1127. {
  1128. bool reuslt = false;
  1129. COTSSample COTSSample = GetResultData().GetWorkingSample();
  1130. if (COTSSample == null) return false;
  1131. int sampleStatus = COTSSample.GetMsrStatus().GetCompletedFields();
  1132. if (sampleStatus > 0)
  1133. {
  1134. reuslt = true;
  1135. }
  1136. return reuslt;
  1137. }
  1138. }
  1139. }