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
97495615
Commit
97495615
authored
May 18, 2020
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化 边界查找界面图更新问题
parent
1abec169
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
305 additions
and
265 deletions
+305
-265
ConnContext.cs
Project.FLY.FObjSys/FObjSys/ConnContext.cs
+25
-0
PgBorderSearch.xaml
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgBorderSearch.xaml
+24
-2
PgBorderSearch.xaml.cs
...t.FLY.Thick.Base/FLY.Thick.Base.UI/PgBorderSearch.xaml.cs
+41
-17
PgGageInfo.xaml.cs
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgGageInfo.xaml.cs
+6
-3
BorderSearchServiceClient.cs
...k.Base/FLY.Thick.Base/Client/BorderSearchServiceClient.cs
+42
-62
IBorderSearchService.cs
...hick.Base/FLY.Thick.Base/IService/IBorderSearchService.cs
+55
-30
BORDERSEARCH_OBJ_INTERFACE.cs
...LY.Thick.Base/OBJ_INTERFACE/BORDERSEARCH_OBJ_INTERFACE.cs
+36
-35
BorderSearch_OBJProxy.cs
...e/FLY.Thick.Base/Server.OBJProxy/BorderSearch_OBJProxy.cs
+33
-84
BorderSearch.cs
Project.FLY.Thick.Base/FLY.Thick.Base/Server/BorderSearch.cs
+35
-17
BorderSearchPlastic.cs
...Y.Thick.Base/FLY.Thick.Base/Server/BorderSearchPlastic.cs
+8
-15
No files found.
Project.FLY.FObjSys/FObjSys/ConnContext.cs
View file @
97495615
...
...
@@ -30,4 +30,29 @@ namespace FObjBase
}
public
delegate
void
AsyncCBHandler
(
object
asyncContext
,
object
retData
);
/// <summary>
/// 异步回调
/// </summary>
public
class
AsyncCbAttribute
:
Attribute
{
/// <summary>
/// 返回的数据类型
/// </summary>
public
Type
RetType
{
get
;
private
set
;
}
/// <summary>
/// 无数据返回
/// </summary>
public
AsyncCbAttribute
()
{
}
/// <summary>
///
/// </summary>
/// <param name="retType"></param>
public
AsyncCbAttribute
(
Type
retType
)
{
RetType
=
retType
;
}
}
}
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgBorderSearch.xaml
View file @
97495615
...
...
@@ -5,9 +5,11 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:Chr="clr-namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.DataVisualization"
xmlns:local ="clr-namespace:FLY.Thick.Base.UI"
xmlns:misc="clr-namespace:Misc;assembly=MISC"
mc:Ignorable="d"
d:DesignHeight="727" d:DesignWidth="1280"
d:DataContext="{d:DesignInstance local:PgBorderSearchVm}"
x:Name="root"
Background="WhiteSmoke"
Title="Page_BorderSearch">
<Page.Resources>
...
...
@@ -203,7 +205,17 @@
</Grid.RowDefinitions>
<WrapPanel Grid.Column="1" Orientation="Horizontal">
<StackPanel Margin="5">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeader}" Text="正向边界" />
<TextBlock Text="正向边界" >
<TextBlock.Style>
<Style TargetType="TextBlock" BasedOn="{StaticResource TextBlockStyle_FieldHeader}">
<Style.Triggers>
<DataTrigger Binding="{Binding DataContext.Direction,ElementName=root}" Value="{x:Static misc:DIRECTION.FORWARD}">
<Setter Property="Foreground" Value="Red"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}">
<Run Text="{Binding Border_Forw.Begin, Converter={StaticResource intconv}, Mode=OneWay}"/>
...
...
@@ -232,7 +244,17 @@
</StackPanel>
<StackPanel Margin="5">
<TextBlock Style="{StaticResource TextBlockStyle_FieldHeader}" Text="反向边界" />
<TextBlock Text="反向边界" >
<TextBlock.Style>
<Style TargetType="TextBlock" BasedOn="{StaticResource TextBlockStyle_FieldHeader}">
<Style.Triggers>
<DataTrigger Binding="{Binding DataContext.Direction,ElementName=root}" Value="{x:Static misc:DIRECTION.BACKWARD}">
<Setter Property="Foreground" Value="Red"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
<StackPanel Orientation="Horizontal">
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent}">
<Run Text="{Binding Border_Backw.Begin, Converter={StaticResource intconv}, Mode=OneWay}"/>
...
...
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgBorderSearch.xaml.cs
View file @
97495615
...
...
@@ -21,6 +21,7 @@ using FLY.Thick.Base.IService;
using
System.ComponentModel
;
using
Misc
;
using
GalaSoft.MvvmLight.Command
;
using
FLY.Thick.Base.Server
;
namespace
FLY.Thick.Base.UI
{
...
...
@@ -175,10 +176,10 @@ namespace FLY.Thick.Base.UI
}
[
InjectionMethod
]
public
void
Init
(
IBorderSearchService
borderSearchService
,
IInitParamService
initParamService
)
public
void
Init
(
IBorderSearchService
borderSearchService
,
IInitParamService
initParamService
,
IDynAreaService
dynAreaService
)
{
viewModel
=
new
PgBorderSearchVm
();
viewModel
.
Init
(
borderSearchService
,
initParamService
,
chart1
);
viewModel
.
Init
(
borderSearchService
,
initParamService
,
dynAreaService
,
chart1
);
this
.
DataContext
=
viewModel
;
}
...
...
@@ -189,6 +190,7 @@ namespace FLY.Thick.Base.UI
#
region
延时推送
MARKNO
const
int
MARKNO_UPDATE_BORDER
=
0
;
const
int
MARKNO_UPDATE_DATAS
=
1
;
#
endregion
public
event
PropertyChangedEventHandler
PropertyChanged
;
...
...
@@ -255,8 +257,11 @@ namespace FLY.Thick.Base.UI
public
RelayCommand
ApplyCmd
{
get
;
private
set
;
}
#
endregion
public
Misc
.
DIRECTION
Direction
{
get
;
private
set
;
}
=
DIRECTION
.
FIX
;
public
IBorderSearchService
BorderSearchService
{
get
;
private
set
;
}
public
IInitParamService
InitParamService
{
get
;
private
set
;
}
IDynAreaService
dynAreaService
;
BorderSearchGetViewReponse
getViewReponse
;
System
.
Windows
.
Forms
.
DataVisualization
.
Charting
.
Chart
chart1
;
public
PgBorderSearchVm
()
...
...
@@ -268,10 +273,12 @@ namespace FLY.Thick.Base.UI
public
void
Init
(
IBorderSearchService
borderSearchService
,
IInitParamService
initParamService
,
IDynAreaService
dynAreaService
,
System
.
Windows
.
Forms
.
DataVisualization
.
Charting
.
Chart
chart
)
{
BorderSearchService
=
borderSearchService
;
InitParamService
=
initParamService
;
this
.
dynAreaService
=
dynAreaService
;
chart1
=
chart
;
Misc
.
BindingOperations
.
SetBinding
(
BorderSearchService
,
"Enable"
,
this
,
"Enable"
);
...
...
@@ -300,10 +307,13 @@ namespace FLY.Thick.Base.UI
UpdateBorder
,
this
,
MARKNO_UPDATE_BORDER
);
};
InitParamService
.
PropertyChanged
+=
MInitParamService_PropertyChanged
;
UpdateX
();
chart1
.
PrePaint
+=
Chart1_PrePaint
;
getView
();
}
private
void
MInitParamService_PropertyChanged
(
object
sender
,
System
.
ComponentModel
.
PropertyChangedEventArgs
e
)
{
...
...
@@ -315,12 +325,10 @@ namespace FLY.Thick.Base.UI
private
void
MBorderSearchService_PropertyChanged
(
object
sender
,
System
.
ComponentModel
.
PropertyChangedEventArgs
e
)
{
if
(
e
.
PropertyName
==
"Datas"
)
if
(
e
.
PropertyName
==
"UpdateTime"
)
{
FObjBase
.
PollModule
.
Current
.
Poll_JustOnce
(
UpdateDatas
,
this
,
MARKNO_UPDATE_DATAS
);
FObjBase
.
PollModule
.
Current
.
Poll_JustOnce
(
UpdateBorder
,
this
,
MARKNO_UPDATE_BORDER
);
getView
();
}
else
if
((
e
.
PropertyName
==
"TempAD"
)
||
(
e
.
PropertyName
==
"TempRange"
))
...
...
@@ -328,7 +336,15 @@ namespace FLY.Thick.Base.UI
chart1
.
Invalidate
();
}
}
void
getView
()
{
BorderSearchService
.
GetView
((
asyncContext
,
retData
)
=>
{
this
.
getViewReponse
=
retData
as
BorderSearchGetViewReponse
;
UpdateDatas
();
FObjBase
.
PollModule
.
Current
.
Poll_JustOnce
(
UpdateBorder
,
this
,
MARKNO_UPDATE_BORDER
);
},
this
);
}
private
void
Chart1_PrePaint
(
object
sender
,
ChartPaintEventArgs
e
)
{
if
(
e
.
ChartElement
is
ChartArea
)
...
...
@@ -399,7 +415,9 @@ namespace FLY.Thick.Base.UI
}
void
UpdateY
()
{
int
[]
grid
=
BorderSearchService
.
Datas
;
if
(
getViewReponse
==
null
)
return
;
int
[]
grid
=
getViewReponse
.
dat
;
if
(
grid
==
null
)
return
;
...
...
@@ -417,13 +435,13 @@ namespace FLY.Thick.Base.UI
else
{
chart1
.
ChartAreas
[
0
].
AxisY
.
Minimum
=
0
;
chart1
.
ChartAreas
[
0
].
AxisY
.
Maximum
=
60000
;
chart1
.
ChartAreas
[
0
].
AxisY
.
Maximum
=
dynAreaService
.
DynArea
.
ADMax
;
}
}
else
{
chart1
.
ChartAreas
[
0
].
AxisY
.
Minimum
=
0
;
chart1
.
ChartAreas
[
0
].
AxisY
.
Maximum
=
60000
;
chart1
.
ChartAreas
[
0
].
AxisY
.
Maximum
=
dynAreaService
.
DynArea
.
ADMax
;
}
if
(
chart1
.
ChartAreas
[
0
].
AxisY
.
Minimum
==
chart1
.
ChartAreas
[
0
].
AxisY
.
Maximum
)
...
...
@@ -442,15 +460,18 @@ namespace FLY.Thick.Base.UI
System
.
Windows
.
Forms
.
DataVisualization
.
Charting
.
Series
series
=
chart1
.
Series
[
"series_datas"
];
series
.
Points
.
Clear
();
if
(
getViewReponse
==
null
)
return
;
int
[]
grid
=
BorderSearchService
.
Datas
;
this
.
Direction
=
getViewReponse
.
direction
;
int
[]
grid
=
getViewReponse
.
dat
;
if
(
grid
==
null
)
return
;
int
posOfGrid
=
InitParamService
.
P
osOfGrid
;
int
posOfGrid
=
getViewReponse
.
p
osOfGrid
;
for
(
int
i
=
0
;
i
<
grid
.
Length
;
i
++)
{
series
.
Points
.
AddXY
(
i
*
posOfGrid
,
grid
[
i
]);
series
.
Points
.
AddXY
(
(
i
+
getViewReponse
.
gridBegin
)
*
posOfGrid
,
grid
[
i
]);
if
(!
Misc
.
MyBase
.
ISVALIDATA
(
grid
[
i
]))
{
series
.
Points
[
i
].
IsEmpty
=
true
;
...
...
@@ -465,13 +486,16 @@ namespace FLY.Thick.Base.UI
System
.
Windows
.
Forms
.
DataVisualization
.
Charting
.
Series
series
,
int
pos
)
{
int
[]
grid
=
BorderSearchService
.
Datas
;
if
(
getViewReponse
==
null
)
return
false
;
int
[]
grid
=
getViewReponse
.
dat
;
if
(
grid
==
null
)
return
false
;
int
posOfGrid
=
InitParamService
.
P
osOfGrid
;
int
posOfGrid
=
getViewReponse
.
p
osOfGrid
;
int
grid_idx
=
pos
/
posOfGrid
;
int
grid_idx
=
pos
/
posOfGrid
-
getViewReponse
.
gridBegin
;
if
(
grid_idx
<
0
)
return
false
;
if
(
grid_idx
>=
grid
.
Length
)
...
...
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgGageInfo.xaml.cs
View file @
97495615
...
...
@@ -22,6 +22,7 @@ namespace FLY.Thick.Base.UI
IGageInfoService
gageInfo
=
null
;
IGetSampleService
getSample
=
null
;
IBorderSearchService
borderSearch
=
null
;
IDynAreaService
dynAreaService
=
null
;
IUnityContainer
container
;
public
PgGageInfo
()
{
...
...
@@ -33,12 +34,14 @@ namespace FLY.Thick.Base.UI
IUnityContainer
container
,
IGageInfoService
gageInfoService
,
IGetSampleService
getSample
,
IBorderSearchService
borderSearch
IBorderSearchService
borderSearch
,
IDynAreaService
dynAreaService
)
{
this
.
gageInfo
=
gageInfoService
;
this
.
getSample
=
getSample
;
this
.
borderSearch
=
borderSearch
;
this
.
dynAreaService
=
dynAreaService
;
this
.
container
=
container
;
container
.
BuildUp
(
mircoGage
);
}
...
...
@@ -300,8 +303,8 @@ namespace FLY.Thick.Base.UI
if
(
chart1
.
ChartAreas
[
0
].
AxisY
.
Minimum
<
0
)
chart1
.
ChartAreas
[
0
].
AxisY
.
Minimum
=
0
;
if
(
chart1
.
ChartAreas
[
0
].
AxisY
.
Maximum
>
60000
)
chart1
.
ChartAreas
[
0
].
AxisY
.
Maximum
=
60000
;
if
(
chart1
.
ChartAreas
[
0
].
AxisY
.
Maximum
>
dynAreaService
.
DynArea
.
ADMax
)
chart1
.
ChartAreas
[
0
].
AxisY
.
Maximum
=
dynAreaService
.
DynArea
.
ADMax
;
}
chart1
.
ChartAreas
[
0
].
AxisX
.
Minimum
=
0
;
chart1
.
ChartAreas
[
0
].
AxisX
.
Maximum
=
gageInfo
.
PosLen
;
...
...
Project.FLY.Thick.Base/FLY.Thick.Base/Client/BorderSearchServiceClient.cs
View file @
97495615
...
...
@@ -42,25 +42,28 @@ namespace FLY.Thick.Base.Client
[
PropertyChanged
.
DoNotCheckEquality
]
public
Range
Valid
{
get
;
set
;
}
=
new
Range
();
[
PropertyChanged
.
DoNotCheckEquality
]
public
Range
Border_Backw
{
get
;
private
set
;
}
=
new
Range
();
public
Range
Border_Backw
{
get
;
set
;
}
=
new
Range
();
[
PropertyChanged
.
DoNotCheckEquality
]
public
Range
Border_Forw
{
get
;
private
set
;
}
=
new
Range
();
public
Range
Border_Forw
{
get
;
set
;
}
=
new
Range
();
[
PropertyChanged
.
DoNotCheckEquality
]
public
Range
Border
{
get
;
private
set
;
}
=
new
Range
();
public
Range
Border
{
get
;
set
;
}
=
new
Range
();
/// <summary>
/// 当前膜宽,测量出来的,单位是 脉冲
/// </summary>
public
int
Width
{
get
;
protected
set
;
}
public
int
Width
{
get
;
set
;
}
/// <summary>
/// 膜中间位置 单位 脉冲
/// </summary>
public
int
Mid
{
get
;
protected
set
;
}
public
int
Mid
{
get
;
set
;
}
/// <summary>
/// 调试数据更新时间
/// </summary>
public
DateTime
UpdateTime
{
get
;
set
;
}
/// <summary>
/// 手动设置温修AD值
/// </summary>
...
...
@@ -93,30 +96,28 @@ namespace FLY.Thick.Base.Client
public
int
N3
{
get
;
set
;
}
/// <summary>
/// 用于调试, 进入到边界查找的数据
/// </summary>
[
PropertyChanged
.
DoNotCheckEquality
]
public
int
[]
Datas
{
get
;
protected
set
;
}
=
null
;
#
endregion
public
void
GetView
(
AsyncCBHandler
asyncDelegate
,
object
asyncContext
)
{
CurrObjSys
.
CallFunctionEx
(
mConn
,
mServerID
,
ID
,
BORDERSEARCH_OBJ_INTERFACE
.
CALL_GETVIEW
,
null
,
asyncDelegate
,
asyncContext
);
}
public
void
Apply
()
{
var
p
=
new
BORDERSEARCH_OBJ_INTERFACE
.
Pack_Params
();
p
.
e
nable
=
Enable
;
p
.
t
empADBySet
=
TempADBySet
;
p
.
tempad
=
TempAD
;
p
.
tempr
ange
=
TempRange
;
p
.
n
=
N
;
p
.
n
2
=
N2
;
p
.
n
3
=
N3
;
p
.
v
alid
=
Valid
;
p
.
sensorw
idth
=
SensorWidth
;
p
.
i
sBreakDetect
=
IsBreakDetect
;
p
.
i
sTempRangeByPercent
=
IsTempRangeByPercent
;
p
.
t
empRangePercent
=
TempRangePercent
;
p
.
E
nable
=
Enable
;
p
.
T
empADBySet
=
TempADBySet
;
p
.
TempAD
=
TempAD
;
p
.
TempR
ange
=
TempRange
;
p
.
N
=
N
;
p
.
N
2
=
N2
;
p
.
N
3
=
N3
;
p
.
V
alid
=
Valid
;
p
.
SensorW
idth
=
SensorWidth
;
p
.
I
sBreakDetect
=
IsBreakDetect
;
p
.
I
sTempRangeByPercent
=
IsTempRangeByPercent
;
p
.
T
empRangePercent
=
TempRangePercent
;
string
json
=
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
p
);
//获取所有数据,设置推送
...
...
@@ -137,10 +138,7 @@ namespace FLY.Thick.Base.Client
BORDERSEARCH_OBJ_INTERFACE
.
GET_PARAMS
);
CurrObjSys
.
GetValueEx
(
mConn
,
mServerID
,
ID
,
BORDERSEARCH_OBJ_INTERFACE
.
GET_RESULT
);
CurrObjSys
.
GetValueEx
(
mConn
,
mServerID
,
ID
,
BORDERSEARCH_OBJ_INTERFACE
.
GET_DATAS
);
BORDERSEARCH_OBJ_INTERFACE
.
GET_STATE
);
CurrObjSys
.
SenseConfigEx
(
mConn
,
mServerID
,
ID
,
0xffffffff
,
SENSE_CONFIG
.
ADD
);
}
...
...
@@ -152,44 +150,13 @@ namespace FLY.Thick.Base.Client
case
BORDERSEARCH_OBJ_INTERFACE
.
GET_PARAMS
:
{
string
json
=
Misc
.
Converter
.
BytesToString
(
infodata
);
var
p
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
BORDERSEARCH_OBJ_INTERFACE
.
Pack_Params
>(
json
);
Enable
=
p
.
enable
;
Valid
=
p
.
valid
;
TempADBySet
=
p
.
tempADBySet
;
TempAD
=
p
.
tempad
;
TempRange
=
p
.
temprange
;
N
=
p
.
n
;
SensorWidth
=
p
.
sensorwidth
;
N2
=
p
.
n2
;
N3
=
p
.
n3
;
IsBreakDetect
=
p
.
isBreakDetect
;
IsTempRangeByPercent
=
p
.
isTempRangeByPercent
;
TempRangePercent
=
p
.
tempRangePercent
;
Newtonsoft
.
Json
.
JsonConvert
.
PopulateObject
(
json
,
this
);
}
break
;
case
BORDERSEARCH_OBJ_INTERFACE
.
GET_
RESULT
:
case
BORDERSEARCH_OBJ_INTERFACE
.
GET_
STATE
:
{
string
json
=
Misc
.
Converter
.
BytesToString
(
infodata
);
var
p
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
BORDERSEARCH_OBJ_INTERFACE
.
Pack_Result
>(
json
);
Border_Forw
=
p
.
borderForw
;
Border_Backw
=
p
.
borderBackw
;
Border
=
p
.
border
;
Width
=
p
.
width
;
Mid
=
p
.
mid
;
Newtonsoft
.
Json
.
JsonConvert
.
PopulateObject
(
json
,
this
);
}
break
;
case
BORDERSEARCH_OBJ_INTERFACE
.
GET_DATAS
:
{
string
json
=
Misc
.
Converter
.
BytesToString
(
infodata
);
var
p
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
BORDERSEARCH_OBJ_INTERFACE
.
Pack_Data
>(
json
);
Datas
=
p
.
data
;
}
break
;
}
}
public
override
void
PushInfo
(
IFConn
from
,
uint
srcid
,
ushort
infoid
,
byte
[]
infodata
)
...
...
@@ -197,6 +164,19 @@ namespace FLY.Thick.Base.Client
PushGetValue
(
from
,
srcid
,
infoid
,
infodata
);
}
public
override
void
PushCallFunction
(
IFConn
from
,
uint
srcid
,
uint
magic
,
ushort
funcid
,
byte
[]
retdata
,
object
AsyncDelegate
,
object
AsyncState
)
{
switch
(
funcid
)
{
case
BORDERSEARCH_OBJ_INTERFACE
.
CALL_GETVIEW
:
{
string
json
=
Misc
.
Converter
.
BytesToString
(
retdata
);
var
reponse
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
BorderSearchGetViewReponse
>(
json
);
((
AsyncCBHandler
)
AsyncDelegate
)?.
Invoke
(
AsyncState
,
reponse
);
}
break
;
}
}
}
}
Project.FLY.Thick.Base/FLY.Thick.Base/IService/IBorderSearchService.cs
View file @
97495615
...
...
@@ -5,16 +5,20 @@ using System.Text;
using
FLY.Thick.Base.Common
;
using
System.ComponentModel
;
using
Misc
;
using
FObjBase
;
namespace
FLY.Thick.Base.IService
{
/// <summary>
///
/// </summary>
public
interface
IBorderSearchService
:
INotifyPropertyChanged
{
#
region
参数
/// <summary>
/// 启动与否
/// </summary>
bool
Enable
{
get
;
set
;}
bool
Enable
{
get
;
set
;}
/// <summary>
/// 边界拐点检测,找到的边界更加精确
...
...
@@ -25,26 +29,7 @@ namespace FLY.Thick.Base.IService
/// 有限范围
/// </summary>
Range
Valid
{
get
;
set
;
}
/// <summary>
/// 反向边界
/// </summary>
Range
Border_Backw
{
get
;
}
/// <summary>
/// 正向边界
/// </summary>
Range
Border_Forw
{
get
;
}
/// <summary>
/// 边界
/// </summary>
Range
Border
{
get
;
}
/// <summary>
/// 当前膜宽,测量出来的,单位是 脉冲
/// </summary>
int
Width
{
get
;
}
/// <summary>
/// 膜中间位置 单位 脉冲
/// </summary>
int
Mid
{
get
;
}
/// <summary>
/// 手动设置温修AD值
/// </summary>
...
...
@@ -52,12 +37,12 @@ namespace FLY.Thick.Base.IService
/// <summary>
/// 温修AD值
/// </summary>
int
TempAD
{
get
;
set
;
}
int
TempAD
{
get
;
set
;
}
/// <summary>
/// AD超过了范围, 就认为开始找到边界
/// </summary>
int
TempRange
{
get
;
set
;
}
int
TempRange
{
get
;
set
;
}
/// <summary>
/// 温修范围是温修的百分比
/// </summary>
...
...
@@ -70,32 +55,72 @@ namespace FLY.Thick.Base.IService
/// <summary>
/// 有滤波器,只有非空的连续N个pos以上,才开始算边界开始
/// </summary>
int
N
{
get
;
set
;
}
int
N
{
get
;
set
;
}
/// <summary>
/// 探头直径,单位脉冲, 膜宽 = 边界范围 - 探头直径
/// </summary>
int
SensorWidth
{
get
;
set
;
}
/// <summary>
/// 找到边界后,边界 + 探头半径 + N2个脉冲。 这个是数据有效的开始
/// </summary>
int
N2
{
get
;
set
;
}
int
N2
{
get
;
set
;
}
/// <summary>
/// 记录两个边界以后扫描,以它们再外扩N3个脉冲,作为扫描范围
/// </summary>
int
N3
{
get
;
set
;}
int
N3
{
get
;
set
;
}
#
endregion
#
region
状态
/// <summary>
/// 反向边界
/// </summary>
Range
Border_Backw
{
get
;
}
/// <summary>
/// 正向边界
/// </summary>
Range
Border_Forw
{
get
;
}
/// <summary>
/// 边界
/// </summary>
Range
Border
{
get
;
}
/// <summary>
/// 当前膜宽,测量出来的,单位是 脉冲
/// </summary>
int
Width
{
get
;
}
/// <summary>
/// 膜中间位置 单位 脉冲
/// </summary>
int
Mid
{
get
;
}
/// <summary>
///
用于调试, 进入到边界查找的数据
///
数据更新时间
/// </summary>
int
[]
Datas
{
get
;
}
DateTime
UpdateTime
{
get
;
}
#
endregion
/// <summary>
/// 获取混合后的横向数据;没有把横向留白剔除;只把纵向留白剔除。
/// 数据单位 mm
/// </summary>
/// <param name="asyncDelegate"></param>
/// <param name="asyncContext"></param>
[
AsyncCb
(
typeof
(
BorderSearchGetViewReponse
))]
void
GetView
(
AsyncCBHandler
asyncDelegate
,
object
asyncContext
);
/// <summary>
/// 应该 及 保存
/// </summary>
void
Apply
();
}
public
class
BorderSearchGetViewReponse
{
public
DIRECTION
direction
;
public
int
posOfGrid
;
public
int
gridBegin
;
public
int
[]
dat
;
}
}
Project.FLY.Thick.Base/FLY.Thick.Base/OBJ_INTERFACE/BORDERSEARCH_OBJ_INTERFACE.cs
View file @
97495615
...
...
@@ -5,41 +5,44 @@ using System.Text;
using
FObjBase
;
using
FLY.Thick.Base.Common
;
using
Misc
;
using
AutoMapper
;
using
FLY.Thick.Base.IService
;
namespace
FLY.Thick.Base.OBJ_INTERFACE
{
public
class
BORDERSEARCH_OBJ_INTERFACE
{
public
static
Mapper
Mapper
{
get
;
}
=
new
AutoMapper
.
Mapper
(
new
MapperConfiguration
(
c
=>
{
c
.
CreateMap
<
IBorderSearchService
,
Pack_Params
>();
c
.
CreateMap
<
IBorderSearchService
,
Pack_State
>();
}));
#
region
Pack
public
class
Pack_Params
{
public
bool
e
nable
;
public
Range
v
alid
;
public
bool
t
empADBySet
;
public
int
tempad
;
public
int
tempr
ange
;
public
int
n
;
public
int
sensorw
idth
;
public
int
n
2
;
public
int
n
3
;
public
bool
i
sBreakDetect
;
public
bool
i
sTempRangeByPercent
;
public
double
t
empRangePercent
;
public
bool
E
nable
;
public
Range
V
alid
;
public
bool
T
empADBySet
;
public
int
TempAD
;
public
int
TempR
ange
;
public
int
N
;
public
int
SensorW
idth
;
public
int
N
2
;
public
int
N
3
;
public
bool
I
sBreakDetect
;
public
bool
I
sTempRangeByPercent
;
public
double
T
empRangePercent
;
}
public
class
Pack_
Result
public
class
Pack_
State
{
public
Range
borderForw
;
public
Range
borderBackw
;
public
Range
border
;
public
int
width
;
public
int
mid
;
public
Range
Border_Forw
;
public
Range
Border_Backw
;
public
Range
Border
;
public
int
Width
;
public
int
Mid
;
public
DateTime
UpdateTime
;
}
public
class
Pack_Data
{
public
int
[]
data
;
}
#
endregion
#
region
GetValue
/// <summary>
...
...
@@ -47,33 +50,31 @@ namespace FLY.Thick.Base.OBJ_INTERFACE
/// </summary>
public
const
UInt16
GET_PARAMS
=
0
;
/// <summary>
/// Pack_
Result
/// Pack_
State
/// </summary>
public
const
UInt16
GET_RESULT
=
1
;
/// <summary>
/// Pack_Data
/// </summary>
public
const
UInt16
GET_DATAS
=
2
;
public
const
UInt16
GET_STATE
=
1
;
#
endregion
#
region
SetValue
/// <summary>
/// Pack_
GetParam
/// Pack_
Params
/// </summary>
public
const
UInt16
SET_PARAMS
=
0
;
#
endregion
#
region
PushMsg
/// <summary>
/// Pack_
GetParam
/// Pack_
Params
/// </summary>
public
const
UInt16
PUSH_PARAMS
=
0
;
/// <summary>
/// Pack_
GetResult
/// Pack_
State
/// </summary>
public
const
UInt16
PUSH_RESULT
=
1
;
public
const
UInt16
PUSH_STATE
=
1
;
#
endregion
#
region
Call
/// <summary>
///
Pack_Data
///
/// </summary>
public
const
UInt16
PUSH_DATAS
=
2
;
public
const
UInt16
CALL_GETVIEW
=
0
;
#
endregion
}
}
Project.FLY.Thick.Base/FLY.Thick.Base/Server.OBJProxy/BorderSearch_OBJProxy.cs
View file @
97495615
...
...
@@ -12,9 +12,15 @@ namespace FLY.Thick.Base.Server.OBJProxy
{
#
region
延时推送
MARKNO
const
int
MARKNO_PUSH_PARAMS
=
0
;
const
int
MARKNO_PUSH_RESULT
=
1
;
const
int
MARKNO_PUSH_DATAS
=
2
;
const
int
MARKNO_PUSH_STATE
=
1
;
#
endregion
private
static
string
[]
propertyname_params
=
new
string
[]
{
"Enable"
,
"Valid"
,
"TempADBySet"
,
"TempAD"
,
"TempRange"
,
"TempRangePercent"
,
"IsTempRangeByPercent"
,
"SensorWidth"
,
"N"
,
"N2"
,
"N3"
,
"IsDetectBreak"
};
private
static
string
[]
propertyname_state
=
new
string
[]
{
"Border_Backw"
,
"Border_Forw"
,
"Border"
,
"Width"
,
"Mid"
,
"UpdateTime"
};
IBorderSearchService
mBorderSearch
;
public
BorderSearch_OBJProxy
(
int
objsys_idx
,
UInt32
id
,
IBorderSearchService
borderSearch
)
:
base
(
objsys_idx
)
...
...
@@ -27,19 +33,7 @@ namespace FLY.Thick.Base.Server.OBJProxy
void
mBorderSearch_PropertyChanged
(
object
sender
,
System
.
ComponentModel
.
PropertyChangedEventArgs
e
)
{
if
((
e
.
PropertyName
==
"Enable"
)
||
(
e
.
PropertyName
==
"Valid"
)
||
(
e
.
PropertyName
==
"TempADBySet"
)
||
(
e
.
PropertyName
==
"TempAD"
)
||
(
e
.
PropertyName
==
"TempRange"
)
||
(
e
.
PropertyName
==
"TempRangePercent"
)
||
(
e
.
PropertyName
==
"IsTempRangeByPercent"
)
||
(
e
.
PropertyName
==
"SensorWidth"
)
||
(
e
.
PropertyName
==
"N"
)
||
(
e
.
PropertyName
==
"N2"
)
||
(
e
.
PropertyName
==
"N3"
)
||
(
e
.
PropertyName
==
"IsDetectBreak"
)
)
if
(
propertyname_params
.
Contains
(
e
.
PropertyName
))
{
FObjBase
.
PollModule
.
Current
.
Poll_JustOnce
(
...
...
@@ -52,33 +46,17 @@ namespace FLY.Thick.Base.Server.OBJProxy
buf
);
}),
this
,
MARKNO_PUSH_PARAMS
);
}
else
if
(
(
e
.
PropertyName
==
"Border_Backw"
)
||
(
e
.
PropertyName
==
"Border_Forw"
)
||
(
e
.
PropertyName
==
"Width"
)
||
(
e
.
PropertyName
==
"Mid"
))
else
if
(
propertyname_state
.
Contains
(
e
.
PropertyName
))
{
FObjBase
.
PollModule
.
Current
.
Poll_JustOnce
(
new
PollModule
.
PollHandler
(
delegate
()
{
byte
[]
buf
;
GetValue
(
null
,
0
,
BORDERSEARCH_OBJ_INTERFACE
.
GET_
RESULT
,
out
buf
);
GetValue
(
null
,
0
,
BORDERSEARCH_OBJ_INTERFACE
.
GET_
STATE
,
out
buf
);
CurrObjSys
.
PushObjInfoEx
(
this
,
BORDERSEARCH_OBJ_INTERFACE
.
PUSH_
RESULT
,
this
,
BORDERSEARCH_OBJ_INTERFACE
.
PUSH_
STATE
,
buf
);
}),
this
,
MARKNO_PUSH_RESULT
);
}
else
if
(
e
.
PropertyName
==
"Datas"
)
{
FObjBase
.
PollModule
.
Current
.
Poll_JustOnce
(
new
PollModule
.
PollHandler
(
delegate
()
{
byte
[]
buf
;
GetValue
(
null
,
0
,
BORDERSEARCH_OBJ_INTERFACE
.
GET_DATAS
,
out
buf
);
CurrObjSys
.
PushObjInfoEx
(
this
,
BORDERSEARCH_OBJ_INTERFACE
.
PUSH_DATAS
,
buf
);
}),
this
,
MARKNO_PUSH_DATAS
);
}),
this
,
MARKNO_PUSH_STATE
);
}
}
...
...
@@ -89,46 +67,16 @@ namespace FLY.Thick.Base.Server.OBJProxy
{
case
BORDERSEARCH_OBJ_INTERFACE
.
GET_PARAMS
:
{
BORDERSEARCH_OBJ_INTERFACE
.
Pack_Params
p
=
new
BORDERSEARCH_OBJ_INTERFACE
.
Pack_Params
()
{
enable
=
mBorderSearch
.
Enable
,
valid
=
mBorderSearch
.
Valid
,
tempADBySet
=
mBorderSearch
.
TempADBySet
,
tempad
=
mBorderSearch
.
TempAD
,
temprange
=
mBorderSearch
.
TempRange
,
n
=
mBorderSearch
.
N
,
sensorwidth
=
mBorderSearch
.
SensorWidth
,
n2
=
mBorderSearch
.
N2
,
n3
=
mBorderSearch
.
N3
,
isBreakDetect
=
mBorderSearch
.
IsBreakDetect
,
isTempRangeByPercent
=
mBorderSearch
.
IsTempRangeByPercent
,
tempRangePercent
=
mBorderSearch
.
TempRangePercent
};
var
p
=
BORDERSEARCH_OBJ_INTERFACE
.
Mapper
.
Map
<
BORDERSEARCH_OBJ_INTERFACE
.
Pack_Params
>(
mBorderSearch
);
string
json
=
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
p
);
infodata
=
Misc
.
Converter
.
StringToBytes
(
json
);
}
break
;
case
BORDERSEARCH_OBJ_INTERFACE
.
GET_
RESULT
:
case
BORDERSEARCH_OBJ_INTERFACE
.
GET_
STATE
:
{
BORDERSEARCH_OBJ_INTERFACE
.
Pack_Result
p
=
new
BORDERSEARCH_OBJ_INTERFACE
.
Pack_Result
()
{
borderForw
=
mBorderSearch
.
Border_Forw
,
borderBackw
=
mBorderSearch
.
Border_Backw
,
width
=
mBorderSearch
.
Width
,
mid
=
mBorderSearch
.
Mid
};
var
p
=
BORDERSEARCH_OBJ_INTERFACE
.
Mapper
.
Map
<
BORDERSEARCH_OBJ_INTERFACE
.
Pack_State
>(
mBorderSearch
);
string
json
=
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
p
);
infodata
=
Misc
.
Converter
.
StringToBytes
(
json
);
}
break
;
case
BORDERSEARCH_OBJ_INTERFACE
.
GET_DATAS
:
{
BORDERSEARCH_OBJ_INTERFACE
.
Pack_Data
p
=
new
BORDERSEARCH_OBJ_INTERFACE
.
Pack_Data
()
{
data
=
mBorderSearch
.
Datas
};
string
json
=
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
p
);
infodata
=
Misc
.
Converter
.
StringToBytes
(
json
);
}
break
;
default
:
infodata
=
null
;
break
;
...
...
@@ -141,27 +89,28 @@ namespace FLY.Thick.Base.Server.OBJProxy
case
BORDERSEARCH_OBJ_INTERFACE
.
SET_PARAMS
:
{
string
json
=
Misc
.
Converter
.
BytesToString
(
infodata
);
var
p
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
BORDERSEARCH_OBJ_INTERFACE
.
Pack_Params
>(
json
);
mBorderSearch
.
Enable
=
p
.
enable
;
mBorderSearch
.
Valid
=
p
.
valid
;
mBorderSearch
.
TempRange
=
p
.
temprange
;
mBorderSearch
.
TempADBySet
=
p
.
tempADBySet
;
mBorderSearch
.
TempAD
=
p
.
tempad
;
mBorderSearch
.
N
=
p
.
n
;
mBorderSearch
.
SensorWidth
=
p
.
sensorwidth
;
mBorderSearch
.
N2
=
p
.
n2
;
mBorderSearch
.
N3
=
p
.
n3
;
mBorderSearch
.
IsBreakDetect
=
p
.
isBreakDetect
;
mBorderSearch
.
IsTempRangeByPercent
=
p
.
isTempRangeByPercent
;
mBorderSearch
.
TempRangePercent
=
p
.
tempRangePercent
;
Newtonsoft
.
Json
.
JsonConvert
.
PopulateObject
(
json
,
mBorderSearch
);
mBorderSearch
.
Apply
();
}
break
;
}
}
public
override
void
CallFunction
(
IFConn
from
,
uint
srcid
,
uint
magic
,
ushort
funcid
,
byte
[]
infodata
)
{
switch
(
funcid
)
{
case
BORDERSEARCH_OBJ_INTERFACE
.
CALL_GETVIEW
:
{
mBorderSearch
.
GetView
((
asyncContext
,
retData
)
=>
{
string
json
=
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
retData
);
CurrObjSys
.
PushCallFunctionEx
(
from
,
srcid
,
ID
,
magic
,
funcid
,
Misc
.
Converter
.
StringToBytes
(
json
));
},
null
);
}
break
;
}
}
}
}
Project.FLY.Thick.Base/FLY.Thick.Base/Server/BorderSearch.cs
View file @
97495615
...
...
@@ -6,6 +6,7 @@ using System.ComponentModel;
using
Misc
;
using
FLY.Thick.Base.Common
;
using
FLY.Thick.Base.IService
;
using
FObjBase
;
namespace
FLY.Thick.Base.Server
{
...
...
@@ -35,6 +36,9 @@ namespace FLY.Thick.Base.Server
/// </summary>
public
bool
IsBreakDetect
{
get
;
set
;
}
=
true
;
/// <summary>
/// 正反向边界数据
/// </summary>
protected
Range
[]
border
=
new
Range
[
2
]
{
new
Range
(),
new
Range
()
};
/// <summary>
...
...
@@ -121,15 +125,21 @@ namespace FLY.Thick.Base.Server
/// </summary>
public
int
N3
{
get
;
set
;
}
/// <summary>
///
用于调试, 进入到边界查找的数据
///
数据更新时间
/// </summary>
public
int
[]
Datas
{
get
;
set
;
}
=
null
;
public
DateTime
UpdateTime
{
get
;
protected
set
;
}
#
endregion
OBJComponents
.
Server
.
WarningSystem
warningSystem
;
/// <summary>
/// 用于调试, 进入到边界查找的数据
/// </summary>
protected
BorderSearchGetViewReponse
getViewReponse
;
private
string
param_path
=
"bordersearch.xml"
;
public
BorderSearch
()
{
...
...
@@ -182,6 +192,7 @@ namespace FLY.Thick.Base.Server
TempRange
=
500
;
TempRangePercent
=
500.0
/
50000
;
IsTempRangeByPercent
=
true
;
UpdateTime
=
DateTime
.
MinValue
;
}
...
...
@@ -565,6 +576,7 @@ namespace FLY.Thick.Base.Server
borderend_grid
=
eg
;
return
true
;
}
/// <summary>
/// 放入grid数据,分析边界
/// </summary>
...
...
@@ -576,21 +588,14 @@ namespace FLY.Thick.Base.Server
public
virtual
bool
FindFilm
(
DIRECTION
direction
,
int
posOfGrid
,
int
gridBegin
,
int
[]
dat
)
{
//把数据记录下来
if
((
Datas
==
null
)||
(
Datas
.
Length
<
(
dat
.
Length
+
gridBegin
))
)
getViewReponse
=
new
BorderSearchGetViewReponse
(
)
{
int
len
=
dat
.
Length
+
gridBegin
;
Datas
=
new
int
[
len
];
}
for
(
int
i
=
0
;
i
<
Datas
.
Length
;
i
++)
{
if
(
i
<
gridBegin
)
//清空前面
Datas
[
i
]
=
Misc
.
MyBase
.
NULL_VALUE
;
else
if
(
i
<
(
gridBegin
+
dat
.
Length
))
Datas
[
i
]
=
dat
[
i
-
gridBegin
];
else
//清空后面
Datas
[
i
]
=
Misc
.
MyBase
.
NULL_VALUE
;
}
NotifyPropertyChanged
(
"Datas"
);
direction
=
direction
,
posOfGrid
=
posOfGrid
,
gridBegin
=
gridBegin
,
dat
=
dat
};
UpdateTime
=
DateTime
.
Now
;
//转为 dat 的序号
int
validbegin_grid
=
Valid
.
Begin
/
posOfGrid
-
gridBegin
;
...
...
@@ -755,6 +760,19 @@ namespace FLY.Thick.Base.Server
GetBoltRange2
(
direction
,
out
b
,
out
e
);
return
new
Range
()
{
Begin
=
b
,
End
=
e
};
}
/// <summary>
/// 获取混合后的横向数据;没有把横向留白剔除;只把纵向留白剔除。
/// 数据单位 mm
/// </summary>
/// <param name="asyncDelegate"></param>
/// <param name="asyncContext"></param>
[
AsyncCb
(
typeof
(
BorderSearchGetViewReponse
))]
public
void
GetView
(
AsyncCBHandler
asyncDelegate
,
object
asyncContext
)
{
asyncDelegate
?.
Invoke
(
asyncContext
,
getViewReponse
);
}
public
bool
Load
()
{
return
Misc
.
SaveToXmlHepler
.
Load
(
param_path
,
this
);
...
...
Project.FLY.Thick.Base/FLY.Thick.Base/Server/BorderSearchPlastic.cs
View file @
97495615
using
Misc
;
using
FLY.Thick.Base.IService
;
using
Misc
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
@@ -27,21 +28,13 @@ namespace FLY.Thick.Base.Server
public
override
bool
FindFilm
(
DIRECTION
direction
,
int
posOfGrid
,
int
gridBegin
,
int
[]
dat
)
{
//把数据记录下来
if
((
Datas
==
null
)
||
(
Datas
.
Length
<
(
dat
.
Length
+
gridBegin
))
)
getViewReponse
=
new
BorderSearchGetViewReponse
(
)
{
int
len
=
dat
.
Length
+
gridBegin
;
Datas
=
new
int
[
len
];
}
for
(
int
i
=
0
;
i
<
Datas
.
Length
;
i
++)
{
if
(
i
<
gridBegin
)
//清空前面
Datas
[
i
]
=
Misc
.
MyBase
.
NULL_VALUE
;
else
if
(
i
<
(
gridBegin
+
dat
.
Length
))
Datas
[
i
]
=
dat
[
i
-
gridBegin
];
else
//清空后面
Datas
[
i
]
=
Misc
.
MyBase
.
NULL_VALUE
;
}
NotifyPropertyChanged
(
"Datas"
);
posOfGrid
=
posOfGrid
,
gridBegin
=
gridBegin
,
dat
=
dat
};
UpdateTime
=
DateTime
.
Now
;
//这些是AD值
//转为 dat 的序号
...
...
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