Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Thick-Common
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
潘栩锋
Thick-Common
Commits
28b5f8d3
Commit
28b5f8d3
authored
Mar 15, 2022
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getsample 只要任何一个样品点,获取还没成功, 都是采样未完成。 且把上一次采样完成记录下来,用于 比较数据 异常报警用。
parent
d242251b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
185 additions
and
154 deletions
+185
-154
PgGetSample.xaml
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgGetSample.xaml
+1
-41
PgGetSample.xaml.cs
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgGetSample.xaml.cs
+3
-22
IGetSampleService.cs
...Y.Thick.Base/FLY.Thick.Base/IService/IGetSampleService.cs
+0
-11
GetSample.cs
Project.FLY.Thick.Base/FLY.Thick.Base/Server/GetSample.cs
+181
-80
No files found.
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgGetSample.xaml
View file @
28b5f8d3
...
@@ -98,14 +98,6 @@
...
@@ -98,14 +98,6 @@
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Comment}" Text="样品1AD/样品0AD 与上一次比较" />
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Comment}" Text="样品1AD/样品0AD 与上一次比较" />
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
<StackPanel Margin="{StaticResource ControlMargin}">
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Editable}" Text="差异时间范围" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource Styles.Text.FieldContent.Input.Card}" Text="{Binding ErrIntervalMin}" />
<TextBlock Style="{StaticResource Styles.Text.FieldContent.Unit}" Text="min"/>
<TextBlock Style="{StaticResource Styles.Text.FieldHeader.Comment}" Text="两次时间点比较, 时间点的间隔最大时长。 大于它无效,不能比较" />
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
</Border>
</Border>
...
@@ -277,38 +269,6 @@
...
@@ -277,38 +269,6 @@
</StackPanel>
</StackPanel>
</Border>
</Border>
<Border Style="{StaticResource Styles.Card.Border}">
<StackPanel>
<TextBlock Style="{StaticResource Styles.Card.Title}"
Text="采集记录"/>
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource Styles.Button.Square2}" Content="获取" Command="{Binding GetTempDataCmd}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<ItemsControl ItemsSource="{Binding TempData}" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<DataGrid ItemsSource="{Binding .}" IsReadOnly="True" Margin="{StaticResource ControlMargin}" AutoGenerateColumns="False" Width="400" TextBlock.FontSize="12" TextBlock.FontWeight="Normal"
>
<DataGrid.Columns>
<DataGridTextColumn Header="复位" Binding="{Binding IsReset}" Width="100"/>
<DataGridTextColumn Header="时间" Binding="{Binding Time,StringFormat={}{0:HH:mm:ss}}" FontSize="10" Width="100"/>
<DataGridTextColumn Header="AD" Binding="{Binding Ad}" Width="100"/>
<DataGridTextColumn Header="滤波AD" Binding="{Binding FilterAd}" Width="100"/>
</DataGrid.Columns>
</DataGrid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</StackPanel>
</Border>
</StackPanel>
</StackPanel>
</ScrollViewer>
</ScrollViewer>
<Button Style="{StaticResource Styles.Button.Apply}" VerticalAlignment="Bottom" Margin="0,0,20,20"
<Button Style="{StaticResource Styles.Button.Apply}" VerticalAlignment="Bottom" Margin="0,0,20,20"
...
...
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgGetSample.xaml.cs
View file @
28b5f8d3
...
@@ -85,12 +85,6 @@ namespace FLY.Thick.Base.UI
...
@@ -85,12 +85,6 @@ namespace FLY.Thick.Base.UI
/// </summary>
/// </summary>
public
double
CrossErrPercent
{
get
;
set
;
}
public
double
CrossErrPercent
{
get
;
set
;
}
/// <summary>
/// 异常比较 时间间隔范围;
/// 两次时间点比较, 时间点的间隔最大时长。 大于它无效,不能比较
/// </summary>
public
int
ErrIntervalMin
{
get
;
set
;
}
/// <summary>
/// <summary>
/// 参数:样品点参数
/// 参数:样品点参数
/// </summary>
/// </summary>
...
@@ -108,12 +102,11 @@ namespace FLY.Thick.Base.UI
...
@@ -108,12 +102,11 @@ namespace FLY.Thick.Base.UI
#
region
Command
#
region
Command
public
RelayCommand
ApplyCmd
{
get
;
private
set
;
}
public
RelayCommand
ApplyCmd
{
get
;
private
set
;
}
public
RelayCommand
GetTempDataCmd
{
get
;
private
set
;
}
#
endregion
#
endregion
public
event
PropertyChangedEventHandler
PropertyChanged
;
public
event
PropertyChangedEventHandler
PropertyChanged
;
public
List
<
List
<
TempFilterData
>>
TempData
{
get
;
private
set
;
}
public
string
InfoName
{
get
;
set
;
}
public
string
InfoName
{
get
;
set
;
}
IGetSampleService
getSampleService
;
IGetSampleService
getSampleService
;
...
@@ -121,7 +114,6 @@ namespace FLY.Thick.Base.UI
...
@@ -121,7 +114,6 @@ namespace FLY.Thick.Base.UI
public
PgGetSampleVm
()
public
PgGetSampleVm
()
{
{
ApplyCmd
=
new
RelayCommand
(
Apply
);
ApplyCmd
=
new
RelayCommand
(
Apply
);
GetTempDataCmd
=
new
RelayCommand
(
GetTempData
);
}
}
...
@@ -139,7 +131,6 @@ namespace FLY.Thick.Base.UI
...
@@ -139,7 +131,6 @@ namespace FLY.Thick.Base.UI
Misc
.
BindingOperations
.
SetBinding
(
this
.
getSampleService
,
nameof
(
this
.
getSampleService
.
ErrPercent
),
this
,
nameof
(
ErrPercent
));
Misc
.
BindingOperations
.
SetBinding
(
this
.
getSampleService
,
nameof
(
this
.
getSampleService
.
ErrPercent
),
this
,
nameof
(
ErrPercent
));
Misc
.
BindingOperations
.
SetBinding
(
this
.
getSampleService
,
nameof
(
this
.
getSampleService
.
ErrValue
),
this
,
nameof
(
ErrValue
));
Misc
.
BindingOperations
.
SetBinding
(
this
.
getSampleService
,
nameof
(
this
.
getSampleService
.
ErrValue
),
this
,
nameof
(
ErrValue
));
Misc
.
BindingOperations
.
SetBinding
(
this
.
getSampleService
,
nameof
(
this
.
getSampleService
.
CrossErrPercent
),
this
,
nameof
(
CrossErrPercent
));
Misc
.
BindingOperations
.
SetBinding
(
this
.
getSampleService
,
nameof
(
this
.
getSampleService
.
CrossErrPercent
),
this
,
nameof
(
CrossErrPercent
));
Misc
.
BindingOperations
.
SetBinding
(
this
.
getSampleService
,
nameof
(
this
.
getSampleService
.
ErrIntervalMin
),
this
,
nameof
(
ErrIntervalMin
));
Misc
.
BindingOperations
.
SetBinding
(
this
.
getSampleService
,
nameof
(
this
.
getSampleService
.
SearchRange
),
this
,
nameof
(
SearchRange
));
Misc
.
BindingOperations
.
SetBinding
(
this
.
getSampleService
,
nameof
(
this
.
getSampleService
.
SearchRange
),
this
,
nameof
(
SearchRange
));
...
@@ -257,7 +248,7 @@ namespace FLY.Thick.Base.UI
...
@@ -257,7 +248,7 @@ namespace FLY.Thick.Base.UI
this
.
getSampleService
.
ErrPercent
=
this
.
ErrPercent
;
this
.
getSampleService
.
ErrPercent
=
this
.
ErrPercent
;
this
.
getSampleService
.
ErrValue
=
this
.
ErrValue
;
this
.
getSampleService
.
ErrValue
=
this
.
ErrValue
;
this
.
getSampleService
.
CrossErrPercent
=
this
.
CrossErrPercent
;
this
.
getSampleService
.
CrossErrPercent
=
this
.
CrossErrPercent
;
this
.
getSampleService
.
ErrIntervalMin
=
this
.
ErrIntervalMin
;
for
(
int
i
=
0
;
i
<
Samples
.
Count
();
i
++)
for
(
int
i
=
0
;
i
<
Samples
.
Count
();
i
++)
{
{
...
@@ -287,17 +278,7 @@ namespace FLY.Thick.Base.UI
...
@@ -287,17 +278,7 @@ namespace FLY.Thick.Base.UI
TimeSpan
.
FromSeconds
(
2
));
TimeSpan
.
FromSeconds
(
2
));
}
}
private
void
GetTempData
()
{
getSampleService
.
GetTempFilterDatas
((
asyncContext
,
retData
)
=>
{
var
ll
=
retData
as
List
<
List
<
TempFilterData
>>;
TempData
=
ll
;
FLY
.
ControlLibrary
.
Window_Tip
.
Show
(
"加载完成"
,
$"共加载
{
ll
.
Count
()}
列数据"
,
TimeSpan
.
FromSeconds
(
2
));
},
null
);
}
}
}
public
class
PgGetSampleVmUt
:
PgGetSampleVm
public
class
PgGetSampleVmUt
:
PgGetSampleVm
{
{
...
...
Project.FLY.Thick.Base/FLY.Thick.Base/IService/IGetSampleService.cs
View file @
28b5f8d3
...
@@ -61,13 +61,6 @@ namespace FLY.Thick.Base.IService
...
@@ -61,13 +61,6 @@ namespace FLY.Thick.Base.IService
/// </summary>
/// </summary>
double
CrossErrPercent
{
get
;
set
;
}
double
CrossErrPercent
{
get
;
set
;
}
/// <summary>
/// 异常比较 时间间隔范围;
/// 两次时间点比较, 时间点的间隔最大时长。 大于它无效,不能比较
/// </summary>
int
ErrIntervalMin
{
get
;
set
;
}
/// <summary>
/// <summary>
/// 参数:样品点参数
/// 参数:样品点参数
/// </summary>
/// </summary>
...
@@ -191,10 +184,6 @@ namespace FLY.Thick.Base.IService
...
@@ -191,10 +184,6 @@ namespace FLY.Thick.Base.IService
/// </summary>
/// </summary>
public
double
SampleValue
{
get
;
set
;
}
public
double
SampleValue
{
get
;
set
;
}
/// <summary>
/// 采集失败了
/// </summary>
public
bool
IsFailure
{
get
;
set
;
}
#
region
INotifyPropertyChanged
成员
#
region
INotifyPropertyChanged
成员
public
event
PropertyChangedEventHandler
PropertyChanged
;
public
event
PropertyChangedEventHandler
PropertyChanged
;
...
...
Project.FLY.Thick.Base/FLY.Thick.Base/Server/GetSample.cs
View file @
28b5f8d3
...
@@ -70,12 +70,6 @@ namespace FLY.Thick.Base.Server
...
@@ -70,12 +70,6 @@ namespace FLY.Thick.Base.Server
/// </summary>
/// </summary>
public
double
CrossErrPercent
{
get
;
set
;
}
=
0.02
;
public
double
CrossErrPercent
{
get
;
set
;
}
=
0.02
;
/// <summary>
/// 异常比较 时间间隔范围;
/// 两次时间点比较, 时间点的间隔最大时长。 大于它无效,不能比较
/// </summary>
public
int
ErrIntervalMin
{
get
;
set
;
}
=
30
;
/// <summary>
/// <summary>
/// 样品
/// 样品
/// </summary>
/// </summary>
...
@@ -98,9 +92,29 @@ namespace FLY.Thick.Base.Server
...
@@ -98,9 +92,29 @@ namespace FLY.Thick.Base.Server
TempFilter2
[]
tempFilters
;
TempFilter2
[]
tempFilters
;
DIRECTION
[]
directions
;
DIRECTION
[]
directions
;
/// <summary>
/// 采集状态
/// </summary>
public
SampleState
[]
states
;
public
enum
SampleState
{
/// <summary>
/// 准备采集
/// </summary>
ReadyToCapture
,
/// <summary>
/// 采集成功
/// </summary>
Ok
,
/// <summary>
/// 采集失败
/// </summary>
IsFailure
}
IGageInfoService
mGageInfo
;
IGageInfoService
mGageInfo
;
OBJComponents
.
Server
.
WarningSystem2
warningSystem
;
OBJComponents
.
Server
.
WarningSystem2
warningSystem
;
FlyAD7
flyad
;
FlyAD7
flyad
;
SampleData
last_sampleData
;
public
event
SampleChangedEventHandler
SampleChangedEvent
;
public
event
SampleChangedEventHandler
SampleChangedEvent
;
private
string
param_path
;
private
string
param_path
;
...
@@ -119,7 +133,7 @@ namespace FLY.Thick.Base.Server
...
@@ -119,7 +133,7 @@ namespace FLY.Thick.Base.Server
Features
=
new
SampleFeature
[
2
];
Features
=
new
SampleFeature
[
2
];
tempFilters
=
new
TempFilter2
[
Samples
.
Count
()];
tempFilters
=
new
TempFilter2
[
Samples
.
Count
()];
directions
=
new
DIRECTION
[
Samples
.
Count
()];
directions
=
new
DIRECTION
[
Samples
.
Count
()];
states
=
new
SampleState
[
Samples
.
Count
()];
for
(
int
i
=
0
;
i
<
Samples
.
Count
();
i
++)
for
(
int
i
=
0
;
i
<
Samples
.
Count
();
i
++)
tempFilters
[
i
]
=
new
TempFilter2
();
tempFilters
[
i
]
=
new
TempFilter2
();
...
@@ -196,6 +210,7 @@ namespace FLY.Thick.Base.Server
...
@@ -196,6 +210,7 @@ namespace FLY.Thick.Base.Server
/// <param name="scanend"></param>
/// <param name="scanend"></param>
public
virtual
void
Reset
(
int
scanbegin
,
int
scanend
)
public
virtual
void
Reset
(
int
scanbegin
,
int
scanend
)
{
{
last_sampleData
=
null
;
for
(
int
i
=
0
;
i
<
Samples
.
Count
();
i
++)
{
for
(
int
i
=
0
;
i
<
Samples
.
Count
();
i
++)
{
SampleCell
sample
=
Samples
[
i
];
SampleCell
sample
=
Samples
[
i
];
...
@@ -203,24 +218,20 @@ namespace FLY.Thick.Base.Server
...
@@ -203,24 +218,20 @@ namespace FLY.Thick.Base.Server
directions
[
i
]
=
(
Math
.
Abs
(
pos
-
scanbegin
)
<
Math
.
Abs
(
pos
-
scanend
))
?
Misc
.
DIRECTION
.
BACKWARD
:
Misc
.
DIRECTION
.
FORWARD
;
directions
[
i
]
=
(
Math
.
Abs
(
pos
-
scanbegin
)
<
Math
.
Abs
(
pos
-
scanend
))
?
Misc
.
DIRECTION
.
BACKWARD
:
Misc
.
DIRECTION
.
FORWARD
;
sample
.
AD
=
-
1
;
sample
.
AD
=
-
1
;
states
[
i
]
=
SampleState
.
ReadyToCapture
;
tempFilters
[
i
].
Reset
();
tempFilters
[
i
].
Reset
();
}
}
}
}
/// <summary>
/// <summary>
///
///
进入采集周期,设置全部采样点 为准备采集状态
/// </summary>
/// </summary>
public
void
Re
set
()
public
void
Re
adyToCapture
()
{
{
for
(
int
i
=
0
;
i
<
Samples
.
Count
();
i
++)
for
(
int
i
=
0
;
i
<
Samples
.
Count
();
i
++)
{
{
SampleCell
sample
=
Samples
[
i
];
states
[
i
]
=
SampleState
.
ReadyToCapture
;
sample
.
AD
=
-
1
;
tempFilters
[
i
].
Reset
();
}
}
}
}
/// <summary>
/// <summary>
/// 获取样品测量范围
/// 获取样品测量范围
/// </summary>
/// </summary>
...
@@ -414,11 +425,40 @@ namespace FLY.Thick.Base.Server
...
@@ -414,11 +425,40 @@ namespace FLY.Thick.Base.Server
if
((
directions
[
i
]
==
direction
)
&&
(
sample
.
Enable
))
if
((
directions
[
i
]
==
direction
)
&&
(
sample
.
Enable
))
{
{
tempre
.
Reset
();
tempre
.
Reset
();
sample
.
IsFailure
=
true
;
states
[
i
]
=
SampleState
.
IsFailure
;
}
}
}
/// <summary>
/// 设置全部样品为失败
/// </summary>
void
SetFailure
()
{
for
(
int
i
=
0
;
i
<
Samples
.
Count
();
i
++)
{
SampleCell
sample
=
Samples
[
i
];
var
tempre
=
tempFilters
[
i
];
if
(
sample
.
Enable
)
{
tempre
.
Reset
();
states
[
i
]
=
SampleState
.
IsFailure
;
}
}
}
}
}
}
public
bool
HasSampleAd
()
{
for
(
int
i
=
0
;
i
<
Samples
.
Count
();
i
++)
{
SampleCell
sample
=
Samples
[
i
];
if
(
sample
.
Enable
)
{
if
(
sample
.
AD
<=
0
)
return
false
;
}
}
return
true
;
}
enum
GetSampleAdResult
enum
GetSampleAdResult
{
{
OK
,
OK
,
...
@@ -433,11 +473,7 @@ namespace FLY.Thick.Base.Server
...
@@ -433,11 +473,7 @@ namespace FLY.Thick.Base.Server
/// <summary>
/// <summary>
/// 滤波 异常
/// 滤波 异常
/// </summary>
/// </summary>
FilterErr
,
FilterErr
/// <summary>
/// 与上一个比较,变化太大
/// </summary>
TimeCompareErr
}
}
GetSampleAdResult
GetSampleAd
(
SampleCell
sample
,
TempFilter2
tempre
,
int
grid_start
,
int
[]
buf
,
int
grid_offset
,
out
int
ad
)
GetSampleAdResult
GetSampleAd
(
SampleCell
sample
,
TempFilter2
tempre
,
int
grid_start
,
int
[]
buf
,
int
grid_offset
,
out
int
ad
)
{
{
...
@@ -487,21 +523,9 @@ namespace FLY.Thick.Base.Server
...
@@ -487,21 +523,9 @@ namespace FLY.Thick.Base.Server
return
GetSampleAdResult
.
FilterErr
;
return
GetSampleAdResult
.
FilterErr
;
}
}
}
}
//获取以前的Ad
int
lastAd
=
tempre
.
GetLastAd
(
GetErrIntervalTime
);
if
(
lastAd
!=
-
1
)
{
//找到了
diff
=
Math
.
Abs
(
ad
-
lastAd
);
if
(
diff
/
ad
>=
ErrPercent
)
//大于2% 异常
{
return
GetSampleAdResult
.
TimeCompareErr
;
}
}
}
}
return
GetSampleAdResult
.
OK
;
return
GetSampleAdResult
.
OK
;
}
}
DateTime
GetErrIntervalTime
=>
DateTime
.
Now
-
TimeSpan
.
FromMinutes
(
ErrIntervalMin
);
GetSampleAdResult
SetSampleAds
(
Misc
.
DIRECTION
direction
,
int
grid_start
,
int
[]
buf
,
int
grid_offset
)
GetSampleAdResult
SetSampleAds
(
Misc
.
DIRECTION
direction
,
int
grid_start
,
int
[]
buf
,
int
grid_offset
)
{
{
...
@@ -516,7 +540,7 @@ namespace FLY.Thick.Base.Server
...
@@ -516,7 +540,7 @@ namespace FLY.Thick.Base.Server
if
(
ret
==
GetSampleAdResult
.
OK
)
if
(
ret
==
GetSampleAdResult
.
OK
)
{
{
sample
.
AD
=
ad
;
sample
.
AD
=
ad
;
s
ample
.
IsFailure
=
false
;
s
tates
[
i
]
=
SampleState
.
Ok
;
}
}
else
else
{
{
...
@@ -525,35 +549,6 @@ namespace FLY.Thick.Base.Server
...
@@ -525,35 +549,6 @@ namespace FLY.Thick.Base.Server
}
}
}
}
}
}
if
(
Samples
[
0
].
AD
>
0
&&
Samples
[
0
].
IsFailure
==
false
)
{
//交叉比较
for
(
int
i
=
1
;
i
<
Samples
.
Count
();
i
++)
{
SampleCell
sample
=
Samples
[
i
];
if
((
directions
[
i
]
==
direction
)
&&
(
sample
.
Enable
))
{
double
p
=
1.0
*
Samples
[
i
].
AD
/
Samples
[
0
].
AD
;
if
(
p
<=
0
)
break
;
int
lastAdi
=
tempFilters
[
i
].
GetLastAd
(
GetErrIntervalTime
);
int
lastAd0
=
tempFilters
[
0
].
GetLastAd
(
GetErrIntervalTime
);
if
(
lastAd0
==
0
)
break
;
double
last_p
=
1.0
*
lastAdi
/
lastAd0
;
double
diff
=
Math
.
Abs
(
last_p
-
p
);
if
(
diff
/
p
>=
CrossErrPercent
)
//大于2% 异常
{
//TODO
//TODO
return
GetSampleAdResult
.
TimeCompareErr
;
}
}
}
}
return
GetSampleAdResult
.
OK
;
return
GetSampleAdResult
.
OK
;
}
}
/// <summary>
/// <summary>
...
@@ -620,55 +615,150 @@ namespace FLY.Thick.Base.Server
...
@@ -620,55 +615,150 @@ namespace FLY.Thick.Base.Server
{
{
this
.
warningSystem
.
Update
(
this
.
warningSystem
.
Update
(
ERRNOs
.
Instance
.
SAMPLE_ERRNO_Failure
.
Code
,
ERRNOs
.
Instance
.
SAMPLE_ERRNO_Failure
.
Code
,
$"
{
ERRNOs
.
Instance
.
SAMPLE_ERRNO_Failure
.
Descrption
}
:滤波
异常
"
);
$"
{
ERRNOs
.
Instance
.
SAMPLE_ERRNO_Failure
.
Descrption
}
:滤波
数据与原始数据差异
{
ErrPercent
:
P0
}
"
);
}
}
break
;
break
;
}
}
if
(
ret
!=
GetSampleAdResult
.
OK
)
if
(
ret
!=
GetSampleAdResult
.
OK
)
{
{
//有问题,全部复位
//有问题,全部复位
SetFailure
(
direction
);
SetFailure
(
direction
);
}
}
if
(
OK
())
_end
:
{
//全部都采集完成
if
(!
IsErr
())
//没有异常
{
//备份
last_sampleData
=
new
SampleData
();
last_sampleData
.
Time
=
DateTime
.
Now
;
last_sampleData
.
SampleADs
=
new
int
[
Samples
.
Count
()];
for
(
int
i
=
0
;
i
<
Samples
.
Count
();
i
++)
{
last_sampleData
.
SampleADs
[
i
]
=
Samples
[
i
].
AD
;
}
}
}
_end
:
SampleChangedEvent
?.
Invoke
(
this
);
SampleChangedEvent
?.
Invoke
(
this
);
}
}
bool
IsErr
()
{
if
(
last_sampleData
==
null
)
return
false
;
if
(
IsPercentErr
())
{
//历史比较有问题
this
.
warningSystem
.
Update
(
ERRNOs
.
Instance
.
SAMPLE_ERRNO_Failure
.
Code
,
$"
{
ERRNOs
.
Instance
.
SAMPLE_ERRNO_Failure
.
Descrption
}
:样品AD与上次大于
{
ErrPercent
:
P0
}
变化"
);
//设置全部都是异常,重新测量
SetFailure
();
last_sampleData
=
null
;
return
true
;
}
if
(
IsCrossErr
())
{
//交叉比较有问题
this
.
warningSystem
.
Update
(
ERRNOs
.
Instance
.
SAMPLE_ERRNO_Failure
.
Code
,
$"
{
ERRNOs
.
Instance
.
SAMPLE_ERRNO_Failure
.
Descrption
}
:样品比值与上次大于
{
CrossErrPercent
:
P0
}
变化"
);
//设置全部都是异常,重新测量
SetFailure
();
last_sampleData
=
null
;
return
true
;
}
return
false
;
}
/// <summary>
/// <summary>
/// 检测是否成功
/// 检测是否成功
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
public
virtual
bool
OK
()
public
virtual
bool
OK
()
{
return
!
IsFailure
();
}
/// <summary>
/// 刚才报警了,采样失败
/// </summary>
/// <returns></returns>
public
bool
IsFailure
()
{
{
if
(
Enable
)
if
(
Enable
)
{
{
for
each
(
SampleCell
sample
in
Samples
)
for
(
int
i
=
0
;
i
<
Samples
.
Count
();
i
++
)
{
{
SampleCell
sample
=
Samples
[
i
];
if
(
sample
.
Enable
)
if
(
sample
.
Enable
)
{
{
if
((
sample
.
AD
<=
0
))
if
(
states
[
i
]
!=
SampleState
.
Ok
)
return
false
;
return
true
;
}
}
}
}
}
return
false
;
}
}
/// <summary>
/// 全部采集完成,与上次采集比较 大于2% 异常
/// </summary>
/// <returns></returns>
bool
IsPercentErr
()
{
for
(
int
i
=
0
;
i
<
Samples
.
Count
();
i
++)
{
SampleCell
sample
=
Samples
[
i
];
if
(
sample
.
Enable
)
{
int
ad
=
sample
.
AD
;
if
(
ad
<=
0
)
//写错程序
break
;
int
lastAd
=
last_sampleData
.
SampleADs
[
i
];
double
diff
=
Math
.
Abs
(
ad
-
lastAd
);
if
(
diff
/
ad
>
ErrPercent
)
//大于2% 异常
{
return
true
;
return
true
;
}
}
}
}
return
false
;
}
/// <summary>
/// <summary>
///
刚才报警了,采样失败
///
全部采集完成,再做 交叉比较
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
public
bool
IsFailure
()
bool
IsCrossErr
()
{
if
(
Enable
)
{
{
foreach
(
SampleCell
sample
in
Samples
)
//交叉比较
for
(
int
i
=
1
;
i
<
Samples
.
Count
();
i
++)
{
{
SampleCell
sample
=
Samples
[
i
];
if
(
sample
.
Enable
)
if
(
sample
.
Enable
)
{
{
if
((
sample
.
AD
<=
0
)
||
(
sample
.
IsFailure
))
double
p
=
1.0
*
sample
.
AD
/
Samples
[
0
].
AD
;
if
(
p
<=
0
)
//写错程序
break
;
int
lastAdi
=
last_sampleData
.
SampleADs
[
i
];
int
lastAd0
=
last_sampleData
.
SampleADs
[
0
];
if
(
lastAd0
<=
0
)
//写错程序
break
;
double
last_p
=
1.0
*
lastAdi
/
lastAd0
;
double
diff
=
Math
.
Abs
(
last_p
-
p
);
if
(
diff
/
p
>
CrossErrPercent
)
//大于2% 异常
{
return
true
;
return
true
;
}
}
}
}
...
@@ -726,6 +816,18 @@ _end:
...
@@ -726,6 +816,18 @@ _end:
}
}
public
class
SampleData
:
INotifyPropertyChanged
{
public
DateTime
Time
{
get
;
set
;
}
/// <summary>
/// 样品采集AD值
/// </summary>
public
int
[]
SampleADs
{
get
;
set
;
}
public
event
PropertyChangedEventHandler
PropertyChanged
;
}
public
delegate
void
SampleChangedEventHandler
(
GSample
gsample
);
public
delegate
void
SampleChangedEventHandler
(
GSample
gsample
);
public
class
GSampleJsonDb
public
class
GSampleJsonDb
...
@@ -813,7 +915,6 @@ _end:
...
@@ -813,7 +915,6 @@ _end:
public
double
ErrPercent
{
get
;
set
;
}
=
2
;
public
double
ErrPercent
{
get
;
set
;
}
=
2
;
public
int
ErrValue
{
get
;
set
;
}
=
200
;
public
int
ErrValue
{
get
;
set
;
}
=
200
;
public
double
CrossErrPercent
{
get
;
set
;
}
=
0.02
;
public
double
CrossErrPercent
{
get
;
set
;
}
=
0.02
;
public
int
ErrIntervalMin
{
get
;
set
;
}
=
30
;
public
SampleCellParam
[]
Samples
{
get
;
set
;
}
public
SampleCellParam
[]
Samples
{
get
;
set
;
}
public
int
SearchRange
{
get
;
set
;
}
=
100
;
public
int
SearchRange
{
get
;
set
;
}
=
100
;
public
SampleFeatureParam
[]
Features
{
get
;
set
;
}
public
SampleFeatureParam
[]
Features
{
get
;
set
;
}
...
...
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