Pārlūkot izejas kodu

do some modify.

gsp 4 gadi atpakaļ
vecāks
revīzija
5623e49347

+ 39 - 0
MeasureThread/ArgSend.cs

@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace MeasureThread
+{
+    class ArgSend
+    {
+        private Measure m_measure;
+        private SmartSEMControl.ISEMControl m_sem;
+        ThreadStatusEventArgs mArg ;
+        public ArgSend(Measure ms,SmartSEMControl.ISEMControl sem)
+        {
+            m_measure = ms;
+            m_sem = sem;
+            mArg = ms.GetArgs();
+        }
+        public void SendArgumentToScreen(string stepCode,string msg,string filepath="")
+        {
+            mArg.Picture_Information.Picture_FullPath = filepath;
+            mArg.Picture_Information.Work_Status = "SEM";
+            mArg.Picture_Information.Work_Voltage = m_sem.GetSEMVoltage();
+            Thread.Sleep(200);
+            mArg.Picture_Information.Magnification = m_sem.GetMagnification();
+            Thread.Sleep(200);
+            mArg.Picture_Information.Work_Distance = m_sem.GetWorkingDistance();
+            Thread.Sleep(200);
+            mArg.State = true;
+            //mArg.Step_Code = stepCode;
+            //mArg.Time = DateTime.Now;
+            m_measure.SendMsg(stepCode);
+           
+        }
+
+    }
+}

+ 17 - 13
MeasureThread/Focus.cs

@@ -15,13 +15,22 @@ namespace MeasureThread
         private ISEMControl iSEM;
       private  NLog.Logger log;
 
-        public Focus(Focusparam prm, ISEMControl iSEM)
+        public Focus( ISEMControl iSEM)
         {
             log = NLog.LogManager.GetCurrentClassLogger();
-            this.prm = prm ?? throw new ArgumentNullException(nameof(prm));
+           
             this.iSEM = iSEM ?? throw new ArgumentNullException(nameof(iSEM));
             this.log = log ?? throw new ArgumentNullException(nameof(log));
         }
+        public Focusparam GetParam()
+        {
+            if (prm == null)
+            {
+
+                prm = new Focusparam();
+            }
+            return prm;
+        }
         public bool DoFocusByNewMagnification(float newMag)
         {
 
@@ -50,7 +59,7 @@ namespace MeasureThread
                 iSEM.SetContrast(prm.contrast);//30.0f
                 Thread.Sleep(200);
             }
-            if (!ImageFocus1(true))
+            if (!ImageFocus1(false))
             {
                 log.Error("自动对焦失败,程序退出。", false);
 
@@ -79,13 +88,7 @@ namespace MeasureThread
             Thread.Sleep(500);
             // set magnification
             bool mRetMag=iSEM.SetMagnification(prm.mag);
-            //float current = iSEM.GetMagnification();
-            //while (Math.Abs(current - prm.mag) > 1)
-            //{
-            //    iSEM.SetMagnification(prm.mag);
-            //    Thread.Sleep(200);
-            //    current = iSEM.GetMagnification();
-            //}
+            
             Thread.Sleep(500);
             // 
             if (!TiltCorrection(prm.tiltCorrAngle))
@@ -95,7 +98,7 @@ namespace MeasureThread
              float wd = iSEM.GetWorkingDistance();
 
            float offsetWd = Math.Abs(prm.workingDis - wd*1000);
-            if (offsetWd > 0.5)//如果相差0.5mm以上,则重新设置,否则不动
+            if (offsetWd > 3)//如果相差3mm以上,则重新设置,否则不动
             {
                 if (!iSEM.SetWorkingDistance(prm.workingDis / 1000))
                 {
@@ -123,7 +126,7 @@ namespace MeasureThread
                 iSEM.SetContrast(prm.contrast);//30.0f
                 Thread.Sleep(200);
             }
-            if (!ImageFocus1(true))
+            if (!ImageFocus1(prm.ifStig))
             {
                 log.Error("自动对焦失败,程序退出。", false);
                 
@@ -143,7 +146,8 @@ namespace MeasureThread
 
         public void setFocusParam(Focusparam param)
         {
-            prm = param;
+            this.prm = param ;
+           
         }
         //角度补偿
         public bool TiltCorrection(float a_fAngle)

+ 1 - 0
MeasureThread/IFocus.cs

@@ -29,5 +29,6 @@ namespace MeasureThread
         public int delayTime;//ms
         public string ScanSpeed;
         public float tiltCorrAngle;
+        public bool ifStig=false;
     }
 }

+ 8 - 2
MeasureThread/ILocate.cs

@@ -8,8 +8,14 @@ namespace MeasureThread
 {
     interface ILocate
     {
-        bool DoLocateByMoveStage();
-        bool DoLocateByShiftBeam();
+        LocateParam GetParam();
+        bool MoveRAxis(float value);
+        bool MoveToPix(float x, float y, float pixelSize_Y_cur);
+        bool MoveToPixByMoveStage(float x, float y);
+        bool MoveZAxis(float value, Locate.ZAxisDirection d);
+        bool MoveZAxisByAbs(float value);
+        void RecordCurrentBeamShiftAndStagePosition();
+        void RestoreLastBeamShiftAndStagePosition();
     }
     public class LocateParam
    {

+ 68 - 24
MeasureThread/Locate.cs

@@ -32,14 +32,14 @@ namespace MeasureThread
            
             this.iSEM = iSEM ?? throw new ArgumentNullException(nameof(iSEM));
         }
-        public Locate( LocateParam prm, ISEMControl iSEM)
-        {
-            this.log = NLog.LogManager.GetCurrentClassLogger();
+        //public Locate( LocateParam prm, ISEMControl iSEM)
+        //{
+        //    this.log = NLog.LogManager.GetCurrentClassLogger();
            
-            this.log = log ?? throw new ArgumentNullException(nameof(log));
-            this.prm = prm ?? throw new ArgumentNullException(nameof(prm));
-            this.iSEM = iSEM ?? throw new ArgumentNullException(nameof(iSEM));
-        }
+        //    this.log = log ?? throw new ArgumentNullException(nameof(log));
+        //    this.prm = prm ?? throw new ArgumentNullException(nameof(prm));
+        //    this.iSEM = iSEM ?? throw new ArgumentNullException(nameof(iSEM));
+        //}
         public void RecordCurrentBeamShiftAndStagePosition()
         {
             #region 记录初始设置的BeamShift的百分比和样品台XY位置
@@ -95,15 +95,6 @@ namespace MeasureThread
             float cycle_time = iSEM.GetCycleTime();
             Thread.Sleep(100 + Convert.ToInt32(cycle_time));
 
-            //set = MParam.Photograph_Magnification;
-            //current = iSEM.GetMagnification();
-            //while (Math.Abs(current - set) > 1)
-            //{
-            //    iSEM.SetMagnification(set);
-            //    Thread.Sleep(200);
-            //    current = iSEM.GetMagnification();
-            //}
-
 
             //恢复BeamShift的百分比值
             iSEM.SetBeamShiftX(pr.xs);
@@ -147,7 +138,7 @@ namespace MeasureThread
 
             while (true)
             {
-                Thread.Sleep(500);
+                Thread.Sleep(2000);
                 if (iSEM.GetStageIs() == 0)
                 {
                     break;
@@ -155,6 +146,24 @@ namespace MeasureThread
             }
             return true;
         }
+        public bool MoveRAxis(float value)
+        {
+            if (!iSEM.SetStageGotoR(value))
+            {
+                
+                return false;
+            }
+            while (true)
+            {
+                Thread.Sleep(4000);
+                if (iSEM.GetStageIs() == 0)
+                {
+                    break;
+                }
+            }
+            return true;
+
+        }
 
         public bool MoveZAxisByAbs(float value)
         {
@@ -185,8 +194,10 @@ namespace MeasureThread
         }
 
         //移动到像素位置,这里要靠移动样品台实现,当位移量小于3um时,不予移动
-        bool MoveToPixByMoveStage(float xc, float yc)
+     private   bool MoveToPixByMoveStage()
         {
+            float xc = prm.PositionX;
+            float yc = prm.PositionY;
             //单位是m/pix
             float XpixSize = iSEM.GetPixelSize();
             log.Info("X像素尺寸=" + XpixSize.ToString() + "m/pixel", true);
@@ -259,9 +270,10 @@ namespace MeasureThread
             return true;
         }
         //移动到像素位置
-        bool MoveToPix(float xc, float yc)
+      private  bool MoveToPix()
         {
-
+            float xc = prm.PositionX;
+            float yc = prm.PositionY;
             //单位是m/pix
             float XpixSize = iSEM.GetPixelSize();
 
@@ -396,14 +408,46 @@ namespace MeasureThread
             return true;
         }
 
-        public bool DoLocateByMoveStage()
+        public bool MoveToPixByMoveStage(float x, float y)
         {
-           return MoveToPixByMoveStage(prm.PositionX, prm.PositionY);
+            if (prm == null)
+            {
+                prm = new LocateParam();
+            }
+            this.prm.PositionX = x;
+            this.prm.PositionY = y;
+            //this.prm.PixelSize_Y_cur = pixelSize_Y_cur;
+             MoveToPixByMoveStage();
+            Thread.Sleep(1000);
+            iSEM.SetAutoVideoBrightnessAndContrast();
+            Thread.Sleep(3000);
+            return true;
+
         }
 
-        public bool DoLocateByShiftBeam()
+        public bool MoveToPix(float x,float y,float pixelSize_Y_cur)
         {
-            return MoveToPix(prm.PositionX, prm.PositionY);
+            if (prm == null)
+            {
+                prm = new LocateParam();
+            }
+            this.prm.PositionX = x;
+            this.prm.PositionY = y;
+            this.prm.PixelSize_Y_cur = pixelSize_Y_cur;
+             MoveToPix();
+            Thread.Sleep(1000);
+            iSEM.SetAutoVideoBrightnessAndContrast();
+            Thread.Sleep(3000);
+            return true;
+        }
+        public LocateParam GetParam()
+        {
+            if (prm == null)
+            {
+
+                prm = new LocateParam();
+            }
+            return prm;
         }
     }
 }

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 225 - 577
MeasureThread/Measure.cs


+ 1 - 0
MeasureThread/MeasureThread.csproj

@@ -73,6 +73,7 @@
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="ArgSend.cs" />
     <Compile Include="ILocate.cs" />
     <Compile Include="Locate.cs" />
     <Compile Include="Photo.cs" />

+ 24 - 14
MeasureThread/Photo.cs

@@ -14,31 +14,41 @@ namespace MeasureThread
         NLog.Logger log;
         private PhotoParam prm;
         private ISEMControl iSEM;
-        public Photo( PhotoParam prm,ISEMControl sem)
+        public Photo( ISEMControl sem)
         {
             this.log = NLog.LogManager.GetCurrentClassLogger();
-            this.prm = prm ?? throw new ArgumentNullException(nameof(prm));
+           
             this.iSEM = sem ?? throw new ArgumentNullException(nameof(sem));
         }
+        public void SetPhotoParam(PhotoParam a_prm)
+        {
+            this.prm = a_prm ?? throw new ArgumentNullException(nameof(a_prm));
+        }
+        public PhotoParam GetParam()
+        {
+            if (prm == null)
+            {
 
+                prm = new PhotoParam();
+            }
+            return prm;
+        }
         public bool TakePhoto()
         {
+            
+
             if (!iSEM.SetMagnification(prm.Mag))
             {
                 return false;
             }
-            //float current = iSEM.GetMagnification();
-            //while (Math.Abs(current - prm.mag) > 1)
-            //{
-            //    iSEM.SetMagnification(prm.mag);
-            //    Thread.Sleep(200);
-            //    current = iSEM.GetMagnification();
-            //}
-            Thread.Sleep(500);
 
-
-
-            iSEM.CmdFocusScanSpeed(prm.scanSpeed);//iSEM.CmdSaveRate();
+            Thread.Sleep(500);
+            //iSEM.SetReduced(402, 384, 200, 200);
+            iSEM.CmdFocusScanSpeed("CMD_SCANRATE4");
+            iSEM.SetAutoVideoBrightnessAndContrast();
+            Thread.Sleep(3000);
+            //iSEM.CloseReduced();
+            iSEM.CmdFocusScanSpeed("CMD_SCANRATE4");//iSEM.CmdSaveRate();
           
             //add by sun 2020 - 12 - 15 增加不同样品扫描速度参数,每大类样品3种扫描速度 end
             Thread.Sleep(200);
@@ -53,7 +63,7 @@ namespace MeasureThread
                 log.Error("SEM拍照失败", false);
                 return false;
             }
-            iSEM.CmdFocusScanSpeed(prm.scanSpeedAfter);//CmdFocusRate(4);
+            iSEM.CmdFocusScanSpeed("CMD_SCANRATE4");//CmdFocusRate(4);
             cycle_time = iSEM.GetCycleTime();
             Thread.Sleep(Convert.ToInt32(cycle_time) + 1000);
            

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels