Commit 779567ed authored by 潘栩锋's avatar 潘栩锋 🚴

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

2. 优化 优化线速度 平均值
parent cf57d30d
......@@ -1020,98 +1020,123 @@ namespace FLY.Thick.Blowing.Server
RotationCnt++;
}
}
//void update_roll(FlyADBase.IStatusChangedEventArgs e)
//{
// bool bchanged = false;//信号更新?
// DateTime dt = e.Time;//信号更新发生的时间
// bool status = false;//信号的状态
// //----------------------------------------------------------------------
// //更新辊信号
// if (Misc.MyBase.CHECKBIT(e.IChanged, Roll_bit - 1))
// {
// bchanged = true;
// if (!Misc.MyBase.CHECKBIT(e.IStatus, Roll_bit - 1))
// {
// status = true;
// }
// }
// if (!bchanged)//没有信号更新
// return;
// DateTime dtmid;
// if (mbcRoll.Update(dt, status, out dtmid))
// {
// 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)
{
bool bchanged = false;//信号更新?
DateTime dt = e.Time;//信号更新发生的时间
bool status = false;//信号的状态
//----------------------------------------------------------------------
//更新辊信号
if (Misc.MyBase.CHECKBIT(e.IChanged, Roll_bit - 1))
{
bchanged = true;
if (!Misc.MyBase.CHECKBIT(e.IStatus, Roll_bit - 1))
{
status = true;
}
}
if (!bchanged)//没有信号更新
return;
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
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();
}
......@@ -1136,47 +1161,22 @@ namespace FLY.Thick.Blowing.Server
//--------------------------------------------------------------------
//正反向信号撞两次的超时判断
OnPoll_checkDouble();
//--------------------------------------------------------------------
//旋转架速度安全检测
OnPoll_checkRVelocity();
//--------------------------------------------------------------------
//当前旋转架角度
{
int rotationCnt;
double angle;
bool inCV;
DIRECTION direction;
LimitListSearch(DateTime.Now, false, out angle, out direction, out rotationCnt, out inCV);
Angle = angle;
Direction = direction;
}
OnPoll_updateRV();
//--------------------------------------------------------------------
//线速度安全检测
if (mRollList.Count > 0)
{
DateTime dt = mRollList[mRollList.Count - 1].dt;
TimeSpan ts = DateTime.Now - dt;
if (ts.TotalMinutes > 1)//1min
{
//大于1分钟,也没有一个信号,复位
Clear();
}
}
OnPoll_checkFilmV();
//--------------------------------------------------------------------
//更新当前线速度
if (mRollList.Count > 1)
{
DateTime dt1 = mRollList[mRollList.Count - 1].dt;
DateTime dt2 = mRollList[mRollList.Count - 2].dt;
TimeSpan ts_last = dt1 - dt2;
TimeSpan ts_now = DateTime.Now - dt1;
if (ts_now > (ts_last + ts_last))
{
FilmVelocity = RollPerimeter / 1000.0 / ts_now.TotalMinutes;
}
BufTotalTime = DateTime.Now - mRollList[0].dt;
}
OnPoll_updateFilmV();
}
/// <summary>
/// 虚拟信号添加
......@@ -1266,8 +1266,68 @@ namespace FLY.Thick.Blowing.Server
Clear();
}
}
/// <summary>
/// 更新旋转架速度
/// </summary>
void OnPoll_updateRV()
{
int rotationCnt;
double angle;
bool inCV;
DIRECTION direction;
LimitListSearch(DateTime.Now, false, out angle, out direction, out rotationCnt, out inCV);
Angle = angle;
Direction = direction;
}
/// <summary>
/// 更新当前线速度
/// </summary>
void OnPoll_updateFilmV()
{
if (mRollList.Count > 1)
{
DateTime dt1 = mRollList[mRollList.Count - 1].dt;
int cnt = 5;
if (cnt > mRollList.Count)
cnt = mRollList.Count;
DateTime dt2 = mRollList[mRollList.Count - cnt].dt;
DateTime dt11 = mRollList[mRollList.Count - (cnt - 1)].dt;
TimeSpan ts_last = TimeSpan.FromTicks((dt1 - dt2).Ticks / (cnt - 1));//5次的平均滤波
TimeSpan ts_now = TimeSpan.FromTicks((DateTime.Now - dt11).Ticks / (cnt - 1));
TimeSpan ts_max;
if (ts_now > (ts_last + ts_last))
{
ts_max = ts_now;
}
else
{
ts_max = ts_last;
}
FilmVelocity = RollPerimeter / 1000.0 / ts_max.TotalMinutes;
BufTotalTime = DateTime.Now - mRollList[0].dt;
}
}
/// <summary>
/// 线速度安全检测
/// </summary>
void OnPoll_checkFilmV()
{
if (mRollList.Count > 0)
{
DateTime dt = mRollList[mRollList.Count - 1].dt;
TimeSpan ts = DateTime.Now - dt;
if (ts.TotalMinutes > 1)//1min
{
//大于1分钟,也没有一个信号,复位
Clear();
}
}
}
public void Clear()
{
......
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