123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364 |
- //时间:
- //作者:
- //功能:单元测试功能
- 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.Configuration;
- using System.IO;
- using SmartSEMControl;
- using FileManager;
- using System.Xml;
- using MeasureData;
- using WebManager;
- using MeasureThread;
- namespace HOZProject
- {
- public partial class FormUnitControl : Form
- {
- #region 系统参数
- //全局只有一个fatorySEM
- static FactoryHardware factorySEM = FactoryHardware.Instance;
- ISEMControl iSEM = factorySEM.ISEM;
- //static FactoryHardware factorySEM = null;
- //ISEMControl iSEM = null;
- public XmlManager xmg = new XmlManager();
-
- private String path = Directory.GetCurrentDirectory();
- private int st_flag = 0;
- ImageProcess wr = new ImageProcess(ConfigurationManager.AppSettings["WebServerIP"].ToString(),
- ConfigurationManager.AppSettings["WebServerPort"].ToString(),
- ConfigurationManager.AppSettings["WebServerUrl"].ToString());
- String[] sT;
- String[] firms;
- Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
- #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.SampleType = "aaaaaa";
- md.IfPT = true;
- md.RemotePTOriginalEly = "bbbbb";
- md.RemoteFIBOriginalEly = "cccc";
- //md.FocusMode = 2;
- 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.SetRemoteDesMLFPath(@"\\192.168.1.197\wq\");
- 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.SetRemoteDesELYPath(@"\\192.168.1.197\wq\");
- 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)
- {
- float degree = 0;
- int direction = 0;
- int state = 0;
- wr.Img_OffsetAngle_Direction(txtaddr.Text,Convert.ToInt32(txtTypee.Text),txtfirm.Text, 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)
- {
- float offsetx1 = 0;
- float offsety1 = 0;
- float offsetx2 = 0;
- float offsety2 = 0;
- int state = 0;
- wr.Img_Cut_Position(txtaddr.Text, Convert.ToInt32(txtTypee.Text), txtfirm.Text, out offsetx1, out offsety1, out offsetx2, out offsety2, out state);
- lbllocationx1.Text = offsetx1.ToString("0.0");
- lbllocationy1.Text = offsety1.ToString("0.0");
- lbllocationx2.Text = offsetx2.ToString("0.0");
- lbllocationy2.Text = offsety2.ToString("0.0");
- lblstate2.Text = state.ToString();
- }
- private void btnPost3_Click(object sender, EventArgs e)
- {
- int state = 0;
- wr.Img_Cut_Success(txtaddr.Text, txtaddr2.Text, out state);
- lblstate3.Text = state.ToString();
- }
- private void btnPost4_Click(object sender, EventArgs e)
- {
- float offsetx = 0;
- float offsety = 0;
- int state = 0;
- //wr.Img_Trapezoid_Top_Center_Position(txtaddr.Text, 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)
- {
- float degree = 0;
- int direction = 0;
- int state = 0;
- wr.Img_Center_Position_OffsetAngle_Direction(txtaddr.Text, Convert.ToInt32(txtTypee.Text), txtfirm.Text, 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();
- lblstate7.Text = state.ToString();
- }
- private void btnPost9_Click(object sender, EventArgs e)
- {
- int state = 0;
- wr.Img_Measure_Size(txtaddr.Text, txtaddr2.Text,0.000001f,0.000002f,"D:\\", Convert.ToInt32(txtTypee.Text), txtfirm.Text,out state);
- lblstate9.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)
- {
- MeasureParam cfm = new MeasureParam();
- cfm.IsShotSectionToRun = chkWIsP.Checked;
- cfm.IfPT = chkWPT.Checked;
- cfm.RemotePTOriginalEly = txtWPTF.Text;
- cfm.RemoteFIBOriginalEly = txtWFIBF.Text;
- cfm.Straighten_Magnification = Convert.ToSingle(cbbWLZ.Text);
- cfm.Location_Magnification = Convert.ToSingle(cbbWQGF.Text);
- cfm.Voltage = Convert.ToSingle(cbbWQGD.Text);
- cfm.Photograph_Magnification = Convert.ToSingle(cbbWPZF.Text);
- cfm.Photograph_Voltage = Convert.ToSingle(cbbWPZD.Text);
- //if(cbbWXZ.SelectedIndex==0)
- //{
- // cfm.Correction_Angle = 36;
- //}
- //else
- //{
- // cfm.Correction_Angle = 54;
- //}
-
- cfm.SampleType = cbbWYP.Text;
- cfm.Firm = cbbWCS.Text;
- ConfigFile cf = new ConfigFile(cfm);
-
- cf.Save(@"E:\test.cfg");
- List<String> _sT = sT.ToList();
- if(_sT.IndexOf(cbbWYP.Text)<0)
- {
- _sT.Add(cbbWYP.Text);
- sT = _sT.ToArray();
- string wsT = "";
- for(int i=0;i<sT.Length;i++)
- {
- wsT += sT[i] + ",";
- }
- wsT = wsT.Substring(0, wsT.Length - 1);
- config.AppSettings.Settings["Sample_Type"].Value = wsT;
- }
- List<String> _firms = firms.ToList();
- if (_firms.IndexOf(cbbWCS.Text) < 0)
- {
- _firms.Add(cbbWCS.Text);
- firms = _firms.ToArray();
- string wFirms = "";
- for (int i = 0; i < firms.Length; i++)
- {
- wFirms += firms[i] + ",";
- }
- wFirms = wFirms.Substring(0, wFirms.Length - 1);
- config.AppSettings.Settings["Firm"].Value = wFirms;
- }
- config.Save(ConfigurationSaveMode.Modified);
- ConfigurationManager.RefreshSection("appSettings");//重新加载新的配置文件
- reloadconfig();
- }
- private void btnReadConfig_Click(object sender, EventArgs e)
- {
- MeasureParam cfm = new MeasureParam();
- ConfigFile cf = new ConfigFile(cfm);
- cf.Read(@"E:\test.cfg");
- chkRIsP.Checked = cfm.IsShotSectionToRun;
- chkRPT.Checked = cfm.IfPT;
- txtRPTF.Text = cfm.RemotePTOriginalEly;
- txtRFIBF.Text = cfm.RemoteFIBOriginalEly;
- txtRLZ.Text = cfm.Straighten_Magnification.ToString();
- txtRQGF.Text = cfm.Location_Magnification.ToString();
- txtRQGD.Text = cfm.Voltage.ToString();
- txtRPZF.Text = cfm.Photograph_Magnification.ToString();
- txtRPZD.Text = cfm.Photograph_Voltage.ToString();
- //txtRXZ.Text = cfm.Correction_Angle.ToString();
- txtRYP.Text = cfm.SampleType;
- txtRCS.Text = cfm.Firm;
- }
- private void FormUnitControl_Load(object sender, EventArgs e)
- {
- reloadconfig();
- cbbWYP.SelectedIndex = 0;
- cbbWCS.SelectedIndex = 0;
- cbbWXZ.SelectedIndex = 0;
- this.chart1.Series[0].Points.Clear();
-
- }
- private void reloadconfig()
- {
- String sample_Type = ConfigurationManager.AppSettings["Sample_Type"];
- String firm = ConfigurationManager.AppSettings["Firm"];
- sT = sample_Type.Split(',');
- cbbWYP.Items.Clear();
- for (int i = 0; i < sT.Length; i++)
- {
- cbbWYP.Items.Add(sT[i]);
- }
-
- firms = firm.Split(',');
- cbbWCS.Items.Clear();
- for (int i = 0; i < firms.Length; i++)
- {
- cbbWCS.Items.Add(firms[i]);
- }
-
- }
-
- private void btnPsFile_Click(object sender, EventArgs e)
- {
- OpenFileDialog sfd = new OpenFileDialog();
- sfd.Title = "选择位置文件:";
- //sfd.InitialDirectory = @"C:\ProgramData\Carl Zeiss\SmartSEM\User\Default";
- sfd.Filter = "TXT文件|*.TXT";
- if (sfd.ShowDialog() == DialogResult.OK)
- {
- //Console.WriteLine(sfd.FileName);
- StreamReader sr = new StreamReader(sfd.FileName, Encoding.Default);
- String line = "";
- sr.ReadLine();
- sr.ReadLine();
- sr.ReadLine();
- sr.ReadLine();
- line = sr.ReadLine();
- sr.Close();
- sr.Dispose();
- String[] lines = line.Split(',');
- double x = Convert.ToDouble(lines[1]);
- double y = Convert.ToDouble(lines[2]);
- chart1.Series[0].Points.AddXY(x, y);
- chart1.Series[0].Points[0].Label = x.ToString("0.000") + "," + y.ToString("0.000");
- }
- }
- private void btnrect_Click(object sender, EventArgs e)
- {
- this.chart1.Series[0].Points.Clear();
- List<double> xpoints = new List<double>();
- List<double> ypoints = new List<double>();
- //排列数
- int rag = Convert.ToInt32(txtarray.Text);
- //间距
- float dist = Convert.ToSingle(txtdistance.Text);
- //中心点x,y轴坐标
- float cx = Convert.ToSingle(txtx.Text);
- float cy = Convert.ToSingle(txty.Text);
- //所有点集合
- List<PointF> ptfs = new List<PointF>();
- ptfs = AnalysisPosition(cx, cy, Convert.ToSingle(txtsample1x.Text),
- Convert.ToSingle(txtsample1y.Text), dist, rag);
- for(int i=0;i<ptfs.Count;i++)
- {
- chart1.Series[0].Points.AddXY(ptfs[i].X, ptfs[i].Y);
- chart1.Series[0].Points[chart1.Series[0].Points.Count - 1].Label = ptfs[i].X.ToString("0.000") + "," + ptfs[i].Y.ToString("0.000");
- }
- ////求样品1的水平角度
- //double angle = 0;
- ////xpoints.Add(Math.Pow(Math.Pow(Convert.ToDouble(txtx.Text), 2) + Math.Pow(Convert.ToDouble(txty.Text), 2), 0.5));
- ////ypoints.Add(Math.Pow(Math.Pow(Convert.ToDouble(txtx.Text), 2) + Math.Pow(Convert.ToDouble(txty.Text), 2), 0.5));
- //xpoints.Add(Convert.ToDouble(txtsample1x.Text));
- //ypoints.Add(Convert.ToDouble(txtsample1y.Text));
- ////计算第一个点与X轴的交角度数
- //angle = Math.Atan2(ypoints[0] - cy, cx - xpoints[0]) * 180 / Math.PI;
- //lblPs1.Text = angle.ToString("0.0");
- ////这里是求与第一个点横向排列的其他点的移动角度
- ////就是按45度向左向右移动的度
- //angle = 45 - angle;
- //angle = angle * Math.PI / 180;
- //txtsample1x.Text = xpoints[0].ToString("0.000");
- //txtsample1y.Text = ypoints[0].ToString("0.000");
- //chart1.Series[0].Points.AddXY(xpoints[0], ypoints[0]);
- //chart1.Series[0].Points[chart1.Series[0].Points.Count - 1].Label = xpoints[0].ToString("0.000") + "," + ypoints[0].ToString("0.000");
- //double tx = 0;
- //double ty = 0;
- //for (int j = 0; j < rag; j++)
- //{
- // //计算每行第一个点的坐标
- // if(j>0)
- // {
- // tx = dist * j * Math.Sin(angle);
- // ty = dist * j * Math.Cos(angle);
- // xpoints.Add(tx + xpoints[0]);
- // ypoints.Add(ypoints[0] - ty);
- // chart1.Series[0].Points.AddXY(xpoints[xpoints.Count-1], ypoints[ypoints.Count-1]);
- // chart1.Series[0].Points[chart1.Series[0].Points.Count - 1].Label = xpoints[xpoints.Count - 1].ToString("0.000") + "," + ypoints[ypoints.Count - 1].ToString("0.000");
- // }
- // //计算每行其他点的坐标
- // for (int i = 1; i < rag; i++)
- // {
- // tx = dist * i * Math.Cos(angle);
- // ty = dist * i * Math.Sin(angle);
- // xpoints.Add(tx + xpoints[j * rag]);
- // ypoints.Add(ty + ypoints[j * rag]);
- // chart1.Series[0].Points.AddXY(xpoints[xpoints.Count - 1], ypoints[ypoints.Count - 1]);
- // chart1.Series[0].Points[chart1.Series[0].Points.Count - 1].Label = xpoints[xpoints.Count - 1].ToString("0.000") + "," + ypoints[ypoints.Count - 1].ToString("0.000");
- // }
- //}
- }
- /// <summary>
- /// 分析点坐标
- /// </summary>
- /// <param name="centerX">中心点X轴坐标</param>
- /// <param name="centerY">中心点Y轴坐标</param>
- /// <param name="firstX">第一个点X轴坐标</param>
- /// <param name="firstY">第一个点Y轴坐标</param>
- /// <param name="distance">点与点的距离</param>
- /// <param name="rag">行、列数</param>
- /// <param name="ptsx">计算生成所有X轴坐标</param>
- /// <param name="ptsy">计算生成所有Y轴坐标</param>
- public List<PointF> AnalysisPosition(float centerX, float centerY, float firstX, float firstY, float distance, int rag)
- {
- //求样品1的水平角度
- double angle = 0;
- //清空所有点信息
- List<float> ptsx = new List<float>();
- List<float> ptsy = new List<float>();
- //将第一个点加入到点信息中
- ptsx.Add(firstX);
- ptsy.Add(firstY);
- //计算第一个点与X轴的交角度数
- angle = Math.Atan2(ptsy[0] - centerY, centerX - ptsx[0]) * 180 / Math.PI;
- //这里是求与第一个点横向排列的其他点的移动角度
- //就是按45度向左向右移动的度
- angle = 45 - angle;
- angle = angle * Math.PI / 180;
- float tx = 0;
- float ty = 0;
- for (int j = 0; j < rag; j++)
- {
- //计算每行第一个点的坐标
- if (j > 0)
- {
- tx = (float)(distance * j * Math.Sin(angle));
- ty = (float)(distance * j * Math.Cos(angle));
- ptsx.Add(tx + ptsx[0]);
- ptsy.Add(ptsy[0] - ty);
- }
- //计算每行其他点的坐标
- for (int i = 1; i < rag; i++)
- {
- tx = (float)(distance * i * Math.Cos(angle));
- ty = (float)(distance * i * Math.Sin(angle));
- ptsx.Add(tx + ptsx[j * rag]);
- ptsy.Add(ty + ptsy[j * rag]);
- }
- }
- List<PointF> pts = new List<PointF>();
- for (int i = 0; i < ptsx.Count; i++)
- {
- //增加的点
- PointF pf = new PointF();
- pf.X = ptsx[i];
- pf.Y = ptsy[i];
- pts.Add(pf);
- }
- return pts;
- }
- private void btn30_Click(object sender, EventArgs e)
- {
- txtsample1x.Text = "21.7";
- txtsample1y.Text = "90";
- btnrect_Click(null, null);
- }
- private void btn45_Click(object sender, EventArgs e)
- {
- txtsample1x.Text = "29.65";
- txtsample1y.Text = "100.35";
- btnrect_Click(null, null);
- }
- private void btn60_Click(object sender, EventArgs e)
- {
- txtsample1x.Text = "40";
- txtsample1y.Text = "108.3";
- btnrect_Click(null, null);
- }
- private void button2_Click(object sender, EventArgs e)
- {
- float ret = iSEM.GetSEMVoltage();
- if (float.IsNaN(ret))
- {
- txtVoltage.Text = "NaN";
- txtVoltage.Enabled = false;
- button2.Enabled = false;
- }
- else
- {
- txtVoltage.Text = ret.ToString();
- button2.Enabled = true;
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtVoltage.Text, out set))
- {
- iSEM.SetSEMVoltage(set);
- }
- }
- /// 图像拉直算法
- /// </summary>
- /// <param name="Slope">倾斜角度</param>
- /// <param name="x0">圆心坐标x</param>
- /// <param name="y0">圆心坐标y</param>
- /// <param name="x1">倾斜情况下帧图的坐标x</param>
- /// <param name="y1">倾斜情况下帧图的坐标y</param>
- /// <param name="Hx">复位到原位置需要移动的x值(返回值)</param>
- /// <param name="Hy">复位到原位置需要移动的y值(返回值)</param>
- /// <returns></returns>
- public bool Straightening(float Slope, float x0, float y0, float x1, float y1, ref float Hx, ref float Hy)
- {
- try
- {
- float xr = x1 - x0;//倾斜图到中心的距离差x
- float yr = y1 - y0;//倾斜图到中心的距离差y
- float R =(float)Math.Sqrt(xr * xr + yr * yr);//圆心到倾斜图的长度
- //double D = 2 * R * Math.Sin(ScanRotation / 2);//倾斜图与矫正图底边的长度
- float k = (float)(Math.Atan(yr / xr) / Math.PI * 180);//x1,y1的直角三角形圆心角度
- float k_S = k - Slope;//通过夹角差求x2,y2
- //int y2 = (int)Math.Round(Math.Sin(Math.PI / (180 / k_S)) * R);
- //int x2 = (int)Math.Round(Math.Cos(Math.PI / (180 / k_S)) * R);
- float y2 = (float)(Math.Sin(Math.PI / (180 / k_S)) * R);
- float x2 = (float)(Math.Cos(Math.PI / (180 / k_S)) * R);
- if (Slope > 0 || Slope < 0)
- {
- Hx = x0 + x2;
- Hy = y0 + y2;
- }
- else
- {
- Hx = 0;
- Hy = 0;
- }
- return true;
- }
- catch (Exception)
- {
- return false;
- }
- }
- private void button3_Click(object sender, EventArgs e)
- {
- float x1 = 0, y1 = 0;
- Straightening(45, 48.156f, 49.968f, (float)31.679, (float)58.870, ref x1, ref y1);
- button3.Text = x1.ToString("0.00") + "\n" + y1.ToString("0.00");
- }
- private void btntest_Click(object sender, EventArgs e)
- {
- //FileStream fs = new FileStream(txtaddr.Text, FileMode.Create, FileAccess.Write);
- //StreamWriter sw = new StreamWriter(fs);
- //sw.WriteLine("aaaa");
- //sw.Close();
- //sw.Dispose();
- //fs.Close();
- //fs.Dispose();
- File.Copy(txtaddr2.Text, txtaddr.Text, true);
- }
- private void button4_Click(object sender, EventArgs e)
- {
- iSEM.SetWorkingDistance(0.006f);
- Thread.Sleep(8000);
- iSEM.GrabImage("D:\\HOZ1.0\\6.tif", 0, 0, 1024, 768, 0);
- Thread.Sleep(3000);
- iSEM.SetWorkingDistance(0.007f);
- Thread.Sleep(8000);
- iSEM.GrabImage("D:\\HOZ1.0\\7.tif", 0, 0, 1024, 768, 0);
- Thread.Sleep(3000);
- iSEM.SetWorkingDistance(0.0073f);
- Thread.Sleep(8000);
- iSEM.GrabImage("D:\\HOZ1.0\\73.tif", 0, 0, 1024, 768, 0);
- Thread.Sleep(3000);
- }
- //移动到像素位置
- bool MoveToPix(float sx,float sy,float xc, float yc,float ps,out float nx,out float ny)
- {
-
- int width = 1024/2;
- int height = 768/2;
- float deltX = (xc - (float)width) * ps;
- float deltY = (yc - (float)height) * ps;
- float xpCur = sx;
- float ypCur = sy;
- float xpNew = xpCur - deltX;
- float ypNew = ypCur - deltY;
- nx = xpNew;
- ny = ypNew;
- //if (deltX > 10)//使用移动样品台实现
- //{
- // if (!iSEM.SetStageGotoX(xpNew))
- // {
- // return false;
- // }
- // //判断是否移动完成
- // while (true)
- // {
- // Thread.Sleep(5000);
- // if (iSEM.GetStageIs() == 0)
- // {
- // break;
- // }
- // }
- // //arg.Message = "移动到新x" + xpNew.ToString() + "位置失败";
- // //arg.State = true;
- // //SendMsg("1-7");
- //}
- //else//使用移动光束实现
- //{
- // float beamX = deltX * (float)0.66;
- // if (!iSEM.SetBeamShiftX(beamX))
- // {
- // return false;
- // }
- //}
- //if (deltY > 10)//使用移动样品台实现
- //{
- // if (!iSEM.SetStageGotoY(ypNew))
- // {
- // return false;
- // }
- // //判断是否移动完成
- // while (true)
- // {
- // Thread.Sleep(5000);
- // if (iSEM.GetStageIs() == 0)
- // {
- // break;
- // }
- // }
- //}
- //else//使用移动光束实现
- //{
- // float beamY = deltY * (float)0.671;
- // if (!iSEM.SetBeamShiftY(beamY))
- // {
- // return false;
- // }
- //}
- return true;
- }
- private void btnimgv_Click(object sender, EventArgs e)
- {
- float sx = 0, sy = 0;
- float x1 = 0, y1 = 0;
- float nx = 0, ny = 0;
- float ps = 0;
- sx = Convert.ToSingle(txtstagenx.Text);
- sy = Convert.ToSingle(txtstageny.Text);
- x1 = Convert.ToSingle(txtimgx.Text);
- y1 = Convert.ToSingle(txtimgy.Text);
- ps = Convert.ToSingle(txtps.Text);
- MoveToPix(sx,sy,x1, y1, ps,out nx,out ny);
- txtstagevx.Text = nx.ToString("0.000000");
- txtstagevy.Text = ny.ToString("0.000000");
- }
- private void btnPost8_Click(object sender, EventArgs e)
- {
- System.Drawing.Point pt1, pt2, pt3;
- float mag1 = 0, mag2 = 0;
- int state = 0;
- wr.Img_Two_Region_Position(txtaddr.Text, Convert.ToInt32(txtTypee.Text), txtfirm.Text, out pt1, out mag1, out pt2, out mag2, out pt3, out state);
- if(state==1)
- {
- lblcenter1.Text = pt1.X.ToString() + "," + pt1.Y.ToString();
- lblcenter2.Text = pt2.X.ToString() + "," + pt2.Y.ToString();
- lblMag1.Text = mag1.ToString();
- lblMag2.Text = mag2.ToString();
- lblstate8.Text = state.ToString();
- }
- else
- {
- lblstate8.Text = "0";
- lblcenter1.Text = "";
- lblcenter2.Text = "";
- lblMag1.Text = "";
- lblMag2.Text = "";
- }
- }
- private void button5_Click(object sender, EventArgs e)
- {
- XmlDocument xmlDoc = new XmlDocument();
- xmlDoc.Load(@"E:\HOZ\test3.ely");//加载baixml文件,xmlpath 为XML文件的路径du
- XmlNode xns = xmlDoc.SelectSingleNode("ELAYOUT/STRUCTURE_LIST/STRUCTURE/LAYER_REFERENCE/TRAPEZOID");
- if (xns != null)
- {
- XmlAttributeCollection attributeCol = xns.Attributes;
- //遍历自己点属性
- foreach (XmlAttribute attri in attributeCol)
- {
- if (attri.Name == "x")
- {
- attri.InnerText = "123";
- }
- else if (attri.Name == "y")
- {
- attri.InnerText = "321";
- }
- ////获取每个节点属性的key,value值
- //string name = attri.Name;
- //string value = attri.Value;
- //Console.WriteLine("{0}={1}", name, value);
- }
- }
- xns = xmlDoc.SelectSingleNode("ELAYOUT/STRUCTURE_LIST/STRUCTURE/LAYER_REFERENCE/RECT");
- if (xns != null)
- {
- XmlAttributeCollection attributeCol = xns.Attributes;
- //遍历自己点属性
- foreach (XmlAttribute attri in attributeCol)
- {
- if (attri.Name == "x")
- {
- attri.InnerText = "123";
- }
- else if (attri.Name == "y")
- {
- attri.InnerText = "323";
- }
- ////获取每个节点属性的key,value值
- //string name = attri.Name;
- //string value = attri.Value;
- //Console.WriteLine("{0}={1}", name, value);
- }
- }
- xmlDoc.Save(@"E:\HOZ\test3.ely");//保存的该XML文件,否则更新无效
- xmlDoc = new XmlDocument();
- xmlDoc.Load(@"E:\HOZ\test2.ely");//加载baixml文件,xmlpath 为XML文件的路径du
- xns = xmlDoc.SelectSingleNode("ELAYOUT/STRUCTURE_LIST/STRUCTURE/LAYER_REFERENCE/RECT");
- if (xns != null)
- {
- XmlAttributeCollection attributeCol = xns.Attributes;
- //遍历自己点属性
- foreach (XmlAttribute attri in attributeCol)
- {
- if (attri.Name == "x")
- {
- attri.InnerText = "123";
- }
- else if (attri.Name == "y")
- {
- attri.InnerText = "321";
- }
- ////获取每个节点属性的key,value值
- //string name = attri.Name;
- //string value = attri.Value;
- //Console.WriteLine("{0}={1}", name, value);
- }
- }
- xmlDoc.Save(@"E:\HOZ\test2.ely");//保存的该XML文件,否则更新无效
- }
- private void button6_Click(object sender, EventArgs e)
- {
- int x1, x2, y1, y2;
- x1 = Convert.ToInt32(textBox1.Text);
- y1 = Convert.ToInt32(textBox2.Text);
- x2 = x1 - (1024 / 2);
- y2 = (768 / 2) - y1;
- button6.Text=x2.ToString() + "," + y2.ToString();
- }
- private void btnDRSet_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtDRSet.Text, out set))
- {
- iSEM.SetStageDeltaR(set);
- }
- }
- private void btnDeltaR_Click(object sender, EventArgs e)
- {
- float set = 0;
- if (float.TryParse(txtDRSet.Text, out set))
- {
- iSEM.SetStageDeltaR(set);
- }
- }
- private void button9_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)
- {
- double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
- x1 = Convert.ToDouble(txtelyx.Text);
- y1 = Convert.ToDouble(txtelyy.Text);
- x2 = x1 - 512;
- y2 = 384 - y1;
- float px = iSEM.GetPixelSize();
- XmlDocument xmlDoc = new XmlDocument();
- xmlDoc.Load(sfd.FileName);//加载baixml文件,xmlpath 为XML文件的路径du
- XmlNode xns = xmlDoc.SelectSingleNode("ELAYOUT/STRUCTURE_LIST/STRUCTURE/LAYER_REFERENCE/TRAPEZOID");
- if (xns != null)
- {
- XmlAttributeCollection attributeCol = xns.Attributes;
- //遍历自己点属性
- foreach (XmlAttribute attri in attributeCol)
- {
- if (attri.Name == "x")
- {
- attri.InnerText = ((x2 * px) * 1000000).ToString();
- }
- else if (attri.Name == "y")
- {
- attri.InnerText = ((y2 * px) * 1000000).ToString();
- }
- ////获取每个节点属性的key,value值
- //string name = attri.Name;
- //string value = attri.Value;
- //Console.WriteLine("{0}={1}", name, value);
- }
- }
- xns = xmlDoc.SelectSingleNode("ELAYOUT/STRUCTURE_LIST/STRUCTURE/LAYER_REFERENCE/RECT");
- if (xns != null)
- {
- XmlAttributeCollection attributeCol = xns.Attributes;
- //遍历自己点属性
- foreach (XmlAttribute attri in attributeCol)
- {
- if (attri.Name == "x")
- {
- attri.InnerText = ((x2 * px) * 1000000).ToString();
- }
- else if (attri.Name == "y")
- {
- attri.InnerText = ((y2 * px) * 1000000 + 2).ToString();
- }
- ////获取每个节点属性的key,value值
- //string name = attri.Name;
- //string value = attri.Value;
- //Console.WriteLine("{0}={1}", name, value);
- }
- }
- xmlDoc.Save(sfd.FileName);//保存的该XML文件,否则更新无效
- iSEM.CmdFIBLoadELY(sfd.FileName);
- }
-
- }
- //移动到像素位置
- bool MoveToPix(float xc, float yc)
- {
- //单位是m/pix
- float pixSize = iSEM.GetPixelSize();
- LogManager.AddHardwareLog("像素尺寸=" + pixSize.ToString() + "m/pixel", true);
- Thread.Sleep(500);
- //0:width, 1:height
- int[] imageSize = iSEM.GetImageStore();
- int width = imageSize[0] / 2;
- int height = imageSize[1] / 2;
- LogManager.AddHardwareLog("目标像素是(" + xc.ToString() + "," + yc.ToString() + ")", true);
- LogManager.AddHardwareLog("中心像素是(" + width.ToString() + "," + height.ToString() + ")", true);
- float deltX = (xc - (float)width) * pixSize;
- float deltY = (yc - (float)height) * pixSize;
- LogManager.AddHardwareLog("x位移量 = " + deltX.ToString() + "m", true);
- LogManager.AddHardwareLog("y位移量 = " + deltY.ToString() + "m", true);
- float xpCur = iSEM.GetStageAtX();
- float ypCur = iSEM.GetStageAtY();
- LogManager.AddHardwareLog("当前位置(" + xpCur.ToString() + "," + ypCur.ToString() + "),单位m", true);
- float xpNew = xpCur - deltX;
- float ypNew = ypCur + deltY;
- LogManager.AddHardwareLog("目标位置(" + xpNew.ToString() + "," + ypNew.ToString() + "),单位m", true);
- //计算最大偏移量
- float beamXCur = iSEM.GetBeamShiftX();//单位是%
- iSEM.SetBeamShiftX(100);
- float beamXMax = iSEM.GetBeamOffsetX();//单位是m
- iSEM.SetBeamShiftX(beamXCur);
- //计算光束偏移值:
- float beamX = iSEM.GetBeamOffsetX();
- LogManager.AddHardwareLog("当前X方向光束偏移量=" + beamX.ToString() + "m", true);
- beamX = (-deltX + beamX);
- LogManager.AddHardwareLog("X方向光束偏移量应为=" + beamX.ToString() + "m", true);
- if (beamX < beamXMax || beamX < -beamXMax)
- {
- LogManager.AddHardwareLog("X方向移动光束", true);
- float beamXShift = beamX * 100 / beamXMax;
- if (!iSEM.SetBeamShiftX(beamXShift))
- {
- LogManager.AddHardwareLog("X方向光束偏移量" + beamX.ToString() + "m失败", true);
- return false;
- }
- }
- else if (deltX > 0.000003 || deltX < -0.000003)//大于3um使用移动样品台实现
- {
- LogManager.AddHardwareLog("X方向移动样品台", true);
- if (!iSEM.SetStageGotoX(xpNew))
- {
- return false;
- }
- //判断是否移动完成
- while (true)
- {
- Thread.Sleep(5000);
- if (iSEM.GetStageIs() == 0)
- {
- break;
- }
- }
- }
- float beamY = iSEM.GetBeamOffsetY();
- LogManager.AddHardwareLog("当前Y方向光束偏移量=" + beamY.ToString() + "m", true);
- beamY = (-deltY + beamY);
- LogManager.AddHardwareLog("Y方向光束偏移量应为=" + beamY.ToString() + "m", true);
- //计算最大偏移量
- float beamYCur = iSEM.GetBeamShiftY();//单位是%
- iSEM.SetBeamShiftY(100);
- float beamYMax = iSEM.GetBeamOffsetY();//单位是m
- iSEM.SetBeamShiftY(beamYCur);
- if (beamY < beamYMax || beamY < -beamYMax)
- {
- LogManager.AddHardwareLog("Y方向移动光束", true);
- float beamYShift = beamY * 100 / beamYMax;
- if (!iSEM.SetBeamShiftY(beamY))
- {
- LogManager.AddHardwareLog("Y方向光束偏移量" + beamY.ToString() + "m失败", true);
- return false;
- }
- }
- else if (deltY > 0.000003 || deltY < -0.000003)//大于3um使用移动样品台实现
- {
- LogManager.AddHardwareLog("Y方向移动样品台", true);
- if (!iSEM.SetStageGotoY(ypNew))
- {
- return false;
- }
- //判断是否移动完成
- while (true)
- {
- Thread.Sleep(5000);
- if (iSEM.GetStageIs() == 0)
- {
- break;
- }
- }
- //arg.Message = "移动到新x" + xpNew.ToString() + "位置失败";
- //arg.State = true;
- //SendMsg("1-7");
- }
- return true;
- }
- private void button10_Click(object sender, EventArgs e)
- {
- MoveToPix(Convert.ToSingle(txtTx.Text), Convert.ToSingle(txtTy.Text));
- }
- float cycle_time = 0;
- private void button11_Click(object sender, EventArgs e)
- {
- iSEM.SetReduced(256, 192, 512, 512);
- Thread.Sleep(100);
- iSEM.CmdFocusRate(4);
- Thread.Sleep(200);
- cycle_time = iSEM.GetCycleTime();
- Thread.Sleep(200 + Convert.ToInt32(cycle_time));
- //放大到10000倍
- iSEM.SetMagnification(10000);
- Thread.Sleep(200 + Convert.ToInt32(cycle_time));
- //自动亮度对比度
- iSEM.SetAutoVideoBrightnessAndContrast();
- Thread.Sleep(5000);
- //自动对焦
- if (Directory.Exists(txtFocus.Text))
- {
- Directory.Delete(txtFocus.Text, true);
- }
- Thread.Sleep(3000);
- //再创建文件夹
- Directory.CreateDirectory(txtFocus.Text);
- //1、对焦参数类,2、输出工作距离
- int wd = 0;
- //20201015 根据当前的工作距离重新计算对焦位置
- float currentWd = iSEM.GetWorkingDistance();//0.0154m =15.4mm = 15400um
- MeasureFile m_measureFile = new MeasureFile();
-
-
- //设置工作距离
- iSEM.SetWorkingDistance((float)(wd * 0.00000001));
- //设置完工作距离后必须延迟5秒
- Thread.Sleep(2000);
- //放大倍数5000
- iSEM.SetMagnification(5000);
- Thread.Sleep(200 + Convert.ToInt32(cycle_time));
- //自动消像散
- //if (!ImageStig1())
- //{
- // MessageBox.Show("消像散失败");
- //}
- //放大到10000倍
- iSEM.SetMagnification(10000);
- Thread.Sleep(200 + Convert.ToInt32(cycle_time));
- //自动消像散
- //if (!ImageStig1())
- //{
- // MessageBox.Show("消像散失败");
- //}
- //增亮图像
- iSEM.SetAutoVideoOff();
- Thread.Sleep(200);
- float currentBright = iSEM.GetBrightness();
- Thread.Sleep(200);
- float currentContrast = iSEM.GetContrast();
- Thread.Sleep(200);
- iSEM.SetBrightness(currentBright + 1);
- Thread.Sleep(500);
- iSEM.SetContrast(currentContrast + 1);
- Thread.Sleep(500);
- iSEM.CloseReduced();
- Thread.Sleep(200);
- cycle_time = iSEM.GetCycleTime();
- Thread.Sleep(200 + Convert.ToInt32(cycle_time));
- }
- private void button12_Click(object sender, EventArgs e)
- {
- ltPoints.Items.Clear();
- List<Point> pts = new List<Point>();
- int state = 0;
- wr.EDS_Param_Points(txtPicPath.Text, 1, 0, "N-BOE", out pts, out state);
- foreach(Point pt in pts)
- {
- ltPoints.Items.Add(pt.X.ToString() + "," + pt.Y.ToString());
- }
- button12.Text = pts.Count.ToString();
- }
- private void button13_Click(object sender, EventArgs e)
- {
- ltLines.Items.Clear();
- List<Point> pts = new List<Point>();
- int state = 0;
- //wr.EDS_Param_Lines(txtPicPath.Text, 1, 0, "N-BOE", out pts, out state);
- foreach (Point pt in pts)
- {
- ltLines.Items.Add(pt.X.ToString() + "," + pt.Y.ToString());
- }
- button13.Text = pts.Count.ToString();
- }
- private void button14_Click(object sender, EventArgs e)
- {
- Point pt = new Point();
- int w = 0;
- int h = 0;
- int state = 0;
- wr.EDS_Param_Areas(txtPicPath.Text, 1, 0, "N-BOE", out pt, out w, out h, out state);
- lblEDSX.Text = pt.X.ToString();
- lblEDSY.Text = pt.Y.ToString();
- lblEDSW.Text = w.ToString();
- lblEDSH.Text = h.ToString();
- }
- private void button15_Click(object sender, EventArgs e)
- {
- iSEM.SetReduced(256, 192, Convert.ToInt32(textBox3.Text), Convert.ToInt32(textBox4.Text));
- }
- }
- }
|