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
d1eb223d
Commit
d1eb223d
authored
Mar 26, 2021
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加 RangeStruct.cs,这个 Range 的 struct 版本。 BorderSearch 的 Valid, Border 都是 RangeStruct
parent
0458a2a4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
548 additions
and
137 deletions
+548
-137
Misc.csproj
Project.FLY.Misc/MISC/Misc.csproj
+1
-0
Range.cs
Project.FLY.Misc/MISC/Range.cs
+17
-5
RangeStruct.cs
Project.FLY.Misc/MISC/RangeStruct.cs
+364
-0
PgBorderSearch.xaml.cs
...t.FLY.Thick.Base/FLY.Thick.Base.UI/PgBorderSearch.xaml.cs
+5
-2
PgGageInfo.xaml.cs
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgGageInfo.xaml.cs
+4
-5
BorderSearchServiceClient.cs
...k.Base/FLY.Thick.Base/Client/BorderSearchServiceClient.cs
+6
-6
IBorderSearchService.cs
...hick.Base/FLY.Thick.Base/IService/IBorderSearchService.cs
+2
-2
BorderSearch.cs
Project.FLY.Thick.Base/FLY.Thick.Base/Server/BorderSearch.cs
+147
-114
BorderSearchPlastic.cs
...Y.Thick.Base/FLY.Thick.Base/Server/BorderSearchPlastic.cs
+2
-3
No files found.
Project.FLY.Misc/MISC/Misc.csproj
View file @
d1eb223d
...
...
@@ -87,6 +87,7 @@
<Compile
Include=
"IsErrorAttribute.cs"
/>
<Compile
Include=
"PropertiesManager.cs"
/>
<Compile
Include=
"PropertyBinding.cs"
/>
<Compile
Include=
"RangeStruct.cs"
/>
<Compile
Include=
"Range.cs"
/>
<Compile
Include=
"RangeF.cs"
/>
<Compile
Include=
"RList.cs"
/>
...
...
Project.FLY.Misc/MISC/Range.cs
View file @
d1eb223d
...
...
@@ -17,12 +17,12 @@ namespace Misc
/// <summary>
/// 开始
/// </summary>
public
int
Begin
{
get
;
set
;
}
public
int
Begin
{
get
;
set
;
}
=
Misc
.
MyBase
.
NULL_VALUE
;
/// <summary>
/// 结束
/// </summary>
public
int
End
{
get
;
set
;
}
public
int
End
{
get
;
set
;
}
=
Misc
.
MyBase
.
NULL_VALUE
;
#
endregion
#
region
just
get
property
...
...
@@ -76,9 +76,21 @@ namespace Misc
{
Misc
.
SaveToXmlHepler
.
Regist
(
typeof
(
Range
));
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public
RangeStruct
ToStruct
()
{
return
new
RangeStruct
(
Begin
,
End
);
}
public
Range
(
RangeStruct
rangeStruct
)
{
Begin
=
rangeStruct
.
Begin
;
End
=
rangeStruct
.
End
;
}
/// <summary>
/// 使用无效值初始化
/// </summary>
...
...
Project.FLY.Misc/MISC/RangeStruct.cs
0 → 100644
View file @
d1eb223d
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.ComponentModel
;
using
Newtonsoft.Json
;
using
System.Collections
;
namespace
Misc
{
/// <summary>
/// int范围类,
/// </summary>
public
struct
RangeStruct
{
#
region
property
/// <summary>
/// 开始
/// </summary>
public
int
Begin
{
get
;
set
;
}
/// <summary>
/// 结束
/// </summary>
public
int
End
{
get
;
set
;
}
#
endregion
#
region
just
get
property
/// <summary>
/// 本范围 中心位置
/// </summary>
[
JsonIgnore
]
public
int
Mid
{
get
{
if
(
Misc
.
MyBase
.
ISVALIDATA
(
Begin
))
return
(
End
+
Begin
)
/
2
;
else
return
Misc
.
MyBase
.
NULL_VALUE
;
}
}
/// <summary>
/// 本范围宽度
/// </summary>
[
JsonIgnore
]
public
int
Width
{
get
{
if
(
IsValid
)
return
End
-
Begin
+
1
;
else
return
Misc
.
MyBase
.
NULL_VALUE
;
}
}
/// <summary>
/// 是否有效
/// </summary>
[
JsonIgnore
]
public
bool
IsValid
{
get
{
if
(
Misc
.
MyBase
.
ISVALIDATA
(
Begin
)
&&
Misc
.
MyBase
.
ISVALIDATA
(
End
))
return
true
;
else
return
false
;
}
}
#
endregion
public
RangeStruct
(
int
begin
,
int
end
)
{
Begin
=
begin
;
End
=
end
;
}
#
region
methods
/// <summary>
/// 范围 r 在 本范围内
/// </summary>
/// <param name="r"></param>
/// <returns></returns>
public
bool
Contain
(
RangeStruct
r
)
{
if
((
Begin
<=
r
.
Begin
)
&&
(
r
.
End
<=
End
))
return
true
;
else
return
false
;
}
/// <summary>
/// 点 p 在 本范围内
/// </summary>
/// <param name="p"></param>
/// <returns></returns>
public
bool
Contain
(
int
p
)
{
if
((
Begin
<=
p
)
&&
(
p
<=
End
))
return
true
;
else
return
false
;
}
/// <summary>
/// 无效值
/// </summary>
public
static
RangeStruct
InvalidValue
{
get
{
return
new
RangeStruct
(
Misc
.
MyBase
.
NULL_VALUE
,
Misc
.
MyBase
.
NULL_VALUE
);
}
}
/// <summary>
/// 范围并集
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public
static
RangeStruct
operator
|(
RangeStruct
a
,
RangeStruct
b
)
{
return
new
RangeStruct
()
{
Begin
=
(
a
.
Begin
<
b
.
Begin
)
?
a
.
Begin
:
b
.
Begin
,
End
=
(
a
.
End
>
b
.
End
)
?
a
.
End
:
b
.
End
};
}
/// <summary>
/// 范围交集
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public
static
RangeStruct
operator
&(
RangeStruct
a
,
RangeStruct
b
)
{
RangeStruct
r
=
new
RangeStruct
()
{
Begin
=
(
a
.
Begin
>
b
.
Begin
)
?
a
.
Begin
:
b
.
Begin
,
End
=
(
a
.
End
<
b
.
End
)
?
a
.
End
:
b
.
End
};
if
(
r
.
End
<
r
.
Begin
)
{
return
new
RangeStruct
();
}
else
{
return
r
;
}
}
/// <summary>
/// 范围 a小于b
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public
static
bool
operator
<(
RangeStruct
a
,
RangeStruct
b
)
{
if
(
a
.
End
<
b
.
Begin
)
//[a.b,a.e] [b.b,b.e]
{
return
true
;
}
else
{
return
false
;
}
}
/// <summary>
/// 范围 a大于b
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public
static
bool
operator
>(
RangeStruct
a
,
RangeStruct
b
)
{
if
(
b
.
End
<
(
a
.
Begin
))
// [b.b,b.e][a.b,a.e]
{
return
true
;
}
else
{
return
false
;
}
}
public
static
bool
operator
<(
int
p
,
RangeStruct
r
)
{
if
(
p
<
r
.
Begin
)
{
return
true
;
}
else
{
return
false
;
}
}
public
static
bool
operator
>(
int
p
,
RangeStruct
r
)
{
if
(
p
>
r
.
End
)
{
return
true
;
}
else
{
return
false
;
}
}
public
static
bool
operator
<(
RangeStruct
r
,
int
p
)
{
if
(
r
.
End
<
p
)
{
return
true
;
}
else
{
return
false
;
}
}
public
static
bool
operator
>(
RangeStruct
r
,
int
p
)
{
if
(
r
.
Begin
>
p
)
{
return
true
;
}
else
{
return
false
;
}
}
public
static
RangeStruct
operator
+(
RangeStruct
a
,
int
b
)
{
return
new
RangeStruct
()
{
Begin
=
a
.
Begin
+
b
,
End
=
a
.
Begin
+
b
};
}
public
static
RangeStruct
operator
-(
RangeStruct
a
,
int
b
)
{
return
new
RangeStruct
()
{
Begin
=
a
.
Begin
-
b
,
End
=
a
.
Begin
-
b
};
}
/// <summary>
/// 是否有交集
/// </summary>
/// <param name="r"></param>
/// <returns></returns>
public
bool
HasIntersection
(
RangeStruct
r
)
{
if
(
Contain
(
r
.
Begin
))
return
true
;
if
(
Contain
(
r
.
End
))
return
true
;
if
(
r
.
Contain
(
Begin
))
return
true
;
if
(
r
.
Contain
(
End
))
return
true
;
return
false
;
}
/// <summary>
/// 可以合并
/// </summary>
/// <returns></returns>
public
bool
CanUnion
(
RangeStruct
r
)
{
if
(
HasIntersection
(
r
))
return
true
;
if
(
End
==
(
r
.
Begin
-
1
))
return
true
;
if
(
Begin
==
(
r
.
End
+
1
))
return
true
;
return
false
;
}
#
endregion
/// <summary>
///
/// </summary>
/// <returns></returns>
public
override
string
ToString
()
{
if
(
IsValid
)
return
$"[
{
Begin
}
,
{
End
}
]=
{
Width
}
"
;
else
return
"invalid"
;
}
}
/// <summary>
/// Range 辅助类
/// </summary>
public
static
class
EListRangeStruct
{
/// <summary>
/// rlist 必须是由小到大排列
/// </summary>
/// <param name="rlist"></param>
/// <param name="r"></param>
public
static
void
Union
(
this
List
<
RangeStruct
>
rlist
,
RangeStruct
r
)
{
for
(
int
i
=
0
;
i
<
rlist
.
Count
();
i
++)
{
RangeStruct
r_dest
=
rlist
[
i
];
if
(
r
<
r_dest
)
//在 r_dest 前面
{
rlist
.
Insert
(
i
,
r
);
return
;
//完成
}
else
if
(
r
.
CanUnion
(
r_dest
))
//r 与 r_dest 有交集
{
//r 与 r_dest 合体
r
=
r
|
r_dest
;
rlist
.
RemoveAt
(
i
);
i
--;
//还需要继续判断
}
}
//r 在 rlist 的后面
rlist
.
Add
(
r
);
}
/// <summary>
/// 联合
/// </summary>
/// <param name="rlist1"></param>
/// <param name="rlist2"></param>
public
static
void
Union
(
this
List
<
RangeStruct
>
rlist1
,
List
<
RangeStruct
>
rlist2
)
{
for
(
int
i
=
0
;
i
<
rlist2
.
Count
();
i
++)
{
rlist1
.
Union
(
rlist2
[
i
]);
}
}
}
}
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgBorderSearch.xaml.cs
View file @
d1eb223d
...
...
@@ -272,7 +272,10 @@ namespace FLY.Thick.Base.UI
Misc
.
BindingOperations
.
SetBinding
(
BorderSearchService
,
nameof
(
BorderSearchService
.
Enable
),
this
,
nameof
(
Enable
));
Misc
.
BindingOperations
.
SetBinding
(
BorderSearchService
,
nameof
(
BorderSearchService
.
IsBreakDetect
),
this
,
nameof
(
IsBreakDetect
));
Misc
.
BindingOperations
.
SetBinding
(
BorderSearchService
,
nameof
(
BorderSearchService
.
Valid
),
this
,
nameof
(
Valid
));
Misc
.
BindingOperations
.
SetBinding
(
BorderSearchService
,
nameof
(
BorderSearchService
.
Valid
),
()=>
{
Valid
=
new
Range
(
BorderSearchService
.
Valid
);
});
Misc
.
BindingOperations
.
SetBinding
(
BorderSearchService
,
nameof
(
BorderSearchService
.
TempADBySet
),
this
,
nameof
(
TempADBySet
));
Misc
.
BindingOperations
.
SetBinding
(
BorderSearchService
,
nameof
(
BorderSearchService
.
TempAD
),
this
,
nameof
(
TempAD
));
Misc
.
BindingOperations
.
SetBinding
(
BorderSearchService
,
nameof
(
BorderSearchService
.
TempRange
),
this
,
nameof
(
TempRange
));
...
...
@@ -345,7 +348,7 @@ namespace FLY.Thick.Base.UI
BorderSearchService
.
Enable
=
Enable
;
BorderSearchService
.
IsBreakDetect
=
IsBreakDetect
;
BorderSearchService
.
Valid
=
Valid
;
BorderSearchService
.
Valid
=
Valid
.
ToStruct
()
;
BorderSearchService
.
TempADBySet
=
TempADBySet
;
BorderSearchService
.
TempAD
=
TempAD
;
BorderSearchService
.
TempRange
=
TempRange
;
...
...
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgGageInfo.xaml.cs
View file @
d1eb223d
...
...
@@ -96,11 +96,10 @@ namespace FLY.Thick.Base.UI
{
update
();
}
};
borderSearch
.
Valid
.
PropertyChanged
+=
(
s
,
e
)
=>
{
update
();
else
if
(
e
.
PropertyName
==
nameof
(
borderSearch
.
Valid
))
{
update
();
}
};
DataBindAll
();
...
...
Project.FLY.Thick.Base/FLY.Thick.Base/Client/BorderSearchServiceClient.cs
View file @
d1eb223d
...
...
@@ -40,14 +40,14 @@ namespace FLY.Thick.Base.Client
/// </summary>
public
bool
IsBreakDetect
{
get
;
set
;
}
=
true
;
[
PropertyChanged
.
DoNotCheckEquality
]
public
Range
Valid
{
get
;
set
;
}
=
new
Range
();
[
PropertyChanged
.
DoNotCheckEquality
]
public
Range
Struct
Valid
{
get
;
set
;
}
public
Range
Border_Backw
{
get
;
set
;
}
=
new
Range
();
[
PropertyChanged
.
DoNotCheckEquality
]
public
Range
Border_Forw
{
get
;
set
;
}
=
new
Range
();
[
PropertyChanged
.
DoNotCheckEquality
]
public
Range
Border
{
get
;
set
;
}
=
new
Range
();
public
Range
Struct
Border
{
get
;
set
;
}
/// <summary>
...
...
Project.FLY.Thick.Base/FLY.Thick.Base/IService/IBorderSearchService.cs
View file @
d1eb223d
...
...
@@ -25,7 +25,7 @@ namespace FLY.Thick.Base.IService
/// <summary>
/// 有限范围
/// </summary>
Range
Valid
{
get
;
set
;
}
Range
Struct
Valid
{
get
;
set
;
}
/// <summary>
/// 手动设置温修AD值
...
...
@@ -82,7 +82,7 @@ namespace FLY.Thick.Base.IService
/// <summary>
/// 边界
/// </summary>
Range
Border
{
get
;
}
Range
Struct
Border
{
get
;
}
/// <summary>
/// 当前膜宽,测量出来的,单位是 脉冲
/// </summary>
...
...
Project.FLY.Thick.Base/FLY.Thick.Base/Server/BorderSearch.cs
View file @
d1eb223d
This diff is collapsed.
Click to expand it.
Project.FLY.Thick.Base/FLY.Thick.Base/Server/BorderSearchPlastic.cs
View file @
d1eb223d
...
...
@@ -141,12 +141,11 @@ namespace FLY.Thick.Base.Server
if
(
borders
.
All
(
b
=>
b
.
value
.
IsValid
))
{
Border
.
Begin
=
(
int
)
borders
.
Average
(
b
=>
b
.
real
.
Begin
);
Border
.
End
=
(
int
)
borders
.
Average
(
b
=>
b
.
real
.
End
);
Border
=
new
RangeStruct
((
int
)
borders
.
Average
(
b
=>
b
.
real
.
Begin
),
(
int
)
borders
.
Average
(
b
=>
b
.
real
.
End
));
}
else
if
(
border
.
value
.
IsValid
)
{
Border
.
Copy
(
border
.
real
);
Border
=
border
.
real
.
ToStruct
(
);
}
getViewReponse
.
border
=
border
.
real
;
...
...
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