MeasureParam.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. //时间:20200618
  2. //作者:郝爽
  3. //功能:测量参数
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using FileManager;
  10. using System.Xml;
  11. using System.IO;
  12. using System.Configuration;
  13. namespace MeasureData
  14. {
  15. public class MeasureParam : ISlo
  16. {
  17. #region 内容
  18. //工作条件,一次测量的全部切孔都是一类的
  19. // 样品类型
  20. private string m_SampleName;
  21. public string SampleType
  22. {
  23. get { return this.m_SampleName; }
  24. set { this.m_SampleName = value; }
  25. }
  26. public string SampleTypeNo()
  27. {
  28. return m_SampleName.Split('_')[0];//样品类型的命名必须是“0_XXXX" "1_XXXXX"的形式,前面的数字是与谭博士通信的类型指示
  29. }
  30. //是否仅拍照
  31. private Boolean is_Photograph;
  32. public Boolean IsShotSectionToRun
  33. {
  34. get { return this.is_Photograph; }
  35. set { this.is_Photograph = value; }
  36. }
  37. private bool m_IsGetFibPositionToRun;
  38. private bool m_IsFibCutingToRun;
  39. private bool m_IsMoveToCenterToRun;
  40. private bool m_IsLayerAnalysisToRun;
  41. //是否有pt工序
  42. private Boolean m_pt;
  43. public Boolean IfPT
  44. {
  45. get { return this.m_pt; }
  46. set { this.m_pt = value; }
  47. }
  48. //倾斜样品台
  49. private Boolean m_Tilt;
  50. public Boolean IfTilt
  51. {
  52. get { return this.m_Tilt; }
  53. set { this.m_Tilt = value; }
  54. }
  55. //是否有EDS
  56. private Boolean m_EDS;
  57. public Boolean IsEDSToRun
  58. {
  59. get { return this.m_EDS; }
  60. set { this.m_EDS = value; }
  61. }
  62. //能谱Z轴移动的位置
  63. private float edsZ;
  64. public float EDSZ
  65. {
  66. get { return this.edsZ; }
  67. set { this.edsZ = value; }
  68. }
  69. //能谱电压设定值
  70. private float edsV;
  71. public float EDSV
  72. {
  73. get { return this.edsV; }
  74. set { this.edsV = value; }
  75. }
  76. //能谱电压设定值
  77. private float edsA;
  78. public float EDSA
  79. {
  80. get { return this.edsA; }
  81. set { this.edsA = value; }
  82. }
  83. //Z轴移动的范围
  84. //private float m_dZ;
  85. //public float ZDistance
  86. //{
  87. // get { return this.m_dZ; }
  88. // set { this.m_dZ = value; }
  89. //}
  90. //FIB使用的ELY文件
  91. private string m_fibTemp;
  92. public string FIBTemp
  93. {
  94. get { return this.m_fibTemp; }
  95. set { this.m_fibTemp = value; }
  96. }
  97. //PT使用的ELY文件
  98. private string m_ptTemp;
  99. public string PTTemp
  100. {
  101. get { return this.m_ptTemp; }
  102. set { this.m_ptTemp = value; }
  103. }
  104. public string RemoteELYPath ;
  105. public string RemoteMLFPath;
  106. public string FocusServerIP { get; private set; }
  107. public string FocusServerPort { get; private set; }
  108. public string RemoteCutHoleInfoFilePath { get; private set; }
  109. //拉直操作需要的放大位数
  110. private float straighten_Magnification;
  111. public float Straighten_Magnification
  112. {
  113. get { return this.straighten_Magnification; }
  114. set { this.straighten_Magnification = value; }
  115. }
  116. public bool IsStraightenToRun;
  117. public bool StraightenAutoBC;
  118. public float StraightenManualBrightness;
  119. public float StraightenManualContrast;
  120. //定位切割位置的放大倍数
  121. private float location_Magnification;
  122. public float Location_Magnification
  123. {
  124. get { return this.location_Magnification; }
  125. set { this.location_Magnification = value; }
  126. }
  127. //定位切割位置的工作电压
  128. private float mVoltage;
  129. public float Voltage
  130. {
  131. get { return this.mVoltage; }
  132. set { this.mVoltage = value; }
  133. }
  134. public float Iprobe;
  135. //拍照的放大倍数
  136. private float photograph_Magnification;
  137. public float Photograph_Magnification
  138. {
  139. get { return this.photograph_Magnification; }
  140. set { this.photograph_Magnification = value; }
  141. }
  142. public bool ShotSectionAutoBC;
  143. public float ShotSectionManualBrightness;
  144. public float ShotSectionManualConstrast;
  145. //拍照的工作电压
  146. private float photograph_Voltage;
  147. public float Photograph_Voltage
  148. {
  149. get { return this.photograph_Voltage; }
  150. set { this.photograph_Voltage = value; }
  151. }
  152. //FIB拍照时的放大倍数
  153. private float fib_Magnification;
  154. public float FIB_Magnification
  155. {
  156. get { return this.fib_Magnification; }
  157. set { this.fib_Magnification = value; }
  158. }
  159. //校正角度选择
  160. private float correction_Angle_Inside;
  161. public float Correction_Angle_Inside
  162. {
  163. get { return this.correction_Angle_Inside; }
  164. set { this.correction_Angle_Inside = value; }
  165. }
  166. private float correction_Angle_OutSide;
  167. public float Correction_Angle_OutSide
  168. {
  169. get { return this.correction_Angle_OutSide; }
  170. set { this.correction_Angle_OutSide = value; }
  171. }
  172. //厂商
  173. private String firm;
  174. public String Firm
  175. {
  176. get { return this.firm; }
  177. set { this.firm = value; }
  178. }
  179. //EDS参数
  180. private EDSParam EdsParam;
  181. public EDSParam EDSParam
  182. {
  183. get { return this.EdsParam; }
  184. set { this.EdsParam = value; }
  185. }
  186. //ScanRotation修正角度
  187. private float scanRotCor;
  188. public float ScanRotCor
  189. {
  190. get { return this.scanRotCor; }
  191. set { this.scanRotCor = value; }
  192. }
  193. //ScanRotation修正角度
  194. private float pixelSizeCor;
  195. public float PixelSizeCor
  196. {
  197. get { return this.pixelSizeCor; }
  198. set { this.pixelSizeCor = value; }
  199. }
  200. //能谱参数
  201. //add by sun 2020-12-17 增加调试时是否切割开关
  202. //private bool m_IsCutingForDebug;
  203. //public bool IsCutingForDebug
  204. //{
  205. // get { return this.m_IsCutingForDebug; }
  206. // set { this.m_IsCutingForDebug = value; }
  207. //}
  208. //add by sun 2020-12-17 增加调试时是否切割开关 end
  209. //add by zjx 2020-12-18 为了测试只做能谱部分
  210. //private bool m_IsonlyEDSForDebug;
  211. //public bool IsonlyEDSToRun
  212. //{
  213. // get { return this.m_IsonlyEDSForDebug; }
  214. // set { this.m_IsonlyEDSForDebug = value; }
  215. //}
  216. private bool m_IsTiltCorrectionToRun;
  217. public bool IsTiltCorrectionToRun { get => m_IsTiltCorrectionToRun; set => m_IsTiltCorrectionToRun = value; }
  218. public bool IsGetFibPositionToRun { get => m_IsGetFibPositionToRun; set => m_IsGetFibPositionToRun = value; }
  219. public bool IsFibCutingToRun { get => m_IsFibCutingToRun; set => m_IsFibCutingToRun = value; }
  220. public bool IsMoveToCenterToRun { get => m_IsMoveToCenterToRun; set => m_IsMoveToCenterToRun = value; }
  221. public int MoveToCenterMagnification { get; private set; }
  222. public bool IsLayerAnalysisToRun { get => m_IsLayerAnalysisToRun; set => m_IsLayerAnalysisToRun = value; }
  223. public bool IsBeamShiftResetToRun { get; private set; }
  224. //add by zjx 2020-12-18 为了测试只做能谱部分 end
  225. #endregion
  226. //构造函数
  227. public MeasureParam()
  228. {
  229. Init();
  230. }
  231. public bool GetMeasureParamFromConfigration()
  232. {
  233. MeasureParam cfm = this;
  234. //设置配置文件默认值
  235. bool bResult = false;
  236. //bool.TryParse(ConfigurationManager.AppSettings["Is_Photograph"].ToString(), out bResult);
  237. //cfm.IsShotSectionToRun = bResult;
  238. bool.TryParse(ConfigurationManager.AppSettings["PT_Depostion"].ToString(), out bResult);
  239. cfm.IfPT = bResult;
  240. cfm.PTTemp = ConfigurationManager.AppSettings["PT_ELYFile"].ToString();
  241. cfm.FIBTemp = ConfigurationManager.AppSettings["FIB_ELYFile"].ToString();
  242. cfm.SampleType = ConfigurationManager.AppSettings["LastSampleType"].ToString();
  243. cfm.Firm = ConfigurationManager.AppSettings["LastSelectFirm"].ToString();
  244. bool.TryParse(ConfigurationManager.AppSettings["Is_Title"].ToString(), out bResult);
  245. cfm.IfTilt = bResult;
  246. bool.TryParse(ConfigurationManager.AppSettings["Is_EDS"].ToString(), out bResult);
  247. cfm.IsEDSToRun = bResult;
  248. cfm.ScanRotCor = Convert.ToSingle(ConfigurationManager.AppSettings["ScanRotCur"].ToString());
  249. cfm.PixelSizeCor = Convert.ToSingle(ConfigurationManager.AppSettings["PixelSize_Y_Cur"].ToString());
  250. cfm.IsEDSToRun = Convert.ToBoolean(ConfigurationManager.AppSettings["Is_EDS"].ToString());
  251. cfm.EDSZ = Convert.ToSingle(ConfigurationManager.AppSettings["EDS_Z"].ToString()) / 1000;
  252. cfm.EDSV = Convert.ToSingle(ConfigurationManager.AppSettings["EDS_V"].ToString());
  253. cfm.EDSA = Convert.ToSingle(ConfigurationManager.AppSettings["EDS_A"].ToString()) / 1000000000;
  254. cfm.EDSParam.XrayCollectMode = Convert.ToInt16(ConfigurationManager.AppSettings["EDS_XrayMode"].ToString());
  255. cfm.RemoteCutHoleInfoFilePath = ConfigurationManager.AppSettings["RemoteCutHoleInfoFilePath"];
  256. cfm.RemoteELYPath = ConfigurationManager.AppSettings["RemoteELYPath"];
  257. cfm.RemoteMLFPath = ConfigurationManager.AppSettings["RemoteMLFPath"];
  258. cfm.FocusServerIP = ConfigurationManager.AppSettings["FocusServerIP"];
  259. cfm.FocusServerPort = ConfigurationManager.AppSettings["FocusServerPort"];
  260. return true;
  261. }
  262. public bool loadParamFromSampleTypeTemplate(string filename)
  263. {
  264. DirectoryInfo TheFolder = new DirectoryInfo(System.Environment.CurrentDirectory + "\\SampleTemplate");
  265. XmlDocument doc = new XmlDocument();
  266. doc.Load(TheFolder+"\\"+filename);//载入xml文件
  267. XmlNode root = doc.SelectSingleNode("XMLData");
  268. xString firm = new xString();
  269. Slo sFile = new Slo();
  270. sFile.Register("DefaultFirmName", firm);
  271. Slo locateP = new Slo();
  272. xInt locMag = new xInt();
  273. locateP.Register("Magnification", locMag);
  274. sFile.Register("Locate", locateP);
  275. Slo votandI = new Slo();
  276. xInt vot = new xInt();
  277. xDouble iprobe = new xDouble();
  278. votandI.Register("Votage", vot);
  279. votandI.Register("Iprobe", iprobe);
  280. sFile.Register("VotageAndIprobe", votandI);
  281. Slo tCorrect = new Slo();
  282. xBool tcToRun = new xBool();
  283. xInt Outside = new xInt();
  284. xInt inside = new xInt();
  285. tCorrect.Register("Outside", Outside);
  286. tCorrect.Register("Inside", inside);
  287. tCorrect.Register("ToRun", tcToRun);
  288. sFile.Register("TiltCorrect", tCorrect);
  289. Slo straighten = new Slo();
  290. xInt Straightenmag = new xInt();
  291. xBool torun = new xBool();
  292. xInt b1 = new xInt();
  293. xInt c1 = new xInt();
  294. xBool auto1 = new xBool();
  295. straighten.Register("Magnification", Straightenmag);
  296. straighten.Register("ToRun", torun);
  297. straighten.Register("Hand_Bright", b1);
  298. straighten.Register("Hand_Contrast", c1);
  299. straighten.Register("AutoGet", auto1);
  300. sFile.Register("Straighten", straighten);
  301. Slo FIBposition = new Slo();
  302. xBool fcrun = new xBool();
  303. FIBposition.Register("ToRun", fcrun);
  304. sFile.Register("GetFIBPosition", FIBposition);
  305. Slo fibcuting = new Slo();//fibcross
  306. xBool fibrun = new xBool();
  307. fibcuting.Register("ToRun", fibrun);
  308. sFile.Register("FIBCutting", fibcuting);
  309. Slo movetocenter = new Slo();//findcross
  310. xBool mRun = new xBool();
  311. xInt movemag = new xInt();
  312. movetocenter.Register("ToRun", mRun);
  313. movetocenter.Register("Magnification", movemag);
  314. sFile.Register("MoveToCenter", movetocenter);
  315. Slo shotsection = new Slo();
  316. xBool sRun = new xBool();
  317. xInt shotmag = new xInt();
  318. xBool auto2 = new xBool();
  319. xInt b2 = new xInt();
  320. xInt c2 = new xInt();
  321. shotsection.Register("ToRun", sRun);
  322. shotsection.Register("Magnification", shotmag);
  323. shotsection.Register("Hand_Bright", b2);
  324. shotsection.Register("Hand_Contrast", c2);
  325. shotsection.Register("AutoGet", auto2);
  326. sFile.Register("ShotSection", shotsection);
  327. Slo layerAnalysis = new Slo();
  328. xBool lRun = new xBool();
  329. layerAnalysis.Register("ToRun", lRun);
  330. sFile.Register("LayerAnalysis", layerAnalysis);
  331. //Slo edsAnalysis = new Slo();
  332. //xBool eRun = new xBool();
  333. //edsAnalysis.Register("ToRun", eRun);
  334. //sFile.Register("EDSAnalysis", edsAnalysis);
  335. Slo beamshiftReset = new Slo();
  336. xBool bRun = new xBool();
  337. beamshiftReset.Register("ToRun", bRun);
  338. sFile.Register("BeamShiftReset", beamshiftReset);
  339. sFile.Serialize(false, doc, root);
  340. this.Location_Magnification = locMag.value();
  341. this.mVoltage = vot.value();
  342. this.Iprobe = (float)iprobe.value();
  343. this.IsTiltCorrectionToRun = tcToRun.value();
  344. this.correction_Angle_Inside = inside.value();
  345. this.correction_Angle_OutSide = Outside.value();
  346. this.IsStraightenToRun = torun.value();
  347. this.straighten_Magnification = Straightenmag.value();
  348. this.StraightenAutoBC = auto1.value();
  349. this.StraightenManualBrightness = b1.value();
  350. this.StraightenManualContrast = c1.value();
  351. this.IsGetFibPositionToRun = fcrun.value();
  352. this.IsFibCutingToRun= fibrun.value();
  353. this.IsMoveToCenterToRun = mRun.value();
  354. this.MoveToCenterMagnification = movemag.value();
  355. this.IsShotSectionToRun = sRun.value();
  356. this.photograph_Magnification = shotmag.value();
  357. this.ShotSectionAutoBC = auto2.value();
  358. this.ShotSectionManualBrightness = b2.value();
  359. this.ShotSectionManualConstrast = c2.value();
  360. this.IsLayerAnalysisToRun = lRun.value();
  361. //this.IsEDSToRun = eRun.value();
  362. this.IsBeamShiftResetToRun = bRun.value();
  363. return true;
  364. }
  365. public void Init()
  366. {
  367. this.SampleType = @"";
  368. this.IfPT = false;
  369. this.FIBTemp = @"";
  370. this.PTTemp = @"";
  371. this.IfTilt = false;
  372. this.IsEDSToRun = false;
  373. this.EDSZ = 0.005f;
  374. this.EDSV = 10000;
  375. this.EDSA = 0.0000000005f;
  376. this.EDSParam = new EDSParam();
  377. this.ScanRotCor = 1;
  378. this.PixelSizeCor = 1;
  379. }
  380. //XML文件保存测量参数
  381. public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
  382. {
  383. Slo sFile = new Slo();
  384. //是否拍照和PT
  385. xBool isPhotograph = new xBool();
  386. xBool ptDepostion = new xBool();
  387. xBool isTilt = new xBool();
  388. xBool isEDS = new xBool();
  389. isTilt.AssignValue(this.IfTilt);
  390. isEDS.AssignValue(this.IsEDSToRun);
  391. isPhotograph.AssignValue(this.is_Photograph);
  392. ptDepostion.AssignValue(this.m_pt);
  393. sFile.Register("Is_Title", isTilt);
  394. sFile.Register("Is_Photograph", isPhotograph);
  395. sFile.Register("PT_Depostion", ptDepostion);
  396. sFile.Register("Is_EDS", isEDS);
  397. //ELY文件
  398. xString ptELYFile = new xString();
  399. xString fibELYFile = new xString();
  400. ptELYFile.AssignValue(this.m_ptTemp);
  401. fibELYFile.AssignValue(this.m_fibTemp);
  402. sFile.Register("PT_ELYFile", ptELYFile);
  403. sFile.Register("FIB_ELYFile", fibELYFile);
  404. //对焦方式
  405. xInt focusmode = new xInt();
  406. sFile.Register("FocusMode", focusmode);
  407. //放大倍数和电压参数
  408. xDouble stretchMagnification = new xDouble();
  409. xDouble locationMagnification = new xDouble();
  410. xDouble locationVoltage = new xDouble();
  411. xDouble photographMagnification = new xDouble();
  412. xDouble photographVoltage = new xDouble();
  413. xDouble fibMagnification = new xDouble();
  414. xDouble ZDistance = new xDouble();
  415. xDouble xEDSZ = new xDouble();
  416. xDouble xEDSV = new xDouble();
  417. xDouble xEDSA = new xDouble();
  418. xEDSZ.AssignValue(this.edsZ);
  419. xEDSV.AssignValue(this.edsV);
  420. xEDSA.AssignValue(this.edsA);
  421. //ZDistance.AssignValue(this.ZDistance);
  422. stretchMagnification.AssignValue(this.straighten_Magnification);
  423. locationMagnification.AssignValue(this.location_Magnification);
  424. locationVoltage.AssignValue(this.mVoltage);
  425. photographMagnification.AssignValue(this.photograph_Magnification);
  426. photographVoltage.AssignValue(this.photograph_Voltage);
  427. fibMagnification.AssignValue(this.fib_Magnification);
  428. sFile.Register("Strectch_Magnification", stretchMagnification);
  429. sFile.Register("Locatio_Magnification", locationMagnification);
  430. sFile.Register("Location_Voltage", locationVoltage);
  431. sFile.Register("Photograph_Magnification", photographMagnification);
  432. sFile.Register("Photograph_Voltage", photographVoltage);
  433. sFile.Register("FIB_Magnification", fibMagnification);
  434. //sFile.Register("ZDistance", ZDistance);
  435. sFile.Register("EDSZ", xEDSZ);
  436. sFile.Register("EDSV", xEDSV);
  437. sFile.Register("EDSA", xEDSA);
  438. //校正角度
  439. xDouble correctionAngle = new xDouble();
  440. correctionAngle.AssignValue(this.correction_Angle_Inside);
  441. sFile.Register("Correction_Angle", correctionAngle);
  442. //样品名称和厂商
  443. xString sampleType = new xString();
  444. xString _firm = new xString();
  445. sampleType.AssignValue(this.m_SampleName);
  446. _firm.AssignValue(this.firm);
  447. sFile.Register("Sample_Type", sampleType);
  448. sFile.Register("Firm", _firm);
  449. sFile.Register("EDS_Param", this.EDSParam);
  450. //ScanRotate修正
  451. xDouble scanRotate = new xDouble();
  452. scanRotate.AssignValue(this.scanRotCor);
  453. sFile.Register("ScanRotateCorrect", scanRotate);
  454. //PixelSize_Y轴补偿
  455. xDouble pscor = new xDouble();
  456. pscor.AssignValue(this.pixelSizeCor);
  457. sFile.Register("PixelSizeYCorrect", pscor);
  458. if (isStoring)
  459. {
  460. sFile.Serialize(true, xml, rootNode);
  461. }
  462. else
  463. {
  464. sFile.Serialize(false, xml, rootNode);
  465. this.is_Photograph = isPhotograph.value();
  466. this.m_pt = ptDepostion.value();
  467. this.IfTilt = isTilt.value();
  468. this.IsEDSToRun = isEDS.value();
  469. this.m_ptTemp = ptELYFile.value();
  470. this.m_fibTemp = fibELYFile.value();
  471. this.straighten_Magnification = Convert.ToSingle(stretchMagnification.value());
  472. this.location_Magnification = Convert.ToSingle(locationMagnification.value());
  473. this.mVoltage = Convert.ToSingle(locationVoltage.value());
  474. this.photograph_Magnification = Convert.ToSingle(photographMagnification.value());
  475. this.photograph_Voltage = Convert.ToSingle(photographVoltage.value());
  476. this.correction_Angle_Inside = Convert.ToSingle(correctionAngle.value());
  477. this.m_SampleName = sampleType.value();
  478. this.firm = _firm.value();
  479. //this.ZDistance = Convert.ToSingle(ZDistance.value());
  480. this.EDSZ = Convert.ToSingle(xEDSZ.value());
  481. this.EDSV = Convert.ToSingle(xEDSV.value());
  482. this.EDSA = Convert.ToSingle(xEDSA.value());
  483. this.ScanRotCor = Convert.ToSingle(scanRotate.value());
  484. this.PixelSizeCor = Convert.ToSingle(pscor.value());
  485. }
  486. }
  487. }
  488. }