Commit 52a2953f authored by 潘栩锋's avatar 潘栩锋 🚴

修复 BlowingDetect 的线速度均值,写错减法方向,导致永远都是从列表的头开始算速度均值

parent e783d927
......@@ -952,42 +952,39 @@ namespace FLY.Thick.Blowing.Server
{
if (mRollList.Count > 1)
{
DateTime sysTime1 = mRollList[mRollList.Count - 1].SysTime;//最后一次的sysTime
int cnt = 5;//5次均值
if (cnt > mRollList.Count)
cnt = mRollList.Count;
//最少2秒
int i_end = mRollList.Count() - 1;
DateTime sysTime2 = mRollList[mRollList.Count - cnt].SysTime;//5次前的sysTime
if (sysTime2 - sysTime1 < TimeSpan.FromSeconds(2))
DateTime time1 = mRollList[i_end].Time;//最后一次的time
int i_begin = i_end - 1;
//最少2秒
while (time1 - mRollList[i_begin].Time < TimeSpan.FromSeconds(2))
{
cnt++;
for (;cnt<= mRollList.Count;cnt++) {
sysTime2 = mRollList[mRollList.Count - cnt].SysTime;
if (sysTime2 - sysTime1 >= TimeSpan.FromSeconds(2)) {
break;
}
i_begin--;
if (i_begin<0)
{
///超范围了
break;
}
if (cnt > mRollList.Count)
cnt = mRollList.Count;
sysTime2 = mRollList[mRollList.Count - cnt].SysTime;
}
if (i_begin < 0)
i_begin = 0 ;//超范围了限制它
var sysTime1 = mRollList[i_begin].SysTime;
var sysTime2 = mRollList[i_end].SysTime;
TimeSpan ts_last = TimeSpan.FromTicks((sysTime1 - sysTime2).Ticks / (cnt - 1));//5次的平均滤波, 使用AD盒的时间算出来的时间差,最准
TimeSpan ts_last = TimeSpan.FromTicks((sysTime2 - sysTime1).Ticks / (i_end - i_begin));//5次的平均滤波, 使用AD盒的时间算出来的时间差,最准
DateTime dt11 = mRollList[mRollList.Count - (cnt - 1)].Time;//4次前的PC时间
//因为没有使用AD盒的时间,所以可以用DateTime.Now 比较
TimeSpan ts_now = TimeSpan.FromTicks((DateTime.Now - dt11).Ticks / (cnt - 1));//使用 电脑的时间,算出来的时间差,大概而已
TimeSpan ts_max;
TimeSpan ts_now = DateTime.Now - time1;//使用 电脑的时间,算出来的时间差,大概而已
TimeSpan ts_max = ts_last;
if (ts_now > (ts_last + ts_last))//超过了2倍的时间,肯定是慢下来了
{
ts_max = ts_now;
}
else
{
ts_max = ts_last;
}
FilmVelocity = MofR / ts_max.TotalMinutes;
......@@ -1980,7 +1977,7 @@ namespace FLY.Thick.Blowing.Server
/// </summary>
public void Dispose()
{
Clear();
ClearBuf();
}
#region INotifyPropertyChanged 成员
......
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