MeasureParam.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  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 Is_Photograph
  33. {
  34. get { return this.is_Photograph; }
  35. set { this.is_Photograph = value; }
  36. }
  37. //是否有pt工序
  38. private Boolean m_pt;
  39. public Boolean PT
  40. {
  41. get { return this.m_pt; }
  42. set { this.m_pt = value; }
  43. }
  44. //倾斜样品台
  45. private Boolean m_Tilt;
  46. public Boolean Tilt
  47. {
  48. get { return this.m_Tilt; }
  49. set { this.m_Tilt = value; }
  50. }
  51. //是否有EDS
  52. private Boolean m_EDS;
  53. public Boolean EDS
  54. {
  55. get { return this.m_EDS; }
  56. set { this.m_EDS = value; }
  57. }
  58. //能谱Z轴移动的位置
  59. private float edsZ;
  60. public float EDSZ
  61. {
  62. get { return this.edsZ; }
  63. set { this.edsZ = value; }
  64. }
  65. //能谱电压设定值
  66. private float edsV;
  67. public float EDSV
  68. {
  69. get { return this.edsV; }
  70. set { this.edsV = value; }
  71. }
  72. //能谱电压设定值
  73. private float edsA;
  74. public float EDSA
  75. {
  76. get { return this.edsA; }
  77. set { this.edsA = value; }
  78. }
  79. //Z轴移动的范围
  80. //private float m_dZ;
  81. //public float ZDistance
  82. //{
  83. // get { return this.m_dZ; }
  84. // set { this.m_dZ = value; }
  85. //}
  86. //FIB使用的ELY文件
  87. private string m_fibTemp;
  88. public string FIBTemp
  89. {
  90. get { return this.m_fibTemp; }
  91. set { this.m_fibTemp = value; }
  92. }
  93. //PT使用的ELY文件
  94. private string m_ptTemp;
  95. public string PTTemp
  96. {
  97. get { return this.m_ptTemp; }
  98. set { this.m_ptTemp = value; }
  99. }
  100. public string RemoteELYPath ;
  101. public string RemoteMLFPath;
  102. //拉直操作需要的放大位数
  103. private float straighten_Magnification;
  104. public float Straighten_Magnification
  105. {
  106. get { return this.straighten_Magnification; }
  107. set { this.straighten_Magnification = value; }
  108. }
  109. public bool StraightenToRun;
  110. public bool StraightenAutoBC;
  111. public float StraightenManualBrightness;
  112. public float StraightenManualContrast;
  113. //定位切割位置的放大倍数
  114. private float location_Magnification;
  115. public float Location_Magnification
  116. {
  117. get { return this.location_Magnification; }
  118. set { this.location_Magnification = value; }
  119. }
  120. //定位切割位置的工作电压
  121. private float mVoltage;
  122. public float Voltage
  123. {
  124. get { return this.mVoltage; }
  125. set { this.mVoltage = value; }
  126. }
  127. public float Iprobe;
  128. //拍照的放大倍数
  129. private float photograph_Magnification;
  130. public float Photograph_Magnification
  131. {
  132. get { return this.photograph_Magnification; }
  133. set { this.photograph_Magnification = value; }
  134. }
  135. public bool ShotSectionAutoBC;
  136. public float ShotSectionManualBrightness;
  137. public float ShotSectionManualConstrast;
  138. //拍照的工作电压
  139. private float photograph_Voltage;
  140. public float Photograph_Voltage
  141. {
  142. get { return this.photograph_Voltage; }
  143. set { this.photograph_Voltage = value; }
  144. }
  145. //FIB拍照时的放大倍数
  146. private float fib_Magnification;
  147. public float FIB_Magnification
  148. {
  149. get { return this.fib_Magnification; }
  150. set { this.fib_Magnification = value; }
  151. }
  152. //校正角度选择
  153. private float correction_Angle_Inside;
  154. public float Correction_Angle_Inside
  155. {
  156. get { return this.correction_Angle_Inside; }
  157. set { this.correction_Angle_Inside = value; }
  158. }
  159. private float correction_Angle_OutSide;
  160. public float Correction_Angle_OutSide
  161. {
  162. get { return this.correction_Angle_OutSide; }
  163. set { this.correction_Angle_OutSide = value; }
  164. }
  165. //厂商
  166. private String firm;
  167. public String Firm
  168. {
  169. get { return this.firm; }
  170. set { this.firm = value; }
  171. }
  172. //EDS参数
  173. private EDSParam EdsParam;
  174. public EDSParam EDSParam
  175. {
  176. get { return this.EdsParam; }
  177. set { this.EdsParam = value; }
  178. }
  179. //ScanRotation修正角度
  180. private float scanRotCor;
  181. public float ScanRotCor
  182. {
  183. get { return this.scanRotCor; }
  184. set { this.scanRotCor = value; }
  185. }
  186. //ScanRotation修正角度
  187. private float pixelSizeCor;
  188. public float PixelSizeCor
  189. {
  190. get { return this.pixelSizeCor; }
  191. set { this.pixelSizeCor = value; }
  192. }
  193. //能谱参数
  194. //add by sun 2020-12-17 增加调试时是否切割开关
  195. private bool m_IsCutingForDebug;
  196. public bool IsCutingForDebug
  197. {
  198. get { return this.m_IsCutingForDebug; }
  199. set { this.m_IsCutingForDebug = value; }
  200. }
  201. //add by sun 2020-12-17 增加调试时是否切割开关 end
  202. //add by zjx 2020-12-18 为了测试只做能谱部分
  203. private bool m_IsonlyEDSForDebug;
  204. public bool IsonlyEDSForDebug
  205. {
  206. get { return this.m_IsonlyEDSForDebug; }
  207. set { this.m_IsonlyEDSForDebug = value; }
  208. }
  209. //add by zjx 2020-12-18 为了测试只做能谱部分 end
  210. #endregion
  211. public float FindCrossMagnification;
  212. //构造函数
  213. public MeasureParam()
  214. {
  215. Init();
  216. }
  217. public bool GetMeasureParamFromConfigration()
  218. {
  219. MeasureParam cfm = this;
  220. //设置配置文件默认值
  221. bool bResult = false;
  222. bool.TryParse(ConfigurationManager.AppSettings["Is_Photograph"].ToString(), out bResult);
  223. cfm.Is_Photograph = bResult;
  224. bool.TryParse(ConfigurationManager.AppSettings["PT_Depostion"].ToString(), out bResult);
  225. cfm.PT = bResult;
  226. cfm.PTTemp = ConfigurationManager.AppSettings["PT_ELYFile"].ToString();
  227. cfm.FIBTemp = ConfigurationManager.AppSettings["FIB_ELYFile"].ToString();
  228. cfm.SampleType = ConfigurationManager.AppSettings["LastSampleType"].ToString();
  229. cfm.Firm = ConfigurationManager.AppSettings["LastSelectFirm"].ToString();
  230. bool.TryParse(ConfigurationManager.AppSettings["Is_Title"].ToString(), out bResult);
  231. cfm.Tilt = bResult;
  232. bool.TryParse(ConfigurationManager.AppSettings["Is_EDS"].ToString(), out bResult);
  233. cfm.EDS = bResult;
  234. cfm.ScanRotCor = Convert.ToSingle(ConfigurationManager.AppSettings["ScanRotCur"].ToString());
  235. cfm.PixelSizeCor = Convert.ToSingle(ConfigurationManager.AppSettings["PixelSize_Y_Cur"].ToString());
  236. cfm.EDS = Convert.ToBoolean(ConfigurationManager.AppSettings["Is_EDS"].ToString());
  237. cfm.EDSZ = Convert.ToSingle(ConfigurationManager.AppSettings["EDS_Z"].ToString()) / 1000;
  238. cfm.EDSV = Convert.ToSingle(ConfigurationManager.AppSettings["EDS_V"].ToString());
  239. cfm.EDSA = Convert.ToSingle(ConfigurationManager.AppSettings["EDS_A"].ToString()) / 1000000000;
  240. cfm.EDSParam.XrayCollectMode = Convert.ToInt16(ConfigurationManager.AppSettings["EDS_XrayMode"].ToString());
  241. cfm.IsCutingForDebug = Convert.ToBoolean(ConfigurationManager.AppSettings["IsCutingForDebug"]);
  242. //add by sun 2020-12-17 增加调试时是否切割开关 end
  243. // add by zjx 2020-12-18 为了测试只做能谱部分
  244. cfm.IsonlyEDSForDebug = Convert.ToBoolean(ConfigurationManager.AppSettings["IsonlyEDSForDebug"]);
  245. // add by zjx 2020-12-18 为了测试只做能谱部分 end
  246. cfm.RemoteELYPath = ConfigurationManager.AppSettings["RemoteELYPath"];
  247. cfm.RemoteMLFPath = ConfigurationManager.AppSettings["RemoteMLFPath"];
  248. return true;
  249. }
  250. public bool loadParamFromSampleTypeTemplate(string filename)
  251. {
  252. DirectoryInfo TheFolder = new DirectoryInfo(System.Environment.CurrentDirectory + "\\SampleTemplate");
  253. XmlDocument doc = new XmlDocument();
  254. doc.Load(TheFolder+"\\"+filename);//载入xml文件
  255. XmlNode root = doc.SelectSingleNode("XMLData");
  256. xString firm = new xString();
  257. Slo sFile = new Slo();
  258. sFile.Register("DefaultFirmName", firm);
  259. Slo locateP = new Slo();
  260. xInt locMag = new xInt();
  261. locateP.Register("Magnification", locMag);
  262. sFile.Register("Locate", locateP);
  263. Slo votandI = new Slo();
  264. xInt vot = new xInt();
  265. xDouble iprobe = new xDouble();
  266. votandI.Register("Votage", vot);
  267. votandI.Register("Iprobe", iprobe);
  268. sFile.Register("VotageAndIprobe", votandI);
  269. Slo tCorrect = new Slo();
  270. xInt Outside = new xInt();
  271. xInt inside = new xInt();
  272. tCorrect.Register("Outside", Outside);
  273. tCorrect.Register("Inside", inside);
  274. sFile.Register("TiltCorrect", tCorrect);
  275. Slo straighten = new Slo();
  276. xInt Straightenmag = new xInt();
  277. xBool torun = new xBool();
  278. xInt b1 = new xInt();
  279. xInt c1 = new xInt();
  280. xBool auto1 = new xBool();
  281. straighten.Register("Magnification", Straightenmag);
  282. straighten.Register("ToRun", torun);
  283. straighten.Register("Hand_Bright", b1);
  284. straighten.Register("Hand_Contrast", c1);
  285. straighten.Register("AutoGet", auto1);
  286. sFile.Register("Straighten", straighten);
  287. Slo findcross = new Slo();
  288. xInt crossmag = new xInt();
  289. findcross.Register("Magnification", crossmag);
  290. sFile.Register("FindCross", findcross);
  291. Slo shotsection = new Slo();
  292. xInt shotmag = new xInt();
  293. xBool auto2 = new xBool();
  294. xInt b2 = new xInt();
  295. xInt c2 = new xInt();
  296. shotsection.Register("Magnification", shotmag);
  297. shotsection.Register("Hand_Bright", b2);
  298. shotsection.Register("Hand_Contrast", c2);
  299. shotsection.Register("AutoGet", auto2);
  300. sFile.Register("ShotSection", shotsection);
  301. sFile.Serialize(false, doc, root);
  302. this.Location_Magnification = locMag.value();
  303. this.mVoltage = vot.value();
  304. this.Iprobe = (float)iprobe.value();
  305. this.correction_Angle_Inside = inside.value();
  306. this.correction_Angle_OutSide = Outside.value();
  307. this.StraightenToRun = torun.value();
  308. this.straighten_Magnification = Straightenmag.value();
  309. this.StraightenAutoBC = auto1.value();
  310. this.StraightenManualBrightness = b1.value();
  311. this.StraightenManualContrast = c1.value();
  312. this.FindCrossMagnification = crossmag.value();
  313. this.photograph_Magnification = shotmag.value();
  314. this.ShotSectionAutoBC = auto2.value();
  315. this.ShotSectionManualBrightness = b2.value();
  316. this.ShotSectionManualConstrast = c2.value();
  317. return true;
  318. }
  319. public void Init()
  320. {
  321. this.SampleType = @"";
  322. this.PT = false;
  323. this.FIBTemp = @"";
  324. this.PTTemp = @"";
  325. this.Tilt = false;
  326. this.EDS = false;
  327. this.EDSZ = 0.005f;
  328. this.EDSV = 10000;
  329. this.EDSA = 0.0000000005f;
  330. this.EDSParam = new EDSParam();
  331. this.ScanRotCor = 1;
  332. this.PixelSizeCor = 1;
  333. }
  334. //XML文件保存测量参数
  335. public override void Serialize(bool isStoring, XmlDocument xml, XmlNode rootNode)
  336. {
  337. Slo sFile = new Slo();
  338. //是否拍照和PT
  339. xBool isPhotograph = new xBool();
  340. xBool ptDepostion = new xBool();
  341. xBool isTilt = new xBool();
  342. xBool isEDS = new xBool();
  343. isTilt.AssignValue(this.Tilt);
  344. isEDS.AssignValue(this.EDS);
  345. isPhotograph.AssignValue(this.is_Photograph);
  346. ptDepostion.AssignValue(this.m_pt);
  347. sFile.Register("Is_Title", isTilt);
  348. sFile.Register("Is_Photograph", isPhotograph);
  349. sFile.Register("PT_Depostion", ptDepostion);
  350. sFile.Register("Is_EDS", isEDS);
  351. //ELY文件
  352. xString ptELYFile = new xString();
  353. xString fibELYFile = new xString();
  354. ptELYFile.AssignValue(this.m_ptTemp);
  355. fibELYFile.AssignValue(this.m_fibTemp);
  356. sFile.Register("PT_ELYFile", ptELYFile);
  357. sFile.Register("FIB_ELYFile", fibELYFile);
  358. //对焦方式
  359. xInt focusmode = new xInt();
  360. sFile.Register("FocusMode", focusmode);
  361. //放大倍数和电压参数
  362. xDouble stretchMagnification = new xDouble();
  363. xDouble locationMagnification = new xDouble();
  364. xDouble locationVoltage = new xDouble();
  365. xDouble photographMagnification = new xDouble();
  366. xDouble photographVoltage = new xDouble();
  367. xDouble fibMagnification = new xDouble();
  368. xDouble ZDistance = new xDouble();
  369. xDouble xEDSZ = new xDouble();
  370. xDouble xEDSV = new xDouble();
  371. xDouble xEDSA = new xDouble();
  372. xEDSZ.AssignValue(this.edsZ);
  373. xEDSV.AssignValue(this.edsV);
  374. xEDSA.AssignValue(this.edsA);
  375. //ZDistance.AssignValue(this.ZDistance);
  376. stretchMagnification.AssignValue(this.straighten_Magnification);
  377. locationMagnification.AssignValue(this.location_Magnification);
  378. locationVoltage.AssignValue(this.mVoltage);
  379. photographMagnification.AssignValue(this.photograph_Magnification);
  380. photographVoltage.AssignValue(this.photograph_Voltage);
  381. fibMagnification.AssignValue(this.fib_Magnification);
  382. sFile.Register("Strectch_Magnification", stretchMagnification);
  383. sFile.Register("Locatio_Magnification", locationMagnification);
  384. sFile.Register("Location_Voltage", locationVoltage);
  385. sFile.Register("Photograph_Magnification", photographMagnification);
  386. sFile.Register("Photograph_Voltage", photographVoltage);
  387. sFile.Register("FIB_Magnification", fibMagnification);
  388. //sFile.Register("ZDistance", ZDistance);
  389. sFile.Register("EDSZ", xEDSZ);
  390. sFile.Register("EDSV", xEDSV);
  391. sFile.Register("EDSA", xEDSA);
  392. //校正角度
  393. xDouble correctionAngle = new xDouble();
  394. correctionAngle.AssignValue(this.correction_Angle_Inside);
  395. sFile.Register("Correction_Angle", correctionAngle);
  396. //样品名称和厂商
  397. xString sampleType = new xString();
  398. xString _firm = new xString();
  399. sampleType.AssignValue(this.m_SampleName);
  400. _firm.AssignValue(this.firm);
  401. sFile.Register("Sample_Type", sampleType);
  402. sFile.Register("Firm", _firm);
  403. sFile.Register("EDS_Param", this.EDSParam);
  404. //ScanRotate修正
  405. xDouble scanRotate = new xDouble();
  406. scanRotate.AssignValue(this.scanRotCor);
  407. sFile.Register("ScanRotateCorrect", scanRotate);
  408. //PixelSize_Y轴补偿
  409. xDouble pscor = new xDouble();
  410. pscor.AssignValue(this.pixelSizeCor);
  411. sFile.Register("PixelSizeYCorrect", pscor);
  412. if (isStoring)
  413. {
  414. sFile.Serialize(true, xml, rootNode);
  415. }
  416. else
  417. {
  418. sFile.Serialize(false, xml, rootNode);
  419. this.is_Photograph = isPhotograph.value();
  420. this.m_pt = ptDepostion.value();
  421. this.Tilt = isTilt.value();
  422. this.EDS = isEDS.value();
  423. this.m_ptTemp = ptELYFile.value();
  424. this.m_fibTemp = fibELYFile.value();
  425. this.straighten_Magnification = Convert.ToSingle(stretchMagnification.value());
  426. this.location_Magnification = Convert.ToSingle(locationMagnification.value());
  427. this.mVoltage = Convert.ToSingle(locationVoltage.value());
  428. this.photograph_Magnification = Convert.ToSingle(photographMagnification.value());
  429. this.photograph_Voltage = Convert.ToSingle(photographVoltage.value());
  430. this.correction_Angle_Inside = Convert.ToSingle(correctionAngle.value());
  431. this.m_SampleName = sampleType.value();
  432. this.firm = _firm.value();
  433. //this.ZDistance = Convert.ToSingle(ZDistance.value());
  434. this.EDSZ = Convert.ToSingle(xEDSZ.value());
  435. this.EDSV = Convert.ToSingle(xEDSV.value());
  436. this.EDSA = Convert.ToSingle(xEDSA.value());
  437. this.ScanRotCor = Convert.ToSingle(scanRotate.value());
  438. this.PixelSizeCor = Convert.ToSingle(pscor.value());
  439. }
  440. }
  441. }
  442. }