COTSMeasureParam.cs 49 KB

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