MeasureParam.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  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 RemoteFIBOriginalEly
  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 RemotePTOriginalEly
  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 RemoteELYDesPath { get; private set; }
  107. public string RemoteMLFDesPath { get; private set; }
  108. public string FocusServerIP { get; private set; }
  109. public string FocusServerPort { get; private set; }
  110. public string RemoteCutHoleInfoFilePath { get; private set; }
  111. public string RemoteHintELYPath { get; private set; }
  112. public string RemoteHintMLFPath { get; private set; }
  113. //拉直操作需要的放大位数
  114. private float straighten_Magnification;
  115. public float Straighten_Magnification
  116. {
  117. get { return this.straighten_Magnification; }
  118. set { this.straighten_Magnification = value; }
  119. }
  120. public bool IsStraightenToRun;
  121. public bool StraightenAutoBC;
  122. public float StraightenManualBrightness;
  123. public float StraightenManualContrast;
  124. //定位切割位置的放大倍数
  125. private float location_Magnification;
  126. public float Location_Magnification
  127. {
  128. get { return this.location_Magnification; }
  129. set { this.location_Magnification = value; }
  130. }
  131. //定位切割位置的工作电压
  132. private float mVoltage;
  133. public float Voltage
  134. {
  135. get { return this.mVoltage; }
  136. set { this.mVoltage = value; }
  137. }
  138. public float Iprobe;
  139. //拍照的放大倍数
  140. private float photograph_Magnification;
  141. public float Photograph_Magnification
  142. {
  143. get { return this.photograph_Magnification; }
  144. set { this.photograph_Magnification = value; }
  145. }
  146. public bool ShotSectionAutoBC;
  147. public float ShotSectionManualBrightness;
  148. public float ShotSectionManualConstrast;
  149. //拍照的工作电压
  150. private float photograph_Voltage;
  151. public float Photograph_Voltage
  152. {
  153. get { return this.photograph_Voltage; }
  154. set { this.photograph_Voltage = value; }
  155. }
  156. //FIB拍照时的放大倍数
  157. private float fib_Magnification;
  158. public float FIB_Magnification
  159. {
  160. get { return this.fib_Magnification; }
  161. set { this.fib_Magnification = value; }
  162. }
  163. //校正角度选择
  164. private float correction_Angle_Inside;
  165. public float Correction_Angle_Inside
  166. {
  167. get { return this.correction_Angle_Inside; }
  168. set { this.correction_Angle_Inside = value; }
  169. }
  170. private float correction_Angle_OutSide;
  171. public float Correction_Angle_OutSide
  172. {
  173. get { return this.correction_Angle_OutSide; }
  174. set { this.correction_Angle_OutSide = value; }
  175. }
  176. //厂商
  177. private String firm;
  178. public String Firm
  179. {
  180. get { return this.firm; }
  181. set { this.firm = value; }
  182. }
  183. //EDS参数
  184. private EDSParam EdsParam;
  185. public EDSParam EDSParam
  186. {
  187. get { return this.EdsParam; }
  188. set { this.EdsParam = value; }
  189. }
  190. //ScanRotation修正角度
  191. private float scanRotCor;
  192. public float ScanRotCor
  193. {
  194. get { return this.scanRotCor; }
  195. set { this.scanRotCor = value; }
  196. }
  197. //ScanRotation修正角度
  198. private float pixelSizeCor;
  199. public float PixelSizeCor
  200. {
  201. get { return this.pixelSizeCor; }
  202. set { this.pixelSizeCor = value; }
  203. }
  204. //能谱参数
  205. //add by sun 2020-12-17 增加调试时是否切割开关
  206. //private bool m_IsCutingForDebug;
  207. //public bool IsCutingForDebug
  208. //{
  209. // get { return this.m_IsCutingForDebug; }
  210. // set { this.m_IsCutingForDebug = value; }
  211. //}
  212. //add by sun 2020-12-17 增加调试时是否切割开关 end
  213. //add by zjx 2020-12-18 为了测试只做能谱部分
  214. //private bool m_IsonlyEDSForDebug;
  215. //public bool IsonlyEDSToRun
  216. //{
  217. // get { return this.m_IsonlyEDSForDebug; }
  218. // set { this.m_IsonlyEDSForDebug = value; }
  219. //}
  220. private bool m_IsTiltCorrectionToRun;
  221. public bool IsTiltCorrectionToRun { get => m_IsTiltCorrectionToRun; set => m_IsTiltCorrectionToRun = value; }
  222. public bool IsGetFibPositionToRun { get => m_IsGetFibPositionToRun; set => m_IsGetFibPositionToRun = value; }
  223. public bool IsFibCutingToRun { get => m_IsFibCutingToRun; set => m_IsFibCutingToRun = value; }
  224. public bool IsMoveToCenterToRun { get => m_IsMoveToCenterToRun; set => m_IsMoveToCenterToRun = value; }
  225. public int MoveToCenterMagnification { get; private set; }
  226. public bool IsLayerAnalysisToRun { get => m_IsLayerAnalysisToRun; set => m_IsLayerAnalysisToRun = value; }
  227. public bool IsBeamShiftResetToRun { get; private set; }
  228. //add by zjx 2020-12-18 为了测试只做能谱部分 end
  229. #endregion
  230. //构造函数
  231. public MeasureParam()
  232. {
  233. Init();
  234. }
  235. public bool GetMeasureParamFromConfigration()
  236. {
  237. MeasureParam cfm = this;
  238. //设置配置文件默认值
  239. bool bResult = false;
  240. //bool.TryParse(ConfigurationManager.AppSettings["Is_Photograph"].ToString(), out bResult);
  241. //cfm.IsShotSectionToRun = bResult;
  242. bool.TryParse(ConfigurationManager.AppSettings["PT_Depostion"].ToString(), out bResult);
  243. cfm.IfPT = bResult;
  244. cfm.RemotePTOriginalEly = ConfigurationManager.AppSettings["PT_ELYFile"].ToString();
  245. cfm.RemoteFIBOriginalEly = ConfigurationManager.AppSettings["FIB_ELYFile"].ToString();
  246. cfm.SampleType = ConfigurationManager.AppSettings["LastSampleType"].ToString();
  247. cfm.Firm = ConfigurationManager.AppSettings["LastSelectFirm"].ToString();
  248. bool.TryParse(ConfigurationManager.AppSettings["Is_Title"].ToString(), out bResult);
  249. cfm.IfTilt = bResult;
  250. bool.TryParse(ConfigurationManager.AppSettings["Is_EDS"].ToString(), out bResult);
  251. cfm.IsEDSToRun = bResult;
  252. cfm.ScanRotCor = Convert.ToSingle(ConfigurationManager.AppSettings["ScanRotCur"].ToString());
  253. cfm.PixelSizeCor = Convert.ToSingle(ConfigurationManager.AppSettings["PixelSize_Y_Cur"].ToString());
  254. cfm.IsEDSToRun = Convert.ToBoolean(ConfigurationManager.AppSettings["Is_EDS"].ToString());
  255. cfm.EDSZ = Convert.ToSingle(ConfigurationManager.AppSettings["EDS_Z"].ToString()) / 1000;
  256. cfm.EDSV = Convert.ToSingle(ConfigurationManager.AppSettings["EDS_V"].ToString());
  257. cfm.EDSA = Convert.ToSingle(ConfigurationManager.AppSettings["EDS_A"].ToString()) / 1000000000;
  258. cfm.EDSParam.XrayCollectMode = Convert.ToInt16(ConfigurationManager.AppSettings["EDS_XrayMode"].ToString());
  259. cfm.RemoteCutHoleInfoFilePath = ConfigurationManager.AppSettings["RemoteCutHoleInfoFilePath"];
  260. cfm.RemoteHintELYPath = ConfigurationManager.AppSettings["RemoteHintELYPath"];
  261. cfm.RemoteHintMLFPath = ConfigurationManager.AppSettings["RemoteHintMLFPath"];
  262. cfm.RemoteELYDesPath = ConfigurationManager.AppSettings["RemoteELYDesPath"];
  263. cfm.RemoteMLFDesPath = ConfigurationManager.AppSettings["RemoteMLFDesPath"];
  264. cfm.FocusServerIP = ConfigurationManager.AppSettings["FocusServerIP"];
  265. cfm.FocusServerPort = ConfigurationManager.AppSettings["FocusServerPort"];
  266. return true;
  267. }
  268. public bool loadParamFromSampleTypeTemplate(string filename)
  269. {
  270. DirectoryInfo TheFolder = new DirectoryInfo(System.Environment.CurrentDirectory + "\\SampleTemplate");
  271. XmlDocument doc = new XmlDocument();
  272. doc.Load(TheFolder+"\\"+filename);//载入xml文件
  273. XmlNode root = doc.SelectSingleNode("XMLData");
  274. xString firm = new xString();
  275. Slo sFile = new Slo();
  276. sFile.Register("DefaultFirmName", firm);
  277. Slo locateP = new Slo();
  278. xInt locMag = new xInt();
  279. locateP.Register("Magnification", locMag);
  280. sFile.Register("Locate", locateP);
  281. Slo votandI = new Slo();
  282. xInt vot = new xInt();
  283. xDouble iprobe = new xDouble();
  284. votandI.Register("Votage", vot);
  285. votandI.Register("Iprobe", iprobe);
  286. sFile.Register("VotageAndIprobe", votandI);
  287. Slo tCorrect = new Slo();
  288. xBool tcToRun = new xBool();
  289. xInt Outside = new xInt();
  290. xInt inside = new xInt();
  291. tCorrect.Register("Outside", Outside);
  292. tCorrect.Register("Inside", inside);
  293. tCorrect.Register("ToRun", tcToRun);
  294. sFile.Register("TiltCorrect", tCorrect);
  295. Slo straighten = new Slo();
  296. xInt Straightenmag = new xInt();
  297. xBool torun = new xBool();
  298. xInt b1 = new xInt();
  299. xInt c1 = new xInt();
  300. xBool auto1 = new xBool();
  301. straighten.Register("Magnification", Straightenmag);
  302. straighten.Register("ToRun", torun);
  303. straighten.Register("Hand_Bright", b1);
  304. straighten.Register("Hand_Contrast", c1);
  305. straighten.Register("AutoGet", auto1);
  306. sFile.Register("Straighten", straighten);
  307. Slo FIBposition = new Slo();
  308. xBool fcrun = new xBool();
  309. FIBposition.Register("ToRun", fcrun);
  310. sFile.Register("GetFIBPosition", FIBposition);
  311. Slo fibcuting = new Slo();//fibcross
  312. xBool fibrun = new xBool();
  313. fibcuting.Register("ToRun", fibrun);
  314. sFile.Register("FIBCutting", fibcuting);
  315. Slo movetocenter = new Slo();//findcross
  316. xBool mRun = new xBool();
  317. xInt movemag = new xInt();
  318. movetocenter.Register("ToRun", mRun);
  319. movetocenter.Register("Magnification", movemag);
  320. sFile.Register("MoveToCenter", movetocenter);
  321. Slo shotsection = new Slo();
  322. xBool sRun = new xBool();
  323. xInt shotmag = new xInt();
  324. xBool auto2 = new xBool();
  325. xInt b2 = new xInt();
  326. xInt c2 = new xInt();
  327. shotsection.Register("ToRun", sRun);
  328. shotsection.Register("Magnification", shotmag);
  329. shotsection.Register("Hand_Bright", b2);
  330. shotsection.Register("Hand_Contrast", c2);
  331. shotsection.Register("AutoGet", auto2);
  332. sFile.Register("ShotSection", shotsection);
  333. Slo layerAnalysis = new Slo();
  334. xBool lRun = new xBool();
  335. layerAnalysis.Register("ToRun", lRun);
  336. sFile.Register("LayerAnalysis", layerAnalysis);
  337. //Slo edsAnalysis = new Slo();
  338. //xBool eRun = new xBool();
  339. //edsAnalysis.Register("ToRun", eRun);
  340. //sFile.Register("EDSAnalysis", edsAnalysis);
  341. Slo beamshiftReset = new Slo();
  342. xBool bRun = new xBool();
  343. beamshiftReset.Register("ToRun", bRun);
  344. sFile.Register("BeamShiftReset", beamshiftReset);
  345. sFile.Serialize(false, doc, root);
  346. this.Location_Magnification = locMag.value();
  347. this.mVoltage = vot.value();
  348. this.Iprobe = (float)iprobe.value();
  349. this.IsTiltCorrectionToRun = tcToRun.value();
  350. this.correction_Angle_Inside = inside.value();
  351. this.correction_Angle_OutSide = Outside.value();
  352. this.IsStraightenToRun = torun.value();
  353. this.straighten_Magnification = Straightenmag.value();
  354. this.StraightenAutoBC = auto1.value();
  355. this.StraightenManualBrightness = b1.value();
  356. this.StraightenManualContrast = c1.value();
  357. this.IsGetFibPositionToRun = fcrun.value();
  358. this.IsFibCutingToRun= fibrun.value();
  359. this.IsMoveToCenterToRun = mRun.value();
  360. this.MoveToCenterMagnification = movemag.value();
  361. this.IsShotSectionToRun = sRun.value();
  362. this.photograph_Magnification = shotmag.value();
  363. this.ShotSectionAutoBC = auto2.value();
  364. this.ShotSectionManualBrightness = b2.value();
  365. this.ShotSectionManualConstrast = c2.value();
  366. this.IsLayerAnalysisToRun = lRun.value();
  367. //this.IsEDSToRun = eRun.value();
  368. this.IsBeamShiftResetToRun = bRun.value();
  369. return true;
  370. }
  371. public void Init()
  372. {
  373. this.SampleType = @"";
  374. this.IfPT = false;
  375. this.RemoteFIBOriginalEly = @"";
  376. this.RemotePTOriginalEly = @"";
  377. this.IfTilt = false;
  378. this.IsEDSToRun = false;
  379. this.EDSZ = 0.005f;
  380. this.EDSV = 10000;
  381. this.EDSA = 0.0000000005f;
  382. this.EDSParam = new EDSParam();
  383. this.ScanRotCor = 1;
  384. this.PixelSizeCor = 1;
  385. }
  386. //XML文件保存测量参数
  387. public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
  388. {
  389. Slo sFile = new Slo();
  390. //是否拍照和PT
  391. xBool isPhotograph = new xBool();
  392. xBool ptDepostion = new xBool();
  393. xBool isTilt = new xBool();
  394. xBool isEDS = new xBool();
  395. isTilt.AssignValue(this.IfTilt);
  396. isEDS.AssignValue(this.IsEDSToRun);
  397. isPhotograph.AssignValue(this.is_Photograph);
  398. ptDepostion.AssignValue(this.m_pt);
  399. sFile.Register("Is_Title", isTilt);
  400. sFile.Register("Is_Photograph", isPhotograph);
  401. sFile.Register("PT_Depostion", ptDepostion);
  402. sFile.Register("Is_EDS", isEDS);
  403. //ELY文件
  404. xString ptELYFile = new xString();
  405. xString fibELYFile = new xString();
  406. ptELYFile.AssignValue(this.m_ptTemp);
  407. fibELYFile.AssignValue(this.m_fibTemp);
  408. sFile.Register("PT_ELYFile", ptELYFile);
  409. sFile.Register("FIB_ELYFile", fibELYFile);
  410. //对焦方式
  411. xInt focusmode = new xInt();
  412. sFile.Register("FocusMode", focusmode);
  413. //放大倍数和电压参数
  414. xDouble stretchMagnification = new xDouble();
  415. xDouble locationMagnification = new xDouble();
  416. xDouble locationVoltage = new xDouble();
  417. xDouble photographMagnification = new xDouble();
  418. xDouble photographVoltage = new xDouble();
  419. xDouble fibMagnification = new xDouble();
  420. xDouble ZDistance = new xDouble();
  421. xDouble xEDSZ = new xDouble();
  422. xDouble xEDSV = new xDouble();
  423. xDouble xEDSA = new xDouble();
  424. xEDSZ.AssignValue(this.edsZ);
  425. xEDSV.AssignValue(this.edsV);
  426. xEDSA.AssignValue(this.edsA);
  427. //ZDistance.AssignValue(this.ZDistance);
  428. stretchMagnification.AssignValue(this.straighten_Magnification);
  429. locationMagnification.AssignValue(this.location_Magnification);
  430. locationVoltage.AssignValue(this.mVoltage);
  431. photographMagnification.AssignValue(this.photograph_Magnification);
  432. photographVoltage.AssignValue(this.photograph_Voltage);
  433. fibMagnification.AssignValue(this.fib_Magnification);
  434. sFile.Register("Strectch_Magnification", stretchMagnification);
  435. sFile.Register("Locatio_Magnification", locationMagnification);
  436. sFile.Register("Location_Voltage", locationVoltage);
  437. sFile.Register("Photograph_Magnification", photographMagnification);
  438. sFile.Register("Photograph_Voltage", photographVoltage);
  439. sFile.Register("FIB_Magnification", fibMagnification);
  440. //sFile.Register("ZDistance", ZDistance);
  441. sFile.Register("EDSZ", xEDSZ);
  442. sFile.Register("EDSV", xEDSV);
  443. sFile.Register("EDSA", xEDSA);
  444. //校正角度
  445. xDouble correctionAngle = new xDouble();
  446. correctionAngle.AssignValue(this.correction_Angle_Inside);
  447. sFile.Register("Correction_Angle", correctionAngle);
  448. //样品名称和厂商
  449. xString sampleType = new xString();
  450. xString _firm = new xString();
  451. sampleType.AssignValue(this.m_SampleName);
  452. _firm.AssignValue(this.firm);
  453. sFile.Register("Sample_Type", sampleType);
  454. sFile.Register("Firm", _firm);
  455. sFile.Register("EDS_Param", this.EDSParam);
  456. //ScanRotate修正
  457. xDouble scanRotate = new xDouble();
  458. scanRotate.AssignValue(this.scanRotCor);
  459. sFile.Register("ScanRotateCorrect", scanRotate);
  460. //PixelSize_Y轴补偿
  461. xDouble pscor = new xDouble();
  462. pscor.AssignValue(this.pixelSizeCor);
  463. sFile.Register("PixelSizeYCorrect", pscor);
  464. if (isStoring)
  465. {
  466. sFile.Serialize(true, xml, rootNode);
  467. }
  468. else
  469. {
  470. sFile.Serialize(false, xml, rootNode);
  471. this.is_Photograph = isPhotograph.value();
  472. this.m_pt = ptDepostion.value();
  473. this.IfTilt = isTilt.value();
  474. this.IsEDSToRun = isEDS.value();
  475. this.m_ptTemp = ptELYFile.value();
  476. this.m_fibTemp = fibELYFile.value();
  477. this.straighten_Magnification = Convert.ToSingle(stretchMagnification.value());
  478. this.location_Magnification = Convert.ToSingle(locationMagnification.value());
  479. this.mVoltage = Convert.ToSingle(locationVoltage.value());
  480. this.photograph_Magnification = Convert.ToSingle(photographMagnification.value());
  481. this.photograph_Voltage = Convert.ToSingle(photographVoltage.value());
  482. this.correction_Angle_Inside = Convert.ToSingle(correctionAngle.value());
  483. this.m_SampleName = sampleType.value();
  484. this.firm = _firm.value();
  485. //this.ZDistance = Convert.ToSingle(ZDistance.value());
  486. this.EDSZ = Convert.ToSingle(xEDSZ.value());
  487. this.EDSV = Convert.ToSingle(xEDSV.value());
  488. this.EDSA = Convert.ToSingle(xEDSA.value());
  489. this.ScanRotCor = Convert.ToSingle(scanRotate.value());
  490. this.PixelSizeCor = Convert.ToSingle(pscor.value());
  491. }
  492. }
  493. }
  494. }