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
ae600239
Commit
ae600239
authored
Mar 29, 2021
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复 AD盒的时间与电脑时间不一致时,出错
parent
400001aa
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
38 deletions
+80
-38
BlowingDetect.cs
...Y.Thick.Blowing/FLY.Thick.Blowing/Server/BlowingDetect.cs
+10
-3
GM_BlowingFix.cs
...Y.Thick.Blowing/FLY.Thick.Blowing/Server/GM_BlowingFix.cs
+23
-13
GM_BlowingScan.cs
...lowingScan/FLY.Thick.BlowingScan/Server/GM_BlowingScan.cs
+47
-22
No files found.
Project.FLY.Thick.Blowing/FLY.Thick.Blowing/Server/BlowingDetect.cs
View file @
ae600239
...
@@ -424,7 +424,9 @@ namespace FLY.Thick.Blowing.Server
...
@@ -424,7 +424,9 @@ namespace FLY.Thick.Blowing.Server
{
{
bool
bchanged
=
false
;
//信号更新?
bool
bchanged
=
false
;
//信号更新?
DateTime
dt
=
e
.
Time
;
//信号更新发生的时间
//TODO,不使用AD盒的时间
//DateTime dt = e.Time;//信号更新发生的时间
DateTime
dt
=
DateTime
.
Now
;
int
no
=
-
1
;
//信号序号
int
no
=
-
1
;
//信号序号
bool
status
=
false
;
//信号的状态 true开始, false结束
bool
status
=
false
;
//信号的状态 true开始, false结束
...
@@ -912,7 +914,9 @@ namespace FLY.Thick.Blowing.Server
...
@@ -912,7 +914,9 @@ namespace FLY.Thick.Blowing.Server
//信号的状态
//信号的状态
bool
status
=
!
Misc
.
MyBase
.
CHECKBIT
(
e
.
IStatus
,
Roll_bit
-
1
);
bool
status
=
!
Misc
.
MyBase
.
CHECKBIT
(
e
.
IStatus
,
Roll_bit
-
1
);
DateTime
dt
=
e
.
Time
;
//信号更新发生的时间
//TODO,不使用AD盒的时间
//DateTime dt = e.Time;//信号更新发生的时间
DateTime
dt
=
DateTime
.
Now
;
if
(
status
)
//1->0 触发!!!
if
(
status
)
//1->0 触发!!!
...
@@ -1045,7 +1049,7 @@ namespace FLY.Thick.Blowing.Server
...
@@ -1045,7 +1049,7 @@ namespace FLY.Thick.Blowing.Server
else
else
dt
=
lc
.
dt_begin
;
dt
=
lc
.
dt_begin
;
}
}
//因为没有使用AD盒的时间,所以可以用DateTime.Now 比较
PastTime
=
DateTime
.
Now
-
dt
;
PastTime
=
DateTime
.
Now
-
dt
;
if
(
PastTime
>
TimeSpan
.
FromMinutes
(
25
))
//25min
if
(
PastTime
>
TimeSpan
.
FromMinutes
(
25
))
//25min
{
{
...
@@ -1082,6 +1086,8 @@ namespace FLY.Thick.Blowing.Server
...
@@ -1082,6 +1086,8 @@ namespace FLY.Thick.Blowing.Server
DateTime
dt11
=
mRollList
[
mRollList
.
Count
-
(
cnt
-
1
)].
dt
;
DateTime
dt11
=
mRollList
[
mRollList
.
Count
-
(
cnt
-
1
)].
dt
;
TimeSpan
ts_last
=
TimeSpan
.
FromTicks
((
dt1
-
dt2
).
Ticks
/
(
cnt
-
1
));
//5次的平均滤波
TimeSpan
ts_last
=
TimeSpan
.
FromTicks
((
dt1
-
dt2
).
Ticks
/
(
cnt
-
1
));
//5次的平均滤波
//因为没有使用AD盒的时间,所以可以用DateTime.Now 比较
TimeSpan
ts_now
=
TimeSpan
.
FromTicks
((
DateTime
.
Now
-
dt11
).
Ticks
/
(
cnt
-
1
));
TimeSpan
ts_now
=
TimeSpan
.
FromTicks
((
DateTime
.
Now
-
dt11
).
Ticks
/
(
cnt
-
1
));
TimeSpan
ts_max
;
TimeSpan
ts_max
;
if
(
ts_now
>
(
ts_last
+
ts_last
))
if
(
ts_now
>
(
ts_last
+
ts_last
))
...
@@ -1106,6 +1112,7 @@ namespace FLY.Thick.Blowing.Server
...
@@ -1106,6 +1112,7 @@ namespace FLY.Thick.Blowing.Server
if
(
mRollList
.
Count
>
0
)
if
(
mRollList
.
Count
>
0
)
{
{
DateTime
dt
=
mRollList
[
mRollList
.
Count
-
1
].
dt
;
DateTime
dt
=
mRollList
[
mRollList
.
Count
-
1
].
dt
;
//因为没有使用AD盒的时间,所以可以用DateTime.Now 比较
TimeSpan
ts
=
DateTime
.
Now
-
dt
;
TimeSpan
ts
=
DateTime
.
Now
-
dt
;
if
(
ts
.
TotalMinutes
>
1
)
//1min
if
(
ts
.
TotalMinutes
>
1
)
//1min
{
{
...
...
Project.FLY.Thick.Blowing/FLY.Thick.Blowing/Server/GM_BlowingFix.cs
View file @
ae600239
...
@@ -660,6 +660,8 @@ namespace FLY.Thick.Blowing.Server
...
@@ -660,6 +660,8 @@ namespace FLY.Thick.Blowing.Server
void
mPDetect_ClearEvent
(
object
sender
)
void
mPDetect_ClearEvent
(
object
sender
)
{
{
//没信号,清空所有数据!!!
//没信号,清空所有数据!!!
Clear
();
}
}
/// <summary>
/// <summary>
/// 从1幅数据,获取头部,尾部,为于 ADList 的位置
/// 从1幅数据,获取头部,尾部,为于 ADList 的位置
...
@@ -894,18 +896,28 @@ namespace FLY.Thick.Blowing.Server
...
@@ -894,18 +896,28 @@ namespace FLY.Thick.Blowing.Server
TimeSpan
datOf1s_ts
=
TimeSpan
.
Zero
;
TimeSpan
datOf1s_ts
=
TimeSpan
.
Zero
;
TimeSpan
datOf1s_interval
=
TimeSpan
.
FromSeconds
(
1
);
TimeSpan
datOf1s_interval
=
TimeSpan
.
FromSeconds
(
1
);
List
<
int
>
datOf1s
=
new
List
<
int
>();
List
<
int
>
datOf1s
=
new
List
<
int
>();
//1秒数据缓存,用于求均值
void
ClearDatOf1s
()
{
datOf1s_ts
=
TimeSpan
.
Zero
;
datOf1s
.
Clear
();
}
void
flyad_TimeGridEvent
(
object
sender
,
FlyADBase
.
TimeGridEventArgs
e
)
void
flyad_TimeGridEvent
(
object
sender
,
FlyADBase
.
TimeGridEventArgs
e
)
{
{
bool
issample
=
false
;
bool
issample
=
false
;
TimeSpan
ts
=
e
.
Ts
;
//准确
TimeSpan
ts
=
e
.
Ts
;
//准确
//不使用AD盒的时间
//DateTime dt = e.Time;//准确
DateTime
dt
=
DateTime
.
Now
;
//数据的尾
DateTime
dt
=
e
.
Time
;
//准确
int
[]
data
=
e
.
Data
;
int
[]
data
=
e
.
Data
;
//这个数据包的总耗时
TimeSpan
data_interval
=
TimeSpan
.
FromTicks
((
long
)(
ts
.
TotalMilliseconds
*
data
.
Count
()
*
TimeSpan
.
TicksPerMillisecond
));
DateTime
datOf100ms_dt
=
DateTime
.
MinValue
;
//这个数据包开始的时间
DateTime
data_begin_dt
=
dt
-
data_interval
;
//当前循环处理的数据
DateTime
datOf100ms_dt
=
data_begin_dt
-
ts
;
for
(
int
i
=
0
;
i
<
data
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
data
.
Length
;
i
++)
{
{
if
(
issample
)
//采样中,数据都是无效的
if
(
issample
)
//采样中,数据都是无效的
...
@@ -925,23 +937,19 @@ namespace FLY.Thick.Blowing.Server
...
@@ -925,23 +937,19 @@ namespace FLY.Thick.Blowing.Server
datOf1s
.
Add
(
data
[
i
]);
datOf1s
.
Add
(
data
[
i
]);
}
}
datOf1s_ts
=
datOf1s_ts
+
ts
;
if
(
datOf100ms_dt
==
DateTime
.
MinValue
)
datOf100ms_dt
=
dt
;
datOf1s_ts
=
datOf1s_ts
+
ts
;
else
datOf100ms_dt
=
datOf100ms_dt
+
ts
;
datOf100ms_dt
=
datOf100ms_dt
+
ts
;
if
(
datOf1s_ts
>=
datOf1s_interval
)
//1s 一个数据
if
(
datOf1s_ts
>=
datOf1s_interval
)
//1s 一个数据
{
{
datOf1s_ts
=
datOf1s_ts
-
datOf1s_interval
;
int
avgad
=
Misc
.
MyBase
.
NULL_VALUE
;
int
avgad
=
Misc
.
MyBase
.
NULL_VALUE
;
if
(
datOf1s
.
Count
()
>
0
)
if
(
datOf1s
.
Count
()
>
0
)
{
{
avgad
=
Misc
.
MyMath
.
Avg
(
datOf1s
.
ToArray
());
avgad
=
Misc
.
MyMath
.
Avg
(
datOf1s
);
datOf1s
.
Clear
();
}
}
else
if
(
mADList
.
Count
()
>
0
)
else
if
(
mADList
.
Count
()
>
0
)
{
{
...
@@ -956,6 +964,7 @@ namespace FLY.Thick.Blowing.Server
...
@@ -956,6 +964,7 @@ namespace FLY.Thick.Blowing.Server
Ad
=
avgad
Ad
=
avgad
});
});
ClearDatOf1s
();
}
}
}
}
}
}
...
@@ -984,6 +993,7 @@ namespace FLY.Thick.Blowing.Server
...
@@ -984,6 +993,7 @@ namespace FLY.Thick.Blowing.Server
{
{
mFrameInfoList
.
Clear
();
mFrameInfoList
.
Clear
();
}
}
ClearDatOf1s
();
}
}
int
Angle2BoltIndex
(
double
angle
)
int
Angle2BoltIndex
(
double
angle
)
...
...
Project.FLY.Thick.BlowingScan/FLY.Thick.BlowingScan/Server/GM_BlowingScan.cs
View file @
ae600239
...
@@ -2004,37 +2004,70 @@ namespace FLY.Thick.BlowingScan.Server
...
@@ -2004,37 +2004,70 @@ namespace FLY.Thick.BlowingScan.Server
/// </summary>
/// </summary>
class
PosCell
class
PosCell
{
{
public
DateTime
dt
;
public
DateTime
sysTime
;
public
int
position
;
public
int
position
;
public
override
string
ToString
()
public
override
string
ToString
()
{
{
return
dt
.
ToString
()
+
" pos="
+
position
.
ToString
()
;
return
$"
{
sysTime
}
pos=
{
position
}
"
;
}
}
}
}
class
PosCellList
class
PosCellList
{
{
public
int
scanNo
;
/// <summary>
/// 这次扫描 的开始电脑时间
/// </summary>
public
DateTime
beginTime
;
/// <summary>
/// 这次扫描 的开始AD盒时间
/// </summary>
public
DateTime
beginSysTime
;
/// <summary>
/// 扫描号
/// </summary>
public
int
ScanNo
{
get
;
private
set
;
}
public
PosCellList
(
int
scanNo
,
DateTime
beginTime
,
DateTime
beginSysTime
)
{
this
.
ScanNo
=
scanNo
;
this
.
beginSysTime
=
beginSysTime
;
this
.
beginTime
=
beginTime
;
}
private
List
<
PosCell
>
mPosList
=
new
List
<
PosCell
>();
private
List
<
PosCell
>
mPosList
=
new
List
<
PosCell
>();
public
void
Add
(
int
position
,
DateTime
dt
)
/// <summary>
///
/// </summary>
/// <param name="position">脉冲</param>
/// <param name="systime">AD盒的时间,用于时间偏移量</param>
/// <param name="dt">电脑的时间</param>
public
void
Add
(
int
position
,
DateTime
systime
)
{
{
if
(
mPosList
.
Count
()
==
0
)
{
mPosList
.
Add
(
new
PosCell
()
{
position
=
position
,
sysTime
=
systime
});
return
;
}
if
(
mPosList
.
Count
()
>
0
)
if
(
mPosList
.
Count
()
>
0
)
{
{
if
(
mPosList
.
Last
().
position
==
position
)
if
(
mPosList
.
Last
().
position
==
position
)
{
{
mPosList
.
Last
().
dt
=
dt
;
mPosList
.
Last
().
sysTime
=
systime
;
return
;
return
;
}
}
else
{
mPosList
.
Add
(
new
PosCell
()
{
position
=
position
,
sysTime
=
systime
});
}
}
}
mPosList
.
Add
(
new
PosCell
()
{
position
=
position
,
dt
=
dt
});
}
}
private
DateTime
GetTime
(
int
position
,
int
idx
)
private
DateTime
GetTime
(
int
position
,
int
idx
)
{
{
var
timeOffset
=
beginTime
-
beginSysTime
;
double
d_pos
=
mPosList
[
idx
].
position
-
mPosList
[
idx
+
1
].
position
;
double
d_pos
=
mPosList
[
idx
].
position
-
mPosList
[
idx
+
1
].
position
;
TimeSpan
ts
=
mPosList
[
idx
].
dt
-
mPosList
[
idx
+
1
].
dt
;
TimeSpan
ts
=
mPosList
[
idx
].
sysTime
-
mPosList
[
idx
+
1
].
sysTime
;
long
ticks
=
(
long
)((
position
-
mPosList
[
idx
+
1
].
position
)
/
d_pos
*
ts
.
Ticks
);
long
ticks
=
(
long
)((
position
-
mPosList
[
idx
+
1
].
position
)
/
d_pos
*
ts
.
Ticks
);
return
mPosList
[
idx
+
1
].
dt
+
new
TimeSpan
(
ticks
)
;
return
mPosList
[
idx
+
1
].
sysTime
+
new
TimeSpan
(
ticks
)
+
timeOffset
;
}
}
/// <summary>
/// <summary>
/// 获取位置对应的数据点.
/// 获取位置对应的数据点.
...
@@ -2120,7 +2153,7 @@ namespace FLY.Thick.BlowingScan.Server
...
@@ -2120,7 +2153,7 @@ namespace FLY.Thick.BlowingScan.Server
if
(
mPosLists
.
Count
==
0
)
//没数据
if
(
mPosLists
.
Count
==
0
)
//没数据
return
;
return
;
int
index
=
mPosLists
.
FindIndex
(
pl
=>
pl
.
s
canNo
==
scanNo
);
int
index
=
mPosLists
.
FindIndex
(
pl
=>
pl
.
S
canNo
==
scanNo
);
if
(
index
==
-
1
)
if
(
index
==
-
1
)
return
;
//可能还没出现
return
;
//可能还没出现
index
+=
offset
;
index
+=
offset
;
...
@@ -2145,26 +2178,18 @@ namespace FLY.Thick.BlowingScan.Server
...
@@ -2145,26 +2178,18 @@ namespace FLY.Thick.BlowingScan.Server
{
{
PosCellList
poslist
;
PosCellList
poslist
;
if
(
mPosLists
.
Count
==
0
)
if
(
mPosLists
.
Count
==
0
)
mPosLists
.
Add
(
new
PosCellList
(
)
{
scanNo
=
ScanNo
}
);
mPosLists
.
Add
(
new
PosCellList
(
ScanNo
,
DateTime
.
Now
,
e
.
Time
)
);
else
else
{
{
poslist
=
mPosLists
.
Last
();
poslist
=
mPosLists
.
Last
();
if
(
poslist
.
s
canNo
!=
ScanNo
)
if
(
poslist
.
S
canNo
!=
ScanNo
)
{
{
mPosLists
.
Add
(
new
PosCellList
(
)
{
scanNo
=
ScanNo
}
);
mPosLists
.
Add
(
new
PosCellList
(
ScanNo
,
DateTime
.
Now
,
e
.
Time
)
);
}
}
}
}
poslist
=
mPosLists
.
Last
();
poslist
=
mPosLists
.
Last
();
poslist
.
Add
(
e
.
Position
,
e
.
Time
);
poslist
.
Add
(
e
.
Position
,
e
.
Time
);
//保持20个
//if (mPosLists.Count() > 20)
//{
// mPosLists.RemoveAt(0);
//}
}
}
...
@@ -2189,7 +2214,7 @@ namespace FLY.Thick.BlowingScan.Server
...
@@ -2189,7 +2214,7 @@ namespace FLY.Thick.BlowingScan.Server
if
(
mPosLists
.
Count
==
0
)
//没数据
if
(
mPosLists
.
Count
==
0
)
//没数据
return
1
;
return
1
;
int
d
=
scanNo
-
mPosLists
[
0
].
s
canNo
;
int
d
=
scanNo
-
mPosLists
[
0
].
S
canNo
;
if
(
d
<
0
)
if
(
d
<
0
)
{
{
//发生在过去
//发生在过去
...
@@ -2197,7 +2222,7 @@ namespace FLY.Thick.BlowingScan.Server
...
@@ -2197,7 +2222,7 @@ namespace FLY.Thick.BlowingScan.Server
return
-
2
;
return
-
2
;
}
}
int
index
=
mPosLists
.
FindIndex
(
pl
=>
pl
.
s
canNo
==
scanNo
);
int
index
=
mPosLists
.
FindIndex
(
pl
=>
pl
.
S
canNo
==
scanNo
);
if
(
index
==
-
1
)
if
(
index
==
-
1
)
return
1
;
//可能还没出现
return
1
;
//可能还没出现
...
...
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