Commit 8593d013 authored by 潘栩锋's avatar 潘栩锋 🚴

1. 修复 AD盒 脉冲速度异常巨大。

2. 优化 AD盒 数据缓存池扩展到2分钟
parent 3c4e414f
...@@ -91,20 +91,6 @@ namespace FlyADBase ...@@ -91,20 +91,6 @@ namespace FlyADBase
this.PropertyChanged += FlyAD7_PropertyChanged1; this.PropertyChanged += FlyAD7_PropertyChanged1;
//更新线速度
PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD,
() =>
{
if (calSpeed.Cal(Now, out int speed1, out int speed2))
{
Speed = speed1;
Speed2 = speed2;
}
}, TimeSpan.FromSeconds(1));
//轮询事件触发 //轮询事件触发
PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD, OnPoll); PollModule.Current.Poll_Config(PollModule.POLL_CONFIG.ADD, OnPoll);
} }
...@@ -361,7 +347,8 @@ namespace FlyADBase ...@@ -361,7 +347,8 @@ namespace FlyADBase
//数据滞后 //数据滞后
if (!TimeGridAdvHelperExt.AdLagCorr(dataList, ref endTime, ADLag, AD2Lag)) if (!TimeGridAdvHelperExt.AdLagCorr(dataList, ref endTime, ADLag, AD2Lag))
{ {
throw new Exception("数据量太少,无法滞后修正"); //throw new Exception("数据量太少,无法滞后修正");
return;
} }
//获取grid图 //获取grid图
...@@ -461,22 +448,42 @@ namespace FlyADBase ...@@ -461,22 +448,42 @@ namespace FlyADBase
if (now - last_now < TimeSpan.FromSeconds(0.5)) if (now - last_now < TimeSpan.FromSeconds(0.5))
return false; return false;
bool isInvalid = false;
if (pos1_changed_time != last_pos1_changed_time && last_pos1_changed_time != DateTime.MinValue) if (pos1_changed_time != last_pos1_changed_time && last_pos1_changed_time != DateTime.MinValue)
{ {
speed1 = (int)((pos1 - last_pos1) / (pos1_changed_time - last_pos1_changed_time).TotalSeconds); var spd = (int)((pos1 - last_pos1) / (pos1_changed_time - last_pos1_changed_time).TotalSeconds);
if (Math.Abs(spd) > 100000)
{
//肯定是溢出了,
isInvalid = true;
}
else
{
speed1 = spd;
}
} }
else else
{ {
//停了 //停了
speed1 = 0;
} }
if (pos2_changed_time != last_pos2_changed_time && last_pos2_changed_time != DateTime.MinValue) if (pos2_changed_time != last_pos2_changed_time && last_pos2_changed_time != DateTime.MinValue)
{ {
speed2 = (int)((pos2 - last_pos2) / (pos2_changed_time - last_pos2_changed_time).TotalSeconds); var spd= (int)((pos2 - last_pos2) / (pos2_changed_time - last_pos2_changed_time).TotalSeconds);
if (Math.Abs(spd) > 100000)
{
//肯定是溢出了,
isInvalid = true;
}
else {
speed2 = spd;
}
} }
else else
{ {
//停了 //停了
speed2 = 0;
} }
last_now = now; last_now = now;
...@@ -485,6 +492,9 @@ namespace FlyADBase ...@@ -485,6 +492,9 @@ namespace FlyADBase
last_pos1 = pos1; last_pos1 = pos1;
last_pos2 = pos2; last_pos2 = pos2;
if (isInvalid)
return false;
else
return true; return true;
} }
......
...@@ -40,7 +40,7 @@ namespace FlyADBase ...@@ -40,7 +40,7 @@ namespace FlyADBase
NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
#region 一分钟数据缓存池, 目标每个AD数据(1ms 都有对应的其它数据 #region 一分钟数据缓存池, 目标每个AD数据(1ms 都有对应的其它数据
public const int POOL_SIZE_SECOND = 120;
/// <summary> /// <summary>
/// AD数据池时间间隔为1ms,数据是肯定是连续的。Add数据时,非连续,填充数据直到连续 /// AD数据池时间间隔为1ms,数据是肯定是连续的。Add数据时,非连续,填充数据直到连续
/// </summary> /// </summary>
...@@ -276,19 +276,19 @@ namespace FlyADBase ...@@ -276,19 +276,19 @@ namespace FlyADBase
return; return;
if (DataPool.Count() < (60 * 1.2) * 1000) if (DataPool.Count() < (POOL_SIZE_SECOND + 30) * 1000)
{ {
//比限定的多了0.2min 才会动作 //比限定的多了30秒 才会动作
return; return;
} }
//只保持1分钟数据 //只保持1分钟数据
int remove_cnt = DataPool.Count() - 60 * 1000; int remove_cnt = DataPool.Count() - POOL_SIZE_SECOND * 1000;
DataPool.RemoveRange(0, remove_cnt); DataPool.RemoveRange(0, remove_cnt);
//限制的时间 //限制的时间
var limitTime_other = NewestTime - TimeSpan.FromMinutes(1.5); var limitTime_other = NewestTime - TimeSpan.FromSeconds(POOL_SIZE_SECOND + 30);
LimitSimplePool(DriveStatusPool, limitTime_other); LimitSimplePool(DriveStatusPool, limitTime_other);
} }
......
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