@wang_qi0307 5 лет назад
Родитель
Сommit
3d4a709d49
3 измененных файлов с 152 добавлено и 13 удалено
  1. 2 2
      HOZProject/FormUnitControl.cs
  2. 1 3
      SmartSEMControl/HardwareInterface.cs
  3. 149 8
      SmartSEMControl/SmartSEM.cs

+ 2 - 2
HOZProject/FormUnitControl.cs

@@ -186,7 +186,7 @@ namespace HOZProject
 
         #region 缩放Get
         private void btnenlargeGet_Click(object sender, EventArgs e)
-        {
+        {           
             float ret = sem.GetMagnification();
             if (float.IsNaN(ret))
             {
@@ -406,7 +406,7 @@ namespace HOZProject
             if (sfd.ShowDialog() == DialogResult.OK)
             {
                 string fn = sfd.FileName;
-                sem.GrabImage(fn, 0);
+                sem.GrabImage(fn, 0, 0, 1024, 768, 0);
             }
         }
         #endregion

+ 1 - 3
SmartSEMControl/HardwareInterface.cs

@@ -7,10 +7,8 @@ using System.Threading.Tasks;
 namespace SmartSEMControl
 {
     //SEM控制
-    interface SEMControl
+    public interface SEMControl
     {
-
-
         //缩放
         float GetMagnification();
         Boolean SetMagnification(float set);

+ 149 - 8
SmartSEMControl/SmartSEM.cs

@@ -21,6 +21,10 @@ namespace SmartSEMControl
         private String AP_BRIGHTNESS = "AP_BRIGHTNESS";
         //对比度
         private String AP_CONTRAST = "AP_CONTRAST";
+        //亮度目标
+        private String AP_AUTO_BRIGHT = "AP_AUTO_BRIGHT";
+        //对比度目标
+        private String AP_AUTO_CONTRAST = "AP_AUTO_CONTRAST";
         //消像散X轴
         private String AP_STIG_X = "AP_STIG_X";
         //消像散Y轴
@@ -66,6 +70,12 @@ namespace SmartSEMControl
         private String DP_SCAN_ROT = "DP_SCAN_ROT";
         //取消电子束校正
         private String DP_TILT_CORRECTION = "DP_TILT_CORRECTION";
+        //自动亮度对比度
+        private String DP_AUTO_VIDEO = "DP_AUTO_VIDEO";
+        //图像解冻
+        private String DP_FROZEN = "DP_FROZEN";
+        //图像类型切换
+        private String DP_DETECTOR_TYPE = "DP_DETECTOR_TYPE";
         #endregion
 
         #region 命令
@@ -73,6 +83,12 @@ namespace SmartSEMControl
         private String CMD_BEAM_ON = "CMD_BEAM_ON";
         //关闭电压
         private String CMD_EHT_OFF = "CMD_EHT_OFF";
+        //自动对焦1
+        private String CMD_AUTO_FOCUS_COARSE = "CMD_AUTO_FOCUS_COARSE";
+        //自动对焦2
+        private String CMD_AUTO_FOCUS_FINE = "CMD_AUTO_FOCUS_FINE";
+        //自动消像散
+        private String CMD_AUTO_STIG = "CMD_AUTO_STIG";
         #endregion
 
         #region APILib
@@ -389,6 +405,93 @@ namespace SmartSEMControl
         }
         #endregion
 
+        #region 自动亮度对比度
+        /// <summary>
+        /// 读取自动亮度对比度状态
+        /// </summary>
+        /// <returns>true:float or false:NaN</returns>
+        public float GetAutoVideo()
+        {
+            float ret = 0;
+            if (ReadParams(DP_AUTO_VIDEO, ref ret))
+            {
+                return ret;
+            }
+            else
+            {
+                return float.NaN;
+            }
+        }
+
+        /// <summary>
+        /// 设置自动亮度对比度状态
+        /// </summary>
+        /// <param name="set">0:off;1:B(亮度);2:C(对比度);3:BC</param>
+        /// <returns>true or false</returns>
+        public Boolean SetAutoVideo(float set)
+        {
+            return WriteDataParams(DP_AUTO_VIDEO, set);
+        }
+        #endregion
+
+        #region 亮度目标
+        /// <summary>
+        /// 读取亮度目标
+        /// </summary>
+        /// <returns>true:float or false:NaN</returns>
+        public float GetAutoBright()
+        {
+            float ret = 0;
+            if (ReadParams(AP_AUTO_BRIGHT, ref ret))
+            {
+                return ret;
+            }
+            else
+            {
+                return float.NaN;
+            }
+        }
+
+        /// <summary>
+        /// 设置亮度目标
+        /// </summary>
+        /// <param name="set">亮度</param>
+        /// <returns>true or false</returns>
+        public Boolean SetAutoBright(float set)
+        {
+            return WriteParams(AP_AUTO_BRIGHT, set);
+        }
+        #endregion
+
+        #region 对比度目标
+        /// <summary>
+        /// 读取对比度目标
+        /// </summary>
+        /// <returns>true:float or false:NaN</returns>
+        public float GetAutoContrast()
+        {
+            float ret = 0;
+            if (ReadParams(AP_AUTO_CONTRAST, ref ret))
+            {
+                return ret;
+            }
+            else
+            {
+                return float.NaN;
+            }
+        }
+
+        /// <summary>
+        /// 设置对比度目标
+        /// </summary>
+        /// <param name="set">对比度目标</param>
+        /// <returns>true or false</returns>
+        public Boolean SetAutoContrast(float set)
+        {
+            return WriteParams(AP_AUTO_CONTRAST, set);
+        }
+        #endregion
+
         #region 消像散
         /// <summary>
         /// 读取消像散X
@@ -470,7 +573,11 @@ namespace SmartSEMControl
         /// <returns>true or false</returns>
         public Boolean SetTiltAngle(float set)
         {
-            return WriteParams(AP_TILT_ANGLE, set);
+            Boolean ret = false;
+            ret = WriteDataParams(DP_TILT_CORRECTION, 1);
+            ret = WriteParams(AP_TILT_ANGLE, set);
+            ret = WriteDataParams(DP_TILT_CORRECTION, 0);
+            return ret;
         }
         #endregion
 
@@ -479,11 +586,11 @@ namespace SmartSEMControl
         /// 抓取图像
         /// </summary>
         /// <returns>true:float or false:NaN</returns>
-        public Boolean GrabImage(String filename, short type)
+        public Boolean GrabImage(String filename, short xoff,short yoff, short width,short height,short type)
         {
             if (m_bInitialised)
             {
-                lrt = CZEMApi.Grab(0, 0, 1024, 768, type, filename);
+                lrt = CZEMApi.Grab(xoff, yoff, width, height, type, filename);
                 if (lrt != 0)
                 {
                     return false;
@@ -500,9 +607,23 @@ namespace SmartSEMControl
         }
         #endregion
 
-        #region SEM移动接口
+        #region 图像解冻
+        public Boolean Frozen(float set)
+        {
+            return WriteDataParams(DP_FROZEN, set); 
+        }
+        #endregion
+
+        #region 图像类型切换
+        public Boolean DetectorType(float set)
+        {
+            return WriteDataParams(DP_DETECTOR_TYPE, set);
+        }
+        #endregion
+
+        #region 电子束移动接口
         /// <summary>
-        /// 获取SEM移动接口X
+        /// 获取电子束移动接口X
         /// </summary>
         /// <returns>true:float or false:NaN</returns>
         public float GetBeamShiftX()
@@ -519,7 +640,7 @@ namespace SmartSEMControl
         }
 
         /// <summary>
-        /// 获取SEM移动接口Y
+        /// 获取电子束移动接口Y
         /// </summary>
         /// <returns>true:float or false:NaN</returns>
         public float GetBeamShiftY()
@@ -536,7 +657,7 @@ namespace SmartSEMControl
         }
 
         /// <summary>
-        /// 设置SEM移动接口X
+        /// 设置电子束移动接口X
         /// </summary>
         /// <param name="set">X坐标</param>
         /// <returns>true or false</returns>
@@ -546,7 +667,7 @@ namespace SmartSEMControl
         }
 
         /// <summary>
-        /// 设置SEM移动接口Y
+        /// 设置电子束移动接口Y
         /// </summary>
         /// <param name="set">X坐标</param>
         /// <returns>true or false</returns>
@@ -850,5 +971,25 @@ namespace SmartSEMControl
         }
         #endregion
 
+        #region 自动对焦1
+        public Boolean CmdAutoFocusCoarse()
+        {
+            return ExecuteCmd(CMD_AUTO_FOCUS_COARSE);
+        }
+        #endregion
+
+        #region 自动对焦2
+        public Boolean CmdAutoFocusFine()
+        {
+            return ExecuteCmd(CMD_AUTO_FOCUS_FINE);
+        }
+        #endregion
+
+        #region 自动消像散
+        public Boolean CmdAutoStig()
+        {
+            return ExecuteCmd(CMD_AUTO_STIG);
+        }
+        #endregion
     }
 }