|
@@ -463,6 +463,9 @@ namespace MeasureThread
|
|
|
public Boolean key_stop = false;
|
|
|
|
|
|
String focus_path = "";
|
|
|
+ String FIBfocus_path = "";
|
|
|
+ String StigX_path = "";
|
|
|
+ String StigY_path = "";
|
|
|
String data_path = "";
|
|
|
|
|
|
int m_nWorkHoleNo = -1;
|
|
@@ -628,8 +631,29 @@ namespace MeasureThread
|
|
|
{
|
|
|
Directory.CreateDirectory(focus_path);
|
|
|
}
|
|
|
+ //FIB对焦数据存放目录
|
|
|
+ FIBfocus_path = WorkingFolder + "\\" + m_cutHoles[i].HoleName + "\\FIBFocus";
|
|
|
+ m_MsParam.FIBFocus.Path = FIBfocus_path;
|
|
|
+ if (!Directory.Exists(focus_path))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(focus_path);
|
|
|
+ }
|
|
|
+ //StigX数据存放目录
|
|
|
+ StigX_path = WorkingFolder + "\\" + m_cutHoles[i].HoleName + "\\StigX";
|
|
|
+ m_MsParam.AutoStigX.Path = StigX_path;
|
|
|
+ if (!Directory.Exists(focus_path))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(focus_path);
|
|
|
+ }
|
|
|
+ //StigY数据存放目录
|
|
|
+ StigY_path = WorkingFolder + "\\" + m_cutHoles[i].HoleName + "\\StigY";
|
|
|
+ m_MsParam.AutoStigY.Path = StigY_path;
|
|
|
+ if (!Directory.Exists(focus_path))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(focus_path);
|
|
|
+ }
|
|
|
//判断孔状态
|
|
|
- if(m_cutHoles[i].STATE != State.Ready)
|
|
|
+ if (m_cutHoles[i].STATE != State.Ready)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
@@ -955,6 +979,203 @@ namespace MeasureThread
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ //执行自动消像散
|
|
|
+ public bool ImageStig(String step_code)
|
|
|
+ {
|
|
|
+ if (m_measureFile.MParam.FocusMode == 1)//手动
|
|
|
+ {
|
|
|
+ if (DialogResult.Yes == MessageBox.Show("图像自动消像散已完成?", "确认消息", MessageBoxButtons.YesNo))
|
|
|
+ {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (m_measureFile.MParam.FocusMode == 2)//自有自动
|
|
|
+ {
|
|
|
+ //郝工增加自动对焦算法
|
|
|
+ //处理文件夹
|
|
|
+ if (Directory.Exists(StigX_path))
|
|
|
+ {
|
|
|
+ Directory.Delete(StigX_path, true);
|
|
|
+ }
|
|
|
+ Thread.Sleep(3000);
|
|
|
+ arg.Picture_Information.Work_Voltage = iSEM.GetSEMVoltage();
|
|
|
+ Thread.Sleep(1000);
|
|
|
+ arg.Picture_Information.Magnification = iSEM.GetMagnification();
|
|
|
+ Thread.Sleep(1000);
|
|
|
+
|
|
|
+ //再创建文件夹
|
|
|
+ Directory.CreateDirectory(StigX_path);
|
|
|
+
|
|
|
+ //1、对焦参数类,2、输出像散值
|
|
|
+ int stigX = 0;
|
|
|
+
|
|
|
+ //根据当前的stigX重新计算像散值
|
|
|
+ float currentStigX = iSEM.GetAstigmatismX();
|
|
|
+ m_MsParam.AutoStigX.Step = 10; //像散的步长为10
|
|
|
+ m_MsParam.AutoStigX.UP = currentStigX - m_MsParam.AutoStigX.Step;
|
|
|
+ m_MsParam.AutoStigX.Down = currentStigX + m_MsParam.AutoStigX.Step;
|
|
|
+
|
|
|
+ LogManager.AddHardwareLog("修改消像散参数", true);
|
|
|
+ AutoStig(m_MsParam.AutoStigX, out stigX, step_code);
|
|
|
+
|
|
|
+ //LogManager.AddHardwareLog("算法输出"+ wd.ToString(), true);
|
|
|
+ //设置工作距离
|
|
|
+ iSEM.SetAstigmatismX((float)(stigX * 0.01));
|
|
|
+ //设置完工作距离后必须延迟5秒
|
|
|
+ Thread.Sleep(5000);
|
|
|
+ //处理图片位置
|
|
|
+ //File.Copy(focus_path + "\\fine\\" + wd.ToString() + ".tif", data_path + "\\" + ImageName);
|
|
|
+
|
|
|
+ //处理文件夹
|
|
|
+ if (Directory.Exists(StigY_path))
|
|
|
+ {
|
|
|
+ Directory.Delete(StigY_path, true);
|
|
|
+ }
|
|
|
+ Thread.Sleep(3000);
|
|
|
+ arg.Picture_Information.Work_Voltage = iSEM.GetSEMVoltage();
|
|
|
+ Thread.Sleep(1000);
|
|
|
+ arg.Picture_Information.Magnification = iSEM.GetMagnification();
|
|
|
+ Thread.Sleep(1000);
|
|
|
+
|
|
|
+ //再创建文件夹
|
|
|
+ Directory.CreateDirectory(StigY_path);
|
|
|
+
|
|
|
+ //1、对焦参数类,2、输出像散值
|
|
|
+ int stigY = 0;
|
|
|
+
|
|
|
+ //根据当前的stigX重新计算像散值
|
|
|
+ float currentStigY = iSEM.GetAstigmatismY();
|
|
|
+ m_MsParam.AutoStigY.Step = 10; //像散的步长为10
|
|
|
+ m_MsParam.AutoStigY.UP = currentStigY - m_MsParam.AutoStigY.Step;
|
|
|
+ m_MsParam.AutoStigY.Down = currentStigY + m_MsParam.AutoStigY.Step;
|
|
|
+
|
|
|
+ LogManager.AddHardwareLog("修改消像散参数", true);
|
|
|
+ AutoStig(m_MsParam.AutoStigY, out stigY, step_code);
|
|
|
+
|
|
|
+ //LogManager.AddHardwareLog("算法输出"+ wd.ToString(), true);
|
|
|
+ //设置工作距离
|
|
|
+ iSEM.SetAstigmatismY((float)(stigY * 0.01));
|
|
|
+ //设置完工作距离后必须延迟5秒
|
|
|
+ Thread.Sleep(5000);
|
|
|
+ }
|
|
|
+ else if (m_MsParam.FocusMode == 3) //客户自动
|
|
|
+ {
|
|
|
+ //后期和客户对接接口
|
|
|
+ List<string> filenames = new List<string>();
|
|
|
+ String retfilename = wr.Img_Auto_Focus(filenames);
|
|
|
+ }
|
|
|
+ else //蔡司自动对焦
|
|
|
+ {
|
|
|
+ iSEM.CmdAutoFocusCoarse();
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ Thread.Sleep(10000);
|
|
|
+
|
|
|
+ if (0 == iSEM.GetAutoFunction())
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ iSEM.CmdAutoFocusFine();
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ Thread.Sleep(10000);
|
|
|
+
|
|
|
+ if (0 == iSEM.GetAutoFunction())
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //执行FIB自动对焦,FIBFocus
|
|
|
+ //执行自动消像散
|
|
|
+ public bool FIBFocus(String step_code)
|
|
|
+ {
|
|
|
+ if (m_measureFile.MParam.FocusMode == 1)//手动
|
|
|
+ {
|
|
|
+ if (DialogResult.Yes == MessageBox.Show("FIB图像对焦已完成?", "确认消息", MessageBoxButtons.YesNo))
|
|
|
+ {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (m_measureFile.MParam.FocusMode == 2)//自有自动
|
|
|
+ {
|
|
|
+ //郝工增加自动对焦算法
|
|
|
+ //处理文件夹
|
|
|
+ if (Directory.Exists(FIBfocus_path))
|
|
|
+ {
|
|
|
+ Directory.Delete(FIBfocus_path, true);
|
|
|
+ }
|
|
|
+ Thread.Sleep(3000);
|
|
|
+ arg.Picture_Information.Work_Voltage = iSEM.GetSEMVoltage();
|
|
|
+ Thread.Sleep(1000);
|
|
|
+ arg.Picture_Information.Magnification = iSEM.GetMagnification();
|
|
|
+ Thread.Sleep(1000);
|
|
|
+
|
|
|
+ //再创建文件夹
|
|
|
+ Directory.CreateDirectory(FIBfocus_path);
|
|
|
+
|
|
|
+ //1、对焦参数类,2、输出对焦值
|
|
|
+ int FIBFocus = 0;
|
|
|
+
|
|
|
+ //根据当前的stigX重新计算像散值
|
|
|
+ float currentFIBFocus = iSEM.GetFIBObjectivePotential();
|
|
|
+ m_MsParam.FIBFocus.Step = 10; //像散的步长为10
|
|
|
+ m_MsParam.FIBFocus.UP = currentFIBFocus - m_MsParam.FIBFocus.Step;
|
|
|
+ m_MsParam.FIBFocus.Down = currentFIBFocus + m_MsParam.FIBFocus.Step;
|
|
|
+
|
|
|
+ LogManager.AddHardwareLog("修改FIB自动对焦参数", true);
|
|
|
+ AutoFIBFocus(m_MsParam.FIBFocus, out FIBFocus, step_code);
|
|
|
+
|
|
|
+ //LogManager.AddHardwareLog("算法输出"+ wd.ToString(), true);
|
|
|
+ //设置工作距离
|
|
|
+ iSEM.SetFIBObjectivePotential((float)(FIBFocus * 0.01));
|
|
|
+ //设置完工作距离后必须延迟5秒
|
|
|
+ Thread.Sleep(5000);
|
|
|
+ //处理图片位置
|
|
|
+ //File.Copy(focus_path + "\\fine\\" + wd.ToString() + ".tif", data_path + "\\" + ImageName);
|
|
|
+ }
|
|
|
+ else if (m_MsParam.FocusMode == 3) //客户自动
|
|
|
+ {
|
|
|
+ //后期和客户对接接口
|
|
|
+ List<string> filenames = new List<string>();
|
|
|
+ String retfilename = wr.Img_Auto_Focus(filenames);
|
|
|
+ }
|
|
|
+ else //蔡司自动对焦
|
|
|
+ {
|
|
|
+ iSEM.CmdAutoFocusCoarse();
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ Thread.Sleep(10000);
|
|
|
+
|
|
|
+ if (0 == iSEM.GetAutoFunction())
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ iSEM.CmdAutoFocusFine();
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ Thread.Sleep(10000);
|
|
|
+
|
|
|
+ if (0 == iSEM.GetAutoFunction())
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
/// <summary>
|
|
|
///13. 自动 定位功能,沉积
|
|
|
/// </summary>
|
|
@@ -1009,6 +1230,24 @@ namespace MeasureThread
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ //1.1大于10000倍进行消像散处理
|
|
|
+ float dMag = iSEM.GetMagnification();
|
|
|
+ if (dMag > 10000)//需要消像散
|
|
|
+ {
|
|
|
+ if (!ImageStig("1-3"))
|
|
|
+ {
|
|
|
+ LogManager.AddHardwareLog("拉直操作消像散失败,程序退出。", true);
|
|
|
+ arg.Message = "拉直操作自动消像散失败!";
|
|
|
+ arg.State = false;
|
|
|
+ SendMsg("1-3");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ arg.Message = "拉直操作自动消像散成功!";
|
|
|
+ arg.State = true;
|
|
|
+ SendMsg("1-3");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//3.控制SEM拍照,找到切割位置
|
|
|
String fileName1 = data_path + "\\" + m_cutHoles[m_nWorkHoleNo].HoleName + "_" + m_MsParam.Location_Magnification.ToString("0") + "_" + ImageName1;
|
|
|
arg.Picture_Information.Picture_FullPath = fileName1;
|
|
@@ -1060,8 +1299,7 @@ namespace MeasureThread
|
|
|
if (key_stop)
|
|
|
{
|
|
|
return false;
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
//8.控制FIB拍照
|
|
|
//9.保存照片======更改路径
|
|
|
String fileName2 = data_path + "\\" + m_cutHoles[m_nWorkHoleNo].HoleName + "_" + m_MsParam.FIB_Magnification.ToString("0") + "_" + ImageName2;
|
|
@@ -1091,6 +1329,28 @@ namespace MeasureThread
|
|
|
cycle_time = iSEM.GetCycleTime();
|
|
|
Thread.Sleep(Convert.ToInt32(cycle_time) + 1000);
|
|
|
|
|
|
+ //增加FIB对焦
|
|
|
+ //2.控制SEM自动对焦、亮度、对比度
|
|
|
+ if (FIBFocus("1-8"))
|
|
|
+ {
|
|
|
+ arg.Message = "自动FIB对焦完成";
|
|
|
+ arg.State = true;
|
|
|
+ SendMsg("1-8");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LogManager.AddHardwareLog("设置观测点后,自动FIB对焦失败。", true);
|
|
|
+ arg.Message = "自动FIB对焦失败";
|
|
|
+ arg.State = false;
|
|
|
+ SendMsg("1-8");
|
|
|
+ }
|
|
|
+ //判断是否停止进程
|
|
|
+ if (key_stop)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if (!GetImage(ImageMode.FIB, fileName2))
|
|
|
{
|
|
|
arg.Message = "FIB拍照失败";
|
|
@@ -1292,6 +1552,27 @@ namespace MeasureThread
|
|
|
}
|
|
|
Thread.Sleep(Convert.ToInt32(cycle_time)+1000);
|
|
|
|
|
|
+ //增加FIB对焦
|
|
|
+ if (FIBFocus("1-8"))
|
|
|
+ {
|
|
|
+ arg.Message = "FIB自动对焦完成";
|
|
|
+ arg.State = true;
|
|
|
+ SendMsg("1-8");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LogManager.AddHardwareLog("设置观测点后,自动对焦失败。", true);
|
|
|
+ arg.Message = "自动对焦失败";
|
|
|
+ arg.State = false;
|
|
|
+ SendMsg("1-8");
|
|
|
+ }
|
|
|
+ //判断是否停止进程
|
|
|
+ if (key_stop)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
String fileName31 = data_path + "\\" + m_cutHoles[m_nWorkHoleNo].HoleName + "_" + m_MsParam.FIB_Magnification.ToString() + "_" + ImageName31;
|
|
|
arg.Picture_Information.Picture_FullPath = fileName31;
|
|
|
arg.Picture_Information.Work_Status = "FIB";
|
|
@@ -1653,6 +1934,23 @@ namespace MeasureThread
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ //1.1大于10000倍进行消像散处理
|
|
|
+ float dMag = iSEM.GetMagnification();
|
|
|
+ if (dMag > 10000)//需要消像散
|
|
|
+ {
|
|
|
+ if (!ImageStig("1-3"))
|
|
|
+ {
|
|
|
+ LogManager.AddHardwareLog("拉直操作消像散失败,程序退出。", true);
|
|
|
+ arg.Message = "拉直操作自动消像散失败!";
|
|
|
+ arg.State = false;
|
|
|
+ SendMsg("1-3");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ arg.Message = "拉直操作自动消像散成功!";
|
|
|
+ arg.State = true;
|
|
|
+ SendMsg("1-3");
|
|
|
+ }
|
|
|
+
|
|
|
//3、设置SEM补偿角度
|
|
|
if (m_MsParam.Is_Photograph == false)
|
|
|
{
|
|
@@ -1759,24 +2057,41 @@ namespace MeasureThread
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- ////11、自动对焦。与之前操作相同
|
|
|
- //if (ImageFocus("1-28"))
|
|
|
- //{
|
|
|
- // arg.Message = "自动对焦完成";
|
|
|
- // arg.State = true;
|
|
|
- // SendMsg("1-28");
|
|
|
- //}
|
|
|
- //else
|
|
|
- //{
|
|
|
- // arg.Message = "自动对焦失败";
|
|
|
- // arg.State = false;
|
|
|
- // SendMsg("1-28");
|
|
|
- //}
|
|
|
- ////判断是否停止进程
|
|
|
- //if (key_stop)
|
|
|
- //{
|
|
|
- // return false;
|
|
|
- //}
|
|
|
+ //11、自动对焦。与之前操作相同
|
|
|
+ if (ImageFocus("1-28"))
|
|
|
+ {
|
|
|
+ arg.Message = "自动对焦完成";
|
|
|
+ arg.State = true;
|
|
|
+ SendMsg("1-28");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ arg.Message = "自动对焦失败";
|
|
|
+ arg.State = false;
|
|
|
+ SendMsg("1-28");
|
|
|
+ }
|
|
|
+ //判断是否停止进程
|
|
|
+ if (key_stop)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ //1.1大于10000倍进行消像散处理
|
|
|
+ dMag = iSEM.GetMagnification();
|
|
|
+ if (dMag > 10000)//需要消像散
|
|
|
+ {
|
|
|
+ if (!ImageStig("1-3"))
|
|
|
+ {
|
|
|
+ LogManager.AddHardwareLog("拉直操作消像散失败,程序退出。", true);
|
|
|
+ arg.Message = "拉直操作自动消像散失败!";
|
|
|
+ arg.State = false;
|
|
|
+ SendMsg("1-3");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ arg.Message = "拉直操作自动消像散成功!";
|
|
|
+ arg.State = true;
|
|
|
+ SendMsg("1-3");
|
|
|
+ }
|
|
|
|
|
|
//12拍照
|
|
|
String fileName6 = data_path + "\\" + m_cutHoles[m_nWorkHoleNo].HoleName + "_" + m_MsParam.Photograph_Magnification.ToString("0") + "_" + ImageName6;
|
|
@@ -2454,17 +2769,40 @@ namespace MeasureThread
|
|
|
arg.State = true;
|
|
|
SendMsg("1-3");
|
|
|
|
|
|
- //2、拍张照片
|
|
|
- String fileName0 = data_path + "\\" + m_cutHoles[m_nWorkHoleNo].HoleName + "_" + m_MsParam.Stretch_Magnification.ToString("0") + "_" + ImageName0;
|
|
|
- //拍照前改变速度,延时
|
|
|
- iSEM.CmdSaveRate();
|
|
|
- cycle_time = iSEM.GetCycleTime();
|
|
|
- Thread.Sleep(Convert.ToInt32(cycle_time) + 1000);
|
|
|
- if (!GetImage(ImageMode.SEM, fileName0))
|
|
|
+ //判断是否停止进程
|
|
|
+ if (key_stop)
|
|
|
{
|
|
|
- arg.Message = "拉直拍照成功";
|
|
|
- arg.State = false;
|
|
|
- SendMsg("1-4");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ //1.1大于10000倍进行消像散处理
|
|
|
+ float dMag = iSEM.GetMagnification();
|
|
|
+ if (dMag > 10000)//需要消像散
|
|
|
+ {
|
|
|
+ if (!ImageStig("1-3"))
|
|
|
+ {
|
|
|
+ LogManager.AddHardwareLog("拉直操作消像散失败,程序退出。", true);
|
|
|
+ arg.Message = "拉直操作自动消像散失败!";
|
|
|
+ arg.State = false;
|
|
|
+ SendMsg("1-3");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ arg.Message = "拉直操作自动消像散成功!";
|
|
|
+ arg.State = true;
|
|
|
+ SendMsg("1-3");
|
|
|
+ }
|
|
|
+
|
|
|
+ //2、拍张照片
|
|
|
+ String fileName0 = data_path + "\\" + m_cutHoles[m_nWorkHoleNo].HoleName + "_" + m_MsParam.Stretch_Magnification.ToString("0") + "_" + ImageName0;
|
|
|
+ //拍照前改变速度,延时
|
|
|
+ iSEM.CmdSaveRate();
|
|
|
+ cycle_time = iSEM.GetCycleTime();
|
|
|
+ Thread.Sleep(Convert.ToInt32(cycle_time) + 1000);
|
|
|
+ if (!GetImage(ImageMode.SEM, fileName0))
|
|
|
+ {
|
|
|
+ arg.Message = "拉直拍照成功";
|
|
|
+ arg.State = false;
|
|
|
+ SendMsg("1-4");
|
|
|
return false;
|
|
|
}
|
|
|
arg.Message = "拉直拍照成功!";
|
|
@@ -2720,6 +3058,343 @@ namespace MeasureThread
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //自动消像散 AutoStig
|
|
|
+ public bool AutoStig(FocusParam a_param, out int a_nWd, String step_code)
|
|
|
+ {
|
|
|
+ a_nWd = 0;
|
|
|
+ float wd = 0;
|
|
|
+ if (a_param.TYPE == 2)
|
|
|
+ {
|
|
|
+ wd = iSEM.GetAstigmatismX();
|
|
|
+ }
|
|
|
+ else if (a_param.TYPE == 3)
|
|
|
+ {
|
|
|
+ wd = iSEM.GetAstigmatismY();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LogManager.AddHardwareLog("自动消像散参数设置有误", true);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ a_nWd = (int)Math.Ceiling(wd * 100 + 0.5);//获取当前的工作距离
|
|
|
+
|
|
|
+ if (a_param == null)
|
|
|
+ {
|
|
|
+ LogManager.AddHardwareLog("空参数", true);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ string path = a_param.Path;
|
|
|
+ if (!Directory.Exists(path))
|
|
|
+ {
|
|
|
+ LogManager.AddHardwareLog("文件夹丢失", true);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ string path_coarse = a_param.Path + "\\Coarse";
|
|
|
+ if (!Directory.Exists(path_coarse))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(path_coarse);
|
|
|
+ }
|
|
|
+ string path_fine = a_param.Path + "\\Fine";
|
|
|
+ if (!Directory.Exists(path_fine))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(path_fine);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //1. 拍照
|
|
|
+ //1.1, 粗拍照
|
|
|
+ //1.1.1, 根据参数计算拍照次数
|
|
|
+ double nUp = a_param.UP * 100.0;
|
|
|
+ double nDown = a_param.Down * 100.0;
|
|
|
+ double nStep = a_param.Step * 100.0;
|
|
|
+ double nTimes = Math.Ceiling((nDown - nUp) / nStep + 0.5);
|
|
|
+ LogManager.AddHardwareLog("初调拍照次数=" + nTimes.ToString(), true);
|
|
|
+ //SendMsg("粗对焦:最小值" + nUp.ToString() + ",最大值" + nDown.ToString() + ",步长" + nStep.ToString() + "拍照张数" + nTimes.ToString());
|
|
|
+
|
|
|
+ //粗拍照
|
|
|
+ for (int i = 0; i < nTimes; i++)
|
|
|
+ {
|
|
|
+
|
|
|
+ int cWd = (int)Math.Ceiling(nUp + i * nStep + 0.5);
|
|
|
+
|
|
|
+ if (a_param.TYPE == 2)
|
|
|
+ {
|
|
|
+ iSEM.SetAstigmatismX((float)(cWd * 0.01));
|
|
|
+ }
|
|
|
+ else if (a_param.TYPE == 3)
|
|
|
+ {
|
|
|
+ iSEM.SetAstigmatismY((float)(cWd * 0.01));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LogManager.AddHardwareLog("自动消像散参数设置有误", true);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ //arg.Picture_Information.Work_Distance = (float)(cWd * 0.00000001);
|
|
|
+ Thread.Sleep(Convert.ToInt32(cycle_time) + 1000);
|
|
|
+
|
|
|
+ int swd = cWd / 100;
|
|
|
+ //SendMsg("wd = " + swd.ToString() +"um");
|
|
|
+
|
|
|
+ String fileName = path_coarse + "\\" + cWd.ToString() + ".tif";
|
|
|
+ arg.Picture_Information.Picture_FullPath = fileName;
|
|
|
+ if (!GetImage(ImageMode.SEM, fileName))
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ arg.State = true;
|
|
|
+ arg.Message = "自动对焦";
|
|
|
+ SendMsg(step_code);
|
|
|
+
|
|
|
+ //判断是否停止进程
|
|
|
+ if (key_stop)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //Thread.Sleep(3000);
|
|
|
+ }
|
|
|
+
|
|
|
+ //1.2, 选定细拍照的工作距离
|
|
|
+ int CorWd;
|
|
|
+ ChooseBest(path_coarse, out CorWd);
|
|
|
+
|
|
|
+ a_nWd = CorWd;
|
|
|
+
|
|
|
+ //SendMsg("粗选工作距离wd = " + a_nWd.ToString() );
|
|
|
+
|
|
|
+
|
|
|
+ //1.3, 细拍照
|
|
|
+ if ((CorWd - a_param.Range * 100.0) <= -10000)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ double nfUp = CorWd - a_param.Range * 100.0;
|
|
|
+ double nfStep = a_param.fStep * 100.0;
|
|
|
+ double nfTimes = Math.Ceiling((a_param.Range * 100.0 * 2) / nfStep + 0.5);
|
|
|
+
|
|
|
+
|
|
|
+ //SendMsg("粗对焦:最小值" + nfUp.ToString() + ",步长" + nfStep.ToString() + "拍照张数" + nfTimes.ToString());
|
|
|
+
|
|
|
+
|
|
|
+ for (int i = 0; i < nfTimes; i++)
|
|
|
+ {
|
|
|
+ int cWd = (int)Math.Ceiling(nfUp + i * nfStep + 0.5);
|
|
|
+ if (a_param.TYPE == 2)
|
|
|
+ {
|
|
|
+ iSEM.SetAstigmatismX((float)(cWd * 0.01));
|
|
|
+ }
|
|
|
+ else if (a_param.TYPE == 3)
|
|
|
+ {
|
|
|
+ iSEM.SetAstigmatismY((float)(cWd * 0.01));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LogManager.AddHardwareLog("自动消像散参数设置有误", true);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //arg.Picture_Information.Work_Distance = (float)(cWd * 0.00000001);
|
|
|
+ Thread.Sleep(Convert.ToInt32(cycle_time) + 1000);
|
|
|
+
|
|
|
+ int swd = cWd / 100;
|
|
|
+ //SendMsg("wd = " + swd.ToString() + "um");
|
|
|
+
|
|
|
+ String fileName = path_fine + "\\" + cWd.ToString() + ".tif";
|
|
|
+ arg.Picture_Information.Picture_FullPath = fileName;
|
|
|
+ if (!GetImage(ImageMode.SEM, fileName))
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ arg.State = true;
|
|
|
+ arg.Message = "自动对焦";
|
|
|
+ SendMsg(step_code);
|
|
|
+
|
|
|
+ //判断是否停止进程
|
|
|
+ if (key_stop)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //Thread.Sleep(2000);
|
|
|
+ }
|
|
|
+
|
|
|
+ int fineWd;
|
|
|
+ ChooseBest(path_fine, out fineWd);
|
|
|
+
|
|
|
+ //SendMsg("wd fine max = " + fineWd.ToString());
|
|
|
+
|
|
|
+ a_nWd = fineWd;
|
|
|
+
|
|
|
+ //SendMsg("细选工作距离wd = " + a_nWd.ToString());
|
|
|
+
|
|
|
+ return true;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //自动FIB对焦 AutoFIBFocus
|
|
|
+ public bool AutoFIBFocus(FocusParam a_param, out int a_nWd, String step_code)
|
|
|
+ {
|
|
|
+ a_nWd = 0;
|
|
|
+ float wd = 0;
|
|
|
+ if (a_param.TYPE == 4)
|
|
|
+ {
|
|
|
+ wd = iSEM.GetFIBObjectivePotential();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LogManager.AddHardwareLog("FIB自动聚焦参数设置有误", true);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ a_nWd = (int)Math.Ceiling(wd * 100 + 0.5);//获取当前的工作距离
|
|
|
+
|
|
|
+ if (a_param == null)
|
|
|
+ {
|
|
|
+ LogManager.AddHardwareLog("空参数", true);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ string path = a_param.Path;
|
|
|
+ if (!Directory.Exists(path))
|
|
|
+ {
|
|
|
+ LogManager.AddHardwareLog("文件夹丢失", true);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ string path_coarse = a_param.Path + "\\Coarse";
|
|
|
+ if (!Directory.Exists(path_coarse))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(path_coarse);
|
|
|
+ }
|
|
|
+ string path_fine = a_param.Path + "\\Fine";
|
|
|
+ if (!Directory.Exists(path_fine))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(path_fine);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //1. 拍照
|
|
|
+ //1.1, 粗拍照
|
|
|
+ //1.1.1, 根据参数计算拍照次数
|
|
|
+ double nUp = a_param.UP * 100.0;
|
|
|
+ double nDown = a_param.Down * 100.0;
|
|
|
+ double nStep = a_param.Step * 100.0;
|
|
|
+ double nTimes = Math.Ceiling((nDown - nUp) / nStep + 0.5);
|
|
|
+ LogManager.AddHardwareLog("初调拍照次数=" + nTimes.ToString(), true);
|
|
|
+ //SendMsg("粗对焦:最小值" + nUp.ToString() + ",最大值" + nDown.ToString() + ",步长" + nStep.ToString() + "拍照张数" + nTimes.ToString());
|
|
|
+
|
|
|
+ //粗拍照
|
|
|
+ for (int i = 0; i < nTimes; i++)
|
|
|
+ {
|
|
|
+
|
|
|
+ int cWd = (int)Math.Ceiling(nUp + i * nStep + 0.5);
|
|
|
+
|
|
|
+ if (a_param.TYPE == 4)
|
|
|
+ {
|
|
|
+ iSEM.SetFIBObjectivePotential((float)(cWd * 0.01));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LogManager.AddHardwareLog("自动消像散参数设置有误", true);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ //arg.Picture_Information.Work_Distance = (float)(cWd * 0.00000001);
|
|
|
+ Thread.Sleep(Convert.ToInt32(cycle_time) + 1000);
|
|
|
+
|
|
|
+ int swd = cWd / 100;
|
|
|
+ //SendMsg("wd = " + swd.ToString() +"um");
|
|
|
+
|
|
|
+ String fileName = path_coarse + "\\" + cWd.ToString() + ".tif";
|
|
|
+ arg.Picture_Information.Picture_FullPath = fileName;
|
|
|
+ if (!GetImage(ImageMode.SEM, fileName))
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ arg.State = true;
|
|
|
+ arg.Message = "自动对焦";
|
|
|
+ SendMsg(step_code);
|
|
|
+
|
|
|
+ //判断是否停止进程
|
|
|
+ if (key_stop)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //Thread.Sleep(3000);
|
|
|
+ }
|
|
|
+
|
|
|
+ //1.2, 选定细拍照的工作距离
|
|
|
+ int CorWd;
|
|
|
+ ChooseBest(path_coarse, out CorWd);
|
|
|
+
|
|
|
+ a_nWd = CorWd;
|
|
|
+
|
|
|
+ //SendMsg("粗选工作距离wd = " + a_nWd.ToString() );
|
|
|
+
|
|
|
+
|
|
|
+ //1.3, 细拍照
|
|
|
+ if ((CorWd - a_param.Range * 100.0) <0)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ double nfUp = CorWd - a_param.Range * 100.0;
|
|
|
+ double nfStep = a_param.fStep * 100.0;
|
|
|
+ double nfTimes = Math.Ceiling((a_param.Range * 100.0 * 2) / nfStep + 0.5);
|
|
|
+
|
|
|
+
|
|
|
+ //SendMsg("粗对焦:最小值" + nfUp.ToString() + ",步长" + nfStep.ToString() + "拍照张数" + nfTimes.ToString());
|
|
|
+
|
|
|
+
|
|
|
+ for (int i = 0; i < nfTimes; i++)
|
|
|
+ {
|
|
|
+ int cWd = (int)Math.Ceiling(nfUp + i * nfStep + 0.5);
|
|
|
+ if (a_param.TYPE == 4)
|
|
|
+ {
|
|
|
+ iSEM.SetFIBObjectivePotential((float)(cWd * 0.01));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LogManager.AddHardwareLog("自动消像散参数设置有误", true);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //arg.Picture_Information.Work_Distance = (float)(cWd * 0.00000001);
|
|
|
+ Thread.Sleep(Convert.ToInt32(cycle_time) + 1000);
|
|
|
+
|
|
|
+ int swd = cWd / 100;
|
|
|
+ //SendMsg("wd = " + swd.ToString() + "um");
|
|
|
+
|
|
|
+ String fileName = path_fine + "\\" + cWd.ToString() + ".tif";
|
|
|
+ arg.Picture_Information.Picture_FullPath = fileName;
|
|
|
+ if (!GetImage(ImageMode.SEM, fileName))
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ arg.State = true;
|
|
|
+ arg.Message = "自动对焦";
|
|
|
+ SendMsg(step_code);
|
|
|
+
|
|
|
+ //判断是否停止进程
|
|
|
+ if (key_stop)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //Thread.Sleep(2000);
|
|
|
+ }
|
|
|
+
|
|
|
+ int fineWd;
|
|
|
+ ChooseBest(path_fine, out fineWd);
|
|
|
+
|
|
|
+ //SendMsg("wd fine max = " + fineWd.ToString());
|
|
|
+
|
|
|
+ a_nWd = fineWd;
|
|
|
+
|
|
|
+ //SendMsg("细选工作距离wd = " + a_nWd.ToString());
|
|
|
+
|
|
|
+ return true;
|
|
|
+
|
|
|
+ }
|
|
|
//LoG算子计算
|
|
|
private double LoGMean(string a_strImgPath)
|
|
|
{
|