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> /// 釿–°èŽ·å–æ ·å“