Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hemei
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
hemei
Commits
779567ed
Commit
779567ed
authored
Aug 22, 2019
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 修复 线速度长时间后 1秒变得很小,1秒又变为正常很大,怀疑线速度智能添加信号 那段出错,直接简化,只用上升沿信号。
2. 优化 优化线速度 平均值
parent
cf57d30d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
171 additions
and
111 deletions
+171
-111
BlowingDetect.cs
...Y.Thick.Blowing/FLY.Thick.Blowing/Server/BlowingDetect.cs
+171
-111
No files found.
Project.FLY.Thick.Blowing/FLY.Thick.Blowing/Server/BlowingDetect.cs
View file @
779567ed
...
@@ -1020,98 +1020,123 @@ namespace FLY.Thick.Blowing.Server
...
@@ -1020,98 +1020,123 @@ namespace FLY.Thick.Blowing.Server
RotationCnt
++;
RotationCnt
++;
}
}
}
}
void
update_roll
(
FlyADBase
.
IStatusChangedEventArgs
e
)
//
void update_roll(FlyADBase.IStatusChangedEventArgs e)
{
//
{
bool
bchanged
=
false
;
//信号更新?
//
bool bchanged = false;//信号更新?
DateTime
dt
=
e
.
Time
;
//信号更新发生的时间
//
DateTime dt = e.Time;//信号更新发生的时间
bool
status
=
false
;
//信号的状态
//
bool status = false;//信号的状态
//----------------------------------------------------------------------
//
//----------------------------------------------------------------------
//更新辊信号
//
//更新辊信号
if
(
Misc
.
MyBase
.
CHECKBIT
(
e
.
IChanged
,
Roll_bit
-
1
))
//
if (Misc.MyBase.CHECKBIT(e.IChanged, Roll_bit - 1))
{
//
{
bchanged
=
true
;
//
bchanged = true;
if
(!
Misc
.
MyBase
.
CHECKBIT
(
e
.
IStatus
,
Roll_bit
-
1
))
//
if (!Misc.MyBase.CHECKBIT(e.IStatus, Roll_bit - 1))
{
//
{
status
=
true
;
//
status = true;
}
//
}
}
//
}
if
(!
bchanged
)
//没有信号更新
//
if (!bchanged)//没有信号更新
return
;
//
return;
DateTime
dtmid
;
//
DateTime dtmid;
if
(
mbcRoll
.
Update
(
dt
,
status
,
out
dtmid
))
//
if (mbcRoll.Update(dt, status, out dtmid))
{
//
{
mRollList
.
RAdd
(
//
mRollList.RAdd(
new
RollCell
()
//
new RollCell()
{
//
{
dt
=
dtmid
//
dt = dtmid
});
//
});
//更新当前线速度
//
//更新当前线速度
if
(
mRollList
.
Count
>
1
)
//
if (mRollList.Count > 1)
{
//
{
DateTime
dt1
=
mRollList
[
mRollList
.
Count
-
1
].
dt
;
//
DateTime dt1 = mRollList[mRollList.Count - 1].dt;
DateTime
dt2
=
mRollList
[
mRollList
.
Count
-
2
].
dt
;
//
DateTime dt2 = mRollList[mRollList.Count - 2].dt;
TimeSpan
ts
=
dt1
-
dt2
;
//
TimeSpan ts = dt1 - dt2;
FilmVelocity
=
RollPerimeter
/
1000.0
/
ts
.
TotalMinutes
;
//
FilmVelocity = RollPerimeter / 1000.0 / ts.TotalMinutes;
if
(
mRollList
.
Count
>
100
)
//
if (mRollList.Count > 100)
{
//
{
DateTime
dtn
=
mRollList
[
mRollList
.
Count
-
101
].
dt
;
//
DateTime dtn = mRollList[mRollList.Count - 101].dt;
TimeSpan
tsn
=
dt1
-
dtn
;
//
TimeSpan tsn = dt1 - dtn;
double
avg_filmvelocity
=
RollPerimeter
/
10.0
/
tsn
.
TotalMinutes
;
//
double avg_filmvelocity = RollPerimeter / 10.0 / tsn.TotalMinutes;
DateTime
dt3
=
mRollList
[
mRollList
.
Count
-
3
].
dt
;
//
DateTime dt3 = mRollList[mRollList.Count - 3].dt;
TimeSpan
ts3
=
dt2
-
dt3
;
//
TimeSpan ts3 = dt2 - dt3;
double
last_filmvelocity
=
RollPerimeter
/
1000.0
/
ts3
.
TotalMinutes
;
//
double last_filmvelocity = RollPerimeter / 1000.0 / ts3.TotalMinutes;
//异常检测
//
//异常检测
if
(
FilmVelocity
>
10
)
//
if (FilmVelocity > 10)
{
//
{
if
(
Math
.
Abs
(
avg_filmvelocity
-
FilmVelocity
)
/
FilmVelocity
>
0.1
)
//
if (Math.Abs(avg_filmvelocity - FilmVelocity) / FilmVelocity > 0.1)
{
//
{
//异常
// //异常
//可能少了信号!!!
// //可能少了信号!!!
if
(
Math
.
Abs
(
last_filmvelocity
-
FilmVelocity
*
2
)
<
0.3
)
// if (Math.Abs(last_filmvelocity - FilmVelocity * 2) < 0.3)
{
// {
TimeSpan
ts12
=
TimeSpan
.
FromTicks
((
dt1
-
dt2
).
Ticks
/
2
);
// TimeSpan ts12 = TimeSpan.FromTicks((dt1 - dt2).Ticks / 2);
//肯定少了一个
// //肯定少了一个
mRollList
.
Insert
(
// mRollList.Insert(
mRollList
.
Count
-
1
,
// mRollList.Count - 1,
new
RollCell
()
// new RollCell()
{
// {
dt
=
dt2
+
ts12
// dt = dt2 + ts12
});
// });
}
// }
else
if
(
Math
.
Abs
(
last_filmvelocity
-
FilmVelocity
*
3
)
<
0.3
)
// 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
)
{
{
TimeSpan
ts12
=
TimeSpan
.
FromTicks
((
dt1
-
dt2
).
Ticks
/
3
);
//----------------------------------------------------------------------
//肯定少了两个
//更新辊信号
mRollList
.
Insert
(
if
(!
Misc
.
MyBase
.
CHECKBIT
(
e
.
IChanged
,
Roll_bit
-
1
))
mRollList
.
Count
-
1
,
return
;
//没有信号更新
new
RollCell
()
//信号的状态
bool
status
=
!
Misc
.
MyBase
.
CHECKBIT
(
e
.
IStatus
,
Roll_bit
-
1
);
DateTime
dt
=
e
.
Time
;
//信号更新发生的时间
if
(
status
)
//1->0 触发!!!
{
{
dt
=
dt2
+
ts12
mRollList
.
RAdd
(
});
mRollList
.
Insert
(
mRollList
.
Count
-
1
,
new
RollCell
()
new
RollCell
()
{
{
dt
=
dt2
+
ts12
+
ts12
dt
=
dt
});
});
}
else
{
}
}
}
}
}
//触发修正事件!!!!!
//触发修正事件!!!!!
TouchFilmInfoChanged
();
TouchFilmInfoChanged
();
}
}
...
@@ -1136,47 +1161,22 @@ namespace FLY.Thick.Blowing.Server
...
@@ -1136,47 +1161,22 @@ namespace FLY.Thick.Blowing.Server
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//正反向信号撞两次的超时判断
//正反向信号撞两次的超时判断
OnPoll_checkDouble
();
OnPoll_checkDouble
();
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//旋转架速度安全检测
//旋转架速度安全检测
OnPoll_checkRVelocity
();
OnPoll_checkRVelocity
();
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//当前旋转架角度
//当前旋转架角度
{
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
;
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//线速度安全检测
//线速度安全检测
if
(
mRollList
.
Count
>
0
)
OnPoll_checkFilmV
();
{
DateTime
dt
=
mRollList
[
mRollList
.
Count
-
1
].
dt
;
TimeSpan
ts
=
DateTime
.
Now
-
dt
;
if
(
ts
.
TotalMinutes
>
1
)
//1min
{
//大于1分钟,也没有一个信号,复位
Clear
();
}
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//更新当前线速度
//更新当前线速度
if
(
mRollList
.
Count
>
1
)
OnPoll_updateFilmV
();
{
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
;
}
}
}
/// <summary>
/// <summary>
/// 虚拟信号添加
/// 虚拟信号添加
...
@@ -1266,8 +1266,68 @@ namespace FLY.Thick.Blowing.Server
...
@@ -1266,8 +1266,68 @@ namespace FLY.Thick.Blowing.Server
Clear
();
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
()
public
void
Clear
()
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment