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
c9341c1e
Commit
c9341c1e
authored
Feb 19, 2019
by
潘栩锋
🚴
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
7158c9a0
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
139 additions
and
2 deletions
+139
-2
ConnContext.cs
Project.FLY.FObjSys/FObjSys/ConnContext.cs
+1
-1
IFObj.cs
Project.FLY.FObjSys/FObjSys/IFObj.cs
+1
-1
Enumerable.cs
Project.FLY.Misc/MISC/Enumerable.cs
+136
-0
Misc.csproj
Project.FLY.Misc/MISC/Misc.csproj
+1
-0
No files found.
Project.FLY.FObjSys/FObjSys/ConnContext.cs
View file @
c9341c1e
...
@@ -29,5 +29,5 @@ namespace FObjBase
...
@@ -29,5 +29,5 @@ namespace FObjBase
}
}
}
}
public
delegate
void
AsyncCBHandler
(
object
Async
State
,
object
retData
);
public
delegate
void
AsyncCBHandler
(
object
Async
Context
,
object
retData
);
}
}
Project.FLY.FObjSys/FObjSys/IFObj.cs
View file @
c9341c1e
...
@@ -150,7 +150,7 @@ namespace FObjBase
...
@@ -150,7 +150,7 @@ namespace FObjBase
{
{
}
}
public
virtual
void
PushCallFunction
(
IFConn
from
,
uint
srcid
,
UInt32
magic
,
ushort
funcid
,
byte
[]
retdata
,
object
AsyncDelegate
,
object
Async
State
)
public
virtual
void
PushCallFunction
(
IFConn
from
,
uint
srcid
,
UInt32
magic
,
ushort
funcid
,
byte
[]
retdata
,
object
AsyncDelegate
,
object
Async
Context
)
{
{
}
}
...
...
Project.FLY.Misc/MISC/Enumerable.cs
0 → 100644
View file @
c9341c1e
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
Misc
{
public
static
class
Enumerable
{
//
// 摘要:
// 计算 System.Double 值序列的Sigma,该值可通过调用输入序列的每个元素的转换函数获取。
//
// 参数:
// source:
// 要计算其平均值的值序列。
//
// selector:
// 应用于每个元素的转换函数。
//
// 类型参数:
// TSource:
// source 中的元素的类型。
//
// 返回结果:
// 值序列的Sigma。
//
// 异常:
// T:System.ArgumentNullException:
// source 或 selector 为 null。
//
// T:System.InvalidOperationException:
// source 中不包含任何元素。
public
static
double
Sigma
<
TSource
>(
this
IEnumerable
<
TSource
>
source
,
Func
<
TSource
,
double
>
selector
)
{
if
(
source
.
Count
()
==
0
)
return
-
1
;
double
avg
=
source
.
Average
(
selector
);
double
sum_pow
=
source
.
Sum
((
s
)
=>
Math
.
Pow
((
selector
(
s
)
-
avg
),
2
));
return
Math
.
Sqrt
(
sum_pow
/
(
source
.
Count
()
-
1
));
}
public
static
double
Sigma
(
this
IEnumerable
<
double
>
source
)
{
return
source
.
Sigma
(
d
=>
d
);
}
public
static
double
CPK
<
TSource
>(
this
IEnumerable
<
TSource
>
source
,
Func
<
TSource
,
double
>
selector
,
double
usl
,
double
lsl
)
{
if
(
source
.
Count
()
==
0
)
return
-
1
;
//CPK = Min(CPKu,CPKl)
//USL(Upper specification limit): 规格上限。
//LSL(Low specification limit): 规格下限。
//ˉx = (x1 + x2 +...+ xn) / n : 平均值。
//T = USL - LSL : 规格公差。
//U = (USL + LSL) / 2:规格中心。
//CPKu = | USL - ˉx | / 3σ
//CPKl = | ˉx - LSL | / 3σ
double
avg
=
source
.
Average
(
selector
);
double
sigma3
=
source
.
Sigma
(
selector
)
*
3
;
double
CPKu
=
Math
.
Abs
(
usl
-
avg
)
/
sigma3
;
double
CPKl
=
Math
.
Abs
(
lsl
-
avg
)
/
sigma3
;
double
CPK
=
Math
.
Min
(
CPKu
,
CPKl
);
return
CPK
;
}
public
static
double
CPK
(
this
IEnumerable
<
double
>
source
,
double
usl
,
double
lsl
)
{
return
source
.
CPK
(
d
=>
d
,
usl
,
lsl
);
}
public
static
List
<
XY
>
GetHistogram
<
TSource
>(
this
IEnumerable
<
TSource
>
source
,
Func
<
TSource
,
double
>
selector
,
double
step
)
{
List
<
XY
>
list
=
new
List
<
XY
>();
foreach
(
var
v
in
source
)
{
double
x
=
((
int
)(
selector
(
v
)
/
step
))
*
step
;
XY
xy
=
list
.
Find
(
_xy
=>
_xy
.
X
==
x
);
if
(
xy
!=
null
)
{
xy
.
Y
++;
}
else
{
xy
=
new
XY
(
x
,
1
);
list
.
Add
(
xy
);
}
}
list
.
Sort
();
return
list
;
}
public
static
List
<
XY
>
GetHistogram
(
this
IEnumerable
<
double
>
source
,
double
step
)
{
return
source
.
GetHistogram
(
d
=>
d
,
step
);
}
}
public
class
XY
:
IComparable
,
ICloneable
,
ICopiable
{
public
double
X
{
get
;
set
;
}
public
double
Y
{
get
;
set
;
}
public
XY
()
{
}
public
XY
(
double
x
,
double
y
)
{
X
=
x
;
Y
=
y
;
}
public
int
CompareTo
(
object
obj
)
{
XY
xy
=
obj
as
XY
;
return
X
.
CompareTo
(
xy
.
X
);
}
public
object
Clone
()
{
XY
xy
=
new
XY
();
xy
.
Copy
(
this
);
return
xy
;
}
public
void
Copy
(
object
src
)
{
Misc
.
PropertiesManager
.
CopyTo
(
src
,
this
);
}
}
}
Project.FLY.Misc/MISC/Misc.csproj
View file @
c9341c1e
...
@@ -86,6 +86,7 @@
...
@@ -86,6 +86,7 @@
<Compile
Include=
"CRC.cs"
/>
<Compile
Include=
"CRC.cs"
/>
<Compile
Include=
"DATARANGE.cs"
/>
<Compile
Include=
"DATARANGE.cs"
/>
<Compile
Include=
"Debug.cs"
/>
<Compile
Include=
"Debug.cs"
/>
<Compile
Include=
"Enumerable.cs"
/>
<Compile
Include=
"IgnoreAttribute.cs"
/>
<Compile
Include=
"IgnoreAttribute.cs"
/>
<Compile
Include=
"ITDParam.cs"
/>
<Compile
Include=
"ITDParam.cs"
/>
<Compile
Include=
"Log.cs"
/>
<Compile
Include=
"Log.cs"
/>
...
...
潘栩锋
🚴
@panruising
mentioned in commit
1a7305cc
·
Feb 25, 2019
mentioned in commit
1a7305cc
mentioned in commit 1a7305cc826c2cb2d0b098c832e569bb7b54a271
Toggle commit list
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