Measure.cs 51 KB

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