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
a731e151
Commit
a731e151
authored
Mar 26, 2021
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化 curve模块 改为json保存数据。和obj.reflect 通信方式
parent
682d3e2c
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
137 additions
and
304 deletions
+137
-304
PgCurve.xaml.cs
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgCurve.xaml.cs
+1
-4
PgCurveModify.xaml.cs
...ct.FLY.Thick.Base/FLY.Thick.Base.UI/PgCurveModify.xaml.cs
+2
-2
CurveServiceClient.cs
...LY.Thick.Base/FLY.Thick.Base/Client/CurveServiceClient.cs
+6
-208
CurveCell.cs
Project.FLY.Thick.Base/FLY.Thick.Base/Common/CurveCell.cs
+1
-17
ICurveService.cs
...t.FLY.Thick.Base/FLY.Thick.Base/IService/ICurveService.cs
+6
-5
CurveCollection.cs
...t.FLY.Thick.Base/FLY.Thick.Base/Server/CurveCollection.cs
+121
-68
No files found.
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgCurve.xaml.cs
View file @
a731e151
...
@@ -268,10 +268,7 @@ namespace FLY.Thick.Base.UI
...
@@ -268,10 +268,7 @@ namespace FLY.Thick.Base.UI
if
(!
WdPassword
.
Authorize
(
"Curve"
))
if
(!
WdPassword
.
Authorize
(
"Curve"
))
return
;
return
;
mCurveService
.
CorrectWay
=
this
.
CorrectWay
;
mCurveService
.
Apply
(
this
.
CorrectWay
,
this
.
Flag
,
this
.
Curves
.
ToArray
());
mCurveService
.
Flag
=
this
.
Flag
;
mCurveService
.
Curves
=
this
.
Curves
.
ToList
();
mCurveService
.
Apply
();
FLY
.
ControlLibrary
.
Window_Tip
.
Show
(
"应用成功"
,
FLY
.
ControlLibrary
.
Window_Tip
.
Show
(
"应用成功"
,
null
,
null
,
TimeSpan
.
FromSeconds
(
2
));
TimeSpan
.
FromSeconds
(
2
));
...
...
Project.FLY.Thick.Base/FLY.Thick.Base.UI/PgCurveModify.xaml.cs
View file @
a731e151
...
@@ -322,8 +322,8 @@ namespace FLY.Thick.Base.UI
...
@@ -322,8 +322,8 @@ namespace FLY.Thick.Base.UI
if
(!
WdPassword
.
Authorize
(
"Curve"
))
if
(!
WdPassword
.
Authorize
(
"Curve"
))
return
;
return
;
curveService
.
Curves
=
curveCore
.
Curves
;
curveService
.
Apply
(
curveService
.
CorrectWay
,
curveService
.
Flag
,
curveCore
.
Curves
.
ToArray
())
;
curveService
.
Apply
();
FLY
.
ControlLibrary
.
Window_Tip
.
Show
(
"应用成功"
,
FLY
.
ControlLibrary
.
Window_Tip
.
Show
(
"应用成功"
,
null
,
null
,
TimeSpan
.
FromSeconds
(
2
));
TimeSpan
.
FromSeconds
(
2
));
...
...
Project.FLY.Thick.Base/FLY.Thick.Base/Client/CurveServiceClient.cs
View file @
a731e151
...
@@ -15,8 +15,9 @@ namespace FLY.Thick.Base.Client
...
@@ -15,8 +15,9 @@ namespace FLY.Thick.Base.Client
/// <summary>
/// <summary>
/// AD 曲线服务 客户端代理
/// AD 曲线服务 客户端代理
/// </summary>
/// </summary>
public
class
CurveServiceClient
:
FObj
Ser
viceClient
,
ICurveService
public
class
CurveServiceClient
:
FObj
Base
.
Reflect
.
Reflect_Se
viceClient
,
ICurveService
{
{
protected
override
Type
InterfaceType
=>
typeof
(
ICurveService
);
/// <summary>
/// <summary>
/// AD 曲线服务 客户端代理
/// AD 曲线服务 客户端代理
/// </summary>
/// </summary>
...
@@ -39,7 +40,8 @@ namespace FLY.Thick.Base.Client
...
@@ -39,7 +40,8 @@ namespace FLY.Thick.Base.Client
public
CurveType
Flag
{
get
;
set
;
}
public
CurveType
Flag
{
get
;
set
;
}
[
PropertyChanged
.
DoNotCheckEquality
]
[
PropertyChanged
.
DoNotCheckEquality
]
public
List
<
CurveCell
>
Curves
{
get
;
set
;
}
public
CurveCell
[]
Curves
{
get
;
set
;
}
public
void
SetRevised
()
public
void
SetRevised
()
{
{
for
(
int
i
=
0
;
i
<
Curves
.
Count
();
i
++)
for
(
int
i
=
0
;
i
<
Curves
.
Count
();
i
++)
...
@@ -47,216 +49,12 @@ namespace FLY.Thick.Base.Client
...
@@ -47,216 +49,12 @@ namespace FLY.Thick.Base.Client
Curves
[
i
].
AD
=
Curves
[
i
].
RevisedAD
;
Curves
[
i
].
AD
=
Curves
[
i
].
RevisedAD
;
}
}
}
}
public
void
Apply
()
public
void
Apply
(
CurveCorrectWay
correctWay
,
CurveType
flag
,
CurveCell
[]
curves
)
{
Curves
.
OrderBy
(
c
=>
c
.
Value
);
var
p
=
new
CURVE_OBJ_INTERFACE
.
Pack_CurveList
();
p
.
list
=
Curves
;
p
.
flag
=
Flag
;
p
.
correctway
=
CorrectWay
;
string
json
=
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
p
);
CurrObjSys
.
SetValueEx
(
mConn
,
mServerID
,
ID
,
CURVE_OBJ_INTERFACE
.
SET_CURVELIST
,
Misc
.
Converter
.
StringToBytes
(
json
)
);
}
#
region
E
int
AD2Value_E
(
int
ad
,
AD2ValueFlag
flag
)
{
int
i
;
int
thick
;
if
(
Curves
.
Count
<
1
)
return
-
1
;
if
(
ad
<
0
)
return
-
1
;
if
(
ad
==
0
)
ad
=
1
;
if
(
flag
==
AD2ValueFlag
.
NoRevised
)
{
for
(
i
=
0
;
i
<
Curves
.
Count
;
i
++)
{
if
(
ad
<
Curves
[
i
].
AD
)
continue
;
else
break
;
}
}
else
{
for
(
i
=
0
;
i
<
Curves
.
Count
;
i
++)
{
if
(
ad
<
Curves
[
i
].
RevisedAD
)
continue
;
else
break
;
}
}
if
(
i
>=
Curves
.
Count
)
i
=
Curves
.
Count
-
1
;
if
(
i
==
0
)
i
=
1
;
if
(
flag
==
AD2ValueFlag
.
NoRevised
)
{
double
adi_ad0
=
Math
.
Log
(
Curves
[
i
].
AD
)
-
Math
.
Log
(
Curves
[
i
-
1
].
AD
);
double
vi_v0
=
Curves
[
i
].
Value
-
Curves
[
i
-
1
].
Value
;
double
a
=
vi_v0
/
adi_ad0
;
double
b
=
Curves
[
i
-
1
].
Value
-
Math
.
Log
(
Curves
[
i
-
1
].
AD
)
*
a
;
thick
=
(
int
)(
Math
.
Log
(
ad
)
*
a
+
b
);
//double u;
//u = Math.Log((double)Curves[i - 1].AD / Curves[i].AD, Math.E) * 100 / (Curves[i].Value - Curves[i - 1].Value);
//thick = (int)(Math.Log((double)Curves[i - 1].AD / ad, Math.E) * 100 / u + Curves[i - 1].Value);
}
else
{
{
double
adi_ad0
=
Math
.
Log
(
Curves
[
i
].
RevisedAD
)
-
Math
.
Log
(
Curves
[
i
-
1
].
RevisedAD
);
Call
(
nameof
(
Apply
),
new
{
correctWay
,
flag
,
curves
});
double
vi_v0
=
Curves
[
i
].
Value
-
Curves
[
i
-
1
].
Value
;
double
a
=
vi_v0
/
adi_ad0
;
double
b
=
Curves
[
i
-
1
].
Value
-
Math
.
Log
(
Curves
[
i
-
1
].
RevisedAD
)
*
a
;
thick
=
(
int
)(
Math
.
Log
(
ad
)
*
a
+
b
);
//double u;
//u = Math.Log((double)Curves[i - 1].RevisedAD / Curves[i].RevisedAD, Math.E) * 100 / (Curves[i].Value - Curves[i - 1].Value);
//thick = (int)(Math.Log((double)Curves[i - 1].RevisedAD / ad, Math.E) * 100 / u + Curves[i - 1].Value);
}
}
//if (thick < 0)
// return 0;
return
thick
;
}
#
endregion
#
endregion
#
region
线性
int
AD2Value_Line
(
int
ad
,
AD2ValueFlag
flag
)
{
int
i
;
int
thick
;
if
(
Curves
.
Count
<
2
)
return
-
1
;
if
(
ad
<
0
)
return
-
1
;
if
(
ad
==
0
)
ad
=
1
;
bool
isDescending
=
true
;
//降序排列
if
(
Curves
[
0
].
AD
<
Curves
[
1
].
AD
)
isDescending
=
false
;
//找 ad0<ad<adi
if
(
flag
==
AD2ValueFlag
.
NoRevised
)
{
if
(
isDescending
)
//降序排列
{
for
(
i
=
0
;
i
<
Curves
.
Count
;
i
++)
{
if
(
ad
<
Curves
[
i
].
AD
)
continue
;
else
break
;
}
}
else
{
for
(
i
=
0
;
i
<
Curves
.
Count
;
i
++)
{
if
(
ad
>
Curves
[
i
].
AD
)
continue
;
else
break
;
}
}
if
(
i
>=
Curves
.
Count
)
i
=
Curves
.
Count
-
1
;
if
(
i
==
0
)
i
=
1
;
double
adi_ad0
=
Curves
[
i
].
AD
-
Curves
[
i
-
1
].
AD
;
double
vi_v0
=
Curves
[
i
].
Value
-
Curves
[
i
-
1
].
Value
;
double
a
=
vi_v0
/
adi_ad0
;
double
b
=
Curves
[
i
-
1
].
Value
-
Curves
[
i
-
1
].
AD
*
a
;
thick
=
(
int
)(
ad
*
a
+
b
);
return
thick
;
}
else
{
if
(
isDescending
)
//降序排列
{
for
(
i
=
0
;
i
<
Curves
.
Count
;
i
++)
{
if
(
ad
<
Curves
[
i
].
RevisedAD
)
continue
;
else
break
;
}
}
else
{
for
(
i
=
0
;
i
<
Curves
.
Count
;
i
++)
{
if
(
ad
>
Curves
[
i
].
RevisedAD
)
continue
;
else
break
;
}
}
if
(
i
>=
Curves
.
Count
)
i
=
Curves
.
Count
-
1
;
if
(
i
==
0
)
i
=
1
;
double
adi_ad0
=
Curves
[
i
].
AD
-
Curves
[
i
-
1
].
RevisedAD
;
double
vi_v0
=
Curves
[
i
].
Value
-
Curves
[
i
-
1
].
Value
;
double
a
=
vi_v0
/
adi_ad0
;
double
b
=
Curves
[
i
-
1
].
Value
-
Curves
[
i
-
1
].
RevisedAD
*
a
;
thick
=
(
int
)(
ad
*
a
+
b
);
return
thick
;
}
}
#
endregion
public
int
AD2Value
(
int
ad
,
AD2ValueFlag
flag
)
{
switch
(
Flag
)
{
case
CurveType
.
Line
:
return
AD2Value_Line
(
ad
,
flag
);
default
:
return
AD2Value_E
(
ad
,
flag
);
}
}
#
endregion
public
override
void
ConnectNotify
(
IFConn
from
)
{
base
.
ConnectNotify
(
from
);
if
(
from
.
IsConnected
)
{
CurrObjSys
.
SenseConfigEx
(
mConn
,
mServerID
,
ID
,
0xffffffff
,
SENSE_CONFIG
.
ADD
);
CurrObjSys
.
GetValueEx
(
mConn
,
mServerID
,
ID
,
CURVE_OBJ_INTERFACE
.
GET_CURVELIST
);
}
}
public
override
void
PushGetValue
(
IFConn
from
,
uint
srcid
,
ushort
memid
,
byte
[]
infodata
)
{
PushInfo
(
from
,
srcid
,
memid
,
infodata
);
}
public
override
void
PushInfo
(
IFConn
from
,
uint
srcid
,
ushort
infoid
,
byte
[]
infodata
)
{
switch
(
infoid
)
{
case
CURVE_OBJ_INTERFACE
.
PUSH_CURVELIST
:
{
string
json
=
Misc
.
Converter
.
BytesToString
(
infodata
);
var
p
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
CURVE_OBJ_INTERFACE
.
Pack_CurveList
>(
json
);
CorrectWay
=
p
.
correctway
;
Flag
=
p
.
flag
;
Curves
=
p
.
list
;
}
break
;
}
}
}
}
}
}
Project.FLY.Thick.Base/FLY.Thick.Base/Common/CurveCell.cs
View file @
a731e151
...
@@ -10,12 +10,8 @@ using System.Collections.ObjectModel;
...
@@ -10,12 +10,8 @@ using System.Collections.ObjectModel;
namespace
FLY.Thick.Base.Common
namespace
FLY.Thick.Base.Common
{
{
public
class
CurveCell
:
Misc
.
ISaveToXml
,
INotifyPropertyChanged
public
class
CurveCell
:
INotifyPropertyChanged
{
{
static
CurveCell
()
{
Misc
.
SaveToXmlHepler
.
Regist
(
typeof
(
CurveCell
));
}
public
override
string
ToString
()
public
override
string
ToString
()
{
{
return
"value="
+
Value
.
ToString
()
+
" ad="
+
AD
.
ToString
()
+
" revisedad="
+
RevisedAD
.
ToString
();
return
"value="
+
Value
.
ToString
()
+
" ad="
+
AD
.
ToString
()
+
" revisedad="
+
RevisedAD
.
ToString
();
...
@@ -33,18 +29,6 @@ namespace FLY.Thick.Base.Common
...
@@ -33,18 +29,6 @@ namespace FLY.Thick.Base.Common
/// </summary>
/// </summary>
public
int
RevisedAD
{
get
;
set
;
}
public
int
RevisedAD
{
get
;
set
;
}
#
region
ISaveToXml
成员
public
string
[]
GetSavePropertyNames
()
{
return
new
string
[]{
"Value"
,
"AD"
};
}
#
endregion
#
region
INotifyPropertyChanged
成员
#
region
INotifyPropertyChanged
成员
public
event
PropertyChangedEventHandler
PropertyChanged
;
public
event
PropertyChangedEventHandler
PropertyChanged
;
...
...
Project.FLY.Thick.Base/FLY.Thick.Base/IService/ICurveService.cs
View file @
a731e151
...
@@ -13,16 +13,17 @@ namespace FLY.Thick.Base.IService
...
@@ -13,16 +13,17 @@ namespace FLY.Thick.Base.IService
/// <summary>
/// <summary>
/// AD曲线校正方式
/// AD曲线校正方式
/// </summary>
/// </summary>
CurveCorrectWay
CorrectWay
{
get
;
set
;
}
CurveCorrectWay
CorrectWay
{
get
;
}
/// <summary>
/// <summary>
/// 标记,用于告诉 客户端,当前的曲线类型, 自然对数 / 直线拟合 / 二次拟合
/// 标记,用于告诉 客户端,当前的曲线类型, 自然对数 / 直线拟合 / 二次拟合
/// </summary>
/// </summary>
CurveType
Flag
{
get
;
set
;
}
CurveType
Flag
{
get
;
}
/// <summary>
/// <summary>
/// 曲线
/// 曲线
/// </summary>
/// </summary>
List
<
CurveCell
>
Curves
{
get
;
set
;
}
CurveCell
[]
Curves
{
get
;
}
void
Apply
();
int
AD2Value
(
int
ad
,
AD2ValueFlag
flag
);
void
Apply
(
CurveCorrectWay
correctWay
,
CurveType
flag
,
CurveCell
[]
curves
);
}
}
}
}
Project.FLY.Thick.Base/FLY.Thick.Base/Server/CurveCollection.cs
View file @
a731e151
...
@@ -7,93 +7,96 @@ using System.ComponentModel;
...
@@ -7,93 +7,96 @@ using System.ComponentModel;
using
FLY.Thick.Base.Common
;
using
FLY.Thick.Base.Common
;
using
FLY.Thick.Base.IService
;
using
FLY.Thick.Base.IService
;
using
AutoMapper
;
using
System.IO
;
using
Newtonsoft.Json
;
namespace
FLY.Thick.Base.Server
namespace
FLY.Thick.Base.Server
{
{
public
class
CurveCollection
:
ICurveService
,
Misc
.
ISaveToXml
public
class
CurveCollection
:
ICurveService
{
{
#
region
数据文件需要保存的数据项
#
region
数据文件需要保存的数据项
CurveCorrectWay
correctWay
=
CurveCorrectWay
.
OnePointIsScale
;
/// <summary>
/// <summary>
/// AD曲线校正方式
/// AD曲线校正方式
/// </summary>
/// </summary>
public
CurveCorrectWay
CorrectWay
{
get
;
set
;
}
public
CurveCorrectWay
CorrectWay
{
get
;
set
;
}
=
CurveCorrectWay
.
OnePointIsScale
;
public
CurveType
Flag
{
get
;
set
;
}
public
CurveType
Flag
{
get
;
set
;
}
=
CurveType
.
E
;
/// <summary>
/// <summary>
/// 输入的曲线, 排列顺序,Value 从 小到大
/// 输入的曲线, 排列顺序,Value 从 小到大
/// </summary>
/// </summary>
[
PropertyChanged
.
DoNotCheckEquality
]
[
PropertyChanged
.
DoNotCheckEquality
]
public
List
<
CurveCell
>
Curves
{
get
;
set
;
}
=
new
List
<
CurveCell
>();
public
CurveCell
[]
Curves
{
get
;
set
;
}
#
endregion
#
endregion
public
event
ActiveEventHandler
ActiveEvent
;
public
event
ActiveEventHandler
ActiveEvent
;
public
class
ExChange
:
Misc
.
ISaveToXml
public
struct
ExChange
{
{
static
ExChange
()
public
ExChange
(
int
orgAd
,
int
currAd
)
{
{
OrgAD
=
orgAd
;
Misc
.
SaveToXmlHepler
.
Regist
(
typeof
(
ExChange
))
;
CurrAD
=
currAd
;
}
}
public
int
OrgAD
{
get
;
set
;
}
public
int
OrgAD
{
get
;
set
;
}
public
int
CurrAD
{
get
;
set
;
}
public
int
CurrAD
{
get
;
set
;
}
public
string
[]
GetSavePropertyNames
()
{
return
new
string
[]{
"OrgAD"
,
"CurrAD"
};
}
}
}
/// <summary>
/// <summary>
/// 真实样品校正点
/// 真实样品校正点
/// </summary>
/// </summary>
List
<
ExChange
>
RevisingCurves
=
new
List
<
ExChange
>();
List
<
ExChange
>
RevisingCurves
=
new
List
<
ExChange
>();
private
string
param_path
=
"curve.
xml
"
;
private
string
param_path
=
"curve.
json
"
;
public
CurveCollection
()
public
CurveCollection
()
{
{
SetDefault
();
SetDefault
();
ReviseCurve
();
ReviseCurve
();
}
}
public
CurveCollection
(
string
param_path
)
public
CurveCollection
(
string
param_path
)
{
{
if
(!
string
.
IsNullOrEmpty
(
param_path
))
if
(!
string
.
IsNullOrEmpty
(
param_path
))
this
.
param_path
=
param_path
;
this
.
param_path
=
param_path
;
SetDefault
();
SetDefault
();
Load
();
if
(!
Load
())
{
Save
();
}
Curves
=
Curves
.
OrderBy
(
c
=>
c
.
Value
).
ToArray
();
RevisingCurves
.
Clear
();
ReviseCurve
();
ReviseCurve
();
}
}
void
SetDefault
()
void
SetDefault
()
{
{
CorrectWay
=
CurveCorrectWay
.
OnePointIsScale
;
CorrectWay
=
CurveCorrectWay
.
OnePointIsScale
;
Flag
=
CurveType
.
E
;
Flag
=
CurveType
.
E
;
Curves
.
Add
(
new
CurveCell
()
{
AD
=
57564
,
Value
=
0
});
Curves
=
new
CurveCell
[]
{
Curves
.
Add
(
new
CurveCell
()
{
AD
=
30850
,
Value
=
8800
});
new
CurveCell
()
{
AD
=
57564
,
Value
=
0
},
Curves
.
Add
(
new
CurveCell
()
{
AD
=
19000
,
Value
=
17600
});
new
CurveCell
()
{
AD
=
30850
,
Value
=
8800
},
Curves
.
Add
(
new
CurveCell
()
{
AD
=
12528
,
Value
=
26400
});
new
CurveCell
()
{
AD
=
19000
,
Value
=
17600
},
Curves
.
Add
(
new
CurveCell
()
{
AD
=
8409
,
Value
=
35200
});
new
CurveCell
()
{
AD
=
12528
,
Value
=
26400
},
Curves
.
Add
(
new
CurveCell
()
{
AD
=
5650
,
Value
=
44000
});
new
CurveCell
()
{
AD
=
8409
,
Value
=
35200
},
Curves
.
Add
(
new
CurveCell
()
{
AD
=
3779
,
Value
=
52800
});
new
CurveCell
()
{
AD
=
5650
,
Value
=
44000
},
Curves
.
Add
(
new
CurveCell
()
{
AD
=
2513
,
Value
=
61600
});
new
CurveCell
()
{
AD
=
3779
,
Value
=
52800
},
Curves
.
Add
(
new
CurveCell
()
{
AD
=
1660
,
Value
=
70400
});
new
CurveCell
()
{
AD
=
2513
,
Value
=
61600
},
}
new
CurveCell
()
{
AD
=
1660
,
Value
=
70400
}
public
void
Apply
()
};
{
}
public
void
Apply
(
CurveCorrectWay
correctWay
,
CurveType
flag
,
CurveCell
[]
curves
)
{
CorrectWay
=
correctWay
;
Flag
=
flag
;
Curves
=
curves
;
ClearExChange
();
ClearExChange
();
ReviseCurve
();
ReviseCurve
();
if
(
ActiveEvent
!=
null
)
ActiveEvent
?.
Invoke
(
this
);
ActiveEvent
(
this
);
Save
();
Save
();
}
}
public
void
Clear
()
{
Curves
.
Clear
();
ClearExChange
();
}
#
region
ExChange
#
region
ExChange
...
@@ -188,7 +191,7 @@ namespace FLY.Thick.Base.Server
...
@@ -188,7 +191,7 @@ namespace FLY.Thick.Base.Server
double
uh
=
((
double
)
RevisingCurves
[
0
].
CurrAD
)
/
adh
;
double
uh
=
((
double
)
RevisingCurves
[
0
].
CurrAD
)
/
adh
;
double
ul
=
((
double
)
RevisingCurves
[
1
].
CurrAD
)
/
adl
;
double
ul
=
((
double
)
RevisingCurves
[
1
].
CurrAD
)
/
adl
;
for
(
int
i
=
0
,
j
=
1
;
i
<
Curves
.
Count
;
i
++)
for
(
int
i
=
0
,
j
=
1
;
i
<
Curves
.
Count
()
;
i
++)
{
{
double
ux
=
uh
-
(
adh
-
Curves
[
i
].
AD
)
*
(
uh
-
ul
)
/
(
adh
-
adl
);
double
ux
=
uh
-
(
adh
-
Curves
[
i
].
AD
)
*
(
uh
-
ul
)
/
(
adh
-
adl
);
Curves
[
i
].
RevisedAD
=
(
int
)(
Curves
[
i
].
AD
*
ux
);
Curves
[
i
].
RevisedAD
=
(
int
)(
Curves
[
i
].
AD
*
ux
);
...
@@ -204,12 +207,12 @@ namespace FLY.Thick.Base.Server
...
@@ -204,12 +207,12 @@ namespace FLY.Thick.Base.Server
int
i
;
int
i
;
int
thick
;
int
thick
;
if
(
Curves
.
Count
<
1
)
return
-
1
;
if
(
Curves
.
Count
()
<
1
)
return
-
1
;
if
(
ad
<
0
)
return
-
1
;
if
(
ad
<
0
)
return
-
1
;
if
(
ad
==
0
)
ad
=
1
;
if
(
ad
==
0
)
ad
=
1
;
if
(
flag
==
AD2ValueFlag
.
NoRevised
)
if
(
flag
==
AD2ValueFlag
.
NoRevised
)
{
{
for
(
i
=
0
;
i
<
Curves
.
Count
;
i
++)
for
(
i
=
0
;
i
<
Curves
.
Count
()
;
i
++)
{
{
if
(
ad
<
Curves
[
i
].
AD
)
if
(
ad
<
Curves
[
i
].
AD
)
continue
;
continue
;
...
@@ -219,7 +222,7 @@ namespace FLY.Thick.Base.Server
...
@@ -219,7 +222,7 @@ namespace FLY.Thick.Base.Server
}
}
else
else
{
{
for
(
i
=
0
;
i
<
Curves
.
Count
;
i
++)
for
(
i
=
0
;
i
<
Curves
.
Count
()
;
i
++)
{
{
if
(
ad
<
Curves
[
i
].
RevisedAD
)
if
(
ad
<
Curves
[
i
].
RevisedAD
)
continue
;
continue
;
...
@@ -227,7 +230,7 @@ namespace FLY.Thick.Base.Server
...
@@ -227,7 +230,7 @@ namespace FLY.Thick.Base.Server
break
;
break
;
}
}
}
}
if
(
i
>=
Curves
.
Count
)
i
=
Curves
.
Count
-
1
;
if
(
i
>=
Curves
.
Count
())
i
=
Curves
.
Count
()
-
1
;
if
(
i
==
0
)
i
=
1
;
if
(
i
==
0
)
i
=
1
;
if
(
flag
==
AD2ValueFlag
.
NoRevised
)
if
(
flag
==
AD2ValueFlag
.
NoRevised
)
...
@@ -257,7 +260,7 @@ namespace FLY.Thick.Base.Server
...
@@ -257,7 +260,7 @@ namespace FLY.Thick.Base.Server
int
i
;
int
i
;
int
thick
;
int
thick
;
if
(
Curves
.
Count
<
2
)
return
-
1
;
if
(
Curves
.
Count
()
<
2
)
return
-
1
;
if
(
ad
<
0
)
return
-
1
;
if
(
ad
<
0
)
return
-
1
;
if
(
ad
==
0
)
ad
=
1
;
if
(
ad
==
0
)
ad
=
1
;
bool
isDescending
=
true
;
//降序排列
bool
isDescending
=
true
;
//降序排列
...
@@ -269,7 +272,7 @@ namespace FLY.Thick.Base.Server
...
@@ -269,7 +272,7 @@ namespace FLY.Thick.Base.Server
{
{
if
(
isDescending
)
//降序排列
if
(
isDescending
)
//降序排列
{
{
for
(
i
=
0
;
i
<
Curves
.
Count
;
i
++)
for
(
i
=
0
;
i
<
Curves
.
Count
()
;
i
++)
{
{
if
(
ad
<
Curves
[
i
].
AD
)
if
(
ad
<
Curves
[
i
].
AD
)
continue
;
continue
;
...
@@ -279,7 +282,7 @@ namespace FLY.Thick.Base.Server
...
@@ -279,7 +282,7 @@ namespace FLY.Thick.Base.Server
}
}
else
else
{
{
for
(
i
=
0
;
i
<
Curves
.
Count
;
i
++)
for
(
i
=
0
;
i
<
Curves
.
Count
()
;
i
++)
{
{
if
(
ad
>
Curves
[
i
].
AD
)
if
(
ad
>
Curves
[
i
].
AD
)
continue
;
continue
;
...
@@ -287,7 +290,7 @@ namespace FLY.Thick.Base.Server
...
@@ -287,7 +290,7 @@ namespace FLY.Thick.Base.Server
break
;
break
;
}
}
}
}
if
(
i
>=
Curves
.
Count
)
i
=
Curves
.
Count
-
1
;
if
(
i
>=
Curves
.
Count
())
i
=
Curves
.
Count
()
-
1
;
if
(
i
==
0
)
i
=
1
;
if
(
i
==
0
)
i
=
1
;
double
adi_ad0
=
Curves
[
i
].
AD
-
Curves
[
i
-
1
].
AD
;
double
adi_ad0
=
Curves
[
i
].
AD
-
Curves
[
i
-
1
].
AD
;
...
@@ -302,7 +305,7 @@ namespace FLY.Thick.Base.Server
...
@@ -302,7 +305,7 @@ namespace FLY.Thick.Base.Server
{
{
if
(
isDescending
)
//降序排列
if
(
isDescending
)
//降序排列
{
{
for
(
i
=
0
;
i
<
Curves
.
Count
;
i
++)
for
(
i
=
0
;
i
<
Curves
.
Count
()
;
i
++)
{
{
if
(
ad
<
Curves
[
i
].
RevisedAD
)
if
(
ad
<
Curves
[
i
].
RevisedAD
)
continue
;
continue
;
...
@@ -312,7 +315,7 @@ namespace FLY.Thick.Base.Server
...
@@ -312,7 +315,7 @@ namespace FLY.Thick.Base.Server
}
}
else
else
{
{
for
(
i
=
0
;
i
<
Curves
.
Count
;
i
++)
for
(
i
=
0
;
i
<
Curves
.
Count
()
;
i
++)
{
{
if
(
ad
>
Curves
[
i
].
RevisedAD
)
if
(
ad
>
Curves
[
i
].
RevisedAD
)
continue
;
continue
;
...
@@ -320,7 +323,7 @@ namespace FLY.Thick.Base.Server
...
@@ -320,7 +323,7 @@ namespace FLY.Thick.Base.Server
break
;
break
;
}
}
}
}
if
(
i
>=
Curves
.
Count
)
i
=
Curves
.
Count
-
1
;
if
(
i
>=
Curves
.
Count
())
i
=
Curves
.
Count
()
-
1
;
if
(
i
==
0
)
i
=
1
;
if
(
i
==
0
)
i
=
1
;
double
adi_ad0
=
Curves
[
i
].
RevisedAD
-
Curves
[
i
-
1
].
RevisedAD
;
double
adi_ad0
=
Curves
[
i
].
RevisedAD
-
Curves
[
i
-
1
].
RevisedAD
;
...
@@ -334,47 +337,97 @@ namespace FLY.Thick.Base.Server
...
@@ -334,47 +337,97 @@ namespace FLY.Thick.Base.Server
}
}
#
endregion
#
endregion
public
int
AD2Value
(
int
ad
,
AD2ValueFlag
flag
)
public
double
AD2Value
(
int
ad
,
AD2ValueFlag
flag
)
{
{
int
value
;
switch
(
Flag
)
switch
(
Flag
)
{
{
case
CurveType
.
Line
:
case
CurveType
.
Line
:
return
AD2Value_Line
(
ad
,
flag
);
value
=
AD2Value_Line
(
ad
,
flag
);
break
;
default
:
default
:
return
AD2Value_E
(
ad
,
flag
);
value
=
AD2Value_E
(
ad
,
flag
);
break
;
}
}
return
value
/
100.0
;
}
}
#
region
ITDParam
成员
public
bool
Load
()
public
bool
Load
()
{
{
bool
ret
=
Misc
.
SaveToXmlHepler
.
Load
(
"curve.xml"
,
this
);
return
CurveCollectionJsonDb
.
Load
(
this
,
param_path
);
RevisingCurves
.
Clear
();
Curves
.
OrderBy
(
c
=>
c
.
Value
);
return
ret
;
}
}
public
void
Save
()
public
bool
Save
()
{
{
Misc
.
SaveToXmlHepler
.
Save
(
"curve.xml"
,
this
);
return
CurveCollectionJsonDb
.
Save
(
this
,
param_path
);
}
}
#
region
INotifyPropertyChanged
成员
public
event
System
.
ComponentModel
.
PropertyChangedEventHandler
PropertyChanged
;
#
endregion
#
endregion
}
#
region
ISaveToXml
成员
public
string
[]
GetSavePropertyNames
()
public
class
CurveCollectionJsonDb
{
{
return
new
string
[]{
static
Mapper
Mapper
{
get
;
}
=
new
AutoMapper
.
Mapper
(
new
MapperConfiguration
(
c
=>
"CorrectWay"
,
{
"Flag"
,
c
.
CreateMap
<
CurveCollection
,
CurveCollectionJsonDb
>().
ReverseMap
();
"Curves"
};
}));
public
static
bool
Load
(
CurveCollection
src
,
string
filePath
)
{
try
{
if
(
File
.
Exists
(
filePath
))
{
string
json
=
File
.
ReadAllText
(
filePath
);
var
p
=
JsonConvert
.
DeserializeObject
<
CurveCollectionJsonDb
>(
json
);
Mapper
.
Map
(
p
,
src
);
return
true
;
}
}
catch
{
//异常,没有json 解码失败
}
}
#
endregion
return
false
;
}
public
static
bool
Save
(
CurveCollection
src
,
string
filePath
)
{
var
p
=
Mapper
.
Map
<
CurveCollectionJsonDb
>(
src
);
try
{
File
.
WriteAllText
(
filePath
,
JsonConvert
.
SerializeObject
(
p
,
Formatting
.
Indented
));
return
true
;
}
catch
{
//异常,没有json 编码失败
#
region
INotifyPropertyChanged
成员
}
return
false
;
public
event
System
.
ComponentModel
.
PropertyChangedEventHandler
PropertyChanged
;
}
#
endregion
/// <summary>
/// AD曲线校正方式
/// </summary>
public
CurveCorrectWay
CorrectWay
=
CurveCorrectWay
.
OnePointIsScale
;
public
CurveType
Flag
=
CurveType
.
E
;
public
CurveCell
[]
Curves
=
new
CurveCell
[]
{
new
CurveCell
()
{
AD
=
57564
,
Value
=
0
},
new
CurveCell
()
{
AD
=
30850
,
Value
=
8800
},
new
CurveCell
()
{
AD
=
19000
,
Value
=
17600
},
new
CurveCell
()
{
AD
=
12528
,
Value
=
26400
},
new
CurveCell
()
{
AD
=
8409
,
Value
=
35200
},
new
CurveCell
()
{
AD
=
5650
,
Value
=
44000
},
new
CurveCell
()
{
AD
=
3779
,
Value
=
52800
},
new
CurveCell
()
{
AD
=
2513
,
Value
=
61600
},
new
CurveCell
()
{
AD
=
1660
,
Value
=
70400
}
};
}
}
}
}
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