Commit 0d29afc4 authored by 潘栩锋's avatar 潘栩锋 🚴

删除 flyad2021.B2 grid 获取功能。 grid图的组装,完全使用 TimeGridAdvHelper 解决

parent 5084d3eb
......@@ -236,7 +236,7 @@ namespace FlyADBase
public DRIVE_MAN_STATUS DriveStatus { get; set; } = DRIVE_MAN_STATUS.STOP;
/// <summary>
/// timegrid 事件; 版本1: 1.28s 一次; 版本2: 0.2s一次,
/// timegrid 事件; 大约0.1s更新一次
/// ad值不会被机架修正
/// </summary>
public event TimeGridEventHandler TimeGridEvent;
......@@ -246,11 +246,6 @@ namespace FlyADBase
/// </summary>
public event MiniGridEventHandler MiniGridEvent;
/// <summary>
/// runto 的 grid事件
/// </summary>
public event MiniGridEventHandler GridEvent;
/// <summary>
/// 输入状态改变事件
/// </summary>
......
......@@ -91,13 +91,8 @@ namespace FlyADBase
DateTime lastGridTime;
Stopwatch stopwatch_gridTime = new Stopwatch();
SGrid fGrid1 = new SGrid();
SGrid fGrid2 = new SGrid();
void advConstructor()
{
fGrid1.SetSize(GridLen);
fGrid2.SetSize(GridLen);
mTimeGridAdvHelper.Init();
this.PropertyChanged += FlyAD7_PropertyChanged1;
......@@ -135,12 +130,6 @@ namespace FlyADBase
break;
}
}
else if ((e.PropertyName == nameof(PosLen)) ||
(e.PropertyName == nameof(PosOfGrid)))
{
fGrid1.SetSize(GridLen);
fGrid2.SetSize(GridLen);
}
}
void advAfterContected()
......@@ -199,68 +188,6 @@ namespace FlyADBase
}
}
/// <summary>
/// 从正反缓存区, 获取grid数据
/// </summary>
/// <param name="direction">方向, 只有 正,反</param>
/// <param name="grid_start">grid 开始位置</param>
/// <param name="grid_len">grid 长度</param>
/// <param name="dat">grid 数据</param>
public void GetGrid(Misc.DIRECTION direction, int grid_start, int grid_len, out int[] dat, out int[] dat2)
{
int index = 0;
if (direction == Misc.DIRECTION.BACKWARD)
index = 1;
dat = new int[grid_len];
dat2 = new int[grid_len];
for (int i = 0; i < dat.Length; i++)
{
int grid_num = grid_start + i;
if (grid_num >= fGrid1.data[index].Length)
break;
if (GridSmooth > 0)
{
int sum = 0;
int cnt = 0;
for (int j = 0; j < (GridSmooth * 2 + 1); j++)
{
int idx = grid_num - GridSmooth + j;
if (idx < 0)
continue;
if (idx >= fGrid1.data[index].Length)
break;
if (Misc.MyBase.ISVALIDATA(fGrid1.data[index][idx]))
{
sum += fGrid1.data[index][idx];
cnt++;
}
}
if (cnt > 0)
dat[i] = sum / cnt;
else
dat[i] = Misc.MyBase.NULL_VALUE;
}
else
{
dat[i] = fGrid1.data[index][grid_num];
}
}
return;
}
/// <summary>
/// 从正反缓存区, 获取全部grid数据
/// </summary>
/// <param name="direction">方向, 只有 正,反</param>
/// <param name="dat">grid 数据</param>
public void GetGrid(Misc.DIRECTION direction, out int[] dat, out int[] dat2)
{
GetGrid(direction, 0, fGrid1.data[0].Length, out dat, out dat2);
}
#endregion
......@@ -366,20 +293,20 @@ namespace FlyADBase
}
if (Now - lastUpdateADTime < TimeSpan.FromSeconds(0.2))
if (Now - lastUpdateADTime < TimeSpan.FromSeconds(0.1))
return;
//获取0.2s到现在的数据
//获取0.1s到现在的数据
var dataList = mTimeGridAdvHelper.GetData(lastUpdateADTime);
//算AD均值
int[] ad1s = dataList.Select(d => d.ad).ToArray();
int[] ad2s = dataList.Select(d => d.ad2).ToArray();
int ad = (int)(ad1s.Average());
int ad = (int)ad1s.Average();
AD = ad;
int ad2 = (int)(ad2s.Average());
int ad2 = (int)ad2s.Average();
AD2 = ad2;
//推送timegrid事件
......@@ -417,7 +344,7 @@ namespace FlyADBase
}
return;
}
if (stopwatch_gridTime.Elapsed < TimeSpan.FromSeconds(0.2))
if (stopwatch_gridTime.Elapsed < TimeSpan.FromSeconds(0.1))
{
//太快,控制推送频率
return;
......@@ -449,58 +376,6 @@ namespace FlyADBase
if (grid_start >= GridLen)
return;
int index = (direction == Misc.DIRECTION.BACKWARD) ? 1 : 0;
if (grid_end >= GridLen)
grid_end = GridLen - 1;
int len = grid_end - grid_start + 1;
var grid_data1 = fGrid1.data[index];
var grid_data2 = fGrid2.data[index];
Array.Copy(gridsOfAd1, 0, grid_data1, grid_start, len);
Array.Copy(gridsOfAd2, 0, grid_data2, grid_start, len);
//清空后面的数据
if (direction == Misc.DIRECTION.BACKWARD)
{
if (grid_data1[0] != Misc.MyBase.NULL_VALUE)
{
for (int i = 0; i < grid_start; i++)
{
grid_data1[i] = Misc.MyBase.NULL_VALUE;
}
}
if (grid_data2[0] != Misc.MyBase.NULL_VALUE)
{
for (int i = 0; i < grid_start; i++)
{
grid_data2[i] = Misc.MyBase.NULL_VALUE;
}
}
}
else
{
if (grid_data1.Last() != Misc.MyBase.NULL_VALUE)
{
for (int i = (grid_end + 1); i < grid_data1.Length; i++)
{
grid_data1[i] = Misc.MyBase.NULL_VALUE;
}
}
if (grid_data2.Last() != Misc.MyBase.NULL_VALUE)
{
for (int i = (grid_end + 1); i < grid_data2.Length; i++)
{
grid_data2[i] = Misc.MyBase.NULL_VALUE;
}
}
}
//需要推送grid
MiniGridEvent?.Invoke(this, new MiniGridEventArgs()
{
......@@ -544,13 +419,6 @@ namespace FlyADBase
out int grid_start, out int grid_end,
out int[] gridsOfAd1, out int[] gridsOfAd2);
//放入对应方向缓存区
int index = (direction == Misc.DIRECTION.BACKWARD) ? 1 : 0;
Array.Copy(gridsOfAd1, 0, fGrid1.data[index], 0, GridLen);
Array.Copy(gridsOfAd2, 0, fGrid2.data[index], 0, GridLen);
//触发事件
TimeGridAdv2Event?.Invoke(this, new TimeGridAdv2EventArgs
{
......@@ -558,15 +426,6 @@ namespace FlyADBase
EndTime = endTime,
DataList= dataList
});
GridEvent?.Invoke(this, new MiniGridEventArgs()
{
direction = direction,
buf = gridsOfAd1,
buf2= gridsOfAd2,
posOfGrid = PosOfGrid,
grid_start = 0
});
}
}
......
......@@ -212,11 +212,6 @@ namespace FlyADBase
/// </summary>
event MiniGridEventHandler MiniGridEvent;
/// <summary>
/// runto 的 grid事件
/// </summary>
event MiniGridEventHandler GridEvent;
/// <summary>
/// 输入状态改变事件
/// </summary>
......
......@@ -67,29 +67,11 @@ namespace FlyADBase
/// <param name="is1"></param>
void SetOutputBit(int index, bool is1);
/// <summary>
/// 从正反缓存区, 获取grid数据
/// </summary>
/// <param name="direction">方向, 只有 正,反</param>
/// <param name="grid_start">grid 开始位置</param>
/// <param name="grid_len">grid 长度</param>
/// <param name="dat">grid 数据</param>
void GetGrid(DIRECTION direction, int grid_start, int grid_len, out int[] dat, out int[] dat2);
/// <summary>
/// 从正反缓存区, 获取全部grid数据
/// </summary>
/// <param name="direction">方向, 只有 正,反</param>
/// <param name="dat">grid 数据</param>
void GetGrid(DIRECTION direction, out int[] dat, out int[] dat2);
/// <summary>
/// 动作完成
/// </summary>
bool IsFinish { get; }
/// <summary>
/// ad滞后修正 单位ms
/// </summary>
......
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