Commit bc6e1a6e authored by 潘栩锋's avatar 潘栩锋 🚴

正在调试 机架修正

parent 93976f41
......@@ -173,7 +173,7 @@
<Compile Include="PgReject.xaml.cs">
<DependentUpon>PgReject.xaml</DependentUpon>
</Compile>
<Compile Include="PgScanCorr.xaml.cs">
<Compile Include="PgScanCorr\PgScanCorr.xaml.cs">
<DependentUpon>PgScanCorr.xaml</DependentUpon>
</Compile>
<Compile Include="ParamDistItemKeys.cs" />
......@@ -204,6 +204,7 @@
<Compile Include="PgPwManager.xaml.cs">
<DependentUpon>PgPwManager.xaml</DependentUpon>
</Compile>
<Compile Include="PgScanCorr\PgScanCorrVm.cs" />
<Compile Include="UiModule\DynAreaFilmWidth.xaml.cs">
<DependentUpon>DynAreaFilmWidth.xaml</DependentUpon>
</Compile>
......@@ -334,7 +335,7 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="PgScanCorr.xaml">
<Page Include="PgScanCorr\PgScanCorr.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
......
using FLY.Thick.Base.Client;
using FLY.Thick.Base.IService;
using FObjBase;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Windows;
......@@ -19,6 +21,20 @@ namespace FLY.Thick.Base.UI
const int MARKNO_UPDATE = 1;
#endregion
public class SeriesInfo : INotifyPropertyChanged
{
public string Name { get; set; }
//public Brush Color { get; set; }
public List<int> Datas = new List<int>();
public DateTime UpdateTime = DateTime.MaxValue;
public event PropertyChangedEventHandler PropertyChanged;
}
public SeriesInfo[] SeriesInfos { get; set; }
IGageInfoService gageInfo = null;
IGetSampleService getSample = null;
IBorderSearchService borderSearch = null;
......@@ -44,6 +60,16 @@ namespace FLY.Thick.Base.UI
this.gageService = gageService;
this.container = container;
container.BuildUp(mircoGage);
SeriesInfos = new SeriesInfo[2] {
new SeriesInfo(){
Name = "正向"
},
new SeriesInfo(){
Name = "反向"
}
};
}
private void Page_Loaded(object sender, RoutedEventArgs e1)
{
......@@ -51,10 +77,25 @@ namespace FLY.Thick.Base.UI
gageInfo.PropertyChanged += (s, e) =>
{
if (e.PropertyName == nameof(gageInfo.ForwData) ||
e.PropertyName == nameof(gageInfo.BackwData))
{
DataBindAll();
if (e.PropertyName == nameof(gageInfo.UpdateTimes)) {
//下载数据
for (int i = 0; i < SeriesInfos.Count(); i++) {
var seriesInfo = SeriesInfos[i];
if (gageInfo.UpdateTimes != null && gageInfo.UpdateTimes.Count() > i) {
if (seriesInfo.UpdateTime != gageInfo.UpdateTimes[i]) {
gageInfo.GetGageInfo(i, (asyncContext, retData) =>
{
var reponse = retData as GetGageInfoResponse;
int index = (int)asyncContext;
SeriesInfos[index].Datas.Clear();
SeriesInfos[index].Datas.AddRange(reponse.Data);
SeriesInfos[index].UpdateTime = reponse.UpdateTime;
DataBindAll();
}, i);
}
}
}
}
};
getSample.PropertyChanged += (s, e) =>
......@@ -102,10 +143,29 @@ namespace FLY.Thick.Base.UI
}
};
DataBindAll();
DownloadAll();
//DataBindAll();
update();
}
void DownloadAll() {
//下载数据
for (int i = 0; i < SeriesInfos.Count(); i++)
{
var seriesInfo = SeriesInfos[i];
gageInfo.GetGageInfo(i, (asyncContext, retData) =>
{
var reponse = retData as GetGageInfoResponse;
int index = (int)asyncContext;
SeriesInfos[index].Datas.Clear();
SeriesInfos[index].Datas.AddRange(reponse.Data);
SeriesInfos[index].UpdateTime = reponse.UpdateTime;
DataBindAll();
}, i);
}
}
void InitializeComponent2()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
......@@ -253,10 +313,11 @@ namespace FLY.Thick.Base.UI
chart1.Series.Add(series3);
}
void DataBindAll()
{
string[] series = new string[2] { "正向", "反向" };
int[][] datas = new int[2][] { gageInfo.ForwData, gageInfo.BackwData };
if (gageInfo.PosOfGrid == 0)
return;
int grid_len = gageInfo.PosLen / gageInfo.PosOfGrid;
......@@ -264,11 +325,11 @@ namespace FLY.Thick.Base.UI
for (int j = 0; j < 2; j++)
{
chart1.Series[j].Points.Clear();
if (datas[j] == null || datas[j].Count()==0)
if (SeriesInfos[j].Datas.Count()==0)
continue;
for (int i = 0; i < grid_len && i< datas[j].Count(); i++)
for (int i = 0; i < grid_len && i< SeriesInfos[j].Datas.Count(); i++)
{
int data = datas[j][i];
int data = SeriesInfos[j].Datas[i];
int pos = i * gageInfo.PosOfGrid;
chart1.Series[j].Points.AddXY(pos, data);
......
......@@ -121,7 +121,6 @@ namespace FLY.Thick.Base.UI
public GetSampleVm()
{
ApplyCmd = new RelayCommand(Apply);
GetOrgAdCmd = new RelayCommand(GetOrgAd);
GetTempDataCmd = new RelayCommand(GetTempData);
}
......@@ -168,62 +167,7 @@ namespace FLY.Thick.Base.UI
}
private void GetOrgAd()
{
if (gageInfoService.ForwData == null || gageInfoService.BackwData == null)
{
FLY.ControlLibrary.Window_WarningTip.Show("失败",
"机架信息 为空",
TimeSpan.FromSeconds(2));
return;
}
int[] forwdata = gageInfoService.ForwData.ToArray();
int[] backwdata = gageInfoService.BackwData.ToArray();
for (int i = 0; i < Samples.Count(); i++)
{
var sampleCell = Samples[i];
if (sampleCell.Enable)
{
int grid = sampleCell.Position / gageInfoService.PosOfGrid;
int range = Range / gageInfoService.PosOfGrid;
int bg = grid - range;
int eg = grid + range;
if (bg < 0 || bg >= forwdata.Length || bg > backwdata.Length)
{
FLY.ControlLibrary.Window_WarningTip.Show("失败",
"位置出错",
TimeSpan.FromSeconds(2));
return;
}
if (eg < 0 || eg >= forwdata.Length || eg > backwdata.Length)
{
FLY.ControlLibrary.Window_WarningTip.Show("失败",
"位置出错",
TimeSpan.FromSeconds(2));
return;
}
int ad1 = Misc.MyMath.Avg(forwdata, bg, eg);
int ad2 = Misc.MyMath.Avg(backwdata, bg, eg);
if (!Misc.MyBase.ISVALIDATA(ad1) || !Misc.MyBase.ISVALIDATA(ad2))
{
FLY.ControlLibrary.Window_WarningTip.Show("失败",
"位置出错",
TimeSpan.FromSeconds(2));
return;
}
sampleCell.OrgAD = (ad1 + ad2) / 2;
}
}
FLY.ControlLibrary.Window_Tip.Show("设置完成",
null,
TimeSpan.FromSeconds(2));
}
private void Apply()
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Net;
using FLY.Thick.Base.IService;
using FLY.Thick.Base.Client;
using FLY.Thick.Base.Common;
using System.IO;
using Unity;
using GalaSoft.MvvmLight.Command;
using LiveCharts.Wpf;
namespace FLY.Thick.Base.UI
{
/// <summary>
/// Page_ScanCorr.xaml 的交互逻辑
/// </summary>
public partial class PgScanCorr : Page
{
PgScanCorrVm viewModel;
public PgScanCorr()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(IUnityContainer container,
IScanCorrService scanCorrService,
IInitParamService initParamService
)
{
viewModel = new PgScanCorrVm();
viewModel.Init(scanCorrService, initParamService);
this.DataContext = viewModel;
container.BuildUp(mircoGage);
}
private void UIElement_OnMouseMove(object sender, MouseEventArgs e)
{
if (!isDown)
return;
var vm = viewModel;
var chart = (LiveCharts.Wpf.CartesianChart)sender;
//lets get where the mouse is at our chart
var mouseCoordinate = e.GetPosition(chart);
//now that we know where the mouse is, lets use
//ConverToChartValues extension
//it takes a point in pixes and scales it to our chart current scale/values
var p = chart.ConvertToChartValues(mouseCoordinate);
//var series = vm.Series[0];
//var closetsPoint = series.ClosestPointTo(p.X, AxisOrientation.X);
//if (closetsPoint == null)
// return;
//pEnd = closetsPoint;
pEnd = p;
vm.Select(pBegin, pEnd);
}
private System.Windows.Point pBegin;
private System.Windows.Point pEnd;
private bool isDown = false;
private void UIElement_MouseDown(object sender, MouseButtonEventArgs e)
{
isDown = true;
var vm = viewModel;
var chart = (LiveCharts.Wpf.CartesianChart)sender;
var mouseCoordinate = e.GetPosition(chart);
var p = chart.ConvertToChartValues(mouseCoordinate);
pBegin = p;
//var series = chart.Series[0];
//ChartPoint closetsPoint = series.ClosestPointTo(p.X, AxisOrientation.X);
//if (closetsPoint == null)
//{
// isDown = false;
// return;
//}
//cpBegin = closetsPoint;
vm.Select(pBegin, pBegin);
}
private void UIElement_MouseUp(object sender, MouseButtonEventArgs e)
{
isDown = false;
var vm = viewModel;
var series = vm.Series[0];
var chart = (LiveCharts.Wpf.CartesianChart)sender;
//lets get where the mouse is at our chart
var mouseCoordinate = e.GetPosition(chart);
//now that we know where the mouse is, lets use
//ConverToChartValues extension
//it takes a point in pixes and scales it to our chart current scale/values
var p = chart.ConvertToChartValues(mouseCoordinate);
//for X in this case we will only highlight the closest point.
//lets use the already defined ClosestPointTo extension
//it will return the closest ChartPoint to a value according to an axis.
//here we get the closest point to p.X according to the X axis
//var series = chart.Series[0];
//var closetsPoint = series.ClosestPointTo(p.X, AxisOrientation.X);
//if (closetsPoint == null)
// return;
pEnd = p;
vm.Select(pBegin, pEnd);
}
}
}
using FLY.Thick.Base.IService;
using FObjBase;
using FObjBase.Reflect;
using System;
namespace FLY.Thick.Base.Client
......@@ -11,13 +13,9 @@ namespace FLY.Thick.Base.Client
public GageInfoServiceClient(UInt32 serviceId) : base(serviceId) { }
public GageInfoServiceClient(UInt32 serviceId, string connName) : base(serviceId, connName) { }
#region IGageInfoService 接口
/// <summary>
/// 数据好了!!!!
/// 当 flyad7 的poslen, posOfGrid 发生变化时,DataOK = false, 需要重新记录。
/// </summary>
public bool DataOK { get; set; }
/// <summary>
/// 机架总长,脉冲
......@@ -30,21 +28,27 @@ namespace FLY.Thick.Base.Client
/// </summary>
public int PosOfGrid { get; set; } = 11;
public int[] ForwData { get; set; }
/// <summary>
/// 数据好了!!!!
/// 当 flyad7 的poslen, posOfGrid 发生变化时,DataOK = false, 需要重新记录。
/// </summary>
public bool DataOK { get; set; }
public int[] BackwData { get; set; }
/// <summary>
/// 0~100
/// 当前进度 0 - 100
/// </summary>
public int Progress { get; set; }
/// <summary>
/// 数据更新时间
/// </summary>
public DateTime[] UpdateTimes { get; set; }
/// <summary>
/// 正在机架修正中
/// </summary>
public bool IsRunning { get; set; }
/// <summary>
/// 数据录制,记下来回扫描的AD值数组
/// </summary>
......@@ -57,7 +61,11 @@ namespace FLY.Thick.Base.Client
{
Call(nameof(Stop));
}
#endregion
[Call(typeof(GetGageInfoResponse))]
public void GetGageInfo(int idx, AsyncCBHandler asyncDelegate, object asyncContext)
{
Call(nameof(GetGageInfo), new { idx = idx }, asyncDelegate, asyncContext);
}
}
}
......@@ -96,7 +96,6 @@
<Compile Include="OBJ_INTERFACE\SCANCORR_OBJ_INTERFACE.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Server.OBJProxy\GetSample_OBJProxy.cs" />
<Compile Include="Server.OBJProxy\ScanCorr_OBJProxy.cs" />
<Compile Include="Server\BoltMapImg.cs" />
<Compile Include="Server\BorderSearch.cs" />
<Compile Include="Server\CurveCollection.cs" />
......@@ -120,6 +119,7 @@
<Compile Include="Server\InitParam.cs" />
<Compile Include="Server\Reject.cs" />
<Compile Include="Server\BorderSearchPlastic.cs" />
<Compile Include="Server\ScanMotion2.cs" />
<Compile Include="Server\SysParam.cs" />
<Compile Include="Server\AD2ThickHandler.cs" />
<Compile Include="Server\TempFilter.cs" />
......
......@@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using FObjBase;
using FObjBase.Reflect;
namespace FLY.Thick.Base.IService
{
......@@ -18,15 +20,6 @@ namespace FLY.Thick.Base.IService
/// </summary>
int PosOfGrid { get; }
/// <summary>
/// 正向扫描数据
/// </summary>
int[] ForwData { get; }
/// <summary>
/// 反向扫描数据
/// </summary>
int[] BackwData { get; }
/// <summary>
/// 数据好了!!!!
/// 当 flyad7 的poslen, posOfGrid 发生变化时,DataOK = false, 需要重新记录。
......@@ -37,6 +30,12 @@ namespace FLY.Thick.Base.IService
/// 当前进度 0 - 100
/// </summary>
int Progress { get; }
/// <summary>
/// 数据更新时间
/// </summary>
DateTime[] UpdateTimes { get; }
/// <summary>
/// 正在机架修正中
/// </summary>
......@@ -48,5 +47,35 @@ namespace FLY.Thick.Base.IService
void Start();
void Stop();
[Call(typeof(GetGageInfoResponse))]
void GetGageInfo(int idx, AsyncCBHandler asyncDelegate, object asyncContext);
}
public class GageInfoData
{
/// <summary>
/// 正向扫描数据
/// </summary>
public int[] ForwData = null;
/// <summary>
/// 反向扫描数据
/// </summary>
public int[] BackwData = null;
}
public class GetGageInfoResponse
{
/// <summary>
/// 0 为 射线正向, 1为射线反向
/// </summary>
public int Idx;
/// <summary>
/// 扫描数据
/// </summary>
public int[] Data = null;
/// <summary>
/// 更新时间
/// </summary>
public DateTime UpdateTime;
}
}
......@@ -5,6 +5,9 @@ using System.Text;
using System.ComponentModel;
using FLY.Thick.Base.Common;
using System.Collections.ObjectModel;
using Misc;
using FObjBase.Reflect;
using FObjBase;
namespace FLY.Thick.Base.IService
{
......@@ -15,91 +18,101 @@ namespace FLY.Thick.Base.IService
/// </summary>
bool Enable{set;get;}
/// <summary>
/// 当前修正的组
/// </summary>
int CurrGroupIndex { get; }
/// <summary>
/// 当前进度 0 - 100
/// </summary>
int Progress { get; }
/// <summary>
/// 数据更新时间
/// </summary>
DateTime[] UpdateTimes { get; }
/// <summary>
/// 正在机架修正中
/// </summary>
bool Ing { get; }
bool IsRunning { get; }
/// <summary>
/// 来回次数
/// </summary>
int ScanTimer { get; set; }
int ScanCnt { get; }
/// <summary>
/// 平滑,移动窗口
/// 开始机架修正
/// </summary>
int SmoothFactor { get; set; }
/// <param name="groupIndex">组序号</param>
/// <param name="scanCnt">扫描次数</param>
void Start(int groupIndex, int scanCnt);
/// <summary>
/// 有效范围.开始,单位脉冲
/// 清空组数据
/// </summary>
int ValidBegin { get; set; }
/// <param name="groupIndex"></param>
void Clear(int groupIndex);
/// <summary>
/// 有效范围.结束,单位脉冲
/// 设置修正曲线
/// </summary>
int ValidEnd { get; set; }
/// <param name="groupIndex">组序号</param>
/// <param name="corrDatas">修正数据</param>
/// <param name="avg">均值</param>
void SetCorrData(int groupIndex, int[][] corrDatas, int avg);
[Call(typeof(GetScanCorrGroupResponse))]
void GetScanCorrGroup(int groupIndex, AsyncCBHandler asyncDelegate, object asyncContext);
/// <summary>
/// 储存的数据是grid为单位。 需要PosOfGrid,PosLen 作为对应!!
/// </summary>
int PosOfGrid { get; }
/// <summary>
/// 储存的数据是grid为单位。 需要PosOfGrid,PosLen 作为对应!!
/// </summary>
int PosLen { get; }
}
public class GetScanCorrGroupResponse
{
/// <summary>
///组0
/// 组序号
/// </summary>
IScanCorrGroup Group0 { get; }
public int GroupIndex;
/// <summary>
/// 组1
/// 更新时间
/// </summary>
IScanCorrGroup Group1 { get; }
public DateTime UpdateTime;
/// <summary>
/// 开始机架修正, 参数 ScanTimer,SmoothFactor
/// 机架准备好了
/// </summary>
/// <param name="groupindex">0,1</param>
void Start(int groupindex);
public bool IsDataOK;
/// <summary>
/// 平滑, 参数是SmoothFactor
/// 机架总长,脉冲
/// </summary>
/// <param name="groupindex">0,1</param>
void Smooth(int groupindex);
/// <summary>
/// 清空组数据
/// </summary>
/// <param name="groupindex">0,1</param>
void Clear(int groupindex);
public int PosLen;
/// <summary>
/// 参数应用
/// 1个grid = N个pos
/// </summary>
void Apply();
}
public interface IScanCorrGroup : INotifyPropertyChanged
{
public int PosOfGrid;
/// <summary>
/// 平均AD值
/// 原始 正反方向机架AD值数据, grid数据
/// </summary>
int AvgAD { get; set; }
public int[][] OrgDatas;
/// <summary>
/// 正反方向机架AD值数据, grid数据
/// 修正用 正反方向机架AD值数据
/// </summary>
List<int> ForwDatas { get; }
public int[][] CorrDatas;
/// <summary>
/// 反方向机架AD值数据, grid数据
/// CorrDatas 的均值
/// </summary>
List<int> BackwDatas { get; }
public int Avg;
}
}
......@@ -396,9 +396,15 @@ namespace FLY.Thick.Base.Server
int grid_searchtol = Search / posOfGrid;
//获取相同方向的机架信息数据
int[] gagedata = ((direction == Misc.DIRECTION.FORWARD) ? mGageInfo.ForwData : mGageInfo.BackwData).ToArray();
int index = (direction == Misc.DIRECTION.FORWARD) ? 0 : 1;
int[] gagedata = null;
mGageInfo.GetGageInfo(index, (asyncContext, retData) =>
{
var reponse = retData as GetGageInfoResponse;
gagedata = reponse.Data;
}, this);
//合格,查找最大相识性的点
int grid_b = grid1 - grid_searchtol;
int grid_e = grid2 + grid_searchtol;
......
using FLY.Thick.Base.Common;
using FLY.Thick.Base.Server;
using FlyADBase;
using Misc;
using System;
using System.ComponentModel;
namespace FLY.Thick.Base.Server
{
/// <summary>
/// 使用 TimeGridAdv
/// 只是来回走的逻辑,不包含数据处理;
/// 可以设置扫描次数;
/// 0~posLen;
/// 可以显示进度;
/// </summary>
public class ScanMotion2 : INotifyPropertyChanged
{
#region 成员变量
/// <summary>
/// 扫描次数, 当为-1时,无限次扫描,>0时,有限次扫描
/// </summary>
protected int ScanCnt { get; private set; }
/// <summary>
/// 速度
/// </summary>
public UInt32 Velocity { get; private set; }
/// <summary>
/// 完成
/// </summary>
public bool IsFinish { get; private set; }
public int Progress { get; private set; }
public event EndEventHandler EndEvent;
public event PropertyChangedEventHandler PropertyChanged;
#endregion
enum CTRLST
{
/// <summary>
///
/// </summary>
IDLE = 0,
/// <summary>
/// 准备动作:归0
/// </summary>
READY_ORIGIN = 1,
/// <summary>
/// 准备动作:正在归0
/// </summary>
READY_ORIGINWAIT = 2,
/// <summary>
/// 准备动作:后退到 0 脉冲
/// </summary>
READY_BACKW = 3,
/// <summary>
/// 准备动作:正在后退
/// </summary>
READY_BACKWAIT = 4,
/// <summary>
/// 前进到 机架总长
/// </summary>
SFORWARD = 5,
/// <summary>
/// 前进等待
/// </summary>
SFORWAIT_1 = 6,
/// <summary>
/// 前进结束,等待获取grid
/// </summary>
SFORWAIT_2 = 7,
/// <summary>
/// 后退到 0 脉冲
/// </summary>
SBACKWARD = 8,
/// <summary>
/// 后退等待
/// </summary>
SBACKWAIT_1 = 9,
/// <summary>
/// 后退结束,等待获取grid
/// </summary>
SBACKWAIT_2 = 10,
}
CTRLST state;
private int tempDataCnt = 0;
public int CurrCnt => tempDataCnt;
DateTime mStartDataEndTime;
FlyAD7 flyAd;
public ScanMotion2()
{
state = CTRLST.IDLE;
IsFinish = false;
}
public void Init(FlyAD7 flyAd)
{
this.flyAd = flyAd;
this.flyAd.PositionChangedEvent += FlyAd_PositionChangedEvent;
}
private void FlyAd_PositionChangedEvent(object sender, PositionChangedEventArgs e)
{
if (state == CTRLST.SFORWAIT_1)
{
int p = e.Position * 50 / flyAd.PosLen;
Progress = (100 * tempDataCnt + p) / ScanCnt;
}
else if(state == CTRLST.SBACKWAIT_1)
{
int p = (flyAd.PosLen - e.Position) * 50 / flyAd.PosLen;
Progress = (100 * tempDataCnt + 50 + p) / ScanCnt;
}
}
public void Start(int scanCnt, UInt32 velocity)
{
state = CTRLST.READY_ORIGIN;
IsFinish = false;
ScanCnt = scanCnt;
Velocity = velocity;
tempDataCnt = 0;
Progress = 0;
}
/// <summary>
//返回 false, 还没完成, true 已经完成
/// </summary>
/// <returns></returns>
public bool OnPoll()
{
switch (state)
{
case CTRLST.IDLE:
{
return true;
}break;
case CTRLST.READY_ORIGIN:
{
flyAd.SetVelocity(Velocity);
flyAd.Origin();
state = CTRLST.READY_ORIGINWAIT;
}
break;
case CTRLST.READY_ORIGINWAIT:
{
if (!flyAd.IsFinish)
break;
if (flyAd.DriveStatus == DRIVE_MAN_STATUS.STOP_MANUAL)
return true;
state = CTRLST.READY_BACKW;
}
break;
case CTRLST.READY_BACKW:
{
flyAd.RuntoMin();
state = CTRLST.READY_BACKWAIT;
}
break;
case CTRLST.READY_BACKWAIT:
{
if (!flyAd.IsFinish)
break;
if (flyAd.DriveStatus == DRIVE_MAN_STATUS.STOP_MANUAL)
return true;
if (flyAd.IsTimeToPushTimeGridAdv)
break;
state = CTRLST.SFORWARD;
}
break;
case CTRLST.SFORWARD:
{
//记下时间
mStartDataEndTime = flyAd.Now;
flyAd.RuntoMax();
state = CTRLST.SFORWAIT_1;
}
break;
case CTRLST.SFORWAIT_1:
{
if (!flyAd.IsFinish)
break;
if (flyAd.DriveStatus == DRIVE_MAN_STATUS.STOP_MANUAL)
return true;
if (flyAd.IsTimeToPushTimeGridAdv)
break;
FlushAD(DIRECTION.FORWARD);
state = CTRLST.SFORWAIT_2;
}
break;
case CTRLST.SFORWAIT_2:
{
state = CTRLST.SBACKWARD;
}
break;
case CTRLST.SBACKWARD:
{
mStartDataEndTime = flyAd.Now;
flyAd.RuntoMin();
state = CTRLST.SBACKWAIT_1;
}
break;
case CTRLST.SBACKWAIT_1:
{
if (!flyAd.IsFinish)
break;
if (flyAd.DriveStatus == DRIVE_MAN_STATUS.STOP_MANUAL)
return true;
if (flyAd.IsTimeToPushTimeGridAdv)
break;
FlushAD(DIRECTION.BACKWARD);
state = CTRLST.SBACKWAIT_2;
}
break;
case CTRLST.SBACKWAIT_2:
{
state = CTRLST.SFORWARD;
//扫描次数
tempDataCnt++;
if (tempDataCnt>=ScanCnt)
{
//扫描完成
state = CTRLST.IDLE;
IsFinish = true;
return true;
}
}
break;
}
return false;
}
private void FlushAD(Misc.DIRECTION direction)
{
int start_grid = 0;
int end_grid = flyAd.PosLen / flyAd.PosOfGrid;
int gridLen = end_grid - start_grid + 1;
var timeGridAdv2 = flyAd.GetTimeGridAdv2Event(mStartDataEndTime);
var dat = TimeGridAdvHelperExt.ToGrid(timeGridAdv2.AdList, timeGridAdv2.PosList, flyAd.PosOfGrid, gridLen);
EndEvent?.Invoke(this, new MiniGridEventArgs()
{
grid_start = start_grid,
direction = direction,
posOfGrid = flyAd.PosOfGrid,
buf = dat
});
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment