Measure.cs 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591
  1. //时间:20200610
  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 System.Windows.Forms;
  10. using System.Threading;
  11. using System.IO;
  12. using SmartSEMControl;
  13. using MeasureData;
  14. using FileManager;
  15. namespace MeasureThread
  16. {
  17. //图片模式
  18. public enum ImageMode
  19. {
  20. FIB,
  21. SEM
  22. }
  23. public delegate void ThreadStatusHandler(object sender, ThreadStatusEventArgs e); //声明委托
  24. public delegate void CutHolesStatusHandler(object sender, CutHolesStatusEventArgs e);
  25. //线程与界面通信协议
  26. public class ThreadStatusEventArgs
  27. {
  28. //状态,
  29. public string State
  30. {
  31. get { return m_state; }
  32. set { m_state = value; }
  33. }
  34. private string m_state;
  35. //时间
  36. public DateTime Time
  37. {
  38. get { return m_time; }
  39. set { m_time = value; }
  40. }
  41. private DateTime m_time;
  42. //步骤编码
  43. public int Step_Code
  44. {
  45. get { return step_Code; }
  46. set { step_Code = value; }
  47. }
  48. private int step_Code;
  49. //图片信息
  50. public class PictureInformation
  51. {
  52. public Boolean Is_Picture
  53. {
  54. get { return is_Picture; }
  55. set { is_Picture = value; }
  56. }
  57. private Boolean is_Picture;
  58. public String Picture_FullPath
  59. {
  60. get { return picture_FullPath; }
  61. set { picture_FullPath = value; }
  62. }
  63. private String picture_FullPath;
  64. public double Work_Voltage
  65. {
  66. get { return work_Voltage; }
  67. set { work_Voltage = value; }
  68. }
  69. private double work_Voltage;
  70. public double Magnification
  71. {
  72. get { return magnification; }
  73. set { magnification = value; }
  74. }
  75. private double magnification;
  76. public double Work_Distance
  77. {
  78. get { return work_Distance; }
  79. set { work_Distance = value; }
  80. }
  81. private double work_Distance;
  82. public String Work_Status
  83. {
  84. get { return work_Status; }
  85. set { work_Status = value; }
  86. }
  87. private String work_Status;
  88. }
  89. //图片信息实例类
  90. public PictureInformation Picture_Information
  91. {
  92. get { return picture_Information; }
  93. set { picture_Information = value; }
  94. }
  95. private PictureInformation picture_Information;
  96. //图像信息
  97. public class ImageInformation
  98. {
  99. public int Method_Name
  100. {
  101. get { return method_Name; }
  102. set { method_Name = value; }
  103. }
  104. private int method_Name;
  105. public Source_Img_Degree_Direction SIDD;
  106. public Cut_Position CP;
  107. public Cut_Success CS;
  108. public Trapezoid_Top_Center_Position TTCP;
  109. public Auto_Foucs AF;
  110. public Auto_Stigmatic AS;
  111. public Center_Position_OffsetAngle_Direction CPOD;
  112. public Measure_Size MS;
  113. public ImageInformation()
  114. {
  115. SIDD = new Source_Img_Degree_Direction();
  116. CP = new Cut_Position();
  117. CS = new Cut_Success();
  118. TTCP = new Trapezoid_Top_Center_Position();
  119. AF = new Auto_Foucs();
  120. AS = new Auto_Stigmatic();
  121. CPOD = new Center_Position_OffsetAngle_Direction();
  122. MS = new Measure_Size();
  123. }
  124. //1-计算原始图像偏移角度及方向
  125. public class Source_Img_Degree_Direction
  126. {
  127. public Boolean Is_Image = false;
  128. public double Degree
  129. {
  130. get { return degree; }
  131. set { degree = value; }
  132. }
  133. private double degree;
  134. public int Direction
  135. {
  136. get { return direction; }
  137. set { direction = value; }
  138. }
  139. private int direction;
  140. public int State
  141. {
  142. get { return state; }
  143. set { state = value; }
  144. }
  145. private int state;
  146. }
  147. //2-计算切割点位置
  148. public class Cut_Position
  149. {
  150. public Boolean Is_Image = false;
  151. public double Offsetx
  152. {
  153. get { return offsetx; }
  154. set { offsetx = value; }
  155. }
  156. private double offsetx;
  157. public double Offsety
  158. {
  159. get { return offsety; }
  160. set { offsety = value; }
  161. }
  162. private double offsety;
  163. public int State
  164. {
  165. get { return state; }
  166. set { state = value; }
  167. }
  168. private int state;
  169. }
  170. //3-是否切割成功
  171. public class Cut_Success
  172. {
  173. public Boolean Is_Image = false;
  174. public int State
  175. {
  176. get { return state; }
  177. set { state = value; }
  178. }
  179. private int state;
  180. }
  181. //4-计算切割后图像梯形区域上边中心点坐标
  182. public class Trapezoid_Top_Center_Position
  183. {
  184. public Boolean Is_Image = false;
  185. public double TopCenterX
  186. {
  187. get { return topCenterX; }
  188. set { topCenterX = value; }
  189. }
  190. private double topCenterX;
  191. public double TopCenterY
  192. {
  193. get { return topCenterY; }
  194. set { topCenterY = value; }
  195. }
  196. private double topCenterY;
  197. public int State
  198. {
  199. get { return state; }
  200. set { state = value; }
  201. }
  202. private int state;
  203. }
  204. //5-自动对焦
  205. public class Auto_Foucs
  206. {
  207. public Boolean Is_Image = true;
  208. public String Img_Path
  209. {
  210. get { return img_Path; }
  211. set { img_Path = value; }
  212. }
  213. private String img_Path;
  214. }
  215. //6-自动像闪
  216. public class Auto_Stigmatic
  217. {
  218. public Boolean Is_Image = true;
  219. public String Img_Path
  220. {
  221. get { return img_Path; }
  222. set { img_Path = value; }
  223. }
  224. private String img_Path;
  225. }
  226. //7-计算切割面区域中心坐标,以及偏移角度及方向
  227. public class Center_Position_OffsetAngle_Direction
  228. {
  229. public Boolean Is_Image = false;
  230. public double CenterX
  231. {
  232. get { return centerX; }
  233. set { centerX = value; }
  234. }
  235. private double centerX;
  236. public double CenterY
  237. {
  238. get { return centerY; }
  239. set { centerY = value; }
  240. }
  241. private double centerY;
  242. public double Degree
  243. {
  244. get { return degree; }
  245. set { degree = value; }
  246. }
  247. private double degree;
  248. public int Direction
  249. {
  250. get { return direction; }
  251. set { direction = value; }
  252. }
  253. private int direction;
  254. public int State
  255. {
  256. get { return state; }
  257. set { state = value; }
  258. }
  259. private int state;
  260. }
  261. //8-测量尺寸
  262. public class Measure_Size
  263. {
  264. public Boolean Is_Image = false;
  265. public int State
  266. {
  267. get { return state; }
  268. set { state = value; }
  269. }
  270. private int state;
  271. }
  272. }
  273. public ThreadStatusEventArgs(string a_State)
  274. {
  275. this.m_state = a_State;
  276. picture_Information = new PictureInformation();
  277. }
  278. }
  279. public class CutHolesStatusEventArgs
  280. {
  281. public string State
  282. {
  283. get { return m_state; }
  284. set { m_state = value; }
  285. }
  286. private string m_state;
  287. public string HoleName
  288. {
  289. get { return m_holeName; }
  290. set { m_holeName = value; }
  291. }
  292. private string m_holeName;
  293. public CutHolesStatusEventArgs(string a_state, string a_holeName)
  294. {
  295. this.m_state = a_state;
  296. this.m_holeName = a_holeName;
  297. }
  298. }
  299. public class Measure
  300. {
  301. public event ThreadStatusHandler SendThreadStatus; // 声明事件
  302. public event CutHolesStatusHandler SendCutHolesStatus; // 声明事件
  303. //全局只有一个fatorySEM
  304. static FactoryHardware factorySEM = FactoryHardware.Instance;
  305. ISEMControl iSEM = factorySEM.ISEM;
  306. //@的作用是不用转义字符\\只打一个就行
  307. const String ImageName1 = @"ImageSEM600X.tif"; //传给客户,作水平校正
  308. const String ImageName2 = @"ImageFIB600X1.tif";//传给客户,找到切割点
  309. const String ImageName3 = @"ImageFIB600X2.tif";
  310. const String ImageName4 = @"ImageSEM300X.tif";//传给客户,找到已经切割点
  311. const String ImageName5 = @"ImageSEM6000X.tif";//传给客户,水平校正
  312. const String ImageName6 = @"ImageSEMMag.tif";//传给客户,测量层高
  313. const String MacoInsertPt = "GIS Insert.MLF"; //传入PT针
  314. const String MacoRetractPt = "GIS Retract.MLF"; //退出PT针
  315. const String MacoScanPic = "Scan picture.MLF";//一般质量抓图的宏
  316. const String MacoGoodPic = "Good picture.MLF";//高质量抓图的宏
  317. const String MacoExportTif = "Export TIFF.MLF";// 导出有标尺的图像,这个图像为使用工具SmartSEM工具的图像
  318. const String ElyDeposition = @"Deposition.ely"; //沉积
  319. const String ElyCrossSection = @"CrossSection.ely"; //切割
  320. const float fMin = (float)0.0000002; //单位是米
  321. int m_nWorkHoleNo = -1;
  322. //测量文件
  323. private MeasureFile m_measureFile;
  324. public MeasureFile MeasureFile
  325. {
  326. get { return this.m_measureFile; }
  327. set { this.m_measureFile = value; }
  328. }
  329. //测量的切割孔
  330. private List<MeasureData.CutHole> m_cutHoles;
  331. public List<MeasureData.CutHole> cutHoles
  332. {
  333. get { return this.m_cutHoles; }
  334. set { this.m_cutHoles = value; }
  335. }
  336. //工作文件夹
  337. private string m_WorkingFolder;
  338. public string WorkingFolder
  339. {
  340. get { return this.m_WorkingFolder; }
  341. set { this.m_WorkingFolder = value; }
  342. }
  343. //程序当前路径
  344. private string m_ProgramFolder = Directory.GetCurrentDirectory();
  345. //线程状态
  346. private ThreadStatus m_ThreadStatus;
  347. public ThreadStatus TStatus
  348. {
  349. get { return this.m_ThreadStatus; }
  350. set { this.m_ThreadStatus = value; }
  351. }
  352. //测量参数
  353. private MeasureParam m_MsParam;
  354. public MeasureParam MeasParam
  355. {
  356. get { return this.m_MsParam; }
  357. set { this.m_MsParam = value; }
  358. }
  359. //构造函数
  360. public Measure()
  361. {
  362. Init();
  363. }
  364. private void Init()
  365. {
  366. MeasParam = new MeasureParam();
  367. TStatus = new ThreadStatus();
  368. cutHoles = new List<MeasureData.CutHole>();
  369. }
  370. //初始化测量业务, 读测量文件,判断是否有可测试的切孔
  371. public bool InitMeas(MeasureFile a_measureFile)
  372. {
  373. m_measureFile = a_measureFile;
  374. List<CutHole> listHoles = m_measureFile.ListCutHole;
  375. foreach (CutHole h in listHoles)
  376. {
  377. if (h.SWITCH == true)
  378. {
  379. m_cutHoles.Add(h);
  380. }
  381. }
  382. if (m_cutHoles.Count == 0)
  383. return false;
  384. this.m_MsParam = m_measureFile.MParam;
  385. return true;
  386. }
  387. public void SendMsg(string a_StrMsg)
  388. {
  389. ThreadStatusEventArgs arg = new ThreadStatusEventArgs(a_StrMsg);
  390. arg.Time = DateTime.Now;
  391. SendThreadStatus(this, arg);
  392. }
  393. public void SendCutHoleMsg(string a_state, string a_holeName)
  394. {
  395. CutHolesStatusEventArgs arg = new CutHolesStatusEventArgs(a_state, a_holeName);
  396. arg.HoleName = a_holeName;
  397. arg.State = a_state;
  398. SendCutHolesStatus(this, arg);
  399. }
  400. //测量流程
  401. public void DoMeasure()
  402. {
  403. //创建线程的测量状态的更新
  404. this.TStatus.ComputeTime(THREAD_TIME_TYPE.START);
  405. if (SendThreadStatus != null)
  406. {
  407. SendMsg("开始测量。");
  408. }
  409. //检查硬件连接是否正常
  410. if (!ConnectHardware())
  411. {
  412. SendMsg("连接硬件失败。");
  413. this.TStatus.ComputeTime(THREAD_TIME_TYPE.STOPPED);
  414. return;
  415. }
  416. SendMsg("硬件连接成功。");
  417. //设置工作文件夹
  418. if (!SetWorkingFolderStr())
  419. {
  420. SendMsg("设置工作文件夹失败");
  421. this.TStatus.ComputeTime(THREAD_TIME_TYPE.STOPPED);
  422. return;
  423. }
  424. SendMsg("创建工作文件路径为" + WorkingFolder);
  425. float[] firstPosition;
  426. for (int i = 0; i < m_cutHoles.Count; i++)
  427. {
  428. m_nWorkHoleNo = i;
  429. if (i == 0)
  430. {
  431. SendMsg("第一个切孔开始测量");
  432. //切孔操作-开始
  433. SendCutHoleMsg(((int)ThreadState.InProcess).ToString(), m_cutHoles[i].HoleName);
  434. firstPosition = iSEM.GetStagePosition();
  435. //第一个孔的测试
  436. FirstHole();
  437. //切孔操作-完成
  438. SendCutHoleMsg(((int)ThreadState.Success).ToString(), m_cutHoles[i].HoleName);
  439. }
  440. else
  441. {
  442. //非第一个孔的测试
  443. SendMsg("第" + i.ToString() + "个切孔开始测量");
  444. //切孔操作-开始
  445. SendCutHoleMsg(((int)ThreadState.InProcess).ToString(), m_cutHoles[i].HoleName);
  446. OtherHole();
  447. //切孔操作-完成
  448. SendCutHoleMsg(((int)ThreadState.Success).ToString(), m_cutHoles[i].HoleName);
  449. }
  450. }
  451. }
  452. //检查硬件连接是否正常
  453. public bool ConnectHardware()
  454. {
  455. //返回硬件的连接状态
  456. return iSEM.ConnectStatus();
  457. }
  458. //设置工作文件夹
  459. public bool SetWorkingFolderStr()
  460. {
  461. WorkingFolder = m_measureFile.FilePath;
  462. return true;
  463. ////获取工作文件路径
  464. //string pathName = m_measureFile.FilePath;
  465. ////判断工作文件路径是否为空或无效
  466. //if (string.IsNullOrEmpty(pathName))
  467. //{
  468. // SendMsg("路径无效");
  469. // return false;
  470. //}
  471. ////文件未保存
  472. //else if (pathName.CompareTo(MeasureFile.UNTITLED_FILE_NAME) == 0)
  473. //{
  474. // SendMsg("工程文件未保存");
  475. // return false;
  476. //}
  477. ////获取工作文件所在文件夹
  478. //string folder = System.IO.Path.GetDirectoryName(pathName);
  479. //if (string.IsNullOrEmpty(folder))
  480. //{
  481. // SendMsg("工程文件无效");
  482. // return false;
  483. //}
  484. //WorkingFolder += @"\\";
  485. //LogManager.Init(WorkingFolder);
  486. //return false;
  487. }
  488. //插入PT针
  489. public bool InsertPT()
  490. {
  491. string fn = m_ProgramFolder + "\\Macro\\" + MacoInsertPt;
  492. SendMsg("调用宏插入PT针宏文件" + fn);
  493. iSEM.CMDMCFFilename(fn);
  494. //延时1s??
  495. Thread.Sleep(1000);
  496. return true;
  497. }
  498. //撤出PT针
  499. public bool RetractPT()
  500. {
  501. string fn = m_ProgramFolder + "\\Macro\\" + MacoRetractPt;
  502. SendMsg("调用宏撤出PT针宏文件" + fn);
  503. iSEM.CMDMCFFilename(fn);
  504. //延时1s??
  505. Thread.Sleep(1000);
  506. return true;
  507. }
  508. //PT沉积
  509. public bool PTWork()
  510. {
  511. //执行PT沉积的ELY文件
  512. string fn = m_ProgramFolder + "\\Macro\\" + ElyDeposition;
  513. SendMsg("执行PT沉积Ely文件:" + fn);
  514. if (!ExcuteEly(fn))
  515. {
  516. return false;
  517. }
  518. //等待沉积完成
  519. while (true)
  520. {
  521. Thread.Sleep(10000);
  522. if (iSEM.GetFIBMode() == 0)
  523. {
  524. break;
  525. }
  526. }
  527. return true;
  528. }
  529. //FIB切割
  530. public bool FIBWork()
  531. {
  532. //执行PT沉积的ELY文件
  533. string fn = m_ProgramFolder + "\\Macro\\" + ElyCrossSection;
  534. SendMsg("执行FIB切割Ely文件:" + fn);
  535. if (!ExcuteEly(fn))
  536. {
  537. return false;
  538. }
  539. //等待切割完成
  540. while (true)
  541. {
  542. Thread.Sleep(10000);
  543. if (iSEM.GetFIBMode() == 0)
  544. {
  545. break;
  546. }
  547. }
  548. return true;
  549. }
  550. public bool ExcuteEly(string a_filename)
  551. {
  552. //执行ELy文件有三个动作
  553. //1. 选择ELY文件
  554. SendMsg("选择ELY文件");
  555. if (!iSEM.CmdFIBLoadELY(a_filename))
  556. {
  557. SendMsg("选择ELY文件失败");
  558. return false;
  559. }
  560. Thread.Sleep(1000);
  561. //2. 确认ELY文件
  562. SendMsg("确认ELY文件");
  563. if (!iSEM.CmdFIBEXPOSUREELY())
  564. {
  565. SendMsg("确认ELY文件失败");
  566. return false;
  567. }
  568. Thread.Sleep(1000);
  569. //3. 执行ELY文件
  570. SendMsg("执行ELY文件");
  571. if (!iSEM.CmdFIBSTARTELY())
  572. {
  573. SendMsg("执行ELY文件失败");
  574. return false;
  575. }
  576. Thread.Sleep(1000);
  577. return true;
  578. }
  579. /// <summary>
  580. ///13. 自动 定位功能
  581. /// </summary>
  582. /// <returns></returns>
  583. public bool GetPoistion()
  584. {
  585. SendMsg("自动定位");
  586. //13.自动定位切割
  587. {
  588. SendMsg("放大600倍");
  589. //1.控制SEM放大600X
  590. if (!iSEM.SetMagnification(600))
  591. {
  592. return false;
  593. }
  594. //2.控制SEM自动对焦、亮度、对比度
  595. // if (!MeasParam.FocusMode)
  596. {
  597. if (DialogResult.Yes == MessageBox.Show("图像拍摄已完成?", "确认消息", MessageBoxButtons.YesNo))
  598. {
  599. SendMsg("拍摄照片完成");
  600. //return true;
  601. }
  602. else
  603. {
  604. SendMsg("拍摄照片失败");
  605. return false;
  606. }
  607. //弹出手动对焦的窗口
  608. }
  609. //else
  610. //{
  611. // //调用自动对焦模块
  612. //}
  613. //3.设置SEM进行角度补偿54度
  614. SendMsg("设置校正54度");
  615. if (!TiltCorrection(54))
  616. {
  617. SendMsg("设置SEM进行角度补偿54度");
  618. return false;
  619. }
  620. Thread.Sleep(5000);
  621. //4.控制SEM拍照
  622. SendMsg("SEM拍照");
  623. //5.保存照片
  624. {
  625. //1. 创建目录,已经完成
  626. //2. 设置图片名称
  627. //3. 保存图片1
  628. WorkingFolder = m_measureFile.FilePath;
  629. String fileName1 = WorkingFolder + "\\" + m_nWorkHoleNo.ToString() + "Hole" + ImageName1;
  630. SendMsg("SEM拍照存储到" + fileName1);
  631. if (!GetImage(ImageMode.SEM, fileName1))
  632. {
  633. SendMsg("SEM拍照失败");
  634. return false;
  635. }
  636. Thread.Sleep(3000);
  637. }
  638. //6.设置FIB拍照参数——扫描时间、束流等
  639. //7.控制FIB自动亮度、对比度
  640. SendMsg("切换FIB控制");
  641. if (!iSEM.CmdFIBModeFIB())
  642. {
  643. SendMsg("FIB模式切换失败");
  644. return false;
  645. }
  646. Thread.Sleep(10000);
  647. //8.控制FIB拍照
  648. //9.保存照片
  649. SendMsg("FIB拍照");
  650. {
  651. //1. 设置图片名称
  652. //2. 保存图片2
  653. String fileName2 = WorkingFolder + "\\" + m_nWorkHoleNo.ToString() + "Hole" + ImageName2;
  654. if (!GetImage(ImageMode.FIB, fileName2))
  655. {
  656. SendMsg("FIB拍照失败");
  657. return false;
  658. }
  659. Thread.Sleep(3000);
  660. }
  661. //10.将照片传给客户,返回梯形位置坐标,及样品类型参数(是否需要PT沉积,PT坐标位置,PT宽度、PT高度、梯形上、下边及深度、扫描时间、束流、样品放大倍数1、样品放大倍数2等切割参数)
  662. SendMsg("调用识别位置");
  663. if (DialogResult.Yes == MessageBox.Show("移动已完成?", "确认消息", MessageBoxButtons.YesNo))
  664. {
  665. SendMsg("移动已完成");
  666. //return true;
  667. }
  668. else
  669. {
  670. SendMsg("移动已失败");
  671. return false;
  672. }
  673. SendMsg("进行PT沉积");
  674. //11.自动工具样品类型参数确定是否需要PT沉积
  675. {
  676. //1. 根据客户PT沉积坐标控制FIB调整到中心位置
  677. //2. 验证移动准确性:获取当前FIB中心位置坐标,与客户返回坐标对比,验证是否一定正确
  678. //3. 根据坐标进行PT沉积
  679. if (!PTWork())
  680. {
  681. SendMsg("PT沉积失败");
  682. return false;
  683. }
  684. }
  685. return true;
  686. ////模拟为客户返回的坐标值
  687. //float x0 = 0, y0 = 0;
  688. //SendMsg("移动到新(" + x0.ToString() + "," + y0.ToString() + ")位置失败");
  689. ////12.根据梯形坐标控制FIB调整到中心位置
  690. //if (!iSEM.MoveStageXY(x0, y0))
  691. //{
  692. // SendMsg("移动到新(" + x0.ToString() + "," + y0.ToString() + ")位置失败");
  693. // return false;
  694. //}
  695. ////电镜移动是有一个延时的操作的?
  696. ////13.验证移动准确性:获取当前FIB中心位置坐标,与客户返回坐标对比,验证是否移动正确
  697. //float x1 = iSEM.GetStageAtX();
  698. //float y1 = iSEM.GetStageAtY();
  699. //if (Math.Abs(x0 - x1) > fMin && Math.Abs(y0 - y1) > fMin)
  700. //{
  701. // SendMsg("目标位置(" + x0.ToString() + "," + y0.ToString() + ")移动失败");
  702. // return false;
  703. //}
  704. ////14.保存样品1第1号孔中心位置6轴坐标1 XYZMRT到数据库,保存客户返回值信息到数据库
  705. //float[] firstPosition = iSEM.GetStagePosition();
  706. ////这里要调用文件保存功能
  707. //SendMsg("坐标1(" + firstPosition[0].ToString() + ","
  708. // + firstPosition[1].ToString() + ","
  709. // + firstPosition[2].ToString() + ","
  710. // + firstPosition[3].ToString() + ","
  711. // + firstPosition[4].ToString() + ","
  712. // + firstPosition[5].ToString() + ")");
  713. }
  714. //return false;
  715. }
  716. /// <summary>
  717. /// 14. FIB切割
  718. /// </summary>
  719. /// <returns></returns>
  720. public bool FIBCross()
  721. {
  722. //14.自动控制FIB切割
  723. {
  724. //1.根据参数设置FIB草率时间(使图清晰),设置梯形上下边及深度、设置束流
  725. //2.控制FIB进行切割
  726. SendMsg("FIB切割");
  727. if (!FIBWork())
  728. {
  729. SendMsg("FIB切割失败");
  730. return false;
  731. }
  732. Thread.Sleep(5000);
  733. //3.控制FIB拍照600X
  734. //4.保存图片
  735. {
  736. //1.设置图片名称
  737. //2.保存图片3
  738. WorkingFolder = m_measureFile.FilePath;
  739. String fileName3 = WorkingFolder + "\\" + m_nWorkHoleNo.ToString() + "Hole" + ImageName3;
  740. SendMsg("SEM拍照存储到" + fileName3);
  741. if (!GetImage(ImageMode.FIB, fileName3))
  742. {
  743. SendMsg("FIB拍照失败");
  744. return false;
  745. }
  746. Thread.Sleep(3000);
  747. }
  748. //5.验证切割准确性:与切割前对比,如果对比误差大,则停止自动执行,进行报警
  749. //6.设置FIB解冻:先读取状态,如果冻结状态则进行解冻
  750. }
  751. return true;
  752. }
  753. /// <summary>
  754. /// 16.自动调整SEM找到切割位置,这里不是简单的拉直旋转
  755. /// </summary>
  756. /// <returns></returns>
  757. public bool FindCross()
  758. {
  759. //16.自动调整SEM找到切割位置
  760. {
  761. //1.控制SEM放大到300倍
  762. if (!iSEM.SetMagnification(300))
  763. {
  764. return false;
  765. }
  766. //2.控制SEM自动对焦、亮度、对比度-接口
  767. if (!MeasParam.FocusMode)
  768. {
  769. //弹出手动对焦的窗口
  770. }
  771. else
  772. {
  773. //调用自动对焦模块
  774. }
  775. Thread.Sleep(5000);
  776. //3.控制SEM拍照
  777. String fileName4 = WorkingFolder + ImageName4;
  778. if (!GetImage(ImageMode.SEM, fileName4))
  779. {
  780. return false;
  781. }
  782. Thread.Sleep(3000);
  783. //4.将照片传给客户,获取偏移坐标,以及偏移角度
  784. float x4 = 0, y4 = 0;
  785. float angle = 0;
  786. //5.根据坐标控制SEM移动到切孔位置,居中
  787. if (!iSEM.MoveStageXY(x4, y4))
  788. {
  789. return false;
  790. }
  791. if (!iSEM.SetScanRotation(angle))
  792. {
  793. return false;
  794. }
  795. ////6.验证移动准确性:获取当前SEM中心位置坐标,与客户返回坐标对比,验证是否移动正确
  796. //float x5 = iSEM.GetStageAtX();
  797. //float y5 = iSEM.GetStageAtY();
  798. //if (Math.Abs(x5 - x4) > fMin && Math.Abs(y5 - y4) > fMin)
  799. //{
  800. // return false;
  801. //}
  802. }
  803. return true;
  804. }
  805. public bool CommonWork()
  806. {
  807. SendMsg("插入PT针");
  808. //12.根据样品类型参数确定是否需要PT沉积,控制PT针插入
  809. //if (firstHole.PT == true)
  810. {
  811. if (!InsertPT())
  812. {
  813. SendMsg("插入PT针失败");
  814. return false;
  815. }
  816. }
  817. //13. 自动 定位功能
  818. SendMsg("自动定位切割位置");
  819. if (!GetPoistion())
  820. {
  821. SendMsg("自动定位切割位置失败");
  822. return false;
  823. }
  824. //14.自动控制FIB切割
  825. SendMsg("FIB切割");
  826. if (!FIBCross())
  827. {
  828. SendMsg("FIB切割失败");
  829. return false;
  830. }
  831. //{
  832. // //1.根据参数设置FIB草率时间(使图清晰),设置梯形上下边及深度、设置束流
  833. // //2.控制FIB进行切割
  834. // //3.控制FIB拍照600X
  835. // //4.保存图片
  836. // {
  837. // //1.设置图片名称
  838. // //2.保存图片3
  839. // String fileName3 = WorkingFolder + ImageName3;
  840. // if (!GetImage(ImageMode.FIB, fileName3))
  841. // {
  842. // return false;
  843. // }
  844. // }
  845. // //5.验证切割准确性:与切割前对比,如果对比误差大,则停止自动执行,进行报警
  846. // //6.设置FIB解冻:先读取状态,如果冻结状态则进行解冻
  847. //}
  848. //15.根据样品类型决定是否撤出PT针
  849. SendMsg("撤出PT针");
  850. //if (firstHole.PT == false)
  851. //{
  852. if (!RetractPT())
  853. {
  854. SendMsg("撤出PT针失败");
  855. return false;
  856. }
  857. //}
  858. // 16.找到切割位置
  859. SendMsg("找到切割位置");
  860. //17.自动控制SEM拍截面照
  861. SendMsg("观测层高");
  862. SendMsg("切换SEM控制");
  863. if (!iSEM.CmdFIBModeSEM())
  864. {
  865. SendMsg("SEM模式切换失败");
  866. return false;
  867. }
  868. Thread.Sleep(10000);
  869. SendMsg("放大6000倍");
  870. if (!iSEM.SetMagnification(6000))
  871. {
  872. SendMsg("放大倍数调整失败");
  873. return false;
  874. }
  875. if (DialogResult.Yes == MessageBox.Show("图像拍摄已完成?", "确认消息", MessageBoxButtons.YesNo))
  876. {
  877. SendMsg("拍摄照片完成");
  878. //return true;
  879. }
  880. else
  881. {
  882. SendMsg("拍摄照片失败");
  883. return false;
  884. }
  885. SendMsg("图像校正36度");
  886. //3.设置SEM角度补偿cos36度
  887. if (!TiltCorrection(36))
  888. {
  889. return false;
  890. }
  891. Thread.Sleep(3000);
  892. string fn;
  893. //用宏抓一般图
  894. Thread.Sleep(5000);
  895. fn = m_ProgramFolder + "\\Macro\\" + MacoScanPic;
  896. SendMsg("用宏抓一般图" + fn);
  897. iSEM.CMDMCFFilename(fn);
  898. //延时1s??
  899. Thread.Sleep(5000);
  900. //用宏抓好图
  901. fn = m_ProgramFolder + "\\Macro\\" + MacoGoodPic;
  902. SendMsg("用宏抓好图" + fn);
  903. iSEM.CMDMCFFilename(fn);
  904. //延时1s??
  905. Thread.Sleep(30000);
  906. Thread.Sleep(10000);
  907. WorkingFolder = m_measureFile.FilePath;
  908. String fileName6 = WorkingFolder + "\\" + m_nWorkHoleNo.ToString() + "Hole" + ImageName6;
  909. SendMsg("SEM拍照存储到" + fileName6);
  910. if (!GetImage(ImageMode.SEM, fileName6))
  911. {
  912. SendMsg("SEM拍照失败");
  913. return false;
  914. }
  915. //用宏抓标志图
  916. fn = m_ProgramFolder + "\\Macro\\" + MacoExportTif;
  917. SendMsg("用宏抓标志图" + fn);
  918. iSEM.CMDMCFFilename(fn);
  919. //延时1s??
  920. Thread.Sleep(30000);
  921. //恢复简单抓图
  922. Thread.Sleep(5000);
  923. fn = m_ProgramFolder + "\\Macro\\" + MacoScanPic;
  924. SendMsg("用宏抓一般图" + fn);
  925. iSEM.CMDMCFFilename(fn);
  926. SendMsg("所有图结束");
  927. return true;
  928. }
  929. //第一个孔的测试过程
  930. public bool FirstHole()
  931. {
  932. MeasureData.CutHole firstHole = m_cutHoles[0];
  933. SendMsg("插入PT针");
  934. //12.根据样品类型参数确定是否需要PT沉积,控制PT针插入
  935. //if (firstHole.PT == true)
  936. {
  937. if (!InsertPT())
  938. {
  939. SendMsg("插入PT针失败");
  940. return false;
  941. }
  942. }
  943. //13. 自动 定位功能
  944. SendMsg("自动定位切割位置");
  945. if (!GetPoistion())
  946. {
  947. SendMsg("自动定位切割位置失败");
  948. return false;
  949. }
  950. //14.自动控制FIB切割
  951. SendMsg("FIB切割");
  952. if (!FIBCross())
  953. {
  954. SendMsg("FIB切割失败");
  955. return false;
  956. }
  957. //{
  958. // //1.根据参数设置FIB草率时间(使图清晰),设置梯形上下边及深度、设置束流
  959. // //2.控制FIB进行切割
  960. // //3.控制FIB拍照600X
  961. // //4.保存图片
  962. // {
  963. // //1.设置图片名称
  964. // //2.保存图片3
  965. // String fileName3 = WorkingFolder + ImageName3;
  966. // if (!GetImage(ImageMode.FIB, fileName3))
  967. // {
  968. // return false;
  969. // }
  970. // }
  971. // //5.验证切割准确性:与切割前对比,如果对比误差大,则停止自动执行,进行报警
  972. // //6.设置FIB解冻:先读取状态,如果冻结状态则进行解冻
  973. //}
  974. //15.根据样品类型决定是否撤出PT针
  975. SendMsg("撤出PT针");
  976. //if (firstHole.PT == false)
  977. //{
  978. if (!RetractPT())
  979. {
  980. SendMsg("撤出PT针失败");
  981. return false;
  982. }
  983. //}
  984. // 16.找到切割位置
  985. SendMsg("找到切割位置");
  986. //17.自动控制SEM拍截面照
  987. SendMsg("观测层高");
  988. SendMsg("切换SEM控制");
  989. if (!iSEM.CmdFIBModeSEM())
  990. {
  991. SendMsg("SEM模式切换失败");
  992. return false;
  993. }
  994. Thread.Sleep(10000);
  995. SendMsg("放大6000倍");
  996. if (!iSEM.SetMagnification(6000))
  997. {
  998. SendMsg("放大倍数调整失败");
  999. return false;
  1000. }
  1001. if (DialogResult.Yes == MessageBox.Show("图像拍摄已完成?", "确认消息", MessageBoxButtons.YesNo))
  1002. {
  1003. SendMsg("拍摄照片完成");
  1004. //return true;
  1005. }
  1006. else
  1007. {
  1008. SendMsg("拍摄照片失败");
  1009. return false;
  1010. }
  1011. SendMsg("图像校正36度");
  1012. //3.设置SEM角度补偿cos36度
  1013. if (!TiltCorrection(36))
  1014. {
  1015. return false;
  1016. }
  1017. Thread.Sleep(3000);
  1018. string fn;
  1019. //用宏抓一般图
  1020. Thread.Sleep(5000);
  1021. fn = m_ProgramFolder + "\\Macro\\" + MacoScanPic;
  1022. SendMsg("用宏抓一般图" + fn);
  1023. iSEM.CMDMCFFilename(fn);
  1024. //延时1s??
  1025. Thread.Sleep(5000);
  1026. //用宏抓好图
  1027. fn = m_ProgramFolder + "\\Macro\\" + MacoGoodPic;
  1028. SendMsg("用宏抓好图" + fn);
  1029. iSEM.CMDMCFFilename(fn);
  1030. //延时1s??
  1031. Thread.Sleep(30000);
  1032. Thread.Sleep(10000);
  1033. WorkingFolder = m_measureFile.FilePath;
  1034. String fileName6 = WorkingFolder + "\\" + m_nWorkHoleNo.ToString() + "Hole" + ImageName6;
  1035. SendMsg("SEM拍照存储到" + fileName6);
  1036. if (!GetImage(ImageMode.SEM, fileName6))
  1037. {
  1038. SendMsg("SEM拍照失败");
  1039. return false;
  1040. }
  1041. //用宏抓标志图
  1042. fn = m_ProgramFolder + "\\Macro\\" + MacoExportTif;
  1043. SendMsg("用宏抓标志图" + fn);
  1044. iSEM.CMDMCFFilename(fn);
  1045. //延时1s??
  1046. Thread.Sleep(30000);
  1047. Thread.Sleep(5000);
  1048. fn = m_ProgramFolder + "\\Macro\\" + MacoScanPic;
  1049. SendMsg("用宏抓一般图" + fn);
  1050. iSEM.CMDMCFFilename(fn);
  1051. //延时1s??
  1052. Thread.Sleep(5000);
  1053. SendMsg("所有图结束");
  1054. ////17.自动控制SEM拍截面照
  1055. //{
  1056. // //1.控制SEM放大到指定参数大小范围,6000x
  1057. // if (!iSEM.SetMagnification(6000))
  1058. // {
  1059. // return false;
  1060. // }
  1061. // //2.控制SEM自动对焦、消像散、亮度、对比度
  1062. // if (!MeasParam.FocusMode)
  1063. // {
  1064. // //弹出手动对焦的窗口
  1065. // }
  1066. // else
  1067. // {
  1068. // //调用自动对焦模块
  1069. // }
  1070. // //3.设置SEM角度补偿cos36度
  1071. // if (!TiltCorrection(36))
  1072. // {
  1073. // return false;
  1074. // }
  1075. // //4.控制SEM拍照
  1076. // //5.保存照片4
  1077. // String fileName5 = WorkingFolder + ImageName5;
  1078. // if (!GetImage(ImageMode.SEM, fileName5))
  1079. // {
  1080. // return false;
  1081. // }
  1082. // //6.将照片传给客户,获取偏移坐标
  1083. // float x6 = 0, y6 = 0;
  1084. // float angle1 = 0;
  1085. // float mage = 10000;
  1086. // //7.根据坐标控制SEM移动到分析位置
  1087. // if (!iSEM.MoveStageXY(x6, y6))
  1088. // {
  1089. // return false;
  1090. // }
  1091. // //8.验证移动准确性:获取当前SEM中心位置坐标,与客户返回坐标对比,验证是否移动正确
  1092. // float x7 = iSEM.GetStageAtX();
  1093. // float y7 = iSEM.GetStageAtY();
  1094. // if (Math.Abs(x6 - x7) > fMin && Math.Abs(y6 - y7) > fMin)
  1095. // {
  1096. // return false;
  1097. // }
  1098. // //9.控制SEM平行校正,并记录校正前初始值
  1099. // float foldAnagle = iSEM.GetScanRotation();
  1100. // if (foldAnagle == float.NaN)
  1101. // {
  1102. // return false;
  1103. // }
  1104. // if (!iSEM.SetScanRotation(angle1))
  1105. // {
  1106. // return false;
  1107. // }
  1108. // //10.控制SEM放大到指定参数大小范围
  1109. // if (!iSEM.SetMagnification(mage))
  1110. // {
  1111. // return false;
  1112. // }
  1113. // //11.控制SEM自动对焦、消像散、亮度、对比度
  1114. // if (!MeasParam.FocusMode)
  1115. // {
  1116. // //弹出手动对焦的窗口
  1117. // }
  1118. // else
  1119. // {
  1120. // //调用自动对焦模块
  1121. // }
  1122. // //12.控制SEM对分析位置拍照
  1123. // String fileName6 = WorkingFolder + ImageName6;
  1124. // if (!GetImage(ImageMode.SEM, fileName6))
  1125. // {
  1126. // return false;
  1127. // }
  1128. // //13.保存照片
  1129. // //14.控制SEM取消电子束校正,回到初始值
  1130. // if (!iSEM.SetScanRotation(foldAnagle))
  1131. // {
  1132. // return false;
  1133. // }
  1134. //}
  1135. ////18.自动层高分析
  1136. //{
  1137. // //1.获取SEM Pixel Size给客户传入参数
  1138. // if (iSEM.GetPixelSize() == float.NaN)
  1139. // {
  1140. // return false;
  1141. // }
  1142. // //2.将照片传给客户,客户进行层高分析(返回分析后的图像、相对坐标、分辨率、各层编号以及各层对应的层高数据),如果客户自行出分析报告则无需返回数据
  1143. //}
  1144. ////19.自动能谱分析
  1145. //{
  1146. // //1. 确定能谱位置
  1147. // //2. 控制牛津打能谱
  1148. // //3. 能谱分析——面扫+线扫描
  1149. //}
  1150. return true;
  1151. }
  1152. //非第一个孔的测试过程
  1153. public void OtherHole()
  1154. {
  1155. //for (int i = 1; i < m_cutHoles.Count; i++)
  1156. //{
  1157. SendMsg("当前切孔号为"+ m_nWorkHoleNo.ToString());
  1158. CutHole currentHole = m_cutHoles[m_nWorkHoleNo];
  1159. //1. 初始化
  1160. {
  1161. //1. 设置FIB解冻:先读取状态,如果冻结则进行解冻
  1162. //读取图像冻结状态
  1163. float ffrozen = iSEM.GetImageFrozen();
  1164. if (ffrozen == float.NaN)
  1165. {
  1166. return;
  1167. }
  1168. if (DialogResult.Yes == MessageBox.Show("样品台可以旋转恢复到水平吗?", "确认消息", MessageBoxButtons.YesNo))
  1169. {
  1170. SendMsg("样品台恢复到水平");
  1171. //return true;
  1172. }
  1173. else
  1174. {
  1175. SendMsg("禁止样品台恢复到水平");
  1176. return;
  1177. }
  1178. //2. 调节样品1号孔的样品台6轴坐标
  1179. //3. 将样品1号孔坐标2存入数据库
  1180. //4. 控制样品台T轴归0,R轴变为坐标1、Z/M轴作为坐标2保存不变
  1181. if (!iSEM.SetStageGotoT(0))
  1182. {
  1183. return;
  1184. }
  1185. while (true)
  1186. {
  1187. Thread.Sleep(10000);
  1188. if (iSEM.GetStageIs() == 0)
  1189. {
  1190. break;
  1191. }
  1192. }
  1193. //5. 获取光镜2号孔XY坐标
  1194. SendMsg("移动到"+m_nWorkHoleNo+"号孔位置:(" + currentHole.Position.X.ToString()+","+currentHole.Position.Y.ToString()+")");
  1195. //6. 根据光镜坐标控制样品台移动
  1196. if (!iSEM.MoveStageXY(currentHole.Position.X, currentHole.Position.Y))
  1197. {
  1198. SendMsg("移动失败");
  1199. }
  1200. while (true)
  1201. {
  1202. Thread.Sleep(10000);
  1203. if (iSEM.GetStageIs() == 0)
  1204. {
  1205. break;
  1206. }
  1207. }
  1208. //7. 控制样品台,调整T轴54度、M/Z/R轴不变
  1209. if (DialogResult.Yes == MessageBox.Show("样品台可以旋转吗?", "确认消息", MessageBoxButtons.YesNo))
  1210. {
  1211. SendMsg("样品台旋转");
  1212. //return true;
  1213. }
  1214. else
  1215. {
  1216. SendMsg("禁止样品台旋转");
  1217. return;
  1218. }
  1219. if (!iSEM.SetStageGotoT(54))
  1220. {
  1221. return;
  1222. }
  1223. while (true)
  1224. {
  1225. Thread.Sleep(10000);
  1226. if (iSEM.GetStageIs() == 0)
  1227. {
  1228. break;
  1229. }
  1230. }
  1231. }
  1232. SendMsg("拉直操作");
  1233. SendMsg("其他操作与1号孔操作一致");
  1234. if (!CommonWork())
  1235. {
  1236. return;
  1237. }
  1238. //2. 定位切割
  1239. {
  1240. //1. 拉直操作
  1241. {
  1242. //1.1 控制SEM进行拍照
  1243. //1.2 图片传给客户,返回偏移角度
  1244. //1.3 根据返回角度,控制样品台转动
  1245. }
  1246. //2. 与1号孔13步相同
  1247. }
  1248. //3. 以后步骤与1号孔以后步骤一致
  1249. //}
  1250. }
  1251. //角度补偿
  1252. public bool TiltCorrection(float a_fAngle)
  1253. {
  1254. //记录原来电镜的状态
  1255. // bool bTilt = false;
  1256. //float fOldTilt = iSEM.GetTiltCorrection();
  1257. //if (fOldTilt == float.NaN)
  1258. //{
  1259. // return false;
  1260. //}
  1261. //else if (fOldTilt == 1)
  1262. //{
  1263. // bTilt = true;
  1264. //}
  1265. //else if (fOldTilt == 0)
  1266. //{
  1267. // bTilt = false;
  1268. //}
  1269. //float fOldAngle = iSEM.GetTiltAngle();
  1270. //if (fOldAngle == float.NaN)
  1271. //{
  1272. // return false;
  1273. //}
  1274. //开启校正
  1275. SendMsg("开启校正");
  1276. if (!iSEM.SetTiltAngleOn())
  1277. {
  1278. return false;
  1279. }
  1280. //设置校正角度
  1281. //if (!iSEM.SetTiltAngle(fOldAngle))
  1282. //{
  1283. // return false;
  1284. //}
  1285. //恢复原始状态
  1286. SendMsg("校正角度"+ a_fAngle.ToString());
  1287. if (!iSEM.SetTiltAngle(a_fAngle))
  1288. {
  1289. return false;
  1290. }
  1291. //if (bTilt)
  1292. //{
  1293. // if (!iSEM.SetTiltCorrectionOn())
  1294. // {
  1295. // return false;
  1296. // }
  1297. //}
  1298. //else
  1299. //{
  1300. // if (!iSEM.SetTiltCorrectionOff())
  1301. // {
  1302. // return false;
  1303. // }
  1304. //}
  1305. return true;
  1306. }
  1307. //拍图
  1308. public bool GetImage(ImageMode a_mode, String a_fileName)
  1309. {
  1310. //1. 图像解冻
  1311. float foldFrozen = iSEM.GetImageFrozen();
  1312. if (foldFrozen == float.NaN)
  1313. {
  1314. return false;
  1315. }
  1316. if (!iSEM.ImageLive())
  1317. {
  1318. return false;
  1319. }
  1320. //2. 确认图像模式
  1321. if (ImageMode.SEM == a_mode)
  1322. {
  1323. if (!iSEM.CmdFIBModeSEM())
  1324. {
  1325. return false;
  1326. }
  1327. }
  1328. else if (ImageMode.FIB == a_mode)
  1329. {
  1330. if (!iSEM.CmdFIBModeFIB())
  1331. {
  1332. return false;
  1333. }
  1334. }
  1335. else
  1336. {
  1337. return false;
  1338. }
  1339. //3. 获取分辨率
  1340. int[] ImageSize = iSEM.GetImageStore();
  1341. if (ImageSize[0] == 0 || ImageSize[1] == 0)
  1342. {
  1343. return false;
  1344. }
  1345. short width = (short)ImageSize[0];
  1346. short height = (short)ImageSize[1];
  1347. //4. 抓图
  1348. if (!iSEM.GrabImage(a_fileName, 0, 0, width, height, 0))
  1349. {
  1350. return false;
  1351. }
  1352. //5. 恢复初始状态
  1353. if (foldFrozen == 0)
  1354. {
  1355. if (!iSEM.ImageLive())
  1356. {
  1357. return false;
  1358. }
  1359. }
  1360. else if (foldFrozen == 1)
  1361. {
  1362. if (!iSEM.ImageFrozen())
  1363. {
  1364. return false;
  1365. }
  1366. }
  1367. return true;
  1368. }
  1369. }
  1370. }