diff --git a/Project.FLY.FlyADBase/FlyADBase/FlyADClientAdv.cs b/Project.FLY.FlyADBase/FlyADBase/FlyADClientAdv.cs
index c0d03b174fb9ebc7275a32b42619c1dac0d7a5cf..8ead06cc021580417e883695614b6f60a48a2f3e 100644
--- a/Project.FLY.FlyADBase/FlyADBase/FlyADClientAdv.cs
+++ b/Project.FLY.FlyADBase/FlyADBase/FlyADClientAdv.cs
@@ -73,7 +73,7 @@ namespace FlyADBase
                 () =>
                 {
                     //速度是错了,需要自己计算
-                    double scale = 1000 / sw_calSpeed.ElapsedMilliseconds;
+                    double scale = 1000.0 / sw_calSpeed.ElapsedMilliseconds;
                     sw_calSpeed.Restart();
 
 
diff --git a/Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgFlyAd.xaml b/Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgFlyAd.xaml
index 08f1ecac69f0c95273f55b4aecde3f4411f42469..e0144d810f6ebd753f0e4b83c772244307ff35a3 100644
--- a/Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgFlyAd.xaml
+++ b/Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgFlyAd.xaml
@@ -137,7 +137,7 @@
 
                         </StackPanel>
                         <StackPanel Orientation="Horizontal">
-                            <Button Content="运行至" Command="{Binding RuntoCmd}" />
+                            <Button Content="运行至" Command="{Binding RunToCmd}" />
                             <StackPanel Margin="{StaticResource ControlMargin}">
                                 <TextBlock Style="{StaticResource TextBlockStyle_FieldHeaderEditable}" Text="目标位置" />
                                 <StackPanel Orientation="Horizontal">
diff --git a/Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgGetSample.xaml.cs b/Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgGetSample.xaml.cs
index 3bf85c7ab800121ad2e549ce13db8835d9b67b0d..b5f16acb5cdf5d35e62da81bbf3e694fa77b9a8e 100644
--- a/Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgGetSample.xaml.cs
+++ b/Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgGetSample.xaml.cs
@@ -238,7 +238,6 @@ namespace FLY.Thick.Base.UI
 
 
             this.getSampleService.Enable = this.Enable;
-            this.getSampleService.Interval = this.Interval;
             this.getSampleService.Range = this.Range;
             this.getSampleService.Velocity = this.Velocity;
             this.getSampleService.Window = this.Window;
@@ -301,7 +300,6 @@ namespace FLY.Thick.Base.UI
 
 
             Enable = true;
-            Interval = 20;
             Samples[0].Enable = true;
 
             Features[0].Enable = true;
@@ -315,10 +313,6 @@ namespace FLY.Thick.Base.UI
         /// </summary>
         public bool Enable { get; set; }
 
-        /// <summary>
-        /// 参数:间隔
-        /// </summary>
-        public int Interval { get; set; }
 
         /// <summary>
         /// 参数:速度
diff --git a/Project.FLY.Thick.Base/FLY.Thick.Base/Client/GetSampleServiceClient.cs b/Project.FLY.Thick.Base/FLY.Thick.Base/Client/GetSampleServiceClient.cs
index 7e5d1afd96f8d4476f9e2283e6aebcb85adc668a..d0464ad89ab31bc360abfc5b3960b85503de6873 100644
--- a/Project.FLY.Thick.Base/FLY.Thick.Base/Client/GetSampleServiceClient.cs
+++ b/Project.FLY.Thick.Base/FLY.Thick.Base/Client/GetSampleServiceClient.cs
@@ -27,18 +27,6 @@ namespace FLY.Thick.Base.Client
         [JsonProperty]
         public bool Enable { get; set; }
 
-        /// <summary>
-        /// 参数:间隔
-        /// </summary>
-        [JsonProperty]
-        public int Interval { get; set; }
-
-        /// <summary>
-        /// 采样计数
-        /// </summary>
-        [JsonProperty]
-        public int Timer { get; set; }
-
         /// <summary>
         /// 参数:速度
         /// </summary>
@@ -107,7 +95,6 @@ namespace FLY.Thick.Base.Client
             GETSAMPLE_OBJ_INTERFACE.Pack_Params p = new GETSAMPLE_OBJ_INTERFACE.Pack_Params
             {
                 enable = Enable,
-                interval = Interval,
                 velocity = Velocity,
                 range = Range,
                 window = Window,
@@ -189,7 +176,6 @@ namespace FLY.Thick.Base.Client
 
 
                         Enable = p.enable;
-                        Interval = p.interval;
                         Range = p.range;
                         Velocity = p.velocity;
                         Window = p.window;
diff --git a/Project.FLY.Thick.Base/FLY.Thick.Base/IService/IGetSampleService.cs b/Project.FLY.Thick.Base/FLY.Thick.Base/IService/IGetSampleService.cs
index 638bfff64f18451efadd3154e48ea23da6f62045..2429d745388318b3dcb15f792f8264dbf785638d 100644
--- a/Project.FLY.Thick.Base/FLY.Thick.Base/IService/IGetSampleService.cs
+++ b/Project.FLY.Thick.Base/FLY.Thick.Base/IService/IGetSampleService.cs
@@ -20,10 +20,7 @@ namespace FLY.Thick.Base.IService
         /// </summary>
         bool Enable { get; set; }
 
-        /// <summary>
-        /// 参数:间隔
-        /// </summary>
-        int Interval { get; set; }
+
         
         /// <summary>
         /// 参数:速度
diff --git a/Project.FLY.Thick.Base/FLY.Thick.Base/OBJ_INTERFACE/GETSAMPLE_OBJ_INTERFACE.cs b/Project.FLY.Thick.Base/FLY.Thick.Base/OBJ_INTERFACE/GETSAMPLE_OBJ_INTERFACE.cs
index 82eef85915db9587c86611526a9ff0cea7228e19..77095532e6c11cf0626ff5503dc7848cb5e1e165 100644
--- a/Project.FLY.Thick.Base/FLY.Thick.Base/OBJ_INTERFACE/GETSAMPLE_OBJ_INTERFACE.cs
+++ b/Project.FLY.Thick.Base/FLY.Thick.Base/OBJ_INTERFACE/GETSAMPLE_OBJ_INTERFACE.cs
@@ -27,7 +27,6 @@ namespace FLY.Thick.Base.OBJ_INTERFACE
         public class Pack_Params
         {
             public bool enable;
-            public int interval;
             public UInt32 velocity;
             public int range;
             public int window;
diff --git a/Project.FLY.Thick.Base/FLY.Thick.Base/Server.OBJProxy/FlyAD_OBJProxy.cs b/Project.FLY.Thick.Base/FLY.Thick.Base/Server.OBJProxy/FlyAD_OBJProxy.cs
index 0acf09e4032460ad10ab56395112f9d487d96e5b..19c6a886a12cd0de88a8abaa7aebd6b2ca594737 100644
--- a/Project.FLY.Thick.Base/FLY.Thick.Base/Server.OBJProxy/FlyAD_OBJProxy.cs
+++ b/Project.FLY.Thick.Base/FLY.Thick.Base/Server.OBJProxy/FlyAD_OBJProxy.cs
@@ -30,20 +30,12 @@ namespace FLY.Thick.Base.Server.OBJProxy
             this.AD2Thick = AD2Thick;
             mFlyAD.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(mFlyAD_PropertyChanged);
         }
-
+        static string[] propertyname_params = new string[] {
+            "LocalEP","HasCRC","GridSmooth","IsCalSpeed","PosOfGrid","PosLen","MotorType","Ratio01","Ratio02","PosOffset","JogVelocity"
+        };
         void mFlyAD_PropertyChanged(object sender, PropertyChangedEventArgs e)
         {
-            if ((e.PropertyName == "LocalEP") ||
-                (e.PropertyName == "HasCRC") ||
-                (e.PropertyName == "GridSmooth") ||
-                (e.PropertyName == "IsCalSpeed") ||
-                (e.PropertyName == "PosOfGrid") ||
-                (e.PropertyName == "PosLen") ||
-                (e.PropertyName == "MotorType") ||
-                (e.PropertyName == "Ratio01") ||
-                (e.PropertyName == "Ratio02") ||
-                (e.PropertyName == "PosOffset") ||
-                (e.PropertyName == "JogVelocity"))
+            if (propertyname_params.Contains(e.PropertyName))
             {
                 FObjBase.PollModule.Current.Poll_JustOnce(
                     new PollModule.PollHandler(delegate()
diff --git a/Project.FLY.Thick.Base/FLY.Thick.Base/Server.OBJProxy/GetSample_OBJProxy.cs b/Project.FLY.Thick.Base/FLY.Thick.Base/Server.OBJProxy/GetSample_OBJProxy.cs
index cbd19428e35db598e79877cc88cde6d3dd2b55a0..ccf5bea46a1c237d1ff21e06c6eabb45778228f3 100644
--- a/Project.FLY.Thick.Base/FLY.Thick.Base/Server.OBJProxy/GetSample_OBJProxy.cs
+++ b/Project.FLY.Thick.Base/FLY.Thick.Base/Server.OBJProxy/GetSample_OBJProxy.cs
@@ -120,7 +120,6 @@ namespace FLY.Thick.Base.Server.OBJProxy
                         GETSAMPLE_OBJ_INTERFACE.Pack_Params p = new GETSAMPLE_OBJ_INTERFACE.Pack_Params()
                         {
                             enable = mGetSampleService.Enable,
-                            interval = mGetSampleService.Interval,
                             range = mGetSampleService.Range,
                             velocity = mGetSampleService.Velocity,
                             window = mGetSampleService.Window,
@@ -192,7 +191,6 @@ namespace FLY.Thick.Base.Server.OBJProxy
                         var p = Newtonsoft.Json.JsonConvert.DeserializeObject<GETSAMPLE_OBJ_INTERFACE.Pack_Params>(json);
 
                         mGetSampleService.Enable = p.enable;
-                        mGetSampleService.Interval = p.interval;
                         mGetSampleService.Range = p.range;
                         mGetSampleService.Velocity = p.velocity;
                         mGetSampleService.Window = p.window;
diff --git a/Project.FLY.Thick.Base/FLY.Thick.Base/Server/BorderSearch.cs b/Project.FLY.Thick.Base/FLY.Thick.Base/Server/BorderSearch.cs
index b83c337ae527fcf8cf016c597b6f28031f79e19d..a401c6912c5ff5515852562aac5c859c235fc096 100644
--- a/Project.FLY.Thick.Base/FLY.Thick.Base/Server/BorderSearch.cs
+++ b/Project.FLY.Thick.Base/FLY.Thick.Base/Server/BorderSearch.cs
@@ -632,29 +632,18 @@ namespace FLY.Thick.Base.Server
             border[idx].Begin = (borderbegin_grid + gridBegin) * posOfGrid;
             border[idx].End = (borderend_grid +gridBegin) * posOfGrid;
 
-            if (Misc.MyBase.ISVALIDATA(border[0].Begin) && Misc.MyBase.ISVALIDATA(border[1].Begin)) 
+            if (border.All(b => b.IsValid))
             {
-                Border.Begin = (border[0].Begin + border[1].Begin) / 2 + SensorWidth / 2;
-                Border.End = (border[0].End + border[1].End) / 2 - SensorWidth / 2;
-
-                Width = Border.Width;
-                Mid = Border.Mid;
+                Border.Begin = (int)(border.Average(b => b.Begin) + SensorWidth / 2.0);
+                Border.End = (int)(border.Average(b => b.End) - SensorWidth / 2.0);
             }
-            else if (Misc.MyBase.ISVALIDATA(border[0].Begin))
+            else if (border[idx].IsValid)
             {
-                Border.Copy(border[0]);
-
-                Width = Border.Width;
-                Mid = Border.Mid;
-            }
-            else if (Misc.MyBase.ISVALIDATA(border[1].Begin))
-            {
-                Border.Copy(border[1]);
-
-                Width = Border.Width;
-                Mid = Border.Mid;
+                Border.Begin = border[idx].Begin + SensorWidth / 2;
+                Border.End = border[idx].End - SensorWidth / 2;
             }
-            //膜宽
+            Width = Border.Width;
+            Mid = Border.Mid;
 
             return true;
         }
diff --git a/Project.FLY.Thick.Base/FLY.Thick.Base/Server/BorderSearchPlastic.cs b/Project.FLY.Thick.Base/FLY.Thick.Base/Server/BorderSearchPlastic.cs
index f3209355c5c576726a73dcea61285d77096537c6..82a22ef046c2ab74b7b4dbbef63aaffcc62563a9 100644
--- a/Project.FLY.Thick.Base/FLY.Thick.Base/Server/BorderSearchPlastic.cs
+++ b/Project.FLY.Thick.Base/FLY.Thick.Base/Server/BorderSearchPlastic.cs
@@ -2,6 +2,7 @@
 using Misc;
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.Linq;
 using System.Text;
 
@@ -30,6 +31,7 @@ namespace FLY.Thick.Base.Server
             //把数据记录下来
             getViewReponse = new BorderSearchGetViewReponse()
             {
+                direction = direction,
                 posOfGrid = posOfGrid,
                 gridBegin = gridBegin,
                 dat = dat
@@ -119,30 +121,18 @@ namespace FLY.Thick.Base.Server
             border[idx].Begin = (borderbegin_grid + gridBegin) * posOfGrid - SensorWidth / 2;
             border[idx].End = (borderend_grid + gridBegin) * posOfGrid + SensorWidth / 2;
 
-            if (Misc.MyBase.ISVALIDATA(border[0].Begin) && Misc.MyBase.ISVALIDATA(border[1].Begin))
+            if (border.All(b => b.IsValid))
             {
-                Border.Begin = (border[0].Begin + border[1].Begin) / 2 + SensorWidth / 2;
-                Border.End = (border[0].End + border[1].End) / 2 - SensorWidth / 2;
-
-                Width = Border.Width;
-                Mid = Border.Mid;
-            }
-            else if (Misc.MyBase.ISVALIDATA(border[0].Begin))
-            {
-                Border.Copy(border[0]);
-
-                Width = Border.Width;
-                Mid = Border.Mid;
+                Border.Begin = (int)(border.Average(b => b.Begin) + SensorWidth / 2.0);
+                Border.End = (int)(border.Average(b => b.End) - SensorWidth / 2.0);
             }
-            else if (Misc.MyBase.ISVALIDATA(border[1].Begin))
+            else if (border[idx].IsValid)
             {
-                Border.Copy(border[1]);
-
-                Width = Border.Width;
-                Mid = Border.Mid;
+                Border.Begin = border[idx].Begin + SensorWidth / 2;
+                Border.End = border[idx].End - SensorWidth / 2;
             }
-            //膜宽
-
+            Width = Border.Width;
+            Mid = Border.Mid;
             return true;
         }
     }
diff --git a/Project.FLY.Thick.Base/FLY.Thick.Base/Server/GM_Base.cs b/Project.FLY.Thick.Base/FLY.Thick.Base/Server/GM_Base.cs
index 07b16b68d0d3e184905c91ace079b3c9d1645da8..ab89a98c34a97c48880e54f5f110b1654970c125 100644
--- a/Project.FLY.Thick.Base/FLY.Thick.Base/Server/GM_Base.cs
+++ b/Project.FLY.Thick.Base/FLY.Thick.Base/Server/GM_Base.cs
@@ -143,7 +143,7 @@ namespace FLY.Thick.Base.Server
             bool b = base.Start();
             if (!b)
                 return false;
-            mFlyAD.SetPosParam(Velocity, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff);
+            mFlyAD.SetVelocity(Velocity);
             mFlyAD.Runto(pos);
             return true;
         }
@@ -170,8 +170,7 @@ namespace FLY.Thick.Base.Server
             bool b = base.Start();
             if (!b)
                 return false;
-
-            mFlyAD.SetPosParam( Velocity, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff);
+            mFlyAD.SetVelocity(Velocity);
             mFlyAD.RuntoMax();
             return true;
         }
@@ -198,7 +197,7 @@ namespace FLY.Thick.Base.Server
             bool b = base.Start();
             if (!b)
                 return false;
-            mFlyAD.SetPosParam(Velocity, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff);
+            mFlyAD.SetVelocity(Velocity);
             mFlyAD.RuntoMin();
             return true;
         }
diff --git a/Project.FLY.Thick.Base/FLY.Thick.Base/Server/GM_ScanMotion.cs b/Project.FLY.Thick.Base/FLY.Thick.Base/Server/GM_ScanMotion.cs
index ea844dc46d83b56fb1b675e138895d47b9621474..31477dd3443a12756efd38119c8f73affdfedd3d 100644
--- a/Project.FLY.Thick.Base/FLY.Thick.Base/Server/GM_ScanMotion.cs
+++ b/Project.FLY.Thick.Base/FLY.Thick.Base/Server/GM_ScanMotion.cs
@@ -7,6 +7,7 @@ using System.Text;
 using Misc;
 using FlyADBase;
 using FLY.Thick.Base.Common;
+using System.Diagnostics;
 
 namespace FLY.Thick.Base.Server
 {
@@ -18,64 +19,30 @@ namespace FLY.Thick.Base.Server
     {
         #region 成员变量
         protected GSample gsample;
-        int scanCnt;//扫描次数, 当为-1时,无限次扫描,>0时,有限次扫描
-        public int ScanCnt
-        {
-            get
-            {
-                return scanCnt;
-            }
-            set
-            {
-                if (scanCnt != value)
-                {
-                    scanCnt = value;
-                    NotifyPropertyChanged("ScanCnt");
-                }
-            }
-        }
 
-        int autoOriginCount;//归原点累计(多少次扫描一个归原点的累计)
+        /// <summary>
+        /// 归0开始时间点,用于计算什么时候需要归0
+        /// </summary>
+        private TimeSpan orgStartTime;
+       
+        /// <summary>
+        /// 使用timer.Elapsed 代替 DateTime.Now 使用
+        /// </summary>
+        private Stopwatch timer = new Stopwatch();
 
-        int orgInterval;//归原点间隔
-        public int OrgInterval
-        {
-            get { return orgInterval; }
-            set
-            {
-                if (orgInterval != value)
-                {
-                    orgInterval = value;
-                    NotifyPropertyChanged("OrgInterval");
-                }
-            }
-        }
+        /// <summary>
+        /// 归原点间隔
+        /// </summary>
+        public int OrgInterval { get; set; }
+
+
+        /// <summary>
+        /// 扫描范围
+        /// </summary>
+        public int ScanStart { get; set; }
+
+        public int ScanEnd { get; set; }
 
-        int scanStart, scanEnd;//扫描范围
-        public int ScanStart
-        {
-            get { return scanStart; }
-            set
-            {
-                if (scanStart != value)
-                {
-                    scanStart = value;
-                    NotifyPropertyChanged("ScanStart");
-                }
-            }
-        }
-        public int ScanEnd
-        {
-            get { return scanEnd; }
-            set
-            {
-                if (scanEnd != value)
-                {
-                    scanEnd = value;
-                    NotifyPropertyChanged("ScanEnd");
-                }
-            }
-        }
 
         public event EndEventHandler DataPosEvent;
         public event EndEventHandler EndEvent;
@@ -85,18 +52,30 @@ namespace FLY.Thick.Base.Server
 
         enum CTRLST
         {
-            SORIGIN = 1,//判断是否归0
-            SORIGINWAIT = 2,//正在归0
-            SFORWARD = 3,//前进到样品,或扫描结束位置
-            SFORWAIT_1 = 4,//前进等待
-            SFORWAIT_2 = 5,//前进结束,等待获取grid
-            SBACKWARD = 8,//后退到温修,或扫描开始位置
-            SBACKWAIT_1 = 9,//后退等待
-            SBACKWAIT_2 = 10,//后退结束,等待获取grid
-            SFORWAIT_SAMPLE = 11,//前进取样中
-            SFORW_SAMPLE = 12,//前进取样
-            SBACKWAIT_SAMPLE = 13,//后退取样中
-            SBACKW_SAMPLE = 14//后退取样
+            INIT = 0,//判断进入阶段
+
+            #region 归0 及 样品采集阶段
+            ORIGINWAIT = 2,//正在归0
+            FORWARD = 3,//前进到样品,或扫描结束位置
+            FORWAIT_1 = 4,//前进等待
+            FORWAIT_2 = 5,//前进结束,等待获取grid
+            BACKWARD = 8,//后退到温修,或扫描开始位置
+            BACKWAIT_1 = 9,//后退等待
+            BACKWAIT_2 = 10,//后退结束,等待获取grid
+            FORWAIT_SAMPLE = 11,//前进取样中
+            FORW_SAMPLE = 12,//前进取样
+            BACKWAIT_SAMPLE = 13,//后退取样中
+            BACKW_SAMPLE = 14,//后退取样
+            #endregion
+
+            #region 正常扫描阶段
+            SCAN_FORW = 20,//前进扫描
+            SCAN_FORWAIT = 21,//前进等待
+            SCAN_BACKW = 22,//后退扫描
+            SCAN_BACKWAIT = 23,//后退等待
+            #endregion
+
+
         }
         CTRLST state;
         #endregion
@@ -109,19 +88,17 @@ namespace FLY.Thick.Base.Server
             GMState = CTRL_STATE.SCAN;
 
             this.gsample = gsample;
-            ScanCnt = -1;//无限次扫描
 
             ScanStart = -1;
             ScanEnd = -1;
-
-            state = CTRLST.SORIGIN;
-
             flyad.MiniGridEvent += (s, e) =>
             {
-                if ((state == CTRLST.SFORWAIT_1) || (state == CTRLST.SBACKWAIT_1))
+                if ((state == CTRLST.FORWAIT_1) 
+                || (state == CTRLST.BACKWAIT_1)
+                || (state == CTRLST.SCAN_FORWAIT)
+                || (state == CTRLST.SCAN_BACKWAIT))
                 {
-                    if (DataPosEvent != null)
-                        DataPosEvent(this, e);
+                    DataPosEvent?.Invoke(this, e);
                 }
             };
         }
@@ -131,25 +108,21 @@ namespace FLY.Thick.Base.Server
             ScanStart = start;
             ScanEnd = end;
 
-            autoOriginCount = 0;
-            state = CTRLST.SORIGIN;
-            if (ScanCnt >= 0)
-            {
-                OrgInterval = ScanCnt + 1;//禁止自动归原点
-            }
+            timer.Restart();
+            orgStartTime = TimeSpan.FromMinutes(-OrgInterval);
+            state = CTRLST.INIT;
 
             if (gsample != null)
                 gsample.Init(ScanStart, ScanEnd);
 
-            if (StartEvent != null)
-                StartEvent(this, null);
+            StartEvent?.Invoke(this, null);
             return true;
         }
 
         public override void Stop()
         {
-            if (FinishEvent != null)
-                FinishEvent(this, null);
+            timer.Stop();
+            FinishEvent?.Invoke(this, null);
             base.Stop();
         }
         bool WaitFinish(ref CTRLST src, CTRLST next)
@@ -174,198 +147,191 @@ namespace FLY.Thick.Base.Server
         {
             switch (state)
             {
-                case CTRLST.SORIGIN:
+                case CTRLST.INIT:
                     {
-                        state = CTRLST.SFORWARD;
-
-                        //if( scanCnt == -1 )
+                        if (IsOrging())
                         {
-                            if (IsOrgEnable() && (autoOriginCount > 0))
-                                autoOriginCount--;
-
-                            if (IsOrging())
-                            {
-                                autoOriginCount = OrgInterval;
-                                mFlyAD.Origin();
-                                state = CTRLST.SORIGINWAIT;
-                                break;
-                            }
+                            mFlyAD.Origin();
+                            state = CTRLST.ORIGINWAIT;
                         }
-                    } break;
-                case CTRLST.SORIGINWAIT:
+                        else {
+                            state = CTRLST.SCAN_FORW;
+                        }
+                    }
+                    break;
+                case CTRLST.ORIGINWAIT:
                     {
-                        WaitFinish(ref state, CTRLST.SFORWARD);
+                        WaitFinish(ref state, CTRLST.FORWARD);
                     } break;
-                case CTRLST.SFORWARD:
+                case CTRLST.FORWARD:
                     {
                         int to = ScanEnd;
 
-                        if (scanCnt == -1)
+                        int b, e;
+                        if (gsample.GetSampleRange(Misc.DIRECTION.FORWARD, out b, out e))
                         {
-                            if (gsample != null && gsample.Check())
-                            {
-                                int b, e;
-                                if (gsample.GetSampleRange(Misc.DIRECTION.FORWARD, out b, out e))
-                                {
-                                    FlyADBase.MOTORTYPE motorType = mFlyAD.MotorType;
-
-                                    if (motorType == FlyADBase.MOTORTYPE.VF0)
-                                    {
-                                        //直接去到取样的位置
-                                        to = e;
-                                    }
-                                    else//要变速,分开两段
-                                    {
-                                        to = b;
-                                    }
-                                }
+                            FlyADBase.MOTORTYPE motorType = mFlyAD.MotorType;
 
+                            if (motorType == FlyADBase.MOTORTYPE.VF0)
+                            {
+                                //直接去到取样的位置
+                                to = e;
+                            }
+                            else//要变速,分开两段
+                            {
+                                to = b;
                             }
                         }
-                        mFlyAD.SetPosParam(Velocity, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff);
+                        
+                        mFlyAD.SetVelocity(Velocity);
                         mFlyAD.Runto(to);
-                        state = CTRLST.SFORWAIT_1;
+                        state = CTRLST.FORWAIT_1;
                     } break;
-                case CTRLST.SFORWAIT_1:
+                case CTRLST.FORWAIT_1:
                     {
-                        if (WaitFinish(ref state, CTRLST.SFORWAIT_2))
+                        if (WaitFinish(ref state, CTRLST.FORWAIT_2))
                             FlushAD(DIRECTION.FORWARD);
 
                     } break;
-                case CTRLST.SFORWAIT_2:
+                case CTRLST.FORWAIT_2:
                     {
-                        state = CTRLST.SBACKWARD;
+                        state = CTRLST.BACKWARD;
 
-                        //扫描次数
-                        if (scanCnt > 0)
-                            scanCnt--;
-
-                        if (scanCnt == 0)
+                        int b, e;
+                        if (gsample.GetSampleRange(Misc.DIRECTION.FORWARD, out b, out e))
                         {
-                            //扫描完成
-                            Stop(); return;
-                        }
+                            FlyADBase.MOTORTYPE motorType = mFlyAD.MotorType;
 
-                        if (scanCnt == -1)
-                        {
-                            if (gsample != null && gsample.Check())
+                            if (motorType == FlyADBase.MOTORTYPE.VF0)
+                            {
+                                //直接去到取样的位置
+                                state = CTRLST.FORW_SAMPLE;
+                            }
+                            else//要变速,分开两段
                             {
-                                int b, e;
-                                if (gsample.GetSampleRange(Misc.DIRECTION.FORWARD, out b, out e))
-                                {
-                                    FlyADBase.MOTORTYPE motorType = mFlyAD.MotorType;
-
-                                    if (motorType == FlyADBase.MOTORTYPE.VF0)
-                                    {
-                                        //直接去到取样的位置
-                                        state = CTRLST.SFORW_SAMPLE;
-                                    }
-                                    else//要变速,分开两段
-                                    {
-                                        mFlyAD.SetPosParam((UInt32)gsample.Velocity, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff);
-                                        mFlyAD.Runto(e);
-                                        state = CTRLST.SFORWAIT_SAMPLE;
-                                    }
-                                }
+                                mFlyAD.SetVelocity(gsample.Velocity);
+                                mFlyAD.Runto(e);
+                                state = CTRLST.FORWAIT_SAMPLE;
                             }
                         }
                     } break;
-                case CTRLST.SFORWAIT_SAMPLE:
+                case CTRLST.FORWAIT_SAMPLE:
                     {
-                        WaitFinish(ref state, CTRLST.SFORW_SAMPLE);
+                        WaitFinish(ref state, CTRLST.FORW_SAMPLE);
                     } break;
-                case CTRLST.SFORW_SAMPLE:
+                case CTRLST.FORW_SAMPLE:
                     {
                         gsample.Do(Misc.DIRECTION.FORWARD);
-                        state = CTRLST.SBACKWARD;
+                        state = CTRLST.BACKWARD;
                     } break;
-                case CTRLST.SBACKWARD:
+                case CTRLST.BACKWARD:
                     {
                         int to = ScanStart;
-                        if (scanCnt == -1)
+
+                        int b, e;
+                        if (gsample.GetSampleRange(Misc.DIRECTION.BACKWARD, out b, out e))
                         {
-                            if (gsample.Check())
+                            FlyADBase.MOTORTYPE motorType = mFlyAD.MotorType;
+
+                            if (motorType == FlyADBase.MOTORTYPE.VF0)
+                            {
+                                //直接去到取样的位置
+                                to = b;
+                            }
+                            else//要变速,分开两段
                             {
-                                int b, e;
-                                if (gsample.GetSampleRange(Misc.DIRECTION.BACKWARD, out b, out e))
-                                {
-                                    FlyADBase.MOTORTYPE motorType = mFlyAD.MotorType;
-
-                                    if (motorType == FlyADBase.MOTORTYPE.VF0)
-                                    {
-                                        //直接去到取样的位置
-                                        to = b;
-                                    }
-                                    else//要变速,分开两段
-                                    {
-                                        to = e;
-                                    }
-                                }
+                                to = e;
                             }
                         }
-                        mFlyAD.SetPosParam(Velocity, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff);
+                        
+                        mFlyAD.SetVelocity(Velocity);
                         mFlyAD.Runto(to);
-                        state = CTRLST.SBACKWAIT_1;
+                        state = CTRLST.BACKWAIT_1;
                     } break;
-                case CTRLST.SBACKWAIT_1:
+                case CTRLST.BACKWAIT_1:
                     {
-                        if (WaitFinish(ref state, CTRLST.SBACKWAIT_2))
+                        if (WaitFinish(ref state, CTRLST.BACKWAIT_2))
                             FlushAD(DIRECTION.BACKWARD);
                     } break;
-                case CTRLST.SBACKWAIT_2:
+                case CTRLST.BACKWAIT_2:
                     {
-                        state = CTRLST.SORIGIN;
-
-                        //扫描次数
-                        if (scanCnt > 0)
-                            scanCnt--;
-
-                        if (scanCnt == 0)
-                        {
-                            //扫描完成
-                            Stop(); return;
-                        }
-                        if (scanCnt == -1)
+                        int b, e;
+                        if (gsample.GetSampleRange(Misc.DIRECTION.BACKWARD, out b, out e))
                         {
-                            if (gsample.Check())
+                            FlyADBase.MOTORTYPE motorType = mFlyAD.MotorType;
+
+                            if (motorType == FlyADBase.MOTORTYPE.VF0)
                             {
-                                int b, e;
-                                if (gsample.GetSampleRange(Misc.DIRECTION.BACKWARD, out b, out e))
-                                {
-                                    FlyADBase.MOTORTYPE motorType = mFlyAD.MotorType;
-
-                                    if (motorType == FlyADBase.MOTORTYPE.VF0)
-                                    {
-                                        //直接去到取样的位置
-                                        state = CTRLST.SBACKW_SAMPLE;
-                                    }
-                                    else//要变速,分开两段
-                                    {
-                                        mFlyAD.SetPosParam((UInt32)gsample.Velocity, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff);
-                                        mFlyAD.Runto(b);
-                                        state = CTRLST.SBACKWAIT_SAMPLE;
-                                    }
-
-                                }
+                                //直接去到取样的位置
+                                state = CTRLST.BACKW_SAMPLE;
+                            }
+                            else//要变速,分开两段
+                            {
+                                mFlyAD.SetVelocity(gsample.Velocity);
+                                mFlyAD.Runto(b);
+                                state = CTRLST.BACKWAIT_SAMPLE;
                             }
                         }
+                        else {
+                            //完成一次周期
+                            if (gsample.OK())
+                                orgStartTime = timer.Elapsed;
+                            state = CTRLST.INIT;
+                        }
                     } break;
-                case CTRLST.SBACKWAIT_SAMPLE:
+                case CTRLST.BACKWAIT_SAMPLE:
                     {
-                        WaitFinish(ref state, CTRLST.SBACKW_SAMPLE);
+                        WaitFinish(ref state, CTRLST.BACKW_SAMPLE);
                     } break;
-                case CTRLST.SBACKW_SAMPLE:
+                case CTRLST.BACKW_SAMPLE:
                     {
                         gsample.Do(Misc.DIRECTION.BACKWARD);
-                        state = CTRLST.SORIGIN;
+                        //完成一次周期
+                        if (gsample.OK())
+                            orgStartTime = timer.Elapsed;
+                        state = CTRLST.INIT;
                     } break;
+
+
+                case CTRLST.SCAN_FORW:
+                    {
+                        int to = ScanEnd;
+                        mFlyAD.SetVelocity(Velocity);
+                        mFlyAD.Runto(to);
+                        state = CTRLST.SCAN_FORWAIT;
+                    }
+                    break;
+                case CTRLST.SCAN_FORWAIT:
+                    {
+                        if (WaitFinish(ref state, CTRLST.SCAN_BACKW))
+                            FlushAD(DIRECTION.FORWARD);
+                    }
+                    break;
+                case CTRLST.SCAN_BACKW:
+                    {
+                        int to = ScanStart;
+                        mFlyAD.SetVelocity(Velocity);
+                        mFlyAD.Runto(to);
+                        state = CTRLST.SCAN_BACKWAIT;
+                    }
+                    break;
+                case CTRLST.SCAN_BACKWAIT:
+                    {
+                        if (WaitFinish(ref state, CTRLST.INIT))
+                            FlushAD(DIRECTION.BACKWARD);
+                    }
+                    break;
             }
         }
 
         private bool IsOrging()
         {
-            if ((autoOriginCount == 0) && (OrgInterval > 0))
-                return true;
+            if (OrgInterval > 0) {
+
+                if (timer.Elapsed >= (orgStartTime + TimeSpan.FromMinutes(OrgInterval)))
+                    return true;
+            }
+
             return false;
         }
 
@@ -554,8 +520,9 @@ namespace FLY.Thick.Base.Server
                     }break;
                 case CTRLST.READY_BACKW:
                     {
-                        mFlyAD.SetPosParam(Velocity, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff);
-                        mFlyAD.Runto(0);
+
+                        mFlyAD.SetVelocity(Velocity);
+                        mFlyAD.RuntoMin();
                         state = CTRLST.READY_BACKWAIT;
                     } break;
                 case CTRLST.READY_BACKWAIT:
@@ -564,9 +531,8 @@ namespace FLY.Thick.Base.Server
                     } break;
                 case CTRLST.SFORWARD:
                     {
-                        int to = mFlyAD.PosLen;
-                        mFlyAD.SetPosParam(Velocity, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff);
-                        mFlyAD.Runto(to);
+                        mFlyAD.SetVelocity(Velocity);
+                        mFlyAD.RuntoMax();
                         state = CTRLST.SFORWAIT_1;
                     } break;
                 case CTRLST.SFORWAIT_1:
@@ -580,8 +546,8 @@ namespace FLY.Thick.Base.Server
                     } break;
                 case CTRLST.SBACKWARD:
                     {
-                        mFlyAD.SetPosParam(Velocity, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff);
-                        mFlyAD.Runto(0);
+                        mFlyAD.SetVelocity(Velocity);
+                        mFlyAD.RuntoMin();
                         state = CTRLST.SBACKWAIT_1;
                     } break;
                 case CTRLST.SBACKWAIT_1:
diff --git a/Project.FLY.Thick.Base/FLY.Thick.Base/Server/GetSample.cs b/Project.FLY.Thick.Base/FLY.Thick.Base/Server/GetSample.cs
index 3844bb845d900336ca4aa5de5800187772b2cf60..4217b899e62b0bbdadea5c828d4619b53c671fbc 100644
--- a/Project.FLY.Thick.Base/FLY.Thick.Base/Server/GetSample.cs
+++ b/Project.FLY.Thick.Base/FLY.Thick.Base/Server/GetSample.cs
@@ -28,18 +28,6 @@ namespace FLY.Thick.Base.Server
         [JsonProperty]
         public bool Enable { get; set; } = true;
 
-        /// <summary>
-        /// 参数:间隔
-        /// </summary>
-        [JsonProperty]
-        public int Interval { get; set; } = 5;
-
-
-        /// <summary>
-        /// 采样计数
-        /// </summary>
-        public int Timer { get; set; }
-
         /// <summary>
         /// 参数:速度
         /// </summary>
@@ -131,7 +119,6 @@ namespace FLY.Thick.Base.Server
 
 
             Enable = true;
-            Interval = 5;//采样间隔
             Range = 100;//样品范围
             Velocity = 200;//取样速度
             Window = 3;//移动窗口
@@ -142,16 +129,16 @@ namespace FLY.Thick.Base.Server
             Samples[0] = new SampleCell()
             {
                 Enable = true,
-                Position = 0,
-                OrgAD = 0
+                Position = 200,
+                OrgAD = 50300
             };
             directions[0] = DIRECTION.BACKWARD;
 
             Samples[1] = new SampleCell()
             {
                 Enable = false,
-                Position = 2006,
-                OrgAD = 30000
+                Position = 0,
+                OrgAD = 0
             };
             directions[1] = DIRECTION.FORWARD;
 
@@ -223,8 +210,6 @@ namespace FLY.Thick.Base.Server
                 sample.AD = -1;
                 tempFilters[i].Reset();
             }
-
-            Timer = Interval;
         }
         
         /// <summary>
@@ -239,29 +224,8 @@ namespace FLY.Thick.Base.Server
                 sample.AD = -1;
                 tempFilters[i].Reset();
             }
-            Timer = Interval;
         }
-        /// <summary>
-        /// 检测是否要样品校正
-        /// </summary>
-        /// <returns></returns>
-        public virtual bool Check()
-        {
-            if (!Samples.Any(s => s.Enable))
-            {
-                return false;
-            }
 
-            if (Timer < Interval)
-            {
-                Timer++;
-                return false;
-            }
-            else
-            {
-                return true;
-            }
-        }
         /// <summary>
         /// 获取样品测量范围
         /// </summary>
@@ -527,9 +491,7 @@ namespace FLY.Thick.Base.Server
 
             if (isFailure)//样品获取失败,下次继续!!!
                     return;
-            //只有当所有都成功,Timer=0
-            if(Samples.All(s => (s.Enable && s.AD > 0) || (!s.Enable)))
-                Timer = 0;
+
         }
 
         /// <summary>
@@ -571,11 +533,6 @@ namespace FLY.Thick.Base.Server
 
 
             SampleChangedEvent?.Invoke(this);
-
-
-            //只有当所有都成功,Timer=0
-            if (Samples.All(s => (s.Enable && s.AD > 0) || (!s.Enable)))
-                Timer = 0;
         }
         /// <summary>
         /// 重新获取样品