Browse Source

Upate SmartSEM.cs and HardWareInterface.cs and FormUnitControl.cs

@wang_qi0307 5 years ago
parent
commit
ff2fc65205

+ 30 - 195
HOZProject/FormUnitControl.Designer.cs

@@ -29,13 +29,11 @@
         private void InitializeComponent()
         {
             this.btnGrabImage = new System.Windows.Forms.Button();
-            this.btnInit = new System.Windows.Forms.Button();
-            this.btnCloseCtrl = new System.Windows.Forms.Button();
-            this.btnSetNotify = new System.Windows.Forms.Button();
             this.btnenlargeGet = new System.Windows.Forms.Button();
             this.groupBox1 = new System.Windows.Forms.GroupBox();
             this.tabControl1 = new System.Windows.Forms.TabControl();
             this.tabPage1 = new System.Windows.Forms.TabPage();
+            this.btnDoSemDriftCorrn = new System.Windows.Forms.Button();
             this.btnGetStagePosition = new System.Windows.Forms.Button();
             this.btnStageSetM = new System.Windows.Forms.Button();
             this.txtStageM = new System.Windows.Forms.TextBox();
@@ -113,17 +111,7 @@
             this.label1 = new System.Windows.Forms.Label();
             this.tabPage2 = new System.Windows.Forms.TabPage();
             this.tabPage3 = new System.Windows.Forms.TabPage();
-            this.btnBeamShiftYSet = new System.Windows.Forms.Button();
-            this.txtBeamShiftYSet = new System.Windows.Forms.TextBox();
-            this.lblBeamShiftYGet = new System.Windows.Forms.Label();
-            this.label12 = new System.Windows.Forms.Label();
-            this.btnBeamShiftYGet = new System.Windows.Forms.Button();
-            this.btnBeamShiftXSet = new System.Windows.Forms.Button();
-            this.txtBeamShiftXSet = new System.Windows.Forms.TextBox();
-            this.lblBeamShiftXGet = new System.Windows.Forms.Label();
-            this.label16 = new System.Windows.Forms.Label();
-            this.btnBeamShiftXGet = new System.Windows.Forms.Button();
-            this.btnDoSemDriftCorrn = new System.Windows.Forms.Button();
+            this.button1 = new System.Windows.Forms.Button();
             this.groupBox1.SuspendLayout();
             this.tabControl1.SuspendLayout();
             this.tabPage1.SuspendLayout();
@@ -141,42 +129,6 @@
             this.btnGrabImage.UseVisualStyleBackColor = true;
             this.btnGrabImage.Click += new System.EventHandler(this.btnGrabImage_Click);
             // 
-            // btnInit
-            // 
-            this.btnInit.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.btnInit.Location = new System.Drawing.Point(31, 31);
-            this.btnInit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.btnInit.Name = "btnInit";
-            this.btnInit.Size = new System.Drawing.Size(144, 42);
-            this.btnInit.TabIndex = 1;
-            this.btnInit.Text = "初始化设备";
-            this.btnInit.UseVisualStyleBackColor = true;
-            this.btnInit.Click += new System.EventHandler(this.btnInit_Click);
-            // 
-            // btnCloseCtrl
-            // 
-            this.btnCloseCtrl.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.btnCloseCtrl.Location = new System.Drawing.Point(194, 31);
-            this.btnCloseCtrl.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.btnCloseCtrl.Name = "btnCloseCtrl";
-            this.btnCloseCtrl.Size = new System.Drawing.Size(144, 42);
-            this.btnCloseCtrl.TabIndex = 2;
-            this.btnCloseCtrl.Text = "关闭设备";
-            this.btnCloseCtrl.UseVisualStyleBackColor = true;
-            this.btnCloseCtrl.Click += new System.EventHandler(this.btnCloseCtrl_Click);
-            // 
-            // btnSetNotify
-            // 
-            this.btnSetNotify.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.btnSetNotify.Location = new System.Drawing.Point(356, 31);
-            this.btnSetNotify.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.btnSetNotify.Name = "btnSetNotify";
-            this.btnSetNotify.Size = new System.Drawing.Size(144, 42);
-            this.btnSetNotify.TabIndex = 3;
-            this.btnSetNotify.Text = "设置通知";
-            this.btnSetNotify.UseVisualStyleBackColor = true;
-            this.btnSetNotify.Click += new System.EventHandler(this.btnSetNotify_Click);
-            // 
             // btnenlargeGet
             // 
             this.btnenlargeGet.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
@@ -192,9 +144,6 @@
             // groupBox1
             // 
             this.groupBox1.Controls.Add(this.btnGrabImage);
-            this.groupBox1.Controls.Add(this.btnInit);
-            this.groupBox1.Controls.Add(this.btnCloseCtrl);
-            this.groupBox1.Controls.Add(this.btnSetNotify);
             this.groupBox1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.groupBox1.Location = new System.Drawing.Point(3, 1);
             this.groupBox1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
@@ -219,17 +168,8 @@
             // tabPage1
             // 
             this.tabPage1.BackColor = System.Drawing.Color.Transparent;
+            this.tabPage1.Controls.Add(this.button1);
             this.tabPage1.Controls.Add(this.btnDoSemDriftCorrn);
-            this.tabPage1.Controls.Add(this.btnBeamShiftYSet);
-            this.tabPage1.Controls.Add(this.txtBeamShiftYSet);
-            this.tabPage1.Controls.Add(this.lblBeamShiftYGet);
-            this.tabPage1.Controls.Add(this.label12);
-            this.tabPage1.Controls.Add(this.btnBeamShiftYGet);
-            this.tabPage1.Controls.Add(this.btnBeamShiftXSet);
-            this.tabPage1.Controls.Add(this.txtBeamShiftXSet);
-            this.tabPage1.Controls.Add(this.lblBeamShiftXGet);
-            this.tabPage1.Controls.Add(this.label16);
-            this.tabPage1.Controls.Add(this.btnBeamShiftXGet);
             this.tabPage1.Controls.Add(this.btnGetStagePosition);
             this.tabPage1.Controls.Add(this.btnStageSetM);
             this.tabPage1.Controls.Add(this.txtStageM);
@@ -309,15 +249,27 @@
             this.tabPage1.Font = new System.Drawing.Font("楷体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.tabPage1.Location = new System.Drawing.Point(4, 25);
             this.tabPage1.Name = "tabPage1";
-            this.tabPage1.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
+            this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
             this.tabPage1.Size = new System.Drawing.Size(1127, 438);
             this.tabPage1.TabIndex = 0;
             this.tabPage1.Text = "SEM";
             // 
+            // btnDoSemDriftCorrn
+            // 
+            this.btnDoSemDriftCorrn.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.btnDoSemDriftCorrn.Location = new System.Drawing.Point(604, 375);
+            this.btnDoSemDriftCorrn.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.btnDoSemDriftCorrn.Name = "btnDoSemDriftCorrn";
+            this.btnDoSemDriftCorrn.Size = new System.Drawing.Size(144, 42);
+            this.btnDoSemDriftCorrn.TabIndex = 92;
+            this.btnDoSemDriftCorrn.Text = "取消光束校正";
+            this.btnDoSemDriftCorrn.UseVisualStyleBackColor = true;
+            this.btnDoSemDriftCorrn.Click += new System.EventHandler(this.btnDoSemDriftCorrn_Click);
+            // 
             // btnGetStagePosition
             // 
             this.btnGetStagePosition.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.btnGetStagePosition.Location = new System.Drawing.Point(864, 375);
+            this.btnGetStagePosition.Location = new System.Drawing.Point(960, 375);
             this.btnGetStagePosition.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.btnGetStagePosition.Name = "btnGetStagePosition";
             this.btnGetStagePosition.Size = new System.Drawing.Size(144, 42);
@@ -1117,7 +1069,7 @@
             this.tabPage2.Font = new System.Drawing.Font("微软雅黑", 13.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.tabPage2.Location = new System.Drawing.Point(4, 25);
             this.tabPage2.Name = "tabPage2";
-            this.tabPage2.Padding = new System.Windows.Forms.Padding(3, 3, 3, 3);
+            this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
             this.tabPage2.Size = new System.Drawing.Size(1127, 438);
             this.tabPage2.TabIndex = 1;
             this.tabPage2.Text = "FIB";
@@ -1132,123 +1084,17 @@
             this.tabPage3.Text = "PT";
             this.tabPage3.UseVisualStyleBackColor = true;
             // 
-            // btnBeamShiftYSet
-            // 
-            this.btnBeamShiftYSet.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.btnBeamShiftYSet.Location = new System.Drawing.Point(1043, 277);
-            this.btnBeamShiftYSet.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.btnBeamShiftYSet.Name = "btnBeamShiftYSet";
-            this.btnBeamShiftYSet.Size = new System.Drawing.Size(78, 33);
-            this.btnBeamShiftYSet.TabIndex = 91;
-            this.btnBeamShiftYSet.Text = "Set";
-            this.btnBeamShiftYSet.UseVisualStyleBackColor = true;
-            this.btnBeamShiftYSet.Click += new System.EventHandler(this.btnBeamShiftYSet_Click);
-            // 
-            // txtBeamShiftYSet
-            // 
-            this.txtBeamShiftYSet.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F);
-            this.txtBeamShiftYSet.Location = new System.Drawing.Point(937, 278);
-            this.txtBeamShiftYSet.Name = "txtBeamShiftYSet";
-            this.txtBeamShiftYSet.Size = new System.Drawing.Size(100, 30);
-            this.txtBeamShiftYSet.TabIndex = 90;
-            this.txtBeamShiftYSet.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
-            // 
-            // lblBeamShiftYGet
-            // 
-            this.lblBeamShiftYGet.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
-            this.lblBeamShiftYGet.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
-            this.lblBeamShiftYGet.Location = new System.Drawing.Point(762, 277);
-            this.lblBeamShiftYGet.Name = "lblBeamShiftYGet";
-            this.lblBeamShiftYGet.Size = new System.Drawing.Size(84, 33);
-            this.lblBeamShiftYGet.TabIndex = 89;
-            this.lblBeamShiftYGet.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
-            // 
-            // label12
-            // 
-            this.label12.AutoSize = true;
-            this.label12.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label12.Location = new System.Drawing.Point(621, 283);
-            this.label12.Name = "label12";
-            this.label12.Size = new System.Drawing.Size(127, 27);
-            this.label12.TabIndex = 88;
-            this.label12.Text = "SEM移动Y轴";
-            // 
-            // btnBeamShiftYGet
-            // 
-            this.btnBeamShiftYGet.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.btnBeamShiftYGet.Location = new System.Drawing.Point(852, 277);
-            this.btnBeamShiftYGet.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.btnBeamShiftYGet.Name = "btnBeamShiftYGet";
-            this.btnBeamShiftYGet.Size = new System.Drawing.Size(78, 33);
-            this.btnBeamShiftYGet.TabIndex = 87;
-            this.btnBeamShiftYGet.Text = "Get";
-            this.btnBeamShiftYGet.UseVisualStyleBackColor = true;
-            this.btnBeamShiftYGet.Click += new System.EventHandler(this.btnBeamShiftYGet_Click);
-            // 
-            // btnBeamShiftXSet
-            // 
-            this.btnBeamShiftXSet.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.btnBeamShiftXSet.Location = new System.Drawing.Point(1043, 240);
-            this.btnBeamShiftXSet.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.btnBeamShiftXSet.Name = "btnBeamShiftXSet";
-            this.btnBeamShiftXSet.Size = new System.Drawing.Size(78, 33);
-            this.btnBeamShiftXSet.TabIndex = 86;
-            this.btnBeamShiftXSet.Text = "Set";
-            this.btnBeamShiftXSet.UseVisualStyleBackColor = true;
-            this.btnBeamShiftXSet.Click += new System.EventHandler(this.btnBeamShiftXSet_Click);
-            // 
-            // txtBeamShiftXSet
-            // 
-            this.txtBeamShiftXSet.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F);
-            this.txtBeamShiftXSet.Location = new System.Drawing.Point(937, 241);
-            this.txtBeamShiftXSet.Name = "txtBeamShiftXSet";
-            this.txtBeamShiftXSet.Size = new System.Drawing.Size(100, 30);
-            this.txtBeamShiftXSet.TabIndex = 85;
-            this.txtBeamShiftXSet.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
-            // 
-            // lblBeamShiftXGet
-            // 
-            this.lblBeamShiftXGet.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
-            this.lblBeamShiftXGet.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
-            this.lblBeamShiftXGet.Location = new System.Drawing.Point(762, 240);
-            this.lblBeamShiftXGet.Name = "lblBeamShiftXGet";
-            this.lblBeamShiftXGet.Size = new System.Drawing.Size(84, 33);
-            this.lblBeamShiftXGet.TabIndex = 84;
-            this.lblBeamShiftXGet.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
-            // 
-            // label16
-            // 
-            this.label16.AutoSize = true;
-            this.label16.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label16.Location = new System.Drawing.Point(621, 246);
-            this.label16.Name = "label16";
-            this.label16.Size = new System.Drawing.Size(148, 27);
-            this.label16.TabIndex = 83;
-            this.label16.Text = "SEM移动X轴:";
-            // 
-            // btnBeamShiftXGet
-            // 
-            this.btnBeamShiftXGet.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.btnBeamShiftXGet.Location = new System.Drawing.Point(852, 240);
-            this.btnBeamShiftXGet.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.btnBeamShiftXGet.Name = "btnBeamShiftXGet";
-            this.btnBeamShiftXGet.Size = new System.Drawing.Size(78, 33);
-            this.btnBeamShiftXGet.TabIndex = 82;
-            this.btnBeamShiftXGet.Text = "Get";
-            this.btnBeamShiftXGet.UseVisualStyleBackColor = true;
-            this.btnBeamShiftXGet.Click += new System.EventHandler(this.btnBeamShiftXGet_Click);
-            // 
-            // btnDoSemDriftCorrn
+            // button1
             // 
-            this.btnDoSemDriftCorrn.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.btnDoSemDriftCorrn.Location = new System.Drawing.Point(604, 375);
-            this.btnDoSemDriftCorrn.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
-            this.btnDoSemDriftCorrn.Name = "btnDoSemDriftCorrn";
-            this.btnDoSemDriftCorrn.Size = new System.Drawing.Size(144, 42);
-            this.btnDoSemDriftCorrn.TabIndex = 92;
-            this.btnDoSemDriftCorrn.Text = "取消光束校正";
-            this.btnDoSemDriftCorrn.UseVisualStyleBackColor = true;
-            this.btnDoSemDriftCorrn.Click += new System.EventHandler(this.btnDoSemDriftCorrn_Click);
+            this.button1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.button1.Location = new System.Drawing.Point(762, 375);
+            this.button1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(144, 42);
+            this.button1.TabIndex = 93;
+            this.button1.Text = "设置光束校正";
+            this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
             // 
             // FormUnitControl
             // 
@@ -1260,6 +1106,7 @@
             this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.Name = "FormUnitControl";
             this.Text = "UnitControl";
+            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormUnitControl_FormClosing);
             this.groupBox1.ResumeLayout(false);
             this.tabControl1.ResumeLayout(false);
             this.tabPage1.ResumeLayout(false);
@@ -1269,9 +1116,6 @@
         }
 
         #endregion
-        private System.Windows.Forms.Button btnInit;
-        private System.Windows.Forms.Button btnCloseCtrl;
-        private System.Windows.Forms.Button btnSetNotify;
         private System.Windows.Forms.Button btnGrabImage;
         private System.Windows.Forms.GroupBox groupBox1;
         private System.Windows.Forms.Button btnenlargeGet;
@@ -1354,17 +1198,8 @@
         private System.Windows.Forms.Label label21;
         private System.Windows.Forms.Button btnStageGetX;
         private System.Windows.Forms.Button btnGetStagePosition;
-        private System.Windows.Forms.Button btnBeamShiftYSet;
-        private System.Windows.Forms.TextBox txtBeamShiftYSet;
-        private System.Windows.Forms.Label lblBeamShiftYGet;
-        private System.Windows.Forms.Label label12;
-        private System.Windows.Forms.Button btnBeamShiftYGet;
-        private System.Windows.Forms.Button btnBeamShiftXSet;
-        private System.Windows.Forms.TextBox txtBeamShiftXSet;
-        private System.Windows.Forms.Label lblBeamShiftXGet;
-        private System.Windows.Forms.Label label16;
-        private System.Windows.Forms.Button btnBeamShiftXGet;
         private System.Windows.Forms.Button btnDoSemDriftCorrn;
+        private System.Windows.Forms.Button button1;
     }
 }
 

+ 44 - 232
HOZProject/FormUnitControl.cs

@@ -22,11 +22,12 @@ namespace HOZProject
     public partial class FormUnitControl : Form
     {
         //全局只有一个fatorySEM
-        FactoryHardware factorySEM = FactoryHardware.Instance; 
+        static FactoryHardware factorySEM = FactoryHardware.Instance;
+        ISEMControl iSEM = factorySEM.ISEM;
 
         #region 系统参数
         private String path = Directory.GetCurrentDirectory();
-        private SmartSEM sem = new SmartSEM();
+        //private SmartSEM sem = new SmartSEM();
         #endregion
 
         #region 构造函数
@@ -43,159 +44,11 @@ namespace HOZProject
         }
         #endregion
 
-        #region 设备初始化按键
-        private void btnInit_Click(object sender, EventArgs e)
-        {
-            if (sem.Init())
-            {
-                btnInit.BackColor = Color.Lime;
-            }
-            else
-            {
-                btnInit.BackColor = Color.Red;
-            }
-        }
-        #endregion
-
-        #region 设备关闭按键
-        private void btnCloseCtrl_Click(object sender, EventArgs e)
-        {
-            if (sem.Dispose())
-            {
-                btnInit.BackColor = Control.DefaultBackColor;
-            }
-        }
-        #endregion
-
-        #region 设置参数更新通知
-        private void btnSetNotify_Click(object sender, EventArgs e)
-        {
-            //if (m_bInitialised)
-            //{
-            //    // Magnification
-            //    if (CZEMApi.SetNotify("AP_MAG", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "AP_MAG");
-            //        return;
-            //    }
-            //    // Working distance
-            //    if (CZEMApi.SetNotify("AP_WD", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "AP_WD");
-            //        return;
-            //    }
-            //    // BRIGHTNESS 亮度
-            //    if (CZEMApi.SetNotify("AP_BRIGHTNESS", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "AP_BRIGHTNESS");
-            //        return;
-            //    }
-            //    // AP_CONTRAST,对比度
-            //    if (CZEMApi.SetNotify("AP_CONTRAST", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "AP_CONTRAST");
-            //        return;
-            //    }
-            //    // Vacuum
-            //    if (CZEMApi.SetNotify("DP_VACSTATUS", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_VACSTATUS");
-            //        return;
-            //    }
-            //    // Gun / EHT state
-            //    if (CZEMApi.SetNotify("DP_RUNUPSTATE", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_RUNUPSTATE");
-            //        return;
-            //    }
-            //    // actual KV / EHT
-            //    if (CZEMApi.SetNotify("AP_ACTUALKV", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "AP_ACTUALKV");
-            //        return;
-            //    }
-            //    // actual current
-            //    if (CZEMApi.SetNotify("AP_ACTUALCURRENT", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "AP_ACTUALCURRENT");
-            //        return;
-            //    }
-            //    // column type
-            //    if (CZEMApi.SetNotify("DP_COLUMN_TYPE", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_COLUMN_TYPE");
-            //        return;
-            //    }
-            //    // mode
-            //    if (CZEMApi.SetNotify("DP_OPERATING_MODE", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_OPERATING_MODE");
-            //        return;
-            //    }
-            //    // scan rate
-            //    if (CZEMApi.SetNotify("DP_SCANRATE", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_SCANRATE");
-            //        return;
-            //    }
-            //    // auto function active
-            //    if (CZEMApi.SetNotify("DP_AUTO_FUNCTION", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_AUTO_FUNCTION");
-            //        return;
-            //    }
-
-
-            //    // probe current
-            //    if (CZEMApi.SetNotify("AP_IPROBE", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "AP_IPROBE");
-            //        return;
-            //    }
-            //    // detector
-            //    if (CZEMApi.SetNotify("DP_DETECTOR_TYPE", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_DETECTOR_TYPE");
-            //        return;
-            //    }
-            //    // stage initialised
-            //    if (CZEMApi.SetNotify("DP_STAGE_INIT", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_STAGE_INIT");
-            //        return;
-            //    }
-            //    // stage busy?
-            //    if (CZEMApi.SetNotify("DP_STAGE_IS", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_STAGE_IS");
-            //        return;
-            //    }
-            //    // fib mode
-            //    if (CZEMApi.SetNotify("DP_FIB_MODE", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_FIB_MODE");
-            //        return;
-            //    }
-            //    // fib gun state
-            //    if (CZEMApi.SetNotify("DP_FIB_GUN_STATE", 1) != 0)
-            //    {
-            //        DisplayError("SetNotify", "DP_FIB_GUN_STATE");
-            //        return;
-            //    }
-
-            //listmsg.Items.Add("Notification enabled");
-            // }
-        }
-        #endregion
-
         #region 缩放Get
         private void btnenlargeGet_Click(object sender, EventArgs e)
-        {           
-            ISEMControl iSEM = factorySEM.ISEM;
-            iSEM.GetMagnification();
-
+        {
 
-            float ret = sem.GetMagnification();
+            float ret = iSEM.GetMagnification();
             if (float.IsNaN(ret))
             {
                 lblenlargeGet.Text = "NaN";
@@ -217,7 +70,7 @@ namespace HOZProject
             float set = 0;
             if (float.TryParse(txtenlargeSet.Text, out set))
             {
-                sem.SetMagnification(set);
+                iSEM.SetMagnification(set);
             }
 
         }
@@ -226,7 +79,7 @@ namespace HOZProject
         #region 焦距Get
         private void btnWDGet_Click(object sender, EventArgs e)
         {
-            float ret = sem.GetWorkingDistance();
+            float ret = iSEM.GetWorkingDistance();
             if (float.IsNaN(ret))
             {
                 lblWDGet.Text = "NaN";
@@ -248,7 +101,7 @@ namespace HOZProject
             float set = 0;
             if (float.TryParse(txtWDSet.Text, out set))
             {
-                sem.SetWorkingDistance(set);
+                iSEM.SetWorkingDistance(set);
             }
         }
         #endregion
@@ -256,7 +109,7 @@ namespace HOZProject
         #region 亮度Get
         private void btnBrightnessGet_Click(object sender, EventArgs e)
         {
-            float ret = sem.GetBrightness();
+            float ret = iSEM.GetBrightness();
             if (float.IsNaN(ret))
             {
                 lblBrightnessGet.Text = "NaN";
@@ -278,7 +131,7 @@ namespace HOZProject
             float set = 0;
             if (float.TryParse(txtBrightnessSet.Text, out set))
             {
-                sem.SetBrightness(set);
+                iSEM.SetBrightness(set);
             }
         }
         #endregion
@@ -286,7 +139,7 @@ namespace HOZProject
         #region 对比度Get
         private void btnContrastGet_Click(object sender, EventArgs e)
         {
-            float ret = sem.GetContrast();
+            float ret = iSEM.GetContrast();
             if (float.IsNaN(ret))
             {
                 lblContrastGet.Text = "NaN";
@@ -308,7 +161,7 @@ namespace HOZProject
             float set = 0;
             if (float.TryParse(txtContrastSet.Text, out set))
             {
-                sem.SetContrast(set);
+                iSEM.SetContrast(set);
             }
         }
         #endregion
@@ -316,7 +169,7 @@ namespace HOZProject
         #region 消像散X Get
         private void btnAstigmatismXGet_Click(object sender, EventArgs e)
         {
-            float ret = sem.GetAstigmatismX();
+            float ret = iSEM.GetAstigmatismX();
             if (float.IsNaN(ret))
             {
                 lblAstigmatismXGet.Text = "NaN";
@@ -338,7 +191,7 @@ namespace HOZProject
             float set = 0;
             if (float.TryParse(txtAstigmatismXSet.Text, out set))
             {
-                sem.SetAstigmatismX(set);
+                iSEM.SetAstigmatismX(set);
             }
         }
         #endregion
@@ -346,7 +199,7 @@ namespace HOZProject
         #region 消像散Y Get
         private void btnAstigmatismYGet_Click(object sender, EventArgs e)
         {
-            float ret = sem.GetAstigmatismY();
+            float ret = iSEM.GetAstigmatismY();
             if (float.IsNaN(ret))
             {
                 lblAstigmatismYGet.Text = "NaN";
@@ -368,7 +221,7 @@ namespace HOZProject
             float set = 0;
             if (float.TryParse(txtAstigmatismYSet.Text, out set))
             {
-                sem.SetAstigmatismY(set);
+                iSEM.SetAstigmatismY(set);
             }
         }
 
@@ -377,7 +230,7 @@ namespace HOZProject
         #region 角度补偿Get
         private void btnTiltAngleGet_Click(object sender, EventArgs e)
         {
-            float ret = sem.GetTiltAngle();
+            float ret = iSEM.GetTiltAngle();
             if (float.IsNaN(ret))
             {
                 lblTiltAngleGet.Text = "NaN";
@@ -399,7 +252,7 @@ namespace HOZProject
             float set = 0;
             if (float.TryParse(txtTiltAngleSet.Text, out set))
             {
-                sem.SetTiltAngle(set);
+                iSEM.SetTiltAngle(set);
             }
         }
         #endregion
@@ -414,7 +267,7 @@ namespace HOZProject
             if (sfd.ShowDialog() == DialogResult.OK)
             {
                 string fn = sfd.FileName;
-                sem.GrabImage(fn, 0, 0, 1024, 768, 0);
+                iSEM.GrabImage(fn, 0, 0, 1024, 768, 0);
             }
         }
         #endregion
@@ -422,7 +275,7 @@ namespace HOZProject
         #region ScanRotate Get
         private void btnScanRotationGet_Click(object sender, EventArgs e)
         {
-            float ret = sem.GetScanRotation();
+            float ret = iSEM.GetScanRotation();
             if (float.IsNaN(ret))
             {
                 lblScanRotationGet.Text = "NaN";
@@ -445,7 +298,7 @@ namespace HOZProject
             if (float.TryParse(txtScanRotationSet.Text, out set))
             {
                 
-                sem.SetScanRotation(set);
+                iSEM.SetScanRotation(set);
             }
         }
         #endregion
@@ -453,7 +306,7 @@ namespace HOZProject
         #region PixelSize Get
         private void btnPixelSizeGet_Click(object sender, EventArgs e)
         {
-            float ret = sem.GetPixelSize();
+            float ret = iSEM.GetPixelSize();
             if (float.IsNaN(ret))
             {
                 lblPixelSizeGet.Text = "NaN";
@@ -468,21 +321,21 @@ namespace HOZProject
         #region 开启电压
         private void btnOpenVoltage_Click(object sender, EventArgs e)
         {
-            sem.CmdOpenVoltage();
+            iSEM.CmdOpenVoltage();
         }
         #endregion
 
         #region 关闭电压
         private void btnCloseVoltage_Click(object sender, EventArgs e)
         {
-            sem.CmdCloseVoltage();
+            iSEM.CmdCloseVoltage();
         }
         #endregion
 
         #region 样品台位置获取
         private void btnStageGetX_Click(object sender, EventArgs e)
         {
-            float ret = sem.GetStageAtX();
+            float ret = iSEM.GetStageAtX();
             if (float.IsNaN(ret))
             {
                 lblStageX.Text = "NaN";
@@ -495,7 +348,7 @@ namespace HOZProject
 
         private void btnStageGetY_Click(object sender, EventArgs e)
         {
-            float ret = sem.GetStageAtY();
+            float ret = iSEM.GetStageAtY();
             if (float.IsNaN(ret))
             {
                 lblStageY.Text = "NaN";
@@ -508,7 +361,7 @@ namespace HOZProject
 
         private void btnStageGetZ_Click(object sender, EventArgs e)
         {
-            float ret = sem.GetStageAtZ();
+            float ret = iSEM.GetStageAtZ();
             if (float.IsNaN(ret))
             {
                 lblStageZ.Text = "NaN";
@@ -521,7 +374,7 @@ namespace HOZProject
 
         private void btnStageGetT_Click(object sender, EventArgs e)
         {
-            float ret = sem.GetStageAtT();
+            float ret = iSEM.GetStageAtT();
             if (float.IsNaN(ret))
             {
                 lblStageT.Text = "NaN";
@@ -534,7 +387,7 @@ namespace HOZProject
 
         private void btnStageGetR_Click(object sender, EventArgs e)
         {
-            float ret = sem.GetStageAtR();
+            float ret = iSEM.GetStageAtR();
             if (float.IsNaN(ret))
             {
                 lblStageR.Text = "NaN";
@@ -547,7 +400,7 @@ namespace HOZProject
 
         private void btnStageGetM_Click(object sender, EventArgs e)
         {
-            float ret = sem.GetStageAtM();
+            float ret = iSEM.GetStageAtM();
             if (float.IsNaN(ret))
             {
                 lblStageM.Text = "NaN";
@@ -565,7 +418,7 @@ namespace HOZProject
             float set = 0;
             if (float.TryParse(txtStageX.Text, out set))
             {
-                sem.SetStageGotoX(set);
+                iSEM.SetStageGotoX(set);
             }
         }
 
@@ -574,7 +427,7 @@ namespace HOZProject
             float set = 0;
             if (float.TryParse(txtStageY.Text, out set))
             {
-                sem.SetStageGotoY(set);
+                iSEM.SetStageGotoY(set);
             }
         }
 
@@ -583,7 +436,7 @@ namespace HOZProject
             float set = 0;
             if (float.TryParse(txtStageZ.Text, out set))
             {
-                sem.SetStageGotoZ(set);
+                iSEM.SetStageGotoZ(set);
             }
         }
 
@@ -592,7 +445,7 @@ namespace HOZProject
             float set = 0;
             if (float.TryParse(txtStageT.Text, out set))
             {
-                sem.SetStageGotoT(set);
+                iSEM.SetStageGotoT(set);
             }
         }
 
@@ -601,7 +454,7 @@ namespace HOZProject
             float set = 0;
             if (float.TryParse(txtStageR.Text, out set))
             {
-                sem.SetStageGotoR(set);
+                iSEM.SetStageGotoR(set);
             }
         }
 
@@ -610,7 +463,7 @@ namespace HOZProject
             float set = 0;
             if (float.TryParse(txtStageM.Text, out set))
             {
-                sem.SetStageGotoM(set);
+                iSEM.SetStageGotoM(set);
             }
         }
         #endregion
@@ -618,7 +471,7 @@ namespace HOZProject
         #region 获取样品台位置数组
         private void btnGetStagePosition_Click(object sender, EventArgs e)
         {
-            float[] pt = sem.GetStagePosition();
+            float[] pt = iSEM.GetStagePosition();
             if (!float.IsNaN(pt[0]))
             {
                 lblStageX.Text = pt[0].ToString();
@@ -646,63 +499,22 @@ namespace HOZProject
         }
         #endregion
 
-        #region 获取光束BEAM坐标
-        private void btnBeamShiftXGet_Click(object sender, EventArgs e)
-        {
-            float ret = sem.GetBeamShiftX();
-            if (float.IsNaN(ret))
-            {
-                lblBeamShiftXGet.Text = "NaN";
-                txtBeamShiftXSet.Enabled = false;
-                btnBeamShiftXSet.Enabled = false;
-            }
-            else
-            {
-                lblBeamShiftXGet.Text = ret.ToString();
-                txtBeamShiftXSet.Text = ret.ToString();
-                btnBeamShiftXSet.Enabled = true;
-            }
-        }
-
-        private void btnBeamShiftXSet_Click(object sender, EventArgs e)
+        private void btnDoSemDriftCorrn_Click(object sender, EventArgs e)
         {
-            float set = 0;
-            if (float.TryParse(txtBeamShiftXSet.Text, out set))
-            {
-                sem.SetBeamShiftX(set);
-            }
+            iSEM.SetTiltCorrectionOff();
         }
 
-        private void btnBeamShiftYGet_Click(object sender, EventArgs e)
+        private void button1_Click(object sender, EventArgs e)
         {
-            float ret = sem.GetBeamShiftY();
-            if (float.IsNaN(ret))
-            {
-                lblBeamShiftYGet.Text = "NaN";
-                txtBeamShiftYSet.Enabled = false;
-                btnBeamShiftYSet.Enabled = false;
-            }
-            else
-            {
-                lblBeamShiftYGet.Text = ret.ToString();
-                txtBeamShiftYSet.Text = ret.ToString();
-                btnBeamShiftYSet.Enabled = true;
-            }
+            iSEM.SetTiltCorrectionOn();
         }
 
-        private void btnBeamShiftYSet_Click(object sender, EventArgs e)
+        private void FormUnitControl_FormClosing(object sender, FormClosingEventArgs e)
         {
-            float set = 0;
-            if (float.TryParse(txtBeamShiftYSet.Text, out set))
+            if(iSEM!=null)
             {
-                sem.SetBeamShiftY(set);
+                iSEM.Dispose();
             }
         }
-        #endregion
-
-        private void btnDoSemDriftCorrn_Click(object sender, EventArgs e)
-        {
-            //sem.CmdDoSemDriftCorrn();
-        }
     }
 }

+ 29 - 9
SmartSEMControl/HardwareInterface.cs

@@ -9,8 +9,6 @@ namespace SmartSEMControl
     //sealed, 避免继承出新类造成重构
     public sealed class FactoryHardware
     {
-
-
         //只读的静态成员
         private static readonly FactoryHardware instance = new FactoryHardware();
 
@@ -20,7 +18,8 @@ namespace SmartSEMControl
         //在整个应用程序域中只会被执行一次。
         static FactoryHardware()
         {
-        }        private FactoryHardware()
+        }
+        private FactoryHardware()
         {
         }
 
@@ -61,23 +60,39 @@ namespace SmartSEMControl
         float GetContrast();
         Boolean SetContrast(float set);
 
+        //自动亮度
+        float GetAutoVideo();
+        Boolean SetAutoVideoOff();
+        Boolean SetAutoVideoBrightness();
+        Boolean SetAutoVideoContrast();
+        Boolean SetAutoVideoBrightnessAndContrast();
+
         //消像散
         float GetAstigmatismX();
         float GetAstigmatismY();
         Boolean SetAstigmatismX(float set);
         Boolean SetAstigmatismY(float set);
 
+        //自动消像散
+        Boolean CmdAutoStig();
+
         //角度补偿
         float GetTiltAngle();
         Boolean SetTiltAngle(float set);
 
-        //BeamSHift移动
-        float GetBeamShiftX();
-        float GetBeamShiftY();
-        Boolean SetBeamShiftX(float set);
-        Boolean SetBeamShiftY(float set);
+        //抓图
+        Boolean GrabImage(String filename, short xoff, short yoff, short width, short height, short type);
+        //解冻
+        Boolean ImageFrozen();
+        //冻结
+        Boolean ImageLive();
+        //获取分辨率
+        int[] GetImageStore();
+        //设置分辨率
+        Boolean SetImageStore(float set);
 
         //样品台
+        float[] GetStagePosition();
         float GetStageAtX();
         float GetStageAtY();
         float GetStageAtZ();
@@ -90,6 +105,7 @@ namespace SmartSEMControl
         Boolean SetStageGotoT(float set);
         Boolean SetStageGotoR(float set);
         Boolean SetStageGotoM(float set);
+        Boolean MoveStageXY(float x, float y);
 
         //Scan Rotate角度接口
         float GetScanRotation();
@@ -100,7 +116,8 @@ namespace SmartSEMControl
 
         //电子束校正设置
         float GetTiltCorrection();
-        Boolean SetTiltCorrection(float set);
+        Boolean SetTiltCorrectionOff();
+        Boolean SetTiltCorrectionOn();
 
         //开启电压
         Boolean CmdOpenVoltage();
@@ -108,6 +125,9 @@ namespace SmartSEMControl
         //关闭电压
         Boolean CmdCloseVoltage();
 
+        //图像类型切换
+        Boolean DetectorType(float set);
+
         //清除控件
         Boolean Dispose();
 

+ 30 - 7
SmartSEMControl/SmartSEM.cs

@@ -430,9 +430,24 @@ namespace SmartSEMControl
         /// </summary>
         /// <param name="set">0:off;1:B(亮度);2:C(对比度);3:BC</param>
         /// <returns>true or false</returns>
-        public Boolean SetAutoVideo(float set)
+        public Boolean SetAutoVideoOff()
         {
-            return WriteDataParams(DP_AUTO_VIDEO, set);
+            return WriteDataParams(DP_AUTO_VIDEO, (float)0);
+        }
+
+        public Boolean SetAutoVideoBrightness()
+        {
+            return WriteDataParams(DP_AUTO_VIDEO, (float)1);
+        }
+
+        public Boolean SetAutoVideoContrast()
+        {
+            return WriteDataParams(DP_AUTO_VIDEO, (float)2);
+        }
+
+        public Boolean SetAutoVideoBrightnessAndContrast()
+        {
+            return WriteDataParams(DP_AUTO_VIDEO, (float)3);
         }
         #endregion
 
@@ -676,7 +691,7 @@ namespace SmartSEMControl
                 }
                 else
                 {
-                    Frozen(1);
+                    ImageFrozen();
                     return true;
                 }
             }
@@ -688,9 +703,13 @@ namespace SmartSEMControl
         #endregion
 
         #region 图像解冻
-        public Boolean Frozen(float set)
+        public Boolean ImageFrozen()
+        {
+            return WriteDataParams(DP_FROZEN, (float)1); 
+        }
+        public Boolean ImageLive()
         {
-            return WriteDataParams(DP_FROZEN, set); 
+            return WriteDataParams(DP_FROZEN, (float)0);
         }
         #endregion
 
@@ -1041,9 +1060,13 @@ namespace SmartSEMControl
         /// </summary>
         /// <param name="set"></param>
         /// <returns></returns>
-        public Boolean SetTiltCorrection(float set)
+        public Boolean SetTiltCorrectionOff()
+        {
+            return WriteDataParams(DP_TILT_CORRECTION, (float)0);
+        }
+        public Boolean SetTiltCorrectionOn()
         {
-            return WriteDataParams(DP_TILT_CORRECTION, set);
+            return WriteDataParams(DP_TILT_CORRECTION, (float)1);
         }
         #endregion