123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419 |
- //时间:
- //作者:
- //功能:单元测试功能
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.IO;
- using SmartSEMControl;
- using FileManager;
- using System.Xml;
- using MeasureData;
- using WebManager;
- namespace HOZProject
- {
- public partial class FormUnitControl : Form
- {
- #region 系统参数
- //全局只有一个fatorySEM
- static FactoryHardware factorySEM = FactoryHardware.Instance;
- ISEMControl iSEM = factorySEM.ISEM;
- public XmlManager xmg = new XmlManager();
-
- private String path = Directory.GetCurrentDirectory();
- private int st_flag = 0;
- WebResult wr = new WebResult("127.0.0.1", "18080");
- #endregion
- #region 构造函数
- public FormUnitControl()
- {
- InitializeComponent();
- Control.CheckForIllegalCrossThreadCalls = false;
- if(iSEM.ConnectStatus())
- {
- float ret = iSEM.GetFIBIMAGING();
- if(ret==0)
- {
- btnSEM.BackColor = Color.Lime;
- }
- else if(ret==1)
- {
- btnFIB.BackColor = Color.Lime;
- panelFIB.Visible = true;
- }
- else if(ret==2)
- {
- btnMILL.BackColor = Color.Lime;
- }
- }
- //Calling Notification for updated status
- //CZEMApi.Notify += new _EMApiEvents_NotifyEventHandler(CZEMApi_Notify);
- //CZEMApi.NotifyWithCurrentValue += new _EMApiEvents_NotifyWithCurrentValueEventHandler(CZEMApi_NotifyWithCurrentValue);
- //加载参数
- }
- #endregion
-
- #region 缩放Get
- private void btnenlargeGet_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetMagnification();
- if (float.IsNaN(ret))
- {
- txtenlargeSet.Text = "NaN";
- txtenlargeSet.Enabled = false;
- btnenlargeSet.Enabled = false;
- }
- else
- {
- txtenlargeSet.Text = ret.ToString();
- btnenlargeSet.Enabled = true;
- }
- }
- #endregion
- #region 缩放Set
- private void btnenlargeSet_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtenlargeSet.Text, out set))
- {
- iSEM.SetMagnification(set);
- }
- }
- #endregion
- #region 焦距Get
- private void btnWDGet_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetWorkingDistance();
- if (float.IsNaN(ret))
- {
- txtWDSet.Text = "NaN";
- txtWDSet.Enabled = false;
- btnWDSet.Enabled = false;
- }
- else
- {
- txtWDSet.Text = ret.ToString();
- btnWDSet.Enabled = true;
- }
- }
- #endregion
- #region 焦距Set
- private void btnWDSet_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtWDSet.Text, out set))
- {
- iSEM.SetWorkingDistance(set);
- }
- }
- #endregion
- #region 亮度Get
- private void btnBrightnessGet_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetBrightness();
- if (float.IsNaN(ret))
- {
- txtBrightnessSet.Text = "NaN";
- txtBrightnessSet.Enabled = false;
- btnBrightnessSet.Enabled = false;
- }
- else
- {
- txtBrightnessSet.Text = ret.ToString();
- btnBrightnessSet.Enabled = true;
- }
- }
- #endregion
- #region 亮度Set
- private void btnBrightnessSet_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtBrightnessSet.Text, out set))
- {
- iSEM.SetBrightness(set);
- }
- }
- #endregion
- #region 对比度Get
- private void btnContrastGet_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetContrast();
- if (float.IsNaN(ret))
- {
- txtContrastSet.Text = "NaN";
- txtContrastSet.Enabled = false;
- btnContrastSet.Enabled = false;
- }
- else
- {
- txtContrastSet.Text = ret.ToString();
- btnContrastSet.Enabled = true;
- }
- }
- #endregion
- #region 对比度Set
- private void btnContrastSet_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtContrastSet.Text, out set))
- {
- iSEM.SetContrast(set);
- }
- }
- #endregion
- #region 消像散X Get
- private void btnAstigmatismXGet_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetAstigmatismX();
- if (float.IsNaN(ret))
- {
- txtAstigmatismXSet.Text = "NaN";
- txtAstigmatismXSet.Enabled = false;
- btnAstigmatismXSet.Enabled = false;
- }
- else
- {
- txtAstigmatismXSet.Text = ret.ToString();
- btnAstigmatismXSet.Enabled = true;
- }
- }
- #endregion
- #region 消像散X Set
- private void btnAstigmatismXSet_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtAstigmatismXSet.Text, out set))
- {
- iSEM.SetAstigmatismX(set);
- }
- }
- #endregion
- #region 消像散Y Get
- private void btnAstigmatismYGet_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetAstigmatismY();
- if (float.IsNaN(ret))
- {
- txtAstigmatismYSet.Text = "NaN";
- txtAstigmatismYSet.Enabled = false;
- btnAstigmatismYSet.Enabled = false;
- }
- else
- {
- txtAstigmatismYSet.Text = ret.ToString();
- btnAstigmatismYSet.Enabled = true;
- }
- }
- #endregion
- #region 消像散Y Set
- private void btnAstigmatismYSet_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtAstigmatismYSet.Text, out set))
- {
- iSEM.SetAstigmatismY(set);
- }
- }
- #endregion
- #region 角度补偿Get
- private void btnTiltAngleGet_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetTiltAngle();
- if (float.IsNaN(ret))
- {
- txtTiltAngleSet.Text = "NaN";
- txtTiltAngleSet.Enabled = false;
- btnTiltAngleSet.Enabled = false;
- }
- else
- {
- txtTiltAngleSet.Text = ret.ToString();
- btnTiltAngleSet.Enabled = true;
- }
- }
- #endregion
- #region 角度补偿Set
- private void btnTiltAngleSet_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtTiltAngleSet.Text, out set))
- {
- //iSEM.SetTiltAngleOn();
- iSEM.SetTiltAngle(set);
- }
- }
- #endregion
- #region 抓取图像
- private void btnGrabImage_Click(object sender, EventArgs e)
- {
- SaveFileDialog sfd = new SaveFileDialog();
- sfd.Title = "图像保存位置:";
- sfd.FileName = "test.tif";
- sfd.Filter = "TIF文件|*.tif";
- if (sfd.ShowDialog() == DialogResult.OK)
- {
- string fn = sfd.FileName;
- iSEM.GrabImage(fn, 0, 0, 1024, 768, 0);
- }
- }
- #endregion
- #region ScanRotate Get
- private void btnScanRotationGet_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetScanRotation();
- if (float.IsNaN(ret))
- {
- txtScanRotationSet.Text = "NaN";
- txtScanRotationSet.Enabled = false;
- btnScanRotationSet.Enabled = false;
- }
- else
- {
- txtScanRotationSet.Text = ret.ToString();
- btnScanRotationSet.Enabled = true;
- }
- }
- #endregion
- #region ScanRotate Set
- private void btnScanRotationSet_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtScanRotationSet.Text, out set))
- {
- //iSEM.SetScanRotationOn();
- iSEM.SetScanRotation(set);
- }
- }
- #endregion
- #region PixelSize Get
- private void btnPixelSizeGet_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetPixelSize();
- if (float.IsNaN(ret))
- {
- lblPixelSizeGet.Text = "NaN";
- }
- else
- {
- lblPixelSizeGet.Text = ret.ToString();
- }
- }
- #endregion
- #region 电子束
- private void btnTiltCorrXGet_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetBeamShiftX();
- if (float.IsNaN(ret))
- {
- txtTiltCorrX.Text = "NaN";
- txtTiltCorrX.Enabled = false;
- btnTiltCorrXSet.Enabled = false;
- }
- else
- {
- txtTiltCorrX.Text = ret.ToString();
- btnTiltCorrXSet.Enabled = true;
- }
- }
- private void btnTiltCorrXSet_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtTiltCorrX.Text, out set))
- {
- iSEM.SetBeamShiftX(set);
- }
- }
- private void btnTiltCorrYGet_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetBeamShiftY();
- if (float.IsNaN(ret))
- {
- txtTiltCorrY.Text = "NaN";
- txtTiltCorrY.Enabled = false;
- btnTiltCorrYSet.Enabled = false;
- }
- else
- {
- txtTiltCorrY.Text = ret.ToString();
- btnTiltCorrYSet.Enabled = true;
- }
- }
- private void btnTiltCorrYSet_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtTiltCorrY.Text, out set))
- {
- iSEM.SetBeamShiftY(set);
- }
- }
- #endregion
- #region 开启电压
- private void btnOpenVoltage_Click(object sender, EventArgs e)
- {
- iSEM.CmdOpenVoltage();
- }
- #endregion
- #region 关闭电压
- private void btnCloseVoltage_Click(object sender, EventArgs e)
- {
- iSEM.CmdCloseVoltage();
- }
- #endregion
- #region 电子束校正
- private void btnTiltCorr_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetTiltCorrection();
- if (float.IsNaN(ret))
- {
- btnTiltCorr.BackColor = Color.Red;
- }
- else
- {
- if(ret==0)
- {
- btnTiltCorr.BackColor = Color.Blue;
- iSEM.SetTiltCorrectionOn();
- btnTiltCorr.Text = "电子束状态:On";
- }
- else
- {
- btnTiltCorr.BackColor = Color.Lime;
- iSEM.SetTiltCorrectionOff();
- btnTiltCorr.Text = "电子束状态:Off";
- }
- }
- }
- #endregion
- #region 样品台位置获取
- private void btnStageGetX_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetStageAtX();
- if (float.IsNaN(ret))
- {
- lblStageX.Text = "NaN";
- }
- else
- {
- lblStageX.Text = ret.ToString();
- }
- }
- private void btnStageGetY_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetStageAtY();
- if (float.IsNaN(ret))
- {
- lblStageY.Text = "NaN";
- }
- else
- {
- lblStageY.Text = ret.ToString();
- }
- }
- private void btnStageGetZ_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetStageAtZ();
- if (float.IsNaN(ret))
- {
- lblStageZ.Text = "NaN";
- }
- else
- {
- lblStageZ.Text = ret.ToString();
- }
- }
- private void btnStageGetT_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetStageAtT();
- if (float.IsNaN(ret))
- {
- lblStageT.Text = "NaN";
- }
- else
- {
- lblStageT.Text = ret.ToString();
- }
- }
- private void btnStageGetR_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetStageAtR();
- if (float.IsNaN(ret))
- {
- lblStageR.Text = "NaN";
- }
- else
- {
- lblStageR.Text = ret.ToString();
- }
- }
- private void btnStageGetM_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetStageAtM();
- if (float.IsNaN(ret))
- {
- lblStageM.Text = "NaN";
- }
- else
- {
- lblStageM.Text = ret.ToString();
- }
- }
- #endregion
- #region 样品台位置设置
- private void btnStageSetX_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtStageX.Text, out set))
- {
- iSEM.SetStageGotoX(set);
- }
- }
- private void btnStageSetY_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtStageY.Text, out set))
- {
- iSEM.SetStageGotoY(set);
- }
- }
- private void btnStageSetZ_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtStageZ.Text, out set))
- {
- iSEM.SetStageGotoZ(set);
- }
- }
- private void btnStageSetT_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtStageT.Text, out set))
- {
- iSEM.SetStageGotoT(set);
- }
- }
- private void btnStageSetR_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtStageR.Text, out set))
- {
- iSEM.SetStageGotoR(set);
- }
- }
- private void btnStageSetM_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtStageM.Text, out set))
- {
- iSEM.SetStageGotoM(set);
- }
- }
- #endregion
- #region 获取样品台位置数组
- private void btnGetStagePosition_Click(object sender, EventArgs e)
- {
- float[] pt = iSEM.GetStagePosition();
- if (!float.IsNaN(pt[0]))
- {
- lblStageX.Text = pt[0].ToString();
- }
- if (!float.IsNaN(pt[1]))
- {
- lblStageY.Text = pt[1].ToString();
- }
- if (!float.IsNaN(pt[2]))
- {
- lblStageZ.Text = pt[2].ToString();
- }
- if (!float.IsNaN(pt[3]))
- {
- lblStageT.Text = pt[3].ToString();
- }
- if (!float.IsNaN(pt[4]))
- {
- lblStageR.Text = pt[4].ToString();
- }
- if (!float.IsNaN(pt[5]))
- {
- lblStageM.Text = pt[5].ToString();
- }
- }
- #endregion
- #region 窗体关闭
- private void FormUnitControl_FormClosing(object sender, FormClosingEventArgs e)
- {
- if(iSEM!=null)
- {
- iSEM.Dispose();
- }
- }
- #endregion
- #region 宏文件
- private void btnCMDMCF_Click(object sender, EventArgs e)
- {
- iSEM.CMDMCFFilename("OPTON");
- }
- #endregion
- #region 读取Xml文件
- private void btnReadXml_Click(object sender, EventArgs e)
- {
- MeasureFile mf = new MeasureFile();
- XmlDocument doc = new XmlDocument();
- doc.Load("test_opton.msf");//载入xml文件
- XmlNode root = doc.SelectSingleNode("XMLData");
- mf.Serialize(false, doc, root);
- doc.Save("test_opton.msf");
- }
- #endregion
- #region 写入Xml文件
- private void btnWriteXml_Click(object sender, EventArgs e)
- {
- MeasureFile mf = new MeasureFile();
- mf.FileName = path + "\\test_opton.msf";
- mf.FilePath = path;
- CutHole ch = new CutHole();
- ch.OPT = Operation.Image;
- ch.START = System.DateTime.Now;
- ch.END = System.DateTime.Now.AddHours(2);
- ch.STATE = State.Success;
- ch.SWITCH = true;
- SemPosition sp = new SemPosition();
- sp.X = 11;
- sp.Y = 22;
- sp.Z = 33;
- sp.T = 44;
- sp.R = 55;
- sp.M = 66;
- ch.Position = sp;
- mf.ListCutHole.Add(ch);
- ch = new CutHole();
- ch.OPT = Operation.Image;
- ch.START = System.DateTime.Now;
- ch.END = System.DateTime.Now.AddHours(2);
- ch.STATE = State.Success;
- ch.SWITCH = true;
- sp = new SemPosition();
- sp.X = 12;
- sp.Y = 34;
- sp.Z = 56;
- sp.T = 78;
- sp.R = 90;
- sp.M = 55;
- ch.Position = sp;
- mf.ListCutHole.Add(ch);
- MeasureParam md = new MeasureParam();
- md.SampleName = "aaaaaa";
- md.PT = true;
- md.PTTemp = "bbbbb";
- md.FIBTemp = "cccc";
- md.FocusMode = false;
- mf.MParam = md;
- mf.New();
- //XmlDocument doc = new XmlDocument();
- //doc.Load(mf.FilePath+"\\" + mf.FileName);//载入xml文件
- //XmlNode root = doc.SelectSingleNode("XMLData");
- //mf.Serialize(true, doc, root);
- //doc.Save("test.aaa");
- }
- #endregion
- #region SEM模式
- private void btnSEM_Click(object sender, EventArgs e)
- {
- if(iSEM.CmdFIBModeSEM())
- {
- btnFIB.BackColor = SystemColors.Control;
- btnSEM.BackColor = Color.Lime;
- btnMILL.BackColor = SystemColors.Control;
- panelFIB.Visible = false;
- }
- }
- #endregion
- #region FIB模式
- private void btnFIB_Click(object sender, EventArgs e)
- {
- if(iSEM.CmdFIBModeFIB())
- {
- btnFIB.BackColor = Color.Lime;
- btnSEM.BackColor = SystemColors.Control;
- btnMILL.BackColor = SystemColors.Control;
- panelFIB.Visible = true;
- }
- }
- #endregion
- #region MILL模式
- private void btnMILL_Click(object sender, EventArgs e)
- {
- if(iSEM.CmdFIBModeMILL())
- {
- btnFIB.BackColor = SystemColors.Control;
- btnSEM.BackColor = SystemColors.Control;
- btnMILL.BackColor = Color.Lime;
- }
- }
- #endregion
- #region 自动对焦1
- private void btnAutoFocus1_Click(object sender, EventArgs e)
- {
- //抓图1
- iSEM.GrabImage(path + "\\test1.tif", 0, 0, 1024, 768, 0);
- if (File.Exists(path + "\\test1.tif"))
- {
- FileStream fileStream = new FileStream(path + "\\test1.tif", FileMode.Open, FileAccess.Read);
- pictureBox1.Image = Image.FromStream(fileStream);
- fileStream.Close();
- fileStream.Dispose();
- }
- Thread.Sleep(1000);
- iSEM.CmdAutoFocusCoarse();
- btnAutoFocus1.BackColor = Color.Red;
- st_flag = 1;
- Thread.Sleep(1000);
- Thread thread = new Thread(AutoFunction);
- thread.Start();
- }
- #endregion
- #region 自动函数监测线程
- private void AutoFunction()
- {
- float ret = 111;
- Boolean state = false;
- while(true)
- {
- Thread.Sleep(1000);
- ret = iSEM.GetAutoFunction();
- if(ret==0)
- {
- if (st_flag == 1 && state == true)
- {
- btnAutoFocus1.BackColor = Color.Lime;
- Thread.Sleep(1000);
- //抓图1
- iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
- if (File.Exists(path + "\\test2.tif"))
- {
- FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
- pictureBox2.Image = Image.FromStream(fileStream);
- fileStream.Close();
- fileStream.Dispose();
- }
- break;
- }
- else if(st_flag==2 && state)
- {
- btnAutoFocus2.BackColor = Color.Lime;
- Thread.Sleep(1000);
- //抓图1
- iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
- if (File.Exists(path + "\\test2.tif"))
- {
- FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
- pictureBox2.Image = Image.FromStream(fileStream);
- fileStream.Close();
- fileStream.Dispose();
- }
- break;
- }
- else if (st_flag == 3)
- {
- btnAutoBrightness.BackColor = Color.Lime;
- Thread.Sleep(1000);
- //抓图1
- iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
- if (File.Exists(path + "\\test2.tif"))
- {
- FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
- pictureBox2.Image = Image.FromStream(fileStream);
- fileStream.Close();
- fileStream.Dispose();
- }
- break;
- }
- else if (st_flag == 4)
- {
- btnAutoContrast.BackColor = Color.Lime;
- Thread.Sleep(1000);
- //抓图1
- iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
- if (File.Exists(path + "\\test2.tif"))
- {
- FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
- pictureBox2.Image = Image.FromStream(fileStream);
- fileStream.Close();
- fileStream.Dispose();
- }
- break;
- }
- else if (st_flag == 5)
- {
- btnAutoBrightness.BackColor = Color.Lime;
- btnAutoContrast.BackColor = Color.Lime;
- btnAutoBC.BackColor = Color.Lime;
- Thread.Sleep(1000);
- //抓图1
- iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
- if (File.Exists(path + "\\test2.tif"))
- {
- FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
- pictureBox2.Image = Image.FromStream(fileStream);
- fileStream.Close();
- fileStream.Dispose();
- }
- break;
- }
- else if (st_flag == 6 && state)
- {
- btnAutoBCCancle.BackColor = Color.Lime;
- Thread.Sleep(1000);
- //抓图1
- iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
- if (File.Exists(path + "\\test2.tif"))
- {
- FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
- pictureBox2.Image = Image.FromStream(fileStream);
- fileStream.Close();
- fileStream.Dispose();
- }
- break;
- }
- else if (st_flag == 7 && state)
- {
- btnAutoStig.BackColor = Color.Lime;
- Thread.Sleep(1000);
- //抓图1
- iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
- if (File.Exists(path + "\\test2.tif"))
- {
- FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
- pictureBox2.Image = Image.FromStream(fileStream);
- fileStream.Close();
- fileStream.Dispose();
- }
- break;
- }
- ////抓图1
- //iSEM.GrabImage(path + "\\test2.tif", 0, 0, 1024, 768, 0);
- //if (File.Exists(path + "\\test2.tif"))
- //{
- // FileStream fileStream = new FileStream(path + "\\test2.tif", FileMode.Open, FileAccess.Read);
- // pictureBox2.Image = Image.FromStream(fileStream);
- // fileStream.Close();
- // fileStream.Dispose();
- //}
-
- }
- else if(ret>0 && ret<12)
- {
- state = true;
- }
- }
- }
- #endregion
- #region 自动对焦2
- private void btnAutoFocus2_Click(object sender, EventArgs e)
- {
- //抓图1
- iSEM.GrabImage(path + "\\test1.tif", 0, 0, 1024, 768, 0);
- if (File.Exists(path + "\\test1.tif"))
- {
- FileStream fileStream = new FileStream(path + "\\test1.tif", FileMode.Open, FileAccess.Read);
- pictureBox1.Image = Image.FromStream(fileStream);
- fileStream.Close();
- fileStream.Dispose();
- }
- Thread.Sleep(1000);
- iSEM.CmdAutoFocusFine();
- btnAutoFocus2.BackColor = Color.Red;
- st_flag = 2;
- Thread.Sleep(1000);
- Thread thread = new Thread(AutoFunction);
- thread.Start();
- }
- #endregion
- #region 自动亮度、对比度
- private void btnAutoBrightness_Click(object sender, EventArgs e)
- {
- //抓图1
- iSEM.GrabImage(path + "\\test1.tif", 0, 0, 1024, 768, 0);
- if (File.Exists(path + "\\test1.tif"))
- {
- FileStream fileStream = new FileStream(path + "\\test1.tif", FileMode.Open, FileAccess.Read);
- pictureBox1.Image = Image.FromStream(fileStream);
- fileStream.Close();
- fileStream.Dispose();
- }
- Thread.Sleep(1000);
- iSEM.SetAutoVideoBrightness();
- btnAutoBrightness.BackColor = Color.Red;
- st_flag = 3;
- Thread.Sleep(1000);
- Thread thread = new Thread(AutoFunction);
- thread.Start();
- }
- private void btnAutoContrast_Click(object sender, EventArgs e)
- {
- //抓图1
- iSEM.GrabImage(path + "\\test1.tif", 0, 0, 1024, 768, 0);
- if (File.Exists(path + "\\test1.tif"))
- {
- FileStream fileStream = new FileStream(path + "\\test1.tif", FileMode.Open, FileAccess.Read);
- pictureBox1.Image = Image.FromStream(fileStream);
- fileStream.Close();
- fileStream.Dispose();
- }
- Thread.Sleep(1000);
- iSEM.SetAutoVideoContrast();
- btnAutoContrast.BackColor = Color.Red;
- st_flag = 4;
- Thread.Sleep(1000);
- Thread thread = new Thread(AutoFunction);
- thread.Start();
- }
- private void btnAutoBC_Click(object sender, EventArgs e)
- {
- //抓图1
- iSEM.GrabImage(path + "\\test1.tif", 0, 0, 1024, 768, 0);
- if (File.Exists(path + "\\test1.tif"))
- {
- FileStream fileStream = new FileStream(path + "\\test1.tif", FileMode.Open, FileAccess.Read);
- pictureBox1.Image = Image.FromStream(fileStream);
- fileStream.Close();
- fileStream.Dispose();
- }
- Thread.Sleep(1000);
- iSEM.SetAutoVideoBrightnessAndContrast();
- btnAutoBrightness.BackColor = Color.Red;
- btnAutoContrast.BackColor = Color.Red;
- btnAutoBC.BackColor = Color.Red;
- st_flag = 5;
- Thread.Sleep(1000);
- Thread thread = new Thread(AutoFunction);
- thread.Start();
- }
- private void btnAutoBCCancle_Click(object sender, EventArgs e)
- {
- iSEM.SetAutoVideoOff();
- btnAutoBCCancle.BackColor = Color.Red;
- st_flag = 6;
- Thread.Sleep(1000);
- Thread thread = new Thread(AutoFunction);
- thread.Start();
- }
- #endregion
- #region 自动消像散
- private void btnAutoStig_Click(object sender, EventArgs e)
- {
- //抓图1
- iSEM.GrabImage(path + "\\test1.tif", 0, 0, 1024, 768, 0);
- if (File.Exists(path + "\\test1.tif"))
- {
- FileStream fileStream = new FileStream(path + "\\test1.tif", FileMode.Open, FileAccess.Read);
- pictureBox1.Image = Image.FromStream(fileStream);
- fileStream.Close();
- fileStream.Dispose();
- }
- Thread.Sleep(1000);
- iSEM.CmdAutoStig();
- btnAutoStig.BackColor = Color.Red;
- st_flag = 7;
- Thread.Sleep(1000);
- Thread thread = new Thread(AutoFunction);
- thread.Start();
- }
- #endregion
- #region FIB缩放Get
- private void btnFIBMagGet_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetFIBMagnification();
- if (float.IsNaN(ret))
- {
- txtFIBMag.Text = "NaN";
- txtFIBMag.Enabled = false;
- btnFIBMagSet.Enabled = false;
- }
- else
- {
- txtFIBMag.Text = ret.ToString();
- btnFIBMagSet.Enabled = true;
- }
- }
- #endregion
- #region FIB缩放Set
- private void btnFIBMagSet_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtFIBMag.Text, out set))
- {
- iSEM.SetFIBMagnification(set);
- }
- }
- #endregion
- #region FIB焦距Get
- private void btnFIBWDGet_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetFIBObjectivePotential();
- if (float.IsNaN(ret))
- {
- txtFIBWD.Text = "NaN";
- txtFIBWD.Enabled = false;
- btnFIBWDSet.Enabled = false;
- }
- else
- {
- txtFIBWD.Text = ret.ToString();
- btnFIBWDSet.Enabled = true;
- }
- }
- #endregion
- #region FIB焦距Set
- private void btnFIBWDSet_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtFIBWD.Text, out set))
- {
- iSEM.SetFIBObjectivePotential(set);
- }
- }
- #endregion
- #region FIB电子束移动
- private void btnFIBBeamShiftXGet_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetFIBBeamShiftX();
- if (float.IsNaN(ret))
- {
- txtFIBBeamShiftX.Text = "NaN";
- txtFIBBeamShiftX.Enabled = false;
- btnFIBBeamShiftXSet.Enabled = false;
- }
- else
- {
- txtFIBBeamShiftX.Text = ret.ToString();
- btnFIBBeamShiftXSet.Enabled = true;
- }
- }
- private void btnFIBBeamShiftXSet_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtFIBBeamShiftX.Text, out set))
- {
- iSEM.SetFIBBeamShiftX(set);
- }
- }
- private void btnFIBBeamShiftYGet_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetFIBBeamShiftY();
- if (float.IsNaN(ret))
- {
- txtFIBBeamShiftY.Text = "NaN";
- txtFIBBeamShiftY.Enabled = false;
- btnFIBBeamShiftYSet.Enabled = false;
- }
- else
- {
- txtFIBBeamShiftY.Text = ret.ToString();
- btnFIBBeamShiftYSet.Enabled = true;
- }
- }
- private void btnFIBBeamShiftYSet_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtFIBBeamShiftY.Text, out set))
- {
- iSEM.SetFIBBeamShiftY(set);
- }
- }
- #endregion
- #region 执行宏文件
- private void btnMCF_Click(object sender, EventArgs e)
- {
- OpenFileDialog sfd = new OpenFileDialog();
- sfd.Title = "选择宏文件:";
- sfd.InitialDirectory = @"C:\ProgramData\Carl Zeiss\SmartSEM\User\Default";
- sfd.Filter = "MLF文件|*.MLF";
- if (sfd.ShowDialog() == DialogResult.OK)
- {
- //string fn = Path.GetFileNameWithoutExtension(sfd.FileName).ToUpper();
- iSEM.CMDMCFFilename(sfd.FileName);
- }
- }
- #endregion
- #region FIB消像散
- private void btnFIBAstigmatismXGet_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetFIBAstigmatismX();
- if (float.IsNaN(ret))
- {
- txtFIBAstigmatismX.Text = "NaN";
- txtFIBAstigmatismX.Enabled = false;
- btnFIBAstigmatismXSet.Enabled = false;
- }
- else
- {
- txtFIBAstigmatismX.Text = ret.ToString();
- btnFIBAstigmatismXSet.Enabled = true;
- }
- }
- private void btnFIBAstigmatismXSet_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtFIBAstigmatismX.Text, out set))
- {
- iSEM.SetFIBAstigmatismX(set);
- }
- }
- private void btnFIBAstigmatismYGet_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetFIBAstigmatismY();
- if (float.IsNaN(ret))
- {
- txtFIBAstigmatismY.Text = "NaN";
- txtFIBAstigmatismY.Enabled = false;
- btnFIBAstigmatismYSet.Enabled = false;
- }
- else
- {
- txtFIBAstigmatismY.Text = ret.ToString();
- btnFIBAstigmatismYSet.Enabled = true;
- }
- }
- private void btnFIBAstigmatismYSet_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtFIBAstigmatismY.Text, out set))
- {
- iSEM.SetFIBAstigmatismY(set);
- }
- }
- #endregion
- #region 移动样品台XY
- private void btnMoveXY_Click(object sender, EventArgs e)
- {
- float setx = 0;
- float sety = 0;
- if (!float.TryParse(txtStageX.Text, out setx))
- {
- return;
- }
- if(!float.TryParse(txtStageY.Text,out sety))
- {
- return;
- }
- btnMoveXY.BackColor = Color.Red;
- iSEM.MoveStageXY(setx, sety);
- Thread.Sleep(500);
- Thread th = new Thread(MoveStagexy);
- th.Start();
- }
- private void MoveStagexy()
- {
- float ret = 111;
- while(true)
- {
- ret = iSEM.GetStageIs();
- if(ret==0)
- {
- btnMoveXY.BackColor = Color.Lime;
- break;
- }
- }
- }
- #endregion
- #region 获取分辨率
- private void btnImageStoreGet_Click(object sender, EventArgs e)
- {
- int[] ret = iSEM.GetImageStore();
- lblImageStore.Text = ret[0].ToString() + "*" + ret[1].ToString();
- }
- #endregion
- #region 设置分辨率
- private void btnImageStoreSet_Click(object sender, EventArgs e)
- {
- if (cmbImageStore.SelectedIndex > -1 && cmbImageStore.SelectedIndex < 12)
- {
- iSEM.SetImageStore(cmbImageStore.SelectedIndex);
- }
- }
- #endregion
- #region 样品台急停
- private void btnAbort_Click(object sender, EventArgs e)
- {
- iSEM.CmdStageAbort();
- }
- #endregion
- private void btnLive_Click(object sender, EventArgs e)
- {
- iSEM.ImageLive();
- }
- private void btnFrozen_Click(object sender, EventArgs e)
- {
- iSEM.ImageFrozen();
- }
- private void btnExeEly_Click(object sender, EventArgs e)
- {
- OpenFileDialog sfd = new OpenFileDialog();
- sfd.Title = "选择ELY文件:";
- //sfd.InitialDirectory = @"C:\ProgramData\Carl Zeiss\SmartSEM\User\Default";
- sfd.Filter = "ELY文件|*.ELY";
- if (sfd.ShowDialog() == DialogResult.OK)
- {
- iSEM.CmdFIBLoadELY(sfd.FileName);
- }
- }
- private void btnExeEly2_Click(object sender, EventArgs e)
- {
- iSEM.CmdFIBEXPOSUREELY();
- }
- private void btnFIBStatus_Click(object sender, EventArgs e)
- {
- btnFIBStatus.Text = iSEM.GetFIBMode().ToString();
- }
- private void btnPost1_Click(object sender, EventArgs e)
- {
- double degree = 0;
- int direction = 0;
- int state = 0;
- wr.Img_OffsetAngle_Direction("D:/aaaa.jpg", out degree, out direction, out state);
- lbldegree1.Text = degree.ToString("0.0");
- lbldirection1.Text = direction.ToString();
- lblstate1.Text = state.ToString();
- }
- private void btnPost2_Click(object sender, EventArgs e)
- {
- double offsetx = 0;
- double offsety = 0;
- int state = 0;
- wr.Img_Cut_Position("D:/aaaa.jpg", out offsetx, out offsety, out state);
- lbllocationx.Text = offsetx.ToString("0.0");
- lbllocationy.Text = offsety.ToString("0.0");
- lblstate2.Text = state.ToString();
- }
- private void btnPost3_Click(object sender, EventArgs e)
- {
- int state = 0;
- wr.Img_Cut_Success("D:/aaaa.jpg", "D:/bbbb.jpg", out state);
- lblstate3.Text = state.ToString();
- }
- private void btnPost4_Click(object sender, EventArgs e)
- {
- double offsetx = 0;
- double offsety = 0;
- int state = 0;
- wr.Img_Trapezoid_Top_Center_Position("D:/aaaa.jpg", out offsetx, out offsety, out state);
- lbltopcx.Text = offsetx.ToString("0.0");
- lbltopcy.Text = offsety.ToString("0.0");
- lblstate4.Text = state.ToString();
- }
- private void btnPost5_Click(object sender, EventArgs e)
- {
- List<string> filenames = new List<string>();
- filenames.Add("1111111");
- filenames.Add("2222222");
- filenames.Add("3333333");
- lblfocuspath.Text = wr.Img_Auto_Focus(filenames);
- }
- private void btnPost6_Click(object sender, EventArgs e)
- {
- List<string> filenames = new List<string>();
- filenames.Add("1111111");
- filenames.Add("2222222");
- filenames.Add("3333333");
- lblstigpath.Text = wr.Img_Auto_Focus(filenames);
- }
- private void btnPost7_Click(object sender, EventArgs e)
- {
- double offsetx = 0;
- double offsety = 0;
- double degree = 0;
- int direction = 0;
- int state = 0;
- wr.Img_Center_Position_OffsetAngle_Direction("D:/aaaa.jpg", out offsetx, out offsety, out degree, out direction, out state);
- lblcenterx.Text = offsetx.ToString("0.0");
- lblcentery.Text = offsety.ToString("0.0");
- lbldegree2.Text = degree.ToString();
- lbldirection2.Text = direction.ToString();
- lblstate5.Text = state.ToString();
- }
- private void btnPost8_Click(object sender, EventArgs e)
- {
- int state = 0;
- wr.Img_Measure_Size("D:/aaaa.jpg", "1000", "0.005", out state);
- lblstate6.Text = state.ToString();
- }
- private void btnScanRotationSetLock_Click(object sender, EventArgs e)
- {
- iSEM.SetScanRotationOff();
- }
- private void button1_Click_1(object sender, EventArgs e)
- {
- iSEM.SetTiltAngleOff();
- }
- private void btnTiltAngleSetOn_Click(object sender, EventArgs e)
- {
- iSEM.SetTiltAngleOn();
- }
- private void btnScanRotationSetOn_Click(object sender, EventArgs e)
- {
- iSEM.SetScanRotationOn();
- }
- private void btnExeEly3_Click(object sender, EventArgs e)
- {
- iSEM.CmdFIBSTARTELY();
- }
- private void btnCreateConfig_Click(object sender, EventArgs e)
- {
- ConfigManager cfm = new ConfigManager();
- cfm.PT_Depostion = chkpt0.Checked;
- cfm.Template_File = txtTemplateFile.Text;
- cfm.Sample_Name = txtSampleName.Text;
- cfm.M_Config_Param.Voltage = Convert.ToDouble(txtvoltage.Text);
- cfm.M_Config_Param.Magnification = Convert.ToDouble(txtMag.Text);
- cfm.M_Config_Param.Pixel_Size = Convert.ToDouble(txtpixel.Text);
- cfm.CreateXml(@"E:\test.cfg");
- cfm.Save(@"E:\test.cfg");
- }
- private void btnReadConfig_Click(object sender, EventArgs e)
- {
- ConfigManager cfm = new ConfigManager();
- cfm.Read(@"E:\test.cfg");
- this.ckbPT.Checked = cfm.PT_Depostion;
- this.lblTemplateFile.Text = cfm.Template_File;
- this.lblSampleName.Text = cfm.Sample_Name;
- this.lblvoltage.Text = cfm.M_Config_Param.Voltage.ToString();
- this.lblmag.Text = cfm.M_Config_Param.Magnification.ToString();
- this.lblpixel.Text = cfm.M_Config_Param.Pixel_Size.ToString();
- }
- }
- }
|