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

1. 修复 线速度长时间后 1秒变得很小,1秒又变为正常很大,怀疑线速度智能添加信号 那段出错,直接简化,只用上升沿信号。

parent 8e5b98a8
......@@ -257,7 +257,7 @@ namespace FLY.Thick.Blowing.Server
Angle = 0;//°
Direction = Misc.DIRECTION.FORWARD;
FilmVelocity = 0;//m/min
mRollList = new Misc.RList<RollCell>(4000);//以50m/min 线速度,储存大于 30min数据
mLimitList = new Misc.RList<LimitCell>(20);//人字架转10次的信号
......@@ -1018,6 +1018,97 @@ namespace FLY.Thick.Blowing.Server
RotationCnt++;
}
}
//void update_roll(FlyADBase.IStatusChangedEventArgs e)
//{
// //----------------------------------------------------------------------
// //更新辊信号
// if (!Misc.MyBase.CHECKBIT(e.IChanged, Roll_bit - 1))
// return;//没有信号更新
// //信号的状态
// bool status = !Misc.MyBase.CHECKBIT(e.IStatus, Roll_bit - 1);
// DateTime dt = e.Time;//信号更新发生的时间
// DateTime dtmid;
// if (mbcRoll.Update(dt, status, out dtmid))
// if (status)//1->0 触发!!!
// {
// mRollList.RAdd(
// new RollCell()
// {
// dt = dtmid
// });
// //更新当前线速度
// if (mRollList.Count > 1)
// {
// DateTime dt1 = mRollList[mRollList.Count - 1].dt;
// DateTime dt2 = mRollList[mRollList.Count - 2].dt;
// TimeSpan ts = dt1 - dt2;
// FilmVelocity = RollPerimeter / 1000.0 / ts.TotalMinutes;
// if (mRollList.Count > 100)
// {
// DateTime dtn = mRollList[mRollList.Count - 101].dt;
// TimeSpan tsn = dt1 - dtn;
// double avg_filmvelocity = RollPerimeter / 10.0 / tsn.TotalMinutes;
// DateTime dt3 = mRollList[mRollList.Count - 3].dt;
// TimeSpan ts3 = dt2 - dt3;
// double last_filmvelocity = RollPerimeter / 1000.0 / ts3.TotalMinutes;
// //异常检测
// if (FilmVelocity > 10)
// {
// if (Math.Abs(avg_filmvelocity - FilmVelocity) / FilmVelocity > 0.1)
// {
// //异常
// //可能少了信号!!!
// if (Math.Abs(last_filmvelocity - FilmVelocity * 2) < 0.3)
// {
// TimeSpan ts12 = TimeSpan.FromTicks((dt1 - dt2).Ticks / 2);
// //肯定少了一个
// mRollList.Insert(
// mRollList.Count - 1,
// new RollCell()
// {
// dt = dt2 + ts12
// });
// }
// else if (Math.Abs(last_filmvelocity - FilmVelocity * 3) < 0.3)
// {
// TimeSpan ts12 = TimeSpan.FromTicks((dt1 - dt2).Ticks / 3);
// //肯定少了两个
// mRollList.Insert(
// mRollList.Count - 1,
// new RollCell()
// {
// dt = dt2 + ts12
// });
// mRollList.Insert(
// mRollList.Count - 1,
// new RollCell()
// {
// dt = dt2 + ts12 + ts12
// });
// }
// else
// {
// }
// }
// }
// }
// }
// //触发修正事件!!!!!
// TouchFilmInfoChanged();
// }
//}
void update_roll(FlyADBase.IStatusChangedEventArgs e)
{
//----------------------------------------------------------------------
......@@ -1030,79 +1121,15 @@ namespace FLY.Thick.Blowing.Server
DateTime dt = e.Time;//信号更新发生的时间
DateTime dtmid;
if (mbcRoll.Update(dt, status, out dtmid))
if (status)//1->0 触发!!!
{
mRollList.RAdd(
new RollCell()
{
dt = dtmid
dt = dt
});
//更新当前线速度
if (mRollList.Count > 1)
{
DateTime dt1 = mRollList[mRollList.Count - 1].dt;
DateTime dt2 = mRollList[mRollList.Count - 2].dt;
TimeSpan ts = dt1 - dt2;
FilmVelocity = RollPerimeter / 1000.0 / ts.TotalMinutes;
if (mRollList.Count > 100)
{
DateTime dtn = mRollList[mRollList.Count - 101].dt;
TimeSpan tsn = dt1 - dtn;
double avg_filmvelocity = RollPerimeter / 10.0 / tsn.TotalMinutes;
DateTime dt3 = mRollList[mRollList.Count - 3].dt;
TimeSpan ts3 = dt2 - dt3;
double last_filmvelocity = RollPerimeter / 1000.0 / ts3.TotalMinutes;
//异常检测
if (FilmVelocity > 10)
{
if (Math.Abs(avg_filmvelocity - FilmVelocity) / FilmVelocity > 0.1)
{
//异常
//可能少了信号!!!
if (Math.Abs(last_filmvelocity - FilmVelocity * 2) < 0.3)
{
TimeSpan ts12 = TimeSpan.FromTicks((dt1 - dt2).Ticks / 2);
//肯定少了一个
mRollList.Insert(
mRollList.Count - 1,
new RollCell()
{
dt = dt2 + ts12
});
}
else if (Math.Abs(last_filmvelocity - FilmVelocity * 3) < 0.3)
{
TimeSpan ts12 = TimeSpan.FromTicks((dt1 - dt2).Ticks / 3);
//肯定少了两个
mRollList.Insert(
mRollList.Count - 1,
new RollCell()
{
dt = dt2 + ts12
});
mRollList.Insert(
mRollList.Count - 1,
new RollCell()
{
dt = dt2 + ts12 + ts12
});
}
else
{
}
}
}
}
}
//触发修正事件!!!!!
TouchFilmInfoChanged();
}
......@@ -1159,13 +1186,17 @@ namespace FLY.Thick.Blowing.Server
if (mRollList.Count > 1)
{
DateTime dt1 = mRollList[mRollList.Count - 1].dt;
DateTime dt2 = mRollList[mRollList.Count - 2].dt;
TimeSpan ts_last = dt1 - dt2;
int cnt = 5;
if (cnt > mRollList.Count)
cnt = mRollList.Count;
DateTime dt2 = mRollList[mRollList.Count - cnt].dt;
TimeSpan ts_last = TimeSpan.FromTicks((dt1 - dt2).Ticks / (cnt - 1));//5次的平均滤波
TimeSpan ts_now = DateTime.Now - dt1;
if (ts_now > (ts_last + ts_last))
{
FilmVelocity = RollPerimeter / 1000.0 / ts_now.TotalMinutes;
}
TimeSpan ts_max = (ts_now > (ts_last + ts_last)) ? ts_now : ts_last;
FilmVelocity = RollPerimeter / 1000.0 / ts_max.TotalMinutes;
BufTotalTime = DateTime.Now - mRollList[0].dt;
}
}
......
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